Merge lp:~elopio/ubuntu-filemanager-app/fix1188732-test_open_directory into lp:ubuntu-filemanager-app

Proposed by Leo Arias
Status: Merged
Approved by: Arto Jalkanen
Approved revision: 42
Merged at revision: 36
Proposed branch: lp:~elopio/ubuntu-filemanager-app/fix1188732-test_open_directory
Merge into: lp:ubuntu-filemanager-app
Diff against target: 314 lines (+208/-18)
6 files modified
README (+6/-8)
debian/control (+1/-0)
tests/autopilot/ubuntu_filemanager_app/emulators/main_window.py (+6/-4)
tests/autopilot/ubuntu_filemanager_app/emulators/ubuntusdk.py (+154/-0)
tests/autopilot/ubuntu_filemanager_app/tests/__init__.py (+7/-1)
tests/autopilot/ubuntu_filemanager_app/tests/test_filemanager.py (+34/-5)
To merge this branch: bzr merge lp:~elopio/ubuntu-filemanager-app/fix1188732-test_open_directory
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Arto Jalkanen Approve
Review via email: mp+169340@code.launchpad.net

Commit message

Added the test to open a directory.

To post a comment you must log in.
40. By Leo Arias

Added information about the label bug.

41. By Leo Arias

Factored the code to make the test dif.

42. By Leo Arias

Updated the README.

Revision history for this message
Arto Jalkanen (ajalkane) wrote :
Download full text (4.0 KiB)

Hi,

I had a problem running the tests on this merge requests. Do I miss some needed package (I installed python-mock that was added as new dependency)?

$ autopilot run ubuntu_filemanager_app
Loading tests from: /home/arto/coding/merge/fix1188732-test_open_directory/tests/autopilot

Tests running...
======================================================================
ERROR: ubuntu_filemanager_app.tests.test_filemanager.TestMainWindow.test_open_directory(with mouse)
----------------------------------------------------------------------
_StringException: Empty attachments:
  process-stdout

process-stderr: {{{
Loading testability driver.
Module 'org.nemomobile.folderlistmodel' does not contain a module identifier directive - it cannot be protected from external registrations.
QQmlComponent: Component is not ready
ToolbarActions.active property is DEPRECATED. Use opened instead.
ToolbarActions.lock property is DEPRECATED. Use locked instead.
}}}

Traceback (most recent call last):
  File "/home/arto/coding/merge/fix1188732-test_open_directory/tests/autopilot/ubuntu_filemanager_app/tests/test_filemanager.py", line 58, in test_open_directory
    sub_dir = self._make_directory_in_home()
  File "/home/arto/coding/merge/fix1188732-test_open_directory/tests/autopilot/ubuntu_filemanager_app/tests/test_filemanager.py", line 54, in _make_directory_in_home
    self.ubuntusdk.click_toolbar_button('Home')
  File "/home/arto/coding/merge/fix1188732-test_open_directory/tests/autopilot/ubuntu_filemanager_app/emulators/ubuntusdk.py", line 87, in click_toolbar_button
    self.autopilot.pointing_device.click_object(button)
  File "/usr/lib/python2.7/dist-packages/autopilot/input/__init__.py", line 506, in click_object
    self.move_to_object(object_proxy)
  File "/usr/lib/python2.7/dist-packages/autopilot/input/__init__.py", line 523, in move_to_object
    x,y = get_center_point(object_proxy)
  File "/usr/lib/python2.7/dist-packages/autopilot/input/_common.py", line 56, in get_center_point
    raise ValueError("Object '%r' does not have any recognised position attributes" % object_proxy)
ValueError: Object 'None' does not have any recognised position attributes

======================================================================
ERROR: ubuntu_filemanager_app.tests.test_filemanager.TestMainWindow.test_toolbar_shows(with mouse)
----------------------------------------------------------------------
_StringException: Empty attachments:
  process-stdout

process-stderr: {{{
Loading testability driver.
Module 'org.nemomobile.folderlistmodel' does not contain a module identifier directive - it cannot be protected from external registrations.
QQmlComponent: Component is not ready
ToolbarActions.active property is DEPRECATED. Use opened instead.
ToolbarActions.lock property is DEPRECATED. Use locked instead.
}}}

Traceback (most recent call last):
  File "/home/arto/coding/merge/fix1188732-test_open_directory/tests/autopilot/ubuntu_filemanager_app/tests/test_filemanager.py", line 41, in test_toolbar_shows
    self._make_directory_in_home()
  File "/home/arto/coding/merge/fix1188732-test_open_directory/tests/autopilot/ubuntu_filemanager_app/tests/test_filemanager....

Read more...

review: Needs Information
Revision history for this message
Leo Arias (elopio) wrote :

"Object 'None' does not have any recognised position attributes"

This means your test is not finding the home button. I'm on saucy, and it works here. You are on raring, right?
I'll fire up a vm to see what's going on.

These warning you re getting don't look nice, I'll check if I'm getting that too:
QQmlComponent: Component is not ready
ToolbarActions.active property is DEPRECATED. Use opened instead.
ToolbarActions.lock property is DEPRECATED. Use locked instead.

Revision history for this message
Arto Jalkanen (ajalkane) wrote :

Thanks for checking it. I am indeed in raring, so I guess it's an issue only there.

Revision history for this message
Arto Jalkanen (ajalkane) wrote :

This was a problem in my own environment. I have now successfully managed to run the autopilot tests. Thank you for the great work!

review: Approve
Revision history for this message
Leo Arias (elopio) wrote :

woohoo.
Sorry I got caught up last week on other tasks.

Thanks for the review.
--
¡paz y baile!
http://one.ubuntu.com

Revision history for this message
Arto Jalkanen (ajalkane) wrote :

Well, it's a good thing you got caught up on other tasks, as this one would have been just time wasted for you :).

If you can continue the excellent work on other tests when time permits, that'd be great!

Revision history for this message
Leo Arias (elopio) wrote :

Arto, I can't merge the branch. Can you please do it for me?

Revision history for this message
Arto Jalkanen (ajalkane) wrote :

Umm... Normally Jenkins gives his approval and then it's merged. I wonder why it's not happening. I'll try marking this manually as approved.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README'
2--- README 2013-04-15 19:50:55 +0000
3+++ README 2013-06-14 05:57:27 +0000
4@@ -1,15 +1,13 @@
5 Prerequisites
6 =============
7
8-Folderlistmodel plugin must be built and installed before running.
9-
10-Currently it can be obtained like this:
11-
12-bzr branch lp:~carlos-mazieri/ubuntu-filemanager-app/model
13+The package qtdeclarative5-nemo-qml-plugins-folderlistmodel must be installed
14+before running.
15+
16+Currently it can be obtained from
17+https://launchpad.net/~ubuntu-touch-coreapps-drivers/+archive/daily
18
19 Running filemanager
20 ===================
21
22-qmlscene filemanager.qml
23-
24-
25+qmlscene ubuntu-filemanager-app.qml
26
27=== modified file 'debian/control'
28--- debian/control 2013-05-31 12:23:54 +0000
29+++ debian/control 2013-06-14 05:57:27 +0000
30@@ -22,6 +22,7 @@
31 Architecture: all
32 Depends: libautopilot-qt,
33 libqt5test5,
34+ python-mock,
35 ubuntu-filemanager-app (= ${source:Version})
36 Description: Autopilot tests for File Manager Application
37 This package contains the autopilot tests for the File Manager
38
39=== modified file 'tests/autopilot/ubuntu_filemanager_app/emulators/main_window.py'
40--- tests/autopilot/ubuntu_filemanager_app/emulators/main_window.py 2013-05-31 12:23:54 +0000
41+++ tests/autopilot/ubuntu_filemanager_app/emulators/main_window.py 2013-06-14 05:57:27 +0000
42@@ -16,13 +16,15 @@
43 def __init__(self, app):
44 self.app = app
45
46- def get_qml_view(self):
47- """Get the main QML view"""
48- return self.app.select_single("QQuickView")
49-
50 def get_folder(self, index):
51 """Returns the list view folder with index number."""
52 return self.app.select_many("Subtitled")[index]
53
54 def get_action_popover(self):
55 return self.app.select_single("ActionSelectionPopover")
56+
57+ def get_current_folder_name(self):
58+ # XXX the label with the folder name doesn't have an objectName.
59+ # See bug #1190855.
60+ return self.app.select_single('FolderListView').select_many(
61+ 'Label')[0].text
62
63=== added file 'tests/autopilot/ubuntu_filemanager_app/emulators/ubuntusdk.py'
64--- tests/autopilot/ubuntu_filemanager_app/emulators/ubuntusdk.py 1970-01-01 00:00:00 +0000
65+++ tests/autopilot/ubuntu_filemanager_app/emulators/ubuntusdk.py 2013-06-14 05:57:27 +0000
66@@ -0,0 +1,154 @@
67+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
68+#
69+# Copyright (C) 2013 Canonical Ltd
70+#
71+# This program is free software: you can redistribute it and/or modify
72+# it under the terms of the GNU General Public License version 3 as
73+# published by the Free Software Foundation.
74+#
75+# This program is distributed in the hope that it will be useful,
76+# but WITHOUT ANY WARRANTY; without even the implied warranty of
77+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
78+# GNU General Public License for more details.
79+#
80+# You should have received a copy of the GNU General Public License
81+# along with this program. If not, see <http://www.gnu.org/licenses/>.
82+#
83+# Authored by: Nicholas Skaggs <nicholas.skaggs@canonical.com>
84+
85+from testtools.matchers import Equals, NotEquals, Not, Is
86+from autopilot.matchers import Eventually
87+
88+class ubuntusdk(object):
89+ """An emulator class that makes it easy to interact with the ubuntu sdk applications."""
90+
91+ def __init__(self, autopilot, app):
92+ self.app = app
93+ self.autopilot = autopilot
94+
95+ def get_qml_view(self):
96+ """Get the main QML view"""
97+ return self.app.select_single("QQuickView")
98+
99+ def get_object(self, typeName, name):
100+ """Get a specific object"""
101+ return self.app.select_single(typeName, objectName=name)
102+
103+ def get_objects(self, typeName, name):
104+ """Get more than one object"""
105+ return self.app.select_many(typeName, objectName=name)
106+
107+ def switch_to_tab(self, tab):
108+ """Switch to the specified tab number"""
109+ tabs = self.get_tabs()
110+ currentTab = tabs.selectedTabIndex
111+
112+ #perform operations until tab == currentTab
113+ while tab != currentTab:
114+ if tab > currentTab:
115+ self._previous_tab()
116+ if tab < currentTab:
117+ self._next_tab()
118+ currentTab = tabs.selectedTabIndex
119+
120+ def toggle_toolbar(self):
121+ """Toggle the toolbar between revealed and hidden"""
122+ #check and see if the toolbar is open or not
123+ if self.get_toolbar().opened:
124+ self.hide_toolbar()
125+ else:
126+ self.open_toolbar()
127+
128+ def get_toolbar(self):
129+ """Returns the toolbar in the main events view."""
130+ return self.app.select_single("Toolbar")
131+
132+ def get_toolbar_button(self, buttonLabel):
133+ """Returns the toolbar button at position index"""
134+ toolbar = self.get_toolbar()
135+ if not toolbar.opened:
136+ self.open_toolbar()
137+ row = toolbar.select_single("QQuickRow")
138+ loaderList = row.select_many("QQuickLoader")
139+ for loader in loaderList:
140+ buttonList = loader.select_many("Button")
141+ for button in buttonList:
142+ if button.text == buttonLabel:
143+ return button
144+
145+ def click_toolbar_button(self, buttonLabel):
146+ """Clicks the toolbar button with buttonLabel"""
147+ #The toolbar button is assumed to be the following format
148+ #ToolbarActions {
149+ # Action {
150+ # objectName: "name"
151+ # text: value
152+ button = self.get_toolbar_button(buttonLabel)
153+ self.autopilot.pointing_device.click_object(button)
154+
155+ def open_toolbar(self):
156+ """Open the toolbar"""
157+ qmlView = self.get_qml_view()
158+
159+ lineX = qmlView.x + qmlView.width * 0.50
160+ startY = qmlView.y + qmlView.height - 1
161+ stopY = qmlView.y + qmlView.height * 0.95
162+
163+ self.autopilot.pointing_device.drag(lineX, startY, lineX, stopY)
164+
165+ def hide_toolbar(self):
166+ """Hide the toolbar"""
167+ qmlView = self.get_qml_view()
168+
169+ lineX = qmlView.x + qmlView.width * 0.50
170+ startY = qmlView.y + qmlView.height * 0.95
171+ stopY = qmlView.y + qmlView.height - 1
172+
173+ self.autopilot.pointing_device.drag(lineX, startY, lineX, stopY)
174+
175+ def set_popup_value(self, popover, button, value):
176+ """Changes the given popover selector to the request value
177+ At the moment this only works for values that are currently visible. To
178+ access the remaining items, a help method to drag and recheck is needed."""
179+ #The popover is assumed to be the following format
180+ # Popover {
181+ # Column {
182+ # ListView {
183+ # delegate: Standard {
184+ # objectName: "name"
185+ # text: value
186+
187+ self.autopilot.pointing_device.click_object(button)
188+ #we'll get all matching objects, incase the popover is reused between buttons
189+ itemList = lambda: self.get_objects("Standard", popover)
190+
191+ for item in itemList():
192+ if item.get_properties()['text'] == value:
193+ self.autopilot.pointing_device.click_object(item)
194+
195+ def get_tabs(self):
196+ """Return all tabs"""
197+ return self.get_object("Tabs", "rootTabs")
198+
199+ def _previous_tab(self):
200+ """Switch to the previous tab"""
201+ qmlView = self.get_qml_view()
202+
203+ startX = qmlView.x + qmlView.width * 0.35
204+ stopX = qmlView.x + qmlView.width * 0.50
205+ lineY = qmlView.y + qmlView.height * 0.05
206+
207+ self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY)
208+ self.autopilot.pointing_device.click()
209+ self.autopilot.pointing_device.click()
210+
211+ def _next_tab(self):
212+ """Switch to the next tab"""
213+ qmlView = self.get_qml_view()
214+
215+ startX = qmlView.x + qmlView.width * 0.50
216+ stopX = qmlView.x + qmlView.width * 0.35
217+ lineY = qmlView.y + qmlView.height * 0.05
218+
219+ self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY)
220+ self.autopilot.pointing_device.click()
221
222=== modified file 'tests/autopilot/ubuntu_filemanager_app/tests/__init__.py'
223--- tests/autopilot/ubuntu_filemanager_app/tests/__init__.py 2013-05-31 12:23:54 +0000
224+++ tests/autopilot/ubuntu_filemanager_app/tests/__init__.py 2013-06-14 05:57:27 +0000
225@@ -16,6 +16,7 @@
226 from time import sleep
227
228 from ubuntu_filemanager_app.emulators.main_window import MainWindow
229+from ubuntu_filemanager_app.emulators.ubuntusdk import ubuntusdk
230
231
232 class FileManagerTestCase(AutopilotTestCase):
233@@ -49,7 +50,8 @@
234 self.app = self.launch_test_application(
235 "qmlscene",
236 "/usr/share/ubuntu-filemanager-app/ubuntu-filemanager-app.qml",
237- "--desktop_file_hint=/usr/share/applications/ubuntu-filemanager-app.desktop",
238+ "--desktop_file_hint="
239+ "/usr/share/applications/ubuntu-filemanager-app.desktop",
240 app_type='qt')
241
242 def tap_item(self, item):
243@@ -61,3 +63,7 @@
244 @property
245 def main_window(self):
246 return MainWindow(self.app)
247+
248+ @property
249+ def ubuntusdk(self):
250+ return ubuntusdk(self, self.app)
251
252=== modified file 'tests/autopilot/ubuntu_filemanager_app/tests/test_filemanager.py'
253--- tests/autopilot/ubuntu_filemanager_app/tests/test_filemanager.py 2013-05-31 12:23:54 +0000
254+++ tests/autopilot/ubuntu_filemanager_app/tests/test_filemanager.py 2013-06-14 05:57:27 +0000
255@@ -9,6 +9,12 @@
256
257 from __future__ import absolute_import
258
259+import tempfile
260+
261+import mock
262+import os
263+import shutil
264+
265 from autopilot.matchers import Eventually
266 from testtools.matchers import Equals
267
268@@ -18,18 +24,41 @@
269 class TestMainWindow(FileManagerTestCase):
270
271 def setUp(self):
272+ self._patch_home()
273 super(TestMainWindow, self).setUp()
274 self.assertThat(
275- self.main_window.get_qml_view().visible, Eventually(Equals(True)))
276+ self.ubuntusdk.get_qml_view().visible, Eventually(Equals(True)))
277
278- def tearDown(self):
279- super(TestMainWindow, self).tearDown()
280+ def _patch_home(self):
281+ temp_dir = tempfile.mkdtemp()
282+ self.addCleanup(shutil.rmtree, temp_dir)
283+ patcher = mock.patch.dict('os.environ', {'HOME': temp_dir})
284+ patcher.start()
285+ self.addCleanup(patcher.stop)
286
287 def test_toolbar_shows(self):
288- """Make sure that dragging from the bottom reveals the hidden
289- toolbar."""
290+ """Dragging from the bottom reveals the hidden toolbar."""
291+ self._make_directory_in_home()
292+
293 first_folder = self.main_window.get_folder(0)
294 self.tap_item(first_folder)
295
296 action_popover = self.main_window.get_action_popover()
297 self.assertThat(lambda: action_popover.opacity, Eventually(Equals(1)))
298+
299+ def _make_directory_in_home(self):
300+ path = tempfile.mkdtemp(dir=os.environ['HOME'])
301+ # Currently, we need to open again the home folder to show the newly
302+ # created one. See bug #1190676.
303+ # TODO when the bug is fixed, remove the next line.
304+ self.ubuntusdk.click_toolbar_button('Home')
305+ return path
306+
307+ def test_open_directory(self):
308+ sub_dir = self._make_directory_in_home()
309+
310+ first_folder = self.main_window.get_folder(0)
311+ self.pointing_device.click_object(first_folder)
312+ self.assertThat(
313+ self.main_window.get_current_folder_name,
314+ Eventually(Equals(sub_dir)))

Subscribers

People subscribed via source and target branches