def test_gallery_edit_photo(self):
        gallery = Gallery(self.marionette)
        gallery.launch()
        gallery.wait_for_files_to_load(1)

        self.assertTrue(gallery.gallery_items_number > 0)

        image = gallery.tap_first_gallery_item()

        # Tap on Edit button.
        edit_image = image.tap_edit_button()

        # Tap on Effects button.
        edit_image.tap_edit_effects_button()

        # Change effects.
        [effect.tap() for effect in edit_image.effects]

        # TBD. Verify the photo is changed.

        gallery = edit_image.tap_edit_save_button()
        gallery.wait_for_files_to_load(2)

        # Verify new Photo is created
        self.assertEqual(2, gallery.gallery_items_number)
Beispiel #2
0
    def test_gallery_open_valid_image_file(self, filename, width, height):

        self.push_resource(filename)

        gallery = Gallery(self.marionette)
        gallery.launch()
        gallery.wait_for_files_to_load(1)  # all and only valid files are showing previews
        self.assertTrue(gallery.gallery_items_number == 1)

        # make sure the file opens
        image = gallery.tap_first_gallery_item()

        # verify the blob is displayed
        self.assertTrue("blob:app://gallery.gaiamobile.org/" in image.current_image_source)

        # collect the initial image view dimension for comparison later
        initial_width = image.current_image_size_width
        initial_height = image.current_image_size_height

        image.double_tap_image()  # displays the image in its original resolution

        # for big images exceeding the phone resolution, the gallery app only doubles the view size
        # from the initial view; it does not render the entire image fully
        if width <= (2 * initial_width) and height <= (2 * initial_height):
            Wait(self.marionette).until(lambda m: image.current_image_size_width == width)
            Wait(self.marionette).until(lambda m: image.current_image_size_height == height)
        else:
            Wait(self.marionette).until(lambda m: image.current_image_size_width == 2 * initial_width)
            Wait(self.marionette).until(lambda m: image.current_image_size_height == 2 * initial_height)
    def test_gallery_crop_photo(self):
        gallery = Gallery(self.marionette)
        gallery.launch()
        gallery.wait_for_files_to_load(1)

        initial_image_size = gallery.thumbnails[0].absolute_image_size
        image = gallery.tap_first_gallery_item()

        # Tap on Edit button.
        edit_image = image.tap_edit_button()
        edit_image.tap_edit_crop_button()
        # portrait crop is 2:3 and will retain the image's height
        edit_image.tap_portrait_crop()
        edit_image.tap_edit_tool_apply_button()

        image = edit_image.tap_edit_save_button()
        gallery = image.go_back()
        gallery.wait_for_files_to_load(2)

        # get the absolute image for the new first image
        cropped_image_size = gallery.thumbnails[0].absolute_image_size

        # As we have chosen portrait crop, height will remain the same, width should change
        self.assertEqual(cropped_image_size['height'], initial_image_size['height'])
        self.assertLess(cropped_image_size['width'], initial_image_size['width'])
    def test_gallery_open_valid_image_file(self, filename, width, height):

        self.push_resource(filename)

        gallery = Gallery(self.marionette)
        gallery.launch()
        gallery.wait_for_files_to_load(1)  # all and only valid files are showing previews
        self.assertTrue(gallery.gallery_items_number == 1)

        # make sure the file opens
        image = gallery.tap_first_gallery_item()

        # verify the blob is displayed
        self.assertTrue("blob:app://gallery.gaiamobile.org/" in image.current_image_source)

        # collect the initial image view dimension for comparison later
        initial_width = image.current_image_size_width
        initial_height = image.current_image_size_height

        image.double_tap_image()  # displays the image in its original resolution

        # for big images exceeding the phone resolution, the gallery app only doubles the view size
        # from the initial view; it does not render the entire image fully
        if width <= (2 * initial_width) and height <= (2 * initial_height):
            Wait(self.marionette).until(lambda m: image.current_image_size_width == width)
            Wait(self.marionette).until(lambda m: image.current_image_size_height == height)
        else:
            Wait(self.marionette).until(lambda m: image.current_image_size_width == 2 * initial_width)
            Wait(self.marionette).until(lambda m: image.current_image_size_height == 2 * initial_height)
    def test_gallery_full_screen_image_flicks(self):
        """https://moztrap.mozilla.org/manage/case/1326/"""

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

        self.assertEqual(gallery.gallery_items_number, self.image_count)

        # Tap first image to open full screen view.
        image = gallery.tap_first_gallery_item()
        self.assertIsNotNone(image.current_image_source)
        self.assertTrue(image.is_photo_toolbar_displayed)
        previous_image_source = image.current_image_source

        # Check the next flicks.
        for i in range(1, gallery.gallery_items_number):
            image.flick_to_next_image()
            self.assertIsNotNone(image.current_image_source)
            self.assertNotEqual(image.current_image_source, previous_image_source)
            self.assertTrue(image.is_photo_toolbar_displayed)
            previous_image_source = image.current_image_source

        # Check the prev flick.
        for i in range(gallery.gallery_items_number, 1, -1):
            image.flick_to_previous_image()
            self.assertIsNotNone(image.current_image_source)
            self.assertNotEqual(image.current_image_source, previous_image_source)
            self.assertTrue(image.is_photo_toolbar_displayed)
            previous_image_source = image.current_image_source
    def test_gallery_view(self):
        # https://moztrap.mozilla.org/manage/case/1326/

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

        image = gallery.tap_first_gallery_item()
        self.assertIsNotNone(image.current_image_source)

        #  Verify that the screen orientation is in portrait mode
        self.assertTrue(image.is_photo_toolbar_displayed)
        self.assertEqual('portrait-primary', self.screen_orientation)
        self.assertEqual(self.screen_width, image.photo_toolbar_width)

        #  Change the screen orientation to landscape mode and verify that the screen is in landscape mode
        self.change_orientation('landscape-primary')
        self.assertTrue(image.is_photo_toolbar_displayed)
        self.assertEqual('landscape-primary', self.screen_orientation)
        self.assertEqual(self.screen_width, image.photo_toolbar_width)

        #  Unlock the screen so that it can be changed back to portrait mode
        self.marionette.execute_script('window.screen.mozUnlockRotation')

        #  Change the screen orientation back to portrait-primary and verify the screen is in portrait mode
        self.change_orientation('portrait-primary')
        self.assertTrue(image.is_photo_toolbar_displayed)
        self.assertEqual('portrait-primary', self.screen_orientation)
        self.assertEqual(self.screen_width, image.photo_toolbar_width)
