summaryrefslogtreecommitdiffstats
path: root/content/shell
diff options
context:
space:
mode:
authorleandrogracia@chromium.org <leandrogracia@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-10 12:38:27 +0000
committerleandrogracia@chromium.org <leandrogracia@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-10 12:38:27 +0000
commit58b7e70ddc4923a2c284023a17e7e42be1ee394f (patch)
tree29fca395ea8e0279aceab730266f6f347da20f05 /content/shell
parent535b73c90de52b413e5a9340e4e9864c6f5ba758 (diff)
downloadchromium_src-58b7e70ddc4923a2c284023a17e7e42be1ee394f.zip
chromium_src-58b7e70ddc4923a2c284023a17e7e42be1ee394f.tar.gz
chromium_src-58b7e70ddc4923a2c284023a17e7e42be1ee394f.tar.bz2
[Android] Upstream content detection and ChromeBrowserProvider tests.
BUG=125390,138755 Review URL: https://codereview.chromium.org/11085008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161101 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/shell')
-rw-r--r--content/shell/android/java/src/org/chromium/content_shell/ContentShellActivity.java21
-rw-r--r--content/shell/android/javatests/src/org/chromium/content_shell/ContentShellTestBase.java30
-rw-r--r--content/shell/android/res/values/strings.xml6
3 files changed, 48 insertions, 9 deletions
diff --git a/content/shell/android/java/src/org/chromium/content_shell/ContentShellActivity.java b/content/shell/android/java/src/org/chromium/content_shell/ContentShellActivity.java
index c683c63..64f0347 100644
--- a/content/shell/android/java/src/org/chromium/content_shell/ContentShellActivity.java
+++ b/content/shell/android/java/src/org/chromium/content_shell/ContentShellActivity.java
@@ -27,6 +27,7 @@ public class ContentShellActivity extends Activity {
private static final String ACTIVE_SHELL_URL_KEY = "activeUrl";
public static final String DEFAULT_SHELL_URL = "http://www.google.com";
+ public static final String COMMAND_LINE_ARGS_KEY = "commandLineArgs";
private ShellManager mShellManager;
private ActivityNativeWindow mActivityNativeWindow;
@@ -36,7 +37,13 @@ public class ContentShellActivity extends Activity {
super.onCreate(savedInstanceState);
// Initializing the command line must occur before loading the library.
- if (!CommandLine.isInitialized()) CommandLine.initFromFile(COMMAND_LINE_FILE);
+ if (!CommandLine.isInitialized()) {
+ CommandLine.initFromFile(COMMAND_LINE_FILE);
+ String[] commandLineParams = getCommandLineParamsFromIntent(getIntent());
+ if (commandLineParams != null) {
+ CommandLine.getInstance().appendSwitchesAndArguments(commandLineParams);
+ }
+ }
waitForDebuggerIfNeeded();
LibraryLoader.loadAndInitSync();
@@ -97,6 +104,10 @@ public class ContentShellActivity extends Activity {
@Override
protected void onNewIntent(Intent intent) {
+ if (getCommandLineParamsFromIntent(intent) != null) {
+ Log.i(TAG, "Ignoring command line params: can only be set when creating the activity.");
+ }
+
String url = getUrlFromIntent(intent);
if (!TextUtils.isEmpty(url)) {
Shell activeView = getActiveShell();
@@ -132,6 +143,10 @@ public class ContentShellActivity extends Activity {
return intent != null ? intent.getDataString() : null;
}
+ private static String[] getCommandLineParamsFromIntent(Intent intent) {
+ return intent != null ? intent.getStringArrayExtra(COMMAND_LINE_ARGS_KEY) : null;
+ }
+
/**
* @return The {@link ShellManager} configured for the activity or null if it has not been
* created yet.
@@ -158,7 +173,11 @@ public class ContentShellActivity extends Activity {
private void initializeContentViewResources() {
AppResource.DIMENSION_LINK_PREVIEW_OVERLAY_RADIUS = R.dimen.link_preview_overlay_radius;
+ AppResource.DRAWABLE_ICON_ACTION_BAR_SHARE = R.drawable.ic_menu_share_holo_light;
+ AppResource.DRAWABLE_ICON_ACTION_BAR_WEB_SEARCH = R.drawable.ic_menu_search_holo_light;
AppResource.DRAWABLE_LINK_PREVIEW_POPUP_OVERLAY = R.drawable.popup_zoomer_overlay;
+ AppResource.STRING_ACTION_BAR_SHARE = R.string.action_bar_share;
+ AppResource.STRING_ACTION_BAR_WEB_SEARCH = R.string.action_bar_search;
AppResource.STRING_CONTENT_VIEW_CONTENT_DESCRIPTION = R.string.accessibility_content_view;
AppResource.STRING_MEDIA_PLAYER_MESSAGE_PLAYBACK_ERROR =
R.string.media_player_error_text_invalid_progressive_playback;
diff --git a/content/shell/android/javatests/src/org/chromium/content_shell/ContentShellTestBase.java b/content/shell/android/javatests/src/org/chromium/content_shell/ContentShellTestBase.java
index 1c633db..68d7b8f3 100644
--- a/content/shell/android/javatests/src/org/chromium/content_shell/ContentShellTestBase.java
+++ b/content/shell/android/javatests/src/org/chromium/content_shell/ContentShellTestBase.java
@@ -21,29 +21,47 @@ import org.chromium.content.browser.test.util.CriteriaHelper;
*/
public class ContentShellTestBase extends ActivityInstrumentationTestCase2<ContentShellActivity> {
+ /** The maximum time the waitForActiveShellToBeDoneLoading method will wait. */
+ private static final long WAIT_FOR_ACTIVE_SHELL_LOADING_TIMEOUT = 10000;
+
public ContentShellTestBase() {
super(ContentShellActivity.class);
}
/**
* Starts the ContentShell activity and loads the given URL.
+ * The URL can be null, in which case will default to ContentShellActivity.DEFAULT_SHELL_URL.
*/
protected ContentShellActivity launchContentShellWithUrl(String url) {
+ return launchContentShellWithUrlAndCommandLineArgs(url, null);
+ }
+
+ /**
+ * Starts the ContentShell activity appending the provided command line arguments
+ * and loads the given URL. The URL can be null, in which case will default to
+ * ContentShellActivity.DEFAULT_SHELL_URL.
+ */
+ protected ContentShellActivity launchContentShellWithUrlAndCommandLineArgs(String url,
+ String[] commandLineArgs) {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.setData(Uri.parse(url));
+ if (url != null) intent.setData(Uri.parse(url));
intent.setComponent(new ComponentName(getInstrumentation().getTargetContext(),
ContentShellActivity.class));
+ if (commandLineArgs != null) {
+ intent.putExtra(ContentShellActivity.COMMAND_LINE_ARGS_KEY, commandLineArgs);
+ }
setActivityIntent(intent);
return getActivity();
}
+
/**
- * Waits for the Active shell to finish loading. This times out after three seconds,
- * so it shouldn't be used for long loading pages. Instead it should be used more for
- * test initialization. The proper way to wait is to use a TestCallbackHelperContainer
- * after the initial load is completed.
+ * Waits for the Active shell to finish loading. This times out after
+ * WAIT_FOR_ACTIVE_SHELL_LOADING_TIMEOUT milliseconds and it shouldn't be used for long
+ * loading pages. Instead it should be used more for test initialization. The proper way
+ * to wait is to use a TestCallbackHelperContainer after the initial load is completed.
* @return Whether or not the Shell was actually finished loading.
* @throws Exception
*/
@@ -78,6 +96,6 @@ public class ContentShellTestBase extends ActivityInstrumentationTestCase2<Conte
return false;
}
}
- });
+ }, WAIT_FOR_ACTIVE_SHELL_LOADING_TIMEOUT, CriteriaHelper.DEFAULT_POLLING_INTERVAL);
}
}
diff --git a/content/shell/android/res/values/strings.xml b/content/shell/android/res/values/strings.xml
index 1e4e54d..5e07215 100644
--- a/content/shell/android/res/values/strings.xml
+++ b/content/shell/android/res/values/strings.xml
@@ -7,11 +7,13 @@
-->
<resources>
-
<string name="url_hint">Type URL Here</string>
-
<string name="accessibility_content_view">Web View</string>
+ <!-- Action Bar -->
+ <string name="action_bar_share">Share</string>
+ <string name="action_bar_search">Search</string>
+
<!-- Media Player -->
<string name="media_player_error_title">Cannot play video</string>
<string name="media_player_error_text_invalid_progressive_playback">