Пример #1
0
class TestGallery(GaiaTestCase):
    def setUp(self):
        GaiaTestCase.setUp(self)

        self.apps.set_permission('Camera', 'geolocation', 'deny')

        self.push_resource('IMG_0001.jpg')

    def test_gallery_switch_to_camera(self):
        """
        https://moztrap.mozilla.org/manage/case/3620/
        """

        gallery = Gallery(self.marionette)
        gallery.launch()
        gallery.wait_for_files_to_load(1)

        # Enter the single photo view
        image = gallery.tap_first_gallery_item()
        self.assertIsNotNone(image.current_image_source)

        # Check that there are 5 options displayed beneath the picture
        self.assertEqual(len(image.photo_toolbar_options), 5)

        # Tap on the Camera button to go to the Camera app
        self.previous_number_of_pictures = len(self.data_layer.picture_files)
        self.camera = image.tap_switch_to_camera()

        # Take a picture and verify the picture is taken
        self.camera.take_photo()

        # Check that picture saved to SD card
        Wait(
            self.marionette).until(lambda m: len(self.data_layer.picture_files)
                                   == self.previous_number_of_pictures + 1)

        # Open Preview, tap the option icon and select Gallery app
        self.camera.tap_thumbnail()
        self.preview = ImagePreview(self.marionette)
        self.preview.tap_switch_to_gallery()

        # Verify the Gallery app is now open, with one more file
        gallery.wait_for_files_to_load(2)
        new_image = gallery.tap_first_gallery_item()
        # verify the new first image is not same as the previous (and only) first image,
        # meaning that the new image is shown on the top of the gallery app grid
        self.assertFalse(
            new_image.current_image_source is image.current_image_source)
Пример #2
0
class TestGallery(GaiaTestCase):
    def setUp(self):
        GaiaTestCase.setUp(self)

        self.apps.set_permission("Camera", "geolocation", "deny")

        self.push_resource("IMG_0001.jpg")

    def test_gallery_switch_to_camera(self):
        """
        https://moztrap.mozilla.org/manage/case/3620/
        """

        gallery = Gallery(self.marionette)
        gallery.launch()
        gallery.wait_for_files_to_load(1)

        # Enter the single photo view
        image = gallery.tap_first_gallery_item()
        self.assertIsNotNone(image.current_image_source)

        # Check that there are 5 options displayed beneath the picture
        self.assertEqual(len(image.photo_toolbar_options), 5)

        # Tap on the Camera button to go to the Camera app
        self.previous_number_of_pictures = len(self.data_layer.picture_files)
        self.camera = image.tap_switch_to_camera()

        # Take a picture and verify the picture is taken
        self.camera.take_photo()

        # Check that picture saved to SD card
        Wait(self.marionette).until(
            lambda m: len(self.data_layer.picture_files) == self.previous_number_of_pictures + 1
        )

        # Open Preview, tap the option icon and select Gallery app
        self.camera.tap_thumbnail()
        self.preview = ImagePreview(self.marionette)
        self.preview.tap_switch_to_gallery()

        # Verify the Gallery app is now open, with one more file
        gallery.wait_for_files_to_load(2)
        new_image = gallery.tap_first_gallery_item()
        # verify the new first image is not same as the previous (and only) first image,
        # meaning that the new image is shown on the top of the gallery app grid
        self.assertFalse(new_image.current_image_source is image.current_image_source)
    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_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)