Exemplo n.º 1
0
 def tap_new_alarm(self):
     new_alarm = Wait(self.marionette).until(
         expected.element_present(*self._alarm_create_new_locator))
     Wait(self.marionette).until(expected.element_displayed(new_alarm))
     new_alarm.tap()
     from gaiatest.apps.clock.regions.alarm import NewAlarm
     return NewAlarm(self.marionette)
Exemplo n.º 2
0
 def a11y_click_day_display_button(self):
     self.accessibility.click(
         self.marionette.find_element(*self._day_display_button_locator))
     Wait(self.marionette).until(
         expected.element_displayed(
             Wait(self.marionette).until(
                 expected.element_present(*self._day_view_locator))))
Exemplo n.º 3
0
 def make_call(self, to_number, timeout=DEFAULT_TIMEOUT):
     """Place a call to a number and wait for the call_uuid to be available
         Return the call_uuid
     """
     # Check that we have the balance available
     if self.account_balance < 0.1:
         raise Exception(
             'Plivo account balance of %s is insufficient to make a call.' %
             self.account_balance)
     # Make the call
     Wait(self.api, timeout).until(
         lambda p: p.make_call({
             'from': self.from_number,
             'to': to_number,
             'answer_url': "http://example.com/answer_url",
             'hangup_url': "http://example.com/hangup_url",
             'caller_name': 'test_call_from_Plivo',
         })[0] == 201,
         message='The call was not able to be made.')
     # Wait until the call is reported back by the api
     call = Wait(
         self, timeout,
         ignored_exceptions=self.PlivoActiveCallNotFound).until(
             lambda p: p.get_call_for_number(to_number),
             message='Unable to find the live call for this device.')
     return call['call_uuid']
Exemplo n.º 4
0
    def test_receive_call(self):
        """Make a phone call from Plivo to the phone."""
        PLIVO_TIMEOUT = 30

        self.plivo = PlivoUtil(self.testvars['plivo']['auth_id'],
                               self.testvars['plivo']['auth_token'],
                               self.testvars['plivo']['phone_number'])
        self.call_uuid = self.plivo.make_call(
            to_number=self.testvars['carrier']['phone_number'].replace(
                '+', ''),
            timeout=PLIVO_TIMEOUT)

        call_screen = CallScreen(self.marionette)
        call_screen.wait_for_incoming_call()
        call_screen.answer_call()

        # Wait for Plivo to report the call as connected
        Wait(self.plivo, timeout=PLIVO_TIMEOUT).until(
            lambda p: p.is_call_connected(self.call_uuid),
            message='The call was not connected.')

        # Wait for the state to be connected
        call_screen.wait_for_condition(
            lambda m: self.data_layer.active_telephony_state == 'connected',
            timeout=30)

        call_screen.hang_up()

        # Wait for Plivo to report the call as completed
        Wait(self.plivo, timeout=PLIVO_TIMEOUT).until(
            lambda p: p.is_call_completed(self.call_uuid),
            message='The call was not completed.')
        self.call_uuid = None
Exemplo n.º 5
0
 def dismiss_banner(self):
     banner = Wait(self.marionette).until(
         expected.element_present(
             *self._banner_countdown_notification_locator))
     Wait(self.marionette).until(expected.element_displayed(banner))
     # We can't tap to clear the banner as sometimes it taps the underlying alarm changing the UI
     Wait(self.marionette).until(expected.element_not_displayed(banner))
    def test_lockscreen_unlock_to_homescreen_with_passcode(self):
        # Need to wait until the carrier is detected, so the lockscreen will display the carrier information
        Wait(self.marionette,
             timeout=30).until(lambda m: self.device.has_mobile_connection)

        self.data_layer.set_time(self._seconds_since_epoch * 1000)
        self.data_layer.set_setting('time.timezone', 'Atlantic/Reykjavik')

        # set passcode-lock
        self.data_layer.set_setting('lockscreen.passcode-lock.code',
                                    self._input_passcode)
        self.data_layer.set_setting('lockscreen.passcode-lock.enabled', True)

        # this time we need it locked!
        self.device.lock()

        # 1st try

        lock_screen = LockScreen(self.marionette)
        lock_screen.switch_to_frame()
        lock_screen.unlock_to_passcode_pad()
        self.take_screenshot()
        self.device.turn_screen_off()

        # 2nd try
        self.device.turn_screen_on()
        passcode_pad = lock_screen.unlock_to_passcode_pad()
        homescreen = passcode_pad.type_passcode(self._input_passcode)

        Wait(self.marionette).until(
            lambda m: self.apps.displayed_app.name == homescreen.name)
        self.take_screenshot()
