-
Notifications
You must be signed in to change notification settings - Fork 894
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd01a46
commit 421afb8
Showing
3 changed files
with
102 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
android/javatests/org/chromium/chrome/browser/sync/BraveManageSyncSettingsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* Copyright (c) 2020 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
package org.chromium.chrome.browser.sync; | ||
|
||
import androidx.preference.Preference; | ||
import androidx.test.filters.SmallTest; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import org.chromium.base.test.util.CommandLineFlags; | ||
import org.chromium.base.test.util.DoNotBatch; | ||
import org.chromium.base.test.util.Feature; | ||
import org.chromium.base.test.util.Features.DisableFeatures; | ||
import org.chromium.chrome.browser.flags.ChromeFeatureList; | ||
import org.chromium.chrome.browser.flags.ChromeSwitches; | ||
import org.chromium.chrome.browser.settings.SettingsActivity; | ||
import org.chromium.chrome.browser.settings.SettingsActivityTestRule; | ||
import org.chromium.chrome.browser.sync.settings.BraveManageSyncSettings; | ||
import org.chromium.chrome.browser.sync.settings.ManageSyncSettings; | ||
import org.chromium.chrome.test.ChromeJUnit4ClassRunner; | ||
import org.chromium.components.browser_ui.settings.ChromeSwitchPreference; | ||
|
||
/** Tests for BraveManageSyncSettings. */ | ||
@RunWith(ChromeJUnit4ClassRunner.class) | ||
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE}) | ||
@DoNotBatch(reason = "TODO(crbug.com/40743432): SyncTestRule doesn't support batching.") | ||
public class BraveManageSyncSettingsTest { | ||
private SettingsActivity mSettingsActivity; | ||
|
||
private final SettingsActivityTestRule<BraveManageSyncSettings> mSettingsActivityTestRule = | ||
new SettingsActivityTestRule<>(BraveManageSyncSettings.class); | ||
|
||
@Before | ||
public void setUp() {} | ||
|
||
@Test | ||
@SmallTest | ||
@Feature({"Sync"}) | ||
@DisableFeatures({ChromeFeatureList.REPLACE_SYNC_PROMOS_WITH_SIGN_IN_PROMOS}) | ||
public void syncEverythingOrPasswordsHandlerIsOriginalOnChromeOS() { | ||
syncEverythingOrPasswordsOverridden(true, false); | ||
} | ||
|
||
@Test | ||
@SmallTest | ||
@Feature({"Sync"}) | ||
@DisableFeatures({ChromeFeatureList.REPLACE_SYNC_PROMOS_WITH_SIGN_IN_PROMOS}) | ||
public void syncEverythingOrPasswordsHandlerOverriddenOnNonChromeOS() { | ||
syncEverythingOrPasswordsOverridden(false, true); | ||
} | ||
|
||
void syncEverythingOrPasswordsOverridden( | ||
Boolean isChromeOS, Boolean handlerShouldBeOverridden) { | ||
BraveManageSyncSettings.setIsRunningOnChromeOSForTesting(isChromeOS); | ||
BraveManageSyncSettings fragment = startManageSyncPreferences(); | ||
|
||
ChromeSwitchPreference prefSyncPasswords = | ||
fragment.findPreference(ManageSyncSettings.PREF_SYNC_PASSWORDS); | ||
ChromeSwitchPreference syncEverything = | ||
fragment.findPreference(ManageSyncSettings.PREF_SYNC_EVERYTHING); | ||
|
||
Preference.OnPreferenceChangeListener origSyncPasswordsListner = | ||
prefSyncPasswords.getOnPreferenceChangeListener(); | ||
Preference.OnPreferenceChangeListener origSyncEverythingListner = | ||
syncEverything.getOnPreferenceChangeListener(); | ||
|
||
Assert.assertEquals( | ||
handlerShouldBeOverridden, | ||
origSyncPasswordsListner != (Preference.OnPreferenceChangeListener) fragment); | ||
Assert.assertEquals( | ||
handlerShouldBeOverridden, | ||
origSyncEverythingListner != (Preference.OnPreferenceChangeListener) fragment); | ||
} | ||
|
||
private BraveManageSyncSettings startManageSyncPreferences() { | ||
mSettingsActivity = mSettingsActivityTestRule.startSettingsActivity(); | ||
return mSettingsActivityTestRule.getFragment(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters