Merge lp:~elopio/ubuntu-ui-toolkit/loadItem-no_more into lp:ubuntu-ui-toolkit
- loadItem-no_more
- Merge into trunk
Proposed by
Leo Arias
Status: | Superseded |
---|---|
Proposed branch: | lp:~elopio/ubuntu-ui-toolkit/loadItem-no_more |
Merge into: | lp:ubuntu-ui-toolkit |
Diff against target: |
865 lines (+334/-126) 23 files modified
CHANGES (+1/-1) components.api (+7/-14) debian/ubuntu-ui-toolkit-autopilot.install (+1/-0) 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/fixture_setup.py (+45/-0) tests/autopilot/ubuntuuitoolkit/tests/__init__.py (+1/-14) tests/autopilot/ubuntuuitoolkit/tests/gallery/__init__.py (+15/-1) tests/autopilot/ubuntuuitoolkit/tests/gallery/test_buttons.py (+1/-3) tests/autopilot/ubuntuuitoolkit/tests/gallery/test_gallery.py (+4/-19) tests/autopilot/ubuntuuitoolkit/tests/gallery/test_optionselector.py (+1/-3) tests/autopilot/ubuntuuitoolkit/tests/gallery/test_textinput.py (+2/-6) tests/autopilot/ubuntuuitoolkit/tests/gallery/test_toggles.py (+2/-8) tests/autopilot/ubuntuuitoolkit/tests/test_fixture_setup.py (+72/-1) tests/launcher/launcher.cpp (+143/-0) tests/launcher/launcher.pro (+11/-0) tests/qmlapicheck.py (+6/-5) tests/tests.pro (+2/-0) |
To merge this branch: | bzr merge lp:~elopio/ubuntu-ui-toolkit/loadItem-no_more |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu SDK team | Pending | ||
Review via email: mp+221552@code.launchpad.net |
This proposal has been superseded by a proposal from 2014-05-30.
Commit message
Remove the loadItem helper from the gallery autopilot tests.
Description of the change
To post a comment you must log in.
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-30 14:35:19 +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-30 14:35:19 +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 'debian/ubuntu-ui-toolkit-autopilot.install' |
95 | --- debian/ubuntu-ui-toolkit-autopilot.install 2014-02-21 23:39:43 +0000 |
96 | +++ debian/ubuntu-ui-toolkit-autopilot.install 2014-05-30 14:35:19 +0000 |
97 | @@ -1,2 +1,3 @@ |
98 | usr/lib/python3 |
99 | +usr/lib/ubuntu-ui-toolkit/launcher |
100 | usr/lib/python2.7 |
101 | |
102 | === modified file 'modules/Ubuntu/Components/AnimatedItem.qml' |
103 | --- modules/Ubuntu/Components/AnimatedItem.qml 2014-04-23 08:50:20 +0000 |
104 | +++ modules/Ubuntu/Components/AnimatedItem.qml 2014-05-30 14:35:19 +0000 |
105 | @@ -30,45 +30,8 @@ |
106 | id: root |
107 | /*! |
108 | \preliminary |
109 | + \deprecated |
110 | Specifies whether the component is on the visible area of the Flickable or not. |
111 | */ |
112 | property bool onScreen: true |
113 | - |
114 | - QtObject { |
115 | - id: internal |
116 | - property Flickable flickable |
117 | - |
118 | - // returns whether the component is in the visible area of the flickable |
119 | - function checkOnScreen() |
120 | - { |
121 | - var pos = root.mapToItem(flickable, 0, 0) |
122 | - root.onScreen = (pos.y + root.height >= 0) && (pos.y <= internal.flickable.height) && |
123 | - (pos.x + root.width >= 0) && (pos.x <= internal.flickable.width) |
124 | - } |
125 | - // lookup for a flickable parent |
126 | - function updateFlickableParent() |
127 | - { |
128 | - var flickable = root.parent |
129 | - while (flickable) { |
130 | - if (flickable.hasOwnProperty("flicking") && flickable.hasOwnProperty("flickableDirection")) { |
131 | - // non-interactive flickables must be skipped as those do not provide |
132 | - // on-screen detection support |
133 | - if (flickable.interactive) |
134 | - break |
135 | - } |
136 | - flickable = flickable.parent |
137 | - } |
138 | - internal.flickable = flickable |
139 | - } |
140 | - } |
141 | - |
142 | - Connections { |
143 | - target: internal.flickable |
144 | - |
145 | - onContentXChanged: internal.checkOnScreen() |
146 | - onContentYChanged: internal.checkOnScreen() |
147 | - } |
148 | - |
149 | - Component.onCompleted: internal.updateFlickableParent() |
150 | - onParentChanged: internal.updateFlickableParent() |
151 | } |
152 | |
153 | === modified file 'modules/Ubuntu/Components/ListItems/Base.qml' |
154 | --- modules/Ubuntu/Components/ListItems/Base.qml 2014-04-28 19:24:56 +0000 |
155 | +++ modules/Ubuntu/Components/ListItems/Base.qml 2014-05-30 14:35:19 +0000 |
156 | @@ -159,7 +159,7 @@ |
157 | /*! |
158 | \internal |
159 | */ |
160 | - property alias children: middle.data |
161 | + default property alias children: middle.data |
162 | Item { |
163 | id: middle |
164 | property bool anchorToIconHelper: !__iconIsItem && iconHelper.source != "" |
165 | |
166 | === modified file 'modules/Ubuntu/Components/PageStack.qml' |
167 | --- modules/Ubuntu/Components/PageStack.qml 2014-05-13 09:09:35 +0000 |
168 | +++ modules/Ubuntu/Components/PageStack.qml 2014-05-30 14:35:19 +0000 |
169 | @@ -192,6 +192,7 @@ |
170 | */ |
171 | default property alias data: inactiveNode.data |
172 | PageTreeNode { |
173 | + anchors.fill: parent |
174 | id: inactiveNode |
175 | active: false |
176 | } |
177 | |
178 | === modified file 'modules/Ubuntu/Components/Pickers/DatePicker.qml' |
179 | --- modules/Ubuntu/Components/Pickers/DatePicker.qml 2014-05-07 10:42:31 +0000 |
180 | +++ modules/Ubuntu/Components/Pickers/DatePicker.qml 2014-05-30 14:35:19 +0000 |
181 | @@ -523,7 +523,8 @@ |
182 | function updatePickers() { |
183 | if (completed) { |
184 | // check mode flags first |
185 | - var modes = datePicker.mode.split(/\W/g); |
186 | + // 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) |
187 | + var modes = datePicker.mode.match(/\w+/g); |
188 | |
189 | showYearPicker = showMonthPicker = showDayPicker = |
190 | showHoursPicker = showMinutesPicker = showSecondsPicker = false; |
191 | @@ -607,7 +608,8 @@ |
192 | completed = false; |
193 | |
194 | // use short format to exclude any extra characters |
195 | - var format = datePicker.locale.dateFormat(Locale.ShortFormat).split(/\W/g); |
196 | + // 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) |
197 | + var format = datePicker.locale.dateFormat(Locale.ShortFormat).match(/\w+/g); |
198 | // loop through the format to decide the position of the tumbler |
199 | var formatIndex = 0; |
200 | for (var i in format) { |
201 | |
202 | === modified file 'modules/Ubuntu/Components/plugin/i18n.cpp' |
203 | --- modules/Ubuntu/Components/plugin/i18n.cpp 2014-05-22 15:54:13 +0000 |
204 | +++ modules/Ubuntu/Components/plugin/i18n.cpp 2014-05-30 14:35:19 +0000 |
205 | @@ -103,13 +103,14 @@ |
206 | /* |
207 | The default is /usr/share/locale if we don't set a folder |
208 | For click we use APP_DIR/share/locale |
209 | - eg. /usr/share/click/preinstalled/com.example.foo/current/share/locale |
210 | + e.g. /usr/share/click/preinstalled/com.example.foo/current/share/locale |
211 | */ |
212 | - QDir appDir(getenv("APP_DIR")); |
213 | - if (appDir.exists()) { |
214 | - QString localePath(appDir.filePath("share/locale")); |
215 | - C::bindtextdomain(domain.toUtf8(), localePath.toUtf8()); |
216 | + QString appDir(getenv("APP_DIR")); |
217 | + if (!QDir::isAbsolutePath (appDir)) { |
218 | + appDir = "/usr"; |
219 | } |
220 | + QString localePath(QDir(appDir).filePath("share/locale")); |
221 | + C::bindtextdomain(domain.toUtf8(), localePath.toUtf8()); |
222 | Q_EMIT domainChanged(); |
223 | } |
224 | |
225 | |
226 | === modified file 'modules/Ubuntu/Components/plugin/thumbnailgenerator.cpp' |
227 | --- modules/Ubuntu/Components/plugin/thumbnailgenerator.cpp 2014-02-25 09:14:23 +0000 |
228 | +++ modules/Ubuntu/Components/plugin/thumbnailgenerator.cpp 2014-05-30 14:35:19 +0000 |
229 | @@ -43,12 +43,15 @@ |
230 | * is the only way around the issue for now. */ |
231 | std::string src_path(QUrl(id).path().toUtf8().data()); |
232 | std::string tgt_path; |
233 | + const int xlarge_cutoff = 512; |
234 | + const int large_cutoff = 256; |
235 | + const int small_cutoff = 128; |
236 | try { |
237 | ThumbnailSize desiredSize; |
238 | - const int large_cutoff = 256; |
239 | - const int small_cutoff = 128; |
240 | - if(requestedSize.width() > large_cutoff || requestedSize.height() > large_cutoff) { |
241 | + if(requestedSize.width() > xlarge_cutoff || requestedSize.height() > xlarge_cutoff) { |
242 | desiredSize = TN_SIZE_ORIGINAL; |
243 | + } else if(requestedSize.width() > large_cutoff || requestedSize.height() > large_cutoff) { |
244 | + desiredSize = TN_SIZE_XLARGE; |
245 | } else if(requestedSize.width() > small_cutoff || requestedSize.height() > small_cutoff) { |
246 | desiredSize = TN_SIZE_LARGE; |
247 | } else { |
248 | |
249 | === modified file 'modules/Ubuntu/Components/qmldir' |
250 | --- modules/Ubuntu/Components/qmldir 2014-04-25 12:53:58 +0000 |
251 | +++ modules/Ubuntu/Components/qmldir 2014-05-30 14:35:19 +0000 |
252 | @@ -29,7 +29,7 @@ |
253 | internal PageTreeNode PageTreeNode.qml |
254 | PageStack 0.1 PageStack.qml |
255 | internal Toolbar Toolbar.qml |
256 | -Header 0.1 Header.qml |
257 | +internal Header Header.qml |
258 | internal AnimatedItem AnimatedItem.qml |
259 | internal PageWrapper PageWrapper.qml |
260 | UbuntuShape 0.1 UbuntuShape.qml |
261 | @@ -76,7 +76,6 @@ |
262 | OptionSelectorDelegate 1.0 OptionSelectorDelegate.qml |
263 | Page 1.0 Page.qml |
264 | PageStack 1.0 PageStack.qml |
265 | -Header 1.0 Header.qml |
266 | UbuntuShape 1.0 UbuntuShape.qml |
267 | CrossFadeImage 1.0 CrossFadeImage.qml |
268 | Icon 1.0 Icon.qml |
269 | |
270 | === modified file 'tests/autopilot/ubuntuuitoolkit/fixture_setup.py' |
271 | --- tests/autopilot/ubuntuuitoolkit/fixture_setup.py 2014-04-23 08:50:20 +0000 |
272 | +++ tests/autopilot/ubuntuuitoolkit/fixture_setup.py 2014-05-30 14:35:19 +0000 |
273 | @@ -16,6 +16,7 @@ |
274 | |
275 | import copy |
276 | import os |
277 | +import shutil |
278 | import tempfile |
279 | |
280 | import fixtures |
281 | @@ -118,3 +119,47 @@ |
282 | original_value) |
283 | else: |
284 | self.addCleanup(environment.unset_initctl_env_var, variable) |
285 | + |
286 | + |
287 | +class FakeHome(fixtures.Fixture): |
288 | + |
289 | + # We copy the Xauthority file to allow executions using XVFB. If it is not |
290 | + # on the user's HOME directory, nothing will happen. |
291 | + should_copy_xauthority_file = True |
292 | + |
293 | + def __init__(self, directory=None): |
294 | + super(FakeHome, self).__init__() |
295 | + self.directory = directory |
296 | + |
297 | + def setUp(self): |
298 | + super(FakeHome, self).setUp() |
299 | + self.directory = self._make_directory_if_not_specified() |
300 | + if self.should_copy_xauthority_file: |
301 | + self._copy_xauthority_file(self.directory) |
302 | + # We patch both environment variables so it works on the desktop and on |
303 | + # the phone. |
304 | + self.useFixture( |
305 | + InitctlEnvironmentVariable(HOME=self.directory)) |
306 | + self.useFixture( |
307 | + fixtures.EnvironmentVariable('HOME', newvalue=self.directory)) |
308 | + |
309 | + def _make_directory_if_not_specified(self): |
310 | + if self.directory is None: |
311 | + parent_directory = os.path.join( |
312 | + os.environ.get('HOME'), 'autopilot', 'fakeenv') |
313 | + if not os.path.exists(parent_directory): |
314 | + os.makedirs(parent_directory) |
315 | + temp_dir_fixture = fixtures.TempDir(parent_directory) |
316 | + self.useFixture(temp_dir_fixture) |
317 | + return temp_dir_fixture.path |
318 | + else: |
319 | + return self.directory |
320 | + |
321 | + def _copy_xauthority_file(self, directory): |
322 | + """Copy the .Xauthority file if it exists in the user's home.""" |
323 | + xauthority_file_path = os.path.join( |
324 | + os.environ.get('HOME'), '.Xauthority') |
325 | + if os.path.isfile(xauthority_file_path): |
326 | + shutil.copyfile( |
327 | + xauthority_file_path, |
328 | + os.path.join(directory, '.Xauthority')) |
329 | |
330 | === modified file 'tests/autopilot/ubuntuuitoolkit/tests/__init__.py' |
331 | --- tests/autopilot/ubuntuuitoolkit/tests/__init__.py 2014-04-23 08:50:20 +0000 |
332 | +++ tests/autopilot/ubuntuuitoolkit/tests/__init__.py 2014-05-30 14:35:19 +0000 |
333 | @@ -1,6 +1,6 @@ |
334 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
335 | # |
336 | -# Copyright (C) 2012, 2013 Canonical Ltd. |
337 | +# Copyright (C) 2012, 2013, 2014 Canonical Ltd. |
338 | # |
339 | # This program is free software; you can redistribute it and/or modify |
340 | # it under the terms of the GNU Lesser General Public License as published by |
341 | @@ -161,19 +161,6 @@ |
342 | self.assertThat(listView.visible, Eventually(Equals(True))) |
343 | return (contentLoader, listView) |
344 | |
345 | - def loadItem(self, item): |
346 | - self.selectItem(item) |
347 | - contentLoader = self.main_view.select_single( |
348 | - "QQuickLoader", objectName="contentLoader") |
349 | - self.assertThat(contentLoader.progress, Eventually(Equals(1.0))) |
350 | - loadedPage = self.getListItem(item) |
351 | - self.assertThat(loadedPage, Not(Is(None))) |
352 | - #loadedPage is not a page, it is the list item which goes in |
353 | - #background when the item is selected, which changes the visible |
354 | - #property of item in list itself to False. So followin check |
355 | - #fails on Nexus 4. Commenting it for now. |
356 | - #self.assertThat(loadedPage.visible, Eventually(Equals(True))) |
357 | - |
358 | def drag(self, itemText, itemTextTo): |
359 | item = self.getListItem(itemText) |
360 | itemTo = self.getListItem(itemTextTo) |
361 | |
362 | === modified file 'tests/autopilot/ubuntuuitoolkit/tests/gallery/__init__.py' |
363 | --- tests/autopilot/ubuntuuitoolkit/tests/gallery/__init__.py 2013-10-24 11:01:03 +0000 |
364 | +++ tests/autopilot/ubuntuuitoolkit/tests/gallery/__init__.py 2014-05-30 14:35:19 +0000 |
365 | @@ -1,6 +1,6 @@ |
366 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
367 | # |
368 | -# Copyright (C) 2012, 2013 Canonical Ltd. |
369 | +# Copyright (C) 2012, 2013, 2014 Canonical Ltd. |
370 | # |
371 | # This program is free software; you can redistribute it and/or modify |
372 | # it under the terms of the GNU Lesser General Public License as published by |
373 | @@ -19,6 +19,7 @@ |
374 | import os |
375 | import shutil |
376 | |
377 | +import ubuntuuitoolkit |
378 | from ubuntuuitoolkit import tests |
379 | |
380 | |
381 | @@ -71,6 +72,19 @@ |
382 | else: |
383 | return desktop_file_path |
384 | |
385 | + def open_page(self, page): |
386 | + """Open a page of the widget gallery. |
387 | + |
388 | + :param page: The objectName of the element in the index list that opens |
389 | + the page. |
390 | + |
391 | + """ |
392 | + list_view = self.main_view.select_single( |
393 | + ubuntuuitoolkit.QQuickListView, objectName="widgetList") |
394 | + list_view.click_element(page) |
395 | + element = self.main_view.select_single('Standard', objectName=page) |
396 | + element.selected.wait_for(True) |
397 | + |
398 | def tearDown(self): |
399 | super(GalleryTestCase, self).tearDown() |
400 | # We can't delete the desktop file before we close the application, |
401 | |
402 | === modified file 'tests/autopilot/ubuntuuitoolkit/tests/gallery/test_buttons.py' |
403 | --- tests/autopilot/ubuntuuitoolkit/tests/gallery/test_buttons.py 2014-02-11 01:55:49 +0000 |
404 | +++ tests/autopilot/ubuntuuitoolkit/tests/gallery/test_buttons.py 2014-05-30 14:35:19 +0000 |
405 | @@ -45,9 +45,7 @@ |
406 | ] |
407 | |
408 | def test_buttons(self): |
409 | - item = "Buttons" |
410 | - self.loadItem(item) |
411 | - self.checkPageHeader(item) |
412 | + self.open_page('buttonsElement') |
413 | |
414 | button = self.app.select_single(objectName=self.button_name) |
415 | self.assertIsNot(button, None) |
416 | |
417 | === modified file 'tests/autopilot/ubuntuuitoolkit/tests/gallery/test_gallery.py' |
418 | --- tests/autopilot/ubuntuuitoolkit/tests/gallery/test_gallery.py 2014-05-26 12:37:32 +0000 |
419 | +++ tests/autopilot/ubuntuuitoolkit/tests/gallery/test_gallery.py 2014-05-30 14:35:19 +0000 |
420 | @@ -19,7 +19,6 @@ |
421 | from autopilot.matchers import Eventually |
422 | from testtools.matchers import Is, Not, Equals |
423 | |
424 | -from ubuntuuitoolkit import emulators |
425 | from ubuntuuitoolkit.tests import gallery |
426 | |
427 | |
428 | @@ -33,15 +32,8 @@ |
429 | self.assertThat(rootItem, Not(Is(None))) |
430 | self.assertThat(rootItem.visible, Eventually(Equals(True))) |
431 | |
432 | - def test_navigation(self): |
433 | - item = "Navigation" |
434 | - self.loadItem(item) |
435 | - self.checkPageHeader(item) |
436 | - |
437 | def test_slider(self): |
438 | - item = "Slider" |
439 | - self.loadItem(item) |
440 | - self.checkPageHeader(item) |
441 | + self.open_page('slidersElement') |
442 | |
443 | item_data = [ |
444 | ["slider_standard"], |
445 | @@ -57,9 +49,7 @@ |
446 | # TODO: move slider value |
447 | |
448 | def test_progress_and_activity(self): |
449 | - item = "Progress and activity" |
450 | - self.loadItem(item) |
451 | - self.checkPageHeader(item) |
452 | + self.open_page('progressBarsElement') |
453 | |
454 | item_data = [ |
455 | ["progressbar_standard"], |
456 | @@ -79,9 +69,7 @@ |
457 | # FIXME: https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1308979 |
458 | return |
459 | |
460 | - item = "Ubuntu Shape" |
461 | - self.loadItem(item) |
462 | - self.checkPageHeader(item) |
463 | + self.open_page('ubuntuShapesElement') |
464 | |
465 | item_data = [ |
466 | ["ubuntushape_color_hex"], |
467 | @@ -115,12 +103,9 @@ |
468 | ] |
469 | |
470 | def test_open_page(self): |
471 | - list_view = self.main_view.select_single( |
472 | - emulators.QQuickListView, objectName="widgetList") |
473 | - list_view.click_element(self.element_name) |
474 | + self.open_page(self.element_name) |
475 | element = self.main_view.select_single( |
476 | 'Standard', objectName=self.element_name) |
477 | - element.selected.wait_for(True) |
478 | self.checkPageHeader(element.text) |
479 | if self.template_name == 'textinputsTemplate': |
480 | page_type = 'TextInputs' |
481 | |
482 | === modified file 'tests/autopilot/ubuntuuitoolkit/tests/gallery/test_optionselector.py' |
483 | --- tests/autopilot/ubuntuuitoolkit/tests/gallery/test_optionselector.py 2014-05-23 09:50:42 +0000 |
484 | +++ tests/autopilot/ubuntuuitoolkit/tests/gallery/test_optionselector.py 2014-05-30 14:35:19 +0000 |
485 | @@ -24,9 +24,7 @@ |
486 | |
487 | def setUp(self): |
488 | super(OptionSelectorTestCase, self).setUp() |
489 | - item = "Option Selector" |
490 | - self.loadItem(item) |
491 | - self.checkPageHeader(item) |
492 | + self.open_page('optionSelectorsElement') |
493 | |
494 | def test_select_option_from_collapsed_optionselector(self): |
495 | collapsed_option_selector = self.main_view.select_single( |
496 | |
497 | === modified file 'tests/autopilot/ubuntuuitoolkit/tests/gallery/test_textinput.py' |
498 | --- tests/autopilot/ubuntuuitoolkit/tests/gallery/test_textinput.py 2014-04-30 09:40:17 +0000 |
499 | +++ tests/autopilot/ubuntuuitoolkit/tests/gallery/test_textinput.py 2014-05-30 14:35:19 +0000 |
500 | @@ -54,9 +54,7 @@ |
501 | # Apply the user locale from the environment |
502 | # The UITK does the same, so the test must be localized |
503 | locale.setlocale(locale.LC_ALL, "") |
504 | - item = 'Text Field' |
505 | - self.loadItem(item) |
506 | - self.checkPageHeader(item) |
507 | + self.open_page('textinputsElement') |
508 | |
509 | def test_write_on_textfield_must_update_text(self): |
510 | textfield = self.main_view.select_single( |
511 | @@ -78,9 +76,7 @@ |
512 | |
513 | def setUp(self): |
514 | super(DisabledTextInputTestCase, self).setUp() |
515 | - item = 'Text Field' |
516 | - self.loadItem(item) |
517 | - self.checkPageHeader(item) |
518 | + self.open_page('textinputsElement') |
519 | |
520 | def test_textfield_disabled(self): |
521 | textfield_disabled = self.main_view.select_single( |
522 | |
523 | === modified file 'tests/autopilot/ubuntuuitoolkit/tests/gallery/test_toggles.py' |
524 | --- tests/autopilot/ubuntuuitoolkit/tests/gallery/test_toggles.py 2013-11-01 15:15:30 +0000 |
525 | +++ tests/autopilot/ubuntuuitoolkit/tests/gallery/test_toggles.py 2014-05-30 14:35:19 +0000 |
526 | @@ -35,10 +35,7 @@ |
527 | |
528 | def setUp(self): |
529 | super(EnabledTogglesTestCase, self).setUp() |
530 | - item = "Toggles" |
531 | - self.checkListItem(item) |
532 | - self.loadItem(item) |
533 | - self.checkPageHeader(item) |
534 | + self.open_page('togglesElement') |
535 | |
536 | def test_change_toggles_state(self): |
537 | toggle = self.main_view.select_single( |
538 | @@ -65,10 +62,7 @@ |
539 | |
540 | def setUp(self): |
541 | super(DisabledTogglesTestCase, self).setUp() |
542 | - item = "Toggles" |
543 | - self.checkListItem(item) |
544 | - self.loadItem(item) |
545 | - self.checkPageHeader(item) |
546 | + self.open_page('togglesElement') |
547 | |
548 | def test_change_toggles_state(self): |
549 | toggle = self.main_view.select_single( |
550 | |
551 | === modified file 'tests/autopilot/ubuntuuitoolkit/tests/test_fixture_setup.py' |
552 | --- tests/autopilot/ubuntuuitoolkit/tests/test_fixture_setup.py 2014-03-10 16:51:01 +0000 |
553 | +++ tests/autopilot/ubuntuuitoolkit/tests/test_fixture_setup.py 2014-05-30 14:35:19 +0000 |
554 | @@ -15,6 +15,7 @@ |
555 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
556 | |
557 | import os |
558 | +import tempfile |
559 | |
560 | try: |
561 | # Python 3. |
562 | @@ -24,7 +25,7 @@ |
563 | import mock |
564 | import testtools |
565 | from autopilot import testcase as autopilot_testcase |
566 | -from testtools.matchers import Contains, Not, FileExists |
567 | +from testtools.matchers import Contains, FileExists, Not |
568 | |
569 | from ubuntuuitoolkit import base, environment, fixture_setup |
570 | |
571 | @@ -233,3 +234,73 @@ |
572 | self.assertEqual( |
573 | 'original test value', |
574 | environment.get_initctl_env_var('testenvvarforfixture')) |
575 | + |
576 | + |
577 | +class FakeHomeTestCase(testtools.TestCase): |
578 | + |
579 | + def test_fake_home_fixture_patches_initctl_env_var(self): |
580 | + original_home = environment.get_initctl_env_var('HOME') |
581 | + fake_home = original_home + 'fake' |
582 | + result = testtools.TestResult() |
583 | + |
584 | + def inner_test(): |
585 | + class TestWithFakeHome(testtools.TestCase): |
586 | + def test_it(self): |
587 | + fake_home_fixture = fixture_setup.FakeHome(fake_home) |
588 | + fake_home_fixture.should_copy_xauthority_file = False |
589 | + self.useFixture(fake_home_fixture) |
590 | + self.assertEqual( |
591 | + fake_home, environment.get_initctl_env_var('HOME')) |
592 | + return TestWithFakeHome('test_it') |
593 | + |
594 | + inner_test().run(result) |
595 | + |
596 | + self.assertTrue( |
597 | + result.wasSuccessful(), |
598 | + 'Failed to fake the home: {}'.format(result.errors)) |
599 | + self.assertEqual( |
600 | + original_home, |
601 | + environment.get_initctl_env_var('HOME')) |
602 | + |
603 | + def test_fake_home_fixture_patches_env_var(self): |
604 | + original_home = os.environ.get('HOME') |
605 | + fake_home = tempfile.gettempdir() |
606 | + result = testtools.TestResult() |
607 | + |
608 | + def inner_test(): |
609 | + class TestWithFakeHome(testtools.TestCase): |
610 | + def test_it(self): |
611 | + fake_home_fixture = fixture_setup.FakeHome(fake_home) |
612 | + fake_home_fixture.should_copy_xauthority_file = False |
613 | + self.useFixture(fake_home_fixture) |
614 | + self.assertEqual( |
615 | + fake_home, os.environ.get('HOME')) |
616 | + return TestWithFakeHome('test_it') |
617 | + |
618 | + inner_test().run(result) |
619 | + |
620 | + self.assertTrue( |
621 | + result.wasSuccessful(), |
622 | + 'Failed to fake the home: {}'.format(result.failures)) |
623 | + self.assertEqual(original_home, os.environ.get('HOME')) |
624 | + |
625 | + def test_fake_home_fixture_must_create_default_directory(self): |
626 | + original_home = os.environ.get('HOME') |
627 | + self.useFixture(fixture_setup.FakeHome()) |
628 | + |
629 | + home_parent_directory, _ = os.path.split(os.environ.get('HOME')) |
630 | + self.assertEqual( |
631 | + home_parent_directory, |
632 | + os.path.join(original_home, 'autopilot', 'fakeenv')) |
633 | + |
634 | + def test_fake_home_fixture_must_copy_xauthority(self): |
635 | + # Fake the home first so we don't write the xauthority on the real |
636 | + # home. |
637 | + self.useFixture(fixture_setup.FakeHome()) |
638 | + |
639 | + open(os.path.join(os.environ.get('HOME'), '.Xauthority')).close() |
640 | + |
641 | + self.useFixture(fixture_setup.FakeHome()) |
642 | + self.assertTrue( |
643 | + os.path.exists( |
644 | + os.path.join(os.environ.get('HOME'), '.Xauthority'))) |
645 | |
646 | === added directory 'tests/launcher' |
647 | === added file 'tests/launcher/launcher.cpp' |
648 | --- tests/launcher/launcher.cpp 1970-01-01 00:00:00 +0000 |
649 | +++ tests/launcher/launcher.cpp 2014-05-30 14:35:19 +0000 |
650 | @@ -0,0 +1,143 @@ |
651 | +/* |
652 | + * Copyright 2014 Canonical Ltd. |
653 | + * |
654 | + * This program is free software; you can redistribute it and/or modify |
655 | + * it under the terms of the GNU Lesser General Public License as published by |
656 | + * the Free Software Foundation; version 3. |
657 | + * |
658 | + * This program is distributed in the hope that it will be useful, |
659 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
660 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
661 | + * GNU Lesser General Public License for more details. |
662 | + * |
663 | + * You should have received a copy of the GNU Lesser General Public License |
664 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
665 | + * |
666 | + * QML launcher with the ability to setup the QQuickView/ QQmlEngine differently |
667 | + * |
668 | + * Rationale: Different variants of qmlscene exist as well as C++ and Go apps |
669 | + * This is to write Autopilot test cases that exhibit specific behavior |
670 | + */ |
671 | + |
672 | +#include <iostream> |
673 | +#include <QtCore/qdebug.h> |
674 | +#include <QtQuick/QQuickView> |
675 | +#include <QtGui/QGuiApplication> |
676 | +#include <QtQml/QQmlEngine> |
677 | +#include <QtQml/QQmlContext> |
678 | +#include <QtCore/QFileInfo> |
679 | +#include <QLibrary> |
680 | +#include <QOpenGLContext> |
681 | +#include <QtGui/private/qopenglcontext_p.h> |
682 | +#include <QtQuick/private/qsgcontext_p.h> |
683 | + |
684 | +int usage() |
685 | +{ |
686 | + QString self(QGuiApplication::instance()->arguments().at(0)); |
687 | + std::cout << "Usage\n " |
688 | + << qPrintable(self) |
689 | + << " -testability -frameless -engine" |
690 | + << " --desktop_file_path=DESKTOP_FILE" |
691 | + << " -I MODULE_PATH FILENAME\n"; |
692 | + return 1; |
693 | +} |
694 | + |
695 | +int main(int argc, const char *argv[]) |
696 | +{ |
697 | + // QPlatformIntegration::ThreadedOpenGL |
698 | + setenv("QML_FORCE_THREADED_RENDERER", "1", 1); |
699 | + // QPlatformIntegration::BufferQueueingOpenGL |
700 | + setenv("QML_FIXED_ANIMATION_STEP", "1", 1); |
701 | + // Oxide and QWebEngine need a shared context |
702 | + QScopedPointer<QOpenGLContext> shareContext; |
703 | + shareContext.reset(new QOpenGLContext); |
704 | + QSGContext::setSharedOpenGLContext(shareContext.data()); |
705 | + |
706 | + QGuiApplication::setApplicationName("UITK Launcher"); |
707 | + QGuiApplication application(argc, (char**)argv); |
708 | + QStringList args (application.arguments()); |
709 | + |
710 | + int _testability(args.indexOf("-testability")); |
711 | + args.removeAt(_testability); |
712 | + int _frameless(args.indexOf("-frameless")); |
713 | + args.removeAt(_frameless); |
714 | + int _engine(args.indexOf("-engine")); |
715 | + args.removeAt(_engine); |
716 | + |
717 | + Q_FOREACH(QString arg, args) { |
718 | + if (arg.startsWith("--desktop_file_hint")) { |
719 | + // This will not be used - it only needs to be ignored |
720 | + int _desktop_file_hint(args.indexOf(arg)); |
721 | + args.removeAt(_desktop_file_hint); |
722 | + } |
723 | + } |
724 | + |
725 | + // Testability is only supported out of the box by QApplication not QGuiApplication |
726 | + if (_testability > -1 || getenv("QT_LOAD_TESTABILITY")) { |
727 | + QLibrary testLib(QLatin1String("qttestability")); |
728 | + if (testLib.load()) { |
729 | + typedef void (*TasInitialize)(void); |
730 | + TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init"); |
731 | + if (initFunction) { |
732 | + initFunction(); |
733 | + } else { |
734 | + qCritical("Library qttestability resolve failed!"); |
735 | + return 1; |
736 | + } |
737 | + } else { |
738 | + qCritical("Library qttestability load failed!"); |
739 | + return 1; |
740 | + } |
741 | + } |
742 | + |
743 | + QQmlEngine* engine; |
744 | + // The default constructor affects the components tree (autopilot vis) |
745 | + QQuickView* view; |
746 | + if (_engine > -1) { |
747 | + view = new QQuickView(); |
748 | + engine = view->engine(); |
749 | + } else { |
750 | + engine = new QQmlEngine(); |
751 | + view = new QQuickView(engine, NULL); |
752 | + } |
753 | + |
754 | + int _import(args.indexOf("-I")); |
755 | + args.removeAt(_import); |
756 | + if (_import > -1) { |
757 | + if (args.count() > _import) { |
758 | + QString importPath(args.at(_import)); |
759 | + args.removeAt(_import); |
760 | + engine->addImportPath(importPath); |
761 | + } |
762 | + } |
763 | + |
764 | + view->setResizeMode(QQuickView::SizeRootObjectToView); |
765 | + view->setTitle("UI Toolkit QQuickView"); |
766 | + if (_frameless > -1) { |
767 | + view->setFlags(Qt::FramelessWindowHint); |
768 | + } |
769 | + |
770 | + // The remaining unnamed argument must be a filename |
771 | + if (args.count() == 1) { |
772 | + qCritical() << "Missing filename"; |
773 | + return usage(); |
774 | + } |
775 | + QString filename(args.at(1)); |
776 | + // The first argument is the launcher itself |
777 | + args.removeAt(0); |
778 | + |
779 | + QUrl source(QUrl::fromLocalFile(filename)); |
780 | + view->setSource(source); |
781 | + if (view->errors().count() > 0) { |
782 | + return usage(); |
783 | + } |
784 | + view->show(); |
785 | + |
786 | + if (args.count() > 1) { |
787 | + qCritical() << "Invalid arguments passed" << args; |
788 | + return usage(); |
789 | + } |
790 | + |
791 | + return application.exec(); |
792 | +} |
793 | + |
794 | |
795 | === added file 'tests/launcher/launcher.pro' |
796 | --- tests/launcher/launcher.pro 1970-01-01 00:00:00 +0000 |
797 | +++ tests/launcher/launcher.pro 2014-05-30 14:35:19 +0000 |
798 | @@ -0,0 +1,11 @@ |
799 | +TEMPLATE = app |
800 | +QT += qml quick |
801 | +# For setSharedOpenGLContext |
802 | +QT += core-private gui-private quick-private |
803 | +CONFIG += no_keywords |
804 | +SOURCES += \ |
805 | + launcher.cpp |
806 | +launcher.path = /usr/lib/ubuntu-ui-toolkit |
807 | +launcher.files = launcher |
808 | +INSTALLS += launcher |
809 | + |
810 | |
811 | === modified file 'tests/qmlapicheck.py' |
812 | --- tests/qmlapicheck.py 2014-04-24 09:18:38 +0000 |
813 | +++ tests/qmlapicheck.py 2014-05-30 14:35:19 +0000 |
814 | @@ -130,10 +130,10 @@ |
815 | if '{' in line and '}' in line: |
816 | if filetype == 'qmltypes' and not in_builtin_type: |
817 | print(' ' + line.strip()) |
818 | - continue |
819 | + continue |
820 | |
821 | # End of function/ signal/ Item block |
822 | - if '}' in line: |
823 | + if '}' in line and not '{' in line: |
824 | in_block -= 1 |
825 | block_meta = {} |
826 | if in_block == 1 and in_builtin_type: |
827 | @@ -143,7 +143,7 @@ |
828 | # Only root "Item {" is inspected for QML, otherwise all children |
829 | if in_block == 1 or filetype == 'qmltypes': |
830 | # Left hand side specifies a keyword, a type and a variable name |
831 | - declaration = line.split(':')[0] |
832 | + declaration = line.split(':', 1)[0] |
833 | words = declaration.strip().split(' ') |
834 | # Skip types with prefixes considered builtin |
835 | if filetype == 'qmltypes' and words[0] == 'name': |
836 | @@ -175,7 +175,8 @@ |
837 | for word in words: |
838 | if word in keywords: |
839 | if filetype == 'qml': |
840 | - signature = declaration.split('{')[0].strip() |
841 | + separator = '{' if 'function' in declaration else ':' |
842 | + signature = declaration.split(separator, 1)[0].strip() |
843 | if 'alias' in line: |
844 | no_mods = signature |
845 | for mod in ['readonly', 'default']: |
846 | @@ -198,7 +199,7 @@ |
847 | break |
848 | |
849 | # Start of function/ signal/ Item block |
850 | - if '{' in line: |
851 | + if '{' in line and not '}' in line: |
852 | in_block += 1 |
853 | block_meta = {} |
854 | # The parent type can affect API |
855 | |
856 | === modified file 'tests/tests.pro' |
857 | --- tests/tests.pro 2014-02-21 23:39:43 +0000 |
858 | +++ tests/tests.pro 2014-05-30 14:35:19 +0000 |
859 | @@ -7,4 +7,6 @@ |
860 | autopilot2_module.path = /usr/lib/python2.7/dist-packages/ubuntuuitoolkit |
861 | autopilot2_module.files = autopilot/ubuntuuitoolkit/* |
862 | |
863 | +SUBDIRS += launcher |
864 | + |
865 | INSTALLS += autopilot_module autopilot2_module |