Merge lp:~carla-sella/ubuntu-calendar-app/calendar-app into lp:ubuntu-calendar-app

Proposed by Carla Sella
Status: Merged
Merged at revision: 65
Proposed branch: lp:~carla-sella/ubuntu-calendar-app/calendar-app
Merge into: lp:ubuntu-calendar-app
Diff against target: 322 lines (+223/-40)
4 files modified
tests/autopilot/calendar_app/emulators/main_window.py (+3/-19)
tests/autopilot/calendar_app/emulators/ubuntusdk.py (+154/-0)
tests/autopilot/calendar_app/tests/__init__.py (+5/-10)
tests/autopilot/calendar_app/tests/test_calendar.py (+61/-11)
To merge this branch: bzr merge lp:~carla-sella/ubuntu-calendar-app/calendar-app
Reviewer Review Type Date Requested Status
Carla Sella (community) for merging Needs Resubmitting
Olivier Tilloy (community) fixed what asked Needs Fixing
Review via email: mp+170194@code.launchpad.net

Description of the change

Autopilot test for calendar-app with conflicts resolved.

To post a comment you must log in.
53. By Launchpad Translations on behalf of ubuntu-calendar-dev

Launchpad automatic translations update.

Revision history for this message
Olivier Tilloy (osomon) wrote :

205 - "/usr/share/calendar-app/calendar.qml",
206 + "/usr/share/ubuntu-calendar-app/calendar.qml",

please revert this change

review: Needs Fixing
Revision history for this message
Olivier Tilloy (osomon) wrote :

270 + #check that "create event" window opens
271 + #create_event_page = self.main_window.get_create_event_page()
272 + #self.assertThat(lambda: self.main_window.get_create_event_page(), Eventually(Equals("True")))

Why is this commented out? Is it not working?

Revision history for this message
Olivier Tilloy (osomon) wrote :

266 + def test_new_event(self):

This method looks good overall, however it’s not really testing that the event has been effectively created, it might be interesting to test that the event appears in the timeline after it’s been created.

Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

> 270 + #check that "create event" window opens
> 271 + #create_event_page = self.main_window.get_create_event_page()
> 272 + #self.assertThat(lambda: self.main_window.get_create_event_page(),
> Eventually(Equals("True")))
>
> Why is this commented out? Is it not working?

Yes, it's an un-needed assert, but it doesn't work. I would remove it completely.

54. By Launchpad Translations on behalf of ubuntu-calendar-dev

Launchpad automatic translations update.

55. By Launchpad Translations on behalf of ubuntu-calendar-dev

Launchpad automatic translations update.

Revision history for this message
Carla Sella (carla-sella) wrote :

I fixed what you asked.
Resubmitting for merge.

review: Needs Resubmitting (for merging)
56. By Launchpad Translations on behalf of ubuntu-calendar-dev

Launchpad automatic translations update.

57. By Launchpad Translations on behalf of ubuntu-calendar-dev

Launchpad automatic translations update.

58. By Launchpad Translations on behalf of ubuntu-calendar-dev

Launchpad automatic translations update.

59. By Launchpad Translations on behalf of ubuntu-calendar-dev

Launchpad automatic translations update.

60. By Launchpad Translations on behalf of ubuntu-calendar-dev

Launchpad automatic translations update.

61. By Launchpad Translations on behalf of ubuntu-calendar-dev

Launchpad automatic translations update.

62. By Launchpad Translations on behalf of ubuntu-calendar-dev

Launchpad automatic translations update.

63. By Launchpad Translations on behalf of ubuntu-calendar-dev

Launchpad automatic translations update.

64. By Kunal Parmar

YearView implemented
Reusable MonthView component created ( needs to use it with yearview and monthview)
Reusable PathViewBase created ( needs to use it with timeline view, weekview ).

Approved by Michael Hall, Ubuntu Phone Apps Jenkins Bot.

65. By Carla Sella

add event autopilot test.

