| 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.browser.signin; | 5 package org.chromium.chrome.browser.signin; |
| 6 | 6 |
| 7 import android.app.Activity; | 7 import android.app.Activity; |
| 8 import android.app.DialogFragment; | 8 import android.app.DialogFragment; |
| 9 import android.app.Fragment; | 9 import android.app.Fragment; |
| 10 import android.app.Instrumentation.ActivityMonitor; | 10 import android.app.Instrumentation.ActivityMonitor; |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 private Context mContext; | 212 private Context mContext; |
| 213 private SigninManager mSigninManager; | 213 private SigninManager mSigninManager; |
| 214 private PrefServiceBridge mPrefService; | 214 private PrefServiceBridge mPrefService; |
| 215 private BookmarkBridge mBookmarks; | 215 private BookmarkBridge mBookmarks; |
| 216 private TestBookmarkModelObserver mTestBookmarkModelObserver; | 216 private TestBookmarkModelObserver mTestBookmarkModelObserver; |
| 217 private TestSignInObserver mTestSignInObserver; | 217 private TestSignInObserver mTestSignInObserver; |
| 218 | 218 |
| 219 @Before | 219 @Before |
| 220 public void setUp() throws Exception { | 220 public void setUp() throws Exception { |
| 221 // Mock out the account manager on the device. | 221 // Mock out the account manager on the device. |
| 222 SigninTestUtil.setUpAuthForTest(InstrumentationRegistry.getInstrumentati
on()); | 222 SigninTestUtil.setUpAuthForTest(); |
| 223 | 223 |
| 224 mActivityTestRule.startMainActivityOnBlankPage(); | 224 mActivityTestRule.startMainActivityOnBlankPage(); |
| 225 mContext = InstrumentationRegistry.getInstrumentation().getTargetContext
(); | 225 mContext = InstrumentationRegistry.getInstrumentation().getTargetContext
(); |
| 226 final TestSignInAllowedObserver signinAllowedObserver = new TestSignInAl
lowedObserver(); | 226 final TestSignInAllowedObserver signinAllowedObserver = new TestSignInAl
lowedObserver(); |
| 227 | 227 |
| 228 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 228 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 229 @Override | 229 @Override |
| 230 public void run() { | 230 public void run() { |
| 231 // This call initializes the ChromeSigninController to use our t
est context. | 231 // This call initializes the ChromeSigninController to use our t
est context. |
| 232 ChromeSigninController.get(); | 232 ChromeSigninController.get(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 | 272 |
| 273 mSigninManager.removeSignInStateObserver(mTestSignInObserver); | 273 mSigninManager.removeSignInStateObserver(mTestSignInObserver); |
| 274 | 274 |
| 275 if (ChromeSigninController.get().isSignedIn()) { | 275 if (ChromeSigninController.get().isSignedIn()) { |
| 276 mSigninManager.signOut(null, null); | 276 mSigninManager.signOut(null, null); |
| 277 } | 277 } |
| 278 | 278 |
| 279 mBookmarks.destroy(); | 279 mBookmarks.destroy(); |
| 280 } | 280 } |
| 281 }); | 281 }); |
| 282 SigninTestUtil.tearDownAuthForTest(); | |
| 283 } | 282 } |
| 284 | 283 |
| 285 @Test | 284 @Test |
| 286 @MediumTest | 285 @MediumTest |
| 287 @Restriction(ChromeRestriction.RESTRICTION_TYPE_GOOGLE_PLAY_SERVICES) | 286 @Restriction(ChromeRestriction.RESTRICTION_TYPE_GOOGLE_PLAY_SERVICES) |
| 288 public void testConsumerSignin() { | 287 public void testConsumerSignin() { |
| 289 SigninTestUtil.addTestAccount(); | 288 SigninTestUtil.addTestAccount(); |
| 290 signInToSingleAccount(); | 289 signInToSingleAccount(); |
| 291 | 290 |
| 292 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 291 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 InstrumentationRegistry.getInstrumentation().waitForIdleSync(); | 439 InstrumentationRegistry.getInstrumentation().waitForIdleSync(); |
| 441 DialogFragment fragment = ActivityUtils.waitForFragment(activity, tag); | 440 DialogFragment fragment = ActivityUtils.waitForFragment(activity, tag); |
| 442 AlertDialog dialog = (AlertDialog) fragment.getDialog(); | 441 AlertDialog dialog = (AlertDialog) fragment.getDialog(); |
| 443 Assert.assertTrue(dialog != null); | 442 Assert.assertTrue(dialog != null); |
| 444 Assert.assertTrue(dialog.isShowing()); | 443 Assert.assertTrue(dialog.isShowing()); |
| 445 Button button = dialog.getButton(DialogInterface.BUTTON_POSITIVE); | 444 Button button = dialog.getButton(DialogInterface.BUTTON_POSITIVE); |
| 446 Assert.assertNotNull("Could not find the accept button.", button); | 445 Assert.assertNotNull("Could not find the accept button.", button); |
| 447 TestTouchUtils.performClickOnMainSync(InstrumentationRegistry.getInstrum
entation(), button); | 446 TestTouchUtils.performClickOnMainSync(InstrumentationRegistry.getInstrum
entation(), button); |
| 448 } | 447 } |
| 449 } | 448 } |
| OLD | NEW |