Browse files

Merge pull request #6 from malini/scrollfps

Scrollfps - Added scrolling for the remaining tests
  • Loading branch information...
2 parents 10cffed + 83c6f6e commit af97ceb0e9ae9aa6c97caa69599a8378a3fc7fd4 ctalbert committed Mar 7, 2013
Showing with 56 additions and 2 deletions.
  1. +21 −2 b2gperf/b2gperf.py
  2. +35 −0 b2gperf/gestures.py
View
23 b2gperf/b2gperf.py
@@ -21,6 +21,7 @@
import gaiatest
from marionette import Marionette
from marionette import MarionetteTouchMixin
+from gestures import smooth_scroll
import mozdevice
TEST_TYPES = ['startup', 'scrollfps']
@@ -285,14 +286,32 @@ def scroll_app(self, app_name):
self.marionette.__class__ = type('Marionette', (Marionette, MarionetteTouchMixin), {})
self.marionette.setup_touch()
+ apps = gaiatest.GaiaApps(self.marionette)
if app_name == 'Homescreen':
self.marionette.flick(self.marionette.find_element('id', 'landing-page'), '90%', '50%', '10%', '50%', touch_duration)
time.sleep(touch_duration / 1000)
self.marionette.flick(self.marionette.find_elements('css selector', '.page')[1], '10%', '50%', '90%', '50%', touch_duration)
elif app_name == 'Contacts':
- print "SCROLL ME NOW"
- time.sleep(25)
+ contacts = apps.launch('Contacts')
+ time.sleep(5) # wait for the contacts to load
+ names = self.marionette.find_elements("class name", "contact-item")
+ smooth_scroll(self.marionette, names[0], "y", "negative", 5000, scroll_back=False)
+ time.sleep(5)
+ elif app_name == 'Browser':
+ browser = apps.launch('Browser')
+ #navigate is misbehaving
+ self.marionette.execute_script("window.location.href='http://taskjs.org/';")
+ time.sleep(5) # 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)
+ time.sleep(5)
+ elif app_name == 'Email':
+ email = apps.launch('Email')
+ time.sleep(10) # wait for the page to load
+ emails = self.marionette.find_elements("class name", "msg-header-item")
+ smooth_scroll(self.marionette, emails[0], "y", "negative", 2000, scroll_back=True)
+ time.sleep(5)
class dzOptionParser(OptionParser):
View
35 b2gperf/gestures.py
@@ -0,0 +1,35 @@
+from marionette import Actions
+
+#axis is y or x
+#direction is negative or positive
+def smooth_scroll(marionette_session, start_element, axis, direction, length, increments=None, wait_period=None, scroll_back=None):
+ if axis not in ["x", "y"]:
+ raise Exception("Axis must be either 'x' or 'y'")
+ if direction not in ["negative", "positive"]:
+ raise Exception("Direction must either be negative or positive")
+ increments = increments or 100
+ wait_period = wait_period or 0.05
+ scroll_back = scroll_back or False
+ current = 0
+ if axis is "x":
+ if direction is "negative":
+ offset = [-increments, 0]
+ else:
+ offset = [increments, 0]
+ else:
+ if direction is "negative":
+ offset = [0, -increments]
+ else:
+ offset = [0, increments]
+ action = Actions(marionette_session)
+ action.press(start_element)
+ while (current < length):
+ current += increments
+ action.move_by_offset(*offset).wait(wait_period)
+ if scroll_back:
+ offset = [-value for value in offset]
+ while (current > 0):
+ current -= increments
+ action.move_by_offset(*offset).wait(wait_period)
+ action.release()
+ action.perform()

0 comments on commit af97ceb

Please sign in to comment.