Beispiel #1
0
    def run(self):
        apps = GaiaApps(self.device.marionette)
        # open two apps
        for name in ['Contacts', 'Clock', 'Music']:
            app = apps.launch(name)
            assert app.frame_id is not None

        # switch back to main frame
        self.device.marionette.switch_to_frame()

        # open cards view
        self.device.marionette.execute_script(
            "window.dispatchEvent(new Event('holdhome'));")

        # launching apps can reset orientation to the wrong value, since some
        # apps only support portrait mode. reset it here.
        self.device.resetOrientation()

        self.start_capture()
        self.test_started()
        for i in range(3):
            for command in ['swipe_left', 'swipe_left', 'swipe_right',
                            'swipe_right']:
                self.device.executeCommand(command, [])
                time.sleep(0.5)
        self.test_finished()
        self.end_capture()
Beispiel #2
0
 def launch_app(self):
     # launch app and wait for it to "settle" so that it's ready for use
     # (this is a naive implementation that just assumes that we're done
     # "loading" after 5 seconds -- feel free to override this method in
     # your test)
     apps = GaiaApps(self.device.marionette)
     app = apps.launch(self.appname)
     assert app.frame_id is not None
     time.sleep(5)
Beispiel #3
0
 def __init__(self, app_name, app_id, device=False):
     self.device = device
     if self.device:
         call(['adb', 'forward', 'tcp:2828', 'tcp:2828'])
     self._app_name = app_name
     self._app_id = app_id
     self._marionette = Marionette()
     self._marionette.start_session()
     self._gaia_apps = GaiaApps(self._marionette)
     self._gaia_data = GaiaData(self._marionette)
     self._gaia_device = GaiaDevice(self._marionette)
     ''' Deprecated
Beispiel #4
0
    def wait_for_content_ready(self):
        apps = GaiaApps(self.device.marionette)
        contacts = Contacts(self.device.marionette)

        Wait(self.device.marionette).until(
            lambda m: apps.displayed_app.name.lower() == 'contacts')
        apps.switch_to_displayed_app()

        Wait(self.device.marionette,
             120,
             ignored_exceptions=(
                 NoSuchElementException,
                 ElementNotVisibleException)).until(lambda m: m.find_element(
                     *contacts._contact_locator).is_displayed())
Beispiel #5
0
 def wait_for_content_ready(self):
     apps = GaiaApps(self.device.marionette)
     Wait(self.device.marionette).until(
         lambda m: apps.displayed_app.name.lower() == 'marketplace')
     apps.switch_to_displayed_app()
     iframe = Wait(self.device.marionette).until(
         expected.element_present(By.CSS_SELECTOR,
                                  'iframe[src*="marketplace"]'))
     self.device.marionette.switch_to_frame(iframe)
     # FIXME: The below *should* work, but doesn't... just doing an
     # arbitrary
     #Wait(self.device.marionette).until(
     #    lambda m: 'loaded' in m.find_element(
     #        By.TAG_NAME, 'body').get_attribute('class').split()
     time.sleep(30)
Beispiel #6
0
    def setupMarionette(self):
        self.marionette = marionette.Marionette()
        self._logger.info("Waiting for Marionette...")
        self.marionette.wait_for_port()
        self._logger.info("Marionette ready, starting session")
        self.marionette.start_session()
        if 'b2g' not in self.marionette.session:
            raise mozdevice.DMError(
                "bad session value %s returned by start_session" %
                self.marionette.session)
        self.marionette.set_script_timeout(60000)
        self.marionette.timeouts(self.marionette.TIMEOUT_SEARCH, 10000)
        self._logger.info("Marionette ready!")

        self.b2gpopulate = B2GPopulate(self.marionette)
        self.gaiaApps = GaiaApps(self.marionette)
        self.gaiaDevice = GaiaDevice(self.marionette)
Beispiel #7
0
    def run(self):
        self.device.gaiaApps.switch_to_displayed_app()  # switch to homescreen
        appicon = None

        # HACK: Bug 1026527 - perform a no-op swipe before running test to
        # workaround flame not processing input events properly
        self.device.executeCommands([['swipe_right']])

        icons = self.device.marionette.find_elements(
            By.CSS_SELECTOR, 'gaia-grid .icon:not(.placeholder)')
        for icon in icons:
            if icon.text == self.appname:
                self.device.marionette.execute_script(
                    'arguments[0].scrollIntoView(false);', [icon])
                appicon = icon
        if appicon is None:
            raise TestException("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)

        # wait for the app to be displayed
        apps = GaiaApps(self.device.marionette)
        Wait(self.device.marionette).until(
            lambda m: apps.displayed_app.name.lower() == self.appname.lower())
        apps.switch_to_displayed_app()

        self.wait_for_content_ready()

        self.logger.info("Content ready. Waiting an additional second to make "
                         "sure it has settled")
        time.sleep(1)

        self.test_finished()
        self.end_capture()
Beispiel #8
0
 def launch_app(self):
     apps = GaiaApps(self.device.marionette)
     apps.launch('Marketplace')
     self.wait_for_content_ready()
Beispiel #9
0
 def prepare_app(self):
     apps = GaiaApps(self.device.marionette)
     apps.set_permission('Camera', 'geolocation', 'deny')