def setUp(self): try: MarionetteTestCase.setUp(self) except InvalidResponseException: if self.restart: pass self.device = GaiaDevice(self.marionette, self.testvars) if self.restart and (self.device.is_android_build or self.marionette.instance): self.device.stop_b2g() if self.device.is_android_build: # revert device to a clean state self.device.manager.removeDir('/data/local/storage/persistent') self.device.manager.removeDir('/data/b2g/mozilla') self.device.start_b2g() # the emulator can be really slow! self.marionette.set_script_timeout(self._script_timeout) self.marionette.set_search_timeout(self._search_timeout) self.lockscreen = LockScreen(self.marionette) self.apps = GaiaApps(self.marionette) self.data_layer = GaiaData(self.marionette, self.testvars) from gaiatest.apps.keyboard.app import Keyboard self.keyboard = Keyboard(self.marionette) self.cleanUp()
def test_sms_semicolon_completes_the_entered_recipient(self): """ https://moztrap.mozilla.org/manage/case/10925/ """ self.messages = Messages(self.marionette) self.messages.launch() new_message = self.messages.tap_create_new_message() from gaiatest.apps.keyboard.app import Keyboard keyboard = Keyboard(self.marionette) keyboard.send('074') keyboard.send(';') # Verify if recipient is valid and uneditable self.assertNotIn('invalid', new_message.recipient_css_class) self.assertTrue(new_message.is_recipient_name_editable == 'false') keyboard.send('777') keyboard.send(';') self.assertEqual(new_message.number_of_recipients, 2) new_message.tap_message() self.assertEqual(new_message.number_of_recipients, 2) self.marionette.switch_to_frame() self.assertTrue(new_message.keyboard.is_keyboard_displayed)
def tap_number_input(self): number_input = self.marionette.find_element(*self._number_input_locator) self.marionette.execute_script("arguments[0].scrollIntoView(false);", [number_input]) number_input.tap() from gaiatest.apps.keyboard.app import Keyboard return Keyboard(self.marionette)
def test_sms_contact_validation(self): self.messages = Messages(self.marionette) self.messages.launch() new_message = self.messages.tap_create_new_message() from gaiatest.apps.keyboard.app import Keyboard keyboard = Keyboard(self.marionette) keyboard.send('test_contact') keyboard.tap_enter() # Verify if recipient is invalid and uneditable self.assertIn('invalid', new_message.recipient_css_class) self.assertTrue(new_message.is_recipient_name_editable == 'false') new_message.tap_recipient_name() self.assertTrue(new_message.is_recipient_name_editable == 'true') # Type_message will tap in the field to focus it new_message.type_message('Test message') self.assertFalse(new_message.is_send_button_enabled)
def tap_submit(self): el = self.marionette.find_element(*self._submit_locator) from gaiatest.apps.keyboard.app import Keyboard k = Keyboard(self.marionette) # The keyboard can overlay the submit button on desktop b2g, so close it k.dismiss() self.marionette.find_element(*self._submit_locator).tap()
def setUp(self): MarionetteTestCase.setUp(self) self.marionette.__class__ = type('Marionette', (Marionette, MarionetteTouchMixin), {}) self.device = GaiaDevice(self.marionette) if self.restart and (self.device.is_android_build or self.marionette.instance): self.device.stop_b2g() if self.device.is_android_build: # revert device to a clean state self.device.manager.removeDir('/data/local/indexedDB') self.device.manager.removeDir('/data/b2g/mozilla') self.device.start_b2g() self.marionette.setup_touch() # the emulator can be really slow! self.marionette.set_script_timeout(self._script_timeout) self.marionette.set_search_timeout(self._search_timeout) self.lockscreen = LockScreen(self.marionette) self.apps = GaiaApps(self.marionette) self.data_layer = GaiaData(self.marionette, self.testvars) from gaiatest.apps.keyboard.app import Keyboard self.keyboard = Keyboard(self.marionette) self.cleanUp()
def __init__(self, parent): self.apps = parent.apps self.data_layer = parent.data_layer self.parent = parent self.marionette = parent.marionette self.UTILS = parent.UTILS self.actions = Actions(self.marionette) self.keyboard = Keyboard(self.marionette)
def setUp(self): try: MarionetteTestCase.setUp(self) except InvalidResponseException: if self.restart: pass if self.yocto: """ with the yocto ammeter we only get amp measurements so we also need to use the linux kernel voltage device to sample the voltage at the start of each test so we can calculate watts.""" try: self.ammeter = YoctoAmmeter() except: self.ammeter = None self.device = GaiaDevice(self.marionette, self.testvars) if self.device.is_android_build: self.device.add_device_manager( self.get_device_manager( deviceSerial=self.marionette.device_serial)) if self.restart and (self.device.is_android_build or self.marionette.instance): self.device.stop_b2g() if self.device.is_android_build: self.cleanup_data() self.device.start_b2g() # we need to set the default timeouts because we may have a new session if self.marionette.timeout is not None: self.marionette.timeouts(self.marionette.TIMEOUT_SEARCH, self.marionette.timeout) self.marionette.timeouts(self.marionette.TIMEOUT_SCRIPT, self.marionette.timeout) self.marionette.timeouts(self.marionette.TIMEOUT_PAGE, self.marionette.timeout) else: self.marionette.timeouts(self.marionette.TIMEOUT_SEARCH, 10000) self.marionette.timeouts(self.marionette.TIMEOUT_PAGE, 30000) self.lockscreen = LockScreen(self.marionette) self.apps = GaiaApps(self.marionette) self.data_layer = GaiaData(self.marionette, self.testvars) from gaiatest.apps.keyboard.app import Keyboard self.keyboard = Keyboard(self.marionette) if self.device.is_android_build: self.cleanup_sdcard() if self.restart: self.cleanup_gaia(full_reset=False) else: self.cleanup_gaia(full_reset=True)
def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) self.keyboard = Keyboard(self.marionette) # Establish which phone number to use. self.phone_number = self.UTILS.general.get_config_variable("phone_number", "custom") self.UTILS.reporting.logComment("Sending sms to telephone number " + self.phone_number)
def create_passcode(self, passcode): # switch to keyboard, input passcode keyboard = Keyboard(self.marionette) keyboard.switch_to_keyboard() for times in range(2): keyboard.send("".join(passcode)) # switch to settings frame self.marionette.switch_to_frame() self.marionette.switch_to_frame(self.apps.displayed_app.frame) # create passcode self.wait_for_element_displayed( *self._phone_lock_passcode_section_locator) self.marionette.find_element(*self._passcode_create_locator).tap() self.wait_for_element_displayed(*self._phone_lock_section_locator)
def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.contacts = Contacts(self) self.keyboard = Keyboard(self.marionette) self.gmail_user = self.UTILS.general.get_config_variable( "gmail_1_user", "common") self.gmail_passwd = self.UTILS.general.get_config_variable( "gmail_1_pass", "common") self.connect_to_network() # Create test contacts. self.contact = MockContact() self.UTILS.general.insertContact(self.contact)
def test_post_bluetooth(self): lock_screen = LockScreen(self.marionette) homescreen = lock_screen.unlock() settings = Settings(self.marionette) settings.launch() bluetooth_settings = settings.open_bluetooth() self.data_layer.bluetooth_disable() # make sure it starts out disabled self.data_layer.bluetooth_enable() print "Enabled bluetooth" time.sleep(20) # Sometimes the BT device doesn't show up in the list right off. Try and click it, # if we can't then do an actual search and then try to click it again print "First Try" if not bluetooth_settings.tap_device('HC-06'): print "About to search for devices" bluetooth_settings.tap_search_for_devices() time.sleep(1) print "Second Try" if not bluetooth_settings.tap_device('HC-06'): assert False, "Unable to find bluetooth device 'HC-06'..." keyboard = Keyboard(self.marionette) #time.sleep(1) keyboard.send("1234") keyboard.tap_enter() time.sleep(35) print "Attempting to unpair with device" bluetooth_settings.refresh_root_element() if bluetooth_settings.tap_device('HC-06'): print "Confirming unpair" time.sleep(2) bluetooth_settings.tap_confirm_unpair_device() time.sleep(10) print "Device unpaired" print "Done sleep, disabling bluetooth" self.data_layer.bluetooth_disable() print "Disabled bluetooth" self.device.turn_screen_off() print "" print "Running Post Bluetooth Test" self.runPowerTest("post_idle_bluetooth", "Settings", "settings")
def test_contact_match(self): # insert contact self.contact = MockContact( tel={'value': '555%s' % repr(time.time()).replace('.', '')[8:]}) self.data_layer.insert_contact(self.contact) # launch Messages app self.messages = Messages(self.marionette) self.messages.launch() new_message = self.messages.tap_create_new_message() from gaiatest.apps.keyboard.app import Keyboard keyboard = Keyboard(self.marionette) keyboard.send(self.contact['name']) keyboard.tap_enter() # verify that contacts and tel number match self.assertEqual(self.contact['name'], new_message.first_recipient_name) self.assertEqual(self.contact['tel']['value'], new_message.first_recipient_number_attribute)
def keyboard(self): from gaiatest.apps.keyboard.app import Keyboard return Keyboard(self.marionette)
def __init__(self, parent): self.parent = parent self.marionette = parent.marionette self.keyboard = Keyboard(self.marionette)
def tap_recipient_section(self): self.marionette.find_element(*self._recipient_section_locator).tap() from gaiatest.apps.keyboard.app import Keyboard return Keyboard(self.marionette)
def test_ftu_skip_tour(self): # https://moztrap.mozilla.org/manage/case/3876/ # 3876, 3879 self.wait_for_element_displayed(*self._section_languages_locator) listed_languages = self.marionette.find_elements( *self._listed_languages_locator) self.assertGreater(len(listed_languages), 0, "No languages listed on screen") # select en-US due to the condition of this test is only for en-US language_item = self.marionette.find_element( *self.create_language_locator("en-US")) language_item.tap() # Tap next self.wait_for_element_displayed(*self._next_button_locator) self.marionette.find_element(*self._next_button_locator).tap() self.wait_for_element_displayed(*self._section_cell_data_locator) # Tap enable data self.marionette.find_element(*self._enable_data_checkbox_locator).tap() self.wait_for_condition( lambda m: self.data_layer.is_cell_data_connected, message="Cell data was not connected by FTU app") # Tap next self.marionette.find_element(*self._next_button_locator).tap() self.wait_for_element_displayed(*self._section_wifi_locator) # Wait for some networks to be found self.wait_for_condition(lambda m: len( m.find_elements(*self._found_wifi_networks_locator)) > 0, message="No networks listed on screen") wifi_network = self.marionette.find_element( By.ID, self.testvars['wifi']['ssid']) wifi_network.tap() # This is in the event we are using a Wifi Network that requires a password # We cannot be sure of this thus need the logic if self.testvars['wifi'].get('keyManagement'): self.wait_for_element_displayed(*self._password_input_locator) password = self.marionette.find_element( *self._password_input_locator) password.send_keys(self.testvars['wifi'].get('psk') or self.testvars['wifi'].get('wep')) # Wait for Keyboard app init and be displayed self.wait_for_condition( lambda m: Keyboard(self.marionette).is_displayed()) self.marionette.find_element(*self._join_network_locator).tap() self.wait_for_condition( lambda m: m.find_element(By.ID, self.testvars['wifi']['ssid']). find_element(*self._network_state_locator).text == "Connected") self.assertTrue( self.data_layer.is_wifi_connected(self.testvars['wifi']), "WiFi was not connected via FTU app") # is_wifi_connected() calls switch_to_frame() self.apps.switch_to_displayed_app() # Tap next self.marionette.find_element(*self._next_button_locator).tap() self.wait_for_element_displayed(*self._section_date_time_locator) # Set timezone continent_select = self.marionette.find_element( *self._timezone_continent_locator) continent_select.tap() self._select("Asia") city_select = self.marionette.find_element( *self._timezone_city_locator) city_select.tap() self._select("Almaty") self.assertEqual( self.marionette.find_element(*self._time_zone_title_locator).text, "UTC+06:00 Asia/Almaty") self.marionette.find_element(*self._next_button_locator).tap() # Verify Geolocation section appears self.wait_for_element_displayed(*self._section_geolocation_locator) # Disable geolocation self.wait_for_element_displayed( *self._enable_geolocation_checkbox_locator) self.marionette.find_element( *self._enable_geolocation_checkbox_locator).tap() self.wait_for_condition( lambda m: not self.data_layer.get_setting('geolocation.enabled'), message="Geolocation was not disabled by the FTU app") self.marionette.find_element(*self._next_button_locator).tap() self.wait_for_element_displayed(*self._section_import_contacts_locator) # Tap import from SIM # You can do this as many times as you like without db conflict self.marionette.find_element(*self._import_from_sim_locator).tap() # pass third condition when contacts are 0~N self.wait_for_condition( lambda m: self._pattern_contacts.match( m.find_element(*self._sim_import_feedback_locator).text ) is not None, message="Contact did not import from sim before timeout") # Find how many contacts are imported. import_sim_message = self.marionette.find_element( *self._sim_import_feedback_locator).text import_sim_count = None if self._pattern_contacts_0.match(import_sim_message) is not None: import_sim_count = 0 elif self._pattern_contacts_1.match(import_sim_message) is not None: import_sim_count = 1 elif self._pattern_contacts_N.match(import_sim_message) is not None: count = self._pattern_contacts_N.match(import_sim_message).group(1) import_sim_count = int(count) self.assertEqual(len(self.data_layer.all_contacts), import_sim_count) # all_contacts switches to top frame; Marionette needs to be switched back to ftu self.apps.switch_to_displayed_app() # Tap next self.marionette.find_element(*self._next_button_locator).tap() self.wait_for_element_displayed(*self._section_welcome_browser_locator) # Tap the statistics box and check that it sets a setting # TODO assert via settings API that this is set. Currently it is not used self.marionette.find_element( *self._enable_statistic_checkbox_locator).tap() # Tap next self.marionette.find_element(*self._next_button_locator).tap() self.wait_for_element_displayed(*self._section_browser_privacy_locator) # Enter a dummy email address and check it set inside the os # TODO assert that this is preserved in the system somewhere. Currently it is not used self.marionette.find_element( *self._email_field_locator).send_keys("*****@*****.**") # Tap next self.marionette.find_element(*self._next_button_locator).tap() self.wait_for_element_displayed(*self._section_finish_locator) # Skip the tour self.marionette.find_element(*self._skip_tour_button_locator).tap() # Switch back to top level now that FTU app is gone self.marionette.switch_to_frame()
def tap_url_input(self): self.marionette.find_element(*self._url_input_locator).tap() from gaiatest.apps.keyboard.app import Keyboard return Keyboard(self.marionette)