Beispiel #1
0
class TestCamera(GaiaTestCase):

    def setUp(self):
        GaiaTestCase.setUp(self)

        # Turn off geolocation prompt
        self.apps.set_permission('Camera', 'geolocation', 'deny')

    def test_capture_a_video(self):
        # https://moztrap.mozilla.org/manage/case/2477/

        self.camera = Camera(self.marionette)
        self.camera.launch()

        self.camera.tap_switch_source()

        self.camera.tap_capture()
        self.camera.wait_for_video_capturing()

        # Wait for 3 seconds of recording
        self.wait_for_condition(lambda m: self.camera.video_timer >= time.strptime('00:03', '%M:%S'))

        # Stop recording
        self.camera.tap_capture()
        self.camera.wait_for_video_timer_not_visible()

        # Wait for image to be added in to filmstrip
        self.camera.wait_for_filmstrip_visible()

        # Find the new film thumbnail in the film strip
        self.assertTrue(self.camera.is_filmstrip_visible)
class TestCamera(GaiaTestCase):
    def setUp(self):
        GaiaTestCase.setUp(self)

        # Turn off geolocation prompt
        self.apps.set_permission('Camera', 'geolocation', 'deny')

    def test_capture_a_video(self):
        """https://moztrap.mozilla.org/manage/case/2477/"""

        # Check that 0 video files are present before we start the test
        self.assertEqual(len(self.data_layer.video_files), 0)

        self.camera = Camera(self.marionette)
        self.camera.launch()

        # Switch to video mode
        self.camera.tap_switch_source()

        # Record 3 seconds of video
        self.camera.record_video(3)

        # Check that Filmstrip is visible
        self.assertTrue(self.camera.is_filmstrip_visible)
        self.camera.wait_for_filmstrip_not_visible()

        # Check that video saved to SD card
        self.assertIn("VID_0001.3gp", self.data_layer.video_files[0])
Beispiel #3
0
class TestCamera(GaiaMtbfTestCase):
    def setUp(self):
        GaiaMtbfTestCase.setUp(self)

        # Turn off geolocation prompt
        self.apps.set_permission('Camera', 'geolocation', 'deny')

        self.camera = Camera(self.marionette)
        self.camera.launch()

    def test_capture_a_video(self):
        """https://moztrap.mozilla.org/manage/case/2477/"""
        self.previous_number_of_videos = len(self.data_layer.video_files)

        # Switch to video mode
        self.camera.wait_for_capture_ready()
        if self.camera.camera_mode == u'picture':
            self.camera.tap_switch_source()

        # Record 10 seconds of video
        self.camera.record_video(10)

        # Check that video saved to SD card
        self.wait_for_condition(
            lambda m: len(self.data_layer.video_files) == self.
            previous_number_of_videos + 1, 15)
        self.assertEqual(len(self.data_layer.video_files),
                         self.previous_number_of_videos + 1)

    def tearDown(self):
        GaiaMtbfTestCase.tearDown(self)
class TestCamera(GaiaTestCase):

    def setUp(self):
        GaiaTestCase.setUp(self)

        # Turn off geolocation prompt
        self.apps.set_permission('Camera', 'geolocation', 'deny')

    def test_capture_a_video(self):
        """https://moztrap.mozilla.org/manage/case/2477/"""

        # Check that 0 video files are present before we start the test
        self.assertEqual(len(self.data_layer.video_files), 0)

        self.camera = Camera(self.marionette)
        self.camera.launch()

        # Switch to video mode
        self.camera.tap_switch_source()

        # Record 3 seconds of video
        self.camera.record_video(3)

        # Check that Filmstrip is visible
        self.assertTrue(self.camera.is_filmstrip_visible)
        self.camera.wait_for_filmstrip_not_visible()

        # Check that video saved to SD card
        self.assertIn("VID_0001.3gp", self.data_layer.video_files[0])
Beispiel #5
0
class TestCamera(GaiaTestCase):

    def setUp(self):
        GaiaTestCase.setUp(self)

        # Turn off geolocation prompt
        self.apps.set_permission('Camera', 'geolocation', 'deny')

    def test_capture_a_video(self):
        """
        https://moztrap.mozilla.org/manage/case/2477/
        """
        self.previous_number_of_videos = len(self.data_layer.video_files)

        self.camera = Camera(self.marionette)
        self.camera.launch()

        # Switch to video mode
        self.camera.tap_switch_source()

        # Record 3 seconds of video
        self.camera.record_video(3)

        # Check that video saved to SD card
        self.wait_for_condition(lambda m: len(self.data_layer.video_files) == self.previous_number_of_videos + 1, 15)
        self.assertEqual(len(self.data_layer.video_files), self.previous_number_of_videos + 1)
