OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.test.util.browser.signin; | 5 package org.chromium.chrome.test.util.browser.signin; |
6 | 6 |
7 import android.accounts.Account; | 7 import android.accounts.Account; |
| 8 import android.annotation.SuppressLint; |
8 import android.app.Instrumentation; | 9 import android.app.Instrumentation; |
9 import android.content.Context; | 10 import android.content.Context; |
10 | 11 |
11 import org.chromium.base.ContextUtils; | 12 import org.chromium.base.ContextUtils; |
12 import org.chromium.base.ThreadUtils; | 13 import org.chromium.base.ThreadUtils; |
13 import org.chromium.chrome.browser.init.ProcessInitializationHandler; | 14 import org.chromium.chrome.browser.init.ProcessInitializationHandler; |
14 import org.chromium.chrome.browser.signin.AccountIdProvider; | 15 import org.chromium.chrome.browser.signin.AccountIdProvider; |
15 import org.chromium.chrome.browser.signin.AccountTrackerService; | 16 import org.chromium.chrome.browser.signin.AccountTrackerService; |
16 import org.chromium.chrome.browser.signin.OAuth2TokenService; | 17 import org.chromium.chrome.browser.signin.OAuth2TokenService; |
17 import org.chromium.components.signin.AccountManagerHelper; | 18 import org.chromium.components.signin.AccountManagerHelper; |
18 import org.chromium.components.signin.ChromeSigninController; | 19 import org.chromium.components.signin.ChromeSigninController; |
19 import org.chromium.components.signin.test.util.AccountHolder; | 20 import org.chromium.components.signin.test.util.AccountHolder; |
20 import org.chromium.components.signin.test.util.FakeAccountManagerDelegate; | 21 import org.chromium.components.signin.test.util.FakeAccountManagerDelegate; |
21 | 22 |
22 import java.util.HashSet; | 23 import java.util.HashSet; |
23 | 24 |
24 /** | 25 /** |
25 * Utility class for test signin functionality. | 26 * Utility class for test signin functionality. |
26 */ | 27 */ |
27 public final class SigninTestUtil { | 28 public final class SigninTestUtil { |
28 private static final String TAG = "Signin"; | 29 private static final String TAG = "Signin"; |
29 | 30 |
30 private static final String DEFAULT_ACCOUNT = "test@gmail.com"; | 31 private static final String DEFAULT_ACCOUNT = "test@gmail.com"; |
31 | 32 |
| 33 @SuppressLint("StaticFieldLeak") |
32 private static Context sContext; | 34 private static Context sContext; |
| 35 @SuppressLint("StaticFieldLeak") |
33 private static FakeAccountManagerDelegate sAccountManager; | 36 private static FakeAccountManagerDelegate sAccountManager; |
34 | 37 |
35 /** | 38 /** |
36 * Sets up the test authentication environment. | 39 * Sets up the test authentication environment. |
37 * | 40 * |
38 * This must be called before native is loaded. | 41 * This must be called before native is loaded. |
39 */ | 42 */ |
40 public static void setUpAuthForTest(Instrumentation instrumentation) { | 43 public static void setUpAuthForTest(Instrumentation instrumentation) { |
41 assert sContext == null; | 44 assert sContext == null; |
42 sContext = instrumentation.getTargetContext(); | 45 sContext = instrumentation.getTargetContext(); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 // Clear cached signed account name and accounts list. | 142 // Clear cached signed account name and accounts list. |
140 ChromeSigninController.get().setSignedInAccountName(null); | 143 ChromeSigninController.get().setSignedInAccountName(null); |
141 ContextUtils.getAppSharedPreferences() | 144 ContextUtils.getAppSharedPreferences() |
142 .edit() | 145 .edit() |
143 .putStringSet(OAuth2TokenService.STORED_ACCOUNTS_KEY, new HashSe
t<String>()) | 146 .putStringSet(OAuth2TokenService.STORED_ACCOUNTS_KEY, new HashSe
t<String>()) |
144 .apply(); | 147 .apply(); |
145 } | 148 } |
146 | 149 |
147 private SigninTestUtil() {} | 150 private SigninTestUtil() {} |
148 } | 151 } |
OLD | NEW |