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")); |
+ } |
+} |