Approved by Ubuntu Phone Apps Jenkins Bot, Michael Hall, Nicholas Skaggs.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/autopilot/calendar_app/emulators/main_window.py'
--- tests/autopilot/calendar_app/emulators/main_window.py 2013-05-29 16:38:15 +0000
+++ tests/autopilot/calendar_app/emulators/main_window.py 2013-06-21 18:12:26 +0000
@@ -16,25 +16,6 @@
16 def __init__(self, app):16 def __init__(self, app):
17 self.app = app17 self.app = app
1818
19 def get_qml_view(self):
20 """Get the main QML view"""
21 return self.app.select_single("QQuickView")
22
23 def get_panel(self):
24 return self.app.select_single("Toolbar")
25
26 def get_toolbar_button(self, button_idx):
27 toolbar = self.app.select_single("Toolbar")
28 row = toolbar.select_single("QQuickRow")
29 buttons = row.select_many("Button")
30 return buttons[button_idx]
31
32 def get_toolbar_new_event_button(self):
33 return self.get_toolbar_button(1)
34
35 def get_toolbar_timeline_button(self):
36 return self.get_toolbar_button(2)
37
38 def get_create_event_page(self):19 def get_create_event_page(self):
39 return self.app.select_single("NewEvent")20 return self.app.select_single("NewEvent")
4021
@@ -60,3 +41,6 @@
6041
61 def get_event_view(self):42 def get_event_view(self):
62 return self.app.select_single("EventView")43 return self.app.select_single("EventView")
44
45 def get_title_label(self, title):
46 return self.app.select_many("Label", text=title)
6347
=== added file 'tests/autopilot/calendar_app/emulators/ubuntusdk.py'
--- tests/autopilot/calendar_app/emulators/ubuntusdk.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/calendar_app/emulators/ubuntusdk.py 2013-06-21 18:12:26 +0000
@@ -0,0 +1,154 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
3# Copyright (C) 2013 Canonical Ltd
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3 as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16#
17# Authored by: Nicholas Skaggs <nicholas.skaggs@canonical.com>
18
19from testtools.matchers import Equals, NotEquals, Not, Is
20from autopilot.matchers import Eventually
21
22class ubuntusdk(object):
23 """An emulator class that makes it easy to interact with the ubuntu sdk applications."""
24
25 def __init__(self, autopilot, app):
26 self.app = app
27 self.autopilot = autopilot
28
29 def get_qml_view(self):
30 """Get the main QML view"""
31 return self.app.select_single("QQuickView")
32
33 def get_object(self, typeName, name):
34 """Get a specific object"""
35 return self.app.select_single(typeName, objectName=name)
36
37 def get_objects(self, typeName, name):
38 """Get more than one object"""
39 return self.app.select_many(typeName, objectName=name)
40
41 def switch_to_tab(self, tab):
42 """Switch to the specified tab number"""
43 tabs = self.get_tabs()
44 currentTab = tabs.selectedTabIndex
45
46 #perform operations until tab == currentTab
47 while tab != currentTab:
48 if tab > currentTab:
49 self._previous_tab()
50 if tab < currentTab:
51 self._next_tab()
52 currentTab = tabs.selectedTabIndex
53
54 def toggle_toolbar(self):
55 """Toggle the toolbar between revealed and hidden"""
56 #check and see if the toolbar is open or not
57 if self.get_toolbar().opened:
58 self.hide_toolbar()
59 else:
60 self.open_toolbar()
61
62 def get_toolbar(self):
63 """Returns the toolbar in the main events view."""
64 return self.app.select_single("Toolbar")
65
66 def get_toolbar_button(self, buttonLabel):
67 """Returns the toolbar button at position index"""
68 toolbar = self.get_toolbar()
69 if not toolbar.opened:
70 self.open_toolbar()
71 row = toolbar.select_single("QQuickRow")
72 loaderList = row.select_many("QQuickLoader")
73 for loader in loaderList:
74 buttonList = loader.select_many("Button")
75 for button in buttonList:
76 if button.text == buttonLabel:
77 return button
78
79 def click_toolbar_button(self, buttonLabel):
80 """Clicks the toolbar button with buttonLabel"""
81 #The toolbar button is assumed to be the following format
82 #ToolbarActions {
83 # Action {
84 # objectName: "name"
85 # text: value
86 button = self.get_toolbar_button(buttonLabel)
87 self.autopilot.pointing_device.click_object(button)
88
89 def open_toolbar(self):
90 """Open the toolbar"""
91 qmlView = self.get_qml_view()
92
93 lineX = qmlView.x + qmlView.width * 0.50
94 startY = qmlView.y + qmlView.height - 1
95 stopY = qmlView.y + qmlView.height * 0.95
96
97 self.autopilot.pointing_device.drag(lineX, startY, lineX, stopY)
98
99 def hide_toolbar(self):
100 """Hide the toolbar"""
101 qmlView = self.get_qml_view()
102
103 lineX = qmlView.x + qmlView.width * 0.50
104 startY = qmlView.y + qmlView.height * 0.95
105 stopY = qmlView.y + qmlView.height - 1
106
107 self.autopilot.pointing_device.drag(lineX, startY, lineX, stopY)
108
109 def set_popup_value(self, popover, button, value):
110 """Changes the given popover selector to the request value
111 At the moment this only works for values that are currently visible. To
112 access the remaining items, a help method to drag and recheck is needed."""
113 #The popover is assumed to be the following format
114 # Popover {
115 # Column {
116 # ListView {
117 # delegate: Standard {
118 # objectName: "name"
119 # text: value
120
121 self.autopilot.pointing_device.click_object(button)
122 #we'll get all matching objects, incase the popover is reused between buttons
123 itemList = lambda: self.get_objects("Standard", popover)
124
125 for item in itemList():
126 if item.get_properties()['text'] == value:
127 self.autopilot.pointing_device.click_object(item)
128
129 def get_tabs(self):
130 """Return all tabs"""
131 return self.get_object("Tabs", "rootTabs")
132
133 def _previous_tab(self):
134 """Switch to the previous tab"""
135 qmlView = self.get_qml_view()
136
137 startX = qmlView.x + qmlView.width * 0.35
138 stopX = qmlView.x + qmlView.width * 0.50
139 lineY = qmlView.y + qmlView.height * 0.05
140
141 self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY)
142 self.autopilot.pointing_device.click()
143 self.autopilot.pointing_device.click()
144
145 def _next_tab(self):
146 """Switch to the next tab"""
147 qmlView = self.get_qml_view()
148
149 startX = qmlView.x + qmlView.width * 0.50
150 stopX = qmlView.x + qmlView.width * 0.35
151 lineY = qmlView.y + qmlView.height * 0.05
152
153 self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY)
154 self.autopilot.pointing_device.click()
0155
=== modified file 'tests/autopilot/calendar_app/tests/__init__.py'
--- tests/autopilot/calendar_app/tests/__init__.py 2013-06-12 15:47:15 +0000
+++ tests/autopilot/calendar_app/tests/__init__.py 2013-06-21 18:12:26 +0000
@@ -16,6 +16,7 @@
16from testtools.matchers import Equals16from testtools.matchers import Equals
1717
18from calendar_app.emulators.main_window import MainWindow18from calendar_app.emulators.main_window import MainWindow
19from calendar_app.emulators.ubuntusdk import ubuntusdk
1920
2021
21class CalendarTestCase(AutopilotTestCase):22class CalendarTestCase(AutopilotTestCase):
@@ -52,16 +53,10 @@
52 "--desktop_file_hint=/usr/share/applications/calendar-app.desktop",53 "--desktop_file_hint=/usr/share/applications/calendar-app.desktop",
53 app_type='qt')54 app_type='qt')
5455
55 def reveal_toolbar(self):
56 toolbar = self.main_window.get_panel()
57
58 x, y, w, h = toolbar.globalRect
59 tx = x + (w / 2)
60 ty = y + (h - 2)
61
62 self.pointing_device.drag(tx, ty, tx, ty - h)
63 self.assertThat(toolbar.state, Eventually(Equals("spread")))
64
65 @property56 @property
66 def main_window(self):57 def main_window(self):
67 return MainWindow(self.app)58 return MainWindow(self.app)
59
60 @property
61 def ubuntusdk(self):
62 return ubuntusdk(self, self.app)
6863
=== modified file 'tests/autopilot/calendar_app/tests/test_calendar.py'
--- tests/autopilot/calendar_app/tests/test_calendar.py 2013-06-12 15:47:15 +0000
+++ tests/autopilot/calendar_app/tests/test_calendar.py 2013-06-21 18:12:26 +0000
@@ -10,28 +10,78 @@
10from __future__ import absolute_import10from __future__ import absolute_import
1111
12from autopilot.matchers import Eventually12from autopilot.matchers import Eventually
13from testtools.matchers import Equals13from testtools.matchers import Equals, NotEquals
1414
15from calendar_app.tests import CalendarTestCase15from calendar_app.tests import CalendarTestCase
1616
17import time
1718
18class TestMainWindow(CalendarTestCase):19class TestMainWindow(CalendarTestCase):
1920
20 def setUp(self):21 def setUp(self):
21 super(TestMainWindow, self).setUp()22 super(TestMainWindow, self).setUp()
22 self.assertThat(23 self.assertThat(
23 self.main_window.get_qml_view().visible, Eventually(Equals(True)))24 self.ubuntusdk.get_qml_view().visible, Eventually(Equals(True)))
2425
25 def tearDown(self):26 def tearDown(self):
26 super(TestMainWindow, self).tearDown()27 super(TestMainWindow, self).tearDown()
2728
28 def test_timeline_view_shows(self):29 def test_timeline_view_shows(self):
29 timeline_button = self.main_window.get_toolbar_timeline_button()30 event_view = lambda: self.main_window.get_event_view().eventViewType
30 event_view = self.main_window.get_event_view()31
31 self.reveal_toolbar()32 self.ubuntusdk.click_toolbar_button('Timeline')
3233 self.assertThat(event_view, Eventually(Equals("TimeLineView.qml")))
33 self.assertThat(event_view.eventViewType, Eventually(Equals("DiaryView.qml")))34 self.ubuntusdk.click_toolbar_button('Diary')
34 self.pointing_device.click_object(timeline_button)35 self.assertThat(event_view, Eventually(Equals("DiaryView.qml")))
35 self.assertThat(event_view.eventViewType, Eventually(Equals("TimeLineView.qml")))36 self.ubuntusdk.click_toolbar_button('Timeline')
36 self.pointing_device.click_object(timeline_button)37 self.assertThat(event_view, Eventually(Equals("TimeLineView.qml")))
37 self.assertThat(event_view.eventViewType, Eventually(Equals("DiaryView.qml")))38
39 def test_new_event(self):
40 #click on new event button
41 self.ubuntusdk.click_toolbar_button('New Event')
42
43 #grab all the fields
44 #event_view = self.main_window.get_event_view()
45 event_name_field = self.main_window.get_new_event_name_input_box()
46 start_time_field = self.main_window.get_event_start_time_field()
47 end_time_field = self.main_window.get_event_end_time_field()
48 location_field = self.main_window.get_event_location_field()
49 people_field = self.main_window.get_event_people_field()
50 save_button = self.main_window.get_event_save_button()
51
52 #input a new event name
53 eventTitle = "Test event" + str(time.time())
54
55 self.pointing_device.click_object(event_name_field)
56 self.keyboard.type(eventTitle)
57 self.assertThat(event_name_field.text, Eventually(Equals(eventTitle)))
58
59 #input start time
60 self.pointing_device.click_object(start_time_field)
61 self.keyboard.press_and_release("Ctrl+a")
62 self.keyboard.type("11")
63 self.assertThat(start_time_field.text, Eventually(Equals("11")))
64
65 #input end time
66 self.pointing_device.click_object(end_time_field)
67 self.keyboard.press_and_release("Ctrl+a")
68 self.keyboard.type("00")
69 self.assertThat(end_time_field.text, Eventually(Equals("00")))
70
71 #input location
72 self.pointing_device.click_object(location_field)
73 self.keyboard.type("My location")
74 self.assertThat(location_field.text, Eventually(Equals("My location")))
75
76 #input people
77 self.pointing_device.click_object(people_field)
78 self.keyboard.type("Me")
79 self.assertThat(people_field.text, Eventually(Equals("Me")))
80
81 #click save button
82 self.pointing_device.click_object(save_button)
83
84 #verify that the event has been created in timeline
85 title_label = lambda: self.main_window.get_title_label(eventTitle)
86 self.assertThat(title_label, Eventually(NotEquals(None)))
87

Subscribers

People subscribed via source and target branches

to status/vote changes: