Merge lp:~carla-sella/ubuntu-docviewer-app/test-toc into lp:ubuntu-docviewer-app/trunk
- test-toc
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Alan Pope 🍺🐧🐱 🦄 | ||||
Approved revision: | 146 | ||||
Merged at revision: | 141 | ||||
Proposed branch: | lp:~carla-sella/ubuntu-docviewer-app/test-toc | ||||
Merge into: | lp:ubuntu-docviewer-app/trunk | ||||
Diff against target: |
307 lines (+158/-13) 5 files modified
po/com.ubuntu.docviewer.pot (+5/-5) src/app/qml/pdfView/PdfContentsPage.qml (+11/-0) tests/autopilot/ubuntu_docviewer_app/__init__.py (+94/-7) tests/autopilot/ubuntu_docviewer_app/tests/test_docviewer.py (+1/-1) tests/autopilot/ubuntu_docviewer_app/tests/test_toc.py (+47/-0) |
||||
To merge this branch: | bzr merge lp:~carla-sella/ubuntu-docviewer-app/test-toc | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu Phone Apps Jenkins Bot | continuous-integration | Approve | |
Nicholas Skaggs (community) | Approve | ||
Stefano Verzegnassi | Approve | ||
Review via email: mp+258082@code.launchpad.net |
Commit message
First test for testing Docviewer app TOC.
Description of the change
First test for testing Docviewer app TOC.
Carla Sella (carla-sella) wrote : | # |
Carla Sella (carla-sella) wrote : | # |
Ok test completed. Should be ok for rewiew now :).
- 139. By Carla Sella
-
Fixed little error.
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:139
http://
Executed test runs:
UNSTABLE: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 140. By Carla Sella
-
Fixed regression on test test_go_
to_page_ pdf_file.
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:140
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Carla Sella (carla-sella) wrote : | # |
\o/ passed :).
Stefano Verzegnassi (verzegnassi-stefano) wrote : | # |
Hi Carla,
thanks for the MP!
There is an issue that makes tests fail on my PC.
I've added two in-line comment (at lines 56 and 168).
Carla Sella (carla-sella) wrote : | # |
Hi Stefano,
I left replies to your comments.
I will find a fix for your problem and let you know so you can test it.
Carla Sella (carla-sella) wrote : | # |
By the way, Stefano, can you send me the error output you get on your computer as this does not occur on my Desktop. The strange thing for me is that "self.bottomEdg
Carla Sella (carla-sella) wrote : | # |
Another thing, you are using "autopilot3 run -vv test-name" to launch the tests, right?
- 141. By Carla Sella
-
Added comment on PdfContentPage.qml propery.
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:141
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Stefano Verzegnassi (verzegnassi-stefano) wrote : | # |
Here's the log: http://
I think I found out the issue.
When you run the test, where is the DocViewer window on the screen?
If the window is anchored on the bottom-right corner, the suite runs well with no failure, but if the window is floating in the middle of the screen, ToC tests return a failure.
Having a look at what happens on the screen, it seems that depends on the WM.
I've seen that in the former case, the mouse cursor does not change its hint and it's not possible to resize the window from its bottom edge, since the cursor can not reach the border of the window.
In the latter that's possible, and the window is resized.
The 0.3 second delay makes the tests working, so I suppose that the coordinate for the bottomEdgeTip are wrong.
Without the delay, the mouse cursor is moved to y=659, with the delay to y=644. The difference is 15px. If it may be useful, 15px = units.gu(1.875).
- 142. By Carla Sella
-
First try to fix bottome edge issue.
Carla Sella (carla-sella) wrote : | # |
Hello Stefano,
I tried to fix the bottom edge issue adding this line:
action_
(action_item is the bottomEdgeTip.
If you can test this on you PC to see if it still fails.
I have found another issue though: the test fails when trying to click on the "Chapter 3. Package Management" content line as it is out of the Doviewer app window and not visible, but in autopilot vis it is in the QQuickListView and the test clicks on it as it is in the QQuickListView as a ListItemWithAct
I'm not sure I have been clear, hope this screenshot helps to understand the issue:
https:/
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:142
http://
Executed test runs:
UNSTABLE: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Stefano Verzegnassi (verzegnassi-stefano) wrote : | # |
My Autopilot knowledge is poor, I'm learning case by case.
Dunno how to make test waiting for the bottomEdgeTip to be completely visible, but I found a better workaround that worked for me.
Since the tip is always partially visible (by a units.gu(1) offset), even when hidden, setting
start_y = (action_
does the trick and grants a legal value which is inside the window boundaries.
The issue with scroll seems to be the same issue I have with the bottomEdge.
I tried to add a further check that ensure the ToC entry will be visible, and it worked: http://
- 143. By Carla Sella
-
Inserted fixes suggested by Stefano for Bottom Edge and content items not visible.
Carla Sella (carla-sella) wrote : | # |
Thanks Stefano.
Your fixes worked so, probably you know Autopilot enough :-).
Carla Sella (carla-sella) wrote : | # |
Thanks Stefano.
Your fixes worked so your knowledge of Autopilot is good :-).
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:143
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Carla Sella (carla-sella) wrote : | # |
Thanks Stefano.
Your fixes worked so your knowledge of Autopilot is good :-).
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:143
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Carla Sella (carla-sella) wrote : | # |
Thanks Stefano.
Your fixes worked so your knowledge of Autopilot is good :-).
Stefano Verzegnassi (verzegnassi-stefano) wrote : | # |
Heh, if I had to write this test suite, I'd be still trying to understand where to start. :-)
Anyway, it LGTM now! Thanks Carla!
P.S. No problem for having sent the comment several times!
Stefano Verzegnassi (verzegnassi-stefano) wrote : | # |
Forgot to ask: should I wait for balloons' review, before top-approve it?
Carla Sella (carla-sella) wrote : | # |
I am not sure if Nicholas has to approve it too, maybe just ask him :), I
usually always ask him to reiview,but maybe it is not necessary.
--
Carla Sella
email: <email address hidden>
http://
On Tue, May 5, 2015 at 3:02 PM, Stefano Verzegnassi <<email address hidden>
> wrote:
> Forgot to ask: should I wait for balloons' review, before top-approve it?
> --
>
> https:/
> You are the owner of lp:~carla-sella/ubuntu-docviewer-app/test-toc.
>
Nicholas Skaggs (nskaggs) wrote : | # |
Some comments :-)
- 144. By Carla Sella
-
Fixed code as Nicholas asked to.
Nicholas Skaggs (nskaggs) wrote : | # |
A few more comments :-)
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:144
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 145. By Carla Sella
-
Fixed while loop.
Carla Sella (carla-sella) wrote : | # |
Fixed the part of the while loop.
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:145
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Nicholas Skaggs (nskaggs) wrote : | # |
+1 from me, but do change the logger.warn to something else before top approving.
- 146. By Carla Sella
-
Deleted logger.warn.
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:146
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'po/com.ubuntu.docviewer.pot' |
2 | --- po/com.ubuntu.docviewer.pot 2015-04-27 16:02:40 +0000 |
3 | +++ po/com.ubuntu.docviewer.pot 2015-05-08 19:00:14 +0000 |
4 | @@ -8,7 +8,7 @@ |
5 | msgstr "" |
6 | "Project-Id-Version: \n" |
7 | "Report-Msgid-Bugs-To: \n" |
8 | -"POT-Creation-Date: 2015-04-27 18:02+0200\n" |
9 | +"POT-Creation-Date: 2015-05-04 21:48+0200\n" |
10 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
11 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
12 | "Language-Team: LANGUAGE <LL@li.org>\n" |
13 | @@ -34,7 +34,7 @@ |
14 | |
15 | #: ../src/app/docviewer-application.cpp:164 |
16 | #: ../src/app/qml/documentPage/DocumentPage.qml:25 |
17 | -#: /home/stefano/tmp/build-ch-imported-documents-name-Desktop-Default/po/com.ubuntu.docviewer.desktop.in.in.h:1 |
18 | +#: /home/letozaf/autopilot-tests/build-test-toc-Desktop-Default/po/com.ubuntu.docviewer.desktop.in.in.h:1 |
19 | msgid "Document Viewer" |
20 | msgstr "" |
21 | |
22 | @@ -257,12 +257,12 @@ |
23 | msgstr "" |
24 | |
25 | #. TRANSLATORS: "Contents" refers to the "Table of Contents" of a PDF document. |
26 | -#: ../src/app/qml/pdfView/PdfContentsPage.qml:26 |
27 | +#: ../src/app/qml/pdfView/PdfContentsPage.qml:32 |
28 | #: ../src/app/qml/pdfView/PdfView.qml:37 |
29 | msgid "Contents" |
30 | msgstr "" |
31 | |
32 | -#: ../src/app/qml/pdfView/PdfContentsPage.qml:32 |
33 | +#: ../src/app/qml/pdfView/PdfContentsPage.qml:38 |
34 | msgid "Hide table of contents" |
35 | msgstr "" |
36 | |
37 | @@ -319,6 +319,6 @@ |
38 | msgid "Open" |
39 | msgstr "" |
40 | |
41 | -#: /home/stefano/tmp/build-ch-imported-documents-name-Desktop-Default/po/com.ubuntu.docviewer.desktop.in.in.h:2 |
42 | +#: /home/letozaf/autopilot-tests/build-test-toc-Desktop-Default/po/com.ubuntu.docviewer.desktop.in.in.h:2 |
43 | msgid "documents;viewer;pdf;reader;" |
44 | msgstr "" |
45 | |
46 | === modified file 'src/app/qml/pdfView/PdfContentsPage.qml' |
47 | --- src/app/qml/pdfView/PdfContentsPage.qml 2015-04-16 12:58:29 +0000 |
48 | +++ src/app/qml/pdfView/PdfContentsPage.qml 2015-05-08 19:00:14 +0000 |
49 | @@ -22,6 +22,12 @@ |
50 | import "../upstreamComponents" |
51 | |
52 | Page { |
53 | + id: pdfContents |
54 | + objectName: "pdfcontents" |
55 | + |
56 | + // this property will have to be removed when bug #1341671 will be fixed. |
57 | + property string testProperty: "for page name issue" |
58 | + |
59 | // TRANSLATORS: "Contents" refers to the "Table of Contents" of a PDF document. |
60 | title: i18n.tr("Contents") |
61 | |
62 | @@ -57,6 +63,7 @@ |
63 | |
64 | ListView { |
65 | id: view |
66 | + objectName: "view" |
67 | anchors.fill: parent |
68 | clip: true |
69 | |
70 | @@ -64,6 +71,7 @@ |
71 | |
72 | delegate: ListItemWithActions { |
73 | id: delegate |
74 | + objectName: "delegate" + index |
75 | |
76 | width: parent.width |
77 | height: (model.level === 0) ? units.gu(7) : units.gu(6) |
78 | @@ -73,6 +81,7 @@ |
79 | : Theme.palette.normal.background |
80 | |
81 | AbstractButton { |
82 | + objectName: "abstractbutton" |
83 | anchors.fill: parent |
84 | |
85 | onClicked: { |
86 | @@ -91,6 +100,7 @@ |
87 | spacing: units.gu(1) |
88 | |
89 | Label { |
90 | + objectName: "content" |
91 | Layout.fillWidth: true |
92 | |
93 | text: model.title |
94 | @@ -102,6 +112,7 @@ |
95 | } |
96 | |
97 | Label { |
98 | + objectName: "pageindex" |
99 | text: model.pageIndex + 1 |
100 | font.weight: model.level == 0 ? Font.DemiBold : Font.Normal |
101 | color: (model.level === 0) ? UbuntuColors.midAubergine |
102 | |
103 | === modified file 'tests/autopilot/ubuntu_docviewer_app/__init__.py' |
104 | --- tests/autopilot/ubuntu_docviewer_app/__init__.py 2015-04-14 15:37:06 +0000 |
105 | +++ tests/autopilot/ubuntu_docviewer_app/__init__.py 2015-05-08 19:00:14 +0000 |
106 | @@ -20,6 +20,7 @@ |
107 | from autopilot import logging as autopilot_logging |
108 | logger = logging.getLogger(__name__) |
109 | |
110 | +from autopilot.introspection import dbus |
111 | import ubuntuuitoolkit |
112 | |
113 | |
114 | @@ -58,10 +59,20 @@ |
115 | return self.wait_select_single(PdfView) |
116 | |
117 | @autopilot_logging.log_action(logger.info) |
118 | + def open_PdfContentsPage(self): |
119 | + """Open the PdfContents Page. |
120 | + |
121 | + :return the PdfContents Page |
122 | + |
123 | + """ |
124 | + return self.wait_select_single(PdfContentsPage) |
125 | + |
126 | + @autopilot_logging.log_action(logger.info) |
127 | def get_PdfViewGotoDialog(self): |
128 | """Return a dialog emulator""" |
129 | return self.wait_select_single(objectName="PdfViewGotoDialog") |
130 | |
131 | + @autopilot_logging.log_action(logger.info) |
132 | def go_to_page_from_dialog(self, page_no): |
133 | """ Go to page from get_PfdViewGotoDialog """ |
134 | textfield = self.wait_select_single( |
135 | @@ -70,6 +81,12 @@ |
136 | go_button = self.wait_select_single("Button", objectName="GOButton") |
137 | self.pointing_device.click_object(go_button) |
138 | |
139 | + @autopilot_logging.log_action(logger.info) |
140 | + def click_go_to_page_button(self): |
141 | + """Click the go_to_page header button.""" |
142 | + header = self.get_header() |
143 | + header.click_action_button('gotopage') |
144 | + |
145 | |
146 | class Page(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase): |
147 | |
148 | @@ -82,15 +99,85 @@ |
149 | self.main_view = self.get_root_instance().select_single(MainView) |
150 | |
151 | |
152 | -class PdfView(Page): |
153 | +class PageWithBottomEdge(MainView): |
154 | + """ |
155 | + An emulator class that makes it easy to interact with the bottom edge |
156 | + swipe page |
157 | + """ |
158 | + def __init__(self, *args): |
159 | + super(PageWithBottomEdge, self).__init__(*args) |
160 | + |
161 | + def reveal_bottom_edge_page(self): |
162 | + """Bring the bottom edge page to the screen""" |
163 | + self.bottomEdgePageLoaded.wait_for(True) |
164 | + try: |
165 | + action_item = self.wait_select_single(objectName='bottomEdgeTip') |
166 | + action_item.visible.wait_for(True) |
167 | + action_item.stretched.wait_for(True) |
168 | + start_x = (action_item.globalRect.x + |
169 | + (action_item.globalRect.width * 0.5)) |
170 | + start_y = (action_item.globalRect.y + 1) |
171 | + stop_y = start_y - (self.height * 0.5) |
172 | + self.pointing_device.drag(start_x, start_y, |
173 | + start_x, stop_y, rate=2) |
174 | + self.isReady.wait_for(True) |
175 | + except dbus.StateNotFoundError: |
176 | + logger.error('BottomEdge element not found.') |
177 | + raise |
178 | + |
179 | + |
180 | +class PdfView(PageWithBottomEdge): |
181 | """Autopilot helper for PdfView page.""" |
182 | |
183 | @autopilot_logging.log_action(logger.info) |
184 | def toggle_header_visibility(self): |
185 | """Show/hide page header by clicking on the center of main view""" |
186 | - self.pointing_device.click_object(self.main_view) |
187 | - |
188 | - def click_go_to_page_button(self): |
189 | - """Click the go_to_page header button.""" |
190 | - header = self.main_view.get_header() |
191 | - header.click_action_button('gotopage') |
192 | + self.pointing_device.click_object(self) |
193 | + |
194 | + def get_currentpage_number(self): |
195 | + """return the value of the currentPage property""" |
196 | + return self.currentPage |
197 | + |
198 | + |
199 | +class PdfContentsPage(Page): |
200 | + """Autopilot helper for PdfContents page.""" |
201 | + |
202 | + @autopilot_logging.log_action(logger.info) |
203 | + def get_content_and_line_pageindex(self, labelText): |
204 | + content_line, page_no = self._get_listitem(labelText) |
205 | + return content_line, page_no |
206 | + |
207 | + def _get_listitem(self, labelText): |
208 | + view_item = self.select_single( |
209 | + "QQuickListView", objectName="view") |
210 | + list_items_count = view_item.count |
211 | + |
212 | + index = 0 |
213 | + for index in range(list_items_count): |
214 | + list_item = self.select_single( |
215 | + "ListItemWithActions", objectName="delegate{}".format(index)) |
216 | + while list_item.y > (view_item.contentY + |
217 | + view_item.globalRect.height): |
218 | + self.scroll_pdfcontentspage() |
219 | + label = list_item.select_single("Label", objectName="content") |
220 | + if label.text == labelText: |
221 | + page_no = list_item.select_single( |
222 | + "Label", objectName="pageindex").text |
223 | + return label, page_no |
224 | + break |
225 | + |
226 | + @autopilot_logging.log_action(logger.info) |
227 | + def click_content_line(self, content_line): |
228 | + self.pointing_device.click_object(content_line) |
229 | + |
230 | + @autopilot_logging.log_action(logger.info) |
231 | + def scroll_pdfcontentspage(self): |
232 | + action_item = self.select_single("QQuickListView") |
233 | + start_x = (action_item.globalRect.x + |
234 | + (action_item.globalRect.width * 0.5)) |
235 | + start_y = (action_item.globalRect.y + |
236 | + (action_item.height * 0.8)) |
237 | + stop_y = start_y - (action_item.height * 0.7) |
238 | + self.pointing_device.drag(start_x, start_y, |
239 | + start_x, stop_y, rate=2) |
240 | + action_item.moving.wait_for(False) |
241 | |
242 | === added file 'tests/autopilot/ubuntu_docviewer_app/files/serverguide.pdf' |
243 | Binary files tests/autopilot/ubuntu_docviewer_app/files/serverguide.pdf 1970-01-01 00:00:00 +0000 and tests/autopilot/ubuntu_docviewer_app/files/serverguide.pdf 2015-05-08 19:00:14 +0000 differ |
244 | === modified file 'tests/autopilot/ubuntu_docviewer_app/tests/test_docviewer.py' |
245 | --- tests/autopilot/ubuntu_docviewer_app/tests/test_docviewer.py 2015-04-14 15:37:06 +0000 |
246 | +++ tests/autopilot/ubuntu_docviewer_app/tests/test_docviewer.py 2015-05-08 19:00:14 +0000 |
247 | @@ -60,7 +60,7 @@ |
248 | self.launch_app() |
249 | pdf = self.app.main_view.open_PdfView() |
250 | pdf.toggle_header_visibility() |
251 | - pdf.click_go_to_page_button() |
252 | + self.app.main_view.click_go_to_page_button() |
253 | self.go_to_page_no(page_no) |
254 | |
255 | self.assertThat( |
256 | |
257 | === added file 'tests/autopilot/ubuntu_docviewer_app/tests/test_toc.py' |
258 | --- tests/autopilot/ubuntu_docviewer_app/tests/test_toc.py 1970-01-01 00:00:00 +0000 |
259 | +++ tests/autopilot/ubuntu_docviewer_app/tests/test_toc.py 2015-05-08 19:00:14 +0000 |
260 | @@ -0,0 +1,47 @@ |
261 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
262 | +# Copyright 2013 Canonical |
263 | +# |
264 | +# This program is free software: you can redistribute it and/or modify it |
265 | +# under the terms of the GNU General Public License version 3, as published |
266 | +# by the Free Software Foundation. |
267 | + |
268 | +"""Docviewer app autopilot tests.""" |
269 | + |
270 | +from ubuntu_docviewer_app.tests import DocviewerAppTestCase |
271 | + |
272 | +import logging |
273 | +logger = logging.getLogger(__name__) |
274 | + |
275 | + |
276 | +class TestMainWindow(DocviewerAppTestCase): |
277 | + |
278 | + """Tests the TOC features""" |
279 | + scenarios = [ |
280 | + ('Chapter 1', |
281 | + {'content_label': 'Chapter 1. Introduction' |
282 | + }), |
283 | + |
284 | + ('Chapter 3', |
285 | + {'content_label': 'Chapter 3. Package Management', |
286 | + }) |
287 | + ] |
288 | + |
289 | + def setUp(self): |
290 | + super(TestMainWindow, self).setUp() |
291 | + self.filepath = 'ubuntu_docviewer_app/files/serverguide.pdf' |
292 | + |
293 | + def test_go_to_chapters_in_toc(self): |
294 | + """" Testing going to chapters from Table Of Contents """ |
295 | + |
296 | + self.launch_app() |
297 | + pdf = self.app.main_view.open_PdfView() |
298 | + pdf.reveal_bottom_edge_page() |
299 | + contents_page = self.app.main_view.open_PdfContentsPage() |
300 | + content_line, page_no = contents_page.\ |
301 | + get_content_and_line_pageindex(self.content_label) |
302 | + contents_page.click_content_line(content_line) |
303 | + |
304 | + word_in_currentpage = pdf.get_currentpage_number().split() |
305 | + pdfview_currentpage = word_in_currentpage[1] |
306 | + |
307 | + self.assertEquals(pdfview_currentpage, page_no) |
Still have to fix scrolling.