Exemplo n.º 7
0
Arquivo: app.py Projeto: philsmd/gaia
 def launch(self):
     Base.launch(self)
     # empty message is only displayed after first MonthsDay#render,
     # so we are sure app is "ready" after that
     Wait(self.marionette).until(expected.element_displayed(
         Wait(self.marionette).until(expected.element_present(
             *self._event_list_empty_locator))))
Exemplo n.º 8
0
 def launch(self):
     Base.launch(self)
     Wait(self.marionette).until(expected.element_displayed(
         Wait(self.marionette).until(expected.element_present(
             *self._visible_clock_locator))))
     Wait(self.marionette).until(expected.element_displayed(
         Wait(self.marionette).until(expected.element_present(
             *self._alarm_create_new_locator))))
Exemplo n.º 9
0
Arquivo: app.py Projeto: philsmd/gaia
 def a11y_click_month_display_button(self):
     self.accessibility.click(self.marionette.find_element(*self._month_display_button_locator))
     Wait(self.marionette).until(expected.element_displayed(
         Wait(self.marionette).until(expected.element_present(
             *self._current_monthly_calendar_locator))))
     Wait(self.marionette).until(expected.element_displayed(
         Wait(self.marionette).until(expected.element_present(
             *self._current_month_day_agenda_locator))))
Exemplo n.º 10
0
 def a11y_click_modify_account_back(self):
     self.a11y_click_header(
         self.marionette.find_element(*self._modify_account_header_locator),
         'button.icon-back')
     Wait(self.marionette).until(
         expected.element_displayed(
             Wait(self.marionette).until(
                 expected.element_present(
                     *self._create_account_view_locator))))
Exemplo n.º 11
0
    def wait_for_b2g_ready(self, timeout=60):
        # Wait for the homescreen to finish loading
        Wait(self.marionette, timeout).until(expected.element_present(
            By.CSS_SELECTOR, '#homescreen[loading-state=false]'))

        # Wait for logo to be hidden
        self.marionette.set_search_timeout(0)
        try:
            Wait(self.marionette, timeout, ignored_exceptions=StaleElementException).until(
                lambda m: not m.find_element(By.ID, 'os-logo').is_displayed())
        except NoSuchElementException:
            pass
        self.marionette.set_search_timeout(self.marionette.timeout or 10000)
Exemplo n.º 12
0
    def test_a11y_calendar_month_view_select_event(self):

        event = self.calendar.event(self.event_title)
        # Make sure that the title and the location are correct
        self.assertEquals(event.title, self.event_title)
        self.assertEquals(event.location, self.event_location)

        event_detail = event.a11y_click()

        # Make sure that the title and the location correspond to the selected event.
        # Note: title and location are populated asynchronously
        Wait(self.marionette).until(lambda m: self.event_title == event_detail.title)
        Wait(self.marionette).until(lambda m: self.event_location == event_detail.location)
