class TestFMRadioAddRemoveFavorites(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) # launch the FM Radio app self.fm_radio = FmRadio(self.marionette) self.fm_radio.launch() def test_add_remove_from_favorites(self): """ Add a frequency to favorite list https://moztrap.mozilla.org/manage/case/1923/ """ # check the headphone is plugged-in or not self.assertTrue(self.data_layer.is_antenna_available, 'Antenna (headphones) not plugged in') # wait for the radio start-up self.wait_for_condition(lambda m: self.data_layer.is_fm_radio_enabled) # add the current frequency to favorite list self.fm_radio.tap_add_favorite() self.assertEqual(len(self.fm_radio.favorite_channels), 1) # verify that the current frequency is in the favorite frequency is equal to the self.assertEqual(self.fm_radio.frequency, self.fm_radio.favorite_channels[0].text) # remove the station from favorite list self.fm_radio.favorite_channels[0].remove() # verify the change of favorite after remove self.assertEqual(0, len(self.fm_radio.favorite_channels))
class TestFMRadioAirplaneMode(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) # Disable the device radio, enable Airplane mode self.data_layer.set_setting('airplaneMode.enabled', True) def test_radio_airplane_mode(self): """ Set airplane mode then turn on the radio https://moztrap.mozilla.org/manage/case/8464/ """ self.fm_radio = FmRadio(self.marionette) self.fm_radio.launch( self.data_layer.get_setting('airplaneMode.enabled')) self.assertFalse(self.data_layer.is_fm_radio_enabled, 'Radio is still enabled in Airplane mode') # check the headphone is plugged-in or not self.assertTrue(self.data_layer.is_antenna_available, 'Antenna (headphones) not plugged in') Wait(self.marionette).until( lambda m: self.fm_radio.airplane_warning_title == 'Airplane mode is on') self.assertEqual(self.fm_radio.airplane_warning_text, 'Turn off Airplane mode to use FM Radio.')
class TestFMRadioFreqDialer(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) # launch the FM Radio app self.fm_radio = FmRadio(self.marionette) self.fm_radio.launch() def test_radio_frequency_dialer(self): # https://moztrap.mozilla.org/manage/case/2461/ # Access to the FM hardware radio requires the use of headphones self.assertTrue(self.data_layer.is_antenna_available, 'Antenna (headphones) not plugged in') # Determine if the FM hardware radio is enabled; wait for hardware init self.wait_for_condition(lambda m: self.data_layer.is_fm_radio_enabled) # Check that the FM radio has tuned in to the default channel frequency (lower bound) channel = self.data_layer.fm_radio_frequency self.assertEqual(self.fm_radio.frequency, channel) # Flick up the frequency dialer a few times for station in range(0, 5): # Get new coordinates for realistic flinging self.fm_radio.flick_frequency_dialer_up() # Check that the FM radio has tuned in to a higher default frequency (upper bound) self.assertNotEqual(channel, str(self.data_layer.fm_radio_frequency)) self.assertNotEqual(self.fm_radio.frequency, channel)
class TestFMRadioFreqDialer(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) # launch the FM Radio app self.fm_radio = FmRadio(self.marionette) self.fm_radio.launch() def test_radio_frequency_dialer(self): """ https://moztrap.mozilla.org/manage/case/2461/ """ # Access to the FM hardware radio requires the use of headphones self.assertTrue(self.data_layer.is_antenna_available, 'Antenna (headphones) not plugged in') # Determine if the FM hardware radio is enabled; wait for hardware init self.wait_for_condition(lambda m: self.data_layer.is_fm_radio_enabled) # Check that the FM radio has tuned in to the default channel frequency (lower bound) channel = self.data_layer.fm_radio_frequency self.assertEqual(self.fm_radio.frequency, channel) # Flick up the frequency dialer a few times for station in range(0, 5): # Get new coordinates for realistic flinging self.fm_radio.flick_frequency_dialer_up() # Check that the FM radio has tuned in to a higher default frequency (upper bound) self.assertNotEqual(channel, str(self.data_layer.fm_radio_frequency)) self.assertNotEqual(self.fm_radio.frequency, channel)
def setUp(self): GaiaEnduranceTestCase.setUp(self) # launch the FM Radio app self.fm_radio = FmRadio(self.marionette) self.fm_radio.launch() # check the headphone is plugged-in or not self.assertTrue(self.data_layer.is_antenna_available, 'Antenna (headphones) not plugged in') # wait for the radio start-up self.wait_for_condition(lambda m: self.data_layer.is_fm_radio_enabled) # stay on initial station for a few seconds time.sleep(5)
class TestFMRadioTurnOnOff(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.fm_radio = FmRadio(self.marionette) self.fm_radio.launch() def test_turn_radio_on_off(self): """ Turn off and then Turn on the radio https://moztrap.mozilla.org/manage/case/1930/ https://moztrap.mozilla.org/manage/case/1931/ """ self.wait_for_condition(lambda m: self.data_layer.is_fm_radio_enabled) # check the headphone is plugged-in or not self.assertTrue(self.data_layer.is_antenna_available, 'Antenna (headphones) not plugged in') # wait for the radio start-up self.wait_for_condition(lambda m: self.data_layer.is_fm_radio_enabled) # turn the radio off self.fm_radio.tap_power_button() # check the radio is off self.fm_radio.wait_for_radio_off() self.assertFalse(self.data_layer.is_fm_radio_enabled) # turn the radio on self.fm_radio.tap_power_button() self.wait_for_condition(lambda m: self.data_layer.is_fm_radio_enabled) # check the radio is on self.assertTrue(self.fm_radio.is_power_button_on) self.assertTrue(self.data_layer.is_fm_radio_enabled) def tearDown(self): if self.fm_radio.is_power_button_on: self.fm_radio.tap_power_button() GaiaTestCase.tearDown(self)
class TestEnduranceFMRadioPlay(GaiaEnduranceTestCase): def setUp(self): GaiaEnduranceTestCase.setUp(self) # launch the FM Radio app self.fm_radio = FmRadio(self.marionette) self.fm_radio.launch() # check the headphone is plugged-in or not self.assertTrue(self.data_layer.is_antenna_available, 'Antenna (headphones) not plugged in') # wait for the radio start-up self.wait_for_condition(lambda m: self.data_layer.is_fm_radio_enabled) # stay on initial station for a few seconds time.sleep(5) def test_endurance_fmradio_play(self): self.drive(test=self.fmradio_play, app='fm_radio') def fmradio_play(self): # Code taken from WebQA's existing FM radio tests (thanks!) # ensure radio is still enabled self.assertTrue(self.fm_radio.is_power_button_on, "FM radio should still be playing") # save the current frequency initial_frequency = self.fm_radio.frequency # go to next station self.fm_radio.tap_next() # check the change of the frequency self.assertNotEqual(initial_frequency, self.fm_radio.frequency) # Stay on new station for awhile; 33 seconds for 100 iterations; with checkpoints # every 10 iterations (radio plays during checkpoints) = 60 minutes of radio play time.sleep(33)
class TestFMRadioFindStations(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) # launch the FM Radio app self.fm_radio = FmRadio(self.marionette) self.fm_radio.launch() def test_find_next_station(self): """ Find next station https://moztrap.mozilla.org/manage/case/1928/ """ # check the headphone is plugged-in or not self.assertTrue(self.data_layer.is_antenna_available, 'Antenna (headphones) not plugged in') # wait for the radio start-up self.wait_for_condition(lambda m: self.data_layer.is_fm_radio_enabled) # save the current frequency initial_frequency = self.fm_radio.frequency # search next station self.fm_radio.tap_next() # check the ui value and the system value self.assertEqual(self.fm_radio.frequency, float(self.data_layer.fm_radio_frequency)) # check the change of the frequency self.assertNotEqual(initial_frequency, self.fm_radio.frequency) def test_find_prev_station(self): """ Find previous station https://moztrap.mozilla.org/manage/case/1929/ """ # check the headphone is plugged-in or not self.assertTrue(self.data_layer.is_antenna_available, 'Antenna (headphones) not plugged in') # wait for the radio start-up self.wait_for_condition(lambda m: self.data_layer.is_fm_radio_enabled) # save the current frequency current_frequency = self.fm_radio.frequency # check the ui value and the system value self.assertEqual(current_frequency, float(self.data_layer.fm_radio_frequency)) # search prev station self.fm_radio.tap_previous() # check the ui value and the system value self.assertEqual(self.fm_radio.frequency, float(self.data_layer.fm_radio_frequency)) # check the change of the frequency self.assertNotEqual(current_frequency, self.fm_radio.frequency)
class TestFMRadioAirplaneMode(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) # Disable the device radio, enable Airplane mode self.data_layer.set_setting('airplaneMode.enabled', True) def test_radio_airplane_mode(self): """ Set airplane mode then turn on the radio https://moztrap.mozilla.org/manage/case/8464/ """ self.fm_radio = FmRadio(self.marionette) self.fm_radio.launch(self.data_layer.get_setting('airplaneMode.enabled')) self.assertFalse(self.data_layer.is_fm_radio_enabled, 'Radio is still enabled in Airplane mode') # check the headphone is plugged-in or not self.assertTrue(self.data_layer.is_antenna_available, 'Antenna (headphones) not plugged in') Wait(self.marionette).until(lambda m: self.fm_radio.airplane_warning_title == 'Airplane mode is on') self.assertEqual(self.fm_radio.airplane_warning_text, 'Turn off Airplane mode to use FM Radio.')
class TestFMRadioFindStations(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) # launch the FM Radio app self.fm_radio = FmRadio(self.marionette) self.fm_radio.launch() def test_find_next_previous_station(self): """ Find next station https://moztrap.mozilla.org/manage/case/1928/ Find previous station https://moztrap.mozilla.org/manage/case/1929/ """ # check the headphone is plugged-in or not self.assertTrue(self.data_layer.is_antenna_available, 'Antenna (headphones) not plugged in') # wait for the radio start-up self.wait_for_condition(lambda m: self.data_layer.is_fm_radio_enabled) # save the current frequency initial_frequency = self.fm_radio.frequency # search next station self.fm_radio.tap_next() # check the ui value and the system value self.assertEqual(self.fm_radio.frequency, float(self.data_layer.fm_radio_frequency)) # check the change of the frequency self.assertNotEqual(initial_frequency, self.fm_radio.frequency) # save the current frequency current_frequency = self.fm_radio.frequency # check the ui value and the system value self.assertEqual(current_frequency, float(self.data_layer.fm_radio_frequency)) # search prev station self.fm_radio.tap_previous() # check the ui value and the system value self.assertEqual(self.fm_radio.frequency, float(self.data_layer.fm_radio_frequency)) # check the change of the frequency self.assertNotEqual(current_frequency, self.fm_radio.frequency)
class TestFMRadioRemoveFromFavorite(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) # launch the FM Radio app self.fm_radio = FmRadio(self.marionette) self.fm_radio.launch() def test_remove_from_favorite(self): """ Remove a station from favorite list https://moztrap.mozilla.org/manage/case/1926/ """ # check the headphone is plugged-in or not self.assertTrue(self.data_layer.is_antenna_available, 'Antenna (headphones) not plugged in') # wait for the radio start-up self.wait_for_condition(lambda m: self.data_layer.is_fm_radio_enabled) # add the current frequency to favorite list self.fm_radio.tap_add_favorite() # verify the change of favorite list after add self.assertEqual(1, len(self.fm_radio.favorite_channels)) # remove the station from favorite list self.fm_radio.favorite_channels[0].remove() # TODO: The remove method should wait for the favourite to be removed. bug 864296 self.fm_radio.wait_for_favorite_list_not_displayed() # verify the change of favorite after remove self.assertEqual(0, len(self.fm_radio.favorite_channels)) def tearDown(self): # remove the station from favorite list for favorite_channel in self.fm_radio.favorite_channels: favorite_channel.remove() GaiaTestCase.tearDown(self)
def setUp(self): GaiaTestCase.setUp(self) # launch the FM Radio app self.fm_radio = FmRadio(self.marionette) self.fm_radio.launch()