[Merge] lp:~artmello/gallery-app/gallery-app-remove_photo_from_album into lp:gallery-app
Chris Gagnon
chris.gagnon at canonical.com
Fri Jun 13 13:54:13 UTC 2014
Review: Needs Fixing
There is one minor pep8 error introduced by a deleted line.
photo_viewer.py:89:5: E301 expected 1 blank line, found 0
gallery_utils.py|13 col 1| E302 expected 2 blank lines, found 1
Sorry I didn't catch it in the first review
Diff comments:
> === modified file 'rc/qml/MediaViewer/MediaViewer.qml'
> --- rc/qml/MediaViewer/MediaViewer.qml 2014-05-20 15:32:39 +0000
> +++ rc/qml/MediaViewer/MediaViewer.qml 2014-06-12 16:42:39 +0000
> @@ -65,8 +65,8 @@
>
> // tooolbar actions for the full view
> property Item tools: media ? (media.type === MediaSource.Photo ?
> - d.photoToolbar : d.videoToolbar)
> - : null
> + d.photoToolbar : d.videoToolbar)
> + : null
>
> /*!
> */
> @@ -257,7 +257,7 @@
> sharePanel.userAccountId = facebook.id;
> sharePanel.visible = true;
> viewerWrapper.tools.opened = false;
> - _lastPopover = null;
> + _lastPopover = null;
> }
> }
> }
> @@ -311,6 +311,50 @@
> }
> }
>
> + Component {
> + id: removeFromAlbumDialog
> + Dialog {
> + id: dialogue
> + objectName: "removePhotoFromAlbumDialog"
> + title: i18n.tr("Remove a photo from album")
> +
> + function finishRemove() {
> + if (model.count === 0)
> + galleryPhotoViewer.closeRequested();
> + }
> +
> + Button {
> + objectName: "removeFromAlbumButton"
> + text: i18n.tr("Remove from Album")
> + color: Gallery.HIGHLIGHT_BUTTON_COLOR
> + onClicked: {
> + PopupUtils.close(dialogue)
> + viewerWrapper.model.removeMediaFromAlbum(album, galleryPhotoViewer.media);
> + galleryPhotoViewer.currentIndexChanged();
> + dialogue.finishRemove();
> + }
> + }
> +
> + Button {
> + objectName: "removeFromAlbumAndDeleteButton"
> + text: i18n.tr("Remove from Album and Delete")
> + onClicked: {
> + PopupUtils.close(dialogue)
> + viewerWrapper.model.destroyMedia(galleryPhotoViewer.media, true);
> + galleryPhotoViewer.currentIndexChanged();
> + dialogue.finishRemove();
> + }
> + }
> +
> + Button {
> + objectName: "removeFromAlbumCancelButton"
> + text: i18n.tr("Cancel")
> + onClicked: PopupUtils.close(dialogue)
> + }
> + }
> +
> + }
> +
> onCloseRequested: viewerWrapper.closeRequested()
> onEditRequested: viewerWrapper.editRequested(media)
> }
> @@ -488,7 +532,10 @@
> text: i18n.tr("Delete")
> iconSource: "../../img/delete.png"
> onTriggered: {
> - PopupUtils.open(deleteDialog, null);
> + if (album)
> + PopupUtils.open(removeFromAlbumDialog, null);
> + else
> + PopupUtils.open(deleteDialog, null);
> }
> }
> text: i18n.tr("Delete")
> @@ -592,5 +639,4 @@
> }
> }
> }
> -
> }
>
> === modified file 'src/qml/qml-media-collection-model.cpp'
> --- src/qml/qml-media-collection-model.cpp 2014-03-21 18:13:28 +0000
> +++ src/qml/qml-media-collection-model.cpp 2014-06-12 16:42:39 +0000
> @@ -112,6 +112,24 @@
> }
>
> /*!
> + * \brief QmlMediaCollectionModel::removeMediaFromAlbum
> + * \param valbum
> + * \param vmedia
> + */
> +void QmlMediaCollectionModel::removeMediaFromAlbum(QVariant valbum, QVariant vmedia)
> +{
> + Album* album = VariantToObject<Album*>(valbum);
> + if (album == NULL)
> + return;
> +
> + MediaSource* media = VariantToObject<MediaSource*>(vmedia);
> + if (media == NULL)
> + return;
> +
> + album->detach(media);
> +}
> +
> +/*!
> * \brief QmlMediaCollectionModel::monitored
> * \return
> */
>
> === modified file 'src/qml/qml-media-collection-model.h'
> --- src/qml/qml-media-collection-model.h 2014-03-21 18:13:28 +0000
> +++ src/qml/qml-media-collection-model.h 2014-06-12 16:42:39 +0000
> @@ -48,6 +48,7 @@
> Q_INVOKABLE QVariant createAlbumFromSelected();
> Q_INVOKABLE void destroySelectedMedia();
> Q_INVOKABLE void destroyMedia(QVariant vmedia, bool destroy_backing);
> + Q_INVOKABLE void removeMediaFromAlbum(QVariant valbum, QVariant vmedia);
>
> bool monitored() const;
> void setMonitored(bool monitor);
>
> === modified file 'tests/autopilot/gallery_app/emulators/album_view.py'
> --- tests/autopilot/gallery_app/emulators/album_view.py 2014-06-10 19:00:23 +0000
> +++ tests/autopilot/gallery_app/emulators/album_view.py 2014-06-12 16:42:39 +0000
> @@ -5,13 +5,21 @@
> # under the terms of the GNU General Public License version 3, as published
> # by the Free Software Foundation.
>
> -from testtools.matchers import GreaterThan, LessThan
> +import logging
> +import re
> +
> +from testtools.matchers import GreaterThan, LessThan, Equals, Is
> +from autopilot.matchers import Eventually
> +
> +from autopilot import logging as autopilot_logging
>
> from gallery_app.emulators.gallery_utils import(
> GalleryUtils,
> GalleryAppException,
> )
>
> +logger = logging.getLogger(__name__)
> +
>
> class AlbumView(GalleryUtils):
> """An emulator class that makes it easy to interact with the gallery app"""
> @@ -41,8 +49,7 @@
>
> def get_album_photo_view(self):
> """Returns the photo view of the album viewer"""
> - view = self.get_album_view()
> - return view.select_single("PopupPhotoViewer")
> + return self.app.select_single("PopupPhotoViewer")
>
> def get_spread_view(self):
> """Returns the inner spread view to access the pages"""
> @@ -126,3 +133,87 @@
> :param page_number: The starting page number you are swiping from
> '''
> self._swipe_setup(page_number, 'right')
> +
> + def _get_remove_from_album_dialog(self):
> + """Returns the photo viewer remove from album dialog."""
> + return self.app.wait_select_single("Dialog",
> + objectName=
> + "removePhotoFromAlbumDialog")
> +
> + def _remove_from_album_dialog_shown(self):
> + dialog = self.app.select_many("Dialog",
> + objectName="removePhotoFromAlbumDialog")
> + return len(dialog) >= 1
> +
> + def _get_remove_from_album_popover_remove_item(self):
> + """Returns remove button of the remove from album popover."""
> + return self.app.select_single("Button",
> + objectName="removeFromAlbumButton",
> + visible=True)
> +
> + def _get_remove_from_album_popover_delete_item(self):
> + """Returns delete button of the remove from album popover."""
> + return self.app.select_single("Button",
> + objectName=
> + "removeFromAlbumAndDeleteButton",
> + visible=True)
> +
> + def _get_remove_from_album_popover_cancel_item(self):
> + """Returns cancel button of the remove from album popover."""
> + return self.app.select_single("Button",
> + objectName="removeFromAlbumCancelButton",
> + visible=True)
> +
> + def _ensure_remove_from_album_dialog_is_open(self):
> + """Ensure that the remove from album dialog is fully opened."""
> + remove_dialog = self._get_remove_from_album_dialog()
> + self.assertThat(remove_dialog.visible, Eventually(Equals(True)))
> + self.assertThat(remove_dialog.opacity, Eventually(Equals(1)))
> +
> + def _ensure_remove_from_album_dialog_is_close(self):
> + """Ensure that the remove from album dialog is fully closed."""
> + self.assertThat(self._remove_from_album_dialog_shown,
> + Eventually(Is(False)))
> +
> + @autopilot_logging.log_action(logger.info)
> + def click_remove_from_album_remove_button(self):
> + """Click on the remove from album button of the remove dialog."""
> + self._ensure_remove_from_album_dialog_is_open()
> +
> + remove_item = self._get_remove_from_album_popover_remove_item()
> + self.pointing_device.click_object(remove_item)
> +
> + self._ensure_remove_from_album_dialog_is_close()
> +
> + @autopilot_logging.log_action(logger.info)
> + def click_remove_from_album_delete_button(self):
> + """Click on the remove and delete of the remove dialog."""
> + self._ensure_remove_from_album_dialog_is_open()
> +
> + delete_item = self._get_remove_from_album_popover_delete_item()
> + self.pointing_device.click_object(delete_item)
> +
> + self._ensure_remove_from_album_dialog_is_close()
> +
> + @autopilot_logging.log_action(logger.info)
> + def click_remove_from_album_cancel_button(self):
> + """Click on the cancel of the remove dialog."""
> + self._ensure_remove_from_album_dialog_is_open()
> +
> + cancel_item = self._get_remove_from_album_popover_cancel_item()
> + self.pointing_device.click_object(cancel_item)
> +
> + self._ensure_remove_from_album_dialog_is_close()
> +
> + @autopilot_logging.log_action(logger.info)
> + def click_first_photo(self):
> + """Click on the first photo of the album and return the path of it."""
> + photo = self.get_first_photo()
> + images = photo.select_many('QQuickImage')
> + path = ''
> + for i in images:
> + if str(i.source).startswith('image://gallery-standard/'):
> + path = re.sub('^image://gallery-standard/', '',
> + i.source).split('?')[0]
> + self.pointing_device.click_object(photo)
> + return path
>
> === modified file 'tests/autopilot/gallery_app/emulators/gallery_utils.py'
> --- tests/autopilot/gallery_app/emulators/gallery_utils.py 2014-05-01 15:27:13 +0000
> +++ tests/autopilot/gallery_app/emulators/gallery_utils.py 2014-06-12 16:42:39 +0000
> @@ -6,14 +6,15 @@
> # by the Free Software Foundation.
> import ubuntuuitoolkit.emulators
>
> +from autopilot.testcase import AutopilotTestCase
> +
> from time import sleep
>
> -
this space needed to be here for pep8
> class GalleryAppException(Exception):
> pass
>
>
> -class GalleryUtils(object):
> +class GalleryUtils(AutopilotTestCase):
> """An emulator class that makes it easy to interact with
> general components of the gallery app."""
>
>
> === modified file 'tests/autopilot/gallery_app/emulators/photo_viewer.py'
> --- tests/autopilot/gallery_app/emulators/photo_viewer.py 2014-05-01 15:27:13 +0000
> +++ tests/autopilot/gallery_app/emulators/photo_viewer.py 2014-06-12 16:42:39 +0000
> @@ -86,7 +86,6 @@
> return self.app.select_single("Button",
> objectName="deletePhotoDialogNo",
> visible=True)
> -
this space needs to be here, otherwise you're introducing a pep8 error
> def get_opened_photo(self):
> """Returns the first opened photo."""
> return self.app.wait_select_single("ZoomablePhotoComponent",
>
> === modified file 'tests/autopilot/gallery_app/tests/test_album_view.py'
> --- tests/autopilot/gallery_app/tests/test_album_view.py 2014-05-22 17:06:01 +0000
> +++ tests/autopilot/gallery_app/tests/test_album_view.py 2014-06-12 16:42:39 +0000
> @@ -14,9 +14,11 @@
> from gallery_app.emulators.album_view import AlbumView
> from gallery_app.emulators.albums_view import AlbumsView
> from gallery_app.emulators.media_selector import MediaSelector
> +from gallery_app.emulators.photo_viewer import PhotoViewer
> from gallery_app.emulators import album_editor
> from gallery_app.tests import GalleryTestCase
>
> +import os
> from time import sleep
> from unittest import skip
>
> @@ -36,6 +38,10 @@
> def media_selector(self):
> return MediaSelector(self.app)
>
> + @property
> + def photo_viewer(self):
> + return PhotoViewer(self.app)
> +
> def setUp(self):
> self.ARGS = []
> super(TestAlbumView, self).setUp()
> @@ -105,6 +111,77 @@
> lambda: self.album_view.number_of_photos(),
> Eventually(Equals(num_photos_start + 1)))
>
> + def test_remove_photo_from_album(self):
> + self.main_view.close_toolbar()
> + self.open_first_album()
> + num_photos_start = self.album_view.number_of_photos()
> + self.assertThat(num_photos_start, Equals(1))
> +
> + path = self.album_view.click_first_photo()
> +
> + self.assertThat(lambda: os.path.exists(path),
> + Eventually(Equals(True)))
> +
> + photo_view = self.album_view.get_album_photo_view()
> + self.assertThat(photo_view.visible, Eventually(Equals(True)))
> +
> + self.main_view.open_toolbar().click_button("deleteButton")
> + self.album_view.click_remove_from_album_remove_button()
> +
> + self.assertThat(lambda: self.album_view.number_of_photos(),
> + Eventually(Equals(num_photos_start - 1)))
> +
> + self.assertThat(lambda: os.path.exists(path),
> + Eventually(Equals(True)))
> +
> + def test_remove_photo_from_album_and_delete(self):
> + self.main_view.close_toolbar()
> + self.open_first_album()
> + num_photos_start = self.album_view.number_of_photos()
> + self.assertThat(num_photos_start, Equals(1))
> +
> + path = self.album_view.click_first_photo()
> +
> + self.assertThat(lambda: os.path.exists(path),
> + Eventually(Equals(True)))
> +
> + photo_view = self.album_view.get_album_photo_view()
> + self.assertThat(photo_view.visible, Eventually(Equals(True)))
> +
> + self.main_view.open_toolbar().click_button("deleteButton")
> + self.album_view.click_remove_from_album_delete_button()
> +
> + self.assertThat(lambda: self.album_view.number_of_photos(),
> + Eventually(Equals(num_photos_start - 1)))
> +
> + self.assertThat(lambda: os.path.exists(path),
> + Eventually(Equals(False)))
> +
> + def test_cancel_remove_photo_from_album(self):
> + self.main_view.close_toolbar()
> + self.open_first_album()
> + num_photos_start = self.album_view.number_of_photos()
> + self.assertThat(num_photos_start, Equals(1))
> +
> + path = self.album_view.click_first_photo()
> +
> + self.assertThat(lambda: os.path.exists(path),
> + Eventually(Equals(True)))
> +
> + photo_view = self.album_view.get_album_photo_view()
> + self.assertThat(photo_view.visible, Eventually(Equals(True)))
> +
> + self.main_view.open_toolbar().click_button("deleteButton")
> + self.album_view.click_remove_from_album_cancel_button()
> +
> + self.main_view.open_toolbar().click_button("backButton")
> +
> + self.assertThat(lambda: self.album_view.number_of_photos(),
> + Eventually(Equals(num_photos_start)))
> +
> + self.assertThat(lambda: os.path.exists(path),
> + Eventually(Equals(True)))
> +
> def test_add_photo_to_new_album(self):
> self.main_view.open_toolbar().click_button("addButton")
> self.ui_update()
>
--
https://code.launchpad.net/~artmello/gallery-app/gallery-app-remove_photo_from_album/+merge/222739
Your team Ubuntu Phablet Team is requested to review the proposed merge of lp:~artmello/gallery-app/gallery-app-remove_photo_from_album into lp:gallery-app.
More information about the Ubuntu-reviews
mailing list