def horizontal_launch_by_touch( self, name, switch_to_frame=True, url=None, launch_timeout=None): ''' This function is deprecated because homescreen was changed to vertical ''' homescreen = Homescreen(self.marionette) self.marionette.switch_to_frame() hs = self.marionette.find_element('css selector', '#homescreen iframe') self.marionette.switch_to_frame(hs) homescreen.go_to_next_page() icon = self.marionette.find_element( 'css selector', 'li[aria-label="' + name + '"]:not([data-type="collection"])') while not icon.is_displayed() and homescreen.homescreen_has_more_pages: homescreen.go_to_next_page() get_current_page = "var pageHelper = window.wrappedJSObject.GridManager.pageHelper;return pageHelper.getCurrentPageNumber() > 0;" while not icon.is_displayed() and self.marionette.execute_script(get_current_page): self.marionette.execute_script('window.wrappedJSObject.GridManager.goToPreviousPage()') self.wait_for_condition(lambda m: m.find_element('tag name', 'body').get_attribute('data-transitioning') != 'true') icon.tap() self.marionette.switch_to_frame()
class TestMoveApp(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.homescreen = Homescreen(self.marionette) self.apps.switch_to_displayed_app() def test_move_app_position(self): """Verify the user can move an application around on the homescreen. https://moztrap.mozilla.org/manage/case/1317/ """ # Go to app page self.homescreen.go_to_next_page() first_app_before_move = self.homescreen.visible_apps[0].name # Activate edit mode self.assertFalse(self.homescreen.is_edit_mode_active, "Edit mode should not be active") self.homescreen.activate_edit_mode() self.assertTrue(self.homescreen.is_edit_mode_active, "Edit mode should be active") # Move first app to position 12 self.homescreen.move_app_to_position(0, 12) # Exit edit mode self.device.touch_home_button() self.assertFalse(self.homescreen.is_edit_mode_active, "Edit mode should not be active") # Check the app order and that the app on position 12 is the right one first_app_after_move = self.homescreen.visible_apps[0].name self.assertNotEqual(first_app_before_move, first_app_after_move) self.assertEqual(first_app_before_move, self.homescreen.visible_apps[12].name)
class TestMoveApp(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.homescreen = Homescreen(self.marionette) self.homescreen.launch() def test_move_app_position(self): """ Verify the user can move an application around on the homescreen. https://moztrap.mozilla.org/manage/case/1317/ """ # Go to app page self.homescreen.go_to_next_page() first_app_before_move = self.homescreen.visible_apps[0].name # Activate edit mode self.assertFalse(self.homescreen.is_edit_mode_active, "Edit mode should not be active") self.homescreen.activate_edit_mode() self.assertTrue(self.homescreen.is_edit_mode_active, "Edit mode should be active") # Move first app to position 12 self.homescreen.move_app_to_position(0, 12) # Exit edit mode self.homescreen.touch_home_button() self.homescreen.switch_to_homescreen_frame() self.assertFalse(self.homescreen.is_edit_mode_active, "Edit mode should not be active") # Check the app order and that the app on position 12 is the right one first_app_after_move = self.homescreen.visible_apps[0].name self.assertNotEqual(first_app_before_move, first_app_after_move) self.assertEqual(first_app_before_move, self.homescreen.visible_apps[12].name)
def horizontal_launch_by_touch(self, name, switch_to_frame=True, url=None, launch_timeout=None): ''' This function is deprecated because homescreen was changed to vertical ''' homescreen = Homescreen(self.marionette) self.marionette.switch_to_frame() hs = self.marionette.find_element('css selector', '#homescreen iframe') self.marionette.switch_to_frame(hs) homescreen.go_to_next_page() icon = self.marionette.find_element( 'css selector', 'li[aria-label="' + name + '"]:not([data-type="collection"])') while not icon.is_displayed() and homescreen.homescreen_has_more_pages: homescreen.go_to_next_page() get_current_page = "var pageHelper = window.wrappedJSObject.GridManager.pageHelper;return pageHelper.getCurrentPageNumber() > 0;" while not icon.is_displayed() and self.marionette.execute_script( get_current_page): self.marionette.execute_script( 'window.wrappedJSObject.GridManager.goToPreviousPage()') self.wait_for_condition( lambda m: m.find_element('tag name', 'body').get_attribute( 'data-transitioning') != 'true') icon.tap() self.marionette.switch_to_frame()
def run(self): # kill any open apps (e.g. "firstrun") self.device.killApps() from gaiatest.apps.homescreen.app import Homescreen homescreen = Homescreen(self.device.marionette) self.device.gaiaApps.switch_to_displayed_app() # switch to homescreen appicon = None try: # look for the application icon in the dock first self.log('Looking for app icon in dock') appicon = self.device.marionette.find_element( By.CSS_SELECTOR, '#footer .icon[aria-label="%s"]' % self.appname) except NoSuchElementException: # skip the everything.me page self.device.marionette.execute_async_script( 'window.wrappedJSObject.GridManager.goToPage(1, ' 'marionetteScriptFinished);') for i in range(1, homescreen.homescreen_get_total_pages_number): current_page = self.device.marionette.find_element( By.CSS_SELECTOR, '#icongrid .page:not([aria-hidden=true])') try: self.log('Looking for app icon on page %s' % (i + 1)) appicon = current_page.find_element( By.CSS_SELECTOR, '.icon[aria-label="%s"]' % self.appname) break except NoSuchElementException: if homescreen.homescreen_has_more_pages: homescreen.go_to_next_page() else: raise Exception("Cannot find icon for app with name " "'%s'" % self.appname) tap_x = appicon.location['x'] + (appicon.size['width'] / 2) tap_y = appicon.location['y'] + (appicon.size['height'] / 2) self.start_capture() self.execute_actions([['tap', tap_x, tap_y]], test_finished_after_actions=False) self.log("Waiting %s seconds for app to finish starting" % self.capture_timeout) time.sleep(self.capture_timeout) self.test_finished() self.end_capture()
def run(self): # kill any open apps (e.g. "firstrun") self.device.killApps() from gaiatest.apps.homescreen.app import Homescreen homescreen = Homescreen(self.device.marionette) self.device.gaiaApps.switch_to_displayed_app() # switch to homescreen appicon = None try: # look for the application icon in the dock first self.log('Looking for app icon in dock') appicon = self.device.marionette.find_element( By.CSS_SELECTOR, '#footer .icon[aria-label="%s"]' % self.appname) except NoSuchElementException: # skip the everything.me page self.device.marionette.execute_async_script( 'window.wrappedJSObject.GridManager.goToPage(1, ' 'marionetteScriptFinished);') for i in range(1, homescreen.homescreen_get_total_pages_number): current_page = self.device.marionette.find_element( By.CSS_SELECTOR, '#icongrid .page:not([aria-hidden=true])') try: self.log('Looking for app icon on page %s' % (i + 1)) appicon = current_page.find_element( By.CSS_SELECTOR, '.icon[aria-label="%s"]' % self.appname) break except NoSuchElementException: if homescreen.homescreen_has_more_pages: homescreen.go_to_next_page() else: raise Exception("Cannot find icon for app with name " "'%s'" % self.appname) tap_x = appicon.location['x'] + (appicon.size['width'] / 2) tap_y = appicon.location['y'] + (appicon.size['height'] / 2) self.start_capture() self.execute_actions([['tap', tap_x, tap_y]], test_finished_after_actions=False) self.log("Waiting %s seconds for app to finish starting" % self.capture_timeout) time.sleep(self.capture_timeout) self.test_finished() self.end_capture()
class TestEditMode(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.homescreen = Homescreen(self.marionette) self.homescreen.launch() def test_access_and_leave_edit_mode(self): self.homescreen.go_to_next_page() # Go to edit mode self.homescreen.activate_edit_mode() # Verify that edit mode is active self.assertTrue(self.homescreen.is_edit_mode_active, "Edit mode should be active") # Tap home button and verify that edit mode is no longer active self.homescreen.touch_home_button() self.assertFalse(self.homescreen.is_edit_mode_active, "Edit mode should not be active")
class TestEditMode(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.homescreen = Homescreen(self.marionette) self.apps.switch_to_displayed_app() def test_access_and_leave_edit_mode(self): self.homescreen.go_to_next_page() # Go to edit mode self.homescreen.activate_edit_mode() # Verify that edit mode is active self.assertTrue(self.homescreen.is_edit_mode_active, "Edit mode should be active") # Tap home button and verify that edit mode is no longer active self.homescreen.touch_home_button() self.assertFalse(self.homescreen.is_edit_mode_active, "Edit mode should not be active")
def launch_by_touch(self, name, switch_to_frame=True, url=None, launch_timeout=None): from gaiatest.apps.homescreen.app import Homescreen homescreen = Homescreen(self.marionette) self.marionette.switch_to_frame(self.apps.displayed_app.frame) icon = self.marionette.find_element('css selector', 'li[aria-label="' + name + '"]') while not icon.is_displayed() and homescreen.homescreen_has_more_pages: homescreen.go_to_next_page() while not icon.is_displayed() and self.marionette.execute_script("""var pageHelper = window.wrappedJSObject.GridManager.pageHelper;return pageHelper.getCurrentPageNumber() > 0;"""): self.marionette.execute_script('window.wrappedJSObject.GridManager.goToPreviousPage()') icon.tap() pt = re.compile("_|-") lowered_name = pt.sub("", name).split(' ')[0].lower() self.marionette.switch_to_frame() app = self.marionette.find_element('css selector', "iframe[mozapp^='app://" + lowered_name + "'][mozapp$='manifest.webapp']") iframe_id = app.get_attribute('id') if switch_to_frame: self.marionette.switch_to_frame(iframe_id) return iframe_id