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

Unified Diff: sync/android/javatests/src/org/chromium/sync/notifier/signin/AccountManagerHelperTest.java

Issue 617183003: Make sure GetAuthenticatedAccountId() returns a canonicalized id. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 6 years, 2 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
« no previous file with comments | « sync/android/java/src/org/chromium/sync/signin/AccountManagerHelper.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/android/javatests/src/org/chromium/sync/notifier/signin/AccountManagerHelperTest.java
diff --git a/sync/android/javatests/src/org/chromium/sync/notifier/signin/AccountManagerHelperTest.java b/sync/android/javatests/src/org/chromium/sync/notifier/signin/AccountManagerHelperTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..8633fef62c1b70c8024a424e49cb233178deae5a
--- /dev/null
+++ b/sync/android/javatests/src/org/chromium/sync/notifier/signin/AccountManagerHelperTest.java
@@ -0,0 +1,57 @@
+// Copyright 2012 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.sync.notifier.signin;
+
+import android.accounts.Account;
+import android.content.Context;
+import android.test.InstrumentationTestCase;
+import android.test.suitebuilder.annotation.SmallTest;
+
+import org.chromium.sync.signin.AccountManagerHelper;
+import org.chromium.sync.test.util.AccountHolder;
+import org.chromium.sync.test.util.MockAccountManager;
+
+public class AccountManagerHelperTest extends InstrumentationTestCase {
+
+ private MockAccountManager mAccountManager;
+ private AccountManagerHelper mHelper;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ Context context = getInstrumentation().getContext();
+ mAccountManager = new MockAccountManager(context, context);
+ AccountManagerHelper.overrideAccountManagerHelperForTests(context, mAccountManager);
+ mHelper = AccountManagerHelper.get(context);
+ }
+
+ private Account addTestAccount(String accountName, String password) {
+ Account account = AccountManagerHelper.createAccountFromName(accountName);
+ AccountHolder.Builder accountHolder =
+ AccountHolder.create().account(account).password(password).alwaysAccept(true);
+ mAccountManager.addAccountHolderExplicitly(accountHolder.build());
+ return account;
+ }
+
+ @SmallTest
+ public void testCanonicalAccount() throws InterruptedException {
+ addTestAccount("test@gmail.com", "password");
+
+ assertTrue(mHelper.hasAccountForName("test@gmail.com"));
+ assertTrue(mHelper.hasAccountForName("Test@gmail.com"));
+ assertTrue(mHelper.hasAccountForName("te.st@gmail.com"));
+ }
+
+ @SmallTest
+ public void testNonCanonicalAccount() throws InterruptedException {
+ addTestAccount("test.me@gmail.com", "password");
+
+ assertTrue(mHelper.hasAccountForName("test.me@gmail.com"));
+ assertTrue(mHelper.hasAccountForName("testme@gmail.com"));
+ assertTrue(mHelper.hasAccountForName("Testme@gmail.com"));
+ assertTrue(mHelper.hasAccountForName("te.st.me@gmail.com"));
+ }
+}
« no previous file with comments | « sync/android/java/src/org/chromium/sync/signin/AccountManagerHelper.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698