OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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.components.signin.test; | 5 package org.chromium.components.signin.test; |
6 | 6 |
7 import android.accounts.Account; | 7 import android.accounts.Account; |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.support.test.filters.SmallTest; | 9 import android.support.test.filters.SmallTest; |
10 import android.test.InstrumentationTestCase; | 10 import android.test.InstrumentationTestCase; |
(...skipping 10 matching lines...) Expand all Loading... |
21 private MockAccountManager mAccountManager; | 21 private MockAccountManager mAccountManager; |
22 private AccountManagerHelper mHelper; | 22 private AccountManagerHelper mHelper; |
23 | 23 |
24 @Override | 24 @Override |
25 protected void setUp() throws Exception { | 25 protected void setUp() throws Exception { |
26 super.setUp(); | 26 super.setUp(); |
27 | 27 |
28 Context context = getInstrumentation().getTargetContext(); | 28 Context context = getInstrumentation().getTargetContext(); |
29 mAccountManager = new MockAccountManager(context, context); | 29 mAccountManager = new MockAccountManager(context, context); |
30 AccountManagerHelper.overrideAccountManagerHelperForTests(context, mAcco
untManager); | 30 AccountManagerHelper.overrideAccountManagerHelperForTests(context, mAcco
untManager); |
31 mHelper = AccountManagerHelper.get(context); | 31 mHelper = AccountManagerHelper.get(); |
32 } | 32 } |
33 | 33 |
34 @SmallTest | 34 @SmallTest |
35 public void testCanonicalAccount() throws InterruptedException { | 35 public void testCanonicalAccount() throws InterruptedException { |
36 addTestAccount("test@gmail.com", "password"); | 36 addTestAccount("test@gmail.com", "password"); |
37 | 37 |
38 assertTrue(hasAccountForName("test@gmail.com")); | 38 assertTrue(hasAccountForName("test@gmail.com")); |
39 assertTrue(hasAccountForName("Test@gmail.com")); | 39 assertTrue(hasAccountForName("Test@gmail.com")); |
40 assertTrue(hasAccountForName("te.st@gmail.com")); | 40 assertTrue(hasAccountForName("te.st@gmail.com")); |
41 } | 41 } |
(...skipping 17 matching lines...) Expand all Loading... |
59 mAccountManager.addAccountHolderExplicitly(accountHolder.build()); | 59 mAccountManager.addAccountHolderExplicitly(accountHolder.build()); |
60 return account; | 60 return account; |
61 } | 61 } |
62 | 62 |
63 private boolean hasAccountForName(String accountName) throws InterruptedExce
ption { | 63 private boolean hasAccountForName(String accountName) throws InterruptedExce
ption { |
64 SimpleFuture<Boolean> result = new SimpleFuture<Boolean>(); | 64 SimpleFuture<Boolean> result = new SimpleFuture<Boolean>(); |
65 mHelper.hasAccountForName(accountName, result.createCallback()); | 65 mHelper.hasAccountForName(accountName, result.createCallback()); |
66 return result.get(); | 66 return result.get(); |
67 } | 67 } |
68 } | 68 } |
OLD | NEW |