Exemplo n.º 13
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())
Exemplo n.º 14
0
    def test_cost_control_data_alert_mobile(self):
        """https://moztrap.mozilla.org/manage/case/8938/"""

        cost_control = CostControl(self.marionette)
        cost_control.launch()

        cost_control.switch_to_ftu()
        cost_control.run_ftu_accepting_defaults()

        self.assertTrue(cost_control.is_mobile_data_tracking_on)
        self.assertFalse(cost_control.is_wifi_data_tracking_on)

        settings = cost_control.tap_settings()
        settings.toggle_data_alert_switch(True)
        settings.select_when_use_is_above_unit_and_value(u'MB', '0.1')
        settings.reset_mobile_usage()
        settings.tap_done()
        self.assertTrue(cost_control.is_mobile_data_tracking_on)

        # open browser to get some data downloaded
        search = Search(self.marionette)
        search.launch(launch_timeout=30000)
        browser = search.go_to_url('http://www.mozilla.org/')
        browser.wait_for_page_to_load(180)

        browser.switch_to_content()
        Wait(self.marionette, timeout=60).until(
            lambda m: "Home of the Mozilla Project" in m.title)
        browser.switch_to_chrome()

        # get the notification bar
        self.device.touch_home_button()
        self.marionette.switch_to_frame()
        self.marionette.execute_script(
            "window.wrappedJSObject.UtilityTray.show()")

        # switch to cost control widget
        usage_iframe = self.marionette.find_element(
            *self._cost_control_widget_locator)
        self.marionette.switch_to_frame(usage_iframe)

        # make sure the color changed
        # The timeout is increased, because for some reason, it takes some time
        # before the limit view is shown (the browser has to finish loading?)
        usage_view = self.marionette.find_element(
            *self._data_usage_view_locator)
        Wait(self.marionette, timeout=40).until(
            lambda m: 'reached-limit' in usage_view.get_attribute('class'),
            message='Data usage bar did not breach limit')
Exemplo n.º 15
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)
    def test_set_up_conference_call(self):
        """Set up a conference between the remote phone and Plivo."""

        test_phone_number = self.testvars['remote_phone_number']
        from gaiatest.utils.plivo.plivo_util import PlivoUtil

        self.plivo = PlivoUtil(
            self.testvars['plivo']['auth_id'],
            self.testvars['plivo']['auth_token'],
            self.testvars['plivo']['phone_number']
        )

        self.is_in_conference_call = False
        self.is_in_regular_call = False

        phone = Phone(self.marionette)
        phone.launch()

        call_screen = phone.keypad.call_number(test_phone_number)
        call_screen.wait_for_outgoing_call()
        self.is_in_regular_call = True
        call_screen.wait_for_condition(lambda m: self.data_layer.active_telephony_state == 'connected')

        self.call_uuid = self.plivo.make_call(
            to_number=self.testvars['local_phone_numbers'][0].replace('+', ''),
            timeout=PLIVO_TIMEOUT)

        call_screen = CallScreen(self.marionette)
        call_screen.wait_for_incoming_call_while_on_call()
        call_screen.answer_call_while_on_call()

        # Wait for Plivo to report the call as connected
        Wait(self.plivo, timeout=PLIVO_TIMEOUT).until(
            lambda p: p.is_call_connected(self.call_uuid),
            message='The call was not connected.')

        call_screen.merge_calls()
        self.is_in_regular_call = False
        self.is_in_conference_call = True
        self.assertEqual(call_screen.conference_label, 'Conference (2)')

        call_screen.hang_up()
        self.is_in_conference_call = False

        Wait(self.plivo, timeout=PLIVO_TIMEOUT).until(
            lambda p: p.is_call_completed(self.call_uuid),
            message="Plivo didn't report the call as completed")
        self.call_uuid = None
Exemplo n.º 17
0
 def launch(self):
     Base.launch(self)
     # _currentPanel is set after all handlers are set
     Wait(
         self.marionette, ignored_exceptions=JavascriptException
     ).until(lambda m: m.execute_script(
         'return window.wrappedJSObject.Settings._currentPanel') == '#root')
Exemplo n.º 18
0
 def wait_for_history_to_load(self, number_of_items=1):
     if number_of_items == 0:
         self.wait_for_element_not_displayed(*self._history_item_locator)
     else:
         Wait(self.marionette).until(
             lambda m: len(m.find_elements(*self._history_item_locator)
                           ) == number_of_items)
