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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/signin/SigninUtilsTest.java

Issue 1258563005: Added Signin Utilities (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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/signin/SigninUtilsTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/signin/SigninUtilsTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/signin/SigninUtilsTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..af650ea6e6432eaf80afac4720134b3583dd8593
--- /dev/null
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/signin/SigninUtilsTest.java
@@ -0,0 +1,158 @@
+// Copyright 2015 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.test.util;
+
+import android.test.suitebuilder.annotation.MediumTest;
+import android.test.suitebuilder.annotation.SmallTest;
+
+import org.chromium.chrome.browser.ChromeActivity;
+import org.chromium.chrome.test.ChromeActivityTestCaseBase;
+
+/**
+ * Tester class for {@link SigninUtils}.
+ *
+ * Internet is needed for running the Gaia account tests.
+ */
+public class SigninUtilsTest extends ChromeActivityTestCaseBase<ChromeActivity> {
+ private static final String APP_FAKE_ACCOUNT_USERNAME = "test@google.com";
+ private static final String FAKE_OS_ACCOUNT_USERNAME = "test@example.com";
+ private static final String FAKE_OS_ACCOUNT_PASSWORD = "$3cr3t";
+ private static final String REAL_OS_ACCOUNT_USERNAME = "chromiumforandroid01@gmail.com";
+ private static final String REAL_OS_ACCOUNT_PASSWORD = "chromeforandroid";
+ private static final String ACCOUNT_TYPE = "mail";
+
+ private SigninUtils mSigninUtil;
+
+ public SigninUtilsTest() {
+ super(ChromeActivity.class);
+ }
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ mSigninUtil = new SigninUtils(this);
+ }
+
+ @SmallTest
+ public void testActivityIsNotSignedInOnAppOrFakeOSorGaiaOS() {
+ assertEquals("Should not be signed into app.", false,
+ mSigninUtil.isExistingAccountOnApp());
+ assertEquals("Should not be signed into OS with fake account.", false,
+ mSigninUtil.isExistingFakeAccountOnOs());
+ assertEquals("Should not be signed in on OS with GAIA account.", false,
+ mSigninUtil.isExistingGaiaAccountOnOs());
+ }
+
+ @SmallTest
+ public void testIsSignedInOnApp() {
+ mSigninUtil.addAccountToApp(APP_FAKE_ACCOUNT_USERNAME);
+ assertEquals("Should be signed on app.", true,
+ mSigninUtil.isExistingAccountOnApp());
+ assertEquals("Should not be signed on OS with fake account.", false,
+ mSigninUtil.isExistingFakeAccountOnOs());
+ assertEquals("Should not be signed in on OS with GAIA account.", false,
+ mSigninUtil.isExistingGaiaAccountOnOs());
+ mSigninUtil.removeAccountFromApp();
+ }
+
+ @SmallTest
+ public void testIsSignedInOnFakeOS() {
+ mSigninUtil.removeAllFakeAccountsFromOs();
+ mSigninUtil.addFakeAccountToOs(FAKE_OS_ACCOUNT_USERNAME, FAKE_OS_ACCOUNT_PASSWORD);
+ assertEquals("Should not be signed in on app.", false,
+ mSigninUtil.isExistingAccountOnApp());
+ assertEquals("Should be signed in on OS with fake account.", true,
+ mSigninUtil.isExistingFakeAccountOnOs());
+ assertEquals("Should not be signed in on OS with GAIA account.", false,
+ mSigninUtil.isExistingGaiaAccountOnOs());
+ mSigninUtil.removeFakeAccountFromOs(FAKE_OS_ACCOUNT_USERNAME);
+ }
+
+ @MediumTest
+ public void testIsSignedInOnGaiaOS() {
+ mSigninUtil.removeAllGaiaAccountsFromOs();
+ mSigninUtil.addGaiaAccountToOs(REAL_OS_ACCOUNT_USERNAME, REAL_OS_ACCOUNT_PASSWORD,
+ ACCOUNT_TYPE);
+ assertEquals("Should not be signed into app.", false,
+ mSigninUtil.isExistingAccountOnApp());
+ assertEquals("Should not be signed into OS with fake account.", false,
+ mSigninUtil.isExistingFakeAccountOnOs());
+ assertEquals("Should be signed in on OS with GAIA account.", true,
+ mSigninUtil.isExistingGaiaAccountOnOs());
+ mSigninUtil.removeAllGaiaAccountsFromOs();
+ }
+
+ @SmallTest
+ public void testIsSignedInOnFakeOSandApp() {
+ mSigninUtil.addAccountToApp(APP_FAKE_ACCOUNT_USERNAME);
+ mSigninUtil.removeAllFakeAccountsFromOs();
+ mSigninUtil.addFakeAccountToOs(FAKE_OS_ACCOUNT_USERNAME, FAKE_OS_ACCOUNT_PASSWORD);
+ assertEquals("Should be signed in on app.", true,
+ mSigninUtil.isExistingAccountOnApp());
+ assertEquals("Should be signed in on OS with fake account.", true,
+ mSigninUtil.isExistingFakeAccountOnOs());
+ assertEquals("Should not be signed in on OS with GAIA account.", false,
+ mSigninUtil.isExistingGaiaAccountOnOs());
+ mSigninUtil.removeAccountFromApp();
+ mSigninUtil.removeFakeAccountFromOs(FAKE_OS_ACCOUNT_USERNAME);
+ }
+
+ @MediumTest
+ public void testIsSignedInOnAppAndGaiaOS() {
+ mSigninUtil.addAccountToApp(APP_FAKE_ACCOUNT_USERNAME);
+ mSigninUtil.removeAllGaiaAccountsFromOs();
+ mSigninUtil.addGaiaAccountToOs(REAL_OS_ACCOUNT_USERNAME, REAL_OS_ACCOUNT_PASSWORD,
+ ACCOUNT_TYPE);
+ assertEquals("Should be signed into app.", true,
+ mSigninUtil.isExistingAccountOnApp());
+ assertEquals("Should not be signed into OS with fake account.", false,
+ mSigninUtil.isExistingFakeAccountOnOs());
+ assertEquals("Should be signed in on OS with GAIA account.", true,
+ mSigninUtil.isExistingGaiaAccountOnOs());
+ mSigninUtil.removeAccountFromApp();
+ mSigninUtil.removeAllGaiaAccountsFromOs();
+ }
+
+ @MediumTest
+ public void testIsSignedInOnFakeOSandGaiaOS() {
+ mSigninUtil.removeAllFakeAccountsFromOs();
+ mSigninUtil.addFakeAccountToOs(FAKE_OS_ACCOUNT_USERNAME, FAKE_OS_ACCOUNT_PASSWORD);
+ mSigninUtil.removeAllGaiaAccountsFromOs();
+ mSigninUtil.addGaiaAccountToOs(REAL_OS_ACCOUNT_USERNAME, REAL_OS_ACCOUNT_PASSWORD,
+ ACCOUNT_TYPE);
+ assertEquals("Should not be signed into app.", false,
+ mSigninUtil.isExistingAccountOnApp());
+ assertEquals("Should be signed into OS with fake account.", true,
+ mSigninUtil.isExistingFakeAccountOnOs());
+ assertEquals("Should be signed in on OS with GAIA account.", true,
+ mSigninUtil.isExistingGaiaAccountOnOs());
+ mSigninUtil.removeFakeAccountFromOs(FAKE_OS_ACCOUNT_USERNAME);
+ mSigninUtil.removeAllGaiaAccountsFromOs();
+ }
+
+ @MediumTest
+ public void testIsSignedInOnAppAndFakeOSandGaiaOS() {
+ mSigninUtil.addAccountToApp(APP_FAKE_ACCOUNT_USERNAME);
+ mSigninUtil.removeAllFakeAccountsFromOs();
+ mSigninUtil.addFakeAccountToOs(FAKE_OS_ACCOUNT_USERNAME, FAKE_OS_ACCOUNT_PASSWORD);
+ mSigninUtil.removeAllGaiaAccountsFromOs();
+ mSigninUtil.addGaiaAccountToOs(REAL_OS_ACCOUNT_USERNAME, REAL_OS_ACCOUNT_PASSWORD,
+ ACCOUNT_TYPE);
+ assertEquals("Should be signed into app.", true,
+ mSigninUtil.isExistingAccountOnApp());
+ assertEquals("Should be signed into OS with fake account.", true,
+ mSigninUtil.isExistingFakeAccountOnOs());
+ assertEquals("Should be signed in on OS with GAIA account.", true,
+ mSigninUtil.isExistingGaiaAccountOnOs());
+ mSigninUtil.removeAccountFromApp();
+ mSigninUtil.removeFakeAccountFromOs(FAKE_OS_ACCOUNT_USERNAME);
+ mSigninUtil.removeAllGaiaAccountsFromOs();
+ }
+
+ @Override
+ public void startMainActivity() throws InterruptedException {
+ startMainActivityOnBlankPage();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698