Beispiel #7
0
    def test_gallery_crop_photo(self):
        gallery = Gallery(self.marionette)
        gallery.launch()
        gallery.wait_for_files_to_load(1)

        initial_image_size = gallery.thumbnails[0].absolute_image_size
        image = gallery.tap_first_gallery_item()

        # Tap on Edit button.
        edit_image = image.tap_edit_button()
        edit_image.tap_edit_crop_button()
        # portrait crop is 2:3 and will retain the image's height
        edit_image.tap_portrait_crop()

        gallery = edit_image.tap_edit_save_button()
        gallery.wait_for_files_to_load(2)

        # get the absolute image for the new first image
        cropped_image_size = gallery.thumbnails[0].absolute_image_size

        # As we have chosen portrait crop, height will remain the same, width should change
        self.assertEqual(cropped_image_size['height'],
                         initial_image_size['height'])
        self.assertLess(cropped_image_size['width'],
                        initial_image_size['width'])
Beispiel #8
0
    def test_gallery_crop_photo(self):
        gallery = Gallery(self.marionette)
        gallery.launch()
        gallery.wait_for_files_to_load(1)

        image = gallery.tap_first_gallery_item()
        initial_scale = image.current_scale

        # Tap on Edit button.
        edit_image = image.tap_edit_button()
        edit_image.tap_edit_crop_button()
        edit_image.tap_portrait_crop()

        gallery = edit_image.tap_edit_save_button()

        gallery.wait_for_files_to_load(2)

        # Verify new Photo is created
        self.assertEqual(2, gallery.gallery_items_number)

        image1 = gallery.tap_first_gallery_item()

        # The logic is: scale is inversely proportional with the size(witdh*height) of the image
        # if initial_scale < image1.current_scale then image > image1
        self.assertLess(initial_scale, image1.current_scale)
 def tap_confirm_deletion_button(self):
     self.marionette.find_element(*self._confirm_delete_locator).tap()
     self.wait_for_element_not_displayed(*self._confirm_delete_locator)
     from gaiatest.apps.gallery.app import Gallery
     gallery = Gallery(self.marionette)
     gallery.launch()
     return gallery
Beispiel #10
0
    def test_gallery_view(self):
        # https://moztrap.mozilla.org/manage/case/1326/

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

        image = gallery.tap_first_gallery_item()
        self.assertIsNotNone(image.current_image_source)

        #  Verify that the screen orientation is in portrait mode
        self.assertTrue(image.is_photo_toolbar_displayed)
        self.assertEqual('portrait-primary', self.screen_orientation)
        self.assertEqual(self.screen_width, image.photo_toolbar_width)

        #  Change the screen orientation to landscape mode and verify that the screen is in landscape mode
        self.change_orientation('landscape-primary')
        self.assertTrue(image.is_photo_toolbar_displayed)
        self.assertEqual('landscape-primary', self.screen_orientation)
        self.assertEqual(self.screen_width, image.photo_toolbar_width)

        #  Unlock the screen so that it can be changed back to portrait mode
        self.marionette.execute_script('window.screen.mozUnlockRotation')

        #  Change the screen orientation back to portrait-primary and verify the screen is in portrait mode
        self.change_orientation('portrait-primary')
        self.assertTrue(image.is_photo_toolbar_displayed)
        self.assertEqual('portrait-primary', self.screen_orientation)
        self.assertEqual(self.screen_width, image.photo_toolbar_width)
Beispiel #11
0
class TestEnduranceGalleryCamera(GaiaEnduranceTestCase):

    def setUp(self):
        GaiaEnduranceTestCase.setUp(self)

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

        # add photo to storage
        self.push_resource('IMG_0001.jpg')

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

    def test_endurance_gallery_camera(self):
        self.drive(test=self.gallery_camera, app='gallery')

    def gallery_camera(self):
        # Test requested per bug 851626:
        # 1. open the Gallery app
        # 2. when the UI/Camera button appears, tap it to switch to the camera
        # 3. when the UI/Gallery button appears, tap it to switch back to the gallery
        # 4. repeat steps 2 and 3 until *crash*
        time.sleep(3)

        # From gallery app, switch to camera app
        self.camera = self.gallery.switch_to_camera()
        time.sleep(3)

        # From camera app, switch back to gallery again
        self.gallery = self.camera.tap_switch_to_gallery()
        self.gallery.wait_for_files_to_load(1)
        self.assertTrue(self.gallery.are_gallery_items_displayed)
Beispiel #12
0
    def test_gallery_full_screen_image_flicks(self):
        """https://moztrap.mozilla.org/manage/case/1326/"""

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

        self.assertEqual(gallery.gallery_items_number, self.image_count)

        # Tap first image to open full screen view.
        image = gallery.tap_first_gallery_item()
        self.assertIsNotNone(image.current_image_source)
        self.assertTrue(image.is_photo_toolbar_displayed)
        previous_image_source = image.current_image_source

        # Check the next flicks.
        for i in range(1, gallery.gallery_items_number):
            image.flick_to_next_image()
            self.assertIsNotNone(image.current_image_source)
            self.assertNotEqual(image.current_image_source, previous_image_source)
            self.assertTrue(image.is_photo_toolbar_displayed)
            previous_image_source = image.current_image_source

        # Check the prev flick.
        for i in range(gallery.gallery_items_number, 1, -1):
            image.flick_to_previous_image()
            self.assertIsNotNone(image.current_image_source)
            self.assertNotEqual(image.current_image_source, previous_image_source)
            self.assertTrue(image.is_photo_toolbar_displayed)
            previous_image_source = image.current_image_source
    def test_gallery_frame_visibility(self):
        gallery = Gallery(self.marionette)
        gallery.launch()
        gallery.wait_for_files_to_load(self.image_count)

        self.assertEqual(gallery.gallery_items_number, self.image_count)

        # Tap first image to open full screen view.
        image = gallery.tap_first_gallery_item()
        previous_frame = image.current_image_frame
        # Check that initial image is visible.
        self.assertTrue(self.accessibility.is_visible(previous_frame))

        # Check the next flicks.
        for i in range(1, gallery.gallery_items_number):
            image.flick_to_next_image()
            # Check that current image is visible.
            self.assertTrue(
                self.accessibility.is_visible(image.current_image_frame))
            # Check that previous image is hidden.
            self.assertTrue(self.accessibility.is_hidden(previous_frame))
            previous_frame = image.current_image_frame

        # Check the prev flick.
        for i in range(gallery.gallery_items_number, 1, -1):
            image.flick_to_previous_image()
            # Check that current image is visible.
            self.assertTrue(
                self.accessibility.is_visible(image.current_image_frame))
            # Check that previous image is hidden.
            self.assertTrue(self.accessibility.is_hidden(previous_frame))
            previous_frame = image.current_image_frame
class TestCardsViewTwoApps(GaiaTestCase):

    def setUp(self):
        GaiaTestCase.setUp(self)
        self.cards_view = CardsView(self.marionette)

        self.clock = Clock(self.marionette)
        self.clock.launch()
        self.gallery = Gallery(self.marionette)
        self.gallery.launch(empty=True)

    def test_kill_app_from_cards_view(self):
        """https://moztrap.mozilla.org/manage/case/1917/"""

        # Pull up the cards view
        self.device.hold_home_button()
        self.cards_view.wait_for_cards_view()

        # Wait for first app ready
        self.cards_view.cards[1].wait_for_centered()
        self.assertIn(self.cards_view.cards[1].manifest_url, self.gallery.manifest_url)

        # Close the current apps from the cards view
        self.cards_view.cards[1].close()
        self.cards_view.cards[0].close()

        # If successfully killed, the apps should no longer appear in the cards view and the "No recent apps" message should be displayed
        self.assertEqual(len(self.cards_view.cards), 0, 'Should have no cards to display')
Beispiel #15
0
 def tap_confirm_deletion_button(self):
     self.marionette.find_element(*self._confirm_delete_locator).tap()
     self.wait_for_element_not_displayed(*self._confirm_delete_locator)
     from gaiatest.apps.gallery.app import Gallery
     gallery = Gallery(self.marionette)
     gallery.launch()
     return gallery
    def test_gallery_frame_visibility(self):
        gallery = Gallery(self.marionette)
        gallery.launch()
        gallery.wait_for_files_to_load(self.image_count)

        self.assertEqual(gallery.gallery_items_number, self.image_count)

        # Tap first image to open full screen view.
        image = gallery.tap_first_gallery_item()
        previous_frame = image.current_image_frame
        # Check that initial image is visible.
        self.assertTrue(self.accessibility.is_visible(previous_frame))

        # Check the next flicks.
        for i in range(1, gallery.gallery_items_number):
            image.flick_to_next_image()
            # Check that current image is visible.
            self.assertTrue(self.accessibility.is_visible(image.current_image_frame))
            # Check that previous image is hidden.
            self.assertTrue(self.accessibility.is_hidden(previous_frame))
            previous_frame = image.current_image_frame

        # Check the prev flick.
        for i in range(gallery.gallery_items_number, 1, -1):
            image.flick_to_previous_image()
            # Check that current image is visible.
            self.assertTrue(self.accessibility.is_visible(image.current_image_frame))
            # Check that previous image is hidden.
            self.assertTrue(self.accessibility.is_hidden(previous_frame))
            previous_frame = image.current_image_frame
    def orientation_zoom_check(self):

        self.push_resource(self.images, count=self.image_count)

        self.take_screenshot()
        # flick image, change orientation, pinch zoom, change orientation
        # launch gallery, load image.
        gallery = Gallery(self.marionette)
        gallery.launch()
        gallery.wait_for_files_to_load(self.image_count)

        self.assertEqual(gallery.gallery_items_number, self.image_count)

        # Tap first image to open full screen view.
        image = gallery.tap_first_gallery_item()
        self.assertIsNotNone(image.current_image_source)
        self.assertTrue(image.is_photo_toolbar_displayed)

        # scroll back and forth in different display mode
        self.change_orientation('landscape-primary')
        self.take_screenshot()
        GaiaImageCompareTestCase.scroll(self.marionette, 'right',
                                        400, locator=image._current_image_locator)

        self.change_orientation('portrait-primary')
        self.take_screenshot()
        GaiaImageCompareTestCase.scroll(self.marionette, 'left',
                                        400, locator=image._current_image_locator)

        # flip A LOT
        for x in range(0, 4):
            self.change_orientation('landscape-primary')
            self.change_orientation('portrait-primary')
        self.take_screenshot()

        # do pinch zoom while flipping the phone
        GaiaImageCompareTestCase.pinch(self.marionette, image._current_frame_locator, 'in', 20)

        self.take_screenshot()
        GaiaImageCompareTestCase.scroll(self.marionette, 'right',
                                        300, locator=image._current_image_locator)
        self.take_screenshot()
        self.change_orientation('landscape-primary')
        GaiaImageCompareTestCase.pinch(self.marionette, image._current_frame_locator, 'out', 50)
        self.take_screenshot()
        self.change_orientation('portrait-primary')

        image.double_tap_image()
        self.take_screenshot(prewait=3) #takes time for zoom-in action to complete

        # go back and forth with flicking then exit gallery app
        GaiaImageCompareTestCase.scroll(self.marionette, 'right',
                                        150, locator=image._current_frame_locator)

        self.take_screenshot()
        GaiaImageCompareTestCase.scroll(self.marionette, 'left',
                                        150, locator=image._current_frame_locator)
        self.take_screenshot()
class TestEnduranceGalleryFlick(GaiaEnduranceTestCase):

    images = 'IMG_0001.jpg'
    image_count = 10

    def setUp(self):
        GaiaEnduranceTestCase.setUp(self)

        # Add photos to storage.
        self.push_resource(self.images, count=self.image_count)

        # Start gallery app
        self.gallery = Gallery(self.marionette)
        self.gallery.launch()
        self.gallery.wait_for_files_to_load(self.image_count)
        self.assertTrue(self.gallery.gallery_items_number >= self.image_count)

        # Tap first image to open full screen view.
        self.image = self.gallery.tap_first_gallery_item()

    def test_endurance_gallery_flick(self):
        self.drive(test=self.gallery_flick, app='gallery')

    def gallery_flick(self):
        # Flick through images in gallery, and back again
        # Original code taken from existing webqa test (test_gallery_flick.py, thanks!)
        previous_image_source = None

        # Check the next flicks.
        for i in range(self.gallery.gallery_items_number):
            self.assertIsNotNone(self.image.current_image_source)
            self.assertNotEqual(self.image.current_image_source,
                                previous_image_source)
            self.assertTrue(self.image.is_photo_toolbar_displayed)
            previous_image_source = self.image.current_image_source
            self.image.flick_to_next_image()

        self.assertIsNotNone(self.image.current_image_source)
        self.assertEqual(self.image.current_image_source,
                         previous_image_source)
        self.assertTrue(self.image.is_photo_toolbar_displayed)

        # Check the prev flick.
        for i in range(self.gallery.gallery_items_number - 1):
            self.image.flick_to_previous_image()
            self.assertIsNotNone(self.image.current_image_source)
            self.assertNotEqual(self.image.current_image_source,
                                previous_image_source)
            self.assertTrue(self.image.is_photo_toolbar_displayed)
            previous_image_source = self.image.current_image_source

        # Try to flick prev image (No image should be available)
        self.image.flick_to_previous_image()
        self.assertIsNotNone(self.image.current_image_source)
        self.assertEqual(self.image.current_image_source,
                         previous_image_source)
        self.assertTrue(self.image.is_photo_toolbar_displayed)
    def test_gallery_handle_load_corrupt_file(self, filename):
        self.push_resource(filename)

        gallery = Gallery(self.marionette)
        gallery.launch(True)
        self.assertTrue(len(self.data_layer.picture_files) == 1)

        # image will not display in the gallery app
        Wait(self.marionette).until(lambda m: gallery.empty_gallery_text == 'Use the Camera app to get started.')
        self.assertTrue(gallery.gallery_items_number == 0)
        self.assertEqual(gallery.empty_gallery_title, 'No photos or videos')
Beispiel #20
0
    def test_empty_gallery(self):
        """https://moztrap.mozilla.org/manage/case/4003/"""
        # Requires there to be no photos on SDCard which is the default

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

        self.wait_for_condition(lambda m: gallery.empty_gallery_text == 'Use the Camera app to get started.')

        # Verify empty gallery title
        self.assertEqual(gallery.empty_gallery_title, 'No photos or videos')
Beispiel #21
0
    def test_gallery_view(self):
        # https://moztrap.mozilla.org/manage/case/1326/

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

        image = gallery.tap_first_gallery_item()

        self.assertIsNotNone(image.current_image_source)
        self.assertTrue(image.is_photo_toolbar_displayed)
    def test_empty_gallery(self):
        """https://moztrap.mozilla.org/manage/case/4003/"""
        # Requires there to be no photos on SDCard which is the default

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

        self.wait_for_condition(lambda m: gallery.empty_gallery_text == 'Use the Camera app to get started.')

        # Verify empty gallery title
        self.assertEqual(gallery.empty_gallery_title, 'No photos or videos')
Beispiel #23
0
    def test_gallery_view(self):
        # https://moztrap.mozilla.org/manage/case/1326/

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

        image = gallery.tap_first_gallery_item()

        self.assertIsNotNone(image.current_image_source)
        self.assertTrue(image.is_photo_toolbar_displayed)
Beispiel #24
0
    def test_gallery_handle_load_corrupt_file(self, filename):
        self.push_resource(filename)

        gallery = Gallery(self.marionette)
        gallery.launch(True)
        self.assertTrue(len(self.data_layer.picture_files) == 1)

        # image will not display in the gallery app
        Wait(self.marionette).until(lambda m: gallery.empty_gallery_text ==
                                    'Use the Camera app to get started.')
        self.assertTrue(gallery.gallery_items_number == 0)
        self.assertEqual(gallery.empty_gallery_title, 'No photos or videos')
    def test_empty_gallery(self):
        # https://moztrap.mozilla.org/manage/case/4003/
        # Requires there to be no photos on SDCard which is the default

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

        # Verify empty gallery title
        self.assertEqual(gallery.empty_gallery_title, 'No photos or videos')

        # Verify empty gallery text
        self.assertEqual(gallery.empty_gallery_text, 'Use the Camera app to get started.')
Beispiel #26
0
    def orientation_zoom_check(self):

        self.push_resource(self.images, count=self.image_count)

        self.take_screenshot()
        # flick image, change orientation, pinch zoom, change orientation
        # launch gallery, load image.
        gallery = Gallery(self.marionette)
        gallery.launch()
        gallery.wait_for_files_to_load(self.image_count)

        self.assertEqual(gallery.gallery_items_number, self.image_count)

        # Tap first image to open full screen view.
        image = gallery.tap_first_gallery_item()
        self.assertIsNotNone(image.current_image_source)
        self.assertTrue(image.is_photo_toolbar_displayed)

        # scroll back and forth in different display mode
        self.change_orientation('landscape-primary')
        self.take_screenshot()
        self.scroll(image._current_image_locator, 'left', 400)
        self.change_orientation('portrait-primary')
        self.take_screenshot()
        self.scroll(image._current_image_locator, 'right', 400)

        # flip A LOT
        for x in range(0, 4):
            self.change_orientation('landscape-primary')
            self.change_orientation('portrait-primary')
        self.take_screenshot()

        # do pinch zoom while filpping the phone
        self.pinch(image._current_frame_locator, 'in', 20)
        self.take_screenshot()
        self.scroll(image._current_frame_locator, 'left', 300)
        self.take_screenshot()
        self.change_orientation('landscape-primary')
        self.pinch(image._current_frame_locator, 'out', 50)
        self.take_screenshot()
        self.change_orientation('portrait-primary')

        image.double_tap_image()
        self.take_screenshot()

        # go back and forth with flicking then exit gallery app
        self.scroll(image._current_frame_locator, 'left', 150)
        self.take_screenshot()
        self.scroll(image._current_frame_locator, 'right', 150)
        self.take_screenshot()
        self.apps.kill(gallery.app)
        time.sleep(2)
        self.take_screenshot()
