~schwann/gallery-app/gallery-no-album-share

« back to all changes in this revision

Viewing changes to tests/autopilot/gallery_app/tests/test_photos_view.py

  • Committer: Guenter Schwann
  • Date: 2013-03-28 10:35:15 UTC
  • mto: This revision was merged to the branch mainline in revision 627.
  • Revision ID: guenter.schwann@canonical.com-20130328103515-9sfpjwsvvct0rbeh
Autopilot test refactoring

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
from autopilot.matchers import Eventually
15
15
 
16
16
from gallery_app.tests import GalleryTestCase
 
17
from gallery_app.emulators.photos_view import PhotosView
17
18
 
18
19
from os.path import exists
19
20
from time import sleep
21
22
 
22
23
class TestPhotosView(GalleryTestCase):
23
24
 
 
25
    @property
 
26
    def photos_view(self):
 
27
        return PhotosView(self.app)
 
28
 
24
29
    def setUp(self):
25
30
        super(TestPhotosView, self).setUp()
26
 
        self.assertThat(self.photo_viewer.get_qml_view().visible, Eventually(Equals(True)))
27
 
 
28
 
        self.click_tabs_bar()
29
 
        self.click_photos_tab_button()
30
 
 
31
 
        photos_view = self.photos_view.get_photos_view()
32
 
        self.assertThat(photos_view.focus, Eventually(Equals(True)))
33
 
        sleep(1)
34
 
 
35
 
 
36
 
    def click_tabs_bar(self):
 
31
        self.switch_to_photos_tab()
 
32
 
 
33
 
 
34
    def switch_to_photos_tab(self):
37
35
        tabs_bar = self.photos_view.get_tabs_bar()
38
36
        self.click_item(tabs_bar)
39
37
 
40
 
    def click_photos_tab_button(self):
41
 
        photos_tab_button = self.app.select_single("AbstractButton", buttonIndex=5)
42
 
 
 
38
        photos_tab_button = self.photos_view.get_photos_tab_button()
43
39
        #Due to some timing issues sometimes mouse moves to the location a bit earlier
44
40
        #even though the tab item is not fully visible, hence the tab does not activate.
45
41
        self.assertThat(photos_tab_button.opacity, Eventually(GreaterThan(0.2)))
 
42
        self.click_item(photos_tab_button)
46
43
 
47
 
        photos_tab = self.photos_view.get_photos_tab()
48
 
        self.click_item(photos_tab)
 
44
        photos_view = self.photos_view.get_photos_view()
 
45
        self.assertThat(photos_view.focus, Eventually(Equals(True)))
49
46
 
50
47
    def enable_select_mode(self):
51
 
        self.reveal_tool_bar()
 
48
        self.reveal_toolbar()
52
49
        self.click_select_icon()
53
50
 
54
51
    def click_select_icon(self):
55
 
        select_icon = self.photos_view.get_select_icon()
 
52
        select_icon = self.photos_view.get_toolbar_select_button()
56
53
        self.click_item(select_icon)
57
54
 
58
55
    def click_first_photo(self):
60
57
        self.click_item(photo)
61
58
 
62
59
    def click_delete_action(self):
63
 
        trash_button = self.photos_view.get_delete_icon()
 
60
        trash_button = self.photos_view.get_toolbar_delete_button()
64
61
        self.click_item(trash_button)
65
62
 
66
63
 
71
68
 
72
69
    def test_select_button_cancel(self):
73
70
        """Clicking the cancel button after clicking the select button must
74
 
        hide the chromebar automatically."""
 
71
        hide the toolbar automatically."""
75
72
        self.enable_select_mode()
76
73
 
77
 
        cancel_icon = self.photos_view.get_cancel_icon()
 
74
        cancel_icon = self.photos_view.get_toolbar_cancel_icon()
78
75
        self.click_item(cancel_icon)
79
76
 
80
 
        toolbar = self.photos_view.get_tool_bar()
 
77
        toolbar = self.photos_view.get_toolbar()
81
78
        self.assertThat(toolbar.active, Eventually(Equals(False)))
82
79
 
83
80
    def test_delete_a_photo(self):