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.content.Context; | 8 import android.content.Context; |
9 import android.support.test.InstrumentationRegistry; | 9 import android.support.test.InstrumentationRegistry; |
10 import android.support.test.filters.MediumTest; | 10 import android.support.test.filters.MediumTest; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 @Before | 63 @Before |
64 public void setUp() throws Exception { | 64 public void setUp() throws Exception { |
65 mapAccountNamesToIds(); | 65 mapAccountNamesToIds(); |
66 ApplicationData.clearAppData( | 66 ApplicationData.clearAppData( |
67 InstrumentationRegistry.getInstrumentation().getTargetContext())
; | 67 InstrumentationRegistry.getInstrumentation().getTargetContext())
; |
68 | 68 |
69 // loadNativeLibraryAndInitBrowserProcess will access AccountManagerHelp
er, so it should | 69 // loadNativeLibraryAndInitBrowserProcess will access AccountManagerHelp
er, so it should |
70 // be initialized beforehand. | 70 // be initialized beforehand. |
71 mContext = new AdvancedMockContext( | 71 mContext = new AdvancedMockContext( |
72 InstrumentationRegistry.getInstrumentation().getTargetContext())
; | 72 InstrumentationRegistry.getInstrumentation().getTargetContext())
; |
73 mAccountManager = new FakeAccountManagerDelegate(mContext); | 73 mAccountManager = new FakeAccountManagerDelegate(); |
74 AccountManagerHelper.overrideAccountManagerHelperForTests(mContext, mAcc
ountManager); | 74 AccountManagerHelper.overrideAccountManagerHelperForTests(mAccountManage
r); |
75 | 75 |
76 mActivityTestRule.loadNativeLibraryAndInitBrowserProcess(); | 76 mActivityTestRule.loadNativeLibraryAndInitBrowserProcess(); |
77 | 77 |
78 // Make sure there is no account signed in yet. | 78 // Make sure there is no account signed in yet. |
79 mChromeSigninController = ChromeSigninController.get(); | 79 mChromeSigninController = ChromeSigninController.get(); |
80 mChromeSigninController.setSignedInAccountName(null); | 80 mChromeSigninController.setSignedInAccountName(null); |
81 | 81 |
82 // Seed test accounts to AccountTrackerService. | 82 // Seed test accounts to AccountTrackerService. |
83 seedAccountTrackerService(mContext); | 83 seedAccountTrackerService(mContext); |
84 | 84 |
85 // Get a reference to the service. | 85 // Get a reference to the service. |
86 mOAuth2TokenService = getOAuth2TokenServiceOnUiThread(); | 86 mOAuth2TokenService = getOAuth2TokenServiceOnUiThread(); |
87 | 87 |
88 // Set up observer. | 88 // Set up observer. |
89 mObserver = new TestObserver(); | 89 mObserver = new TestObserver(); |
90 addObserver(mObserver); | 90 addObserver(mObserver); |
91 } | 91 } |
92 | 92 |
93 @After | 93 @After |
94 public void tearDown() throws Exception { | 94 public void tearDown() throws Exception { |
95 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 95 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
96 @Override | 96 @Override |
97 public void run() { | 97 public void run() { |
98 mChromeSigninController.setSignedInAccountName(null); | 98 mChromeSigninController.setSignedInAccountName(null); |
99 mOAuth2TokenService.validateAccounts(false); | 99 mOAuth2TokenService.validateAccounts(false); |
100 } | 100 } |
101 }); | 101 }); |
102 AccountManagerHelper.resetAccountManagerHelperForTests(); | |
103 } | 102 } |
104 | 103 |
105 private void mapAccountNamesToIds() { | 104 private void mapAccountNamesToIds() { |
106 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 105 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
107 @Override | 106 @Override |
108 public void run() { | 107 public void run() { |
109 AccountIdProvider.setInstanceForTest(new AccountIdProvider() { | 108 AccountIdProvider.setInstanceForTest(new AccountIdProvider() { |
110 @Override | 109 @Override |
111 public String getAccountId(String accountName) { | 110 public String getAccountId(String accountName) { |
112 return "gaia-id-" + accountName; | 111 return "gaia-id-" + accountName; |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 | 554 |
556 public int getLoadedCallCount() { | 555 public int getLoadedCallCount() { |
557 return mLoadedCallCount; | 556 return mLoadedCallCount; |
558 } | 557 } |
559 | 558 |
560 public Account getLastAccount() { | 559 public Account getLastAccount() { |
561 return mLastAccount; | 560 return mLastAccount; |
562 } | 561 } |
563 } | 562 } |
564 } | 563 } |
OLD | NEW |