Merge lp:~carla-sella/ubuntu-docviewer-app/remove-single-file into lp:ubuntu-docviewer-app/trunk

Proposed by Carla Sella
Status: Work in progress
Proposed branch: lp:~carla-sella/ubuntu-docviewer-app/remove-single-file
Merge into: lp:ubuntu-docviewer-app/trunk
Diff against target: 279 lines (+109/-12)
8 files modified
po/com.ubuntu.docviewer.pot (+9/-9)
src/app/qml/documentPage/DocumentListView.qml (+2/-0)
src/app/qml/documentPage/DocumentPage.qml (+1/-0)
tests/autopilot/ubuntu_docviewer_app/__init__.py (+32/-1)
tests/autopilot/ubuntu_docviewer_app/tests/__init__.py (+37/-1)
tests/autopilot/ubuntu_docviewer_app/tests/test_content_in_fake_home.py (+26/-0)
tests/autopilot/ubuntu_docviewer_app/tests/test_docviewer.py (+1/-0)
tests/autopilot/ubuntu_docviewer_app/tests/test_toc.py (+1/-1)
To merge this branch: bzr merge lp:~carla-sella/ubuntu-docviewer-app/remove-single-file
Reviewer Review Type Date Requested Status
Stefano Verzegnassi Pending
Review via email: mp+261143@code.launchpad.net

Commit message

Remove single file autopilot test for Ubuntu Docviewer app.

Description of the change

New test for deleting a file for Ubuntu Docviewer App.

To post a comment you must log in.
149. By Carla Sella

test_remove_single_file ...

150. By Carla Sella

Fixed pep8 and pyflakes

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

Carla, where did you get stuck with this?

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

I get this error running the test:

Traceback (most recent call last):
  File "/home/letozaf/autopilot-tests/ubuntu-docviewer-app/tests/autopilot/ubuntu_docviewer_app/tests/test_content_in_fake_home.py", line 23, in test_remove_single_file
    initial_no_of_files = document_page.get_DocumentListView().count
AttributeError: 'NoneType' object has no attribute 'count'

I have tried several ways to find out why I cannot get the DocumentListView object, event using a sleep to see if it's a timing issue, but was unable to figure out what the issu is.
If I launch autopilot vis it looks like the object is there and visible.

Unmerged revisions

150. By Carla Sella

Fixed pep8 and pyflakes

149. By Carla Sella

test_remove_single_file ...

148. By Carla Sella

Commit for merging trunk.

147. By Carla Sella

First part of remove file test.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'po/com.ubuntu.docviewer.pot'
2--- po/com.ubuntu.docviewer.pot 2015-05-19 12:06:27 +0000
3+++ po/com.ubuntu.docviewer.pot 2015-06-10 19:58:18 +0000
4@@ -8,7 +8,7 @@
5 msgstr ""
6 "Project-Id-Version: \n"
7 "Report-Msgid-Bugs-To: \n"
8-"POT-Creation-Date: 2015-05-19 14:05+0200\n"
9+"POT-Creation-Date: 2015-06-09 22:36+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@@ -33,8 +33,8 @@
14 msgstr ""
15
16 #: ../src/app/docviewer-application.cpp:171
17-#: ../src/app/qml/documentPage/DocumentPage.qml:25
18-#: /home/stefano/tmp/build-sdcard-read-support-Desktop-Default/po/com.ubuntu.docviewer.desktop.in.in.h:1
19+#: ../src/app/qml/documentPage/DocumentPage.qml:26
20+#: /home/letozaf/autopilot-tests/build-ubuntu-docviewer-app-Desktop-Default/po/com.ubuntu.docviewer.desktop.in.in.h:1
21 msgid "Document Viewer"
22 msgstr ""
23
24@@ -214,23 +214,23 @@
25 msgid "dd-MM-yyyy hh:mm"
26 msgstr ""
27
28-#: ../src/app/qml/documentPage/DocumentListView.qml:136
29+#: ../src/app/qml/documentPage/DocumentListView.qml:138
30 msgid "Today"
31 msgstr ""
32
33-#: ../src/app/qml/documentPage/DocumentListView.qml:139
34+#: ../src/app/qml/documentPage/DocumentListView.qml:141
35 msgid "Yesterday"
36 msgstr ""
37
38-#: ../src/app/qml/documentPage/DocumentListView.qml:142
39+#: ../src/app/qml/documentPage/DocumentListView.qml:144
40 msgid "Earlier this week"
41 msgstr ""
42
43-#: ../src/app/qml/documentPage/DocumentListView.qml:145
44+#: ../src/app/qml/documentPage/DocumentListView.qml:147
45 msgid "Earlier this month"
46 msgstr ""
47
48-#: ../src/app/qml/documentPage/DocumentListView.qml:147
49+#: ../src/app/qml/documentPage/DocumentListView.qml:149
50 msgid "Even earlier..."
51 msgstr ""
52
53@@ -319,6 +319,6 @@
54 msgid "Open"
55 msgstr ""
56
57-#: /home/stefano/tmp/build-sdcard-read-support-Desktop-Default/po/com.ubuntu.docviewer.desktop.in.in.h:2
58+#: /home/letozaf/autopilot-tests/build-ubuntu-docviewer-app-Desktop-Default/po/com.ubuntu.docviewer.desktop.in.in.h:2
59 msgid "documents;viewer;pdf;reader;"
60 msgstr ""
61
62=== modified file 'src/app/qml/documentPage/DocumentListView.qml'
63--- src/app/qml/documentPage/DocumentListView.qml 2015-04-29 15:58:13 +0000
64+++ src/app/qml/documentPage/DocumentListView.qml 2015-06-10 19:58:18 +0000
65@@ -23,6 +23,7 @@
66
67 MultipleSelectionListView {
68 id: documentListView
69+ objectName: "documentListView"
70
71 anchors { fill: parent; margins: units.gu(0.5) }
72 clip: true
73@@ -50,6 +51,7 @@
74
75 listDelegate: DocumentListDelegate {
76 id: delegate
77+ objectName:"delegate" + index
78
79 property var removalAnimation
80
81
82=== modified file 'src/app/qml/documentPage/DocumentPage.qml'
83--- src/app/qml/documentPage/DocumentPage.qml 2015-05-13 14:22:36 +0000
84+++ src/app/qml/documentPage/DocumentPage.qml 2015-06-10 19:58:18 +0000
85@@ -21,6 +21,7 @@
86
87 Page {
88 id: documentPage
89+ objectName:"documentPage"
90
91 title: i18n.tr("Document Viewer")
92 flickable: null
93
94=== modified file 'tests/autopilot/ubuntu_docviewer_app/__init__.py'
95--- tests/autopilot/ubuntu_docviewer_app/__init__.py 2015-05-08 18:59:03 +0000
96+++ tests/autopilot/ubuntu_docviewer_app/__init__.py 2015-06-10 19:58:18 +0000
97@@ -22,6 +22,8 @@
98
99 from autopilot.introspection import dbus
100 import ubuntuuitoolkit
101+import os
102+import shutil
103
104
105 class DocviewerException(ubuntuuitoolkit.ToolkitException):
106@@ -73,6 +75,12 @@
107 return self.wait_select_single(objectName="PdfViewGotoDialog")
108
109 @autopilot_logging.log_action(logger.info)
110+ def get_DocumentPage(self):
111+ """Return Document page"""
112+ return self.wait_select_single(
113+ "DocumentPage", objectName="documentPage")
114+
115+ @autopilot_logging.log_action(logger.info)
116 def go_to_page_from_dialog(self, page_no):
117 """ Go to page from get_PfdViewGotoDialog """
118 textfield = self.wait_select_single(
119@@ -81,12 +89,18 @@
120 go_button = self.wait_select_single("Button", objectName="GOButton")
121 self.pointing_device.click_object(go_button)
122
123- @autopilot_logging.log_action(logger.info)
124 def click_go_to_page_button(self):
125 """Click the go_to_page header button."""
126 header = self.get_header()
127 header.click_action_button('gotopage')
128
129+ @autopilot_logging.log_action(logger.info)
130+ def copy_files_to_fake_home(self, fake_home):
131+ files_dir = os.path.join(os.path.dirname(__file__), 'files')
132+ files = os.listdir(files_dir)
133+ for file_name in files:
134+ shutil.copy(os.path.join(files_dir, file_name), fake_home)
135+
136
137 class Page(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
138
139@@ -181,3 +195,20 @@
140 self.pointing_device.drag(start_x, start_y,
141 start_x, stop_y, rate=2)
142 action_item.moving.wait_for(False)
143+
144+
145+class DocumentPage(Page):
146+ """Autopilot helper for Document page."""
147+ @autopilot_logging.log_action(logger.info)
148+ def get_DocumentListView(self):
149+ self.wait_select_single(
150+ "DocumentListView", objectName="documentListView")
151+
152+ @autopilot_logging.log_action(logger.info)
153+ def get_DocumentListDelegate(self, index):
154+ self.wait_select_single(
155+ "DocumentListDelegate", objectName="delegate{}".format(index))
156+
157+ @autopilot_logging.log_action(logger.info)
158+ def long_press_document(self, document):
159+ self.pointing_device.click_object(document, press_duration=0.3)
160
161=== modified file 'tests/autopilot/ubuntu_docviewer_app/tests/__init__.py'
162--- tests/autopilot/ubuntu_docviewer_app/tests/__init__.py 2014-12-11 01:13:20 +0000
163+++ tests/autopilot/ubuntu_docviewer_app/tests/__init__.py 2015-06-10 19:58:18 +0000
164@@ -40,7 +40,18 @@
165 """
166
167 def get_launcher_and_type(self):
168- if os.path.exists(self.local_location_binary):
169+ if self.filepath is None and \
170+ os.path.exists(self.local_location_binary):
171+ launcher = self.launch_test_local_faked_home
172+ test_type = 'local-faked-home'
173+ elif self.filepath is None and \
174+ os.path.exists(self.installed_location_binary):
175+ launcher = self.launch_test_installed_faked_home
176+ test_type = 'deb-faked-home'
177+ elif self.filepath is None:
178+ launcher = self.launch_test_click_faked_home
179+ test_type = 'click-faked-home'
180+ elif os.path.exists(self.local_location_binary):
181 launcher = self.launch_test_local
182 test_type = 'local'
183 elif os.path.exists(self.installed_location_binary):
184@@ -102,6 +113,30 @@
185 "com.ubuntu.docviewer",
186 emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
187
188+ @autopilot_logging.log_action(logger.info)
189+ def launch_test_local_faked_home(self):
190+ return self.launch_test_application(
191+ self.local_location_binary,
192+ "--documents-dir=" + self.home_dir,
193+ app_type='qt',
194+ emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
195+
196+ @autopilot_logging.log_action(logger.info)
197+ def launch_test_installed_faked_home(self):
198+ return self.launch_test_application(
199+ self.installed_location_binary,
200+ "--documents-dir=" + self.home_dir,
201+ app_type='qt',
202+ emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
203+
204+ @autopilot_logging.log_action(logger.info)
205+ def launch_test_click_faked_home(self):
206+ return self.launch_click_package(
207+ "com.ubuntu.docviewer",
208+ "--documents-dir=",
209+ self.home_dir,
210+ emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
211+
212 def _copy_xauthority_file(self, directory):
213 """ Copy .Xauthority file to directory, if it exists in /home
214 """
215@@ -136,6 +171,7 @@
216 self._copy_xauthority_file(temp_dir)
217 self.useFixture(fixtures.EnvironmentVariable('HOME',
218 newvalue=temp_dir))
219+ return temp_dir
220
221 logger.debug("Patched home to fake home directory %s" % temp_dir)
222
223
224=== added file 'tests/autopilot/ubuntu_docviewer_app/tests/test_content_in_fake_home.py'
225--- tests/autopilot/ubuntu_docviewer_app/tests/test_content_in_fake_home.py 1970-01-01 00:00:00 +0000
226+++ tests/autopilot/ubuntu_docviewer_app/tests/test_content_in_fake_home.py 2015-06-10 19:58:18 +0000
227@@ -0,0 +1,26 @@
228+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
229+# Copyright 2013 Canonical
230+#
231+# This program is free software: you can redistribute it and/or modify it
232+# under the terms of the GNU General Public License version 3, as published
233+# by the Free Software Foundation.
234+
235+"""Docviewer app autopilot tests."""
236+
237+from ubuntu_docviewer_app.tests import DocviewerAppTestCase
238+
239+
240+class TestInFakeHome(DocviewerAppTestCase):
241+
242+ def setUp(self):
243+ self.filepath = None
244+ super(TestInFakeHome, self).setUp()
245+
246+ def test_remove_single_file(self):
247+ self.launch_app()
248+ self.app.main_view.copy_files_to_fake_home(self.home_dir)
249+ document_page = self.app.main_view.get_DocumentPage()
250+ initial_no_of_files = document_page.get_DocumentListView().count
251+ index = 0
252+ document = document_page.get_DocumentListDelegate(index)
253+ document_page.long_press_document(document)
254
255=== modified file 'tests/autopilot/ubuntu_docviewer_app/tests/test_docviewer.py'
256--- tests/autopilot/ubuntu_docviewer_app/tests/test_docviewer.py 2015-05-02 10:25:56 +0000
257+++ tests/autopilot/ubuntu_docviewer_app/tests/test_docviewer.py 2015-06-10 19:58:18 +0000
258@@ -16,6 +16,7 @@
259 class TestMainWindow(DocviewerAppTestCase):
260
261 def setUp(self):
262+ self.filepath = ""
263 super(TestMainWindow, self).setUp()
264
265 def go_to_page_no(self, page_no):
266
267=== modified file 'tests/autopilot/ubuntu_docviewer_app/tests/test_toc.py'
268--- tests/autopilot/ubuntu_docviewer_app/tests/test_toc.py 2015-05-06 19:00:26 +0000
269+++ tests/autopilot/ubuntu_docviewer_app/tests/test_toc.py 2015-06-10 19:58:18 +0000
270@@ -27,8 +27,8 @@
271 ]
272
273 def setUp(self):
274+ self.filepath = 'ubuntu_docviewer_app/files/serverguide.pdf'
275 super(TestMainWindow, self).setUp()
276- self.filepath = 'ubuntu_docviewer_app/files/serverguide.pdf'
277
278 def test_go_to_chapters_in_toc(self):
279 """" Testing going to chapters from Table Of Contents """

Subscribers

People subscribed via source and target branches