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

Unified Diff: tools/chrome_remote_control/chrome_remote_control/browser_finder.py

Issue 10875044: Basic framework for devtools-based scrolling tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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
Index: tools/chrome_remote_control/chrome_remote_control/browser_finder.py
diff --git a/tools/chrome_remote_control/chrome_remote_control/browser_finder.py b/tools/chrome_remote_control/chrome_remote_control/browser_finder.py
new file mode 100644
index 0000000000000000000000000000000000000000..3cd12eccd0aa9e79a97ec42c4127ade425816ab9
--- /dev/null
+++ b/tools/chrome_remote_control/chrome_remote_control/browser_finder.py
@@ -0,0 +1,75 @@
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os as real_os
+import sys as real_sys
+import subprocess as real_subprocess
+
+def Find(options,
+ chrome_src_dir = None,
+ os = real_os,
+ sys = real_sys,
+ subprocess = real_subprocess):
+ # Use an absolute browser path if given
+ if options.browser_executable:
+ if os.path.exists(options.browser_executable):
+ return options.browser_executable
+ return None
+
+ # Look for a browser in the standard chrome build locations.
+ if chrome_src_dir == None:
+ chrome_src_dir = os.path.join(os.path.dirname(__file__), "../../../")
+
+ if options.debug:
+ buildname = "Debug"
+ else:
+ buildname = "Release"
+
+ if sys.platform == 'darwin':
+ app_name = "Chromium.app/Contents/MacOS/Chromium"
+ elif sys.platform.startswith('linux'):
+ app_name = "chrome"
+ elif sys.platform == 'win':
+ app_name = "chrome.exe"
+ else:
+ raise Exception("Platform not recognized")
+
+ built_app = os.path.join(chrome_src_dir, "out", buildname, app_name)
+ if os.path.exists(built_app):
+ return built_app
+
+ # Look for an installed version of the browser.
+ if sys.platform == 'darwin':
+ mac_canary = "/Applications/Google Chrome Canary.app/" +
dtu 2012/08/24 08:55:43 Parentheses around these string literals, and you
+ "Contents/MacOS/Google Chrome Canary"
+ mac_stable = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
+ if options.canary:
+ if os.path.exists(mac_canary):
+ return mac_canary
+ return None
+
+ if os.path.exists(mac_stable):
+ return mac_stable
+
+ if os.path.exists(mac_canary):
+ return mac_canary
+
+ # TODO(nduca): Look for a browser in the cwd
+ return None
+
+ if sys.platform.startswith('linux'):
+ if options.canary:
+ return None
+
+ # look for a google-chrome
+ found = False
+ try:
+ found = subprocess.call(['google-chrome', '--version']) == 0
+ except OSError:
+ pass
+ if found:
+ return 'google-chrome'
+ return None
+
+ raise Exception("Unsupported platform.")

Powered by Google App Engine
This is Rietveld 408576698