class TestEnduranceGalleryFlick(GaiaEnduranceTestCase):

    images = 'IMG_0001.jpg'
    image_count = 10

    def setUp(self):
        GaiaEnduranceTestCase.setUp(self)

        # Add photos to storage.
        self.push_resource(self.images, count=self.image_count)

        # Start gallery app
        self.gallery = Gallery(self.marionette)
        self.gallery.launch()
        self.gallery.wait_for_files_to_load(self.image_count)
        self.assertTrue(self.gallery.gallery_items_number >= self.image_count)

        # Tap first image to open full screen view.
        self.image = self.gallery.tap_first_gallery_item()

    def test_endurance_gallery_flick(self):
        self.drive(test=self.gallery_flick, app='gallery')

    def gallery_flick(self):
        # Flick through images in gallery, and back again
        # Original code taken from existing webqa test (test_gallery_flick.py, thanks!)
        previous_image_source = None

        # Check the next flicks.
        for i in range(self.gallery.gallery_items_number):
            self.assertIsNotNone(self.image.current_image_source)
            self.assertNotEqual(self.image.current_image_source, previous_image_source)
            self.assertTrue(self.image.is_photo_toolbar_displayed)
            previous_image_source = self.image.current_image_source
            self.image.flick_to_next_image()

        self.assertIsNotNone(self.image.current_image_source)
        self.assertEqual(self.image.current_image_source, previous_image_source)
        self.assertTrue(self.image.is_photo_toolbar_displayed)

        # Check the prev flick.
        for i in range(self.gallery.gallery_items_number - 1):
            self.image.flick_to_previous_image()
            self.assertIsNotNone(self.image.current_image_source)
            self.assertNotEqual(self.image.current_image_source, previous_image_source)
            self.assertTrue(self.image.is_photo_toolbar_displayed)
            previous_image_source = self.image.current_image_source

        # Try to flick prev image (No image should be available)
        self.image.flick_to_previous_image()
        self.assertIsNotNone(self.image.current_image_source)
        self.assertEqual(self.image.current_image_source, previous_image_source)
        self.assertTrue(self.image.is_photo_toolbar_displayed)
    def test_gallery_delete_image(self):
        gallery = Gallery(self.marionette)
        gallery.launch()
        gallery.wait_for_files_to_load(3)

        gallery_multi_view = gallery.switch_to_multiple_selection_view()
        gallery_multi_view.select_nth_picture(0)
        gallery_multi_view.select_nth_picture(1)
        gallery_multi_view.select_nth_picture(2)

        # Tap the delete button and confirm by default
        gallery_multi_view.tap_delete_button()
        gallery.wait_for_thumbnail_view_to_load()

        # Verify empty gallery title.
        Wait(self.marionette).until(lambda m: gallery.empty_gallery_title == 'No photos or videos')
    def test_gallery_view(self):
        """ Test return to tiles view
        Load gallery.
        Tap the image and wait for it to load.
        Tap the tile view toolbar icon.
        Assert that the app returns to the main/tile view screen.
        """
        gallery = Gallery(self.marionette)
        gallery.launch()
        gallery.wait_for_files_to_load(1)

        image = gallery.tap_first_gallery_item()
        self.assertTrue(image.is_photo_toolbar_displayed)

        gallery = image.tap_tile_view_button()
        self.assertTrue(gallery.are_gallery_items_displayed)
Beispiel #30
0
    def test_gallery_view(self):
        """ Test return to tiles view
        Load gallery.
        Tap the image and wait for it to load.
        Tap the tile view toolbar icon.
        Assert that the app returns to the main/tile view screen.
        """
        gallery = Gallery(self.marionette)
        gallery.launch()
        gallery.wait_for_files_to_load(1)

        image = gallery.tap_first_gallery_item()
        self.assertTrue(image.is_photo_toolbar_displayed)

        gallery = image.tap_tile_view_button()
        self.assertTrue(gallery.are_gallery_items_displayed)
    def test_gallery_delete_image(self):
        gallery = Gallery(self.marionette)
        gallery.launch()
        gallery.wait_for_files_to_load(1)

        # Tap first image to open full screen view.
        image = gallery.tap_first_gallery_item()

        # Tap the delete button from the fullscreen toolbar.
        image.tap_delete_button()

        # Tap the confirm delete button.
        image.tap_confirm_deletion_button()
        self.wait_for_condition(lambda m: gallery.empty_gallery_text == 'Use the Camera app to get started.')

        # Verify empty gallery title.
        self.assertEqual(gallery.empty_gallery_title, 'No photos or videos')
    def test_gallery_handle_load_corrupt_file(self, filename):
        self.push_resource(filename)

        gallery = Gallery(self.marionette)
        gallery.launch(filename != "image_formats/x07.jpg")

        self.assertTrue(len(self.data_layer.picture_files) == 1)

        # loaded image will not display in the gallery app, except in case of corrupt_jpg
        if filename == "image_formats/x07.jpg":
            self.assertTrue(gallery.gallery_items_number == 1)
            # make sure the file opens without crash
            image = gallery.tap_first_gallery_item()
            self.assertTrue("blob:app://gallery.gaiamobile.org/" in image.current_image_source)
        else:
            Wait(self.marionette).until(lambda m: gallery.empty_gallery_text == 'Use the Camera app to get started.')
            self.assertTrue(gallery.gallery_items_number == 0)
            self.assertEqual(gallery.empty_gallery_title, 'No photos or videos')
