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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.chrome.browser.identity;
6
7 import android.test.InstrumentationTestCase;
8 import android.test.suitebuilder.annotation.SmallTest;
9
10 import org.chromium.base.test.util.Feature;
11
12 import javax.annotation.Nullable;
13
14 public class UniqueIdentificationGeneratorFactoryTest extends InstrumentationTes tCase {
15
16 @SmallTest
17 @Feature({"ChromeToMobile", "Omaha", "Sync"})
18 public void testSetAndGetGenerator() {
19 UniqueIdentificationGeneratorFactory.clearGeneratorMapForTest();
20 UniqueIdentificationGenerator gen = new TestGenerator();
21 UniqueIdentificationGeneratorFactory.registerGenerator("generator", gen, false);
22 assertEquals(gen, UniqueIdentificationGeneratorFactory.getInstance("gene rator"));
23 }
24
25 @SmallTest
26 @Feature({"ChromeToMobile", "Omaha", "Sync"})
27 public void testForceCanOverrideGenerator() {
28 UniqueIdentificationGeneratorFactory.clearGeneratorMapForTest();
29 UniqueIdentificationGenerator gen1 = new TestGenerator();
30 UniqueIdentificationGenerator gen2 = new TestGenerator();
31 UniqueIdentificationGenerator gen3 = new TestGenerator();
32 UniqueIdentificationGeneratorFactory.registerGenerator("generator", gen1 , false);
33 assertEquals(gen1, UniqueIdentificationGeneratorFactory.getInstance("gen erator"));
34 UniqueIdentificationGeneratorFactory.registerGenerator("generator", gen2 , false);
35 assertEquals(gen1, UniqueIdentificationGeneratorFactory.getInstance("gen erator"));
36 UniqueIdentificationGeneratorFactory.registerGenerator("generator", gen3 , true);
37 assertEquals(gen3, UniqueIdentificationGeneratorFactory.getInstance("gen erator"));
38 }
39
40 @SmallTest
41 @Feature({"ChromeToMobile", "Omaha", "Sync"})
42 public void testGeneratorNotFoundThrows() {
43 UniqueIdentificationGeneratorFactory.clearGeneratorMapForTest();
44 UniqueIdentificationGenerator generator = null;
45 try {
46 generator = UniqueIdentificationGeneratorFactory.getInstance("genera tor");
47 fail("The generator does not exist, so factory should throw an error .");
48 } catch (RuntimeException e) {
49 assertEquals(null, generator);
50 }
51 }
52
53 private static class TestGenerator implements UniqueIdentificationGenerator {
54 @Override
55 public String getUniqueId(@Nullable String salt) {
56 return null;
57 }
58 }
59 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698