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

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

Issue 23643002: Enable invalidations for arbitrary objects on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 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
Index: sync/android/javatests/src/org/chromium/sync/notifier/InvalidationControllerTest.java
diff --git a/sync/android/javatests/src/org/chromium/sync/notifier/InvalidationControllerTest.java b/sync/android/javatests/src/org/chromium/sync/notifier/InvalidationControllerTest.java
index 215430b9a5203e94b4ef78d5b0bc84f249dda4ad..fe7eb092d01fa5c6fcaf89dfb7d1a6be9513699f 100644
--- a/sync/android/javatests/src/org/chromium/sync/notifier/InvalidationControllerTest.java
+++ b/sync/android/javatests/src/org/chromium/sync/notifier/InvalidationControllerTest.java
@@ -13,6 +13,8 @@ import android.content.pm.PackageManager;
import android.test.InstrumentationTestCase;
import android.test.suitebuilder.annotation.SmallTest;
+import com.google.ipc.invalidation.external.client.types.ObjectId;
+
import org.chromium.base.ActivityStatus;
import org.chromium.base.CollectionUtil;
import org.chromium.base.test.util.AdvancedMockContext;
@@ -171,6 +173,7 @@ public class InvalidationControllerTest extends InstrumentationTestCase {
Set<String> actualTypes = new HashSet<String>();
actualTypes.addAll(intent.getStringArrayListExtra(IntentProtocol.EXTRA_REGISTERED_TYPES));
assertEquals(expectedTypes, actualTypes);
+ assertNull(IntentProtocol.getRegisteredObjectIds(intent));
}
@SmallTest
@@ -195,6 +198,7 @@ public class InvalidationControllerTest extends InstrumentationTestCase {
Set<String> actualTypes = new HashSet<String>();
actualTypes.addAll(intent.getStringArrayListExtra(IntentProtocol.EXTRA_REGISTERED_TYPES));
assertEquals(expectedTypes, actualTypes);
+ assertNull(IntentProtocol.getRegisteredObjectIds(intent));
}
@SmallTest
@@ -277,6 +281,29 @@ public class InvalidationControllerTest extends InstrumentationTestCase {
assertEquals(true, resultAllTypes.get());
}
+ @SmallTest
+ @Feature({"Sync"})
+ public void testSetRegisteredObjectIds() {
+ InvalidationController controller = new InvalidationController(mContext);
+ ObjectId bookmark = ModelType.BOOKMARK.toObjectId();
+ controller.setRegisteredObjectIds(new int[] {1, 2, bookmark.getSource()},
+ new String[] {"a", "b", new String(bookmark.getName())});
+ assertEquals(1, mContext.getNumStartedIntents());
+
+ // Validate destination.
+ Intent intent = mContext.getStartedIntent(0);
+ validateIntentComponent(intent);
+ assertEquals(IntentProtocol.ACTION_REGISTER, intent.getAction());
+
+ // Validate registered object ids. The bookmark object should not be registered since it is
+ // a Sync type.
+ assertNull(intent.getStringArrayListExtra(IntentProtocol.EXTRA_REGISTERED_TYPES));
+ Set<ObjectId> objectIds = IntentProtocol.getRegisteredObjectIds(intent);
+ assertEquals(2, objectIds.size());
+ assertTrue(objectIds.contains(ObjectId.newInstance(1, "a".getBytes())));
+ assertTrue(objectIds.contains(ObjectId.newInstance(2, "b".getBytes())));
+ }
+
/**
* Asserts that {@code intent} is destined for the correct component.
*/

Powered by Google App Engine
This is Rietveld 408576698