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; | 5 package org.chromium.chrome.test.util; |
6 | 6 |
7 import android.accounts.Account; | 7 import android.accounts.Account; |
8 import android.accounts.AccountManager; | 8 import android.accounts.AccountManager; |
9 import android.accounts.AccountManagerCallback; | 9 import android.accounts.AccountManagerCallback; |
10 import android.accounts.AccountManagerFuture; | 10 import android.accounts.AccountManagerFuture; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 /** | 54 /** |
55 * Adds an account to the app. | 55 * Adds an account to the app. |
56 * | 56 * |
57 * @param username the username for the logged in account; must be a Google
account. | 57 * @param username the username for the logged in account; must be a Google
account. |
58 */ | 58 */ |
59 public void addAccountToApp(String username) { | 59 public void addAccountToApp(String username) { |
60 if (TextUtils.isEmpty(username)) { | 60 if (TextUtils.isEmpty(username)) { |
61 throw new IllegalArgumentException("ERROR: must specify account"); | 61 throw new IllegalArgumentException("ERROR: must specify account"); |
62 } | 62 } |
63 | 63 |
64 if (ChromeSigninController.get(mContext).isSignedIn()) { | 64 if (ChromeSigninController.get().isSignedIn()) { |
65 ChromeSigninController.get(mContext).setSignedInAccountName(null); | 65 ChromeSigninController.get().setSignedInAccountName(null); |
66 } | 66 } |
67 ChromeSigninController.get(mContext).setSignedInAccountName(username); | 67 ChromeSigninController.get().setSignedInAccountName(username); |
68 } | 68 } |
69 | 69 |
70 /** | 70 /** |
71 * Adds a fake account to the OS. | 71 * Adds a fake account to the OS. |
72 */ | 72 */ |
73 public void addFakeAccountToOs(String username, String password) { | 73 public void addFakeAccountToOs(String username, String password) { |
74 if (TextUtils.isEmpty(username)) { | 74 if (TextUtils.isEmpty(username)) { |
75 throw new IllegalArgumentException("ERROR: must specify account"); | 75 throw new IllegalArgumentException("ERROR: must specify account"); |
76 } | 76 } |
77 | 77 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 */ | 220 */ |
221 private Bundle buildExceptionBundle(Exception e) { | 221 private Bundle buildExceptionBundle(Exception e) { |
222 Bundle bundle = new Bundle(); | 222 Bundle bundle = new Bundle(); |
223 bundle.putInt(AccountManager.KEY_ERROR_CODE, | 223 bundle.putInt(AccountManager.KEY_ERROR_CODE, |
224 AccountManager.ERROR_CODE_INVALID_RESPONSE); | 224 AccountManager.ERROR_CODE_INVALID_RESPONSE); |
225 bundle.putString(AccountManager.KEY_ERROR_MESSAGE, e.toString()); | 225 bundle.putString(AccountManager.KEY_ERROR_MESSAGE, e.toString()); |
226 return bundle; | 226 return bundle; |
227 } | 227 } |
228 } | 228 } |
229 } | 229 } |
OLD | NEW |