Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove desktop changes for dayzero flag #26396

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions browser/day_zero_browser_ui_expt/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ source_set("unit_tests") {

deps = [
"//base",
"//brave/components/brave_news/common",
"//brave/components/brave_rewards/common",
"//brave/components/brave_wallet/browser:pref_names",
"//brave/components/ntp_background_images/browser",
"//brave/components/ntp_background_images/common",
"//brave/components/p3a",
"//chrome/browser/ui",
"//chrome/test:test_support",
Expand All @@ -35,7 +30,6 @@ source_set("browser_tests") {

deps = [
"//base",
"//brave/components/brave_rewards/common",
"//chrome/browser",
"//chrome/browser:browser_process",
"//chrome/browser/ui",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "base/test/scoped_feature_list.h"
#include "brave/browser/brave_browser_features.h"
#include "brave/browser/day_zero_browser_ui_expt/pref_names.h"
#include "brave/components/brave_rewards/common/pref_names.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/first_run/first_run.h"
#include "chrome/browser/profiles/profile.h"
Expand Down Expand Up @@ -47,26 +46,6 @@ class DayZeroBrowserUIExptBrowserTest
base::test::ScopedFeatureList feature_list_;
};

IN_PROC_BROWSER_TEST_P(DayZeroBrowserUIExptBrowserTest, InitTest) {
auto* prefs = browser()->profile()->GetPrefs();

const bool button_is_hidden =
!prefs->GetBoolean(brave_rewards::prefs::kShowLocationBarButton);

// We don't apply day-zero experiment to existing users.
if (!IsFirstRun()) {
EXPECT_FALSE(button_is_hidden);
return;
}

// Button is hidden by default when expt feature is enabled.
EXPECT_EQ(IsDayZeroEnabled(), button_is_hidden);
}

INSTANTIATE_TEST_SUITE_P(DayZeroExpt,
DayZeroBrowserUIExptBrowserTest,
testing::Combine(testing::Bool(), testing::Bool()));

class DayZeroBrowserUIExptSecondLaunchBrowserTest
: public InProcessBrowserTest {
public:
Expand All @@ -86,13 +65,3 @@ IN_PROC_BROWSER_TEST_F(DayZeroBrowserUIExptSecondLaunchBrowserTest,
g_browser_process->local_state()->SetBoolean(kDayZeroExperimentTargetInstall,
true);
}

// Check day-zero experiment is stiil applied at non first run if it's applied
// at first run.
IN_PROC_BROWSER_TEST_F(DayZeroBrowserUIExptSecondLaunchBrowserTest,
SecondLaunch) {
auto* prefs = browser()->profile()->GetPrefs();
const bool button_is_hidden =
!prefs->GetBoolean(brave_rewards::prefs::kShowLocationBarButton);
EXPECT_TRUE(button_is_hidden);
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,41 +117,14 @@ void DayZeroBrowserUIExptManager::OnProfileManagerDestroying() {

void DayZeroBrowserUIExptManager::SetForDayZeroBrowserUI(Profile* profile) {
VLOG(2) << __func__ << " Update prefs for day zero expt.";

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's delete header files for these deleted pref names.

auto* prefs = profile->GetPrefs();
prefs->SetDefaultPrefValue(kNewTabPageShowRewards, base::Value(false));
prefs->SetDefaultPrefValue(kNewTabPageShowBraveTalk, base::Value(false));
prefs->SetDefaultPrefValue(kShowWalletIconOnToolbar, base::Value(false));
prefs->SetDefaultPrefValue(brave_rewards::prefs::kShowLocationBarButton,
base::Value(false));
bool should_show_ntp_si_and_news = false;
#if BUILDFLAG(IS_ANDROID)
should_show_ntp_si_and_news = true;
Java_DayZeroHelper_setDayZeroExptAndroid(
base::android::AttachCurrentThread(), false);
#endif // #BUILDFLAG(IS_ANDROID)
prefs->SetDefaultPrefValue(ntp_background_images::prefs::
kNewTabPageShowSponsoredImagesBackgroundImage,
base::Value(should_show_ntp_si_and_news));
prefs->SetDefaultPrefValue(brave_news::prefs::kNewTabPageShowToday,
base::Value(should_show_ntp_si_and_news));
}

void DayZeroBrowserUIExptManager::ResetForDayZeroBrowserUI(Profile* profile) {
VLOG(2) << __func__ << " Update prefs for day zero expt.";

auto* prefs = profile->GetPrefs();
prefs->SetDefaultPrefValue(kNewTabPageShowRewards, base::Value(true));
prefs->SetDefaultPrefValue(kNewTabPageShowBraveTalk, base::Value(true));
prefs->SetDefaultPrefValue(kShowWalletIconOnToolbar, base::Value(true));
prefs->SetDefaultPrefValue(ntp_background_images::prefs::
kNewTabPageShowSponsoredImagesBackgroundImage,
base::Value(true));
prefs->SetDefaultPrefValue(brave_rewards::prefs::kShowLocationBarButton,
base::Value(true));
prefs->SetDefaultPrefValue(
brave_news::prefs::kNewTabPageShowToday,
base::Value(brave_news::IsUserInDefaultEnabledLocale()));
#if BUILDFLAG(IS_ANDROID)
Java_DayZeroHelper_setDayZeroExptAndroid(
base::android::AttachCurrentThread(), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,9 @@ class DayZeroBrowserUIExptTest : public testing::Test,
}
}

void CheckBrowserHasDayZeroUI(Profile* profile) {
auto* prefs = profile->GetPrefs();
EXPECT_FALSE(prefs->GetBoolean(kNewTabPageShowRewards));
EXPECT_FALSE(prefs->GetBoolean(kNewTabPageShowBraveTalk));
EXPECT_FALSE(prefs->GetBoolean(kShowWalletIconOnToolbar));
EXPECT_FALSE(
prefs->GetBoolean(ntp_background_images::prefs::
kNewTabPageShowSponsoredImagesBackgroundImage));
EXPECT_FALSE(
prefs->GetBoolean(brave_rewards::prefs::kShowLocationBarButton));
EXPECT_FALSE(prefs->GetBoolean(brave_news::prefs::kNewTabPageShowToday));
}

void CheckBrowserHasOriginalUI(Profile* profile) {
auto* prefs = profile->GetPrefs();
EXPECT_TRUE(prefs->GetBoolean(kNewTabPageShowRewards));
EXPECT_TRUE(prefs->GetBoolean(kNewTabPageShowBraveTalk));
EXPECT_TRUE(prefs->GetBoolean(kShowWalletIconOnToolbar));
EXPECT_TRUE(
prefs->GetBoolean(ntp_background_images::prefs::
kNewTabPageShowSponsoredImagesBackgroundImage));
EXPECT_TRUE(
prefs->GetBoolean(brave_rewards::prefs::kShowLocationBarButton));
EXPECT_EQ(prefs->GetBoolean(brave_news::prefs::kNewTabPageShowToday),
brave_news::IsUserInDefaultEnabledLocale());
}
// Keeping below methods empty to add future features and test
void CheckBrowserHasDayZeroUI(Profile* profile) {}
void CheckBrowserHasOriginalUI(Profile* profile) {}

bool IsDayZeroEnabled() { return GetParam(); }

Expand All @@ -85,6 +62,7 @@ TEST_P(DayZeroBrowserUIExptTest, PrefsTest) {
auto* profile2 =
testing_profile_manager_.CreateTestingProfile("TestProfile2");

// Add check for DayZero prefs here
if (IsDayZeroEnabled()) {
CheckBrowserHasDayZeroUI(profile);
CheckBrowserHasDayZeroUI(profile2);
Expand Down
Loading