class TestCameraFlashModes(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) # Turn off Geolocation prompt self.apps.set_permission('Camera', 'geolocation', 'deny') def test_camera_flash_modes(self): # https://moztrap.mozilla.org/manage/case/1325/ self.previous_number_of_pictures = len(self.data_layer.picture_files) self.camera = Camera(self.marionette) self.camera.launch() # Toggle flash mode to "on" self.camera.tap_toggle_flash_button() self.assertEqual(self.camera.current_flash_mode, 'on') # Take a photo self.camera.take_photo() # Check that thumbnail is visible self.assertTrue(self.camera.is_thumbnail_visible) # Check that picture saved to SD card self.wait_for_condition(lambda m: len(self.data_layer.picture_files) == self.previous_number_of_pictures + 1, 10) self.assertEqual(len(self.data_layer.picture_files), self.previous_number_of_pictures + 1) # Toggle flash mode to "off" self.camera.tap_toggle_flash_button() self.assertEqual(self.camera.current_flash_mode, 'off') first_image_src = self.camera.current_image_src # Take a photo self.camera.take_photo() self.camera.wait_for_picture_to_change(first_image_src) # Check that Filmstrip is visible self.assertTrue(self.camera.is_thumbnail_visible) # Check that picture saved to SD card self.wait_for_condition(lambda m: len(self.data_layer.picture_files) == self.previous_number_of_pictures + 2, 10) self.assertEqual(len(self.data_layer.picture_files), self.previous_number_of_pictures + 2) # Toggle flash mode to "auto" self.camera.tap_toggle_flash_button() self.assertEqual(self.camera.current_flash_mode, 'auto') second_image_src = self.camera.current_image_src # Take a photo self.camera.take_photo() self.camera.wait_for_picture_to_change(second_image_src) # Check that Filmstrip is visible self.assertTrue(self.camera.is_thumbnail_visible) # Check that picture saved to SD card self.wait_for_condition(lambda m: len(self.data_layer.picture_files) == self.previous_number_of_pictures + 3, 10) self.assertEqual(len(self.data_layer.picture_files), self.previous_number_of_pictures + 3)
class TestCameraFlashModes(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) # Turn off Geolocation prompt self.apps.set_permission('Camera', 'geolocation', 'deny') def test_camera_flash_modes(self): # https://moztrap.mozilla.org/manage/case/1325/ self.camera = Camera(self.marionette) self.camera.launch() if self.camera.is_toggle_flash_button_visible: # Toggle flash mode to "on" self.camera.tap_toggle_flash_button() self.assertEqual(self.camera.current_flash_mode, 'on') # Take a photo self.camera.take_photo() # Check that Filmstrip is visible self.assertTrue(self.camera.is_filmstrip_visible) # Check that picture saved to SD card self.wait_for_condition( lambda m: len(self.data_layer.picture_files) == 1) self.assertEqual(len(self.data_layer.picture_files), 1) # Toggle flash mode to "off" self.camera.tap_toggle_flash_button() self.assertEqual(self.camera.current_flash_mode, 'off') # Take a photo self.camera.take_photo() # Check that Filmstrip is visible self.assertTrue(self.camera.is_filmstrip_visible) # Check that picture saved to SD card self.wait_for_condition( lambda m: len(self.data_layer.picture_files) == 2) self.assertEqual(len(self.data_layer.picture_files), 2) # Toggle flash mode to "auto" self.camera.tap_toggle_flash_button() self.assertEqual(self.camera.current_flash_mode, 'auto') # Take a photo self.camera.take_photo() # Check that Filmstrip is visible self.assertTrue(self.camera.is_filmstrip_visible) # Check that picture saved to SD card self.wait_for_condition( lambda m: len(self.data_layer.picture_files) == 3) self.assertEqual(len(self.data_layer.picture_files), 3)
class TestCameraFlashModes(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) # Turn off Geolocation prompt self.apps.set_permission("Camera", "geolocation", "deny") def test_camera_flash_modes(self): # https://moztrap.mozilla.org/manage/case/1325/ self.camera = Camera(self.marionette) self.camera.launch() if self.camera.is_toggle_flash_button_visible: # Toggle flash mode to "on" self.camera.tap_toggle_flash_button() self.assertEqual(self.camera.current_flash_mode, "on") # Take a photo self.camera.take_photo() # Check that Filmstrip is visible self.assertTrue(self.camera.is_filmstrip_visible) # Check that picture saved to SD card self.wait_for_condition(lambda m: len(self.data_layer.picture_files) == 1) self.assertEqual(len(self.data_layer.picture_files), 1) # Toggle flash mode to "off" self.camera.tap_toggle_flash_button() self.assertEqual(self.camera.current_flash_mode, "off") # Take a photo self.camera.take_photo() # Check that Filmstrip is visible self.assertTrue(self.camera.is_filmstrip_visible) # Check that picture saved to SD card self.wait_for_condition(lambda m: len(self.data_layer.picture_files) == 2) self.assertEqual(len(self.data_layer.picture_files), 2) # Toggle flash mode to "auto" self.camera.tap_toggle_flash_button() self.assertEqual(self.camera.current_flash_mode, "auto") # Take a photo self.camera.take_photo() # Check that Filmstrip is visible self.assertTrue(self.camera.is_filmstrip_visible) # Check that picture saved to SD card self.wait_for_condition(lambda m: len(self.data_layer.picture_files) == 3) self.assertEqual(len(self.data_layer.picture_files), 3)
class TestCameraPower(TestPower): _camera_frame_locator = (By.CSS_SELECTOR, 'iframe[src*="camera"][src*="/index.html"]') def setUp(self): TestPower.setUp(self) def take_picture(self): self.camera.take_photo() def test_camera_preview(self): """https://moztrap.mozilla.org/manage/case/1296/""" lock_screen = LockScreen(self.marionette) homescreen = lock_screen.unlock() self.wait_for_condition(lambda m: self.apps.displayed_app.name == homescreen.name) # Turn off the geolocation prompt, and then launch the camera app self.apps.set_permission('Camera', 'geolocation', 'deny') self.camera = Camera(self.marionette) self.camera.launch() while (self.camera.current_flash_mode != 'off'): self.camera.tap_toggle_flash_button(); time.sleep(2) self.marionette.switch_to_frame() self.wait_for_element_present(*self._camera_frame_locator) camera_frame = self.marionette.find_element(*self._camera_frame_locator) camera_frame.tap() self.marionette.switch_to_frame(camera_frame) print "" print "Running Camera Preview Test" self.runPowerTest("camera_preview", "Camera", "camera") def test_camera_video(self): """https://moztrap.mozilla.org/manage/case/1296/""" lock_screen = LockScreen(self.marionette) homescreen = lock_screen.unlock() self.wait_for_condition(lambda m: self.apps.displayed_app.name == homescreen.name) # Turn off the geolocation prompt, and then launch the camera app self.apps.set_permission('Camera', 'geolocation', 'deny') self.camera = Camera(self.marionette) self.camera.launch() while (self.camera.current_flash_mode != 'off'): self.camera.tap_toggle_flash_button(); time.sleep(2) time.sleep(5) self.camera.tap_switch_source() time.sleep(5) self.marionette.switch_to_frame() self.wait_for_element_present(*self._camera_frame_locator) camera_frame = self.marionette.find_element(*self._camera_frame_locator) camera_frame.tap() self.marionette.switch_to_frame(camera_frame) self.camera.tap_capture() print "" print "Running Camera Video Test" self.runPowerTest("camera_video", "Camera", "camera") self.camera.tap_capture() def test_camera_picture(self): """https://moztrap.mozilla.org/manage/case/1296/""" lock_screen = LockScreen(self.marionette) homescreen = lock_screen.unlock() self.wait_for_condition(lambda m: self.apps.displayed_app.name == homescreen.name) # Turn off the geolocation prompt, and then launch the camera app self.apps.set_permission('Camera', 'geolocation', 'deny') self.camera = Camera(self.marionette) self.camera.launch() while (self.camera.current_flash_mode != 'off'): self.camera.tap_toggle_flash_button(); time.sleep(2) self.marionette.switch_to_frame() self.wait_for_element_present(*self._camera_frame_locator) camera_frame = self.marionette.find_element(*self._camera_frame_locator) camera_frame.tap() self.marionette.switch_to_frame(camera_frame) print "" print "Running Camera Picture Test" self.runPowerTest("camera_picture", "Camera", "camera", PICTURE_INTERVAL_TIME, self.take_picture) def tearDown(self): TestPower.tearDown(self)
class TestCameraFlashModes(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) # Turn off Geolocation prompt self.apps.set_permission('Camera', 'geolocation', 'deny') def test_camera_flash_modes(self): # https://moztrap.mozilla.org/manage/case/1325/ self.previous_number_of_pictures = len(self.data_layer.picture_files) self.camera = Camera(self.marionette) self.camera.launch() # Toggle flash mode to "on" self.camera.tap_toggle_flash_button() self.assertEqual(self.camera.current_flash_mode, 'on') # Take a photo self.camera.take_photo() # Check that thumbnail is visible self.assertTrue(self.camera.is_thumbnail_visible) # Check that picture saved to SD card self.wait_for_condition( lambda m: len(self.data_layer.picture_files) == self. previous_number_of_pictures + 1, 10) self.assertEqual(len(self.data_layer.picture_files), self.previous_number_of_pictures + 1) # Toggle flash mode to "off" self.camera.tap_toggle_flash_button() self.assertEqual(self.camera.current_flash_mode, 'off') first_image_src = self.camera.current_image_src # Take a photo self.camera.take_photo() self.camera.wait_for_picture_to_change(first_image_src) # Check that Filmstrip is visible self.assertTrue(self.camera.is_thumbnail_visible) # Check that picture saved to SD card self.wait_for_condition( lambda m: len(self.data_layer.picture_files) == self. previous_number_of_pictures + 2, 10) self.assertEqual(len(self.data_layer.picture_files), self.previous_number_of_pictures + 2) # Toggle flash mode to "auto" self.camera.tap_toggle_flash_button() self.assertEqual(self.camera.current_flash_mode, 'auto') second_image_src = self.camera.current_image_src # Take a photo self.camera.take_photo() self.camera.wait_for_picture_to_change(second_image_src) # Check that Filmstrip is visible self.assertTrue(self.camera.is_thumbnail_visible) # Check that picture saved to SD card self.wait_for_condition( lambda m: len(self.data_layer.picture_files) == self. previous_number_of_pictures + 3, 10) self.assertEqual(len(self.data_layer.picture_files), self.previous_number_of_pictures + 3)
class TestPostIdlePower(TestPower): _geoloc_start_button_locator = (By.ID, 'permission-yes') _camera_frame_locator = (By.CSS_SELECTOR, 'iframe[src*="camera"][src*="/index.html"]') def setUp(self): TestPower.setUp(self) self.data_layer.set_setting("airplaneMode.enabled", False) def test_post_wifi_disable(self): lock_screen = LockScreen(self.marionette) homescreen = lock_screen.unlock() #homescreen.wait_to_be_displayed() self.data_layer.disable_wifi() # make sure it starts out disabled self.data_layer.connect_to_wifi() print "Connected to wifi" time.sleep(30) self.data_layer.disable_wifi() print "Disabled wifi" self.device.turn_screen_off() print "" print "Running Post Wifi Test (screen off)" self.runPowerTest("post_idle_wifi", "Homescreen", "verticalhome") def go_to_url(self, homescreen, url): search = Search(self.marionette) search.launch() browser = search.go_to_url(url) def post_idle_wifi_browser_run_test(self, url, test_name, permissionFlag = False): lock_screen = LockScreen(self.marionette) homescreen = lock_screen.unlock() self.data_layer.disable_wifi() # make sure it starts out disabled self.data_layer.connect_to_wifi() print "Connected to wifi" self.apps.switch_to_displayed_app() self.go_to_url(homescreen, url) print "Opened URL" if permissionFlag: time.sleep(2) print "Looking for Permission Dialog" permission = PermissionDialog(self.marionette) permission.wait_for_permission_dialog_displayed() print "Pressing Share Button" permission.tap_to_confirm_permission() print "Waiting 30 seconds for URL to load" time.sleep(30) self.device.touch_home_button() #homescreen.wait_to_be_displayed() self.data_layer.disable_wifi() print "Disabled wifi" self.device.turn_screen_off() print "" print "Running Test (", test_name, ")" self.runPowerTest(test_name, "Browser", "browser") def test_post_maps(self): url = "https://maps.google.com" self.post_idle_wifi_browser_run_test(url, "post_idle_maps", True) def test_post_camera_preview(self): lock_screen = LockScreen(self.marionette) homescreen = lock_screen.unlock() # Turn off the geolocation prompt, and then launch the camera app self.apps.set_permission('Camera', 'geolocation', 'deny') self.camera = Camera(self.marionette) self.camera.launch() while (self.camera.current_flash_mode != 'off'): self.camera.tap_toggle_flash_button(); time.sleep(2) self.marionette.switch_to_frame() camera_frame = Wait(self.marionette, timeout=120).until( expected.element_present(*self._camera_frame_locator)) camera_frame.tap() self.marionette.switch_to_frame(camera_frame) time.sleep(20) self.device.touch_home_button() time.sleep(10) self.device.turn_screen_off() print "" print "Running Post Camera Preview Test" self.runPowerTest("post_idle_camera_preview", "Camera", "camera") 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 tearDown(self): TestPower.tearDown(self)
class TestPostIdlePower(TestPower): _geoloc_start_button_locator = (By.ID, 'permission-yes') _camera_frame_locator = (By.CSS_SELECTOR, 'iframe[src*="camera"][src*="/index.html"]') def setUp(self): TestPower.setUp(self) self.data_layer.set_setting("airplaneMode.enabled", False) def test_post_wifi_disable(self): lock_screen = LockScreen(self.marionette) homescreen = lock_screen.unlock() #homescreen.wait_to_be_displayed() self.data_layer.disable_wifi() # make sure it starts out disabled self.data_layer.connect_to_wifi() print "Connected to wifi" time.sleep(30) self.data_layer.disable_wifi() print "Disabled wifi" self.device.turn_screen_off() print "" print "Running Post Wifi Test (screen off)" self.runPowerTest("post_idle_wifi", "Homescreen", "verticalhome") def go_to_url(self, homescreen, url): search = Search(self.marionette) search.launch() browser = search.go_to_url(url) def post_idle_wifi_browser_run_test(self, url, test_name, permissionFlag=False): lock_screen = LockScreen(self.marionette) homescreen = lock_screen.unlock() self.data_layer.disable_wifi() # make sure it starts out disabled self.data_layer.connect_to_wifi() print "Connected to wifi" self.apps.switch_to_displayed_app() self.go_to_url(homescreen, url) print "Opened URL" if permissionFlag: time.sleep(2) print "Looking for Permission Dialog" permission = PermissionDialog(self.marionette) permission.wait_for_permission_dialog_displayed() print "Pressing Share Button" permission.tap_to_confirm_permission() print "Waiting 30 seconds for URL to load" time.sleep(30) self.device.touch_home_button() #homescreen.wait_to_be_displayed() self.data_layer.disable_wifi() print "Disabled wifi" self.device.turn_screen_off() print "" print "Running Test (", test_name, ")" self.runPowerTest(test_name, "Browser", "browser") def test_post_maps(self): url = "https://maps.google.com" self.post_idle_wifi_browser_run_test(url, "post_idle_maps", True) def test_post_camera_preview(self): lock_screen = LockScreen(self.marionette) homescreen = lock_screen.unlock() # Turn off the geolocation prompt, and then launch the camera app self.apps.set_permission('Camera', 'geolocation', 'deny') self.camera = Camera(self.marionette) self.camera.launch() while (self.camera.current_flash_mode != 'off'): self.camera.tap_toggle_flash_button() time.sleep(2) self.marionette.switch_to_frame() camera_frame = Wait(self.marionette, timeout=120).until( expected.element_present(*self._camera_frame_locator)) camera_frame.tap() self.marionette.switch_to_frame(camera_frame) time.sleep(20) self.device.touch_home_button() time.sleep(10) self.device.turn_screen_off() print "" print "Running Post Camera Preview Test" self.runPowerTest("post_idle_camera_preview", "Camera", "camera") 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 tearDown(self): TestPower.tearDown(self)
class TestCameraPower(TestPower): _camera_frame_locator = (By.CSS_SELECTOR, 'iframe[src*="camera"][src*="/index.html"]') def setUp(self): TestPower.setUp(self) def take_picture(self): self.camera.take_photo() def test_camera_preview(self): """https://moztrap.mozilla.org/manage/case/1296/""" lock_screen = LockScreen(self.marionette) homescreen = lock_screen.unlock() #self.wait_for_condition(lambda m: self.apps.displayed_app.name == homescreen.name) # Turn off the geolocation prompt, and then launch the camera app self.apps.set_permission('Camera', 'geolocation', 'deny') self.camera = Camera(self.marionette) self.camera.launch() while (self.camera.current_flash_mode != 'off'): self.camera.tap_toggle_flash_button() time.sleep(2) self.marionette.switch_to_frame() camera_frame = Wait(self.marionette, timeout=120).until( expected.element_present(*self._camera_frame_locator)) camera_frame.tap() self.marionette.switch_to_frame(camera_frame) print "" print "Running Camera Preview Test" self.runPowerTest("camera_preview", "Camera", "camera") def test_camera_video(self): """https://moztrap.mozilla.org/manage/case/1296/""" lock_screen = LockScreen(self.marionette) homescreen = lock_screen.unlock() #self.wait_for_condition(lambda m: self.apps.displayed_app.name == homescreen.name) # Turn off the geolocation prompt, and then launch the camera app self.apps.set_permission('Camera', 'geolocation', 'deny') self.camera = Camera(self.marionette) self.camera.launch() while (self.camera.current_flash_mode != 'off'): self.camera.tap_toggle_flash_button() time.sleep(2) time.sleep(5) self.camera.tap_switch_source() time.sleep(5) self.marionette.switch_to_frame() camera_frame = Wait(self.marionette, timeout=120).until( expected.element_present(*self._camera_frame_locator)) camera_frame.tap() self.marionette.switch_to_frame(camera_frame) self.camera.tap_capture() print "" print "Running Camera Video Test" self.runPowerTest("camera_video", "Camera", "camera") self.camera.tap_capture() def test_camera_picture(self): """https://moztrap.mozilla.org/manage/case/1296/""" lock_screen = LockScreen(self.marionette) homescreen = lock_screen.unlock() #self.wait_for_condition(lambda m: self.apps.displayed_app.name == homescreen.name) # Turn off the geolocation prompt, and then launch the camera app self.apps.set_permission('Camera', 'geolocation', 'deny') self.camera = Camera(self.marionette) self.camera.launch() while (self.camera.current_flash_mode != 'off'): self.camera.tap_toggle_flash_button() time.sleep(2) self.marionette.switch_to_frame() camera_frame = Wait(self.marionette, timeout=120).until( expected.element_present(*self._camera_frame_locator)) camera_frame.tap() self.marionette.switch_to_frame(camera_frame) print "" print "Running Camera Picture Test" self.runPowerTest("camera_picture", "Camera", "camera", PICTURE_INTERVAL_TIME, self.take_picture) def tearDown(self): TestPower.tearDown(self)