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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/signin/OAuth2TokenServiceIntegrationTest.java

Issue 1256283002: GAIA ID migration for Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase & solve tests Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/javatests/src/org/chromium/chrome/browser/signin/OAuth2TokenServiceIntegrationTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/signin/OAuth2TokenServiceIntegrationTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/signin/OAuth2TokenServiceIntegrationTest.java
index 2e5bff09807d373fa70596f3fe037b6789d2908c..5522b3cf21fc4cfd03a99ce3fde1734f7aaacbf2 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/signin/OAuth2TokenServiceIntegrationTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/signin/OAuth2TokenServiceIntegrationTest.java
@@ -5,6 +5,8 @@
package org.chromium.chrome.browser.signin;
import android.accounts.Account;
+import android.app.Activity;
+import android.content.Context;
import android.test.UiThreadTest;
import android.test.suitebuilder.annotation.MediumTest;
@@ -45,6 +47,7 @@ public class OAuth2TokenServiceIntegrationTest extends NativeLibraryTestBase {
@Override
protected void setUp() throws Exception {
+ mapAccountNamesToIds();
super.setUp();
ApplicationData.clearAppData(getInstrumentation().getTargetContext());
loadNativeLibraryAndInitBrowserProcess();
@@ -58,6 +61,9 @@ public class OAuth2TokenServiceIntegrationTest extends NativeLibraryTestBase {
mChromeSigninController = ChromeSigninController.get(mContext);
mChromeSigninController.setSignedInAccountName(null);
+ // Seed test accounts to AccountTrackerService.
+ seedAccountTrackerService(mContext);
+
// Get a reference to the service.
mOAuth2TokenService = getOAuth2TokenServiceOnUiThread();
@@ -66,6 +72,46 @@ public class OAuth2TokenServiceIntegrationTest extends NativeLibraryTestBase {
addObserver(mObserver);
}
+ @Override
+ protected void tearDown() throws Exception {
+ mChromeSigninController.setSignedInAccountName(null);
+ super.tearDown();
+ }
+
+ private void mapAccountNamesToIds() {
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ AccountIdProvider.setInstanceForTest(new AccountIdProvider() {
+ @Override
+ public String getAccountId(Context ctx, String accountName) {
+ return "gaia-id-" + accountName;
+ }
+
+ @Override
+ public boolean canBeUsed(Context ctx, Activity activity) {
+ return true;
+ }
+ });
+ }
+ });
+ }
+
+ private void seedAccountTrackerService(Context context) {
nyquist 2015/09/11 00:42:52 Add final to this argument
+ final Context mContext = context;
nyquist 2015/09/11 00:42:52 remove this since it's not necessary. Also, for fu
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ AccountIdProvider provider = AccountIdProvider.getInstance();
+ String[] accountNames = {TEST_ACCOUNT1.name, TEST_ACCOUNT2.name};
+ String[] accountIds = {provider.getAccountId(mContext, accountNames[0]),
+ provider.getAccountId(mContext, accountNames[1])};
+ AccountTrackerService.get(mContext).syncForceRefreshForTest(
+ accountIds, accountNames);
+ }
+ });
+ }
+
/**
* The {@link OAuth2TokenService} and the {@link Profile} can only be accessed from the UI
* thread, so this helper method is a convenience method to retrieve it.
@@ -129,7 +175,7 @@ public class OAuth2TokenServiceIntegrationTest extends NativeLibraryTestBase {
// When removed, an observer should not be called.
mOAuth2TokenService.removeObserver(mObserver);
- mOAuth2TokenService.fireRefreshTokenRevoked(TEST_ACCOUNT1);
+ mOAuth2TokenService.fireRefreshTokenRevoked(TEST_ACCOUNT2);
assertEquals(1, mObserver.getRevokedCallCount());
// No other observer interface method should ever have been called.

Powered by Google App Engine
This is Rietveld 408576698