Exemplo n.º 19
0
 def lock(self):
     self.marionette.import_script(self.lockscreen_atom)
     self.marionette.switch_to_frame()
     result = self.marionette.execute_async_script('GaiaLockScreen.lock()')
     assert result, 'Unable to lock screen'
     Wait(self.marionette).until(lambda m: m.find_element(
         By.CSS_SELECTOR, 'div.lockScreenWindow.active'))
    def test_dsds_receive_call_on_both_sims(self, sim_value, sim_name):
        """Make a phone call from Plivo to each SIM."""

        from gaiatest.utils.plivo.plivo_util import PlivoUtil
        self.plivo = PlivoUtil(self.testvars['plivo']['auth_id'],
                               self.testvars['plivo']['auth_token'],
                               self.testvars['plivo']['phone_number'])
        self.call_uuid = self.plivo.make_call(
            to_number=self.testvars['local_phone_numbers'][sim_value].replace(
                '+', ''))

        call_screen = CallScreen(self.marionette)
        call_screen.wait_for_incoming_call()

        # TODO Replace the following line by a check on the l10n ID
        # once bug 1104667 lands
        self.assertTrue(sim_name in call_screen.incoming_via_sim)

        call_screen.answer_call()
        self.plivo.wait_for_call_connected(self.call_uuid)
        Wait(self.marionette).until(
            lambda m: self.data_layer.active_telephony_state == 'connected')

        # TODO Replace the following line by a check on the l10n ID
        # once bug 1104667 lands
        self.assertTrue(sim_name in call_screen.incoming_via_sim)

        call_screen.hang_up()
        self.plivo.wait_for_call_completed(self.call_uuid)
        self.call_uuid = None
Exemplo n.º 21
0
    def test_telephony_outgoing_busy(self):
        self.instruct("Make a call to second non firefox OS phone from third non firefox "
                       "OS phone, answer the call on second phone and press OK")
        # keep a short delay before making an outgoing call to second phone
        time.sleep(2)

        # use the webapi to make an outgoing call to user-specified number
        self.user_guided_outgoing_call()
        # verify one outgoing call
        self.calls = self.marionette.execute_script("return window.wrappedJSObject.get_returnable_calls()")
        self.assertEqual(self.calls['length'], 1, "There should be 1 call")
        self.assertEqual(self.calls['0'], self.outgoing_call)

        # should have received busy event associated with an outgoing call
        wait = Wait(self.marionette, timeout=30, interval=0.5)
        try:
            wait.until(lambda x: x.execute_script("return window.wrappedJSObject.received_busy"))
        except:
            self.fail("Busy event is not found, but should have been, since the outgoing call "
                      "is initiated to busy line")

        # keep call ringing for a while
        time.sleep(1)

        # disconnect the outgoing call
        self.hangup_call(call_type="Outgoing")
        self.calls = self.marionette.execute_script("return window.wrappedJSObject.get_returnable_calls()")
        self.assertEqual(self.calls['length'], 0, "There should be 0 calls")
Exemplo n.º 22
0
    def test_music_album_mp3(self):
        """
        https://moztrap.mozilla.org/manage/case/4031/
        """

        music_app = Music(self.marionette)
        music_app.launch()
        music_app.wait_for_music_tiles_displayed()
        self.take_screenshot()

        # switch to albums view
        list_view = music_app.tap_albums_tab()
        self.take_screenshot()

        # check that albums (at least one) are available
        albums = list_view.media
        self.assertGreater(len(albums), 0, 'The mp3 file could not be found')

        # select an album
        sublist_view = albums[0].tap_first_album()
        self.take_screenshot()
        # select play
        # This wait is timing out because of bug 862156
        player_view = sublist_view.tap_play()
        # play for a short duration
        play_time = time.strptime('00:03', '%M:%S')
        Wait(self.marionette).until(
            lambda m: player_view.player_elapsed_time >= play_time,
            message='Mp3 sample did not start playing')

        ff_button = self.marionette.find_element(
            *self._player_controls_next_locator)
        Actions(self.marionette).tap(ff_button).perform()
        self.take_screenshot()
Exemplo n.º 23
0
    def set_wifi_enabled(self, enable):
        self.marionette.execute_async_script("""
        var enable = arguments[0];
        window.wrappedJSObject.rcvd_enabled_event = false;
        window.wrappedJSObject.rcvd_disabled_event = false;
        window.wrappedJSObject.rcvd_error = false;
        var mozWifi = window.navigator.mozWifiManager;

        mozWifi.onenabled = function() {
           console.log("Received mozWifiManager.onenabled event");
           window.wrappedJSObject.rcvd_enabled_event = true;
        };

        mozWifi.ondisabled = function() {
           console.log("Received mozWifiManager.ondisabled event");
           window.wrappedJSObject.rcvd_disabled_event = true;
        };

        if (enable) {
            console.log("Turning on Wifi via settings");
        } else {
            console.log("Turning off Wifi via settings");
        }
        var lock = window.navigator.mozSettings.createLock();

        var result = lock.set({
            'wifi.enabled': enable
        });

        result.onerror = function() {
            if (enable) {
                console.log("Failed to changed Wifi setting to ON");
            } else {
                console.log("Failed to changed Wifi setting to OFF");
            }
            window.wrappedJSObject.rcvd_error = true;
        };
        marionetteScriptFinished(1);
        """,
                                             script_args=[enable])

        # wait for enabled/disabled event
        wait = Wait(self.marionette, timeout=30, interval=0.5)
        try:
            if enable:
                wait.until(lambda m: m.execute_script(
                    "return window.wrappedJSObject.rcvd_enabled_event;"))
            else:
                wait.until(lambda m: m.execute_script(
                    "return window.wrappedJSObject.rcvd_disabled_event;"))
        except:
            if self.marionette.execute_script(
                    "return window.wrappedJSObject.rcvd_error;"):
                self.fail(
                    "Error received while changing the wifi enabled setting")
            else:
                if enable:
                    self.fail("Failed to enable wifi via mozSettings")
                else:
                    self.fail("Failed to disable wifi via mozSettings")
Exemplo n.º 24
0
 def wait_for_a11y_calendar_unchecked(self, timeout=None):
     Wait(
         self.marionette,
         timeout,
         ignored_exceptions=StaleElementException
     ).until(lambda m: not self.marionette.find_element(
         *self._calendar_local_locator).get_attribute('aria-selected'))
Exemplo n.º 25
0
    def test_music_songs_3gp(self):
        """https://moztrap.mozilla.org/manage/case/4031/"""

        music_app = Music(self.marionette)
        music_app.launch()
        music_app.wait_for_music_tiles_displayed()
        self.take_screenshot()

        # switch to songs view
        list_view = music_app.tap_songs_tab()

        # check that songs (at least one) are available
        songs = list_view.media
        self.assertGreater(len(songs), 0, 'The 3gp file could not be found')
        self.take_screenshot()

        player_view = songs[0].tap_first_song()

        play_time = time.strptime('00:03', '%M:%S')
        Wait(self.marionette).until(
            lambda m: player_view.player_elapsed_time >= play_time,
            message='3gp sample did not start playing')

        # validate playback
        self.assertTrue(player_view.is_player_playing(),
                        'The player is not playing')

        # select stop, then FF to the end of the song
        player_view.tap_play()
        ff_button = self.marionette.find_element(
            *self._player_controls_next_locator)
        Actions(self.marionette).tap(ff_button).perform()
        self.take_screenshot()
    def test_receive_call_with_locked_screen(self):
        """
        Verify that the User can receive a call whilst the device is locked
        https://moztrap.mozilla.org/manage/case/1300/
        """
        PLIVO_TIMEOUT = 30
        self.call_uuid = False

        from gaiatest.utils.plivo.plivo_util import PlivoUtil
        self.plivo = PlivoUtil(self.testvars['plivo']['auth_id'],
                               self.testvars['plivo']['auth_token'],
                               self.testvars['plivo']['phone_number'])

        self.device.lock()
        self.call_uuid = self.plivo.make_call(
            to_number=self.testvars['local_phone_numbers'][0].replace('+', ''),
            timeout=PLIVO_TIMEOUT)

        # Wait for the incoming call screen to show up
        call_screen = CallScreen(self.marionette)
        call_screen.wait_for_incoming_call_with_locked_screen()

        # Reject the call
        call_screen.reject_call()

        Wait(self.plivo, timeout=PLIVO_TIMEOUT).until(
            lambda p: p.is_call_completed(self.call_uuid),
            message="Plivo didn't report the call as completed")
        self.call_uuid = None

        # Check that the screen is still locked
        self.assertTrue(self.device.is_locked)
