Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #6 from malini/scrollfps

Scrollfps - Added scrolling for the remaining tests
  • Loading branch information...
commit af97ceb0e9ae9aa6c97caa69599a8378a3fc7fd4 2 parents 10cffed + 83c6f6e
ctalbert ctalbert authored

Showing 2 changed files with 56 additions and 2 deletions. Show diff stats Hide diff stats

  1. +21 2 b2gperf/b2gperf.py
  2. +35 0 b2gperf/gestures.py
23 b2gperf/b2gperf.py
@@ -21,6 +21,7 @@
21 21 import gaiatest
22 22 from marionette import Marionette
23 23 from marionette import MarionetteTouchMixin
  24 +from gestures import smooth_scroll
24 25 import mozdevice
25 26
26 27 TEST_TYPES = ['startup', 'scrollfps']
@@ -285,14 +286,32 @@ def scroll_app(self, app_name):
285 286 self.marionette.__class__ = type('Marionette', (Marionette, MarionetteTouchMixin), {})
286 287
287 288 self.marionette.setup_touch()
  289 + apps = gaiatest.GaiaApps(self.marionette)
288 290
289 291 if app_name == 'Homescreen':
290 292 self.marionette.flick(self.marionette.find_element('id', 'landing-page'), '90%', '50%', '10%', '50%', touch_duration)
291 293 time.sleep(touch_duration / 1000)
292 294 self.marionette.flick(self.marionette.find_elements('css selector', '.page')[1], '10%', '50%', '90%', '50%', touch_duration)
293 295 elif app_name == 'Contacts':
294   - print "SCROLL ME NOW"
295   - time.sleep(25)
  296 + contacts = apps.launch('Contacts')
  297 + time.sleep(5) # wait for the contacts to load
  298 + names = self.marionette.find_elements("class name", "contact-item")
  299 + smooth_scroll(self.marionette, names[0], "y", "negative", 5000, scroll_back=False)
  300 + time.sleep(5)
  301 + elif app_name == 'Browser':
  302 + browser = apps.launch('Browser')
  303 + #navigate is misbehaving
  304 + self.marionette.execute_script("window.location.href='http://taskjs.org/';")
  305 + time.sleep(5) # wait for the page to load
  306 + a = self.marionette.find_element("tag name", "a")
  307 + smooth_scroll(self.marionette, a, "y", "negative", 5000, scroll_back=True)
  308 + time.sleep(5)
  309 + elif app_name == 'Email':
  310 + email = apps.launch('Email')
  311 + time.sleep(10) # wait for the page to load
  312 + emails = self.marionette.find_elements("class name", "msg-header-item")
  313 + smooth_scroll(self.marionette, emails[0], "y", "negative", 2000, scroll_back=True)
  314 + time.sleep(5)
296 315
297 316
298 317 class dzOptionParser(OptionParser):
35 b2gperf/gestures.py
... ... @@ -0,0 +1,35 @@
  1 +from marionette import Actions
  2 +
  3 +#axis is y or x
  4 +#direction is negative or positive
  5 +def smooth_scroll(marionette_session, start_element, axis, direction, length, increments=None, wait_period=None, scroll_back=None):
  6 + if axis not in ["x", "y"]:
  7 + raise Exception("Axis must be either 'x' or 'y'")
  8 + if direction not in ["negative", "positive"]:
  9 + raise Exception("Direction must either be negative or positive")
  10 + increments = increments or 100
  11 + wait_period = wait_period or 0.05
  12 + scroll_back = scroll_back or False
  13 + current = 0
  14 + if axis is "x":
  15 + if direction is "negative":
  16 + offset = [-increments, 0]
  17 + else:
  18 + offset = [increments, 0]
  19 + else:
  20 + if direction is "negative":
  21 + offset = [0, -increments]
  22 + else:
  23 + offset = [0, increments]
  24 + action = Actions(marionette_session)
  25 + action.press(start_element)
  26 + while (current < length):
  27 + current += increments
  28 + action.move_by_offset(*offset).wait(wait_period)
  29 + if scroll_back:
  30 + offset = [-value for value in offset]
  31 + while (current > 0):
  32 + current -= increments
  33 + action.move_by_offset(*offset).wait(wait_period)
  34 + action.release()
  35 + action.perform()

0 comments on commit af97ceb

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