summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfrankf@chromium.org <frankf@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-02 19:45:35 +0000
committerfrankf@chromium.org <frankf@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-02 19:45:35 +0000
commit49cc02d62108097cb6415b8f41327e14b74d5355 (patch)
treee75720fa111f33de945459eac94cf464e8415c4b
parentb312914ec2304ca347876ec1aefdbcd4717ea27c (diff)
downloadchromium_src-49cc02d62108097cb6415b8f41327e14b74d5355.zip
chromium_src-49cc02d62108097cb6415b8f41327e14b74d5355.tar.gz
chromium_src-49cc02d62108097cb6415b8f41327e14b74d5355.tar.bz2
[chromedriver] Set chrome flags to enable devtools on startup.
Also, specify the landing URL on app launch, rather than doing a Load from ChromeDriver. NOTRY=True BUG=166722 Review URL: https://chromiumcodereview.appspot.com/12394002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@185771 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-xchrome/test/chromedriver/adb_commands.py28
-rw-r--r--chrome/test/chromedriver/chrome_android_impl.cc5
-rw-r--r--chrome/test/chromedriver/chrome_android_impl.h3
-rw-r--r--chrome/test/chromedriver/chrome_desktop_impl.cc5
-rw-r--r--chrome/test/chromedriver/chrome_desktop_impl.h3
-rw-r--r--chrome/test/chromedriver/commands.cc5
6 files changed, 31 insertions, 18 deletions
diff --git a/chrome/test/chromedriver/adb_commands.py b/chrome/test/chromedriver/adb_commands.py
index 241b68b..ae44be9 100755
--- a/chrome/test/chromedriver/adb_commands.py
+++ b/chrome/test/chromedriver/adb_commands.py
@@ -52,7 +52,7 @@ def RunAdbCommand(args, cwd=None):
Raises:
AdbError: if exit code is non-zero.
"""
- args.insert(0, 'adb')
+ args = ['adb', '-d'] + args
try:
p = subprocess.Popen(args, cwd=cwd, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
@@ -66,6 +66,21 @@ def RunAdbCommand(args, cwd=None):
raise e
+def SetChromeFlags():
+ """Sets the command line flags file on device.
+
+ Raises:
+ AdbError: If failed to write the flags file to device.
+ """
+ out, cmd = RunAdbCommand([
+ 'shell',
+ 'echo chrome --disable-fre --metrics-recording-only '
+ '--enable-remote-debugging > /data/local/chrome-command-line'
+ ])
+ if out.strip():
+ raise AdbError('Failed to set the command line flags.', out, cmd)
+
+
def ClearAppData(package):
"""Clears the app data.
@@ -75,7 +90,7 @@ def ClearAppData(package):
Raises:
AdbError: if any step fails.
"""
- out, cmd = RunAdbCommand(['shell', 'pm', 'clear', package])
+ out, cmd = RunAdbCommand(['shell', 'pm clear %s' % package])
# am/pm package do not return valid exit codes.
if 'Success' not in out:
raise AdbError('Failed to clear the profile.', out, cmd)
@@ -90,9 +105,11 @@ def LaunchApp(package):
Raises:
AdbError: if any step fails.
"""
- out, cmd = RunAdbCommand(
- ['shell', 'am', 'start', '-a', 'android.intent.action.VIEW',
- '-S', '-W', '-n', '%s/%s' % (package, PACKAGE_INFO[package][0])])
+ out, cmd = RunAdbCommand([
+ 'shell',
+ 'am start -a android.intent.action.VIEW -S -W -n %s/%s '
+ '-d "data:text/html;charset=utf-8,"' %
+ (package, PACKAGE_INFO[package][0])])
if 'Complete' not in out:
raise AdbError('Failed to start the app. %s', out, cmd)
@@ -132,6 +149,7 @@ if __name__ == '__main__':
PACKAGE_INFO.keys())
if options.launch:
+ SetChromeFlags()
ClearAppData(options.package)
LaunchApp(options.package)
Forward(options.package, options.port)
diff --git a/chrome/test/chromedriver/chrome_android_impl.cc b/chrome/test/chromedriver/chrome_android_impl.cc
index def60c7..0787396 100644
--- a/chrome/test/chromedriver/chrome_android_impl.cc
+++ b/chrome/test/chromedriver/chrome_android_impl.cc
@@ -21,8 +21,7 @@ ChromeAndroidImpl::ChromeAndroidImpl(
ChromeAndroidImpl::~ChromeAndroidImpl() {}
-Status ChromeAndroidImpl::Launch(const std::string& package_name,
- const std::string& landing_url) {
+Status ChromeAndroidImpl::Launch(const std::string& package_name) {
// TODO(frankf): Figure out how this should be installed to
// make this work for all platforms.
base::FilePath adb_commands(FILE_PATH_LITERAL("adb_commands.py"));
@@ -54,7 +53,7 @@ Status ChromeAndroidImpl::Launch(const std::string& package_name,
Status(kUnknownError, "unable to discover open window in chrome");
}
- return web_views.front()->Load(landing_url);
+ return Status(kOk);
}
Status ChromeAndroidImpl::Quit() {
diff --git a/chrome/test/chromedriver/chrome_android_impl.h b/chrome/test/chromedriver/chrome_android_impl.h
index 5c520cb6..78f5fe3 100644
--- a/chrome/test/chromedriver/chrome_android_impl.h
+++ b/chrome/test/chromedriver/chrome_android_impl.h
@@ -21,8 +21,7 @@ class ChromeAndroidImpl : public ChromeImpl {
const SyncWebSocketFactory& socket_factory);
virtual ~ChromeAndroidImpl();
- virtual Status Launch(const std::string& package_name,
- const std::string& landing_url);
+ virtual Status Launch(const std::string& package_name);
// Overridden from ChromeImpl:
virtual Status Quit() OVERRIDE;
diff --git a/chrome/test/chromedriver/chrome_desktop_impl.cc b/chrome/test/chromedriver/chrome_desktop_impl.cc
index a6233c4..e2d3e50 100644
--- a/chrome/test/chromedriver/chrome_desktop_impl.cc
+++ b/chrome/test/chromedriver/chrome_desktop_impl.cc
@@ -26,8 +26,7 @@ ChromeDesktopImpl::~ChromeDesktopImpl() {
}
Status ChromeDesktopImpl::Launch(const base::FilePath& chrome_exe,
- const base::ListValue* chrome_args,
- const std::string& landing_url) {
+ const base::ListValue* chrome_args) {
base::FilePath program = chrome_exe;
if (program.empty()) {
if (!FindChrome(&program))
@@ -43,7 +42,7 @@ Status ChromeDesktopImpl::Launch(const base::FilePath& chrome_exe,
if (!user_data_dir_.CreateUniqueTempDir())
return Status(kUnknownError, "cannot create temp dir for user data dir");
command.AppendSwitchPath("user-data-dir", user_data_dir_.path());
- command.AppendArg(landing_url);
+ command.AppendArg("data:text/html;charset=utf-8,");
if (chrome_args) {
Status status = internal::ProcessCommandLineArgs(chrome_args, &command);
diff --git a/chrome/test/chromedriver/chrome_desktop_impl.h b/chrome/test/chromedriver/chrome_desktop_impl.h
index bf416fa..8614429 100644
--- a/chrome/test/chromedriver/chrome_desktop_impl.h
+++ b/chrome/test/chromedriver/chrome_desktop_impl.h
@@ -28,8 +28,7 @@ class ChromeDesktopImpl : public ChromeImpl {
virtual ~ChromeDesktopImpl();
virtual Status Launch(const base::FilePath& chrome_exe,
- const base::ListValue* chrome_args,
- const std::string& landing_url);
+ const base::ListValue* chrome_args);
// Overridden from ChromeImpl:
virtual Status Quit() OVERRIDE;
diff --git a/chrome/test/chromedriver/commands.cc b/chrome/test/chromedriver/commands.cc
index 21f3955..2d8b026 100644
--- a/chrome/test/chromedriver/commands.cc
+++ b/chrome/test/chromedriver/commands.cc
@@ -51,14 +51,13 @@ Status ExecuteNewSession(
scoped_ptr<Chrome> chrome;
Status status(kOk);
int port = 33081;
- std::string landing_url("data:text/html;charset=utf-8,");
std::string android_package;
if (params.GetString("desiredCapabilities.chromeOptions.android_package",
&android_package)) {
scoped_ptr<ChromeAndroidImpl> chrome_android(new ChromeAndroidImpl(
context_getter, port, socket_factory));
- status = chrome_android->Launch(android_package, landing_url);
+ status = chrome_android->Launch(android_package);
chrome.reset(chrome_android.release());
} else {
base::FilePath::StringType path_str;
@@ -84,7 +83,7 @@ Status ExecuteNewSession(
scoped_ptr<ChromeDesktopImpl> chrome_desktop(new ChromeDesktopImpl(
context_getter, port, socket_factory));
- status = chrome_desktop->Launch(chrome_exe, args_list, landing_url);
+ status = chrome_desktop->Launch(chrome_exe, args_list);
chrome.reset(chrome_desktop.release());
}
if (status.IsError())