class TestSettingsWifi(GaiaMtbfTestCase):

    def setUp(self):
        GaiaMtbfTestCase.setUp(self)
        self.data_layer.enable_wifi()
        self.data_layer.forget_all_networks()
        self.data_layer.disable_wifi()
        self.settings = MTBF_Settings(self.marionette)
        self.settings.launch()

    def test_connect_to_wifi_via_settings_app(self):
        # we need to go back to main screen of settings app
        self.settings.go_back()

        wifi_settings = self.settings.open_wifi_settings()
        # self.wait_for_element_displayed(*wifi_settings._wifi_enabled_label_locator)

        wifi_settings.enable_wifi()
        wifi_settings.connect_to_network(self.testvars['wifi'])

        # verify that wifi is now on
        self.assertTrue(self.data_layer.is_wifi_connected(self.testvars['wifi']), "WiFi was not connected via Settings app")

    def tearDown(self):
        self.data_layer.disable_wifi()
        GaiaMtbfTestCase.tearDown(self)
class TestSettingsBluetooth(GaiaMtbfTestCase):

    def setUp(self):
        GaiaMtbfTestCase.setUp(self)
        self.settings = MTBF_Settings(self.marionette)
        self.settings.launch()

    def test_turn_on_and_off_bt(self):
        self.settings.go_back()

        self.bt_settings = self.settings.open_bluetooth_settings()
        self.wait_for_element_displayed(*self.bt_settings._bluetooth_label_locator)

        if not self.bt_settings.is_bluetooth_enabled:
            self.bt_settings.enable_bluetooth()
        if not self.bt_settings.is_visible_enabled:
            self.bt_settings.enable_visible_to_all()
        self.assertTrue(self.bt_settings.is_bluetooth_enabled, "Bluetooth not on via Settings app")
        self.assertTrue(self.bt_settings.is_visible_enabled, "Bluetooth not visible via Settings app")

        self.marionette.find_element(*self.bt_settings._bluetooth_label_locator).tap()
        self.wait_for_condition(lambda m: self.bt_settings.is_bluetooth_enabled == None)

    def tearDown(self):
        GaiaMtbfTestCase.tearDown(self)
 def setUp(self):
     GaiaMtbfTestCase.setUp(self)
     self.data_layer.enable_wifi()
     self.data_layer.forget_all_networks()
     self.data_layer.disable_wifi()
     self.settings = MTBF_Settings(self.marionette)
     self.settings.launch()
    def test_connect_to_wifi_via_settings_app(self):
        # we need to go back to main screen of settings app
        self.settings = MTBF_Settings(self.marionette)
        self.settings.launch()
        self.settings.return_to_prev_menu(self.settings.screen_element)
        wifi_settings = self.settings.open_wifi()

        wifi_settings.enable_wifi()
        wifi_settings.connect_to_network(self.testvars['wifi'])

        # verify that wifi is now on
        self.assertTrue(self.data_layer.is_wifi_connected(self.testvars['wifi']), "WiFi was not connected via Settings app")
    def test_browser_clear_history(self):
        """
        https://moztrap.mozilla.org/manage/cases/?filter-id=3582
        """
        search = Search(self.marionette)
        search.launch()
        browser = search.go_to_url(self.test_url)
        browser.switch_to_content()
        Wait(self.marionette).until(lambda m: m.title == 'Mozilla')

        self.device.touch_home_button()

        search.launch()
        Wait(self.marionette).until(lambda m: search.history_items_count > 0)
        self.assertGreater(search.history_items_count, 0)

        settings = MTBF_Settings(self.marionette)
        settings.launch()
        settings.go_back()
        browsing_privacy = settings.open_browsing_privacy_settings()

        browsing_privacy.tap_clear_browsing_history()
        browsing_privacy.tap_clear()

        self.device.touch_home_button()
        search.launch()
        search.wait_for_history_to_load(number_of_items=0)
        self.assertEqual(0, search.history_items_count)
 def setUp(self):
     GaiaMtbfTestCase.setUp(self)
     self.settings = MTBF_Settings(self.marionette)
     self.settings.launch()
    def test_turn_on_and_off_bt(self):
        device_name = ''.join(random.choice(string.ascii_lowercase) for i in range(20))
        settings = Settings(self.marionette)
        settings.launch()

        self.assertFalse(self.data_layer.bluetooth_is_enabled)
        bluetooth_settings = settings.open_bluetooth()

        settings.enable_bluetooth()

        settings.tap_rename_my_device()
        bluetooth_settings.type_phone_name(device_name)
        bluetooth_settings.tap_update_device_name_ok()

        self.assertEquals(bluetooth_settings.device_name, device_name)

        settings.enable_visible_to_all()
        self.assertTrue(self.data_layer.bluetooth_is_discoverable)
        self.assertEquals(self.data_layer.bluetooth_name, device_name)

        settings.disable_bluetooth()
        settings.return_to_prev_menu(settings.screen_element)