Merge lp:~canonical-platform-qa/webbrowser-app/fix_base_class into lp:webbrowser-app

Proposed by Leo Arias on 2015-04-16
Status: Merged
Approved by: Olivier Tilloy on 2015-05-08
Approved revision: 970
Merged at revision: 1004
Proposed branch: lp:~canonical-platform-qa/webbrowser-app/fix_base_class
Merge into: lp:webbrowser-app
Diff against target: 107 lines (+29/-24)
3 files modified
tests/autopilot/webbrowser_app/__init__.py (+25/-1)
tests/autopilot/webbrowser_app/emulators/browser.py (+1/-18)
tests/autopilot/webbrowser_app/tests/__init__.py (+3/-5)
To merge this branch: bzr merge lp:~canonical-platform-qa/webbrowser-app/fix_base_class
Reviewer Review Type Date Requested Status
Olivier Tilloy 2015-04-16 Approve on 2015-05-08
PS Jenkins bot continuous-integration Needs Fixing on 2015-05-07
Christopher Lee (community) 2015-05-06 Approve on 2015-05-07
Review via email: mp+256519@code.launchpad.net

Commit Message

Fix the base class used when launching the app in autopilot tests.

Description of the Change

Using the common base class from the toolkit simplifies the inheritance of autopilot custom proxy objects. The tests are the same, but this allows us to make some changes on the autopilot registry.

To post a comment you must log in.
Olivier Tilloy (osomon) wrote :

LGTM.

review: Approve
Olivier Tilloy (osomon) wrote :

Un-approving. On my desktop, this breaks running one single test case. Running all test cases in one given file/class still works, but passing the fully-qualified name of a test case (e.g. webbrowser_app.tests.test_tabs.TestTabsView.test_switch_tabs) to `autopilot3 run` fails with the following error:

Traceback (most recent call last):
  File "/home/osomon/dev/phablet/browser/webbrowser-app/tests/autopilot/webbrowser_app/tests/test_tabs.py", line 36, in setUp
    super(TestTabsView, self).setUp()
  File "/home/osomon/dev/phablet/browser/webbrowser-app/tests/autopilot/webbrowser_app/tests/__init__.py", line 188, in setUp
    self.assert_home_page_eventually_loaded()
  File "/home/osomon/dev/phablet/browser/webbrowser-app/tests/autopilot/webbrowser_app/tests/__init__.py", line 191, in assert_home_page_eventually_loaded
    self.main_window.wait_until_page_loaded(self.url)
  File "/home/osomon/dev/phablet/browser/webbrowser-app/tests/autopilot/webbrowser_app/tests/__init__.py", line 109, in main_window
    return self.app.main_window
  File "/usr/lib/python3/dist-packages/autopilot/introspection/dbus.py", line 416, in __getattr__
    (self.__class__.__name__, name))
AttributeError: Class 'webbrowser-app' has no attribute 'main_window'.

review: Needs Fixing
Leo Arias (elopio) wrote :

That is a great catch, thanks!

Looking at this example, now I think that the top of the namespace should declare all the custom proxy objects that it exports, forcing them to get into the autopilot registry every time the package is imported.

I pushed a new version.

I'll add veebers to the reviewers to get his opinion.

970. By Leo Arias on 2015-05-06

Merged with trunk.

Christopher Lee (veebers) wrote :

My opinion is that autopilot shouldn't make it so you need to do a work around like this :-) Rest assured that this is a topic of discussion within the team and we hope to improve the story around that.

That being said this seems like a reasonable work around.

review: Approve
Olivier Tilloy (osomon) wrote :

Looks good to me now. Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/webbrowser_app/__init__.py'
2--- tests/autopilot/webbrowser_app/__init__.py 2014-02-06 04:31:01 +0000
3+++ tests/autopilot/webbrowser_app/__init__.py 2015-05-06 22:38:21 +0000
4@@ -1,6 +1,6 @@
5 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
6 #
7-# Copyright 2013 Canonical
8+# Copyright 2013-2015 Canonical
9 #
10 # This program is free software: you can redistribute it and/or modify it
11 # under the terms of the GNU General Public License version 3, as published
12@@ -15,3 +15,27 @@
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14
15 """webbrowser-app autopilot tests and emulators - top level package."""
16+
17+
18+import ubuntuuitoolkit as uitk
19+
20+from autopilot import introspection
21+
22+from webbrowser_app.emulators import browser
23+
24+
25+class Webbrowser(uitk.UbuntuUIToolkitCustomProxyObjectBase):
26+
27+ """Autopilot custom proxy object for the webbrowser app."""
28+
29+ @classmethod
30+ def validate_dbus_object(cls, path, state):
31+ name = introspection.get_classname_from_path(path)
32+ if name == b'webbrowser-app':
33+ if state['applicationName'][1] == 'webbrowser-app':
34+ return True
35+ return False
36+
37+ @property
38+ def main_window(self):
39+ return self.select_single(browser.Browser)
40
41=== modified file 'tests/autopilot/webbrowser_app/emulators/browser.py'
42--- tests/autopilot/webbrowser_app/emulators/browser.py 2015-04-22 10:25:42 +0000
43+++ tests/autopilot/webbrowser_app/emulators/browser.py 2015-05-06 22:38:21 +0000
44@@ -18,24 +18,7 @@
45
46 import autopilot.logging
47 import ubuntuuitoolkit as uitk
48-from autopilot import introspection
49-
50-
51-class Webbrowser(uitk.UbuntuUIToolkitCustomProxyObjectBase):
52-
53- """Autopilot custom proxy object for the webbrowser app."""
54-
55- @classmethod
56- def validate_dbus_object(cls, path, state):
57- name = introspection.get_classname_from_path(path)
58- if name == b'webbrowser-app':
59- if state['applicationName'][1] == 'webbrowser-app':
60- return True
61- return False
62-
63- @property
64- def main_window(self):
65- return self.select_single(Browser)
66+
67
68 logger = logging.getLogger(__name__)
69
70
71=== modified file 'tests/autopilot/webbrowser_app/tests/__init__.py'
72--- tests/autopilot/webbrowser_app/tests/__init__.py 2015-03-31 16:13:25 +0000
73+++ tests/autopilot/webbrowser_app/tests/__init__.py 2015-05-06 22:38:21 +0000
74@@ -31,8 +31,6 @@
75
76 import ubuntuuitoolkit as uitk
77
78-from webbrowser_app.emulators import browser
79-
80
81 class BrowserTestCaseBase(AutopilotTestCase):
82
83@@ -62,21 +60,21 @@
84 return self.launch_test_application(
85 self.local_location,
86 *self.ARGS,
87- emulator_base=browser.Webbrowser)
88+ emulator_base=uitk.UbuntuUIToolkitCustomProxyObjectBase)
89
90 def launch_test_installed(self):
91 if model() == 'Desktop':
92 return self.launch_test_application(
93 "webbrowser-app",
94 *self.ARGS,
95- emulator_base=browser.Webbrowser)
96+ emulator_base=uitk.UbuntuUIToolkitCustomProxyObjectBase)
97 else:
98 return self.launch_test_application(
99 "webbrowser-app",
100 self.d_f,
101 *self.ARGS,
102 app_type='qt',
103- emulator_base=browser.Webbrowser)
104+ emulator_base=uitk.UbuntuUIToolkitCustomProxyObjectBase)
105
106 def clear_datadir(self):
107 datadir = os.path.join(os.path.expanduser("~"), ".local", "share",

Subscribers

People subscribed via source and target branches

to status/vote changes: