Merge lp:~carla-sella/ubuntu-docviewer-app/test-toc into lp:ubuntu-docviewer-app/trunk

Proposed by Carla Sella
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
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.

To post a comment you must log in.
Revision history for this message
Carla Sella (carla-sella) wrote :

Still have to fix scrolling.

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

Ok test completed. Should be ok for rewiew now :).

139. By Carla Sella

Fixed little error.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
140. By Carla Sella

Fixed regression on test test_go_to_page_pdf_file.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Carla Sella (carla-sella) wrote :

\o/ passed :).

Revision history for this message
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).

review: Needs Fixing
Revision history for this message
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.

Revision history for this message
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.bottomEdgePageLoaded.wait_for(True)" (line 112 of __init__.py) should work but looks like it's not for you.

Revision history for this message
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.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Stefano Verzegnassi (verzegnassi-stefano) wrote :

Here's the log: http://paste.ubuntu.com/10971013/

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.

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

Hello Stefano,
I tried to fix the bottom edge issue adding this line:

action_item.stretched.wait_for(True)

(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 ListItemWithActions.

I'm not sure I have been clear, hope this screenshot helps to understand the issue:
https://dl.dropboxusercontent.com/u/10083981/Ubuntu%20phone/Docviewer.png

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
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_item.globalRect.y + 1)
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://paste.ubuntu.com/10985020/

143. By Carla Sella

Inserted fixes suggested by Stefano for Bottom Edge and content items not visible.

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

Thanks Stefano.
Your fixes worked so, probably you know Autopilot enough :-).

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

Thanks Stefano.
Your fixes worked so your knowledge of Autopilot is good :-).

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Carla Sella (carla-sella) wrote :

Thanks Stefano.
Your fixes worked so your knowledge of Autopilot is good :-).

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Carla Sella (carla-sella) wrote :

Thanks Stefano.
Your fixes worked so your knowledge of Autopilot is good :-).

Revision history for this message
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!

review: Approve
Revision history for this message
Stefano Verzegnassi (verzegnassi-stefano) wrote :

Forgot to ask: should I wait for balloons' review, before top-approve it?

Revision history for this message
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://about.me/carla.sella

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://code.launchpad.net/~carla-sella/ubuntu-docviewer-app/test-toc/+merge/258082
> You are the owner of lp:~carla-sella/ubuntu-docviewer-app/test-toc.
>

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

Some comments :-)

review: Needs Fixing
144. By Carla Sella

Fixed code as Nicholas asked to.

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

A few more comments :-)

review: Needs Fixing
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
145. By Carla Sella

Fixed while loop.

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

Fixed the part of the while loop.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

+1 from me, but do change the logger.warn to something else before top approving.

review: Approve
146. By Carla Sella

