Exemplo n.º 1
0
    def setUp(self):
        GaiaMtbfTestCase.setUp(self)
        self.data_layer = GaiaData(self.marionette)
        self.data_layer.connect_to_cell_data()

        self.browser = Browser(self.marionette)
        self.browser.launch()
Exemplo n.º 2
0
def set_up_device(opt):
    if not opt.wifi_ssid or not opt.wifi_key or not opt.wifi_pass:
        raise ValueError('Missing --wifi options')

    mc = Marionette('localhost', opt.adb_port)
    for i in range(2):
        try:
            mc.start_session()
            break
        except socket.error:
            sh('adb forward tcp:%s tcp:%s' % (opt.adb_port, opt.adb_port))
    if opt.shell:
        from pdb import set_trace
        set_trace()
        return

    # watch out! This is how gaiatest does it.
    mc.__class__ = type('Marionette', (Marionette, MarionetteTouchMixin), {})
    device = GaiaDevice(mc)

    device.restart_b2g()

    apps = GaiaApps(mc)
    data_layer = GaiaData(mc)
    lockscreen = LockScreen(mc)
    mc.setup_touch()

    lockscreen.unlock()
    apps.kill_all()

    data_layer.enable_wifi()
    if opt.wifi_key == 'WPA-PSK':
        pass_key = 'psk'
    elif opt.wifi_key == 'WEP':
        pass_key = 'wep'
    else:
        assert 0, 'unknown key management'
    data = {'ssid': opt.wifi_ssid, 'keyManagement': opt.wifi_key,
            pass_key: opt.wifi_pass}
    data_layer.connect_to_wifi(data)

    mc.switch_to_frame()
    all_apps = set(a['manifest']['name'] for a in get_installed(apps))
    if 'Marketplace Dev' not in all_apps:
        mc.execute_script(
            'navigator.mozApps.install'
            '("https://marketplace-dev.allizom.org/manifest.webapp");')
        wait_for_element_displayed(mc, 'id', 'app-install-install-button')
        yes = mc.find_element('id', 'app-install-install-button')
        mc.tap(yes)
        wait_for_element_displayed(mc, 'id', 'system-banner')

    print 'Pushing payment prefs'
    sh('adb shell stop b2g')
    sh('adb push "%s" /data/local/user.js' % (
        os.path.join(os.path.dirname(__file__), 'payment-prefs.js')))
    sh('adb shell start b2g')

    print 'When your device reboots, Marketplace Dev will be installed'
    def setUp(self):
        GaiaMtbfTestCase.setUp(self)
        self.data_layer.disable_wifi()
        self.data_layer.disable_cell_data()

        self.data_layer = GaiaData(self.marionette)
        self.data_layer.connect_to_cell_data()

        self.search = Search(self.marionette)
        self.search.launch()
Exemplo n.º 4
0
    def restart(self):
        self.parent.reporting.logResult('info', 'Restarting the device...')
        # Lockscreen does not get on very well with restarts
        lock_enabled = self.parent.data_layer.get_setting("lockscreen.enabled")
        if lock_enabled:
            self.parent.data_layer.set_setting("lockscreen.enabled", False)

        # After restarting we need to re-instantiate javascript objects
        self.parent.device.restart_b2g()
        self.apps = GaiaApps(self.marionette)
        self.parent.data_layer = GaiaData(self.marionette, self.parent.parent.testvars)
        # Restore lockscreen status
        self.parent.data_layer.set_setting("lockscreen.enabled", lock_enabled)
Exemplo n.º 5
0
    def install_apps():
        mc = get_marionette(args)
        device = GaiaDevice(mc)
        try:
            device.restart_b2g()
            print 'Your device is rebooting.'
        except Exception:
            print ' ** Check to make sure you don\'t have desktop B2G running'
            raise

        apps = GaiaApps(mc)
        apps.kill_all()

        lockscreen = LockScreen(mc)
        lockscreen.unlock()

        if args.wifi_ssid:
            print 'Configuring WiFi'
            if not args.wifi_key or not args.wifi_pass:
                args.error('Missing --wifi_key or --wifi_pass option')
            args.wifi_key = args.wifi_key.upper()

            data_layer = GaiaData(mc)
            data_layer.enable_wifi()
            if args.wifi_key == 'WPA-PSK':
                pass_key = 'psk'
            elif args.wifi_key == 'WEP':
                pass_key = 'wep'
            else:
                args.error('not sure what key to use for %r' % args.wifi_key)

            data = {
                'ssid': args.wifi_ssid,
                'keyManagement': args.wifi_key,
                pass_key: args.wifi_pass
            }
            data_layer.connect_to_wifi(data)

        # disconnect marionette client because install_app would need it
        mc.client.close()

        # install apps one by one
        for manifest in args.apps:
            args.manifest = manifest
            args.app = None
            install_app(args)
    def setup(self):
        if not self.serial or not self.port:
            logger.error("Fail to get device")
            raise DMError
        self.config_raptor()

        self.marionette and self.marionette.session and self.marionette.cleanup(
        )
        self.dm = mozdevice.DeviceManagerADB(deviceSerial=self.serial,
                                             port=self.port)
        self.marionette = Marionette(device_serial=self.serial, port=self.port)
        self.marionette.wait_for_port()
        self.marionette.start_session()
        self.device = GaiaDevice(marionette=self.marionette, manager=self.dm)
        self.apps = GaiaApps(self.marionette)
        self.data_layer = GaiaData(self.marionette)
        if self.flashed:
            self.device.wait_for_b2g_ready()
 def add_7mobile_action(self):
     # workaround for waiting for boot
     self.marionette.wait_for_port()
     self.marionette.start_session()
     self.data_layer = GaiaData(self.marionette)
     self.data_layer.set_setting('ril.data.apnSettings',
                                 [[{
                                     "carrier": "(7-Mobile) (MMS)",
                                     "apn": "opentalk",
                                     "mmsc": "http://mms",
                                     "mmsproxy": "210.241.199.199",
                                     "mmsport": "9201",
                                     "types": ["mms"]
                                 }, {
                                     "carrier": "(7-Mobile) (Internet)",
                                     "apn": "opentalk",
                                     "types": ["default", "supl"]
                                 }]])
     return True
