Commit e5553504 authored by Marc Treib's avatar Marc Treib Committed by Chromium LUCI CQ

Rename isSyncActive to isSyncFeatureActive in ProfileSyncService.java

This aligns the name with the native SyncService.

Also rename SyncTestUtil.isSyncActive()/waitForSyncActive() to
isSyncFeatureActive()/waitForSyncFeatureActive() for consistency.

Bug: 985290
Change-Id: I6383e8bd6bdf3b0767fdd7f5e3c3c4b49292d82d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2644938
Commit-Queue: Marc Treib <treib@chromium.org>
Reviewed-by: default avatarVictor Vianna <victorvianna@google.com>
Cr-Commit-Position: refs/heads/master@{#846133}
parent cfedc527
......@@ -163,8 +163,8 @@ public class ProfileSyncService {
*
* @return true if Sync is active, false otherwise.
*/
public boolean isSyncActive() {
return ProfileSyncServiceJni.get().isSyncActive(
public boolean isSyncFeatureActive() {
return ProfileSyncServiceJni.get().isSyncFeatureActive(
mNativeProfileSyncServiceAndroid, ProfileSyncService.this);
}
......@@ -729,7 +729,8 @@ public class ProfileSyncService {
boolean isSyncRequested(long nativeProfileSyncServiceAndroid, ProfileSyncService caller);
boolean canSyncFeatureStart(
long nativeProfileSyncServiceAndroid, ProfileSyncService caller);
boolean isSyncActive(long nativeProfileSyncServiceAndroid, ProfileSyncService caller);
boolean isSyncFeatureActive(
long nativeProfileSyncServiceAndroid, ProfileSyncService caller);
boolean isSyncDisabledByEnterprisePolicy(
long nativeProfileSyncServiceAndroid, ProfileSyncService caller);
boolean hasKeepEverythingSynced(
......
......@@ -233,7 +233,7 @@ public class SyncSettingsUtils {
: context.getString(R.string.sync_is_disabled);
}
if (!profileSyncService.isSyncActive()) {
if (!profileSyncService.isSyncFeatureActive()) {
return context.getString(R.string.sync_setup_progress);
}
......
......@@ -108,7 +108,7 @@ import java.io.IOException;
Assert.assertEquals("InfoBar should not be shown before signing in", 0,
mSyncTestRule.getInfoBars().size());
mSyncTestRule.setUpAccountAndEnableSyncForTesting();
SyncTestUtil.waitForSyncActive();
SyncTestUtil.waitForSyncFeatureActive();
mFakeProfileSyncService.setEngineInitialized(true);
mFakeProfileSyncService.setAuthError(GoogleServiceAuthError.State.NONE);
mFakeProfileSyncService.setPassphraseRequiredForPreferredDataTypes(false);
......
......@@ -186,7 +186,7 @@ public class MainSettingsFragmentTest {
// Sign in and render changes.
mSyncTestRule.setUpAccountAndEnableSyncForTesting();
SyncTestUtil.waitForSyncActive();
SyncTestUtil.waitForSyncFeatureActive();
mRenderTestRule.render(view, "main_settings_signed_in");
}
......@@ -214,7 +214,7 @@ public class MainSettingsFragmentTest {
// Sign in and render changes.
mSyncTestRule.setUpAccountAndEnableSyncForTesting();
SyncTestUtil.waitForSyncActive();
SyncTestUtil.waitForSyncFeatureActive();
mRenderTestRule.render(view, "main_settings_signed_in_mobile_identity_consistency");
}
......@@ -234,7 +234,7 @@ public class MainSettingsFragmentTest {
// Sign in and render changes.
mSyncTestRule.setUpAccountAndEnableSyncForTesting();
SyncTestUtil.waitForSyncActive();
SyncTestUtil.waitForSyncFeatureActive();
mRenderTestRule.render(view, "main_settings_signed_in_safety_check");
}
......@@ -264,7 +264,7 @@ public class MainSettingsFragmentTest {
// Sign in and render changes.
mSyncTestRule.setUpAccountAndEnableSyncForTesting();
SyncTestUtil.waitForSyncActive();
SyncTestUtil.waitForSyncFeatureActive();
mRenderTestRule.render(
view, "main_settings_signed_in_safety_check_mobile_identity_consistency");
}
......@@ -456,7 +456,7 @@ public class MainSettingsFragmentTest {
// SignIn to see the changes
mSyncTestRule.setUpAccountAndEnableSyncForTesting();
SyncTestUtil.waitForSyncActive();
SyncTestUtil.waitForSyncFeatureActive();
SignInPreference signInPreference =
(SignInPreference) assertSettingsExists(MainSettings.PREF_SIGN_IN, null);
Assert.assertEquals("SignInPreference should be at the signed in state. ",
......@@ -487,7 +487,7 @@ public class MainSettingsFragmentTest {
// SignIn to see the changes
mSyncTestRule.setUpAccountAndEnableSyncForTesting();
SyncTestUtil.waitForSyncActive();
SyncTestUtil.waitForSyncFeatureActive();
SignInPreference signInPreference =
(SignInPreference) assertSettingsExists(MainSettings.PREF_SIGN_IN, null);
Assert.assertEquals("SignInPreference should be at the signed in state. ",
......
......@@ -146,7 +146,7 @@ public class FirstRunTest {
processFirstRun(testAccountInfo.getEmail(), false /* ShowSettings */);
Assert.assertEquals(testAccountInfo, mSyncTestRule.getCurrentSignedInAccount());
SyncTestUtil.waitForSyncActive();
SyncTestUtil.waitForSyncFeatureActive();
}
// Test that signing in and opening settings through FirstRun signs in and doesn't fully start
......@@ -166,7 +166,7 @@ public class FirstRunTest {
// become fully active until the settings page is closed.
Assert.assertEquals(testAccountInfo, mSyncTestRule.getCurrentSignedInAccount());
SyncTestUtil.waitForEngineInitialized();
Assert.assertFalse(SyncTestUtil.isSyncActive());
Assert.assertFalse(SyncTestUtil.isSyncFeatureActive());
// Close the settings fragment.
AccountManagementFragment fragment =
......@@ -175,7 +175,7 @@ public class FirstRunTest {
settingsActivity.getSupportFragmentManager().beginTransaction().remove(fragment).commit();
// Sync should immediately become active.
Assert.assertTrue(SyncTestUtil.isSyncActive());
Assert.assertTrue(SyncTestUtil.isSyncFeatureActive());
}
// Test that not signing in through FirstRun does not sign in sync.
......
......@@ -109,7 +109,7 @@ public class ManageSyncSettingsTest {
@Feature({"Sync"})
public void testSyncEverythingAndDataTypes() {
mSyncTestRule.setUpAccountAndEnableSyncForTesting();
SyncTestUtil.waitForSyncActive();
SyncTestUtil.waitForSyncFeatureActive();
ManageSyncSettings fragment = startManageSyncPreferences();
ChromeSwitchPreference syncEverything = getSyncEverything(fragment);
Collection<CheckBoxPreference> dataTypes = getDataTypes(fragment).values();
......@@ -129,7 +129,7 @@ public class ManageSyncSettingsTest {
@Feature({"Sync"})
public void testSettingDataTypes() {
mSyncTestRule.setUpAccountAndEnableSyncForTesting();
SyncTestUtil.waitForSyncActive();
SyncTestUtil.waitForSyncFeatureActive();
ManageSyncSettings fragment = startManageSyncPreferences();
ChromeSwitchPreference syncEverything = getSyncEverything(fragment);
Map<Integer, CheckBoxPreference> dataTypes = getDataTypes(fragment);
......@@ -162,7 +162,7 @@ public class ManageSyncSettingsTest {
@Features.EnableFeatures(ChromeFeatureList.MOBILE_IDENTITY_CONSISTENCY)
public void testUnsettingAllDataTypesStopsSync() {
mSyncTestRule.setUpAccountAndEnableSyncForTesting();
SyncTestUtil.waitForSyncActive();
SyncTestUtil.waitForSyncFeatureActive();
ManageSyncSettings fragment = startManageSyncPreferences();
assertSyncOnState(fragment);
......@@ -418,7 +418,7 @@ public class ManageSyncSettingsTest {
@Feature({"Sync"})
public void testChoosePassphraseTypeWhenSyncIsOff() {
mSyncTestRule.setUpAccountAndEnableSyncForTesting();
SyncTestUtil.waitForSyncActive();
SyncTestUtil.waitForSyncFeatureActive();
ManageSyncSettings fragment = startManageSyncPreferences();
Preference encryption = getEncryption(fragment);
clickPreference(encryption);
......@@ -439,7 +439,7 @@ public class ManageSyncSettingsTest {
@Feature({"Sync"})
public void testEnterPassphraseWhenSyncIsOff() {
mSyncTestRule.setUpAccountAndEnableSyncForTesting();
SyncTestUtil.waitForSyncActive();
SyncTestUtil.waitForSyncFeatureActive();
final ManageSyncSettings fragment = startManageSyncPreferences();
mSyncTestRule.stopSync();
TestThreadUtils.runOnUiThreadBlockingNoException(
......@@ -452,7 +452,7 @@ public class ManageSyncSettingsTest {
@Feature({"Sync"})
public void testPassphraseCreation() {
mSyncTestRule.setUpAccountAndEnableSyncForTesting();
SyncTestUtil.waitForSyncActive();
SyncTestUtil.waitForSyncFeatureActive();
final ManageSyncSettings fragment = startManageSyncPreferences();
TestThreadUtils.runOnUiThreadBlocking(
() -> fragment.onPassphraseTypeSelected(PassphraseType.CUSTOM_PASSPHRASE));
......@@ -551,7 +551,7 @@ public class ManageSyncSettingsTest {
@Features.EnableFeatures(ChromeFeatureList.MOBILE_IDENTITY_CONSISTENCY)
public void testAdvancedSyncFlowPreferencesAndBottomBarShown() {
mSyncTestRule.setUpAccountAndEnableSyncForTesting();
SyncTestUtil.waitForSyncActive();
SyncTestUtil.waitForSyncFeatureActive();
final ManageSyncSettings fragment = startManageSyncPreferencesFromSyncConsentFlow();
Assert.assertTrue(
fragment.findPreference(ManageSyncSettings.PREF_SYNCING_CATEGORY).isVisible());
......@@ -568,7 +568,7 @@ public class ManageSyncSettingsTest {
@Features.EnableFeatures(ChromeFeatureList.MOBILE_IDENTITY_CONSISTENCY)
public void testAdvancedSyncFlowTopView() throws Exception {
mSyncTestRule.setUpAccountAndEnableSyncForTesting();
SyncTestUtil.waitForSyncActive();
SyncTestUtil.waitForSyncFeatureActive();
final ManageSyncSettings fragment = startManageSyncPreferencesFromSyncConsentFlow();
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
mRenderTestRule.render(fragment.getView(), "advanced_sync_flow_top_view");
......@@ -580,7 +580,7 @@ public class ManageSyncSettingsTest {
@Features.EnableFeatures(ChromeFeatureList.MOBILE_IDENTITY_CONSISTENCY)
public void testAdvancedSyncFlowBottomView() throws Exception {
mSyncTestRule.setUpAccountAndEnableSyncForTesting();
SyncTestUtil.waitForSyncActive();
SyncTestUtil.waitForSyncFeatureActive();
final ManageSyncSettings fragment = startManageSyncPreferencesFromSyncConsentFlow();
TestThreadUtils.runOnUiThreadBlocking(() -> {
RecyclerView recyclerView = fragment.getView().findViewById(R.id.recycler_view);
......
......@@ -59,7 +59,7 @@ public class ManageSyncSettingsWithFakeProfileSyncServiceTest {
(FakeProfileSyncService) mSyncTestRule.getProfileSyncService();
mSyncTestRule.setUpAccountAndEnableSyncForTesting();
SyncTestUtil.waitForSyncActive();
SyncTestUtil.waitForSyncFeatureActive();
// Trigger PassphraseDialogFragment to be shown when taping on Encryption.
fakeProfileSyncService.setPassphraseRequiredForPreferredDataTypes(true);
......
......@@ -64,7 +64,7 @@ public class SyncAndServicesSettingsTest {
@Feature({"Sync", "Preferences"})
public void testSyncSwitch() {
mSyncTestRule.setUpAccountAndEnableSyncForTesting();
SyncTestUtil.waitForSyncActive();
SyncTestUtil.waitForSyncFeatureActive();
SyncAndServicesSettings fragment = startSyncAndServicesPreferences();
final ChromeSwitchPreference syncSwitch = getSyncSwitch(fragment);
......@@ -125,7 +125,7 @@ public class SyncAndServicesSettingsTest {
@Feature({"Sync", "Preferences"})
public void testDefaultControlStatesWithSyncOnThenOff() {
mSyncTestRule.setUpAccountAndEnableSyncForTesting();
SyncTestUtil.waitForSyncActive();
SyncTestUtil.waitForSyncFeatureActive();
SyncAndServicesSettings fragment = startSyncAndServicesPreferences();
assertSyncOnState(fragment);
mSyncTestRule.togglePreference(getSyncSwitch(fragment));
......
......@@ -45,7 +45,7 @@ public class SyncAndServicesSettingsWithFakeProfileSyncServiceTest {
FakeProfileSyncService fakeProfileSyncService =
(FakeProfileSyncService) mSyncTestRule.getProfileSyncService();
mSyncTestRule.setUpAccountAndEnableSyncForTesting();
SyncTestUtil.waitForSyncActive();
SyncTestUtil.waitForSyncFeatureActive();
fakeProfileSyncService.setEngineInitialized(true);
fakeProfileSyncService.setTrustedVaultKeyRequiredForPreferredDataTypes(true);
......
......@@ -59,7 +59,7 @@ public class SyncTest {
// Signing back in should re-enable sync.
mSyncTestRule.signinAndEnableSync(accountInfo);
Assert.assertTrue("Sync should be re-enabled.", SyncTestUtil.isSyncActive());
Assert.assertTrue("Sync should be re-enabled.", SyncTestUtil.isSyncFeatureActive());
}
@Test
......@@ -132,7 +132,7 @@ public class SyncTest {
Criteria.checkThat(mSyncTestRule.getCurrentSignedInAccount().getEmail(),
Matchers.is(newAccount.name));
});
SyncTestUtil.waitForSyncActive();
SyncTestUtil.waitForSyncFeatureActive();
}
@Test
......@@ -166,7 +166,7 @@ public class SyncTest {
// Enabling Android sync should turn Chrome sync engine on.
mSyncTestRule.getSyncContentResolver().setSyncAutomatically(account, authority, true);
SyncTestUtil.waitForSyncActive();
SyncTestUtil.waitForSyncFeatureActive();
}
@Test
......@@ -187,7 +187,7 @@ public class SyncTest {
// Enabling Android's master sync should turn Chrome sync engine on.
mSyncTestRule.getSyncContentResolver().setMasterSyncAutomatically(true);
SyncTestUtil.waitForSyncActive();
SyncTestUtil.waitForSyncFeatureActive();
}
@Test
......@@ -223,7 +223,7 @@ public class SyncTest {
// But then re-enabling Chrome sync should.
mSyncTestRule.getSyncContentResolver().setSyncAutomatically(account, authority, true);
Assert.assertTrue(SyncTestUtil.canSyncFeatureStart());
SyncTestUtil.waitForSyncActive();
SyncTestUtil.waitForSyncFeatureActive();
}
@Test
......@@ -258,7 +258,7 @@ public class SyncTest {
// But then re-enabling master sync should.
mSyncTestRule.getSyncContentResolver().setMasterSyncAutomatically(true);
Assert.assertTrue(SyncTestUtil.canSyncFeatureStart());
SyncTestUtil.waitForSyncActive();
SyncTestUtil.waitForSyncFeatureActive();
}
@Test
......
......@@ -207,7 +207,7 @@ public class SyncTestRule extends ChromeTabbedActivityTestRule {
mAccountManagerTestRule.addTestAccountThenSigninAndEnableSync(mProfileSyncService);
// Enable UKM when enabling sync as it is done by the sync confirmation UI.
enableUKM();
SyncTestUtil.waitForSyncActive();
SyncTestUtil.waitForSyncFeatureActive();
SyncTestUtil.triggerSyncAndWaitForCompletion();
return accountInfo;
}
......@@ -240,7 +240,7 @@ public class SyncTestRule extends ChromeTabbedActivityTestRule {
public void startSyncAndWait() {
startSync();
SyncTestUtil.waitForSyncActive();
SyncTestUtil.waitForSyncFeatureActive();
}
public void stopSync() {
......@@ -253,7 +253,7 @@ public class SyncTestRule extends ChromeTabbedActivityTestRule {
SigninTestUtil.signinAndEnableSync(accountInfo, mProfileSyncService);
// Enable UKM when enabling sync as it is done by the sync confirmation UI.
enableUKM();
SyncTestUtil.waitForSyncActive();
SyncTestUtil.waitForSyncFeatureActive();
SyncTestUtil.triggerSyncAndWaitForCompletion();
}
......
......@@ -151,7 +151,7 @@ void ProfileSyncServiceAndroid::SetSyncAllowedByPlatform(
sync_service_->GetUserSettings()->SetSyncAllowedByPlatform(allowed);
}
jboolean ProfileSyncServiceAndroid::IsSyncActive(
jboolean ProfileSyncServiceAndroid::IsSyncFeatureActive(
JNIEnv* env,
const JavaParamRef<jobject>& obj) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
......
......@@ -50,8 +50,8 @@ class ProfileSyncServiceAndroid : public syncer::SyncServiceObserver {
void SetSyncAllowedByPlatform(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj,
jboolean allowed);
jboolean IsSyncActive(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj);
jboolean IsSyncFeatureActive(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj);
jboolean IsSyncDisabledByEnterprisePolicy(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj);
......
......@@ -61,23 +61,23 @@ public final class SyncTestUtil {
}
/**
* Returns whether sync is active.
* Returns whether sync-the-feature is active.
*/
public static boolean isSyncActive() {
public static boolean isSyncFeatureActive() {
return TestThreadUtils.runOnUiThreadBlockingNoException(new Callable<Boolean>() {
@Override
public Boolean call() {
return ProfileSyncService.get().isSyncActive();
return ProfileSyncService.get().isSyncFeatureActive();
}
});
}
/**
* Waits for sync to become active.
* Waits for sync-the-feature to become active.
*/
public static void waitForSyncActive() {
public static void waitForSyncFeatureActive() {
CriteriaHelper.pollUiThread(()
-> ProfileSyncService.get().isSyncActive(),
-> ProfileSyncService.get().isSyncFeatureActive(),
"Timed out waiting for sync to become active.", TIMEOUT_MS, INTERVAL_MS);
}
......
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