Merge lp:~elopio/ubuntu-ui-toolkit/fix1324556-get_top_container into lp:ubuntu-ui-toolkit

Proposed by Leo Arias
Status: Superseded
Proposed branch: lp:~elopio/ubuntu-ui-toolkit/fix1324556-get_top_container
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 619 lines (+219/-98)
17 files modified
CHANGES (+1/-1)
components.api (+7/-14)
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)
modules/Ubuntu/Components/qmldir (+1/-2)
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/test_header.HeaderInCustomMainViewTestCase.qml (+27/-0)
tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.py (+23/-0)
tests/autopilot/ubuntuuitoolkit/tests/test_fixture_setup.py (+72/-1)
tests/qmlapicheck.py (+6/-5)
To merge this branch: bzr merge lp:~elopio/ubuntu-ui-toolkit/fix1324556-get_top_container
Reviewer Review Type Date Requested Status
Ubuntu SDK team Pending
Review via email: mp+221425@code.launchpad.net

This proposal has been superseded by a proposal from 2014-05-29.

Commit message

On the header autopilot helper, use the top container instead of the main view.

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

Reverted the change on the test init.

1092. By Leo Arias

Fixed pep8.

1093. By Leo Arias

Typo.

1094. By Leo Arias

Fixed the regression test.

1095. By Leo Arias

Prunned the custom main view.

1096. By Leo Arias

removed the header.

1097. By Leo Arias

Kick jenkins.

Unmerged revisions

Preview Diff

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

Subscribers

People subscribed via source and target branches

to status/vote changes: