Index: chrome/android/javatests/src/org/chromium/chrome/test/util/ChromeSigninUtilsTest.java |
diff --git a/chrome/android/javatests/src/org/chromium/chrome/test/util/ChromeSigninUtilsTest.java b/chrome/android/javatests/src/org/chromium/chrome/test/util/ChromeSigninUtilsTest.java |
index fad929282e48ec7b057b2e853637e0c19b655586..c2295bdad285cd1e97e8036821e7012ffadb7aae 100644 |
--- a/chrome/android/javatests/src/org/chromium/chrome/test/util/ChromeSigninUtilsTest.java |
+++ b/chrome/android/javatests/src/org/chromium/chrome/test/util/ChromeSigninUtilsTest.java |
@@ -4,18 +4,26 @@ |
package org.chromium.chrome.test.util; |
+import android.support.test.InstrumentationRegistry; |
import android.support.test.filters.SmallTest; |
-import android.test.InstrumentationTestCase; |
+ |
+import org.junit.After; |
+import org.junit.Assert; |
+import org.junit.Before; |
+import org.junit.Test; |
+import org.junit.runner.RunWith; |
import org.chromium.base.test.util.EnormousTest; |
import org.chromium.base.test.util.FlakyTest; |
import org.chromium.base.test.util.Restriction; |
+import org.chromium.chrome.test.ChromeJUnit4ClassRunner; |
import org.chromium.components.signin.ChromeSigninController; |
/** |
* Tests for {@link ChromeSigninUtils}. |
*/ |
-public class ChromeSigninUtilsTest extends InstrumentationTestCase { |
+@RunWith(ChromeJUnit4ClassRunner.class) |
+public class ChromeSigninUtilsTest { |
private static final String FAKE_ACCOUNT_USERNAME = "test@google.com"; |
private static final String FAKE_ACCOUNT_PASSWORD = "$3cr3t"; |
private static final String GOOGLE_ACCOUNT_USERNAME = "chromiumforandroid01@gmail.com"; |
@@ -25,74 +33,75 @@ public class ChromeSigninUtilsTest extends InstrumentationTestCase { |
private ChromeSigninUtils mSigninUtil; |
private ChromeSigninController mSigninController; |
- @Override |
+ @Before |
public void setUp() throws Exception { |
- super.setUp(); |
- mSigninUtil = new ChromeSigninUtils(getInstrumentation()); |
- mSigninController = ChromeSigninController.get(getInstrumentation().getTargetContext()); |
+ mSigninUtil = new ChromeSigninUtils(InstrumentationRegistry.getInstrumentation()); |
+ mSigninController = ChromeSigninController.get( |
+ InstrumentationRegistry.getInstrumentation().getTargetContext()); |
mSigninController.setSignedInAccountName(null); |
mSigninUtil.removeAllFakeAccountsFromOs(); |
mSigninUtil.removeAllGoogleAccountsFromOs(); |
} |
+ @Test |
@SmallTest |
public void testActivityIsNotSignedInOnAppOrFakeOSorGoogleOS() { |
- assertFalse("Should not be signed into app.", |
- mSigninController.isSignedIn()); |
- assertFalse("Should not be signed into OS with fake account.", |
+ Assert.assertFalse("Should not be signed into app.", mSigninController.isSignedIn()); |
+ Assert.assertFalse("Should not be signed into OS with fake account.", |
mSigninUtil.isExistingFakeAccountOnOs(FAKE_ACCOUNT_USERNAME)); |
- assertFalse("Should not be signed in on OS with Google account.", |
+ Assert.assertFalse("Should not be signed in on OS with Google account.", |
mSigninUtil.isExistingGoogleAccountOnOs(GOOGLE_ACCOUNT_USERNAME)); |
} |
+ @Test |
@SmallTest |
public void testIsSignedInOnApp() { |
mSigninUtil.addAccountToApp(FAKE_ACCOUNT_USERNAME); |
- assertTrue("Should be signed on app.", |
- mSigninController.isSignedIn()); |
- assertFalse("Should not be signed on OS with fake account.", |
+ Assert.assertTrue("Should be signed on app.", mSigninController.isSignedIn()); |
+ Assert.assertFalse("Should not be signed on OS with fake account.", |
mSigninUtil.isExistingFakeAccountOnOs(FAKE_ACCOUNT_USERNAME)); |
- assertFalse("Should not be signed in on OS with Google account.", |
+ Assert.assertFalse("Should not be signed in on OS with Google account.", |
mSigninUtil.isExistingGoogleAccountOnOs(GOOGLE_ACCOUNT_USERNAME)); |
} |
+ @Test |
@SmallTest |
public void testIsSignedInOnFakeOS() { |
mSigninUtil.addFakeAccountToOs(FAKE_ACCOUNT_USERNAME, FAKE_ACCOUNT_PASSWORD); |
- assertFalse("Should not be signed in on app.", |
- mSigninController.isSignedIn()); |
- assertTrue("Should be signed in on OS with fake account.", |
+ Assert.assertFalse("Should not be signed in on app.", mSigninController.isSignedIn()); |
+ Assert.assertTrue("Should be signed in on OS with fake account.", |
mSigninUtil.isExistingFakeAccountOnOs(FAKE_ACCOUNT_USERNAME)); |
- assertFalse("Should not be signed in on OS with Google account.", |
+ Assert.assertFalse("Should not be signed in on OS with Google account.", |
mSigninUtil.isExistingGoogleAccountOnOs(GOOGLE_ACCOUNT_USERNAME)); |
} |
+ @Test |
@FlakyTest(message = "https://crbug.com/517849") |
@EnormousTest |
@Restriction(Restriction.RESTRICTION_TYPE_INTERNET) |
public void testIsSignedInOnGoogleOS() { |
mSigninUtil.addGoogleAccountToOs(GOOGLE_ACCOUNT_USERNAME, GOOGLE_ACCOUNT_PASSWORD, |
GOOGLE_ACCOUNT_TYPE); |
- assertFalse("Should not be signed into app.", |
- mSigninController.isSignedIn()); |
- assertFalse("Should not be signed into OS with fake account.", |
+ Assert.assertFalse("Should not be signed into app.", mSigninController.isSignedIn()); |
+ Assert.assertFalse("Should not be signed into OS with fake account.", |
mSigninUtil.isExistingFakeAccountOnOs(FAKE_ACCOUNT_USERNAME)); |
- assertTrue("Should be signed in on OS with Google account.", |
+ Assert.assertTrue("Should be signed in on OS with Google account.", |
mSigninUtil.isExistingGoogleAccountOnOs(GOOGLE_ACCOUNT_USERNAME)); |
} |
+ @Test |
@SmallTest |
public void testIsSignedInOnFakeOSandApp() { |
mSigninUtil.addAccountToApp(FAKE_ACCOUNT_USERNAME); |
mSigninUtil.addFakeAccountToOs(FAKE_ACCOUNT_USERNAME, FAKE_ACCOUNT_PASSWORD); |
- assertTrue("Should be signed in on app.", |
- mSigninController.isSignedIn()); |
- assertTrue("Should be signed in on OS with fake account.", |
+ Assert.assertTrue("Should be signed in on app.", mSigninController.isSignedIn()); |
+ Assert.assertTrue("Should be signed in on OS with fake account.", |
mSigninUtil.isExistingFakeAccountOnOs(FAKE_ACCOUNT_USERNAME)); |
- assertFalse("Should not be signed in on OS with Google account.", |
+ Assert.assertFalse("Should not be signed in on OS with Google account.", |
mSigninUtil.isExistingGoogleAccountOnOs(GOOGLE_ACCOUNT_USERNAME)); |
} |
+ @Test |
@FlakyTest(message = "https://crbug.com/517849") |
@EnormousTest |
@Restriction(Restriction.RESTRICTION_TYPE_INTERNET) |
@@ -100,14 +109,14 @@ public class ChromeSigninUtilsTest extends InstrumentationTestCase { |
mSigninUtil.addAccountToApp(FAKE_ACCOUNT_USERNAME); |
mSigninUtil.addGoogleAccountToOs(GOOGLE_ACCOUNT_USERNAME, GOOGLE_ACCOUNT_PASSWORD, |
GOOGLE_ACCOUNT_TYPE); |
- assertTrue("Should be signed into app.", |
- mSigninController.isSignedIn()); |
- assertFalse("Should not be signed into OS with fake account.", |
+ Assert.assertTrue("Should be signed into app.", mSigninController.isSignedIn()); |
+ Assert.assertFalse("Should not be signed into OS with fake account.", |
mSigninUtil.isExistingFakeAccountOnOs(FAKE_ACCOUNT_USERNAME)); |
- assertTrue("Should be signed in on OS with Google account.", |
+ Assert.assertTrue("Should be signed in on OS with Google account.", |
mSigninUtil.isExistingGoogleAccountOnOs(GOOGLE_ACCOUNT_USERNAME)); |
} |
+ @Test |
@FlakyTest(message = "https://crbug.com/517849") |
@EnormousTest |
@Restriction(Restriction.RESTRICTION_TYPE_INTERNET) |
@@ -115,14 +124,14 @@ public class ChromeSigninUtilsTest extends InstrumentationTestCase { |
mSigninUtil.addFakeAccountToOs(FAKE_ACCOUNT_USERNAME, FAKE_ACCOUNT_PASSWORD); |
mSigninUtil.addGoogleAccountToOs(GOOGLE_ACCOUNT_USERNAME, GOOGLE_ACCOUNT_PASSWORD, |
GOOGLE_ACCOUNT_TYPE); |
- assertFalse("Should not be signed into app.", |
- mSigninController.isSignedIn()); |
- assertTrue("Should be signed into OS with fake account.", |
+ Assert.assertFalse("Should not be signed into app.", mSigninController.isSignedIn()); |
+ Assert.assertTrue("Should be signed into OS with fake account.", |
mSigninUtil.isExistingFakeAccountOnOs(FAKE_ACCOUNT_USERNAME)); |
- assertTrue("Should be signed in on OS with Google account.", |
+ Assert.assertTrue("Should be signed in on OS with Google account.", |
mSigninUtil.isExistingGoogleAccountOnOs(GOOGLE_ACCOUNT_USERNAME)); |
} |
+ @Test |
@FlakyTest(message = "https://crbug.com/517849") |
@EnormousTest |
@Restriction(Restriction.RESTRICTION_TYPE_INTERNET) |
@@ -131,19 +140,17 @@ public class ChromeSigninUtilsTest extends InstrumentationTestCase { |
mSigninUtil.addFakeAccountToOs(FAKE_ACCOUNT_USERNAME, FAKE_ACCOUNT_PASSWORD); |
mSigninUtil.addGoogleAccountToOs(GOOGLE_ACCOUNT_USERNAME, GOOGLE_ACCOUNT_PASSWORD, |
GOOGLE_ACCOUNT_TYPE); |
- assertTrue("Should be signed into app.", |
- mSigninController.isSignedIn()); |
- assertTrue("Should be signed into OS with fake account.", |
+ Assert.assertTrue("Should be signed into app.", mSigninController.isSignedIn()); |
+ Assert.assertTrue("Should be signed into OS with fake account.", |
mSigninUtil.isExistingFakeAccountOnOs(FAKE_ACCOUNT_USERNAME)); |
- assertTrue("Should be signed in on OS with Google account.", |
+ Assert.assertTrue("Should be signed in on OS with Google account.", |
mSigninUtil.isExistingGoogleAccountOnOs(GOOGLE_ACCOUNT_USERNAME)); |
} |
- @Override |
- protected void tearDown() throws Exception { |
+ @After |
+ public void tearDown() throws Exception { |
mSigninController.setSignedInAccountName(null); |
mSigninUtil.removeAllFakeAccountsFromOs(); |
mSigninUtil.removeAllGoogleAccountsFromOs(); |
- super.tearDown(); |
} |
} |