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

Unified Diff: sync/test/android/javatests/src/org/chromium/sync/test/util/MockAccountManager.java

Issue 467363004: [Android] Check whether MockGrantCredentialsPermissionActivity can be started. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/test/android/javatests/src/org/chromium/sync/test/util/MockAccountManager.java
diff --git a/sync/test/android/javatests/src/org/chromium/sync/test/util/MockAccountManager.java b/sync/test/android/javatests/src/org/chromium/sync/test/util/MockAccountManager.java
index 89410cfe95bcfb671916a136584c89d1c7641594..baf36cd03159dc1573db511e7e4ef96026ffe1ec 100644
--- a/sync/test/android/javatests/src/org/chromium/sync/test/util/MockAccountManager.java
+++ b/sync/test/android/javatests/src/org/chromium/sync/test/util/MockAccountManager.java
@@ -17,6 +17,8 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.pm.ActivityInfo;
+import android.content.pm.PackageManager;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
@@ -349,9 +351,26 @@ public class MockAccountManager implements AccountManagerDelegate {
private Intent newGrantCredentialsPermissionIntent(boolean hasActivity, Account account,
String authTokenType) {
+ ComponentName component = new ComponentName(mTestContext,
+ MockGrantCredentialsPermissionActivity.class.getCanonicalName());
+
+ // Make sure we can start the activity.
+ ActivityInfo ai = null;
+ try {
+ ai = mContext.getPackageManager().getActivityInfo(component, 0);
+ } catch (PackageManager.NameNotFoundException e) {
+ throw new IllegalStateException(
+ "Unable to find " + component.getClassName());
+ }
+ if (ai.applicationInfo != mContext.getApplicationInfo() && !ai.exported) {
+ throw new IllegalStateException(
+ "Unable to start " + ai.name + ". " +
+ "The accounts you added to MockAccountManager may not be " +
+ "configured correctly.");
+ }
+
Intent intent = new Intent();
- intent.setComponent(new ComponentName(mTestContext,
- MockGrantCredentialsPermissionActivity.class.getCanonicalName()));
+ intent.setComponent(component);
intent.putExtra(MockGrantCredentialsPermissionActivity.ACCOUNT, account);
intent.putExtra(MockGrantCredentialsPermissionActivity.AUTH_TOKEN_TYPE, authTokenType);
if (!hasActivity) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698