Exemplo n.º 27
0
 def is_geolocation_enabled(self):
     self.marionette.execute_async_script("""
     window.wrappedJSObject.geo_enabled = null;
     window.wrappedJSObject.get_success = false;
     var lock = navigator.mozSettings.createLock();
     var setting = lock.get('geolocation.enabled');
     setting.onsuccess = function () {
       console.log('geolocation.enabled: ' + setting.result);
       window.wrappedJSObject.get_success = true;
       window.wrappedJSObject.geo_enabled = setting.result["geolocation.enabled"];
     }
     setting.onerror = function () {
       console.log('An error occured: ' + setting.error);
     }
     marionetteScriptFinished(1);
     """)
     # wait for enabled/disabled event
     wait = Wait(self.marionette, timeout=30, interval=0.5)
     try:
         wait.until(lambda m: m.execute_script(
             "return window.wrappedJSObject.get_success"))
     except:
         self.fail("Failed to get the geolocation.enabled setting")
     return self.marionette.execute_script(
         "return window.wrappedJSObject.geo_enabled")
Exemplo n.º 28
0
    def resume_held_call(self):
        self.marionette.execute_async_script("""
        let active = window.wrappedJSObject.active_call;

        window.wrappedJSObject.received_statechange = false;
        active.onstatechange = function onstatechange(event) {
        log("Received TelephonyCall 'onstatechange' event.");
          if (event.call.state == "resuming") {
            window.wrappedJSObject.received_statechange = true;
          };
        };

        window.wrappedJSObject.onresuming_call_ok = false;
        active.onresuming = function onresuming(event) {
          log("Received 'onresuming' call event.");
          if (event.call.state == "resuming") {
            window.wrappedJSObject.onresuming_call_ok = true;
          };
        };

        active.resume();
        marionetteScriptFinished(1);
        """,
                                             special_powers=True)

        # should have received event associated with a resumed call
        wait = Wait(self.marionette, timeout=90, interval=0.5)
        try:
            wait.until(lambda x: x.execute_script(
                "return window.wrappedJSObject.onresuming_call_ok"))
            wait.until(lambda x: x.execute_script(
                "return window.wrappedJSObject.received_statechange"))
        except:
            # failed to resume
            self.fail("Failed to resume the held call")
Exemplo n.º 29
0
 def wait_for_element_not_present(self, by, locator, timeout=None):
     try:
         return Wait(
             self.marionette,
             timeout).until(lambda m: not m.find_element(by, locator))
     except NoSuchElementException:
         pass
Exemplo n.º 30
0
    def create_notification(self, text):
        self.marionette.execute_async_script("""
        window.wrappedJSObject.rcvd_onshow = false;
        var text = arguments[0];

        console.log("Creating new notification");
        var notification = new Notification(text);

        // setup callback
        notification.onshow = function() {
            console.log("Received Notification.onshow event");
            window.wrappedJSObject.rcvd_onshow = true;
        }

        marionetteScriptFinished(1);
    """,
                                             script_args=[text])

        # wait for notification to be displayed
        wait = Wait(self.marionette, timeout=30, interval=0.5)
        try:
            wait.until(lambda x: x.execute_script(
                "return window.wrappedJSObject.rcvd_onshow"))
        except:
            self.fail("Did not receive the Notification.onshow event")