Beispiel #33
0
    def test_gallery_delete_image(self):
        gallery = Gallery(self.marionette)
        gallery.launch()
        gallery.wait_for_files_to_load(1)

        # Tap first image to open full screen view.
        image = gallery.tap_first_gallery_item()

        # Tap the delete button from the fullscreen toolbar.
        image.tap_delete_button()

        # Tap the confirm delete button.
        image.tap_confirm_deletion_button()
        self.wait_for_condition(lambda m: gallery.empty_gallery_text ==
                                'Use the Camera app to get started.')

        # Verify empty gallery title.
        self.assertEqual(gallery.empty_gallery_title, 'No photos or videos')
Beispiel #34
0
    def test_gallery_view(self):
        """
        https://moztrap.mozilla.org/manage/case/14645/
        """

        screen_width = System(self.marionette).screen_width
        screen_height = System(self.marionette).screen_height_without_software_home_button

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

        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)

        #  Verify that the screen orientation is in portrait mode
        self.assertTrue(image.is_photo_toolbar_displayed)
        self.assertEqual('portrait-primary', self.device.screen_orientation)
        self.assertEqual(screen_width, image.photo_toolbar_width)

        #  Change the screen orientation to landscape mode and verify that the screen is in landscape mode
        self.device.change_orientation('landscape-primary')

        # Here we sleep only to give visual feedback when observing the test run
        time.sleep(1)
        self.assertTrue(image.is_photo_toolbar_displayed)
        self.assertEqual('landscape-primary', self.device.screen_orientation)
        self.assertEqual(screen_height, image.photo_toolbar_width)

        #  Unlock the screen so that it can be changed back to portrait mode
        self.marionette.execute_script('window.screen.mozUnlockOrientation()')

        #  Change the screen orientation back to portrait-primary and verify the screen is in portrait mode
        self.device.change_orientation('portrait-primary')

        # Here we sleep only to give visual feedback when observing the test run
        time.sleep(1)
        self.assertTrue(image.is_photo_toolbar_displayed)
        self.assertEqual('portrait-primary', self.device.screen_orientation)
        self.assertEqual(screen_width, image.photo_toolbar_width)
Beispiel #35
0
    def test_gallery_delete_image(self):
        """
        https://moztrap.mozilla.org/manage/case/1533/
        """

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

        gallery_multi_view = gallery.switch_to_multiple_selection_view()
        gallery_multi_view.select_nth_picture(0)
        gallery_multi_view.select_nth_picture(1)
        gallery_multi_view.select_nth_picture(2)

        # Tap the delete button and confirm by default
        gallery_multi_view.tap_delete_button()
        gallery.wait_for_overlay_to_show()

        self.assertEqual(gallery.empty_gallery_title, 'No photos or videos')
    def test_gallery_delete_image(self):
        """
        https://moztrap.mozilla.org/manage/case/1533/
        """

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

        gallery_multi_view = gallery.switch_to_multiple_selection_view()
        gallery_multi_view.select_nth_picture(0)
        gallery_multi_view.select_nth_picture(1)
        gallery_multi_view.select_nth_picture(2)

        # Tap the delete button and confirm by default
        gallery_multi_view.tap_delete_button()
        gallery.wait_for_overlay_to_show()

        self.assertEqual(gallery.empty_gallery_title, 'No photos or videos')
    def test_gallery_click_share_button(self):
        gallery = Gallery(self.marionette)
        gallery.launch()

        gallery.wait_for_thumbnails_to_load()
        image = gallery.tap_first_gallery_item()

        self.assertIsNotNone(image.current_image_source)
        self.assertTrue(image.is_photo_toolbar_displayed)

        # click on share button and check the element is correct
        activities_list = image.tap_share_button()
        self.assertGreater(activities_list.options_count, 1)
        activities_list.tap_cancel()

        gallery = image.tap_tile_view_button()
        gallery.wait_for_thumbnails_to_load()

        image = gallery.tap_first_gallery_item()
        self.assertTrue(image.is_image_displayed)
    def test_gallery_click_share_button(self):
        gallery = Gallery(self.marionette)
        gallery.launch()

        gallery.wait_for_thumbnails_to_load()
        image = gallery.tap_first_gallery_item()

        self.assertIsNotNone(image.current_image_source)
        self.assertTrue(image.is_photo_toolbar_displayed)

        # click on share button and check the element is correct
        actions_list = image.tap_share_button()
        self.assertGreater(actions_list.options_count, 1)
        actions_list.tap_cancel()

        gallery = image.tap_tile_view_button()
        gallery.wait_for_thumbnails_to_load()

        image = gallery.tap_first_gallery_item()
        self.assertTrue(image.is_image_displayed)
