| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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.chrome.browser.signin; | 5 package org.chromium.chrome.browser.signin; |
| 6 | 6 |
| 7 import android.accounts.Account; | 7 import android.accounts.Account; |
| 8 import android.support.test.InstrumentationRegistry; | 8 import android.support.test.InstrumentationRegistry; |
| 9 import android.support.test.filters.SmallTest; | 9 import android.support.test.filters.SmallTest; |
| 10 | 10 |
| 11 import org.junit.After; |
| 11 import org.junit.Assert; | 12 import org.junit.Assert; |
| 12 import org.junit.Before; | 13 import org.junit.Before; |
| 13 import org.junit.Test; | 14 import org.junit.Test; |
| 14 import org.junit.runner.RunWith; | 15 import org.junit.runner.RunWith; |
| 15 | 16 |
| 16 import org.chromium.base.test.util.AdvancedMockContext; | 17 import org.chromium.base.test.util.AdvancedMockContext; |
| 17 import org.chromium.base.test.util.DisabledTest; | 18 import org.chromium.base.test.util.DisabledTest; |
| 18 import org.chromium.base.test.util.Feature; | 19 import org.chromium.base.test.util.Feature; |
| 19 import org.chromium.chrome.test.ChromeJUnit4ClassRunner; | 20 import org.chromium.chrome.test.ChromeJUnit4ClassRunner; |
| 20 import org.chromium.components.signin.AccountManagerHelper; | 21 import org.chromium.components.signin.AccountManagerHelper; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 33 @Before | 34 @Before |
| 34 public void setUp() throws Exception { | 35 public void setUp() throws Exception { |
| 35 // Mock out the account manager on the device. | 36 // Mock out the account manager on the device. |
| 36 mContext = new AdvancedMockContext( | 37 mContext = new AdvancedMockContext( |
| 37 InstrumentationRegistry.getInstrumentation().getTargetContext())
; | 38 InstrumentationRegistry.getInstrumentation().getTargetContext())
; |
| 38 mAccountManager = new MockAccountManager( | 39 mAccountManager = new MockAccountManager( |
| 39 mContext, InstrumentationRegistry.getInstrumentation().getContex
t()); | 40 mContext, InstrumentationRegistry.getInstrumentation().getContex
t()); |
| 40 AccountManagerHelper.overrideAccountManagerHelperForTests(mContext, mAcc
ountManager); | 41 AccountManagerHelper.overrideAccountManagerHelperForTests(mContext, mAcc
ountManager); |
| 41 } | 42 } |
| 42 | 43 |
| 44 @After |
| 45 public void tearDown() { |
| 46 AccountManagerHelper.resetAccountManagerHelperForTests(); |
| 47 } |
| 48 |
| 43 /* | 49 /* |
| 44 * @SmallTest | 50 * @SmallTest |
| 45 * @Feature({"Sync"}) | 51 * @Feature({"Sync"}) |
| 46 */ | 52 */ |
| 47 @Test | 53 @Test |
| 48 @DisabledTest(message = "crbug.com/533417") | 54 @DisabledTest(message = "crbug.com/533417") |
| 49 public void testGetAccountsNoAccountsRegistered() { | 55 public void testGetAccountsNoAccountsRegistered() { |
| 50 String[] accounts = OAuth2TokenService.getAccounts(); | 56 String[] accounts = OAuth2TokenService.getAccounts(); |
| 51 Assert.assertEquals("There should be no accounts registered", 0, account
s.length); | 57 Assert.assertEquals("There should be no accounts registered", 0, account
s.length); |
| 52 } | 58 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 .hasBeenAccepted(oauth2Scope, true
) | 127 .hasBeenAccepted(oauth2Scope, true
) |
| 122 .authToken(oauth2Scope, expectedTo
ken) | 128 .authToken(oauth2Scope, expectedTo
ken) |
| 123 .build(); | 129 .build(); |
| 124 mAccountManager.addAccountHolderExplicitly(accountHolder); | 130 mAccountManager.addAccountHolderExplicitly(accountHolder); |
| 125 | 131 |
| 126 String accessToken = OAuth2TokenService.getOAuth2AccessTokenWithTimeout( | 132 String accessToken = OAuth2TokenService.getOAuth2AccessTokenWithTimeout( |
| 127 mContext, account, scope, 5, TimeUnit.SECONDS); | 133 mContext, account, scope, 5, TimeUnit.SECONDS); |
| 128 Assert.assertEquals(expectedToken, accessToken); | 134 Assert.assertEquals(expectedToken, accessToken); |
| 129 } | 135 } |
| 130 } | 136 } |
| OLD | NEW |