Merge lp:~vrruiz/gallery-app/open-with-content-hub into lp:gallery-app

Proposed by Víctor R. Ruiz
Status: Needs review
Proposed branch: lp:~vrruiz/gallery-app/open-with-content-hub
Merge into: lp:gallery-app
Diff against target: 101 lines (+81/-0)
3 files modified
debian/control (+3/-0)
tests/autopilot/gallery_app/helpers.py (+51/-0)
tests/autopilot/gallery_app/tests/test_open_gallery.py (+27/-0)
To merge this branch: bzr merge lp:~vrruiz/gallery-app/open-with-content-hub
Reviewer Review Type Date Requested Status
Leo Arias (community) Needs Information
PS Jenkins bot continuous-integration Needs Fixing
Javier Collado Pending
Richard Huddie Pending
Review via email: mp+208438@code.launchpad.net

Commit message

Test to check that the gallery is opened by the content hub.

Description of the change

Test to check that the gallery is opened by the content hub.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Javier Collado (javier.collado) wrote :

Is there a way to check that the proxy object is the one that we expect?

If not, then I think I'd just remove the variable from the test, that is,
replace this:
gallery = helpers.open_gallery_with_content_hub()

with this:
helpers.open_gallery_with_content_hub()

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

We could do something like self.assertTrue(gallery.main_view.visible)
For that, you would need to apss the emulator base class parameter to get_proxy_object_for_existing_process.

We have a problem here because you are selecting the process manager with the bamf backend, that's not available on the phone. Will it work if you don't pass any preferred_backend so it chooses the right one?

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

Unmerged revisions

920. By Víctor R. Ruiz

Autopilot test to open the gallery app with the content hub

919. By Víctor R. Ruiz

Autopilot test to open the gallery app with the content hub

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2014-01-14 08:01:56 +0000
3+++ debian/control 2014-02-26 17:37:30 +0000
4@@ -52,6 +52,9 @@
5 libqt5test5,
6 ubuntu-ui-toolkit-autopilot,
7 unity8-autopilot,
8+ python-psutil,
9+ python-dbus,
10+ content-hub,
11 Description: Autopilot tests for the photo gallery for Ubuntu
12 gallery-app is a photo gallery for the Ubuntu platform. This package contains
13 autopilot tests for it.
14
15=== added file 'tests/autopilot/gallery_app/helpers.py'
16--- tests/autopilot/gallery_app/helpers.py 1970-01-01 00:00:00 +0000
17+++ tests/autopilot/gallery_app/helpers.py 2014-02-26 17:37:30 +0000
18@@ -0,0 +1,51 @@
19+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
20+# Copyright (C) 2014 Canonical
21+#
22+# This program is free software: you can redistribute it and/or modify
23+# it under the terms of the GNU General Public License as published by
24+# the Free Software Foundation, either version 3 of the License, or
25+# (at your option) any later version.
26+#
27+# This program is distributed in the hope that it will be useful,
28+# but WITHOUT ANY WARRANTY; without even the implied warranty of
29+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30+# GNU General Public License for more details.
31+#
32+# You should have received a copy of the GNU General Public License
33+# along with this program. If not, see <http://www.gnu.org/licenses/>.
34+
35+import dbus
36+from time import sleep
37+import psutil
38+
39+from autopilot import introspection
40+from autopilot.process import ProcessManager
41+
42+def open_gallery_with_content_hub():
43+ """ Opens the gallery-app with the content-hub """
44+ type_id = 'pictures'
45+ app_id = ''
46+ desktop_file = '/usr/share/applications/gallery-app.desktop'
47+
48+ process_manager = ProcessManager.create(preferred_backend='BAMF')
49+
50+ # Get session dbus
51+ session_dbus = dbus.SessionBus()
52+ proxy = session_dbus.get_object('com.ubuntu.content.dbus.Service', '/')
53+
54+ # Call content-hub to request a picture
55+ peer_id = proxy.DefaultPeerForType('pictures') # Returns 'gallery-app'
56+ object_path = proxy.CreateImportForTypeFromPeer(type_id, peer_id, app_id)
57+ proxy_transfer = session_dbus.get_object('com.ubuntu.content.dbus.Service', object_path)
58+ selection_type = proxy_transfer.SelectionType()
59+ store = proxy_transfer.Store()
60+ proxy_transfer.Start() # This opens the gallery app
61+
62+ # Wait until the application is open
63+ process_manager.wait_until_application_is_running(desktop_file, 10)
64+
65+ # Get and return app proxy
66+ gallery_process = next(p for p in psutil.get_process_list()
67+ if p.name == 'gallery-app')
68+ return introspection.get_proxy_object_for_existing_process(pid=gallery_process.pid)
69+
70
71=== added file 'tests/autopilot/gallery_app/tests/test_open_gallery.py'
72--- tests/autopilot/gallery_app/tests/test_open_gallery.py 1970-01-01 00:00:00 +0000
73+++ tests/autopilot/gallery_app/tests/test_open_gallery.py 2014-02-26 17:37:30 +0000
74@@ -0,0 +1,27 @@
75+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
76+# Copyright (C) 2014 Canonical
77+#
78+# This program is free software: you can redistribute it and/or modify
79+# it under the terms of the GNU General Public License as published by
80+# the Free Software Foundation, either version 3 of the License, or
81+# (at your option) any later version.
82+#
83+# This program is distributed in the hope that it will be useful,
84+# but WITHOUT ANY WARRANTY; without even the implied warranty of
85+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
86+# GNU General Public License for more details.
87+#
88+# You should have received a copy of the GNU General Public License
89+# along with this program. If not, see <http://www.gnu.org/licenses/>.
90+#
91+
92+import testtools
93+
94+from gallery_app import helpers
95+
96+class OpenGalleryTestCase(testtools.TestCase):
97+ """Test that opens the gallery"""
98+
99+ def test_open_gallery_with_content_hub(self):
100+ """Uses the content hub to open the gallery"""
101+ gallery = helpers.open_gallery_with_content_hub()

Subscribers

People subscribed via source and target branches