Skip to content
This repository has been archived by the owner on Aug 20, 2018. It is now read-only.

Commit

Permalink
Bug 860790 - Add support for loading page from already running browser
Browse files Browse the repository at this point in the history
  • Loading branch information
wlach committed Apr 22, 2013
1 parent b4083b7 commit 84e9d0c
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 12 deletions.
18 changes: 14 additions & 4 deletions src/eideticker/eideticker/runner.py
Expand Up @@ -17,13 +17,14 @@ class AndroidBrowserRunner(object):
intent = "android.intent.action.VIEW"

def __init__(self, dm, appname, url, tmpdir, preinitialize_user_profile=False,
enable_profiling=False, gecko_profiler_addon_dir=None,
extra_prefs={}):
open_url_after_launch=False, enable_profiling=False,
gecko_profiler_addon_dir=None, extra_prefs={}):
self.dm = dm
self.appname = appname
self.url = url
self.tmpdir = tmpdir
self.preinitialize_user_profile = preinitialize_user_profile
self.open_url_after_launch = open_url_after_launch
self.enable_profiling = enable_profiling
self.gecko_profiler_addon_dir = gecko_profiler_addon_dir
self.extra_prefs = extra_prefs
Expand Down Expand Up @@ -138,12 +139,22 @@ def start(self):
mozEnv = None

# launch fennec for reals
self.launch_fennec(mozEnv, self.url)
if self.open_url_after_launch:
self.launch_fennec(mozEnv, None)
else:
self.launch_fennec(mozEnv, self.url)
else:
self.is_profiling = False # never profiling with non-fennec browsers
if self.open_url_after_launch:
raise Exception("Opening URL after launch not currently "
"supported on non-fennec browsers")
self.dm.launchApplication(self.appname, self.activity, self.intent,
url=self.url)

def open_url(self):
self.dm.launchFennec(self.appname, mozEnv=None, url=self.url,
failIfRunning=False)

def launch_fennec(self, mozEnv, url):
# sometimes fennec fails to start, so we'll try three times...
for i in range(3):
Expand All @@ -157,7 +168,6 @@ def launch_fennec(self, mozEnv, url):
return # Ok!
raise Exception("Failed to start Fennec after three tries")


def save_profile(self):
# Dump the profile (don't process it yet because we need to cleanup
# the capture first)
Expand Down
1 change: 1 addition & 0 deletions src/eideticker/eideticker/runtest.py
Expand Up @@ -94,6 +94,7 @@ def run_test(testkey, capture_device, devicetype, appname, capture_name,
activity = testinfo.get('activity'),
intent = testinfo.get('intent'),
preinitialize_user_profile = int(testinfo.get('preInitializeProfile', 0)),
open_url_after_launch = bool(testinfo.get('openURLAfterLaunch')),
checkerboard_log_file = checkerboard_log_file,
profile_file = profile_file,
gecko_profiler_addon_dir=GECKO_PROFILER_ADDON_DIR,
Expand Down
32 changes: 26 additions & 6 deletions src/eideticker/eideticker/test.py
Expand Up @@ -222,7 +222,9 @@ class AndroidWebTest(WebTest):

def __init__(self, appname = None, extra_prefs = {}, profile_file = None,
preinitialize_user_profile = False,
gecko_profiler_addon_dir = None, checkerboard_log_file = None,
open_url_after_launch=False,
gecko_profiler_addon_dir = None,
checkerboard_log_file = None,
**kwargs):
super(AndroidWebTest, self).__init__(**kwargs)

Expand All @@ -232,6 +234,7 @@ def __init__(self, appname = None, extra_prefs = {}, profile_file = None,
self.profile_file = profile_file
self.gecko_profiler_addon_dir = gecko_profiler_addon_dir
self.preinitialize_user_profile = preinitialize_user_profile
self.open_url_after_launch = open_url_after_launch

# If we're logging checkerboard stats, set that up here (seems like it
# takes a second or so to accept the new setting, so let's do that here --
Expand All @@ -254,6 +257,7 @@ def __init__(self, appname = None, extra_prefs = {}, profile_file = None,
self.runner = eideticker.AndroidBrowserRunner(self.device, self.appname,
self.url, self.tempdir,
preinitialize_user_profile=self.preinitialize_user_profile,
open_url_after_launch = self.open_url_after_launch,
enable_profiling=bool(self.profile_file),
gecko_profiler_addon_dir=gecko_profiler_addon_dir,
extra_prefs=self.extra_prefs)
Expand Down Expand Up @@ -314,13 +318,29 @@ def __init__(self, **kwargs):
self.capture_controller.find_end_signal = False

def run(self):
# FIXME: currently start capture before launching app because we wait until app is
# launched -- would be better to make waiting optional and then start capture
# after triggering app launch to reduce latency?
self.runner.initialize_user_profile()
self.start_capture()

super(AndroidWebStartupTest, self).run()
if not self.open_url_after_launch:
# FIXME: currently start capture before launching app because we
# wait until app is launched -- would be better to make waiting
# optional and then start capture after triggering app launch to
# reduce latency?
self.start_capture()
self.runner.start()
else:
self.runner.start()
# make sure fennec has actually started by sleeping for a bit.
# this is a fairly arbitrary value but not sure of a better way
time.sleep(5)
self.start_capture()
self.runner.open_url()

self.wait()

if self.profile_file:
self.runner.process_profile(self.profile_file)

self.runner.cleanup()

@property
def url(self):
Expand Down
2 changes: 1 addition & 1 deletion src/mozbase
Submodule mozbase updated from da601b to 42b72f
2 changes: 1 addition & 1 deletion src/tests/ep1
Submodule ep1 updated from 7251c0 to 169e6a

0 comments on commit 84e9d0c

Please sign in to comment.