class TestCamera(GaiaTestCase):

    def setUp(self):
        GaiaTestCase.setUp(self)

        # Turn off geolocation prompt
        self.apps.set_permission('Camera', 'geolocation', 'deny')

    def test_capture_a_video(self):
        # https://moztrap.mozilla.org/manage/case/2477/
        self.camera = Camera(self.marionette)
        self.camera.launch()

        # Switch to video mode
        self.camera.tap_switch_source()

        # Record 3 seconds of video
        self.camera.record_video(3)

        # Check that Filmstrip is visible
        self.assertTrue(self.camera.is_filmstrip_visible)

        # Check that video saved to SD card
        self.wait_for_condition(lambda m: len(self.data_layer.video_files) == 1)
        self.assertEqual(len(self.data_layer.video_files), 1)
class TestCamera(GaiaTestCase):
    def setUp(self):
        GaiaTestCase.setUp(self)

        # Turn off geolocation prompt
        self.apps.set_permission('Camera', 'geolocation', 'deny')

    def test_capture_a_video(self):
        """https://moztrap.mozilla.org/manage/case/2477/"""

        self.camera = Camera(self.marionette)
        self.camera.launch()

        # Switch to video mode
        self.camera.tap_switch_source()

        # Record 3 seconds of video
        self.camera.record_video(3)

        # Check that Filmstrip is visible
        self.assertTrue(self.camera.is_filmstrip_visible)

        # Check that video saved to SD card
        self.wait_for_condition(
            lambda m: len(self.data_layer.video_files) == 1)
        self.assertEqual(len(self.data_layer.video_files), 1)
Beispiel #8
0
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)
Beispiel #9
0
class TestCameraMultipleShots(GaiaMtbfTestCase):
    def setUp(self):
        GaiaMtbfTestCase.setUp(self)

        # Turn off Geolocation prompt
        self.apps.set_permission('Camera', 'geolocation', 'deny')

    def test_capture_multiple_shots(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()

        # Take a photo
        if self.camera.camera_mode == u'video':
            self.camera.tap_switch_source()

        self.camera.take_photo()

        self.apps.switch_to_displayed_app()
        # 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)

        # 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 + 2, 10)
        self.assertEqual(len(self.data_layer.picture_files),
                         self.previous_number_of_pictures + 2)

        # 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 + 3, 10)
        self.assertEqual(len(self.data_layer.picture_files),
                         self.previous_number_of_pictures + 3)

    def tearDown(self):
        GaiaMtbfTestCase.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.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)
Beispiel #11
0
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)
    def camera_viewfinder(self):
        # Start camera
        camera_app = Camera(self.marionette)
        camera_app.launch()

        # Leave viewfinder running / displayed for 30 seconds
        time.sleep(30)

        # Sleep a bit then close the app
        self.close_app()

        # Sleep between iterations
        time.sleep(5)
    def camera_viewfinder(self):
        # Start camera
        camera_app = Camera(self.marionette)
        camera_app.launch()

        # Leave viewfinder running / displayed for 30 seconds
        time.sleep(30)

        # Sleep a bit then close the app
        self.close_app()

        # Sleep between iterations
        time.sleep(5)