Exemplo n.º 8
0
 def __init__(self, marionette):
     self.marionette = marionette
     self.apps = GaiaApps(self.marionette)
     self.data_layer = GaiaData(self.marionette)
     self.frame = None
Exemplo n.º 9
0
 def __init__(self, marionette):
     Base.__init__(self, marionette)
     self.data_layer = GaiaData(self.marionette)
Exemplo n.º 10
0
def do_login(args):
    mc = get_marionette(args)
    device = GaiaDevice(mc)
    apps = GaiaApps(mc)
    data_layer = GaiaData(mc)
    mc.setup_touch()

    _persona_frame_locator = ('css selector', "iframe")

    # Trusty UI on home screen
    _tui_container_locator = ('id', 'trustedui-frame-container')

    # Persona dialog
    _waiting_locator = ('css selector', 'body.waiting')
    _email_input_locator = ('id', 'authentication_email')
    _password_input_locator = ('id', 'authentication_password')
    _new_password = ('id', 'password')
    _verify_new_password = ('id', 'vpassword')
    _next_button_locator = ('css selector', 'button.start')
    _verify_start_button = ('css selector', 'button#verify_user')
    _returning_button_locator = ('css selector', 'button.returning')
    _sign_in_button_locator = ('id', 'signInButton')
    _this_session_only_button_locator = ('id', 'this_is_not_my_computer')

    # Switch to top level frame then Persona frame
    mc.switch_to_frame()
    wait_for_element_present(mc, *_tui_container_locator)
    trustyUI = mc.find_element(*_tui_container_locator)
    wait_for_condition(
        mc, lambda m: trustyUI.find_element(*_persona_frame_locator))
    personaDialog = trustyUI.find_element(*_persona_frame_locator)
    mc.switch_to_frame(personaDialog)

    try:
        ready = mc.find_element(*_email_input_locator).is_displayed()
    except NoSuchElementException:
        ready = False
    if not ready:
        print 'Persona email input is not present.'
        print 'Are you on a new login screen?'
        return

    done = False
    while not done:
        username = raw_input('Persona username: '******'password: '******'Not a new account? Trying to log in to existing account'
        # Logging into an exisiting account:
        password_field = mc.find_element(*_password_input_locator)
        password_field.send_keys(password)
        wait_for_element_displayed(mc, *_returning_button_locator)
        mc.tap(mc.find_element(*_returning_button_locator))  #.click()

    print 'You should be logged in now'
Exemplo n.º 11
0
def set_up_device(args):
    mc = get_marionette(args)
    device = GaiaDevice(mc)
    try:
        device.restart_b2g()
    except Exception:
        print ' ** Check to make sure you don\'t have desktop B2G running'
        raise

    apps = GaiaApps(mc)
    data_layer = GaiaData(mc)
    lockscreen = LockScreen(mc)
    mc.setup_touch()

    lockscreen.unlock()
    apps.kill_all()

    if args.wifi_ssid:
        print 'Configuring WiFi'
        if not args.wifi_key or not args.wifi_pass:
            args.error('Missing --wifi_key or --wifi_pass option')
        args.wifi_key = args.wifi_key.upper()

        data_layer.enable_wifi()
        if args.wifi_key == 'WPA-PSK':
            pass_key = 'psk'
        elif args.wifi_key == 'WEP':
            pass_key = 'wep'
        else:
            args.error('not sure what key to use for %r' % args.wifi_key)

        data = {
            'ssid': args.wifi_ssid,
            'keyManagement': args.wifi_key,
            pass_key: args.wifi_pass
        }
        data_layer.connect_to_wifi(data)

    for manifest in args.apps:
        # There is probably a way easier way to do this by adb pushing
        # something. Send me a patch!
        mc.switch_to_frame()
        try:
            data = requests.get(manifest).json()
            app_name = data['name']
            all_apps = set(a['manifest']['name'] for a in get_installed(apps))
            if app_name not in all_apps:
                print 'Installing %s from %s' % (app_name, manifest)
                mc.execute_script('navigator.mozApps.install("%s");' %
                                  manifest)
                wait_for_element_displayed(mc, 'id',
                                           'app-install-install-button')
                yes = mc.find_element('id', 'app-install-install-button')
                mc.tap(yes)
                # This still works but the id check broke.
                # See https://bugzilla.mozilla.org/show_bug.cgi?id=853878
                wait_for_element_displayed(mc, 'id', 'system-banner')
        except Exception, exc:
            print ' ** installing manifest %s failed (maybe?)' % manifest
            print ' ** error: %s: %s' % (exc.__class__.__name__, exc)
            continue