Deleted logger.warn.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'po/com.ubuntu.docviewer.pot'
--- po/com.ubuntu.docviewer.pot 2015-04-27 16:02:40 +0000
+++ po/com.ubuntu.docviewer.pot 2015-05-08 19:00:14 +0000
@@ -8,7 +8,7 @@
8msgstr ""8msgstr ""
9"Project-Id-Version: \n"9"Project-Id-Version: \n"
10"Report-Msgid-Bugs-To: \n"10"Report-Msgid-Bugs-To: \n"
11"POT-Creation-Date: 2015-04-27 18:02+0200\n"11"POT-Creation-Date: 2015-05-04 21:48+0200\n"
12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14"Language-Team: LANGUAGE <LL@li.org>\n"14"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -34,7 +34,7 @@
3434
35#: ../src/app/docviewer-application.cpp:16435#: ../src/app/docviewer-application.cpp:164
36#: ../src/app/qml/documentPage/DocumentPage.qml:2536#: ../src/app/qml/documentPage/DocumentPage.qml:25
37#: /home/stefano/tmp/build-ch-imported-documents-name-Desktop-Default/po/com.ubuntu.docviewer.desktop.in.in.h:137#: /home/letozaf/autopilot-tests/build-test-toc-Desktop-Default/po/com.ubuntu.docviewer.desktop.in.in.h:1
38msgid "Document Viewer"38msgid "Document Viewer"
39msgstr ""39msgstr ""
4040
@@ -257,12 +257,12 @@
257msgstr ""257msgstr ""
258258
259#. TRANSLATORS: "Contents" refers to the "Table of Contents" of a PDF document.259#. TRANSLATORS: "Contents" refers to the "Table of Contents" of a PDF document.
260#: ../src/app/qml/pdfView/PdfContentsPage.qml:26260#: ../src/app/qml/pdfView/PdfContentsPage.qml:32
261#: ../src/app/qml/pdfView/PdfView.qml:37261#: ../src/app/qml/pdfView/PdfView.qml:37
262msgid "Contents"262msgid "Contents"
263msgstr ""263msgstr ""
264264
265#: ../src/app/qml/pdfView/PdfContentsPage.qml:32265#: ../src/app/qml/pdfView/PdfContentsPage.qml:38
266msgid "Hide table of contents"266msgid "Hide table of contents"
267msgstr ""267msgstr ""
268268
@@ -319,6 +319,6 @@
319msgid "Open"319msgid "Open"
320msgstr ""320msgstr ""
321321
322#: /home/stefano/tmp/build-ch-imported-documents-name-Desktop-Default/po/com.ubuntu.docviewer.desktop.in.in.h:2322#: /home/letozaf/autopilot-tests/build-test-toc-Desktop-Default/po/com.ubuntu.docviewer.desktop.in.in.h:2
323msgid "documents;viewer;pdf;reader;"323msgid "documents;viewer;pdf;reader;"
324msgstr ""324msgstr ""
325325
=== modified file 'src/app/qml/pdfView/PdfContentsPage.qml'
--- src/app/qml/pdfView/PdfContentsPage.qml 2015-04-16 12:58:29 +0000
+++ src/app/qml/pdfView/PdfContentsPage.qml 2015-05-08 19:00:14 +0000
@@ -22,6 +22,12 @@
22import "../upstreamComponents"22import "../upstreamComponents"
2323
24Page {24Page {
25 id: pdfContents
26 objectName: "pdfcontents"
27
28 // this property will have to be removed when bug #1341671 will be fixed.
29 property string testProperty: "for page name issue"
30
25 // TRANSLATORS: "Contents" refers to the "Table of Contents" of a PDF document.31 // TRANSLATORS: "Contents" refers to the "Table of Contents" of a PDF document.
26 title: i18n.tr("Contents")32 title: i18n.tr("Contents")
2733
@@ -57,6 +63,7 @@
5763
58 ListView {64 ListView {
59 id: view65 id: view
66 objectName: "view"
60 anchors.fill: parent67 anchors.fill: parent
61 clip: true68 clip: true
6269
@@ -64,6 +71,7 @@
6471
65 delegate: ListItemWithActions {72 delegate: ListItemWithActions {
66 id: delegate73 id: delegate
74 objectName: "delegate" + index
6775
68 width: parent.width76 width: parent.width
69 height: (model.level === 0) ? units.gu(7) : units.gu(6)77 height: (model.level === 0) ? units.gu(7) : units.gu(6)
@@ -73,6 +81,7 @@
73 : Theme.palette.normal.background81 : Theme.palette.normal.background
7482
75 AbstractButton {83 AbstractButton {
84 objectName: "abstractbutton"
76 anchors.fill: parent85 anchors.fill: parent
7786
78 onClicked: {87 onClicked: {
@@ -91,6 +100,7 @@
91 spacing: units.gu(1)100 spacing: units.gu(1)
92101
93 Label {102 Label {
103 objectName: "content"
94 Layout.fillWidth: true104 Layout.fillWidth: true
95105
96 text: model.title106 text: model.title
@@ -102,6 +112,7 @@
102 }112 }
103113
104 Label {114 Label {
115 objectName: "pageindex"
105 text: model.pageIndex + 1116 text: model.pageIndex + 1
106 font.weight: model.level == 0 ? Font.DemiBold : Font.Normal117 font.weight: model.level == 0 ? Font.DemiBold : Font.Normal
107 color: (model.level === 0) ? UbuntuColors.midAubergine118 color: (model.level === 0) ? UbuntuColors.midAubergine
108119
=== modified file 'tests/autopilot/ubuntu_docviewer_app/__init__.py'
--- tests/autopilot/ubuntu_docviewer_app/__init__.py 2015-04-14 15:37:06 +0000
+++ tests/autopilot/ubuntu_docviewer_app/__init__.py 2015-05-08 19:00:14 +0000
@@ -20,6 +20,7 @@
20from autopilot import logging as autopilot_logging20from autopilot import logging as autopilot_logging
21logger = logging.getLogger(__name__)21logger = logging.getLogger(__name__)
2222
23from autopilot.introspection import dbus
23import ubuntuuitoolkit24import ubuntuuitoolkit
2425
2526
@@ -58,10 +59,20 @@
58 return self.wait_select_single(PdfView)59 return self.wait_select_single(PdfView)
5960
60 @autopilot_logging.log_action(logger.info)61 @autopilot_logging.log_action(logger.info)
62 def open_PdfContentsPage(self):
63 """Open the PdfContents Page.
64
65 :return the PdfContents Page
66
67 """
68 return self.wait_select_single(PdfContentsPage)
69
70 @autopilot_logging.log_action(logger.info)
61 def get_PdfViewGotoDialog(self):71 def get_PdfViewGotoDialog(self):
62 """Return a dialog emulator"""72 """Return a dialog emulator"""
63 return self.wait_select_single(objectName="PdfViewGotoDialog")73 return self.wait_select_single(objectName="PdfViewGotoDialog")
6474
75 @autopilot_logging.log_action(logger.info)
65 def go_to_page_from_dialog(self, page_no):76 def go_to_page_from_dialog(self, page_no):
66 """ Go to page from get_PfdViewGotoDialog """77 """ Go to page from get_PfdViewGotoDialog """
67 textfield = self.wait_select_single(78 textfield = self.wait_select_single(
@@ -70,6 +81,12 @@
70 go_button = self.wait_select_single("Button", objectName="GOButton")81 go_button = self.wait_select_single("Button", objectName="GOButton")
71 self.pointing_device.click_object(go_button)82 self.pointing_device.click_object(go_button)
7283
84 @autopilot_logging.log_action(logger.info)
85 def click_go_to_page_button(self):
86 """Click the go_to_page header button."""
87 header = self.get_header()
88 header.click_action_button('gotopage')
89
7390
74class Page(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):91class Page(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
7592
@@ -82,15 +99,85 @@
82 self.main_view = self.get_root_instance().select_single(MainView)99 self.main_view = self.get_root_instance().select_single(MainView)
83100
84101
85class PdfView(Page):102class PageWithBottomEdge(MainView):
103 """
104 An emulator class that makes it easy to interact with the bottom edge
105 swipe page
106 """
107 def __init__(self, *args):
108 super(PageWithBottomEdge, self).__init__(*args)
109
110 def reveal_bottom_edge_page(self):
111 """Bring the bottom edge page to the screen"""
112 self.bottomEdgePageLoaded.wait_for(True)
113 try:
114 action_item = self.wait_select_single(objectName='bottomEdgeTip')
115 action_item.visible.wait_for(True)
116 action_item.stretched.wait_for(True)
117 start_x = (action_item.globalRect.x +
118 (action_item.globalRect.width * 0.5))
119 start_y = (action_item.globalRect.y + 1)
120 stop_y = start_y - (self.height * 0.5)
121 self.pointing_device.drag(start_x, start_y,
122 start_x, stop_y, rate=2)
123 self.isReady.wait_for(True)
124 except dbus.StateNotFoundError:
125 logger.error('BottomEdge element not found.')
126 raise
127
128
129class PdfView(PageWithBottomEdge):
86 """Autopilot helper for PdfView page."""130 """Autopilot helper for PdfView page."""
87131
88 @autopilot_logging.log_action(logger.info)132 @autopilot_logging.log_action(logger.info)
89 def toggle_header_visibility(self):133 def toggle_header_visibility(self):
90 """Show/hide page header by clicking on the center of main view"""134 """Show/hide page header by clicking on the center of main view"""
91 self.pointing_device.click_object(self.main_view)135 self.pointing_device.click_object(self)
92136
93 def click_go_to_page_button(self):137 def get_currentpage_number(self):
94 """Click the go_to_page header button."""138 """return the value of the currentPage property"""
95 header = self.main_view.get_header()139 return self.currentPage
96 header.click_action_button('gotopage')140
141
142class PdfContentsPage(Page):
143 """Autopilot helper for PdfContents page."""
144
145 @autopilot_logging.log_action(logger.info)
146 def get_content_and_line_pageindex(self, labelText):
147 content_line, page_no = self._get_listitem(labelText)
148 return content_line, page_no
149
150 def _get_listitem(self, labelText):
151 view_item = self.select_single(
152 "QQuickListView", objectName="view")
153 list_items_count = view_item.count
154
155 index = 0
156 for index in range(list_items_count):
157 list_item = self.select_single(
158 "ListItemWithActions", objectName="delegate{}".format(index))
159 while list_item.y > (view_item.contentY +
160 view_item.globalRect.height):
161 self.scroll_pdfcontentspage()
162 label = list_item.select_single("Label", objectName="content")
163 if label.text == labelText:
164 page_no = list_item.select_single(
165 "Label", objectName="pageindex").text
166 return label, page_no
167 break
168
169 @autopilot_logging.log_action(logger.info)
170 def click_content_line(self, content_line):
171 self.pointing_device.click_object(content_line)
172
173 @autopilot_logging.log_action(logger.info)
174 def scroll_pdfcontentspage(self):
175 action_item = self.select_single("QQuickListView")
176 start_x = (action_item.globalRect.x +
177 (action_item.globalRect.width * 0.5))
178 start_y = (action_item.globalRect.y +
179 (action_item.height * 0.8))
180 stop_y = start_y - (action_item.height * 0.7)
181 self.pointing_device.drag(start_x, start_y,
182 start_x, stop_y, rate=2)
183 action_item.moving.wait_for(False)
97184
=== added file 'tests/autopilot/ubuntu_docviewer_app/files/serverguide.pdf'
98Binary 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 differ185Binary 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
=== modified file 'tests/autopilot/ubuntu_docviewer_app/tests/test_docviewer.py'
--- tests/autopilot/ubuntu_docviewer_app/tests/test_docviewer.py 2015-04-14 15:37:06 +0000
+++ tests/autopilot/ubuntu_docviewer_app/tests/test_docviewer.py 2015-05-08 19:00:14 +0000
@@ -60,7 +60,7 @@
60 self.launch_app()60 self.launch_app()
61 pdf = self.app.main_view.open_PdfView()61 pdf = self.app.main_view.open_PdfView()
62 pdf.toggle_header_visibility()62 pdf.toggle_header_visibility()
63 pdf.click_go_to_page_button()63 self.app.main_view.click_go_to_page_button()
64 self.go_to_page_no(page_no)64 self.go_to_page_no(page_no)
6565
66 self.assertThat(66 self.assertThat(
6767
=== added file 'tests/autopilot/ubuntu_docviewer_app/tests/test_toc.py'
--- tests/autopilot/ubuntu_docviewer_app/tests/test_toc.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/ubuntu_docviewer_app/tests/test_toc.py 2015-05-08 19:00:14 +0000
@@ -0,0 +1,47 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2# Copyright 2013 Canonical
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"""Docviewer app autopilot tests."""
9
10from ubuntu_docviewer_app.tests import DocviewerAppTestCase
11
12import logging
13logger = logging.getLogger(__name__)
14
15
16class TestMainWindow(DocviewerAppTestCase):
17
18 """Tests the TOC features"""
19 scenarios = [
20 ('Chapter 1',
21 {'content_label': 'Chapter 1. Introduction'
22 }),
23
24 ('Chapter 3',
25 {'content_label': 'Chapter 3. Package Management',
26 })
27 ]
28
29 def setUp(self):
30 super(TestMainWindow, self).setUp()
31 self.filepath = 'ubuntu_docviewer_app/files/serverguide.pdf'
32
33 def test_go_to_chapters_in_toc(self):
34 """" Testing going to chapters from Table Of Contents """
35
36 self.launch_app()
37 pdf = self.app.main_view.open_PdfView()
38 pdf.reveal_bottom_edge_page()
39 contents_page = self.app.main_view.open_PdfContentsPage()
40 content_line, page_no = contents_page.\
41 get_content_and_line_pageindex(self.content_label)
42 contents_page.click_content_line(content_line)
43
44 word_in_currentpage = pdf.get_currentpage_number().split()
45 pdfview_currentpage = word_in_currentpage[1]
46
47 self.assertEquals(pdfview_currentpage, page_no)

Subscribers

People subscribed via source and target branches