class TestCameraMultipleShots(GaiaMtbfTestCase):

    def setUp(self):
        GaiaMtbfTestCase.setUp(self)

        # Turn off Geolocation prompt
        self.apps.set_permission('Camera', 'geolocation', 'deny')

    def test_capture_multiple_shots(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()

        # Take a photo
        if self.camera.camera_mode == u'video':
            self.camera.tap_switch_source()

        self.camera.take_photo()

        self.apps.switch_to_displayed_app()
        # 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)

        # 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 + 2, 10)
        self.assertEqual(len(self.data_layer.picture_files), self.previous_number_of_pictures + 2)

        # 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 + 3, 10)
        self.assertEqual(len(self.data_layer.picture_files), self.previous_number_of_pictures + 3)

    def tearDown(self):
        GaiaMtbfTestCase.tearDown(self)
class TestPreviewDelete(GaiaTestCase):
    def setUp(self):
        GaiaTestCase.setUp(self)

        # Turn off geolocation prompt
        self.apps.set_permission('Camera', 'geolocation', 'deny')

    def test_capture_and_delete_video(self):
        """
        https://moztrap.mozilla.org/manage/case/3324/
        """
        self.previous_number_of_videos = len(self.data_layer.video_files)

        # launch camera app
        self.camera = Camera(self.marionette)
        self.camera.launch()

        # Switch to video mode
        self.camera.tap_switch_source()

        # Record 10 seconds of video
        self.camera.record_video(10)

        # Check that video saved to SD card
        self.assertEqual(
            len(self.data_layer.video_files),
            self.previous_number_of_videos + 1)

        # Tap preview icon to see the video that's just taken
        self.camera.tap_thumbnail()
        self.preview = ImagePreview(self.marionette)
        Wait(self.marionette).until(
            lambda m: self.preview.is_video_play_button_visible is True)

        # Play video, then pause it
        self.preview.tap_video_player_play_button()
        time.sleep(5)
        self.preview.tap_video_player_pause_button()

        # Tape the options icon, and delete the file
        self.preview.delete_file()

        # Check the user is back in camera preview mode, and there is no preview icon anymore
        Wait(self.marionette).until(
            lambda m: self.camera.is_thumbnail_visible is False)

        # Verify the video is deleted now
        self.assertEqual(
            len(self.data_layer.video_files), self.previous_number_of_videos)
Beispiel #16
0
    def camera_photo(self):
        # Start camera
        camera_app = Camera(self.marionette)
        camera_app.launch()
        time.sleep(5)

        # Take a photo
        camera_app.take_photo()

        # Sleep a bit then close the app
        time.sleep(5)
        self.close_app()

        # Sleep between iterations
        time.sleep(5)
Beispiel #17
0
    def camera_photo(self):
        # Start camera
        camera_app = Camera(self.marionette)
        camera_app.launch()
        time.sleep(5)

        # Take a photo
        camera_app.take_photo()

        # Sleep a bit then close the app
        time.sleep(5)
        self.close_app()

        # Sleep between iterations
        time.sleep(5)
class TestCamera(GaiaTestCase):
    def setUp(self):
        GaiaTestCase.setUp(self)

        # Turn off geolocation prompt
        self.apps.set_permission('Camera', 'geolocation', 'deny')

    def test_capture_a_video(self):
        # https://moztrap.mozilla.org/manage/case/2477/

        self.camera = Camera(self.marionette)
        self.camera.launch()

        self.camera.tap_switch_source()

        self.camera.tap_capture()
        self.camera.wait_for_video_capturing()

        # Wait for 3 seconds of recording
        self.wait_for_condition(lambda m: self.camera.video_timer >= time.
                                strptime('00:03', '%M:%S'))

        # Stop recording
        self.camera.tap_capture()
        self.camera.wait_for_video_timer_not_visible()

        # Wait for image to be added in to filmstrip
        self.camera.wait_for_filmstrip_visible()

        # Find the new film thumbnail in the film strip
        self.assertTrue(self.camera.is_filmstrip_visible)

        # Check that video saved to sdcard
        videos_after_test = self.get_video_files()
        self.assertEqual(len(videos_after_test), 1)

    def get_video_files(self):
        # camera app doesn't have permissions to access
        # all media files on device, so switch to system app
        self.marionette.switch_to_frame()
        videos = []
        for f in self.data_layer.media_files:
            try:
                match = re.search('(.*[.]3gp)', f)
                videos.append(match.group(1))
            except AttributeError:
                pass
        return videos
class TestPreviewDelete(GaiaTestCase):
    def setUp(self):
        GaiaTestCase.setUp(self)

        # Turn off geolocation prompt
        self.apps.set_permission('Camera', 'geolocation', 'deny')

    def test_capture_and_delete_video(self):
        """
        https://moztrap.mozilla.org/manage/case/3324/
        """
        self.previous_number_of_videos = len(self.data_layer.video_files)

        # launch camera app
        self.camera = Camera(self.marionette)
        self.camera.launch()

        # Switch to video mode
        self.camera.tap_switch_source()

        # Record 10 seconds of video
        self.camera.record_video(10)

        # Check that video saved to SD card
        self.assertEqual(len(self.data_layer.video_files),
                         self.previous_number_of_videos + 1)

        # Tap preview icon to see the video that's just taken
        self.camera.tap_thumbnail()
        self.preview = ImagePreview(self.marionette)
        Wait(self.marionette).until(
            lambda m: self.preview.is_video_play_button_visible is True)

        # Play video, then pause it
        self.preview.tap_video_player_play_button()
        time.sleep(5)
        self.preview.tap_video_player_pause_button()

        # Tape the options icon, and delete the file
        self.preview.delete_file()

        # Check the user is back in camera preview mode, and there is no preview icon anymore
        Wait(self.marionette).until(
            lambda m: self.camera.is_thumbnail_visible is False)

        # Verify the video is deleted now
        self.assertEqual(len(self.data_layer.video_files),
                         self.previous_number_of_videos)
    def test_camera_geolocation_prompt(self):

        camera = Camera(self.marionette)
        camera.launch()

        permission = PermissionDialog(self.marionette)
        self.marionette.switch_to_default_content()
        permission.wait_for_permission_dialog_displayed()

        self.assertEqual(permission.permission_dialog_message,
                         '%s would like to know your location.' % camera.name)

        permission.tap_to_confirm_permission()

        current_permission = self.apps.get_permission('Camera', 'geolocation')
        self.assertEqual(current_permission, 'allow')
Beispiel #21
0
    def camera_video(self):
        # Start camera
        camera_app = Camera(self.marionette)
        camera_app.launch()

        # Swtich to video
        time.sleep(5)
        camera_app.tap_switch_source()

        # Record a video for the specified duration
        camera_app.record_video(self.duration)

        # Sleep a bit and close the app
        time.sleep(5)
        self.close_app()

        # Wait between iterations
        time.sleep(5)
Beispiel #22
0
    def camera_video(self):
        # Start camera
        camera_app = Camera(self.marionette)
        camera_app.launch()

        # Swtich to video
        time.sleep(5)
        camera_app.tap_switch_source()

        # Record a video for the specified duration
        camera_app.record_video(self.duration)

        # Sleep a bit and close the app
        time.sleep(5)
        self.close_app()

        # Wait between iterations
        time.sleep(5)
Beispiel #23
0
class TestCameraMultipleShots(GaiaTestCase):
    def setUp(self):
        GaiaTestCase.setUp(self)

        # Turn off Geolocation prompt
        self.apps.set_permission('Camera', 'geolocation', 'deny')

    def test_capture_multiple_shots(self):
        # https://moztrap.mozilla.org/manage/case/1325/
        self.camera = Camera(self.marionette)
        self.camera.launch()

        # 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)

        # 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)

        # 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 TestCameraMultipleShots(GaiaTestCase):

    def setUp(self):
        GaiaTestCase.setUp(self)

        # Turn off Geolocation prompt
        self.apps.set_permission('Camera', 'geolocation', 'deny')

    def test_capture_multiple_shots(self):
        """https://moztrap.mozilla.org/manage/case/1325/"""

        self.camera = Camera(self.marionette)
        self.camera.launch()

        # 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)

        # 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)

        # 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 TestCamera(GaiaTestCase):
    def setUp(self):
        GaiaTestCase.setUp(self)

        # Turn off geolocation prompt
        self.apps.set_permission('Camera', 'geolocation', 'deny')

    def test_capture_a_photo(self):
        # https://moztrap.mozilla.org/manage/case/1325/

        self.camera = Camera(self.marionette)
        self.camera.launch()

        self.camera.take_photo()

        if not self.camera.is_filmstrip_visible:
            self.camera.tap_to_display_filmstrip()

        image_preview = self.camera.filmstrip_images[0].tap()
        self.assertTrue(image_preview.is_image_preview_visible)
Beispiel #26
0
class TestCameraMultipleShots(GaiaTestCase):
    def setUp(self):
        GaiaTestCase.setUp(self)

        # Turn off Geolocation prompt
        self.apps.set_permission('Camera', 'geolocation', 'deny')

    def test_capture_multiple_shots(self):
        # https://moztrap.mozilla.org/manage/case/1325/
        self.camera = Camera(self.marionette)
        self.camera.launch()

        self.camera.take_photo()

        self.camera.tap_to_display_filmstrip()

        image_preview = self.camera.filmstrip_images[0].tap()
        image_preview.wait_for_media_frame()
        self.assertTrue(image_preview.is_image_preview_visible)

        self.camera = image_preview.tap_camera()

        self.camera.take_photo()

        self.camera.tap_to_display_filmstrip()

        image_preview = self.camera.filmstrip_images[1].tap()
        image_preview.wait_for_media_frame()
        self.assertTrue(image_preview.is_image_preview_visible)

        self.camera = image_preview.tap_camera()

        self.camera.take_photo()

        self.camera.tap_to_display_filmstrip()

        image_preview = self.camera.filmstrip_images[2].tap()
        image_preview.wait_for_media_frame()
        self.assertTrue(image_preview.is_image_preview_visible)

        self.camera = image_preview.tap_camera()
class TestCamera(GaiaTestCase):

    def setUp(self):
        GaiaTestCase.setUp(self)

        # Turn off geolocation prompt
        self.apps.set_permission('Camera', 'geolocation', 'deny')

    def test_capture_a_photo(self):
        # https://moztrap.mozilla.org/manage/case/1325/

        self.camera = Camera(self.marionette)
        self.camera.launch()

        self.camera.take_photo()

        if not self.camera.is_filmstrip_visible:
            self.camera.tap_to_display_filmstrip()

        image_preview = self.camera.filmstrip_images[0].tap()
        self.assertTrue(image_preview.is_image_preview_visible)
Beispiel #28
0
class TestCamera(GaiaTestCase):

    def setUp(self):
        GaiaTestCase.setUp(self)

        # Turn off geolocation prompt
        self.apps.set_permission('Camera', 'geolocation', 'deny')

    def test_capture_a_photo(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()

        # Take a photo
        self.camera.take_photo()

        # 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 + 1, 10)
        self.assertEqual(len(self.data_layer.picture_files), self.previous_number_of_pictures + 1)
class TestPower(GaiaTestCase):
    _camera_frame_locator = (By.CSS_SELECTOR, 'iframe[src*="camera"][src*="/index.html"]')

    def setUp(self):
        print "setUp - start"
        GaiaTestCase.setUp(self)

        print "setUp - about to lock"
        # Make sure the lock screen is up
        self.device.lock()

        # Make sure the screen brightness is full on, with auto turned off
        self.data_layer.set_setting("screen.automatic-brightness", False)
        self.data_layer.set_setting("screen.brightness", 1.0)

        # Make sure USB charging is turned off
        cmd = []
        cmd.append("adb")
        cmd.append("shell")
        cmd.append("echo 0 > /sys/class/power_supply/battery/charging_enabled")
        subprocess.Popen(cmd)

        # Set up the ammeter
        self.ammeterFields = ('current','voltage','time')
        serialPortName = "/dev/ttyACM0"
        self.ammeter = MozillaAmmeter(serialPortName, False)

        # Grab a sample, and calculate the timer offset from ammeter time to wall clock time
        sample = self.ammeter.getSample(self.ammeterFields)
        sampleTimeAfterEpochOffset = time.time()
        firstSampleMsCounter = sample['time'].value
        self.sampleTimeEpochOffset = int(sampleTimeAfterEpochOffset * 1000.0) - firstSampleMsCounter;
        print "setUp - done"


    def getSample(self, sampleLog, samples):
        sample = self.ammeter.getSample(self.ammeterFields)
        if sample is not None:
            sampleObj = {}
            sampleObj['current'] = sample['current'].value
            sampleObj['voltage'] = sample['voltage'].value
            sampleObj['time'] = sample['time'].value + self.sampleTimeEpochOffset
            sampleLog.append(sampleObj)
            samples.append(str(sample['current'].value))
            return sampleObj['current']
        else:
            return None


    def runPowerTestLoopSimple(self, testName, appName, context):
        sampleLog = []
        samples = []
        totalCurrent = 0
        done = False
        stopTime = time.time() + SAMPLE_TIME
        while not done:
            current = self.getSample(sampleLog, samples)
            if current is not None:
                totalCurrent += current
            done = (time.time() > stopTime)

        averageCurrent = int(totalCurrent / len(sampleLog))
        return (sampleLog, samples, averageCurrent)


    def runPowerTestCameraPictures(self, testName, appName, context):
        sampleLog = []
        samples = []
        totalCurrent = 0
        done = False
        stopTime = time.time() + SAMPLE_TIME
        nextPictureTime = time.time() + PICTURE_TIME
        while not done:
            current = self.getSample(sampleLog, samples)
            if current is not None:
                totalCurrent += current
            timeNow = time.time()
            if timeNow > nextPictureTime:
                self.camera.take_photo()
                nextPictureTime = timeNow + PICTURE_TIME
            done = (timeNow > stopTime)

        averageCurrent = int(totalCurrent / len(sampleLog))
        return (sampleLog, samples, averageCurrent)


    def runPowerTest(self, testName, appName, context):
        print ""
        print "Waiting", STABILIZATION_TIME, "seconds to stabilize"
        time.sleep(STABILIZATION_TIME)

        print "Starting power test, gathering results for", SAMPLE_TIME, "seconds"
        if testName == "camera_picture":
            (sampleLog, samples, averageCurrent) = self.runPowerTestCameraPictures(testName, appName, context)
        else:
            (sampleLog, samples, averageCurrent) = self.runPowerTestLoopSimple(testName, appName, context)
        powerProfile = {}
        powerProfile['testTime'] = datetime.now().strftime("%Y%m%d%H%M%S")
        powerProfile['epoch'] = int(time.time() * 1000)
        powerProfile['sampleLog'] = sampleLog
        powerProfile['samples'] = samples
        powerProfile['testName'] = testName
        powerProfile['average'] = averageCurrent
        powerProfile['app'] = appName
        powerProfile['context'] = context + ".gaiamobile.org"
        print "Sample count:", len(sampleLog)
        print "Average current:", averageCurrent, "mA"
        self.writeTestResults(powerProfile)


    def writeTestResults(self, powerProfile):
        summaryName = '%s_%s_summary.log' % (powerProfile['testName'], powerProfile['testTime'])
        summaryFile = open(summaryName, 'w')
        summaryFile.write("name: power.%s.current\n" % powerProfile["testName"])
        summaryFile.write("time: %s\n" % powerProfile["epoch"])
        summaryFile.write("value: %s\n" % powerProfile["average"])
        summaryFile.write("context: %s\n" % powerProfile["context"])
        summaryFile.write("app_name: %s\n" % powerProfile["app"])
        summaryFile.write("\n")
        summaryFile.close()


    def test_unlock_to_homescreen_off(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)
        self.device.turn_screen_off()
        print ""
        print "Running Idle Test (screen off)"
        self.runPowerTest("idle_screen_off", "Homescreen", "verticalhome")


    def test_unlock_to_homescreen_on(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)
        print ""
        print "Running Idle Test (screen on)"
        self.runPowerTest("idle_screen_on", "Homescreen", "verticalhome")


    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()
        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()
        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()
        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")


    def tearDown(self):
        GaiaTestCase.tearDown(self)

        # Disconnect from the ammeter
        self.ammeter.close()

        # Turn USB charging back on
        cmd = []
        cmd.append("adb")
        cmd.append("shell")
        cmd.append("echo 1 > /sys/class/power_supply/battery/charging_enabled")
        subprocess.Popen(cmd)
        time.sleep(1)
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 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)
    def test_settings_media_storage_change(self):
        settings = Settings(self.marionette)
        settings.launch()
        media_storage_settings = settings.open_media_storage()

        # Check that no media is on the device
        self.assertEqual(media_storage_settings.internal_storage.music_size, '0 B')
        self.assertEqual(media_storage_settings.internal_storage.pictures_size, '0 B')
        self.assertEqual(media_storage_settings.internal_storage.movies_size, '0 B')
        self.assertEqual(media_storage_settings.external_storage0.music_size, '0 B')
        self.assertEqual(media_storage_settings.external_storage0.pictures_size, '0 B')
        self.assertEqual(media_storage_settings.external_storage0.movies_size, '0 B')

        self.assertEqual(media_storage_settings.default_media_location, 0)
        media_storage_settings.tap_select_media_location()
        media_storage_settings.confirm_select_media_location()
        media_storage_settings.pick_media_location('SD Card')
        self.assertEqual(media_storage_settings.default_media_location, 1)

        # This is necessary, because otherwise we often fail in take_photo
        # Apparently, the ability of making a photo is very fragile on low memory devices
        self.apps.kill_all()

        camera = Camera(self.marionette)
        camera.launch()
        camera.take_photo()
        self.assertTrue(camera.is_thumbnail_visible)

        gallery = Gallery(self.marionette)
        gallery.launch()
        gallery.wait_for_files_to_load(1)
        self.assertEqual(gallery.gallery_items_number, 1)

        # Close the settings application. We need to kill it to re-init the UI
        self.apps.kill_all()
        settings.launch()
        media_storage_settings = settings.open_media_storage()

        # Internal sdcard storage should still have no contents
        self.assertEqual(media_storage_settings.internal_storage.music_size, '0 B')
        self.assertEqual(media_storage_settings.internal_storage.pictures_size, '0 B')
        self.assertEqual(media_storage_settings.internal_storage.movies_size, '0 B')

        # External sdcard storage should contain some pictures
        self.assertEqual(media_storage_settings.external_storage0.music_size, '0 B')
        self.assertNotEqual(media_storage_settings.external_storage0.pictures_size, '0 B')
        self.assertEqual(media_storage_settings.external_storage0.movies_size, '0 B')

        media_storage_settings.external_storage0.tap_eject()
        media_storage_settings.external_storage0.confirm_eject()

        gallery = Gallery(self.marionette)
        gallery.launch(True)
        self.assertFalse(gallery.are_gallery_items_displayed)

        self.device.stop_b2g()
        self.device.start_b2g()

        gallery = Gallery(self.marionette)
        gallery.launch()
        gallery.wait_for_files_to_load(1)
        self.assertEqual(gallery.gallery_items_number, 1)
Beispiel #33
0
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)
Beispiel #34
0
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)
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)
    def test_settings_media_storage_change(self):
        settings = Settings(self.marionette)
        settings.launch()
        media_storage_settings = settings.open_media_storage()

        # Check that no media is on the device
        self.assertEqual(media_storage_settings.internal_storage.music_size,
                         '0 B')
        self.assertEqual(media_storage_settings.internal_storage.pictures_size,
                         '0 B')
        self.assertEqual(media_storage_settings.internal_storage.movies_size,
                         '0 B')
        self.assertEqual(media_storage_settings.external_storage0.music_size,
                         '0 B')
        self.assertEqual(
            media_storage_settings.external_storage0.pictures_size, '0 B')
        self.assertEqual(media_storage_settings.external_storage0.movies_size,
                         '0 B')

        self.assertEqual(media_storage_settings.default_media_location, 0)
        media_storage_settings.tap_select_media_location()
        media_storage_settings.confirm_select_media_location()
        media_storage_settings.pick_media_location('SD Card')
        self.assertEqual(media_storage_settings.default_media_location, 1)

        # This is necessary, because otherwise we often fail in take_photo
        # Apparently, the ability of making a photo is very fragile on low memory devices
        self.apps.kill_all()

        camera = Camera(self.marionette)
        camera.launch()
        camera.take_photo()
        self.assertTrue(camera.is_thumbnail_visible)

        gallery = Gallery(self.marionette)
        gallery.launch()
        gallery.wait_for_files_to_load(1)
        self.assertEqual(gallery.gallery_items_number, 1)

        # Close the settings application. We need to kill it to re-init the UI
        self.apps.kill_all()
        settings.launch()
        media_storage_settings = settings.open_media_storage()

        # Internal sdcard storage should still have no contents
        self.assertEqual(media_storage_settings.internal_storage.music_size,
                         '0 B')
        self.assertEqual(media_storage_settings.internal_storage.pictures_size,
                         '0 B')
        self.assertEqual(media_storage_settings.internal_storage.movies_size,
                         '0 B')

        # External sdcard storage should contain some pictures
        self.assertEqual(media_storage_settings.external_storage0.music_size,
                         '0 B')
        self.assertNotEqual(
            media_storage_settings.external_storage0.pictures_size, '0 B')
        self.assertEqual(media_storage_settings.external_storage0.movies_size,
                         '0 B')

        media_storage_settings.external_storage0.tap_eject()
        media_storage_settings.external_storage0.confirm_eject()

        gallery = Gallery(self.marionette)
        gallery.launch(True)
        self.assertFalse(gallery.are_gallery_items_displayed)

        self.device.stop_b2g()
        self.device.start_b2g()

        gallery = Gallery(self.marionette)
        gallery.launch()
        gallery.wait_for_files_to_load(1)
        self.assertEqual(gallery.gallery_items_number, 1)