Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: chrome/test/android/javatests/src/org/chromium/chrome/test/util/parameters/AddFakeAccountToAppParameter.java

Issue 2872743003: Change AccountManagerHelper initialization
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.parameters; 5 package org.chromium.chrome.test.util.parameters;
6 6
7 import android.app.Instrumentation; 7 import android.app.Instrumentation;
8 8
9 import org.chromium.base.ThreadUtils;
10 import org.chromium.base.test.util.parameter.BaseParameter; 9 import org.chromium.base.test.util.parameter.BaseParameter;
11 import org.chromium.base.test.util.parameter.Parameter; 10 import org.chromium.base.test.util.parameter.Parameter;
12 import org.chromium.chrome.browser.init.ProcessInitializationHandler;
13 import org.chromium.chrome.test.util.ChromeSigninUtils; 11 import org.chromium.chrome.test.util.ChromeSigninUtils;
14 import org.chromium.components.signin.ChromeSigninController; 12 import org.chromium.components.signin.ChromeSigninController;
15 13
16 /** 14 /**
17 * Adds a fake account to app when this parameter is used. 15 * Adds a fake account to app when this parameter is used.
18 */ 16 */
19 public class AddFakeAccountToAppParameter extends BaseParameter { 17 public class AddFakeAccountToAppParameter extends BaseParameter {
20 /** Adds a fake test account to app to run test as signed into the app. */ 18 /** Adds a fake test account to app to run test as signed into the app. */
21 public static final String PARAMETER_TAG = "add-fake-account-to-app-paramete r"; 19 public static final String PARAMETER_TAG = "add-fake-account-to-app-paramete r";
22 20
23 /** The {@Parameter.Argument#name()} value. */ 21 /** The {@Parameter.Argument#name()} value. */
24 public static final class ARGUMENT { 22 public static final class ARGUMENT {
25 public static final String USERNAME = "username"; 23 public static final String USERNAME = "username";
26 private static final class DEFAULT { 24 private static final class DEFAULT {
27 private static final String USERNAME = "test@google.com"; 25 private static final String USERNAME = "test@google.com";
28 } 26 }
29 } 27 }
30 28
31 private ChromeSigninController mSigninController; 29 private ChromeSigninController mSigninController;
32 private ChromeSigninUtils mSigninUtil; 30 private ChromeSigninUtils mSigninUtil;
33 31
34 public AddFakeAccountToAppParameter(Parameter.Reader parameterReader, 32 public AddFakeAccountToAppParameter(Parameter.Reader parameterReader,
35 Instrumentation instrumentation) { 33 Instrumentation instrumentation) {
36 super(PARAMETER_TAG, parameterReader); 34 super(PARAMETER_TAG, parameterReader);
37 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
38 @Override
39 public void run() {
40 ProcessInitializationHandler.getInstance().initializePreNative() ;
41 }
42 });
43 mSigninController = ChromeSigninController.get(); 35 mSigninController = ChromeSigninController.get();
44 mSigninUtil = new ChromeSigninUtils(instrumentation); 36 mSigninUtil = new ChromeSigninUtils(instrumentation);
45 } 37 }
46 38
47 @Override 39 @Override
48 public void setUp() { 40 public void setUp() {
49 String username = getStringArgument(ARGUMENT.USERNAME, ARGUMENT.DEFAULT. USERNAME); 41 String username = getStringArgument(ARGUMENT.USERNAME, ARGUMENT.DEFAULT. USERNAME);
50 42
51 mSigninController.setSignedInAccountName(null); 43 mSigninController.setSignedInAccountName(null);
52 mSigninUtil.addAccountToApp(username); 44 mSigninUtil.addAccountToApp(username);
53 } 45 }
54 46
55 @Override 47 @Override
56 public void tearDown() { 48 public void tearDown() {
57 mSigninController.setSignedInAccountName(null); 49 mSigninController.setSignedInAccountName(null);
58 } 50 }
59 51
60 /** 52 /**
61 * Only affects Java tests. 53 * Only affects Java tests.
62 * 54 *
63 * @return {@code true} if an account is on the app, {@code false} otherwise . 55 * @return {@code true} if an account is on the app, {@code false} otherwise .
64 */ 56 */
65 public boolean isSignedIn() { 57 public boolean isSignedIn() {
66 return mSigninController.isSignedIn(); 58 return mSigninController.isSignedIn();
67 } 59 }
68 } 60 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698