Example #1
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)
Example #2
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_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)
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)
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()

        # 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)
Example #6
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.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)
Example #7
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)
Example #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)
Example #9
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)
Example #10
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)
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)
Example #12
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()
    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)
Example #14
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)
    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)