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() self.assertFalse(settings.is_data_alert_switch_checked) settings.toggle_data_alert_switch() self.assertTrue(settings.is_data_alert_switch_checked) settings.reset_mobile_usage() settings.select_when_use_is_above_unit_and_value(u'MB', '0.1') 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://mozqa.com/qa-testcase-data/Images/sample_png_02.png') browser.wait_for_page_to_load(180) browser.switch_to_content() Wait(self.marionette, timeout=60).until(lambda m: "sample_png_02.png" in m.title) browser.switch_to_chrome() system = System(self.marionette) utility_tray = system.open_utility_tray() utility_tray.wait_for_notification_container_displayed() # 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') usage_view.tap() self.wait_for_condition( lambda m: self.apps.displayed_app.name == cost_control.name)
def test_cost_control_ftu(self): cost_control = CostControl(self.marionette) cost_control.launch() ftu_step1 = cost_control.ftu_step1 ftu_step2 = ftu_step1.tap_next() ftu_step2.select_reset_report_value('Weekly') ftu_step3 = ftu_step2.tap_next() ftu_step3.toggle_data_alert_switch(True) ftu_step3.select_when_use_is_above_unit_and_value('MB', '0.1') ftu_step3.tap_lets_go() self.assertTrue(cost_control.is_mobile_data_tracking_on)
def tap_done(self): self.wait_for_element_displayed(*self._done_button_locator) self.marionette.tap( self.marionette.find_element(*self._done_button_locator)) # Switch back to Cos Control app frame from gaiatest.apps.cost_control.app import CostControl CostControl(self.marionette).launch()
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')
def test_cost_control_ftu(self): cost_control = CostControl(self.marionette) cost_control.launch() # This will switch to ftu iframe cost_control.switch_to_ftu() ftu_step1 = cost_control.ftu_step1 ftu_step2 = ftu_step1.tap_next() ftu_step2.select_reset_report_value('Weekly') ftu_step3 = ftu_step2.tap_next() ftu_step3.toggle_data_alert_switch(True) ftu_step3.select_when_use_is_above_unit_and_value(u'MB', '0.1') ftu_step3.tap_lets_go() self.marionette.switch_to_frame(self.apps.displayed_app.frame) self.assertTrue(cost_control.is_mobile_data_tracking_on)
def test_cost_control_ftu(self): cost_control = CostControl(self.marionette) cost_control.launch() # This will switch to ftu iframe cost_control.switch_to_ftu() from gaiatest.apps.cost_control.regions.ftu_step1 import FTUStep1 ftu_step1 = FTUStep1(self.marionette) ftu_step2 = ftu_step1.tap_next() ftu_step2.select_reset_report_value('Weekly') ftu_step3 = ftu_step2.tap_next() ftu_step3.enable_data_alert_toggle() ftu_step3.select_when_use_is_above_unit_and_value(u'MB', '0.1') ftu_step3.tap_lets_go() self.apps.switch_to_displayed_app() self.wait_for_condition( lambda m: cost_control.is_mobile_data_tracking_on)
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() self.assertFalse(settings.is_data_alert_switch_checked) settings.toggle_data_alert_switch() self.assertTrue(settings.is_data_alert_switch_checked) settings.reset_mobile_usage() settings.select_when_use_is_above_unit_and_value(u'MB', '0.1') 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://mozqa.com/qa-testcase-data/Images/sample_png_02.png') browser.wait_for_page_to_load(180) browser.switch_to_content() Wait(self.marionette, timeout=60).until(lambda m: "sample_png_02.png" in m.title) browser.switch_to_chrome() system = System(self.marionette) utility_tray = system.open_utility_tray() utility_tray.wait_for_notification_container_displayed() # 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') usage_view.tap() self.wait_for_condition(lambda m: self.apps.displayed_app.name == cost_control.name)
def test_cost_control_data_alert_mobile(self): self.data_layer.connect_to_cell_data() 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_data_usage() settings.tap_done() self.assertTrue(cost_control.is_mobile_data_tracking_on) # open browser to get some data downloaded browser = Browser(self.marionette) browser.launch() browser.go_to_url('http://developer.mozilla.org/') browser.switch_to_content() self.wait_for_element_present(*self._page_body_locator, timeout=120) browser.switch_to_chrome() # get the notification bar 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 self.wait_for_condition( lambda m: 'reached-limit' in self.marionette.find_element( *self._data_usage_view_locator).get_attribute('class'), message='Data usage bar did not breach limit')
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.enable_data_alert_switch() settings.reset_mobile_usage() settings.select_when_use_is_above_unit_and_value(u'MB', '0.1') 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) search.go_to_url('http://mozqa.com/qa-testcase-data/Images/sample_png_02.png') system = System(self.marionette) # We could have waited on the page to be loaded, but the toaster can appear before # the end of the load. That's why the timeout is expanded, the webpage loaded just above # might take longer. system.wait_for_notification_toaster_displayed(timeout=180) system.wait_for_notification_toaster_not_displayed() utility_tray = system.open_utility_tray() utility_tray.wait_for_notification_container_displayed() cost_control_widget = utility_tray.cost_control_widget cost_control_widget.wait_for_limit_to_be_reached() cost_control_widget.tap() cost_control.wait_to_be_displayed()
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() browser = search.go_to_url('http://www.mozilla.org/') browser.wait_for_page_to_load(180) browser.switch_to_content() self.wait_for_condition(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) self.wait_for_condition( lambda m: 'reached-limit' in usage_view.get_attribute('class'), message='Data usage bar did not breach limit', timeout=40)
def test_cost_control_data_alert_mobile(self): """https://moztrap.mozilla.org/manage/case/8938/""" self.data_layer.connect_to_cell_data() 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 browser = Browser(self.marionette) browser.launch() browser.go_to_url('http://developer.mozilla.org/', timeout=120) browser.switch_to_content() self.wait_for_element_present(*self._page_body_locator, timeout=120) browser.switch_to_chrome() # get the notification bar 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 self.wait_for_condition( lambda m: 'reached-limit' in self.marionette.find_element( *self._data_usage_view_locator).get_attribute('class'), message='Data usage bar did not breach limit')
def test_cost_control_reset_wifi(self): self.data_layer.connect_to_wifi() cost_control = CostControl(self.marionette) cost_control.launch() cost_control.switch_to_ftu() cost_control.run_ftu_accepting_defaults() cost_control.toggle_mobile_data_tracking(False) cost_control.toggle_wifi_data_tracking(True) # Kill the Cost control application self.apps.kill(cost_control.app) # open browser to get some data downloaded search = Search(self.marionette) search.launch() search.go_to_url('http://mozqa.com/data/firefox/layout/mozilla.html') self.data_layer.disable_wifi() time.sleep(5) # go back to Cost Control cost_control.launch() # if we can't trigger any data usage, there must be something wrong self.assertNotEqual(cost_control.wifi_data_usage_figure, u'0.00 B', 'No data usage shown after browsing.') # # go to settings section settings = cost_control.tap_settings() settings.reset_wifi_usage() settings.tap_done() # wait for usage to be refreshed self.wait_for_condition( lambda m: cost_control.wifi_data_usage_figure == u'0.00 B', message='Wifi usage did not reset back to 0.00 B')
def __init__(self, marionette): CostControl.__init__(self, marionette) view = self.marionette.find_element(*self._view_locator) self.wait_for_condition(lambda m: view.location['x'] == 0)
def __init__(self, marionette): CostControl.__init__(self, marionette) menu = self.marionette.find_element(*self._reset_report_menu_locator) self.wait_for_condition(lambda m: menu.location['x'] == 0)
def __init__(self, marionette): CostControl.__init__(self, marionette) header = self.marionette.find_element(*self._data_alert_header_locator) self.wait_for_condition(lambda m: header.location['x'] == 0)
def __init__(self, marionette): CostControl.__init__(self, marionette) self.wait_for_element_displayed(*self._data_report_title_locator)
def test_cost_control_reset_wifi(self): self.data_layer.connect_to_wifi() cost_control = CostControl(self.marionette) cost_control.launch() cost_control.run_ftu_accepting_defaults() cost_control.toggle_mobile_data_tracking(False) cost_control.toggle_wifi_data_tracking(True) # open browser to get some data downloaded # please remove this once there is a better way than launching browser app/obj to do so browser = Browser(self.marionette) browser.launch() browser.go_to_url('http://mozqa.com/data/firefox/layout/mozilla.html') browser.switch_to_content() self.wait_for_element_present(*self._page_title_locator) # go back to Cost Control cost_control.launch() # if we can't trigger any data usage, there must be something wrong self.assertNotEqual(cost_control.wifi_data_usage_figure, u'0.00 B', 'No data usage shown after browsing.') # disable wifi before reset data, wait for wifi to be closed, and switch back to the app self.data_layer.disable_wifi() time.sleep(1) cost_control.launch() # # go to settings section settings = cost_control.tap_settings() settings.reset_data_usage() settings.tap_done() # wait for usage to be refreshed self.wait_for_condition( lambda m: cost_control.wifi_data_usage_figure == u'0.00 B', message='Wifi usage did not reset back to 0.00 B')
def __init__(self, marionette): CostControl.__init__(self, marionette) self.wait_for_element_displayed(*self._data_report_title_locator) # Wait for the <script defer> to complete time.sleep(1)
def __init__(self, marionette): CostControl.__init__(self, marionette) view = self.marionette.find_element(*self._view_locator) Wait(self.marionette).until(lambda m: view.location['x'] == 0)
def test_cost_control_reset_wifi(self): self.data_layer.connect_to_wifi() cost_control = CostControl(self.marionette) cost_control.launch() cost_control.switch_to_ftu() cost_control.run_ftu_accepting_defaults() cost_control.toggle_mobile_data_tracking(False) cost_control.toggle_wifi_data_tracking(True) # open browser to get some data downloaded browser = Browser(self.marionette) browser.launch() browser.go_to_url('http://mozqa.com/data/firefox/layout/mozilla.html') browser.switch_to_content() self.wait_for_element_present(*self._page_title_locator) # disable wifi and kill the browser before reset data, wait for wifi to be closed, and switch back to the app self.apps.kill(browser.app) self.data_layer.disable_wifi() time.sleep(5) # go back to Cost Control cost_control.launch() # if we can't trigger any data usage, there must be something wrong self.assertNotEqual(cost_control.wifi_data_usage_figure, u'0.00 B', 'No data usage shown after browsing.') # # go to settings section settings = cost_control.tap_settings() settings.reset_wifi_usage() settings.tap_done() # wait for usage to be refreshed self.wait_for_condition( lambda m: cost_control.wifi_data_usage_figure == u'0.00 B', message='Wifi usage did not reset back to 0.00 B')
def test_cost_control_reset_wifi(self): self.data_layer.connect_to_wifi() cost_control = CostControl(self.marionette) cost_control.launch() cost_control.switch_to_ftu() cost_control.run_ftu_accepting_defaults() cost_control.toggle_mobile_data_tracking(False) cost_control.toggle_wifi_data_tracking(True) # If we don't kill the app manually it might get killed by the oom process. # In that case when we re-launch the app it has a hash attached at the end of the src. - Bug 1091676 self.apps.kill(cost_control.app) # open browser to get some data downloaded search = Search(self.marionette) search.launch() search.go_to_url(self.marionette.absolute_url('mozilla.html')) self.data_layer.disable_wifi() time.sleep(5) # go back to Cost Control cost_control.launch() # if we can't trigger any data usage, there must be something wrong self.assertNotEqual(cost_control.wifi_data_usage_figure, u'0.00 B', 'No data usage shown after browsing.') # # go to settings section settings = cost_control.tap_settings() settings.reset_wifi_usage() settings.tap_done() # wait for usage to be refreshed self.wait_for_condition( lambda m: cost_control.wifi_data_usage_figure == u'0.00 B', message='Wifi usage did not reset back to 0.00 B')
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.enable_data_alert_switch() settings.reset_mobile_usage() settings.select_when_use_is_above_unit_and_value(u'MB', '0.1') 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) search.go_to_url( 'http://mozqa.com/qa-testcase-data/Images/sample_png_02.png') system = System(self.marionette) # We could have waited on the page to be loaded, but the toaster can appear before # the end of the load. That's why the timeout is expanded, the webpage loaded just above # might take longer. system.wait_for_notification_toaster_displayed(timeout=180) system.wait_for_notification_toaster_not_displayed() utility_tray = system.open_utility_tray() utility_tray.wait_for_notification_container_displayed() cost_control_widget = utility_tray.cost_control_widget cost_control_widget.wait_for_limit_to_be_reached() cost_control_widget.tap() cost_control.wait_to_be_displayed()