Merge lp:~zsombi/ubuntu-ui-toolkit/layout-tests-fix into lp:ubuntu-ui-toolkit

Proposed by Zsombor Egri
Status: Merged
Approved by: Florian Boucault
Approved revision: 876
Merged at revision: 878
Proposed branch: lp:~zsombi/ubuntu-ui-toolkit/layout-tests-fix
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 924 lines (+222/-132)
7 files modified
tests/unit/test-include.pri (+0/-1)
tests/unit/unit.pro (+0/-1)
tests/unit_x11/test-include.pri (+1/-0)
tests/unit_x11/tst_layouts/PositioningOnLayoutChange.qml (+1/-1)
tests/unit_x11/tst_layouts/tst_layouts.cpp (+218/-127)
tests/unit_x11/tst_layouts/tst_layouts.pro (+1/-1)
tests/unit_x11/unit_x11.pro (+1/-1)
To merge this branch: bzr merge lp:~zsombi/ubuntu-ui-toolkit/layout-tests-fix
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Florian Boucault (community) code Approve
Review via email: mp+197402@code.launchpad.net

Commit message

Layouting fails with Qt5.2 if the tests and components are not rendered upon testing. Layout unit tests have been transferred to X11 unit tests and tests on layout changes all wait till the layout change completes.

Tested with Qt 5.0.2 and Qt 5.2 RC1

To post a comment you must log in.
Revision history for this message
Florian Boucault (fboucault) :
review: Approve (code)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (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=== modified file 'modules/Ubuntu/Components/Themes/Ambiance/TabBarStyle.qml'
3=== modified file 'tests/unit/test-include.pri'
4--- tests/unit/test-include.pri 2013-10-30 13:57:33 +0000
5+++ tests/unit/test-include.pri 2013-12-02 15:24:41 +0000
6@@ -1,5 +1,4 @@
7 include( plugin_dependency.pri )
8-include( layout_dependency.pri )
9 include( add_makecheck.pri )
10
11 TEMPLATE = app
12
13=== modified file 'tests/unit/unit.pro'
14--- tests/unit/unit.pro 2013-11-08 20:19:58 +0000
15+++ tests/unit/unit.pro 2013-12-02 15:24:41 +0000
16@@ -24,6 +24,5 @@
17 tst_i18n \
18 tst_arguments \
19 tst_argument \
20- tst_layouts \
21 tst_alarms \
22 tst_theme
23
24=== renamed file 'tests/unit/layout_dependency.pri' => 'tests/unit_x11/layout_dependency.pri'
25=== modified file 'tests/unit_x11/test-include.pri'
26--- tests/unit_x11/test-include.pri 2013-10-30 13:57:33 +0000
27+++ tests/unit_x11/test-include.pri 2013-12-02 15:24:41 +0000
28@@ -1,4 +1,5 @@
29 include( ../unit/plugin_dependency.pri )
30+include( layout_dependency.pri )
31 include( add_makecheck.pri )
32
33 TEMPLATE = app
34
35=== renamed directory 'tests/unit/tst_layouts' => 'tests/unit_x11/tst_layouts'
36=== modified file 'tests/unit_x11/tst_layouts/PositioningOnLayoutChange.qml'
37--- tests/unit/tst_layouts/PositioningOnLayoutChange.qml 2013-06-19 07:59:44 +0000
38+++ tests/unit_x11/tst_layouts/PositioningOnLayoutChange.qml 2013-12-02 15:24:41 +0000
39@@ -41,7 +41,7 @@
40
41 ConditionalLayout {
42 name: "landscape"
43- when: root.width >= root.height
44+ when: root.width > root.height
45 }
46 ]
47
48
49=== modified file 'tests/unit_x11/tst_layouts/tst_layouts.cpp'
50--- tests/unit/tst_layouts/tst_layouts.cpp 2013-06-28 08:28:44 +0000
51+++ tests/unit_x11/tst_layouts/tst_layouts.cpp 2013-12-02 15:24:41 +0000
52@@ -48,22 +48,28 @@
53 {
54 Q_OBJECT
55 private:
56- QQuickView *view;
57+ QString m_modulePath;
58
59 public:
60
61- tst_Layouts() :
62- view(0)
63+ tst_Layouts()
64 {
65 }
66
67- QQuickItem *loadTest(const QString &document)
68+ QQuickView * loadTest(const QString &file)
69 {
70- // load the document
71- view->setSource(QUrl::fromLocalFile(document));
72- QTest::waitForEvents();
73+ QQuickView *view = new QQuickView;
74+ view->engine()->addImportPath(m_modulePath);
75
76- return view->rootObject();
77+ view->setSource(QUrl::fromLocalFile(file));
78+ if (!view->rootObject()) {
79+ delete view;
80+ view = 0;
81+ } else {
82+ view->show();
83+ QTest::qWaitForWindowExposed(view);
84+ }
85+ return view;
86 }
87
88 QQuickItem *testItem(QQuickItem *that, const QString &identifier)
89@@ -82,27 +88,19 @@
90 QString modules("../../../modules");
91 QVERIFY(QDir(modules).exists());
92
93- view = new QQuickView;
94- QQmlEngine *quickEngine = view->engine();
95-
96- view->setGeometry(0,0, UCUnits::instance().gu(40), UCUnits::instance().gu(30));
97- //add modules folder so we have access to the plugin from QML
98- QStringList imports = quickEngine->importPathList();
99- imports.prepend(QDir(modules).absolutePath());
100- quickEngine->setImportPathList(imports);
101+ m_modulePath = QDir(modules).absolutePath();
102 }
103
104 void cleanupTestCase()
105 {
106- delete view;
107 }
108
109 void testCase_NoLayouts()
110 {
111- QQuickItem *root = loadTest("NoLayouts.qml");
112- QVERIFY(root);
113+ QScopedPointer<QQuickView> view(loadTest("NoLayouts.qml"));
114+ QVERIFY(view);
115
116- ULLayouts *layouts = qobject_cast<ULLayouts*>(testItem(root, "layouts"));
117+ ULLayouts *layouts = qobject_cast<ULLayouts*>(testItem(view->rootObject(), "layouts"));
118 QVERIFY(layouts);
119
120 QVERIFY(layouts->layoutList().isEmpty());
121@@ -110,7 +108,9 @@
122
123 void testCase_SimpleLayout()
124 {
125- QQuickItem *root = loadTest("SimpleLayouts.qml");
126+ QScopedPointer<QQuickView> view(loadTest("SimpleLayouts.qml"));
127+ QVERIFY(view);
128+ QQuickItem *root = view->rootObject();
129 QVERIFY(root);
130
131 ULLayouts *layouts = qobject_cast<ULLayouts*>(testItem(root, "layouts"));
132@@ -134,15 +134,21 @@
133
134 void testCase_SimpleLayout_Medium()
135 {
136- QQuickItem *root = loadTest("SimpleLayouts.qml");
137+ QScopedPointer<QQuickView> view(loadTest("SimpleLayouts.qml"));
138+ QVERIFY(view);
139+ QQuickItem *root = view->rootObject();
140 QVERIFY(root);
141
142 ULLayouts *layouts = qobject_cast<ULLayouts*>(testItem(root, "layouts"));
143 QVERIFY(layouts);
144+
145 QVERIFY(!layouts->layoutList().isEmpty());
146+ QSignalSpy layoutChangeSpy(layouts, SIGNAL(currentLayoutChanged()));
147+
148 root->setWidth(UCUnits::instance().gu(55));
149 QCOMPARE(root->width(), UCUnits::instance().gu(55));
150- QTest::waitForEvents();
151+ layoutChangeSpy.wait(100);
152+ QCOMPARE(layoutChangeSpy.count(), 1);
153
154 QCOMPARE(layouts->currentLayout(), QString("medium"));
155
156@@ -161,15 +167,20 @@
157
158 void testCase_SimpleLayout_Large()
159 {
160- QQuickItem *root = loadTest("SimpleLayouts.qml");
161+ QScopedPointer<QQuickView> view(loadTest("SimpleLayouts.qml"));
162+ QVERIFY(view);
163+ QQuickItem *root = view->rootObject();
164 QVERIFY(root);
165
166 ULLayouts *layouts = qobject_cast<ULLayouts*>(testItem(root, "layouts"));
167 QVERIFY(layouts);
168 QVERIFY(!layouts->layoutList().isEmpty());
169+ QSignalSpy layoutChangeSpy(layouts, SIGNAL(currentLayoutChanged()));
170+
171 root->setWidth(UCUnits::instance().gu(65));
172 QCOMPARE(root->width(), UCUnits::instance().gu(65));
173- QTest::waitForEvents();
174+ layoutChangeSpy.wait(100);
175+ QCOMPARE(layoutChangeSpy.count(), 1);
176
177 QCOMPARE(layouts->currentLayout(), QString("large"));
178
179@@ -188,7 +199,9 @@
180
181 void testCase_OverlappingCondition()
182 {
183- QQuickItem *root = loadTest("OverlappingCondition.qml");
184+ QScopedPointer<QQuickView> view(loadTest("OverlappingCondition.qml"));
185+ QVERIFY(view);
186+ QQuickItem *root = view->rootObject();
187 QVERIFY(root);
188
189 ULLayouts *layouts = qobject_cast<ULLayouts*>(testItem(root, "layouts"));
190@@ -200,7 +213,9 @@
191
192 void testCase_ExternalLayouts()
193 {
194- QQuickItem *root = loadTest("ExternalLayouts.qml");
195+ QScopedPointer<QQuickView> view(loadTest("ExternalLayouts.qml"));
196+ QVERIFY(view);
197+ QQuickItem *root = view->rootObject();
198 QVERIFY(root);
199
200 ULLayouts *layouts = qobject_cast<ULLayouts*>(testItem(root, "layouts"));
201@@ -212,33 +227,47 @@
202
203 void testCase_ExternalLayouts_Medium()
204 {
205- QQuickItem *root = loadTest("ExternalLayouts.qml");
206+ QScopedPointer<QQuickView> view(loadTest("ExternalLayouts.qml"));
207+ QVERIFY(view);
208+ QQuickItem *root = view->rootObject();
209 QVERIFY(root);
210
211 ULLayouts *layouts = qobject_cast<ULLayouts*>(testItem(root, "layouts"));
212 QVERIFY(layouts);
213 QVERIFY(!layouts->layoutList().isEmpty());
214+ QSignalSpy layoutChangeSpy(layouts, SIGNAL(currentLayoutChanged()));
215+
216 root->setWidth(UCUnits::instance().gu(55));
217+ layoutChangeSpy.wait(100);
218+ QCOMPARE(layoutChangeSpy.count(), 1);
219
220 QCOMPARE(layouts->currentLayout(), QString("medium"));
221 }
222
223 void testCase_ExternalLayouts_Large()
224 {
225- QQuickItem *root = loadTest("ExternalLayouts.qml");
226+ QScopedPointer<QQuickView> view(loadTest("ExternalLayouts.qml"));
227+ QVERIFY(view);
228+ QQuickItem *root = view->rootObject();
229 QVERIFY(root);
230
231 ULLayouts *layouts = qobject_cast<ULLayouts*>(testItem(root, "layouts"));
232 QVERIFY(layouts);
233 QVERIFY(!layouts->layoutList().isEmpty());
234+ QSignalSpy layoutChangeSpy(layouts, SIGNAL(currentLayoutChanged()));
235+
236 root->setWidth(UCUnits::instance().gu(65));
237+ layoutChangeSpy.wait(100);
238+ QCOMPARE(layoutChangeSpy.count(), 1);
239
240 QCOMPARE(layouts->currentLayout(), QString("large"));
241 }
242
243 void testCase_NestedLayouts()
244 {
245- QQuickItem *root = loadTest("NestedLayouts.qml");
246+ QScopedPointer<QQuickView> view(loadTest("NestedLayouts.qml"));
247+ QVERIFY(view);
248+ QQuickItem *root = view->rootObject();
249 QVERIFY(root);
250
251 ULLayouts *layouts = qobject_cast<ULLayouts*>(testItem(root, "layouts"));
252@@ -250,26 +279,34 @@
253
254 void testCase_NestedLayouts_ExtraLarge()
255 {
256- QQuickItem *root = loadTest("NestedLayouts.qml");
257+ QScopedPointer<QQuickView> view(loadTest("NestedLayouts.qml"));
258+ QVERIFY(view);
259+ QQuickItem *root = view->rootObject();
260 QVERIFY(root);
261
262 ULLayouts *layouts = qobject_cast<ULLayouts*>(testItem(root, "layouts"));
263 QVERIFY(layouts);
264 QVERIFY(!layouts->layoutList().isEmpty());
265+ QSignalSpy layoutChangeSpy(layouts, SIGNAL(currentLayoutChanged()));
266+
267 root->setWidth(UCUnits::instance().gu(90));
268- QTest::waitForEvents();
269+ layoutChangeSpy.wait(100);
270+ QCOMPARE(layoutChangeSpy.count(), 1);
271
272 QCOMPARE(layouts->currentLayout(), QString("extra-large"));
273
274 root->setWidth(UCUnits::instance().gu(50));
275- QTest::waitForEvents();
276+ layoutChangeSpy.wait(100);
277+ QCOMPARE(layoutChangeSpy.count(), 2);
278
279 QCOMPARE(root->property("nestedLayout").toString(), QString("medium"));
280 }
281
282 void testCase_ResizingContainers()
283 {
284- QQuickItem *root = loadTest("ResizingContainers.qml");
285+ QScopedPointer<QQuickView> view(loadTest("ResizingContainers.qml"));
286+ QVERIFY(view);
287+ QQuickItem *root = view->rootObject();
288 QVERIFY(root);
289
290 // fetch the current size of one item
291@@ -283,21 +320,22 @@
292 ULLayouts *layouts = qobject_cast<ULLayouts*>(testItem(root, "layouts"));
293 QVERIFY(layouts);
294 QVERIFY(!layouts->layoutList().isEmpty());
295+ QSignalSpy layoutChangeSpy(layouts, SIGNAL(currentLayoutChanged()));
296
297 root->setWidth(UCUnits::instance().gu(50));
298- QTest::waitForEvents();
299+ layoutChangeSpy.wait(100);
300 QCOMPARE(layouts->currentLayout(), QString("small"));
301 QCOMPARE(item->width(), UCUnits::instance().gu(10));
302 QCOMPARE(item->height(), UCUnits::instance().gu(10));
303
304 root->setWidth(UCUnits::instance().gu(60));
305- QTest::waitForEvents();
306+ layoutChangeSpy.wait(100);
307 QCOMPARE(layouts->currentLayout(), QString("large"));
308 QCOMPARE(item->width(), UCUnits::instance().gu(22));
309 QCOMPARE(item->height(), UCUnits::instance().gu(22));
310
311 root->setWidth(UCUnits::instance().gu(80));
312- QTest::waitForEvents();
313+ layoutChangeSpy.wait(100);
314 QCOMPARE(layouts->currentLayout(), QString("xlarge"));
315 QCOMPARE(item->width(), UCUnits::instance().gu(30));
316 QCOMPARE(item->height(), UCUnits::instance().gu(30));
317@@ -305,7 +343,7 @@
318 QCOMPARE(item2->height(), UCUnits::instance().gu(50));
319
320 root->setWidth(UCUnits::instance().gu(40));
321- QTest::waitForEvents();
322+ layoutChangeSpy.wait(100);
323 QCOMPARE(item->width(), width);
324 QCOMPARE(item->height(), height);
325 QCOMPARE(item2->width(), width2);
326@@ -314,7 +352,9 @@
327
328 void testCase_CurrentLayoutChange()
329 {
330- QQuickItem *root = loadTest("CurrentLayoutChange.qml");
331+ QScopedPointer<QQuickView> view(loadTest("CurrentLayoutChange.qml"));
332+ QVERIFY(view);
333+ QQuickItem *root = view->rootObject();
334 QVERIFY(root);
335
336 ULLayouts *layouts = qobject_cast<ULLayouts*>(testItem(root, "layoutManager"));
337@@ -322,31 +362,38 @@
338
339 QSignalSpy spy(layouts, SIGNAL(currentLayoutChanged()));
340 root->setWidth(root->height() - 10);
341+ spy.wait(100);
342 QEXPECT_FAIL(0, "Layout change should not happen when component is not defined", Continue);
343 QCOMPARE(spy.count(), 1);
344 }
345
346 void testCase_PositioningOnLayoutChange()
347 {
348- QQuickItem *root = loadTest("PositioningOnLayoutChange.qml");
349+ QScopedPointer<QQuickView> view(loadTest("PositioningOnLayoutChange.qml"));
350+ QVERIFY(view);
351+ QQuickItem *root = view->rootObject();
352 QVERIFY(root);
353
354 ULLayouts *layouts = qobject_cast<ULLayouts*>(testItem(root, "layoutManager"));
355 QVERIFY(layouts);
356
357 QSignalSpy spy(layouts, SIGNAL(currentLayoutChanged()));
358- root->setWidth(root->height() - 10);
359+ root->setWidth(root->height() + 10);
360+ spy.wait(100);
361 QEXPECT_FAIL(0, "Layout change should not happen when component is not defined", Continue);
362 QCOMPARE(spy.count(), 1);
363
364 spy.clear();
365- root->setWidth(root->height() + 10);
366+ root->setWidth(root->height() - 10);
367+ spy.wait(100);
368 QCOMPARE(spy.count(), 1);
369 }
370
371 void testCase_LaidOutItemsOutsideOfLayout()
372 {
373- QQuickItem *root = loadTest("LaidOutItemsOutsideOfLayout.qml");
374+ QScopedPointer<QQuickView> view(loadTest("LaidOutItemsOutsideOfLayout.qml"));
375+ QVERIFY(view);
376+ QQuickItem *root = view->rootObject();
377 QVERIFY(root);
378
379 QQuickItem *item = qobject_cast<QQuickItem*>(testItem(root, "itemLaidOut"));
380@@ -360,7 +407,9 @@
381
382 void testCase_OverlaidInItemLayout()
383 {
384- QQuickItem *root = loadTest("OverlaidInItemLayout.qml");
385+ QScopedPointer<QQuickView> view(loadTest("OverlaidInItemLayout.qml"));
386+ QVERIFY(view);
387+ QQuickItem *root = view->rootObject();
388 QVERIFY(root);
389
390 QQuickItem *layout = qobject_cast<QQuickItem*>(testItem(root, "layout"));
391@@ -374,75 +423,84 @@
392
393 void testCase_AnchorFilledReparenting()
394 {
395- QQuickItem *root = loadTest("AnchorFilledReparenting.qml");
396+ QScopedPointer<QQuickView> view(loadTest("AnchorFilledReparenting.qml"));
397+ QVERIFY(view);
398+ QQuickItem *root = view->rootObject();
399 QVERIFY(root);
400
401- QQuickItem *layout = qobject_cast<QQuickItem*>(testItem(root, "layoutManager"));
402+ QQuickItem *layout = testItem(root, "layoutManager");
403 QVERIFY(layout);
404+ QSignalSpy layoutChangeSpy(layout, SIGNAL(currentLayoutChanged()));
405
406- QQuickItem *item = qobject_cast<QQuickItem*>(testItem(root, "testItem"));
407+ QQuickItem *item = testItem(root, "testItem");
408 QVERIFY(item);
409
410 QQuickAnchors *anchors = item->property("anchors").value<QQuickAnchors*>();
411 QVERIFY(anchors);
412
413 root->setWidth(root->width() + 100);
414- QTest::waitForEvents();
415- QQuickItem *testLayout = qobject_cast<QQuickItem*>(testItem(root, "testLayout"));
416+ layoutChangeSpy.wait(100);
417+ QQuickItem *testLayout = testItem(root, "testLayout");
418 QVERIFY(testLayout);
419 QCOMPARE(anchors->fill(), testLayout);
420
421 root->setWidth(root->width() - 100);
422- QTest::waitForEvents();
423+ layoutChangeSpy.wait(100);
424 QCOMPARE(anchors->fill(), layout);
425 }
426
427 void testCase_AnchorFilledMargins()
428 {
429- QQuickItem *root = loadTest("AnchorFilledMargins.qml");
430+ QScopedPointer<QQuickView> view(loadTest("AnchorFilledMargins.qml"));
431+ QVERIFY(view);
432+ QQuickItem *root = view->rootObject();
433 QVERIFY(root);
434
435- QQuickItem *layout = qobject_cast<QQuickItem*>(testItem(root, "layoutManager"));
436+ QQuickItem *layout = testItem(root, "layoutManager");
437 QVERIFY(layout);
438+ QSignalSpy layoutChangeSpy(layout, SIGNAL(currentLayoutChanged()));
439
440- QQuickItem *item = qobject_cast<QQuickItem*>(testItem(root, "testItem"));
441+ QQuickItem *item = testItem(root, "testItem");
442 QVERIFY(item);
443
444 QQuickAnchors *anchors = item->property("anchors").value<QQuickAnchors*>();
445 QVERIFY(anchors);
446
447 root->setWidth(root->width() + 100);
448- QTest::waitForEvents();
449+ layoutChangeSpy.wait(100);
450
451- QQuickItem *testLayout = qobject_cast<QQuickItem*>(testItem(root, "testLayout"));
452+ QQuickItem *testLayout = testItem(root, "testLayout");
453 QVERIFY(testLayout);
454 QCOMPARE(anchors->fill(), testLayout);
455 QCOMPARE(anchors->margins(), 0.0);
456
457 root->setWidth(root->width() - 100);
458- QTest::waitForEvents();
459+ layoutChangeSpy.wait(100);
460 QCOMPARE(anchors->fill(), layout);
461 QCOMPARE(anchors->margins(), 10.0);
462 }
463
464 void testCase_AnchorFilledSeparateMargins()
465 {
466- QQuickItem *root = loadTest("AnchorFilledSeparateMargins.qml");
467+ QScopedPointer<QQuickView> view(loadTest("AnchorFilledSeparateMargins.qml"));
468+ QVERIFY(view);
469+ QQuickItem *root = view->rootObject();
470 QVERIFY(root);
471
472- QQuickItem *layout = qobject_cast<QQuickItem*>(testItem(root, "layoutManager"));
473+ QQuickItem *layout = testItem(root, "layoutManager");
474 QVERIFY(layout);
475+ QSignalSpy layoutChangeSpy(layout, SIGNAL(currentLayoutChanged()));
476
477- QQuickItem *item = qobject_cast<QQuickItem*>(testItem(root, "testItem"));
478+ QQuickItem *item = testItem(root, "testItem");
479 QVERIFY(item);
480
481 QQuickAnchors *anchors = item->property("anchors").value<QQuickAnchors*>();
482 QVERIFY(anchors);
483
484 root->setWidth(root->width() + 100);
485- QTest::waitForEvents();
486+ layoutChangeSpy.wait(100);
487
488- QQuickItem *testLayout = qobject_cast<QQuickItem*>(testItem(root, "testLayout"));
489+ QQuickItem *testLayout = testItem(root, "testLayout");
490 QVERIFY(testLayout);
491 QCOMPARE(anchors->fill(), testLayout);
492 QCOMPARE(anchors->margins(), 0.0);
493@@ -452,7 +510,7 @@
494 QCOMPARE(anchors->bottomMargin(), 0.0);
495
496 root->setWidth(root->width() - 100);
497- QTest::waitForEvents();
498+ layoutChangeSpy.wait(100);
499 QCOMPARE(anchors->fill(), layout);
500 QCOMPARE(anchors->leftMargin(), 10.0);
501 QCOMPARE(anchors->topMargin(), 20.0);
502@@ -462,38 +520,44 @@
503
504 void testCase_AnchorCenteredInDefault()
505 {
506- QQuickItem *root = loadTest("AnchorCenteredInDefault.qml");
507+ QScopedPointer<QQuickView> view(loadTest("AnchorCenteredInDefault.qml"));
508+ QVERIFY(view);
509+ QQuickItem *root = view->rootObject();
510 QVERIFY(root);
511
512- QQuickItem *layout = qobject_cast<QQuickItem*>(testItem(root, "layoutManager"));
513+ QQuickItem *layout = testItem(root, "layoutManager");
514 QVERIFY(layout);
515+ QSignalSpy layoutChangeSpy(layout, SIGNAL(currentLayoutChanged()));
516
517- QQuickItem *item = qobject_cast<QQuickItem*>(testItem(root, "testItem"));
518+ QQuickItem *item = testItem(root, "testItem");
519 QVERIFY(item);
520
521 QQuickAnchors *anchors = item->property("anchors").value<QQuickAnchors*>();
522 QVERIFY(anchors);
523
524 root->setWidth(root->width() + 100);
525- QTest::waitForEvents();
526- QQuickItem *testLayout = qobject_cast<QQuickItem*>(testItem(root, "testLayout"));
527+ layoutChangeSpy.wait(100);
528+ QQuickItem *testLayout = testItem(root, "testLayout");
529 QVERIFY(testLayout);
530 QCOMPARE(anchors->fill(), testLayout);
531
532 root->setWidth(root->width() - 100);
533- QTest::waitForEvents();
534+ layoutChangeSpy.wait(100);
535 QCOMPARE(anchors->centerIn(), layout);
536 }
537
538 void testCase_AnchorVerticalCenter()
539 {
540- QQuickItem *root = loadTest("AnchorVerticalCenter.qml");
541+ QScopedPointer<QQuickView> view(loadTest("AnchorVerticalCenter.qml"));
542+ QVERIFY(view);
543+ QQuickItem *root = view->rootObject();
544 QVERIFY(root);
545
546- QQuickItem *layout = qobject_cast<QQuickItem*>(testItem(root, "layoutManager"));
547+ QQuickItem *layout = testItem(root, "layoutManager");
548 QVERIFY(layout);
549+ QSignalSpy layoutChangeSpy(layout, SIGNAL(currentLayoutChanged()));
550
551- QQuickItem *item = qobject_cast<QQuickItem*>(testItem(root, "testItem"));
552+ QQuickItem *item = testItem(root, "testItem");
553 QVERIFY(item);
554
555 QQuickAnchors *anchors = item->property("anchors").value<QQuickAnchors*>();
556@@ -502,25 +566,28 @@
557 QCOMPARE(anchors->verticalCenter().item, layout);
558
559 root->setWidth(root->width() + 100);
560- QTest::waitForEvents();
561- QQuickItem *testLayout = qobject_cast<QQuickItem*>(testItem(root, "testLayout"));
562+ layoutChangeSpy.wait(100);
563+ QQuickItem *testLayout = testItem(root, "testLayout");
564 QVERIFY(testLayout);
565 QCOMPARE(anchors->fill(), testLayout);
566
567 root->setWidth(root->width() - 100);
568- QTest::waitForEvents();
569+ layoutChangeSpy.wait(100);
570 QCOMPARE(anchors->verticalCenter().item, layout);
571 }
572
573 void testCase_AnchorVerticalCenterOffset()
574 {
575- QQuickItem *root = loadTest("AnchorVerticalCenterOffset.qml");
576+ QScopedPointer<QQuickView> view(loadTest("AnchorVerticalCenterOffset.qml"));
577+ QVERIFY(view);
578+ QQuickItem *root = view->rootObject();
579 QVERIFY(root);
580
581- QQuickItem *layout = qobject_cast<QQuickItem*>(testItem(root, "layoutManager"));
582+ QQuickItem *layout = testItem(root, "layoutManager");
583 QVERIFY(layout);
584+ QSignalSpy layoutChangeSpy(layout, SIGNAL(currentLayoutChanged()));
585
586- QQuickItem *item = qobject_cast<QQuickItem*>(testItem(root, "testItem"));
587+ QQuickItem *item = testItem(root, "testItem");
588 QVERIFY(item);
589
590 QQuickAnchors *anchors = item->property("anchors").value<QQuickAnchors*>();
591@@ -530,27 +597,30 @@
592 QCOMPARE(anchors->verticalCenterOffset(), 50.0);
593
594 root->setWidth(root->width() + 100);
595- QTest::waitForEvents();
596+ layoutChangeSpy.wait(100);
597 QQuickItem *testLayout = qobject_cast<QQuickItem*>(testItem(root, "testLayout"));
598 QVERIFY(testLayout);
599 QCOMPARE(anchors->fill(), testLayout);
600 // no need to check offset as it does not affect the fill
601
602 root->setWidth(root->width() - 100);
603- QTest::waitForEvents();
604+ layoutChangeSpy.wait(100);
605 QCOMPARE(anchors->verticalCenter().item, layout);
606 QCOMPARE(anchors->verticalCenterOffset(), 50.0);
607 }
608
609 void testCase_AnchorHorizontalCenter()
610 {
611- QQuickItem *root = loadTest("AnchorHorizontalCenter.qml");
612+ QScopedPointer<QQuickView> view(loadTest("AnchorHorizontalCenter.qml"));
613+ QVERIFY(view);
614+ QQuickItem *root = view->rootObject();
615 QVERIFY(root);
616
617- QQuickItem *layout = qobject_cast<QQuickItem*>(testItem(root, "layoutManager"));
618+ QQuickItem *layout = testItem(root, "layoutManager");
619 QVERIFY(layout);
620+ QSignalSpy layoutChangeSpy(layout, SIGNAL(currentLayoutChanged()));
621
622- QQuickItem *item = qobject_cast<QQuickItem*>(testItem(root, "testItem"));
623+ QQuickItem *item = testItem(root, "testItem");
624 QVERIFY(item);
625
626 QQuickAnchors *anchors = item->property("anchors").value<QQuickAnchors*>();
627@@ -559,25 +629,28 @@
628 QCOMPARE(anchors->horizontalCenter().item, layout);
629
630 root->setWidth(root->width() + 100);
631- QTest::waitForEvents();
632- QQuickItem *testLayout = qobject_cast<QQuickItem*>(testItem(root, "testLayout"));
633+ layoutChangeSpy.wait(100);
634+ QQuickItem *testLayout = testItem(root, "testLayout");
635 QVERIFY(testLayout);
636 QCOMPARE(anchors->fill(), testLayout);
637
638 root->setWidth(root->width() - 100);
639- QTest::waitForEvents();
640+ layoutChangeSpy.wait(100);
641 QCOMPARE(anchors->horizontalCenter().item, layout);
642 }
643
644 void testCase_AnchorHorizontalCenterOffset()
645 {
646- QQuickItem *root = loadTest("AnchorHorizontalCenterOffset.qml");
647+ QScopedPointer<QQuickView> view(loadTest("AnchorHorizontalCenterOffset.qml"));
648+ QVERIFY(view);
649+ QQuickItem *root = view->rootObject();
650 QVERIFY(root);
651
652- QQuickItem *layout = qobject_cast<QQuickItem*>(testItem(root, "layoutManager"));
653+ QQuickItem *layout = testItem(root, "layoutManager");
654 QVERIFY(layout);
655+ QSignalSpy layoutChangeSpy(layout, SIGNAL(currentLayoutChanged()));
656
657- QQuickItem *item = qobject_cast<QQuickItem*>(testItem(root, "testItem"));
658+ QQuickItem *item = testItem(root, "testItem");
659 QVERIFY(item);
660
661 QQuickAnchors *anchors = item->property("anchors").value<QQuickAnchors*>();
662@@ -587,27 +660,30 @@
663 QCOMPARE(anchors->horizontalCenterOffset(), 50.0);
664
665 root->setWidth(root->width() + 100);
666- QTest::waitForEvents();
667- QQuickItem *testLayout = qobject_cast<QQuickItem*>(testItem(root, "testLayout"));
668+ layoutChangeSpy.wait(100);
669+ QQuickItem *testLayout = testItem(root, "testLayout");
670 QVERIFY(testLayout);
671 QCOMPARE(anchors->fill(), testLayout);
672 // no need to check offset as it does not affect the fill
673
674 root->setWidth(root->width() - 100);
675- QTest::waitForEvents();
676+ layoutChangeSpy.wait(100);
677 QCOMPARE(anchors->horizontalCenter().item, layout);
678 QCOMPARE(anchors->horizontalCenterOffset(), 50.0);
679 }
680
681 void testCase_AnchorCenterWithOffset()
682 {
683- QQuickItem *root = loadTest("AnchorCenterWithOffset.qml");
684+ QScopedPointer<QQuickView> view(loadTest("AnchorCenterWithOffset.qml"));
685+ QVERIFY(view);
686+ QQuickItem *root = view->rootObject();
687 QVERIFY(root);
688
689- QQuickItem *layout = qobject_cast<QQuickItem*>(testItem(root, "layoutManager"));
690+ QQuickItem *layout = testItem(root, "layoutManager");
691 QVERIFY(layout);
692+ QSignalSpy layoutChangeSpy(layout, SIGNAL(currentLayoutChanged()));
693
694- QQuickItem *item = qobject_cast<QQuickItem*>(testItem(root, "testItem"));
695+ QQuickItem *item = testItem(root, "testItem");
696 QVERIFY(item);
697
698 QQuickAnchors *anchors = item->property("anchors").value<QQuickAnchors*>();
699@@ -618,14 +694,14 @@
700 QCOMPARE(anchors->horizontalCenterOffset(), 40.0);
701
702 root->setWidth(root->width() + 100);
703- QTest::waitForEvents();
704- QQuickItem *testLayout = qobject_cast<QQuickItem*>(testItem(root, "testLayout"));
705+ layoutChangeSpy.wait(100);
706+ QQuickItem *testLayout = testItem(root, "testLayout");
707 QVERIFY(testLayout);
708 QCOMPARE(anchors->fill(), testLayout);
709 // no need to check offsets as it does not affect the fill
710
711 root->setWidth(root->width() - 100);
712- QTest::waitForEvents();
713+ layoutChangeSpy.wait(100);
714 QCOMPARE(anchors->centerIn(), layout);
715 QCOMPARE(anchors->verticalCenterOffset(), 50.0);
716 QCOMPARE(anchors->horizontalCenterOffset(), 40.0);
717@@ -633,13 +709,16 @@
718
719 void testCase_AnchorLeft()
720 {
721- QQuickItem *root = loadTest("AnchorLeft.qml");
722+ QScopedPointer<QQuickView> view(loadTest("AnchorLeft.qml"));
723+ QVERIFY(view);
724+ QQuickItem *root = view->rootObject();
725 QVERIFY(root);
726
727- QQuickItem *layout = qobject_cast<QQuickItem*>(testItem(root, "layoutManager"));
728+ QQuickItem *layout = testItem(root, "layoutManager");
729 QVERIFY(layout);
730+ QSignalSpy layoutChangeSpy(layout, SIGNAL(currentLayoutChanged()));
731
732- QQuickItem *item = qobject_cast<QQuickItem*>(testItem(root, "testItem"));
733+ QQuickItem *item = testItem(root, "testItem");
734 QVERIFY(item);
735
736 QQuickAnchors *anchors = item->property("anchors").value<QQuickAnchors*>();
737@@ -649,27 +728,30 @@
738 QCOMPARE(anchors->leftMargin(), 10.0);
739
740 root->setWidth(root->width() + 100);
741- QTest::waitForEvents();
742- QQuickItem *testLayout = qobject_cast<QQuickItem*>(testItem(root, "testLayout"));
743+ layoutChangeSpy.wait(100);
744+ QQuickItem *testLayout = testItem(root, "testLayout");
745 QVERIFY(testLayout);
746 QCOMPARE(anchors->fill(), testLayout);
747 QCOMPARE(anchors->leftMargin(), 0.0);
748
749 root->setWidth(root->width() - 100);
750- QTest::waitForEvents();
751+ layoutChangeSpy.wait(100);
752 QCOMPARE(anchors->left().item, layout);
753 QCOMPARE(anchors->leftMargin(), 10.0);
754 }
755
756 void testCase_AnchorTop()
757 {
758- QQuickItem *root = loadTest("AnchorTop.qml");
759+ QScopedPointer<QQuickView> view(loadTest("AnchorTop.qml"));
760+ QVERIFY(view);
761+ QQuickItem *root = view->rootObject();
762 QVERIFY(root);
763
764- QQuickItem *layout = qobject_cast<QQuickItem*>(testItem(root, "layoutManager"));
765+ QQuickItem *layout = testItem(root, "layoutManager");
766 QVERIFY(layout);
767+ QSignalSpy layoutChangeSpy(layout, SIGNAL(currentLayoutChanged()));
768
769- QQuickItem *item = qobject_cast<QQuickItem*>(testItem(root, "testItem"));
770+ QQuickItem *item = testItem(root, "testItem");
771 QVERIFY(item);
772
773 QQuickAnchors *anchors = item->property("anchors").value<QQuickAnchors*>();
774@@ -679,27 +761,30 @@
775 QCOMPARE(anchors->topMargin(), 10.0);
776
777 root->setWidth(root->width() + 100);
778- QTest::waitForEvents();
779- QQuickItem *testLayout = qobject_cast<QQuickItem*>(testItem(root, "testLayout"));
780+ layoutChangeSpy.wait(100);
781+ QQuickItem *testLayout = testItem(root, "testLayout");
782 QVERIFY(testLayout);
783 QCOMPARE(anchors->fill(), testLayout);
784 QCOMPARE(anchors->topMargin(), 0.0);
785
786 root->setWidth(root->width() - 100);
787- QTest::waitForEvents();
788+ layoutChangeSpy.wait(100);
789 QCOMPARE(anchors->top().item, layout);
790 QCOMPARE(anchors->topMargin(), 10.0);
791 }
792
793 void testCase_AnchorRight()
794 {
795- QQuickItem *root = loadTest("AnchorRight.qml");
796+ QScopedPointer<QQuickView> view(loadTest("AnchorRight.qml"));
797+ QVERIFY(view);
798+ QQuickItem *root = view->rootObject();
799 QVERIFY(root);
800
801- QQuickItem *layout = qobject_cast<QQuickItem*>(testItem(root, "layoutManager"));
802+ QQuickItem *layout = testItem(root, "layoutManager");
803 QVERIFY(layout);
804+ QSignalSpy layoutChangeSpy(layout, SIGNAL(currentLayoutChanged()));
805
806- QQuickItem *item = qobject_cast<QQuickItem*>(testItem(root, "testItem"));
807+ QQuickItem *item = testItem(root, "testItem");
808 QVERIFY(item);
809
810 QQuickAnchors *anchors = item->property("anchors").value<QQuickAnchors*>();
811@@ -709,27 +794,30 @@
812 QCOMPARE(anchors->rightMargin(), 10.0);
813
814 root->setWidth(root->width() + 100);
815- QTest::waitForEvents();
816- QQuickItem *testLayout = qobject_cast<QQuickItem*>(testItem(root, "testLayout"));
817+ layoutChangeSpy.wait(100);
818+ QQuickItem *testLayout = testItem(root, "testLayout");
819 QVERIFY(testLayout);
820 QCOMPARE(anchors->fill(), testLayout);
821 QCOMPARE(anchors->rightMargin(), 0.0);
822
823 root->setWidth(root->width() - 100);
824- QTest::waitForEvents();
825+ layoutChangeSpy.wait(100);
826 QCOMPARE(anchors->right().item, layout);
827 QCOMPARE(anchors->rightMargin(), 10.0);
828 }
829
830 void testCase_AnchorBottom()
831 {
832- QQuickItem *root = loadTest("AnchorBottom.qml");
833+ QScopedPointer<QQuickView> view(loadTest("AnchorBottom.qml"));
834+ QVERIFY(view);
835+ QQuickItem *root = view->rootObject();
836 QVERIFY(root);
837
838- QQuickItem *layout = qobject_cast<QQuickItem*>(testItem(root, "layoutManager"));
839+ QQuickItem *layout = testItem(root, "layoutManager");
840 QVERIFY(layout);
841+ QSignalSpy layoutChangeSpy(layout, SIGNAL(currentLayoutChanged()));
842
843- QQuickItem *item = qobject_cast<QQuickItem*>(testItem(root, "testItem"));
844+ QQuickItem *item = testItem(root, "testItem");
845 QVERIFY(item);
846
847 QQuickAnchors *anchors = item->property("anchors").value<QQuickAnchors*>();
848@@ -739,27 +827,30 @@
849 QCOMPARE(anchors->bottomMargin(), 10.0);
850
851 root->setWidth(root->width() + 100);
852- QTest::waitForEvents();
853- QQuickItem *testLayout = qobject_cast<QQuickItem*>(testItem(root, "testLayout"));
854+ layoutChangeSpy.wait(100);
855+ QQuickItem *testLayout = testItem(root, "testLayout");
856 QVERIFY(testLayout);
857 QCOMPARE(anchors->fill(), testLayout);
858 QCOMPARE(anchors->bottomMargin(), 0.0);
859
860 root->setWidth(root->width() - 100);
861- QTest::waitForEvents();
862+ layoutChangeSpy.wait(100);
863 QCOMPARE(anchors->bottom().item, layout);
864 QCOMPARE(anchors->bottomMargin(), 10.0);
865 }
866
867 void testCase_AnchorAll()
868 {
869- QQuickItem *root = loadTest("AnchorAll.qml");
870+ QScopedPointer<QQuickView> view(loadTest("AnchorAll.qml"));
871+ QVERIFY(view);
872+ QQuickItem *root = view->rootObject();
873 QVERIFY(root);
874
875- QQuickItem *layout = qobject_cast<QQuickItem*>(testItem(root, "layoutManager"));
876+ QQuickItem *layout = testItem(root, "layoutManager");
877 QVERIFY(layout);
878+ QSignalSpy layoutChangeSpy(layout, SIGNAL(currentLayoutChanged()));
879
880- QQuickItem *item = qobject_cast<QQuickItem*>(testItem(root, "testItem"));
881+ QQuickItem *item = testItem(root, "testItem");
882 QVERIFY(item);
883
884 QQuickAnchors *anchors = item->property("anchors").value<QQuickAnchors*>();
885@@ -773,8 +864,8 @@
886 QCOMPARE(anchors->margins(), 20.0);
887
888 root->setWidth(root->width() + 100);
889- QTest::waitForEvents();
890- QQuickItem *testLayout = qobject_cast<QQuickItem*>(testItem(root, "testLayout"));
891+ layoutChangeSpy.wait(100);
892+ QQuickItem *testLayout = testItem(root, "testLayout");
893 QVERIFY(testLayout);
894 QCOMPARE(anchors->fill(), testLayout);
895 QVERIFY(!anchors->left().item);
896@@ -784,7 +875,7 @@
897 QCOMPARE(anchors->margins(), 0.0);
898
899 root->setWidth(root->width() - 100);
900- QTest::waitForEvents();
901+ layoutChangeSpy.wait(100);
902 QCOMPARE(anchors->left().item, layout);
903 QCOMPARE(anchors->top().item, layout);
904 QCOMPARE(anchors->right().item, layout);
905
906=== modified file 'tests/unit_x11/tst_layouts/tst_layouts.pro'
907--- tests/unit/tst_layouts/tst_layouts.pro 2013-06-26 11:06:39 +0000
908+++ tests/unit_x11/tst_layouts/tst_layouts.pro 2013-12-02 15:24:41 +0000
909@@ -1,5 +1,5 @@
910 include(../test-include.pri)
911-include(../qtprivate_dependency.pri)
912+include(../../unit/qtprivate_dependency.pri)
913
914 QT += gui
915 SOURCES += \
916
917=== modified file 'tests/unit_x11/unit_x11.pro'
918--- tests/unit_x11/unit_x11.pro 2013-10-24 10:35:50 +0000
919+++ tests/unit_x11/unit_x11.pro 2013-12-02 15:24:41 +0000
920@@ -1,3 +1,3 @@
921 TEMPLATE = subdirs
922
923-SUBDIRS += tst_components tst_test tst_inversemousearea tst_recreateview tst_statesaver tst_theme_engine tst_orientation
924+SUBDIRS += tst_components tst_test tst_inversemousearea tst_recreateview tst_statesaver tst_theme_engine tst_orientation tst_layouts

Subscribers

People subscribed via source and target branches

to status/vote changes: