Skip to content
Browse files

get Email test working without sleeps, and get Browser test reporting…

… fps
  • Loading branch information...
1 parent 4c141ef commit 2d6cd5267c225e8a244bfa25fad8e2722aee8c8c @malini committed
Showing with 27 additions and 9 deletions.
  1. +27 −9 b2gperf/b2gperf.py
View
36 b2gperf/b2gperf.py
@@ -234,18 +234,19 @@ def test_scrollfps(self):
time.sleep(self.delay)
period = 5000 # ms
sample_hz = 100
- self.marionette.set_script_timeout(period + 1000)
# Launch the app
app = apps.launch(app_name, switch_to_frame=False)
# Wait for app to load - TODO: can't we be smarter?
time.sleep(1)
# Turn on FPS
+ self.marionette.set_script_timeout(period + 1000)
result = self.marionette.execute_async_script('window.wrappedJSObject.fps = new fps_meter("%s", %d, %d); window.wrappedJSObject.fps.start_fps();' % (app_name, period, sample_hz))
if not result:
raise Exception('Error turning on fps measurement')
# Do scroll
+ self.marionette.set_script_timeout(60000)
self.marionette.switch_to_frame(app.frame)
self.scroll_app(app_name)
self.marionette.execute_async_script('window.addEventListener("touchend", function(){ marionetteScriptFinished();}, false)', new_sandbox=False)
@@ -318,16 +319,33 @@ def wait_for_visible(element, timeout=30):
# TODO: let's see if we can use touchend to know exactly when the scroll is finished so we aren't
# measuring fps while we are not actually scrolling.
elif app_name == 'Browser':
- browser = apps.launch('Browser')
#TODO: navigate is misbehaving
- self.marionette.execute_script("window.location.href='http://taskjs.org/';")
- time.sleep(10) # wait for the page to load
- a = self.marionette.find_element("tag name", "a")
- smooth_scroll(self.marionette, a, "y", "negative", 5000, scroll_back=True)
+ self.marionette.execute_script("return window.wrappedJSObject.Browser.navigate('http://taskjs.org/');", new_sandbox=False)
+ print self.marionette.execute_script("return window.wrappedJSObject.Browser.currentTab.loading;", new_sandbox=False)
+ while self.marionette.execute_script("return window.wrappedJSObject.Browser.currentTab.loading;", new_sandbox=False) != True:
+ print self.marionette.execute_script("return window.wrappedJSObject.Browser.currentTab.loading;", new_sandbox=False)
+ time.sleep(0.1)
+ # check when the tab's document is ready
+ tab_frame = self.marionette.execute_script("return window.wrappedJSObject.Browser.currentTab.dom;")
+ self.marionette.switch_to_frame(tab_frame)
+ while self.marionette.execute_script("return window.document.readyState;", new_sandbox=False) != "complete":
+ print self.marionette.execute_script("return window.document.readyState;", new_sandbox=False)
+ time.sleep(0.1)
+ # we have to fire smooth_scroll from the browser app, so let's go back
+ self.marionette.switch_to_frame()
+ apps = apps.launch(app_name) # since the app is launched, launch will switch us back to the app frame without relaunching
+ tab_dom = self.marionette.execute_script("return window.wrappedJSObject.Browser.currentTab.dom;", new_sandbox=False)
+ smooth_scroll(self.marionette, tab_dom, "y", "negative", 5000, scroll_back=True)
+ # This makes no sense, but this confounding hack is the only way to get fps defined in system apps' window object for some reason.
+ self.marionette.switch_to_frame(tab_frame)
+
elif app_name == 'Email':
- email = self.marionette.find_element("class name", "msg-header-item")
- time.sleep(5)
- smooth_scroll(self.marionette, email, "y", "negative", 2000, scroll_back=True)
+ emails = self.marionette.find_elements("class name", "msg-header-author")
+ #we're dynamically adding these elements from a template, and the first one found is blank.
+ while not emails[0].get_attribute("innerHTML"):
+ time.sleep(0.2)
+ emails = self.marionette.find_elements("class name", "msg-header-author")
+ smooth_scroll(self.marionette, emails[0], "y", "negative", 2000, scroll_back=True)
class dzOptionParser(OptionParser):

0 comments on commit 2d6cd52

Please sign in to comment.
Something went wrong with that request. Please try again.