OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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.history; | 5 package org.chromium.chrome.browser.history; |
6 | 6 |
7 import android.accounts.Account; | 7 import android.accounts.Account; |
8 import android.app.Activity; | 8 import android.app.Activity; |
9 import android.app.Instrumentation; | 9 import android.app.Instrumentation; |
10 import android.app.Instrumentation.ActivityMonitor; | 10 import android.app.Instrumentation.ActivityMonitor; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 | 117 |
118 private HistoryItem mItem1; | 118 private HistoryItem mItem1; |
119 private HistoryItem mItem2; | 119 private HistoryItem mItem2; |
120 | 120 |
121 public HistoryActivityTest() { | 121 public HistoryActivityTest() { |
122 super(HistoryActivity.class); | 122 super(HistoryActivity.class); |
123 } | 123 } |
124 | 124 |
125 @Override | 125 @Override |
126 public void setUp() throws Exception { | 126 public void setUp() throws Exception { |
| 127 SigninTestUtil.setUpAuthForTest(); |
| 128 |
127 super.setUp(); | 129 super.setUp(); |
128 | 130 |
129 mHistoryProvider = new StubbedHistoryProvider(); | 131 mHistoryProvider = new StubbedHistoryProvider(); |
130 | 132 |
131 Date today = new Date(); | 133 Date today = new Date(); |
132 long[] timestamps = {today.getTime()}; | 134 long[] timestamps = {today.getTime()}; |
133 mItem1 = StubbedHistoryProvider.createHistoryItem(0, timestamps); | 135 mItem1 = StubbedHistoryProvider.createHistoryItem(0, timestamps); |
134 mItem2 = StubbedHistoryProvider.createHistoryItem(1, timestamps); | 136 mItem2 = StubbedHistoryProvider.createHistoryItem(1, timestamps); |
135 mHistoryProvider.addItem(mItem1); | 137 mHistoryProvider.addItem(mItem1); |
136 mHistoryProvider.addItem(mItem2); | 138 mHistoryProvider.addItem(mItem2); |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 @Override | 515 @Override |
514 public Boolean call() throws Exception { | 516 public Boolean call() throws Exception { |
515 PrefServiceBridge.getInstance().setSupervisedUserId("ChildAccoun
tSUID"); | 517 PrefServiceBridge.getInstance().setSupervisedUserId("ChildAccoun
tSUID"); |
516 return Profile.getLastUsedProfile().isChild() | 518 return Profile.getLastUsedProfile().isChild() |
517 && !PrefServiceBridge.getInstance().canDeleteBrowsingHis
tory() | 519 && !PrefServiceBridge.getInstance().canDeleteBrowsingHis
tory() |
518 && !PrefServiceBridge.getInstance().isIncognitoModeEnabl
ed(); | 520 && !PrefServiceBridge.getInstance().isIncognitoModeEnabl
ed(); |
519 } | 521 } |
520 })); | 522 })); |
521 | 523 |
522 // Sign in to account. | 524 // Sign in to account. |
523 SigninTestUtil.setUpAuthForTest(getInstrumentation()); | |
524 final Account account = SigninTestUtil.addTestAccount(); | 525 final Account account = SigninTestUtil.addTestAccount(); |
525 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 526 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
526 @Override | 527 @Override |
527 public void run() { | 528 public void run() { |
528 SigninManager.get(getActivity()).onFirstRunCheckDone(); | 529 SigninManager.get(getActivity()).onFirstRunCheckDone(); |
529 SigninManager.get(getActivity()).addSignInStateObserver(mTestObs
erver); | 530 SigninManager.get(getActivity()).addSignInStateObserver(mTestObs
erver); |
530 SigninManager.get(getActivity()).signIn(account, null, null); | 531 SigninManager.get(getActivity()).signIn(account, null, null); |
531 } | 532 } |
532 }); | 533 }); |
533 mTestObserver.onSigninStateChangedCallback.waitForCallback(0, 1, | 534 mTestObserver.onSigninStateChangedCallback.waitForCallback(0, 1, |
(...skipping 22 matching lines...) Expand all Loading... |
556 mTestObserver.onSigninStateChangedCallback.waitForCallback(currentCallCo
unt, 1); | 557 mTestObserver.onSigninStateChangedCallback.waitForCallback(currentCallCo
unt, 1); |
557 assertNull(SigninTestUtil.getCurrentAccount()); | 558 assertNull(SigninTestUtil.getCurrentAccount()); |
558 | 559 |
559 // Remove observer | 560 // Remove observer |
560 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 561 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
561 @Override | 562 @Override |
562 public void run() { | 563 public void run() { |
563 SigninManager.get(getActivity()).removeSignInStateObserver(mTest
Observer); | 564 SigninManager.get(getActivity()).removeSignInStateObserver(mTest
Observer); |
564 } | 565 } |
565 }); | 566 }); |
566 SigninTestUtil.tearDownAuthForTest(); | |
567 } | 567 } |
568 } | 568 } |
OLD | NEW |