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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/identity/UniqueIdentificationGeneratorFactoryTest.java

Issue 12313075: [sync] Upstream the Android ProfileSyncService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 7 years, 9 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: chrome/android/javatests/src/org/chromium/chrome/browser/identity/UniqueIdentificationGeneratorFactoryTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/identity/UniqueIdentificationGeneratorFactoryTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/identity/UniqueIdentificationGeneratorFactoryTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..b2d30a299039b9cc1c5cb5f3b322f6ca9583bacc
--- /dev/null
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/identity/UniqueIdentificationGeneratorFactoryTest.java
@@ -0,0 +1,59 @@
+// Copyright 2013 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.
+
+package org.chromium.chrome.browser.identity;
+
+import android.test.InstrumentationTestCase;
+import android.test.suitebuilder.annotation.SmallTest;
+
+import org.chromium.base.test.util.Feature;
+
+import javax.annotation.Nullable;
+
+public class UniqueIdentificationGeneratorFactoryTest extends InstrumentationTestCase {
+
+ @SmallTest
+ @Feature({"ChromeToMobile", "Omaha", "Sync"})
+ public void testSetAndGetGenerator() {
+ UniqueIdentificationGeneratorFactory.clearGeneratorMapForTest();
+ UniqueIdentificationGenerator gen = new TestGenerator();
+ UniqueIdentificationGeneratorFactory.registerGenerator("generator", gen, false);
+ assertEquals(gen, UniqueIdentificationGeneratorFactory.getInstance("generator"));
+ }
+
+ @SmallTest
+ @Feature({"ChromeToMobile", "Omaha", "Sync"})
+ public void testForceCanOverrideGenerator() {
+ UniqueIdentificationGeneratorFactory.clearGeneratorMapForTest();
+ UniqueIdentificationGenerator gen1 = new TestGenerator();
+ UniqueIdentificationGenerator gen2 = new TestGenerator();
+ UniqueIdentificationGenerator gen3 = new TestGenerator();
+ UniqueIdentificationGeneratorFactory.registerGenerator("generator", gen1, false);
+ assertEquals(gen1, UniqueIdentificationGeneratorFactory.getInstance("generator"));
+ UniqueIdentificationGeneratorFactory.registerGenerator("generator", gen2, false);
+ assertEquals(gen1, UniqueIdentificationGeneratorFactory.getInstance("generator"));
+ UniqueIdentificationGeneratorFactory.registerGenerator("generator", gen3, true);
+ assertEquals(gen3, UniqueIdentificationGeneratorFactory.getInstance("generator"));
+ }
+
+ @SmallTest
+ @Feature({"ChromeToMobile", "Omaha", "Sync"})
+ public void testGeneratorNotFoundThrows() {
+ UniqueIdentificationGeneratorFactory.clearGeneratorMapForTest();
+ UniqueIdentificationGenerator generator = null;
+ try {
+ generator = UniqueIdentificationGeneratorFactory.getInstance("generator");
+ fail("The generator does not exist, so factory should throw an error.");
+ } catch (RuntimeException e) {
+ assertEquals(null, generator);
+ }
+ }
+
+ private static class TestGenerator implements UniqueIdentificationGenerator {
+ @Override
+ public String getUniqueId(@Nullable String salt) {
+ return null;
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698