class TestCardsViewTwoApps(GaiaImageCompareTestCase):

    def setUp(self):
        GaiaImageCompareTestCase.setUp(self)
        self.cards_view = CardsView(self.marionette)

        self.contacts = Contacts(self.marionette)
        self.contacts.launch()
        self.gallery = Gallery(self.marionette)
        self.gallery.launch(empty=True)

        # 10 seconds for the actual user using the app a bit, and going back to homescreen
        time.sleep(10)
        self.device.touch_home_button()

    def test_cards_view_kill_apps_with_two_apps(self):
        """https://moztrap.mozilla.org/manage/case/1917/"""

        # Pull up the cards view
        self.device.hold_home_button()
        self.cards_view.wait_for_cards_view()

        # Wait for first app ready
        self.cards_view.cards[1].wait_for_centered()
        self.take_screenshot(top_frame=True)

        # Close the current apps from the cards view
        self.cards_view.cards[1].close()
        self.cards_view.cards[0].wait_for_centered()
        self.take_screenshot(top_frame=True)
        self.cards_view.cards[0].close()
        self.cards_view.wait_for_cards_view_not_displayed()
        self.take_screenshot(top_frame=True)

        # If successfully killed, the apps should no longer appear in the cards view
        # and the "No recent apps" message should be displayed
        self.device.hold_home_button()
        self.cards_view.wait_for_no_card_displayed()
        self.take_screenshot(top_frame=True)
        self.assertEqual(len(self.cards_view.cards), 0)
        self.assertTrue(self.cards_view.is_no_card_displayed)
    def test_gallery_delete_image(self):
        """
        https://moztrap.mozilla.org/manage/case/1533/
        """

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

        gallery_multi_view = gallery.switch_to_multiple_selection_view()
        gallery_multi_view.select_nth_picture(0)
        gallery_multi_view.select_nth_picture(1)
        gallery_multi_view.select_nth_picture(2)

        # Tap the delete button and confirm by default
        gallery_multi_view.tap_delete_button()
        gallery.wait_for_thumbnail_view_to_load()

        # Verify empty gallery title.
        Wait(self.marionette).until(
            lambda m: gallery.empty_gallery_title == 'No photos or videos')
    def test_gallery_delete_image(self):
        """
        https://moztrap.mozilla.org/manage/case/1534/
        """

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

        # Select 3 images
        gallery_multi_view = gallery.switch_to_multiple_selection_view()
        gallery_multi_view.select_nth_picture(0)
        gallery_multi_view.select_nth_picture(1)
        gallery_multi_view.select_nth_picture(2)

        # Tap the delete button and press cancel button
        gallery_multi_view.tap_delete_button(confirm=False)

        # Verify files still exist and still selected
        self.assertEqual(3, gallery_multi_view.number_of_selected_images)
        self.assertEqual(3, gallery.gallery_items_number)
Beispiel #42
0
    def test_gallery_handle_load_corrupt_file(self, filename):
        self.push_resource(filename)

        gallery = Gallery(self.marionette)
        gallery.launch(filename != "image_formats/x07.jpg")

        self.assertTrue(len(self.data_layer.picture_files) == 1)

        # loaded image will not display in the gallery app, except in case of corrupt_jpg
        if filename == "image_formats/x07.jpg":
            self.assertTrue(gallery.gallery_items_number == 1)
            # make sure the file opens without crash
            image = gallery.tap_first_gallery_item()
            self.assertTrue("blob:app://gallery.gaiamobile.org/" in
                            image.current_image_source)
        else:
            Wait(self.marionette).until(lambda m: gallery.empty_gallery_text ==
                                        'Use the Camera app to get started.')
            self.assertTrue(gallery.gallery_items_number == 0)
            self.assertEqual(gallery.empty_gallery_title,
                             'No photos or videos')
    def test_gallery_delete_image(self):
        """
        https://moztrap.mozilla.org/manage/case/1534/
        """

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

        # Select 3 images
        gallery_multi_view = gallery.switch_to_multiple_selection_view()
        gallery_multi_view.select_nth_picture(0)
        gallery_multi_view.select_nth_picture(1)
        gallery_multi_view.select_nth_picture(2)

        # Tap the delete button and press cancel button
        gallery_multi_view.tap_delete_button(confirm=False)

        # Verify files still exist and still selected
        self.assertEqual(3, gallery_multi_view.number_of_selected_images)
        self.assertEqual(3, gallery.gallery_items_number)
Beispiel #44
0
    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_gallery_share_to_messages(self):
        """
        https://moztrap.mozilla.org/manage/case/4008/
        """

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

        gallery.wait_for_files_to_load(self.image_count)
        self.assertEqual(gallery.gallery_items_number, self.image_count)

        # Enter multiple selection mode and select a picture
        multiple_selection_view = gallery.switch_to_multiple_selection_view()
        multiple_selection_view.select_first_picture()

        # Share the picture to messages
        activities = multiple_selection_view.tap_share_button()
        new_message = activities.share_to_messages()

        # Assert that the new message has an attachment
        new_message.wait_for_message_input_displayed()
        self.assertTrue(new_message.has_attachment)
Beispiel #46
0
    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_gallery_view(self):
        """
        https://moztrap.mozilla.org/manage/case/2309/
        """

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

        # From the main list view, click camera icon
        self.previous_number_of_pictures = len(self.data_layer.picture_files)
        camera = gallery.switch_to_camera()

        # Take the shot
        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)

        # Verify the Camera app is still open, by checking for the presence of thumbnail
        self.assertTrue(camera.is_thumbnail_visible)
    def test_gallery_view(self):
        """
        https://moztrap.mozilla.org/manage/case/2309/
        """

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

        # From the main list view, click camera icon
        self.previous_number_of_pictures = len(self.data_layer.picture_files)
        camera = gallery.switch_to_camera()

        # Take the shot
        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)

        # Verify the Camera app is still open, by checking for the presence of thumbnail
        self.assertTrue(camera.is_thumbnail_visible)
