Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Unified Diff: sync/android/javatests/src/org/chromium/sync/notifier/InvalidationServiceTest.java

Issue 22642004: Ensure we never try to register for the object id "NULL" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sync/android/java/src/org/chromium/sync/notifier/InvalidationService.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/android/javatests/src/org/chromium/sync/notifier/InvalidationServiceTest.java
diff --git a/sync/android/javatests/src/org/chromium/sync/notifier/InvalidationServiceTest.java b/sync/android/javatests/src/org/chromium/sync/notifier/InvalidationServiceTest.java
index 0cff98ed214fc2ffd937e96a8f330ec31eb381b3..db27879c47e24bbf0f000a77c758968ff882de72 100644
--- a/sync/android/javatests/src/org/chromium/sync/notifier/InvalidationServiceTest.java
+++ b/sync/android/javatests/src/org/chromium/sync/notifier/InvalidationServiceTest.java
@@ -521,6 +521,70 @@ public class InvalidationServiceTest extends ServiceTestCase<TestableInvalidatio
@SmallTest
@Feature({"Sync"})
+ public void testRegistrationIntentNoProxyTabsUsingReady() {
+ getService().setShouldRunStates(true, true);
+ getService().onCreate();
+
+ // Send register Intent.
+ Account account = AccountManagerHelper.createAccountFromName("test@example.com");
+ Intent registrationIntent = IntentProtocol.createRegisterIntent(account, true, null);
+ getService().onHandleIntent(registrationIntent);
+
+ // Verify client started and state written.
+ assertTrue(InvalidationService.getIsClientStartedForTest());
+ InvalidationPreferences invPrefs = new InvalidationPreferences(getContext());
+ assertEquals(account, invPrefs.getSavedSyncedAccount());
+ assertEquals(ImmutableSet.of(ModelType.ALL_TYPES_TYPE), invPrefs.getSavedSyncedTypes());
+ assertEquals(1, mStartServiceIntents.size());
+ assertTrue(isAndroidListenerStartIntent(mStartServiceIntents.get(0)));
+
+ // Set client to be ready. This triggers registrations.
+ getService().ready(CLIENT_ID);
+ assertTrue(Arrays.equals(CLIENT_ID, InvalidationService.getClientIdForTest()));
+
+ // Ensure registrations are correct.
+ Set<ObjectId> expectedTypes =
+ ModelType.modelTypesToObjectIds(Sets.newHashSet(ModelType.values()));
+ assertEquals(expectedTypes, Sets.newHashSet(getService().mRegistrations.get(0)));
+ }
+
+ @SmallTest
+ @Feature({"Sync"})
+ public void testRegistrationIntentNoProxyTabsAlreadyWithClientId() {
+ getService().setShouldRunStates(true, true);
+ getService().onCreate();
+
+ // Send register Intent with no desired types.
+ Account account = AccountManagerHelper.createAccountFromName("test@example.com");
+ Intent registrationIntent =
+ IntentProtocol.createRegisterIntent(account, false, Sets.<ModelType>newHashSet());
+ getService().onHandleIntent(registrationIntent);
+
+ // Verify client started and state written.
+ assertTrue(InvalidationService.getIsClientStartedForTest());
+ InvalidationPreferences invPrefs = new InvalidationPreferences(getContext());
+ assertEquals(account, invPrefs.getSavedSyncedAccount());
+ assertEquals(Sets.<String>newHashSet(), invPrefs.getSavedSyncedTypes());
+ assertEquals(1, mStartServiceIntents.size());
+ assertTrue(isAndroidListenerStartIntent(mStartServiceIntents.get(0)));
+
+ // Make sure client is ready.
+ getService().ready(CLIENT_ID);
+ assertTrue(Arrays.equals(CLIENT_ID, InvalidationService.getClientIdForTest()));
+
+ // Choose to register for all types in an already ready client.
+ registrationIntent = IntentProtocol.createRegisterIntent(account, true, null);
+ getService().onHandleIntent(registrationIntent);
+
+ // Ensure registrations are correct.
+ assertEquals(1, getService().mRegistrations.size());
+ Set<ObjectId> expectedTypes =
+ ModelType.modelTypesToObjectIds(Sets.newHashSet(ModelType.values()));
+ assertEquals(expectedTypes, Sets.newHashSet(getService().mRegistrations.get(0)));
+ }
+
+ @SmallTest
+ @Feature({"Sync"})
public void testRegistrationIntentWhenClientShouldNotBeRunning() {
/*
* Test plan: send a registration change event when the client should not be running.
« no previous file with comments | « sync/android/java/src/org/chromium/sync/notifier/InvalidationService.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698