| 1 |
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
| 2 |
# Copyright 2013-2015 Canonical Ltd. |
| 3 |
# |
| 4 |
# This program is free software: you can redistribute it and/or modify it |
| 5 |
# under the terms of the GNU General Public License version 3, as published |
| 6 |
# by the Free Software Foundation. |
| 7 |
|
| 8 |
from lomiriuitoolkit import emulators as toolkit_emulators |
| 9 |
|
| 10 |
|
| 11 |
class AlbumEditor(toolkit_emulators.LomiriUIToolkitEmulatorBase): |
| 12 |
"""A class that makes it easy to interact with the album editor""" |
| 13 |
|
| 14 |
def close(self): |
| 15 |
cover_image = self.album_cover_image() |
| 16 |
# click left of the cover |
| 17 |
x, y, w, h = cover_image.globalRect |
| 18 |
self.pointing_device.move(x - 10, y + (h // 2)) |
| 19 |
# workaround lp:1247698 (get rid of toolbar) |
| 20 |
self.pointing_device.click() |
| 21 |
self.pointing_device.click() |
| 22 |
self.ensure_fully_closed |
| 23 |
|
| 24 |
def ensure_fully_open(self): |
| 25 |
self.animationRunning.wait_for(False) |
| 26 |
self.active.wait_for(True) |
| 27 |
|
| 28 |
def ensure_fully_closed(self): |
| 29 |
self.active.wait_for(False) |
| 30 |
|
| 31 |
def album_editor(self): |
| 32 |
"""Returns the album editor.""" |
| 33 |
return self |
| 34 |
|
| 35 |
def album_title_entry_field(self): |
| 36 |
"""Returns the album title input box.""" |
| 37 |
editor = self.album_editor() |
| 38 |
return editor.wait_select_single("TextEditOnClick", |
| 39 |
objectName="albumTitleField") |
| 40 |
|
| 41 |
def click_title_field(self): |
| 42 |
self.pointing_device.click_object(self.album_title_entry_field()) |
| 43 |
|
| 44 |
def album_subtitle_entry_field(self): |
| 45 |
"""Returns the album subtitle input box.""" |
| 46 |
editor = self.album_editor() |
| 47 |
return editor.wait_select_single("TextEditOnClick", |
| 48 |
objectName="albumSubtitleField") |
| 49 |
|
| 50 |
def click_subtitle_field(self): |
| 51 |
self.pointing_device.click_object(self.album_subtitle_entry_field()) |
| 52 |
|
| 53 |
def album_cover_image(self): |
| 54 |
album_cover = self.wait_select_single("AlbumCover", visible=True) |
| 55 |
return album_cover.wait_select_single( |
| 56 |
"QQuickImage", |
| 57 |
objectName="albumCoverImage" |
| 58 |
) |
| 59 |
|
| 60 |
def add_photos(self): |
| 61 |
self.pointing_device.click_object(self._plus_icon()) |
| 62 |
|
| 63 |
def _plus_icon(self): |
| 64 |
"""Returns the plus icon to add photos""" |
| 65 |
return self.wait_select_single("QQuickImage", |
| 66 |
objectName="albumCoverAddPhotosImage", |
| 67 |
visible=True) |