class TestCardsView(GaiaImageCompareTestCase):

    images = 'IMG_0001.jpg'
    image_count = 4

    def setUp(self):
        GaiaImageCompareTestCase.setUp(self)
        self.push_resource(self.images, count=self.image_count)

        self.take_screenshot(top_frame=True)

        self.contacts = Contacts(self.marionette)
        self.contacts.launch()
        # 10 seconds for the actual user using the app a bit, and going back to homescreen
        time.sleep(10)
        self.device.touch_home_button()
        self.gallery = Gallery(self.marionette)
        self.gallery.launch()
        # 10 seconds for the actual user using the app a bit, and going back to homescreen
        time.sleep(10)
        self.device.touch_home_button()


    def test_cards_view_with_two_apps(self):
        """https://moztrap.mozilla.org/manage/case/2462/"""

        cards_view = CardsView(self.marionette)
        self.assertFalse(cards_view.is_displayed, 'Cards view not expected to be visible')

        # Pull up the cards view
        self.device.hold_home_button()
        cards_view.wait_for_cards_view()
        self.take_screenshot(top_frame=True)

        # disabled per Bug 1118390
        #self.change_orientation('landscape-primary')
        #self.take_screenshot()
        #self.change_orientation('portrait-primary')
        #self.take_screenshot()

        # Wait for first app ready
        cards_view.cards[1].wait_for_centered()
        self.assertIn(cards_view.cards[0].manifest_url[:19], self.contacts.manifest_url)
        self.assertIn(cards_view.cards[1].manifest_url, self.gallery.manifest_url)
        cards_view.swipe_to_previous_app()

        # Wait for previous app ready
        cards_view.cards[0].wait_for_centered()
        # sleep inside above method is insufficient
        time.sleep(2)
        self.take_screenshot(top_frame=True)

        cards_view.cards[0].tap()
        cards_view.wait_for_cards_view_not_displayed()
        self.take_screenshot(top_frame=True) #bug 1151571 will cause blank screen capture

        self.assertTrue(self.contacts.is_displayed)

        # take screenshot and pause, otherwise there will be a collision
    def change_orientation(self, orientation, wait=2):
        self.device.change_orientation(orientation)
        time.sleep(wait)
    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 #51
0
    def gallery_edit_photo(self, photo_file, location=None):

        # add photo to storage
        self.push_resource(photo_file, location)
        gallery = Gallery(self.marionette)
        gallery.launch()
        gallery.wait_for_files_to_load(1)
        self.assertTrue(gallery.gallery_items_number == 1)

        # open picture and capture
        image = gallery.tap_first_gallery_item()
        self.take_screenshot()

        # Tap on Edit button.
        edit_image = image.tap_edit_button()

        self.marionette.find_element(*self._edit_exposure_button_locator).tap()

        # change brightness and capture
        self.move_slider(self._exposure_slider_bar, 250)
        self.take_screenshot()

        edit_image.tap_edit_tool_apply_button()

        # do crop and capture
        self.change_orientation('landscape-primary')
        self.marionette.find_element(*self._edit_crop_button).tap()
        self.take_screenshot()
        self.change_orientation('portrait-primary')
        self.wait_for_element_displayed(*self._crop_aspect_square_button)
        self.marionette.find_element(*self._crop_aspect_portrait_button).tap()
        self.take_screenshot()
        self.change_orientation('landscape-primary')
        self.marionette.find_element(*self._crop_aspect_landscape_button).tap()
        self.take_screenshot()
        self.change_orientation('portrait-primary')
        self.marionette.find_element(*self._crop_aspect_square_button).tap()
        self.take_screenshot()
        self.change_orientation('landscape-primary', 4)
        edit_image.tap_edit_tool_apply_button()

        # Tap on Effects button.
        edit_image.tap_edit_effects_button()
        # Change effects.  take screenshot on each change.
        self.marionette.find_element(*self._bw_effect_button).tap()
        self.take_screenshot()
        self.change_orientation('portrait-primary')
        self.marionette.find_element(*self._sepia_effect_button).tap()
        self.take_screenshot()
        self.change_orientation('landscape-primary')
        self.marionette.find_element(*self._faded_effect_button).tap()
        self.take_screenshot()
        self.change_orientation('portrait-primary')
        self.marionette.find_element(*self._blue_steel_effect_button).tap()
        self.take_screenshot()
        self.change_orientation('landscape-primary')
        edit_image.tap_edit_tool_apply_button()

        # save the resulting picture
        filelist = edit_image.tap_edit_save_button()
        filelist.wait_for_files_to_load(2)
        time.sleep(3)
        self.take_screenshot()
        self.apps.kill(gallery.app)
    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)
    def gallery_edit_photo(self, photo_file, location=None):

        # add photo to storage
        self.push_resource(photo_file, location)
        gallery = Gallery(self.marionette)
        gallery.launch()
        gallery.wait_for_files_to_load(1)
        self.assertTrue(gallery.gallery_items_number == 1)

        # open picture and capture
        image = gallery.tap_first_gallery_item()
        self.take_screenshot()

        # Tap on Edit button.
        edit_image = image.tap_edit_button()

        self.marionette.find_element(*self._edit_exposure_button_locator).tap()

        # change brightness and capture
        self.move_slider(self._exposure_slider_bar, 250)
        self.take_screenshot()

        edit_image.tap_edit_tool_apply_button()

        # do crop and capture
        self.change_orientation('landscape-primary')
        self.marionette.find_element(*self._edit_crop_button).tap()
        self.take_screenshot()
        self.change_orientation('portrait-primary')
        Wait(self.marionette).until(expected.element_displayed(*self._crop_aspect_square_button))
        self.marionette.find_element(*self._crop_aspect_portrait_button).tap()
        self.take_screenshot()
        self.change_orientation('landscape-primary')
        self.marionette.find_element(*self._crop_aspect_landscape_button).tap()
        self.take_screenshot()
        self.change_orientation('portrait-primary')
        self.marionette.find_element(*self._crop_aspect_square_button).tap()
        self.take_screenshot()
        self.change_orientation('landscape-primary', 4)
        edit_image.tap_edit_tool_apply_button()

        # Tap on Effects button.
        edit_image.tap_edit_effects_button()
        # Change effects.  take screenshot on each change.
        self.marionette.find_element(*self._bw_effect_button).tap()
        self.take_screenshot()
        self.change_orientation('portrait-primary')
        self.marionette.find_element(*self._sepia_effect_button).tap()
        self.take_screenshot()
        self.change_orientation('landscape-primary')
        self.marionette.find_element(*self._faded_effect_button).tap()
        self.take_screenshot()
        self.change_orientation('portrait-primary')
        self.marionette.find_element(*self._blue_steel_effect_button).tap()
        self.take_screenshot()
        self.change_orientation('landscape-primary')
        edit_image.tap_edit_tool_apply_button()

        # save the resulting picture
        filelist = edit_image.tap_edit_save_button()
        filelist.wait_for_files_to_load(2)
        time.sleep(3)
        self.take_screenshot()
        self.apps.kill(gallery.app)