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

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/test/util/ChromeSigninUtilsTest.java

Issue 2766373004: Convert the rest of chrome_public_test_apk InstrumentationTestCases to JUnit4 (Closed)
Patch Set: nits and rebase Created 3 years, 8 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
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/widget/DualControlLayoutTest.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.test.util; 5 package org.chromium.chrome.test.util;
6 6
7 import android.support.test.InstrumentationRegistry;
7 import android.support.test.filters.SmallTest; 8 import android.support.test.filters.SmallTest;
8 import android.test.InstrumentationTestCase; 9
10 import org.junit.After;
11 import org.junit.Assert;
12 import org.junit.Before;
13 import org.junit.Test;
14 import org.junit.runner.RunWith;
9 15
10 import org.chromium.base.test.util.EnormousTest; 16 import org.chromium.base.test.util.EnormousTest;
11 import org.chromium.base.test.util.FlakyTest; 17 import org.chromium.base.test.util.FlakyTest;
12 import org.chromium.base.test.util.Restriction; 18 import org.chromium.base.test.util.Restriction;
19 import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
13 import org.chromium.components.signin.ChromeSigninController; 20 import org.chromium.components.signin.ChromeSigninController;
14 21
15 /** 22 /**
16 * Tests for {@link ChromeSigninUtils}. 23 * Tests for {@link ChromeSigninUtils}.
17 */ 24 */
18 public class ChromeSigninUtilsTest extends InstrumentationTestCase { 25 @RunWith(ChromeJUnit4ClassRunner.class)
26 public class ChromeSigninUtilsTest {
19 private static final String FAKE_ACCOUNT_USERNAME = "test@google.com"; 27 private static final String FAKE_ACCOUNT_USERNAME = "test@google.com";
20 private static final String FAKE_ACCOUNT_PASSWORD = "$3cr3t"; 28 private static final String FAKE_ACCOUNT_PASSWORD = "$3cr3t";
21 private static final String GOOGLE_ACCOUNT_USERNAME = "chromiumforandroid01@ gmail.com"; 29 private static final String GOOGLE_ACCOUNT_USERNAME = "chromiumforandroid01@ gmail.com";
22 private static final String GOOGLE_ACCOUNT_PASSWORD = "chromeforandroid"; 30 private static final String GOOGLE_ACCOUNT_PASSWORD = "chromeforandroid";
23 private static final String GOOGLE_ACCOUNT_TYPE = "mail"; 31 private static final String GOOGLE_ACCOUNT_TYPE = "mail";
24 32
25 private ChromeSigninUtils mSigninUtil; 33 private ChromeSigninUtils mSigninUtil;
26 private ChromeSigninController mSigninController; 34 private ChromeSigninController mSigninController;
27 35
28 @Override 36 @Before
29 public void setUp() throws Exception { 37 public void setUp() throws Exception {
30 super.setUp(); 38 mSigninUtil = new ChromeSigninUtils(InstrumentationRegistry.getInstrumen tation());
31 mSigninUtil = new ChromeSigninUtils(getInstrumentation()); 39 mSigninController = ChromeSigninController.get(
32 mSigninController = ChromeSigninController.get(getInstrumentation().getT argetContext()); 40 InstrumentationRegistry.getInstrumentation().getTargetContext()) ;
33 mSigninController.setSignedInAccountName(null); 41 mSigninController.setSignedInAccountName(null);
34 mSigninUtil.removeAllFakeAccountsFromOs(); 42 mSigninUtil.removeAllFakeAccountsFromOs();
35 mSigninUtil.removeAllGoogleAccountsFromOs(); 43 mSigninUtil.removeAllGoogleAccountsFromOs();
36 } 44 }
37 45
46 @Test
38 @SmallTest 47 @SmallTest
39 public void testActivityIsNotSignedInOnAppOrFakeOSorGoogleOS() { 48 public void testActivityIsNotSignedInOnAppOrFakeOSorGoogleOS() {
40 assertFalse("Should not be signed into app.", 49 Assert.assertFalse("Should not be signed into app.", mSigninController.i sSignedIn());
41 mSigninController.isSignedIn()); 50 Assert.assertFalse("Should not be signed into OS with fake account.",
42 assertFalse("Should not be signed into OS with fake account.",
43 mSigninUtil.isExistingFakeAccountOnOs(FAKE_ACCOUNT_USERNAME)); 51 mSigninUtil.isExistingFakeAccountOnOs(FAKE_ACCOUNT_USERNAME));
44 assertFalse("Should not be signed in on OS with Google account.", 52 Assert.assertFalse("Should not be signed in on OS with Google account.",
45 mSigninUtil.isExistingGoogleAccountOnOs(GOOGLE_ACCOUNT_USERNAME) ); 53 mSigninUtil.isExistingGoogleAccountOnOs(GOOGLE_ACCOUNT_USERNAME) );
46 } 54 }
47 55
56 @Test
48 @SmallTest 57 @SmallTest
49 public void testIsSignedInOnApp() { 58 public void testIsSignedInOnApp() {
50 mSigninUtil.addAccountToApp(FAKE_ACCOUNT_USERNAME); 59 mSigninUtil.addAccountToApp(FAKE_ACCOUNT_USERNAME);
51 assertTrue("Should be signed on app.", 60 Assert.assertTrue("Should be signed on app.", mSigninController.isSigned In());
52 mSigninController.isSignedIn()); 61 Assert.assertFalse("Should not be signed on OS with fake account.",
53 assertFalse("Should not be signed on OS with fake account.",
54 mSigninUtil.isExistingFakeAccountOnOs(FAKE_ACCOUNT_USERNAME)); 62 mSigninUtil.isExistingFakeAccountOnOs(FAKE_ACCOUNT_USERNAME));
55 assertFalse("Should not be signed in on OS with Google account.", 63 Assert.assertFalse("Should not be signed in on OS with Google account.",
56 mSigninUtil.isExistingGoogleAccountOnOs(GOOGLE_ACCOUNT_USERNAME) ); 64 mSigninUtil.isExistingGoogleAccountOnOs(GOOGLE_ACCOUNT_USERNAME) );
57 } 65 }
58 66
67 @Test
59 @SmallTest 68 @SmallTest
60 public void testIsSignedInOnFakeOS() { 69 public void testIsSignedInOnFakeOS() {
61 mSigninUtil.addFakeAccountToOs(FAKE_ACCOUNT_USERNAME, FAKE_ACCOUNT_PASSW ORD); 70 mSigninUtil.addFakeAccountToOs(FAKE_ACCOUNT_USERNAME, FAKE_ACCOUNT_PASSW ORD);
62 assertFalse("Should not be signed in on app.", 71 Assert.assertFalse("Should not be signed in on app.", mSigninController. isSignedIn());
63 mSigninController.isSignedIn()); 72 Assert.assertTrue("Should be signed in on OS with fake account.",
64 assertTrue("Should be signed in on OS with fake account.",
65 mSigninUtil.isExistingFakeAccountOnOs(FAKE_ACCOUNT_USERNAME)); 73 mSigninUtil.isExistingFakeAccountOnOs(FAKE_ACCOUNT_USERNAME));
66 assertFalse("Should not be signed in on OS with Google account.", 74 Assert.assertFalse("Should not be signed in on OS with Google account.",
67 mSigninUtil.isExistingGoogleAccountOnOs(GOOGLE_ACCOUNT_USERNAME) ); 75 mSigninUtil.isExistingGoogleAccountOnOs(GOOGLE_ACCOUNT_USERNAME) );
68 } 76 }
69 77
78 @Test
70 @FlakyTest(message = "https://crbug.com/517849") 79 @FlakyTest(message = "https://crbug.com/517849")
71 @EnormousTest 80 @EnormousTest
72 @Restriction(Restriction.RESTRICTION_TYPE_INTERNET) 81 @Restriction(Restriction.RESTRICTION_TYPE_INTERNET)
73 public void testIsSignedInOnGoogleOS() { 82 public void testIsSignedInOnGoogleOS() {
74 mSigninUtil.addGoogleAccountToOs(GOOGLE_ACCOUNT_USERNAME, GOOGLE_ACCOUNT _PASSWORD, 83 mSigninUtil.addGoogleAccountToOs(GOOGLE_ACCOUNT_USERNAME, GOOGLE_ACCOUNT _PASSWORD,
75 GOOGLE_ACCOUNT_TYPE); 84 GOOGLE_ACCOUNT_TYPE);
76 assertFalse("Should not be signed into app.", 85 Assert.assertFalse("Should not be signed into app.", mSigninController.i sSignedIn());
77 mSigninController.isSignedIn()); 86 Assert.assertFalse("Should not be signed into OS with fake account.",
78 assertFalse("Should not be signed into OS with fake account.",
79 mSigninUtil.isExistingFakeAccountOnOs(FAKE_ACCOUNT_USERNAME)); 87 mSigninUtil.isExistingFakeAccountOnOs(FAKE_ACCOUNT_USERNAME));
80 assertTrue("Should be signed in on OS with Google account.", 88 Assert.assertTrue("Should be signed in on OS with Google account.",
81 mSigninUtil.isExistingGoogleAccountOnOs(GOOGLE_ACCOUNT_USERNAME) ); 89 mSigninUtil.isExistingGoogleAccountOnOs(GOOGLE_ACCOUNT_USERNAME) );
82 } 90 }
83 91
92 @Test
84 @SmallTest 93 @SmallTest
85 public void testIsSignedInOnFakeOSandApp() { 94 public void testIsSignedInOnFakeOSandApp() {
86 mSigninUtil.addAccountToApp(FAKE_ACCOUNT_USERNAME); 95 mSigninUtil.addAccountToApp(FAKE_ACCOUNT_USERNAME);
87 mSigninUtil.addFakeAccountToOs(FAKE_ACCOUNT_USERNAME, FAKE_ACCOUNT_PASSW ORD); 96 mSigninUtil.addFakeAccountToOs(FAKE_ACCOUNT_USERNAME, FAKE_ACCOUNT_PASSW ORD);
88 assertTrue("Should be signed in on app.", 97 Assert.assertTrue("Should be signed in on app.", mSigninController.isSig nedIn());
89 mSigninController.isSignedIn()); 98 Assert.assertTrue("Should be signed in on OS with fake account.",
90 assertTrue("Should be signed in on OS with fake account.",
91 mSigninUtil.isExistingFakeAccountOnOs(FAKE_ACCOUNT_USERNAME)); 99 mSigninUtil.isExistingFakeAccountOnOs(FAKE_ACCOUNT_USERNAME));
92 assertFalse("Should not be signed in on OS with Google account.", 100 Assert.assertFalse("Should not be signed in on OS with Google account.",
93 mSigninUtil.isExistingGoogleAccountOnOs(GOOGLE_ACCOUNT_USERNAME) ); 101 mSigninUtil.isExistingGoogleAccountOnOs(GOOGLE_ACCOUNT_USERNAME) );
94 } 102 }
95 103
104 @Test
96 @FlakyTest(message = "https://crbug.com/517849") 105 @FlakyTest(message = "https://crbug.com/517849")
97 @EnormousTest 106 @EnormousTest
98 @Restriction(Restriction.RESTRICTION_TYPE_INTERNET) 107 @Restriction(Restriction.RESTRICTION_TYPE_INTERNET)
99 public void testIsSignedInOnAppAndGoogleOS() { 108 public void testIsSignedInOnAppAndGoogleOS() {
100 mSigninUtil.addAccountToApp(FAKE_ACCOUNT_USERNAME); 109 mSigninUtil.addAccountToApp(FAKE_ACCOUNT_USERNAME);
101 mSigninUtil.addGoogleAccountToOs(GOOGLE_ACCOUNT_USERNAME, GOOGLE_ACCOUNT _PASSWORD, 110 mSigninUtil.addGoogleAccountToOs(GOOGLE_ACCOUNT_USERNAME, GOOGLE_ACCOUNT _PASSWORD,
102 GOOGLE_ACCOUNT_TYPE); 111 GOOGLE_ACCOUNT_TYPE);
103 assertTrue("Should be signed into app.", 112 Assert.assertTrue("Should be signed into app.", mSigninController.isSign edIn());
104 mSigninController.isSignedIn()); 113 Assert.assertFalse("Should not be signed into OS with fake account.",
105 assertFalse("Should not be signed into OS with fake account.",
106 mSigninUtil.isExistingFakeAccountOnOs(FAKE_ACCOUNT_USERNAME)); 114 mSigninUtil.isExistingFakeAccountOnOs(FAKE_ACCOUNT_USERNAME));
107 assertTrue("Should be signed in on OS with Google account.", 115 Assert.assertTrue("Should be signed in on OS with Google account.",
108 mSigninUtil.isExistingGoogleAccountOnOs(GOOGLE_ACCOUNT_USERNAME) ); 116 mSigninUtil.isExistingGoogleAccountOnOs(GOOGLE_ACCOUNT_USERNAME) );
109 } 117 }
110 118
119 @Test
111 @FlakyTest(message = "https://crbug.com/517849") 120 @FlakyTest(message = "https://crbug.com/517849")
112 @EnormousTest 121 @EnormousTest
113 @Restriction(Restriction.RESTRICTION_TYPE_INTERNET) 122 @Restriction(Restriction.RESTRICTION_TYPE_INTERNET)
114 public void testIsSignedInOnFakeOSandGoogleOS() { 123 public void testIsSignedInOnFakeOSandGoogleOS() {
115 mSigninUtil.addFakeAccountToOs(FAKE_ACCOUNT_USERNAME, FAKE_ACCOUNT_PASSW ORD); 124 mSigninUtil.addFakeAccountToOs(FAKE_ACCOUNT_USERNAME, FAKE_ACCOUNT_PASSW ORD);
116 mSigninUtil.addGoogleAccountToOs(GOOGLE_ACCOUNT_USERNAME, GOOGLE_ACCOUNT _PASSWORD, 125 mSigninUtil.addGoogleAccountToOs(GOOGLE_ACCOUNT_USERNAME, GOOGLE_ACCOUNT _PASSWORD,
117 GOOGLE_ACCOUNT_TYPE); 126 GOOGLE_ACCOUNT_TYPE);
118 assertFalse("Should not be signed into app.", 127 Assert.assertFalse("Should not be signed into app.", mSigninController.i sSignedIn());
119 mSigninController.isSignedIn()); 128 Assert.assertTrue("Should be signed into OS with fake account.",
120 assertTrue("Should be signed into OS with fake account.",
121 mSigninUtil.isExistingFakeAccountOnOs(FAKE_ACCOUNT_USERNAME)); 129 mSigninUtil.isExistingFakeAccountOnOs(FAKE_ACCOUNT_USERNAME));
122 assertTrue("Should be signed in on OS with Google account.", 130 Assert.assertTrue("Should be signed in on OS with Google account.",
123 mSigninUtil.isExistingGoogleAccountOnOs(GOOGLE_ACCOUNT_USERNAME) ); 131 mSigninUtil.isExistingGoogleAccountOnOs(GOOGLE_ACCOUNT_USERNAME) );
124 } 132 }
125 133
134 @Test
126 @FlakyTest(message = "https://crbug.com/517849") 135 @FlakyTest(message = "https://crbug.com/517849")
127 @EnormousTest 136 @EnormousTest
128 @Restriction(Restriction.RESTRICTION_TYPE_INTERNET) 137 @Restriction(Restriction.RESTRICTION_TYPE_INTERNET)
129 public void testIsSignedInOnAppAndFakeOSandGoogleOS() { 138 public void testIsSignedInOnAppAndFakeOSandGoogleOS() {
130 mSigninUtil.addAccountToApp(FAKE_ACCOUNT_USERNAME); 139 mSigninUtil.addAccountToApp(FAKE_ACCOUNT_USERNAME);
131 mSigninUtil.addFakeAccountToOs(FAKE_ACCOUNT_USERNAME, FAKE_ACCOUNT_PASSW ORD); 140 mSigninUtil.addFakeAccountToOs(FAKE_ACCOUNT_USERNAME, FAKE_ACCOUNT_PASSW ORD);
132 mSigninUtil.addGoogleAccountToOs(GOOGLE_ACCOUNT_USERNAME, GOOGLE_ACCOUNT _PASSWORD, 141 mSigninUtil.addGoogleAccountToOs(GOOGLE_ACCOUNT_USERNAME, GOOGLE_ACCOUNT _PASSWORD,
133 GOOGLE_ACCOUNT_TYPE); 142 GOOGLE_ACCOUNT_TYPE);
134 assertTrue("Should be signed into app.", 143 Assert.assertTrue("Should be signed into app.", mSigninController.isSign edIn());
135 mSigninController.isSignedIn()); 144 Assert.assertTrue("Should be signed into OS with fake account.",
136 assertTrue("Should be signed into OS with fake account.",
137 mSigninUtil.isExistingFakeAccountOnOs(FAKE_ACCOUNT_USERNAME)); 145 mSigninUtil.isExistingFakeAccountOnOs(FAKE_ACCOUNT_USERNAME));
138 assertTrue("Should be signed in on OS with Google account.", 146 Assert.assertTrue("Should be signed in on OS with Google account.",
139 mSigninUtil.isExistingGoogleAccountOnOs(GOOGLE_ACCOUNT_USERNAME) ); 147 mSigninUtil.isExistingGoogleAccountOnOs(GOOGLE_ACCOUNT_USERNAME) );
140 } 148 }
141 149
142 @Override 150 @After
143 protected void tearDown() throws Exception { 151 public void tearDown() throws Exception {
144 mSigninController.setSignedInAccountName(null); 152 mSigninController.setSignedInAccountName(null);
145 mSigninUtil.removeAllFakeAccountsFromOs(); 153 mSigninUtil.removeAllFakeAccountsFromOs();
146 mSigninUtil.removeAllGoogleAccountsFromOs(); 154 mSigninUtil.removeAllGoogleAccountsFromOs();
147 super.tearDown();
148 } 155 }
149 } 156 }
OLDNEW
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/widget/DualControlLayoutTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698