Commit b138f026 authored by Tanmoy Mollik's avatar Tanmoy Mollik Committed by Commit Bot

[Android][Settings] Show separate sync and services entries in settings

This cl replaces SyncAndServices preference with ManageSync preference
and adds a row for Google services preference. The UI changes are
controlled under MOBILE_IDENTITY_CONSISTENCY flag.

Screenshot: https://crbug.com/1092857#c1

Bug: 1092857
Change-Id: I97ef592e0fd94e9b442764933cf99258b8d6a16b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2279755
Commit-Queue: Tanmoy Mollik <triploblastic@chromium.org>
Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#790923}
parent 557e82d8
...@@ -710,6 +710,7 @@ chrome_java_resources = [ ...@@ -710,6 +710,7 @@ chrome_java_resources = [
"java/res/drawable/ic_full_screen_white_24dp.xml", "java/res/drawable/ic_full_screen_white_24dp.xml",
"java/res/drawable/ic_globe_24dp.xml", "java/res/drawable/ic_globe_24dp.xml",
"java/res/drawable/ic_google_round.xml", "java/res/drawable/ic_google_round.xml",
"java/res/drawable/ic_google_services_48dp.xml",
"java/res/drawable/ic_incognito_24dp.xml", "java/res/drawable/ic_incognito_24dp.xml",
"java/res/drawable/ic_logo_googleg_20dp.xml", "java/res/drawable/ic_logo_googleg_20dp.xml",
"java/res/drawable/ic_loop_round.xml", "java/res/drawable/ic_loop_round.xml",
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2020 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:width="48dp"
android:height="48dp"
android:viewportWidth="40"
android:viewportHeight="40"
tools:targetApi="21">
<path
android:pathData="M19.9998,21.5834V18.4834H27.7998C27.9165,19.0084 28.0082,19.5 28.0082,20.1917C28.0082,24.95 24.8165,28.3334 20.0082,28.3334C15.3998,28.3334 11.6665,24.6 11.6665,20C11.6665,15.4 15.3998,11.6667 19.9998,11.6667C22.2498,11.6667 24.1332,12.4917 25.5748,13.8417L23.2082,16.1417C22.6082,15.575 21.5665,14.9 19.9998,14.9C17.2415,14.9 14.9915,17.1917 14.9915,20C14.9915,22.8084 17.2415,25.1 19.9998,25.1C23.1915,25.1 24.3665,22.8917 24.5832,21.5834H19.9998V21.5834Z"
android:fillColor="@color/modern_grey_700"/>
</vector>
...@@ -4,112 +4,133 @@ ...@@ -4,112 +4,133 @@
found in the LICENSE file. --> found in the LICENSE file. -->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orderingFromXml="false"> android:orderingFromXml="false">
<PreferenceCategory <PreferenceCategory
android:key="account_section" android:key="account_section"
android:order="0" android:order="0"
android:title="@string/prefs_section_account"/> android:title="@string/prefs_section_account"/>
<PreferenceCategory
android:key="account_and_google_services_section"
android:order="1"
android:title="@string/prefs_section_account_and_google_services"
app:isPreferenceVisible="false"/>
<org.chromium.chrome.browser.sync.settings.SignInPreference <org.chromium.chrome.browser.sync.settings.SignInPreference
android:key="sign_in" android:key="sign_in"
android:order="1" android:order="2"
android:title="@string/sign_in_to_chrome"/> android:title="@string/sign_in_to_chrome"/>
<org.chromium.components.browser_ui.settings.ChromeBasePreference <org.chromium.components.browser_ui.settings.ChromeBasePreference
android:key="sync_and_services" android:key="sync_and_services"
android:order="2" android:order="3"
android:layout="@layout/account_management_account_row" android:layout="@layout/account_management_account_row"
android:title="@string/prefs_sync_and_services" android:title="@string/prefs_sync_and_services"
android:fragment="org.chromium.chrome.browser.sync.settings.SyncAndServicesSettings"/> android:fragment="org.chromium.chrome.browser.sync.settings.SyncAndServicesSettings"/>
<!-- manage_sync and google_services replace sync_and_services if MOBILE_IDENTITY_CONSISTENCY
is enabled. -->
<org.chromium.components.browser_ui.settings.ChromeBasePreference
android:key="manage_sync"
android:order="4"
android:title="@string/sync_category_title"
android:fragment="org.chromium.chrome.browser.sync.settings.ManageSyncSettings"
app:isPreferenceVisible="false"/>
<org.chromium.components.browser_ui.settings.ChromeBasePreference
android:key="google_services"
android:order="5"
android:title="@string/services_category_title"
android:icon="@drawable/ic_google_services_48dp"
android:fragment="org.chromium.chrome.browser.sync.settings.GoogleServicesSettings"
app:isPreferenceVisible="false"/>
<PreferenceCategory <PreferenceCategory
android:key="basics_section" android:key="basics_section"
android:order="3" android:order="6"
android:title="@string/prefs_section_basics"/> android:title="@string/prefs_section_basics"/>
<org.chromium.components.browser_ui.settings.ChromeBasePreference <org.chromium.components.browser_ui.settings.ChromeBasePreference
android:fragment="org.chromium.chrome.browser.search_engines.settings.SearchEngineSettings" android:fragment="org.chromium.chrome.browser.search_engines.settings.SearchEngineSettings"
android:key="search_engine" android:key="search_engine"
android:order="4" android:order="7"
android:title="@string/search_engine_settings"/> android:title="@string/search_engine_settings"/>
<org.chromium.components.browser_ui.settings.ChromeBasePreference <org.chromium.components.browser_ui.settings.ChromeBasePreference
android:fragment="org.chromium.chrome.browser.password_manager.settings.PasswordSettings" android:fragment="org.chromium.chrome.browser.password_manager.settings.PasswordSettings"
android:key="passwords" android:key="passwords"
android:order="5" android:order="8"
android:title="@string/password_settings_title"/> android:title="@string/password_settings_title"/>
<org.chromium.components.browser_ui.settings.ChromeBasePreference <org.chromium.components.browser_ui.settings.ChromeBasePreference
android:fragment="org.chromium.chrome.browser.autofill.settings.AutofillPaymentMethodsFragment" android:fragment="org.chromium.chrome.browser.autofill.settings.AutofillPaymentMethodsFragment"
android:key="autofill_payment_methods" android:key="autofill_payment_methods"
android:order="6" android:order="9"
android:title="@string/autofill_payment_methods"/> android:title="@string/autofill_payment_methods"/>
<org.chromium.components.browser_ui.settings.ChromeBasePreference <org.chromium.components.browser_ui.settings.ChromeBasePreference
android:fragment="org.chromium.chrome.browser.autofill.settings.AutofillProfilesFragment" android:fragment="org.chromium.chrome.browser.autofill.settings.AutofillProfilesFragment"
android:key="autofill_addresses" android:key="autofill_addresses"
android:order="7" android:order="10"
android:title="@string/autofill_addresses_settings_title"/> android:title="@string/autofill_addresses_settings_title"/>
<!-- android:order="8" is reserved for "Privacy" behind the privacy-elevated-android flag. --> <!-- android:order="11" is reserved for "Privacy" behind the privacy-elevated-android flag. -->
<Preference <Preference
android:fragment="org.chromium.chrome.browser.safety_check.SafetyCheckSettingsFragment" android:fragment="org.chromium.chrome.browser.safety_check.SafetyCheckSettingsFragment"
android:key="safety_check" android:key="safety_check"
android:order="9" android:order="12"
android:title="@string/prefs_safety_check"/> android:title="@string/prefs_safety_check"/>
<Preference <Preference
android:fragment="org.chromium.chrome.browser.notifications.settings.NotificationSettings" android:fragment="org.chromium.chrome.browser.notifications.settings.NotificationSettings"
android:key="notifications" android:key="notifications"
android:order="10" android:order="13"
android:title="@string/prefs_notifications"/> android:title="@string/prefs_notifications"/>
<Preference <Preference
android:fragment="org.chromium.chrome.browser.homepage.settings.HomepageSettings" android:fragment="org.chromium.chrome.browser.homepage.settings.HomepageSettings"
android:key="homepage" android:key="homepage"
android:order="11" android:order="14"
android:title="@string/options_homepage_title"/> android:title="@string/options_homepage_title"/>
<Preference <Preference
android:fragment="org.chromium.chrome.browser.night_mode.settings.ThemeSettingsFragment" android:fragment="org.chromium.chrome.browser.night_mode.settings.ThemeSettingsFragment"
android:key="ui_theme" android:key="ui_theme"
android:order="12" android:order="15"
android:title="@string/theme_settings" /> android:title="@string/theme_settings" />
<PreferenceCategory <PreferenceCategory
android:key="advanced_section" android:key="advanced_section"
android:order="13" android:order="16"
android:title="@string/prefs_section_advanced"/> android:title="@string/prefs_section_advanced"/>
<Preference <Preference
android:fragment="org.chromium.chrome.browser.privacy.settings.PrivacySettings" android:fragment="org.chromium.chrome.browser.privacy.settings.PrivacySettings"
android:key="privacy" android:key="privacy"
android:order="14" android:order="17"
android:title="@string/prefs_privacy"/> android:title="@string/prefs_privacy"/>
<Preference <Preference
android:fragment="org.chromium.chrome.browser.accessibility.settings.AccessibilitySettings" android:fragment="org.chromium.chrome.browser.accessibility.settings.AccessibilitySettings"
android:key="accessibility" android:key="accessibility"
android:order="15" android:order="18"
android:title="@string/prefs_accessibility"/> android:title="@string/prefs_accessibility"/>
<Preference <Preference
android:fragment="org.chromium.components.browser_ui.site_settings.SiteSettings" android:fragment="org.chromium.components.browser_ui.site_settings.SiteSettings"
android:key="content_settings" android:key="content_settings"
android:order="16" android:order="19"
android:title="@string/prefs_site_settings"/> android:title="@string/prefs_site_settings"/>
<Preference <Preference
android:fragment="org.chromium.chrome.browser.language.settings.LanguageSettings" android:fragment="org.chromium.chrome.browser.language.settings.LanguageSettings"
android:key="languages" android:key="languages"
android:order="17" android:order="20"
android:title="@string/language_settings"/> android:title="@string/language_settings"/>
<org.chromium.components.browser_ui.settings.ChromeBasePreference <org.chromium.components.browser_ui.settings.ChromeBasePreference
android:fragment="org.chromium.chrome.browser.datareduction.settings.DataReductionPreferenceFragment" android:fragment="org.chromium.chrome.browser.datareduction.settings.DataReductionPreferenceFragment"
android:key="data_reduction" android:key="data_reduction"
android:order="18" android:order="21"
android:title="@string/data_reduction_title_lite_mode"/> android:title="@string/data_reduction_title_lite_mode"/>
<org.chromium.components.browser_ui.settings.ChromeBasePreference <org.chromium.components.browser_ui.settings.ChromeBasePreference
android:fragment="org.chromium.chrome.browser.download.settings.DownloadSettings" android:fragment="org.chromium.chrome.browser.download.settings.DownloadSettings"
android:key="downloads" android:key="downloads"
android:order="19" android:order="22"
android:title="@string/menu_downloads"/> android:title="@string/menu_downloads"/>
<Preference <Preference
android:fragment="org.chromium.chrome.browser.tracing.settings.DeveloperSettings" android:fragment="org.chromium.chrome.browser.tracing.settings.DeveloperSettings"
android:key="developer" android:key="developer"
android:order="20" android:order="23"
android:title="Developer options"/> android:title="Developer options"/>
<Preference <Preference
android:fragment="org.chromium.chrome.browser.about_settings.AboutChromeSettings" android:fragment="org.chromium.chrome.browser.about_settings.AboutChromeSettings"
android:key="about_chrome" android:key="about_chrome"
android:order="21" android:order="24"
android:title="@string/prefs_about_chrome"/> android:title="@string/prefs_about_chrome"/>
</PreferenceScreen> </PreferenceScreen>
...@@ -50,8 +50,12 @@ public class MainSettings extends PreferenceFragmentCompat ...@@ -50,8 +50,12 @@ public class MainSettings extends PreferenceFragmentCompat
implements TemplateUrlService.LoadListener, ProfileSyncService.SyncStateChangedListener, implements TemplateUrlService.LoadListener, ProfileSyncService.SyncStateChangedListener,
SigninManager.SignInStateObserver { SigninManager.SignInStateObserver {
public static final String PREF_ACCOUNT_SECTION = "account_section"; public static final String PREF_ACCOUNT_SECTION = "account_section";
public static final String PREF_ACCOUNT_AND_GOOGLE_SERVICES_SECTION =
"account_and_google_services_section";
public static final String PREF_SIGN_IN = "sign_in"; public static final String PREF_SIGN_IN = "sign_in";
public static final String PREF_SYNC_AND_SERVICES = "sync_and_services"; public static final String PREF_SYNC_AND_SERVICES = "sync_and_services";
public static final String PREF_MANAGE_SYNC = "manage_sync";
public static final String PREF_GOOGLE_SERVICES = "google_services";
public static final String PREF_SEARCH_ENGINE = "search_engine"; public static final String PREF_SEARCH_ENGINE = "search_engine";
public static final String PREF_PASSWORDS = "passwords"; public static final String PREF_PASSWORDS = "passwords";
public static final String PREF_HOMEPAGE = "homepage"; public static final String PREF_HOMEPAGE = "homepage";
...@@ -64,12 +68,13 @@ public class MainSettings extends PreferenceFragmentCompat ...@@ -64,12 +68,13 @@ public class MainSettings extends PreferenceFragmentCompat
public static final String PREF_DEVELOPER = "developer"; public static final String PREF_DEVELOPER = "developer";
// Used for elevating the privacy section behind the flag (see crbug.com/1099233). // Used for elevating the privacy section behind the flag (see crbug.com/1099233).
public static final int PRIVACY_ORDER_DEFAULT = 14; public static final int PRIVACY_ORDER_DEFAULT = 17;
public static final int PRIVACY_ORDER_ELEVATED = 8; public static final int PRIVACY_ORDER_ELEVATED = 11;
private final ManagedPreferenceDelegate mManagedPreferenceDelegate; private final ManagedPreferenceDelegate mManagedPreferenceDelegate;
private final Map<String, Preference> mAllPreferences = new HashMap<>(); private final Map<String, Preference> mAllPreferences = new HashMap<>();
private SignInPreference mSignInPreference; private SignInPreference mSignInPreference;
private ChromeBasePreference mManageSync;
public MainSettings() { public MainSettings() {
setHasOptionsMenu(true); setHasOptionsMenu(true);
...@@ -205,6 +210,17 @@ public class MainSettings extends PreferenceFragmentCompat ...@@ -205,6 +210,17 @@ public class MainSettings extends PreferenceFragmentCompat
.setTitle(SafetyCheckSettingsFragment.getSafetyCheckSettingsElementTitle( .setTitle(SafetyCheckSettingsFragment.getSafetyCheckSettingsElementTitle(
getContext())); getContext()));
} }
// Replace the account section header, replace SyncAndServicesSettings with
// ManageSyncSettings and add GoogleServicesSettings row if this flag is enabled.
if (ChromeFeatureList.isEnabled(ChromeFeatureList.MOBILE_IDENTITY_CONSISTENCY)) {
getPreferenceScreen().removePreference(findPreference(PREF_ACCOUNT_SECTION));
getPreferenceScreen().removePreference(findPreference(PREF_SYNC_AND_SERVICES));
findPreference(PREF_ACCOUNT_AND_GOOGLE_SERVICES_SECTION).setVisible(true);
mManageSync.setVisible(true);
findPreference(PREF_GOOGLE_SERVICES).setVisible(true);
}
} }
/** /**
...@@ -218,6 +234,7 @@ public class MainSettings extends PreferenceFragmentCompat ...@@ -218,6 +234,7 @@ public class MainSettings extends PreferenceFragmentCompat
mAllPreferences.put(preference.getKey(), preference); mAllPreferences.put(preference.getKey(), preference);
} }
mSignInPreference = (SignInPreference) mAllPreferences.get(PREF_SIGN_IN); mSignInPreference = (SignInPreference) mAllPreferences.get(PREF_SIGN_IN);
mManageSync = (ChromeBasePreference) findPreference(PREF_MANAGE_SYNC);
} }
private void setManagedPreferenceDelegateForPreference(String key) { private void setManagedPreferenceDelegateForPreference(String key) {
...@@ -234,6 +251,13 @@ public class MainSettings extends PreferenceFragmentCompat ...@@ -234,6 +251,13 @@ public class MainSettings extends PreferenceFragmentCompat
removePreferenceIfPresent(PREF_SIGN_IN); removePreferenceIfPresent(PREF_SIGN_IN);
} }
boolean hasPrimaryAccount = IdentityServicesProvider.get()
.getIdentityManager(Profile.getLastUsedRegularProfile())
.hasPrimaryAccount();
mManageSync.setVisible(
ChromeFeatureList.isEnabled(ChromeFeatureList.MOBILE_IDENTITY_CONSISTENCY)
&& hasPrimaryAccount);
updateSyncAndServicesPreference(); updateSyncAndServicesPreference();
updateSearchEnginePreference(); updateSearchEnginePreference();
...@@ -269,10 +293,12 @@ public class MainSettings extends PreferenceFragmentCompat ...@@ -269,10 +293,12 @@ public class MainSettings extends PreferenceFragmentCompat
} }
private void updateSyncAndServicesPreference() { private void updateSyncAndServicesPreference() {
ChromeBasePreference syncAndServices = ChromeBasePreference preference = findPreference(
(ChromeBasePreference) findPreference(PREF_SYNC_AND_SERVICES); ChromeFeatureList.isEnabled(ChromeFeatureList.MOBILE_IDENTITY_CONSISTENCY)
syncAndServices.setIcon(SyncSettingsUtils.getSyncStatusIcon(getActivity())); ? PREF_MANAGE_SYNC
syncAndServices.setSummary(SyncSettingsUtils.getSyncStatusSummary(getActivity())); : PREF_SYNC_AND_SERVICES);
preference.setIcon(SyncSettingsUtils.getSyncStatusIcon(getActivity()));
preference.setSummary(SyncSettingsUtils.getSyncStatusSummary(getActivity()));
} }
private void updateSearchEnginePreference() { private void updateSearchEnginePreference() {
...@@ -320,8 +346,14 @@ public class MainSettings extends PreferenceFragmentCompat ...@@ -320,8 +346,14 @@ public class MainSettings extends PreferenceFragmentCompat
} }
private void onSignInPreferenceStateChanged() { private void onSignInPreferenceStateChanged() {
// Remove "Account" section header if the personalized sign-in promo is shown. // Remove "Account" section header if the personalized sign-in promo is shown. Remove
if (mSignInPreference.getState() == SignInPreference.State.PERSONALIZED_PROMO) { // "You and Google" section header if the personalized sync promo is shown.
boolean isShowingPersonalizedPromo =
mSignInPreference.getState() == SignInPreference.State.PERSONALIZED_PROMO;
if (ChromeFeatureList.isEnabled(ChromeFeatureList.MOBILE_IDENTITY_CONSISTENCY)) {
findPreference(PREF_ACCOUNT_AND_GOOGLE_SERVICES_SECTION)
.setVisible(!isShowingPersonalizedPromo);
} else if (isShowingPersonalizedPromo) {
removePreferenceIfPresent(PREF_ACCOUNT_SECTION); removePreferenceIfPresent(PREF_ACCOUNT_SECTION);
} else { } else {
addPreferenceIfAbsent(PREF_ACCOUNT_SECTION); addPreferenceIfAbsent(PREF_ACCOUNT_SECTION);
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
package org.chromium.chrome.browser.settings; package org.chromium.chrome.browser.settings;
import android.accounts.Account;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.View; import android.view.View;
...@@ -53,6 +52,7 @@ import org.chromium.chrome.browser.sync.settings.SyncAndServicesSettings; ...@@ -53,6 +52,7 @@ import org.chromium.chrome.browser.sync.settings.SyncAndServicesSettings;
import org.chromium.chrome.browser.tracing.settings.DeveloperSettings; import org.chromium.chrome.browser.tracing.settings.DeveloperSettings;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.util.ChromeRenderTestRule; import org.chromium.chrome.test.util.ChromeRenderTestRule;
import org.chromium.chrome.test.util.browser.Features;
import org.chromium.chrome.test.util.browser.Features.EnableFeatures; import org.chromium.chrome.test.util.browser.Features.EnableFeatures;
import org.chromium.chrome.test.util.browser.sync.SyncTestUtil; import org.chromium.chrome.test.util.browser.sync.SyncTestUtil;
import org.chromium.components.browser_ui.site_settings.SiteSettings; import org.chromium.components.browser_ui.site_settings.SiteSettings;
...@@ -195,6 +195,58 @@ public class MainSettingsFragmentTest { ...@@ -195,6 +195,58 @@ public class MainSettingsFragmentTest {
assertSettingsExists("about_chrome", AboutChromeSettings.class); assertSettingsExists("about_chrome", AboutChromeSettings.class);
} }
/**
* Test for the "Account" section.
*/
@Test
@SmallTest
@Features.EnableFeatures({ChromeFeatureList.MOBILE_IDENTITY_CONSISTENCY})
public void testStartupWithMobileIdentityConsistency() {
launchSettingsActivity();
// For non-signed-in users, the section contains the generic header.
assertSettingsExists(MainSettings.PREF_SIGN_IN, null);
Assert.assertTrue("Google services preference should be shown",
mMainSettings.findPreference(MainSettings.PREF_GOOGLE_SERVICES).isVisible());
// SignInPreference status check.
// As the user is not signed in, sign in promo will show, section header and sync preference
// will be hidden.
Assert.assertFalse("Account section header should be hidden.",
mMainSettings.findPreference(MainSettings.PREF_ACCOUNT_AND_GOOGLE_SERVICES_SECTION)
.isVisible());
Assert.assertFalse("Sync preference should be hidden",
mMainSettings.findPreference(MainSettings.PREF_MANAGE_SYNC).isVisible());
// Assert for "Basics" section
assertSettingsExists(MainSettings.PREF_SEARCH_ENGINE, SearchEngineSettings.class);
assertSettingsExists(MainSettings.PREF_PASSWORDS, PasswordSettings.class);
assertSettingsExists("autofill_payment_methods", AutofillPaymentMethodsFragment.class);
assertSettingsExists("autofill_addresses", AutofillProfilesFragment.class);
assertSettingsExists(MainSettings.PREF_NOTIFICATIONS, NotificationSettings.class);
assertSettingsExists(MainSettings.PREF_HOMEPAGE, HomepageSettings.class);
assertSettingsExists(MainSettings.PREF_UI_THEME, ThemeSettingsFragment.class);
// Verification for summary for the search engine and the homepage
Assert.assertEquals("Homepage summary is different than homepage state",
mMainSettings.getString(R.string.text_on),
mMainSettings.findPreference(MainSettings.PREF_HOMEPAGE).getSummary().toString());
// Assert for advanced section
assertSettingsExists("privacy", PrivacySettings.class);
// Safety check should be hidden with the flag off.
Assert.assertNull("Safety check section should be hidden",
mMainSettings.findPreference(MainSettings.PREF_SAFETY_CHECK));
assertSettingsExists("accessibility", AccessibilitySettings.class);
assertSettingsExists("content_settings", SiteSettings.class);
assertSettingsExists("languages", LanguageSettings.class);
assertSettingsExists(
MainSettings.PREF_DATA_REDUCTION, DataReductionPreferenceFragment.class);
assertSettingsExists(MainSettings.PREF_DOWNLOADS, DownloadSettings.class);
assertSettingsExists(MainSettings.PREF_DEVELOPER, DeveloperSettings.class);
assertSettingsExists("about_chrome", AboutChromeSettings.class);
}
@Test @Test
@SmallTest @SmallTest
@EnableFeatures(ChromeFeatureList.SAFETY_CHECK_ANDROID) @EnableFeatures(ChromeFeatureList.SAFETY_CHECK_ANDROID)
...@@ -247,9 +299,6 @@ public class MainSettingsFragmentTest { ...@@ -247,9 +299,6 @@ public class MainSettingsFragmentTest {
@Test @Test
@SmallTest @SmallTest
public void testAccountSignIn() { public void testAccountSignIn() {
Account account = mSyncTestRule.setUpAccountAndSignInForTesting();
mSyncTestRule.signOut();
launchSettingsActivity(); launchSettingsActivity();
SignInPreference signInPreference = SignInPreference signInPreference =
...@@ -260,14 +309,45 @@ public class MainSettingsFragmentTest { ...@@ -260,14 +309,45 @@ public class MainSettingsFragmentTest {
mMainSettings.findPreference(MainSettings.PREF_ACCOUNT_SECTION)); mMainSettings.findPreference(MainSettings.PREF_ACCOUNT_SECTION));
// SignIn to see the changes // SignIn to see the changes
mSyncTestRule.signinAndEnableSync(account); mSyncTestRule.setUpAccountAndSignInForTesting();
SyncTestUtil.waitForSyncActive(); SyncTestUtil.waitForSyncActive();
Assert.assertEquals("SignInPreference should be at the personalized promo state. ", Assert.assertEquals("SignInPreference should be at the signed in state. ",
signInPreference.getState(), State.SIGNED_IN); signInPreference.getState(), State.SIGNED_IN);
Assert.assertNotNull("Account section header should appear when user signed in.", Assert.assertNotNull("Account section header should appear when user signed in.",
mMainSettings.findPreference(MainSettings.PREF_ACCOUNT_SECTION)); mMainSettings.findPreference(MainSettings.PREF_ACCOUNT_SECTION));
} }
/**
* Test when the sign-in preference is the promo. The section header should be hidden.
*/
@Test
@SmallTest
@Features.EnableFeatures({ChromeFeatureList.MOBILE_IDENTITY_CONSISTENCY})
public void testAccountSignInWithMobileIdentityConsistency() throws InterruptedException {
launchSettingsActivity();
SignInPreference signInPreference =
(SignInPreference) assertSettingsExists(MainSettings.PREF_SIGN_IN, null);
Assert.assertEquals("SignInPreference should be at the personalized promo state. ",
signInPreference.getState(), State.PERSONALIZED_PROMO);
Assert.assertFalse("Account section header should be hidden when promo is shown.",
mMainSettings.findPreference(MainSettings.PREF_ACCOUNT_AND_GOOGLE_SERVICES_SECTION)
.isVisible());
Assert.assertFalse("Sync preference should be hidden when promo is shown.",
mMainSettings.findPreference(MainSettings.PREF_MANAGE_SYNC).isVisible());
// SignIn to see the changes
mSyncTestRule.setUpAccountAndSignInForTesting();
SyncTestUtil.waitForSyncActive();
Assert.assertEquals("SignInPreference should be at the signed in state. ",
signInPreference.getState(), State.SIGNED_IN);
Assert.assertTrue("Account section header should appear when user signed in.",
mMainSettings.findPreference(MainSettings.PREF_ACCOUNT_AND_GOOGLE_SERVICES_SECTION)
.isVisible());
Assert.assertTrue("Sync preference should appear when the user is signed in.",
mMainSettings.findPreference(MainSettings.PREF_MANAGE_SYNC).isVisible());
}
@Test @Test
@SmallTest @SmallTest
public void testRemoveSettings() { public void testRemoveSettings() {
......
...@@ -264,6 +264,9 @@ CHAR-LIMIT guidelines: ...@@ -264,6 +264,9 @@ CHAR-LIMIT guidelines:
<message name="IDS_PREFS_SECTION_ACCOUNT" desc="Title for the group of account-related entries in Settings. [CHAR-LIMIT=32]"> <message name="IDS_PREFS_SECTION_ACCOUNT" desc="Title for the group of account-related entries in Settings. [CHAR-LIMIT=32]">
Account Account
</message> </message>
<message name="IDS_PREFS_SECTION_ACCOUNT_AND_GOOGLE_SERVICES" desc="Title for the group of account-related entries and google services in Settings. [CHAR-LIMIT=32]">
You and Google
</message>
<message name="IDS_SIGN_IN_TO_CHROME" desc="Title for the button to sign in to Chrome using one's Google account. [CHAR-LIMIT=27]"> <message name="IDS_SIGN_IN_TO_CHROME" desc="Title for the button to sign in to Chrome using one's Google account. [CHAR-LIMIT=27]">
Sign in to Chrome Sign in to Chrome
</message> </message>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment