Merge lp:~bzoltan/ubuntu-ui-toolkit/landing_28-05 into lp:ubuntu-ui-toolkit

Proposed by Zoltan Balogh
Status: Merged
Merged at revision: 1027
Proposed branch: lp:~bzoltan/ubuntu-ui-toolkit/landing_28-05
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 594 lines (+241/-82)
16 files modified
components.api (+7/-1)
modules/Ubuntu/Components/AnimatedItem.qml (+1/-38)
modules/Ubuntu/Components/ListItems/Base.qml (+1/-1)
modules/Ubuntu/Components/PageStack.qml (+1/-0)
modules/Ubuntu/Components/Pickers/DatePicker.qml (+4/-2)
modules/Ubuntu/Components/plugin/i18n.cpp (+6/-5)
modules/Ubuntu/Components/plugin/thumbnailgenerator.cpp (+6/-3)
tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_common.py (+16/-0)
tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_flickable.py (+0/-17)
tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_header.py (+2/-9)
tests/autopilot/ubuntuuitoolkit/fixture_setup.py (+45/-0)
tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/CustomMainView.qml (+23/-0)
tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.HeaderInCustomMainViewTestCase.qml (+24/-0)
tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.py (+27/-0)
tests/autopilot/ubuntuuitoolkit/tests/test_fixture_setup.py (+72/-1)
tests/qmlapicheck.py (+6/-5)
To merge this branch: bzr merge lp:~bzoltan/ubuntu-ui-toolkit/landing_28-05
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Zsombor Egri Pending
Review via email: mp+221199@code.launchpad.net

Commit message

[ Christian Dywan ]
  * Tweak API parsing to include the Button.font property.
    Fixes: https://bugs.launchpad.net/bugs/1322169
  * Call bindtextdomain on /usr if APP_DIR is not defined.
    Fixes: https://bugs.launchpad.net/bugs/1322630
  * More unit tests and property corrections for SortFilterModel.
  * Read ubuntu-ui-toolkit.ini from $XDG_CONFIG_HOME.
  * Skip test_ubuntushape which is flakey and add a FIXME.

  [ Zsombor Egri ]
  * Missing "default" keyword added to children property of Base,
    causing rendering and test case failures on Qt 5.3.
    Fixes: https://bugs.launchpad.net/bugs/1317881

  [ Ugo Riboni ]
  * Allow requesting extra large thumbnails.

  [ Florian Boucault ]
  * AnimatedItem: deprecated as it was not used and still costly.
  * Label: default font weight is now light.

  [ Zoltán Balogh ]
  * Replace split with match to work around failing split()
    function usage.

Description of the change

[ Christian Dywan ]
  * Tweak API parsing to include the Button.font property.
    Fixes: https://bugs.launchpad.net/bugs/1322169
  * Call bindtextdomain on /usr if APP_DIR is not defined.
    Fixes: https://bugs.launchpad.net/bugs/1322630
  * More unit tests and property corrections for SortFilterModel.
  * Read ubuntu-ui-toolkit.ini from $XDG_CONFIG_HOME.
  * Skip test_ubuntushape which is flakey and add a FIXME.

  [ Zsombor Egri ]
  * Missing "default" keyword added to children property of Base,
    causing rendering and test case failures on Qt 5.3.
    Fixes: https://bugs.launchpad.net/bugs/1317881

  [ Ugo Riboni ]
  * Allow requesting extra large thumbnails.

  [ Florian Boucault ]
  * AnimatedItem: deprecated as it was not used and still costly.
  * Label: default font weight is now light.

  [ Zoltán Balogh ]
  * Replace split with match to work around failing split()
    function usage.

To post a comment you must log in.
1088. By Zoltan Balogh

Merged from the trunk

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
1089. By Zoltan Balogh

Undo changes of r1082 that cause a regression in messaging-app (and contenthub).

Revision history for this message
Tim Peeters (tpeeters) wrote :

I removed the change that was reverted from the commit message

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
1090. By Zoltan Balogh

On the autopilot Header helper, do not assume that the top container will be a MainView

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Leo Arias (elopio) wrote :

I've confirmed that this landing fixes bug 1324556.
I flashed image 55, ran the gallery tests without the ppa and got the failure.
Then I added the PPA and ran the gallery tests again successfully.
Please note that phablet-test-setup adds an ubuntuuitoolkit folder to /home/phablet/autopilot. That's not the one that comes from the ppa, so you'll need to delete that folder and install ubuntu-ui-toolkit-autopilot.

Revision history for this message
Tim Peeters (tpeeters) wrote :

Running gallery-app tests from image 55 without the ppa fails big time: http://paste.ubuntu.com/7551664/

I cleared /home/phablet/autopilot, installed the ppa and did another phablet-click-test-setup, which failed because the new uitk-autopilot is not in the archive I guess? http://pastebin.ubuntu.com/7551635/

Installing ubuntu-ui-toolkit-autopilot using apt-get worked, but
phablet-click-test-setup --click com.ubuntu.gallery; fails as above^ missing the uitk-autopilot tests...

Revision history for this message
Tim Peeters (tpeeters) wrote :

After installing the new ubuntu-ui-toolkit-autopilot and manually pushing the autopilot directory of gallery-app to the device (since the scripts don't work here, see previous comment), all gallery-app tests pass! http://paste.ubuntu.com/7551949/

1091. By Zoltan Balogh

Fix changelog

1092. By Zoltan Balogh

Fix changelog

1093. By Zoltan Balogh

Fix changelog

1094. By Zoltan Balogh

Fix changelog

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'components.api'
2--- components.api 2014-05-26 11:36:53 +0000
3+++ components.api 2014-06-02 11:30:26 +0000
4@@ -31,6 +31,7 @@
5 AbstractButton
6 property color color
7 property Gradient gradient
8+ property font font
9 property string iconPosition
10 CheckBox 0.1 1.0
11 AbstractButton
12@@ -94,7 +95,7 @@
13 property real __leftIconMargin
14 property real __rightIconMargin
15 property bool __iconIsItem
16- property internal children
17+ default property internal children
18 Caption 0.1 1.0
19 Item
20 property string text
21@@ -140,6 +141,7 @@
22 property bool expanded
23 property bool multiSelection
24 property bool colourImage
25+ property Component delegate
26 property real containerHeight
27 property int selectedIndex
28 property bool currentlyExpanded
29@@ -204,12 +206,14 @@
30 Object 0.1 1.0
31 QtObject
32 default property internal children
33+ property list<QtObject> __defaultPropertyFix
34 OptionSelector 0.1 1.0
35 ListItem.Empty
36 property var model
37 property bool expanded
38 property bool multiSelection
39 property bool colourImage
40+ property Component delegate
41 property real containerHeight
42 property int selectedIndex
43 property bool currentlyExpanded
44@@ -235,6 +239,7 @@
45 Page 0.1 1.0
46 PageTreeNode
47 property string title
48+ property Item tools
49 property Item __customHeaderContents
50 property Flickable flickable
51 property list<Action> actions
52@@ -355,6 +360,7 @@
53 OrientationHelper
54 property Item dismissArea
55 property bool grabDismissAreaEvents
56+ property PropertyAnimation fadingAnimation
57 function show()
58 function hide()
59 function __closeIfHidden()
60
61=== modified file 'modules/Ubuntu/Components/AnimatedItem.qml'
62--- modules/Ubuntu/Components/AnimatedItem.qml 2014-04-23 08:50:20 +0000
63+++ modules/Ubuntu/Components/AnimatedItem.qml 2014-06-02 11:30:26 +0000
64@@ -30,45 +30,8 @@
65 id: root
66 /*!
67 \preliminary
68+ \deprecated
69 Specifies whether the component is on the visible area of the Flickable or not.
70 */
71 property bool onScreen: true
72-
73- QtObject {
74- id: internal
75- property Flickable flickable
76-
77- // returns whether the component is in the visible area of the flickable
78- function checkOnScreen()
79- {
80- var pos = root.mapToItem(flickable, 0, 0)
81- root.onScreen = (pos.y + root.height >= 0) && (pos.y <= internal.flickable.height) &&
82- (pos.x + root.width >= 0) && (pos.x <= internal.flickable.width)
83- }
84- // lookup for a flickable parent
85- function updateFlickableParent()
86- {
87- var flickable = root.parent
88- while (flickable) {
89- if (flickable.hasOwnProperty("flicking") && flickable.hasOwnProperty("flickableDirection")) {
90- // non-interactive flickables must be skipped as those do not provide
91- // on-screen detection support
92- if (flickable.interactive)
93- break
94- }
95- flickable = flickable.parent
96- }
97- internal.flickable = flickable
98- }
99- }
100-
101- Connections {
102- target: internal.flickable
103-
104- onContentXChanged: internal.checkOnScreen()
105- onContentYChanged: internal.checkOnScreen()
106- }
107-
108- Component.onCompleted: internal.updateFlickableParent()
109- onParentChanged: internal.updateFlickableParent()
110 }
111
112=== modified file 'modules/Ubuntu/Components/ListItems/Base.qml'
113--- modules/Ubuntu/Components/ListItems/Base.qml 2014-04-28 19:24:56 +0000
114+++ modules/Ubuntu/Components/ListItems/Base.qml 2014-06-02 11:30:26 +0000
115@@ -159,7 +159,7 @@
116 /*!
117 \internal
118 */
119- property alias children: middle.data
120+ default property alias children: middle.data
121 Item {
122 id: middle
123 property bool anchorToIconHelper: !__iconIsItem && iconHelper.source != ""
124
125=== modified file 'modules/Ubuntu/Components/PageStack.qml'
126--- modules/Ubuntu/Components/PageStack.qml 2014-05-13 09:09:35 +0000
127+++ modules/Ubuntu/Components/PageStack.qml 2014-06-02 11:30:26 +0000
128@@ -192,6 +192,7 @@
129 */
130 default property alias data: inactiveNode.data
131 PageTreeNode {
132+ anchors.fill: parent
133 id: inactiveNode
134 active: false
135 }
136
137=== modified file 'modules/Ubuntu/Components/Pickers/DatePicker.qml'
138--- modules/Ubuntu/Components/Pickers/DatePicker.qml 2014-05-07 10:42:31 +0000
139+++ modules/Ubuntu/Components/Pickers/DatePicker.qml 2014-06-02 11:30:26 +0000
140@@ -523,7 +523,8 @@
141 function updatePickers() {
142 if (completed) {
143 // check mode flags first
144- var modes = datePicker.mode.split(/\W/g);
145+ // FIXME: The js split(/\W/g) terminates the process on armhf with Qt 5.3 (v4 js) (https://bugreports.qt-project.org/browse/QTBUG-39255)
146+ var modes = datePicker.mode.match(/\w+/g);
147
148 showYearPicker = showMonthPicker = showDayPicker =
149 showHoursPicker = showMinutesPicker = showSecondsPicker = false;
150@@ -607,7 +608,8 @@
151 completed = false;
152
153 // use short format to exclude any extra characters
154- var format = datePicker.locale.dateFormat(Locale.ShortFormat).split(/\W/g);
155+ // FIXME: The js split(/\W/g) terminates the process on armhf with Qt 5.3 (v4 js) (https://bugreports.qt-project.org/browse/QTBUG-39255)
156+ var format = datePicker.locale.dateFormat(Locale.ShortFormat).match(/\w+/g);
157 // loop through the format to decide the position of the tumbler
158 var formatIndex = 0;
159 for (var i in format) {
160
161=== modified file 'modules/Ubuntu/Components/plugin/i18n.cpp'
162--- modules/Ubuntu/Components/plugin/i18n.cpp 2014-05-22 15:54:13 +0000
163+++ modules/Ubuntu/Components/plugin/i18n.cpp 2014-06-02 11:30:26 +0000
164@@ -103,13 +103,14 @@
165 /*
166 The default is /usr/share/locale if we don't set a folder
167 For click we use APP_DIR/share/locale
168- eg. /usr/share/click/preinstalled/com.example.foo/current/share/locale
169+ e.g. /usr/share/click/preinstalled/com.example.foo/current/share/locale
170 */
171- QDir appDir(getenv("APP_DIR"));
172- if (appDir.exists()) {
173- QString localePath(appDir.filePath("share/locale"));
174- C::bindtextdomain(domain.toUtf8(), localePath.toUtf8());
175+ QString appDir(getenv("APP_DIR"));
176+ if (!QDir::isAbsolutePath (appDir)) {
177+ appDir = "/usr";
178 }
179+ QString localePath(QDir(appDir).filePath("share/locale"));
180+ C::bindtextdomain(domain.toUtf8(), localePath.toUtf8());
181 Q_EMIT domainChanged();
182 }
183
184
185=== modified file 'modules/Ubuntu/Components/plugin/thumbnailgenerator.cpp'
186--- modules/Ubuntu/Components/plugin/thumbnailgenerator.cpp 2014-02-25 09:14:23 +0000
187+++ modules/Ubuntu/Components/plugin/thumbnailgenerator.cpp 2014-06-02 11:30:26 +0000
188@@ -43,12 +43,15 @@
189 * is the only way around the issue for now. */
190 std::string src_path(QUrl(id).path().toUtf8().data());
191 std::string tgt_path;
192+ const int xlarge_cutoff = 512;
193+ const int large_cutoff = 256;
194+ const int small_cutoff = 128;
195 try {
196 ThumbnailSize desiredSize;
197- const int large_cutoff = 256;
198- const int small_cutoff = 128;
199- if(requestedSize.width() > large_cutoff || requestedSize.height() > large_cutoff) {
200+ if(requestedSize.width() > xlarge_cutoff || requestedSize.height() > xlarge_cutoff) {
201 desiredSize = TN_SIZE_ORIGINAL;
202+ } else if(requestedSize.width() > large_cutoff || requestedSize.height() > large_cutoff) {
203+ desiredSize = TN_SIZE_XLARGE;
204 } else if(requestedSize.width() > small_cutoff || requestedSize.height() > small_cutoff) {
205 desiredSize = TN_SIZE_LARGE;
206 } else {
207
208=== modified file 'tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_common.py'
209--- tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_common.py 2014-04-29 23:03:58 +0000
210+++ tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_common.py 2014-06-02 11:30:26 +0000
211@@ -111,3 +111,19 @@
212 raise ToolkitException(
213 "The element is not contained in a Flickable so it can't be "
214 "swiped into view.")
215+
216+ def _get_top_container(self):
217+ """Return the top-most container with a globalRect."""
218+ root = self.get_root_instance()
219+ parent = self.get_parent()
220+ top_container = None
221+ while parent.id != root.id:
222+ if hasattr(parent, 'globalRect'):
223+ top_container = parent
224+
225+ parent = parent.get_parent()
226+
227+ if top_container is None:
228+ raise ToolkitException('Could not find the top-most container.')
229+ else:
230+ return top_container
231
232=== modified file 'tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_flickable.py'
233--- tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_flickable.py 2014-05-20 07:31:55 +0000
234+++ tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_flickable.py 2014-06-02 11:30:26 +0000
235@@ -51,23 +51,6 @@
236 containers = [self._get_top_container(), self]
237 return containers
238
239- def _get_top_container(self):
240- """Return the top-most container with a globalRect."""
241- root = self.get_root_instance()
242- parent = self.get_parent()
243- top_container = None
244- while parent.id != root.id:
245- if hasattr(parent, 'globalRect'):
246- top_container = parent
247-
248- parent = parent.get_parent()
249-
250- if top_container is None:
251- raise _common.ToolkitException(
252- "Couldn't find the top-most container.")
253- else:
254- return top_container
255-
256 def _is_child_visible(self, child, containers):
257 """Check if the center of the child is visible.
258
259
260=== modified file 'tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_header.py'
261--- tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_header.py 2014-05-13 12:43:31 +0000
262+++ tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_header.py 2014-06-02 11:30:26 +0000
263@@ -21,7 +21,6 @@
264
265 from ubuntuuitoolkit._custom_proxy_objects import (
266 _common,
267- _mainview,
268 _tabbar
269 )
270
271@@ -35,13 +34,6 @@
272 class Header(_common.UbuntuUIToolkitCustomProxyObjectBase):
273 """Header Autopilot emulator."""
274
275- def __init__(self, *args):
276- super(Header, self).__init__(*args)
277- # XXX we need a better way to keep reference to the main view.
278- # --elopio - 2014-02-26
279- self.main_view = self.get_root_instance().select_single(
280- _mainview.MainView)
281-
282 def _show_if_not_visible(self):
283 if not self._is_visible():
284 self._show()
285@@ -53,8 +45,9 @@
286 # FIXME This will fail if the header is not linked to a flickable that
287 # fills the main view. The header has a flickable property but it
288 # can't be read by autopilot. See bug http://pad.lv/1318829
289+ top_container = self._get_top_container()
290 start_x = stop_x = (self.globalRect.x + self.globalRect.width) // 2
291- start_y = self.main_view.globalRect.y + 5
292+ start_y = top_container.globalRect.y + 5
293 stop_y = start_y + self.globalRect.height
294 self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
295 self.y.wait_for(0)
296
297=== modified file 'tests/autopilot/ubuntuuitoolkit/fixture_setup.py'
298--- tests/autopilot/ubuntuuitoolkit/fixture_setup.py 2014-04-23 08:50:20 +0000
299+++ tests/autopilot/ubuntuuitoolkit/fixture_setup.py 2014-06-02 11:30:26 +0000
300@@ -16,6 +16,7 @@
301
302 import copy
303 import os
304+import shutil
305 import tempfile
306
307 import fixtures
308@@ -118,3 +119,47 @@
309 original_value)
310 else:
311 self.addCleanup(environment.unset_initctl_env_var, variable)
312+
313+
314+class FakeHome(fixtures.Fixture):
315+
316+ # We copy the Xauthority file to allow executions using XVFB. If it is not
317+ # on the user's HOME directory, nothing will happen.
318+ should_copy_xauthority_file = True
319+
320+ def __init__(self, directory=None):
321+ super(FakeHome, self).__init__()
322+ self.directory = directory
323+
324+ def setUp(self):
325+ super(FakeHome, self).setUp()
326+ self.directory = self._make_directory_if_not_specified()
327+ if self.should_copy_xauthority_file:
328+ self._copy_xauthority_file(self.directory)
329+ # We patch both environment variables so it works on the desktop and on
330+ # the phone.
331+ self.useFixture(
332+ InitctlEnvironmentVariable(HOME=self.directory))
333+ self.useFixture(
334+ fixtures.EnvironmentVariable('HOME', newvalue=self.directory))
335+
336+ def _make_directory_if_not_specified(self):
337+ if self.directory is None:
338+ parent_directory = os.path.join(
339+ os.environ.get('HOME'), 'autopilot', 'fakeenv')
340+ if not os.path.exists(parent_directory):
341+ os.makedirs(parent_directory)
342+ temp_dir_fixture = fixtures.TempDir(parent_directory)
343+ self.useFixture(temp_dir_fixture)
344+ return temp_dir_fixture.path
345+ else:
346+ return self.directory
347+
348+ def _copy_xauthority_file(self, directory):
349+ """Copy the .Xauthority file if it exists in the user's home."""
350+ xauthority_file_path = os.path.join(
351+ os.environ.get('HOME'), '.Xauthority')
352+ if os.path.isfile(xauthority_file_path):
353+ shutil.copyfile(
354+ xauthority_file_path,
355+ os.path.join(directory, '.Xauthority'))
356
357=== added file 'tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/CustomMainView.qml'
358--- tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/CustomMainView.qml 1970-01-01 00:00:00 +0000
359+++ tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/CustomMainView.qml 2014-06-02 11:30:26 +0000
360@@ -0,0 +1,23 @@
361+/*
362+ * Copyright 2014 Canonical Ltd.
363+ *
364+ * This program is free software; you can redistribute it and/or modify
365+ * it under the terms of the GNU Lesser General Public License as published by
366+ * the Free Software Foundation; version 3.
367+ *
368+ * This program is distributed in the hope that it will be useful,
369+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
370+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
371+ * GNU Lesser General Public License for more details.
372+ *
373+ * You should have received a copy of the GNU Lesser General Public License
374+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
375+ */
376+
377+import QtQuick 2.0
378+import Ubuntu.Components 0.1
379+
380+MainView {
381+ objectName: "overview"
382+ property string test
383+}
384
385=== added file 'tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.HeaderInCustomMainViewTestCase.qml'
386--- tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.HeaderInCustomMainViewTestCase.qml 1970-01-01 00:00:00 +0000
387+++ tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.HeaderInCustomMainViewTestCase.qml 2014-06-02 11:30:26 +0000
388@@ -0,0 +1,24 @@
389+/*
390+ * Copyright 2014 Canonical Ltd.
391+ *
392+ * This program is free software; you can redistribute it and/or modify
393+ * it under the terms of the GNU Lesser General Public License as published by
394+ * the Free Software Foundation; version 3.
395+ *
396+ * This program is distributed in the hope that it will be useful,
397+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
398+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
399+ * GNU Lesser General Public License for more details.
400+ *
401+ * You should have received a copy of the GNU Lesser General Public License
402+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
403+ */
404+
405+import QtQuick 2.0
406+import Ubuntu.Components 1.1
407+
408+CustomMainView {
409+
410+ objectName: 'mainView'
411+
412+}
413
414=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.py'
415--- tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.py 2014-05-20 08:56:28 +0000
416+++ tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.py 2014-06-02 11:30:26 +0000
417@@ -14,6 +14,8 @@
418 # You should have received a copy of the GNU Lesser General Public License
419 # along with this program. If not, see <http://www.gnu.org/licenses/>.
420
421+import os
422+
423 import ubuntuuitoolkit
424 from ubuntuuitoolkit import tests
425
426@@ -157,3 +159,28 @@
427
428 # only three actions are visible
429 self.assertEqual(overflow_button.visible, False)
430+
431+
432+class CustomMainView(ubuntuuitoolkit.MainView):
433+ """Autopilot helper for a custom main view."""
434+
435+
436+class HeaderInCustomMainViewTestCase(tests.QMLFileAppTestCase):
437+
438+ path = os.path.abspath(__file__)
439+ dir_path = os.path.dirname(path)
440+ test_qml_file_path = os.path.join(
441+ dir_path, 'test_header.HeaderInCustomMainViewTestCase.qml')
442+
443+ @property
444+ def main_view(self):
445+ return self.app.select_single(CustomMainView)
446+
447+ def test_get_header_from_custom_main_view(self):
448+ """Test that we can get the header from a custom main view.
449+
450+ This prevents a regression of http://pad.lv/1324556.
451+
452+ """
453+ header = self.main_view.get_header()
454+ self.assertIsInstance(header, ubuntuuitoolkit.Header)
455
456=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/test_fixture_setup.py'
457--- tests/autopilot/ubuntuuitoolkit/tests/test_fixture_setup.py 2014-03-10 16:51:01 +0000
458+++ tests/autopilot/ubuntuuitoolkit/tests/test_fixture_setup.py 2014-06-02 11:30:26 +0000
459@@ -15,6 +15,7 @@
460 # along with this program. If not, see <http://www.gnu.org/licenses/>.
461
462 import os
463+import tempfile
464
465 try:
466 # Python 3.
467@@ -24,7 +25,7 @@
468 import mock
469 import testtools
470 from autopilot import testcase as autopilot_testcase
471-from testtools.matchers import Contains, Not, FileExists
472+from testtools.matchers import Contains, FileExists, Not
473
474 from ubuntuuitoolkit import base, environment, fixture_setup
475
476@@ -233,3 +234,73 @@
477 self.assertEqual(
478 'original test value',
479 environment.get_initctl_env_var('testenvvarforfixture'))
480+
481+
482+class FakeHomeTestCase(testtools.TestCase):
483+
484+ def test_fake_home_fixture_patches_initctl_env_var(self):
485+ original_home = environment.get_initctl_env_var('HOME')
486+ fake_home = original_home + 'fake'
487+ result = testtools.TestResult()
488+
489+ def inner_test():
490+ class TestWithFakeHome(testtools.TestCase):
491+ def test_it(self):
492+ fake_home_fixture = fixture_setup.FakeHome(fake_home)
493+ fake_home_fixture.should_copy_xauthority_file = False
494+ self.useFixture(fake_home_fixture)
495+ self.assertEqual(
496+ fake_home, environment.get_initctl_env_var('HOME'))
497+ return TestWithFakeHome('test_it')
498+
499+ inner_test().run(result)
500+
501+ self.assertTrue(
502+ result.wasSuccessful(),
503+ 'Failed to fake the home: {}'.format(result.errors))
504+ self.assertEqual(
505+ original_home,
506+ environment.get_initctl_env_var('HOME'))
507+
508+ def test_fake_home_fixture_patches_env_var(self):
509+ original_home = os.environ.get('HOME')
510+ fake_home = tempfile.gettempdir()
511+ result = testtools.TestResult()
512+
513+ def inner_test():
514+ class TestWithFakeHome(testtools.TestCase):
515+ def test_it(self):
516+ fake_home_fixture = fixture_setup.FakeHome(fake_home)
517+ fake_home_fixture.should_copy_xauthority_file = False
518+ self.useFixture(fake_home_fixture)
519+ self.assertEqual(
520+ fake_home, os.environ.get('HOME'))
521+ return TestWithFakeHome('test_it')
522+
523+ inner_test().run(result)
524+
525+ self.assertTrue(
526+ result.wasSuccessful(),
527+ 'Failed to fake the home: {}'.format(result.failures))
528+ self.assertEqual(original_home, os.environ.get('HOME'))
529+
530+ def test_fake_home_fixture_must_create_default_directory(self):
531+ original_home = os.environ.get('HOME')
532+ self.useFixture(fixture_setup.FakeHome())
533+
534+ home_parent_directory, _ = os.path.split(os.environ.get('HOME'))
535+ self.assertEqual(
536+ home_parent_directory,
537+ os.path.join(original_home, 'autopilot', 'fakeenv'))
538+
539+ def test_fake_home_fixture_must_copy_xauthority(self):
540+ # Fake the home first so we don't write the xauthority on the real
541+ # home.
542+ self.useFixture(fixture_setup.FakeHome())
543+
544+ open(os.path.join(os.environ.get('HOME'), '.Xauthority')).close()
545+
546+ self.useFixture(fixture_setup.FakeHome())
547+ self.assertTrue(
548+ os.path.exists(
549+ os.path.join(os.environ.get('HOME'), '.Xauthority')))
550
551=== modified file 'tests/qmlapicheck.py'
552--- tests/qmlapicheck.py 2014-04-24 09:18:38 +0000
553+++ tests/qmlapicheck.py 2014-06-02 11:30:26 +0000
554@@ -130,10 +130,10 @@
555 if '{' in line and '}' in line:
556 if filetype == 'qmltypes' and not in_builtin_type:
557 print(' ' + line.strip())
558- continue
559+ continue
560
561 # End of function/ signal/ Item block
562- if '}' in line:
563+ if '}' in line and not '{' in line:
564 in_block -= 1
565 block_meta = {}
566 if in_block == 1 and in_builtin_type:
567@@ -143,7 +143,7 @@
568 # Only root "Item {" is inspected for QML, otherwise all children
569 if in_block == 1 or filetype == 'qmltypes':
570 # Left hand side specifies a keyword, a type and a variable name
571- declaration = line.split(':')[0]
572+ declaration = line.split(':', 1)[0]
573 words = declaration.strip().split(' ')
574 # Skip types with prefixes considered builtin
575 if filetype == 'qmltypes' and words[0] == 'name':
576@@ -175,7 +175,8 @@
577 for word in words:
578 if word in keywords:
579 if filetype == 'qml':
580- signature = declaration.split('{')[0].strip()
581+ separator = '{' if 'function' in declaration else ':'
582+ signature = declaration.split(separator, 1)[0].strip()
583 if 'alias' in line:
584 no_mods = signature
585 for mod in ['readonly', 'default']:
586@@ -198,7 +199,7 @@
587 break
588
589 # Start of function/ signal/ Item block
590- if '{' in line:
591+ if '{' in line and not '}' in line:
592 in_block += 1
593 block_meta = {}
594 # The parent type can affect API

Subscribers

People subscribed via source and target branches

to status/vote changes: