| 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.accounts.Account; | 7 import android.accounts.Account; |
| 8 import android.support.test.InstrumentationRegistry; | 8 import android.support.test.InstrumentationRegistry; |
| 9 import android.support.test.filters.SmallTest; | 9 import android.support.test.filters.SmallTest; |
| 10 | 10 |
| 11 import org.junit.After; | |
| 12 import org.junit.Assert; | 11 import org.junit.Assert; |
| 13 import org.junit.Before; | 12 import org.junit.Before; |
| 14 import org.junit.Test; | 13 import org.junit.Test; |
| 15 import org.junit.runner.RunWith; | 14 import org.junit.runner.RunWith; |
| 16 | 15 |
| 17 import org.chromium.base.test.util.AdvancedMockContext; | 16 import org.chromium.base.test.util.AdvancedMockContext; |
| 18 import org.chromium.base.test.util.DisabledTest; | 17 import org.chromium.base.test.util.DisabledTest; |
| 19 import org.chromium.base.test.util.RetryOnFailure; | 18 import org.chromium.base.test.util.RetryOnFailure; |
| 20 import org.chromium.chrome.test.ChromeJUnit4ClassRunner; | 19 import org.chromium.chrome.test.ChromeJUnit4ClassRunner; |
| 21 import org.chromium.chrome.test.util.browser.signin.MockChangeEventChecker; | 20 import org.chromium.chrome.test.util.browser.signin.MockChangeEventChecker; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 32 private FakeAccountManagerDelegate mAccountManager; | 31 private FakeAccountManagerDelegate mAccountManager; |
| 33 private AdvancedMockContext mContext; | 32 private AdvancedMockContext mContext; |
| 34 private MockChangeEventChecker mEventChecker; | 33 private MockChangeEventChecker mEventChecker; |
| 35 | 34 |
| 36 @Before | 35 @Before |
| 37 public void setUp() { | 36 public void setUp() { |
| 38 mContext = new AdvancedMockContext( | 37 mContext = new AdvancedMockContext( |
| 39 InstrumentationRegistry.getInstrumentation().getTargetContext())
; | 38 InstrumentationRegistry.getInstrumentation().getTargetContext())
; |
| 40 mEventChecker = new MockChangeEventChecker(); | 39 mEventChecker = new MockChangeEventChecker(); |
| 41 | 40 |
| 42 mAccountManager = new FakeAccountManagerDelegate(mContext); | 41 mAccountManager = new FakeAccountManagerDelegate(); |
| 43 AccountManagerHelper.overrideAccountManagerHelperForTests(mContext, mAcc
ountManager); | 42 AccountManagerHelper.overrideAccountManagerHelperForTests(mAccountManage
r); |
| 44 } | |
| 45 | |
| 46 @After | |
| 47 public void tearDown() { | |
| 48 AccountManagerHelper.resetAccountManagerHelperForTests(); | |
| 49 } | 43 } |
| 50 | 44 |
| 51 @Test | 45 @Test |
| 52 @SmallTest | 46 @SmallTest |
| 53 @RetryOnFailure | 47 @RetryOnFailure |
| 54 public void testAccountsChangedPref() { | 48 public void testAccountsChangedPref() { |
| 55 Assert.assertEquals("Should never return true before the pref has ever b
een set.", false, | 49 Assert.assertEquals("Should never return true before the pref has ever b
een set.", false, |
| 56 SigninHelper.checkAndClearAccountsChangedPref(mContext)); | 50 SigninHelper.checkAndClearAccountsChangedPref(mContext)); |
| 57 Assert.assertEquals("Should never return true before the pref has ever b
een set.", false, | 51 Assert.assertEquals("Should never return true before the pref has ever b
een set.", false, |
| 58 SigninHelper.checkAndClearAccountsChangedPref(mContext)); | 52 SigninHelper.checkAndClearAccountsChangedPref(mContext)); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 } | 152 } |
| 159 | 153 |
| 160 private String getSignedInAccountName() { | 154 private String getSignedInAccountName() { |
| 161 return ChromeSigninController.get().getSignedInAccountName(); | 155 return ChromeSigninController.get().getSignedInAccountName(); |
| 162 } | 156 } |
| 163 | 157 |
| 164 private String getNewSignedInAccountName() { | 158 private String getNewSignedInAccountName() { |
| 165 return SigninHelper.getNewSignedInAccountName(mContext); | 159 return SigninHelper.getNewSignedInAccountName(mContext); |
| 166 } | 160 } |
| 167 } | 161 } |
| OLD | NEW |