| 1 | /**************************************************************************** | 
| 2 | ** | 
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | 
| 4 | ** Contact: https://www.qt.io/licensing/ | 
| 5 | ** | 
| 6 | ** This file is part of the test suite of the Qt Toolkit. | 
| 7 | ** | 
| 8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ | 
| 9 | ** Commercial License Usage | 
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | 
| 11 | ** accordance with the commercial license agreement provided with the | 
| 12 | ** Software or, alternatively, in accordance with the terms contained in | 
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | 
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | 
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | 
| 16 | ** | 
| 17 | ** GNU General Public License Usage | 
| 18 | ** Alternatively, this file may be used under the terms of the GNU | 
| 19 | ** General Public License version 3 as published by the Free Software | 
| 20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT | 
| 21 | ** included in the packaging of this file. Please review the following | 
| 22 | ** information to ensure the GNU General Public License requirements will | 
| 23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | 
| 24 | ** | 
| 25 | ** $QT_END_LICENSE$ | 
| 26 | ** | 
| 27 | ****************************************************************************/ | 
| 28 | #include <QtTest/QtTest> | 
| 29 | #include <QtQuick/qquickview.h> | 
| 30 | #include <qqmlengine.h> | 
| 31 | #include <QtQuick/private/qquickrectangle_p.h> | 
| 32 | #include <QtQuick/private/qquickpositioners_p.h> | 
| 33 | #include <QtQuick/private/qquicktransition_p.h> | 
| 34 | #include <QtQuickTest/QtQuickTest> | 
| 35 | #include <private/qquickitem_p.h> | 
| 36 | #include <qqmlexpression.h> | 
| 37 | #include "../shared/viewtestutil.h" | 
| 38 | #include "../shared/visualtestutil.h" | 
| 39 | #include "../../shared/util.h" | 
| 40 |  | 
| 41 | using namespace QQuickViewTestUtil; | 
| 42 | using namespace QQuickVisualTestUtil; | 
| 43 |  | 
| 44 | Q_LOGGING_CATEGORY(lcTests, "qt.quick.tests" ) | 
| 45 |  | 
| 46 | class tst_qquickpositioners : public QQmlDataTest | 
| 47 | { | 
| 48 |     Q_OBJECT | 
| 49 | public: | 
| 50 |     tst_qquickpositioners(); | 
| 51 |  | 
| 52 | private slots: | 
| 53 |     void test_horizontal(); | 
| 54 |     void test_horizontal_padding(); | 
| 55 |     void test_horizontal_rtl(); | 
| 56 |     void test_horizontal_spacing(); | 
| 57 |     void test_horizontal_spacing_rightToLeft(); | 
| 58 |     void test_horizontal_animated(); | 
| 59 |     void test_horizontal_animated_padding(); | 
| 60 |     void test_horizontal_animated_rightToLeft(); | 
| 61 |     void test_horizontal_animated_rightToLeft_padding(); | 
| 62 |     void test_horizontal_animated_disabled(); | 
| 63 |     void test_horizontal_animated_disabled_padding(); | 
| 64 |     void test_vertical(); | 
| 65 |     void test_vertical_padding(); | 
| 66 |     void test_vertical_spacing(); | 
| 67 |     void test_vertical_animated(); | 
| 68 |     void test_vertical_animated_padding(); | 
| 69 |     void test_grid(); | 
| 70 |     void test_grid_padding(); | 
| 71 |     void test_grid_topToBottom(); | 
| 72 |     void test_grid_rightToLeft(); | 
| 73 |     void test_grid_spacing(); | 
| 74 |     void test_grid_row_column_spacing(); | 
| 75 |     void test_grid_animated(); | 
| 76 |     void test_grid_animated_padding(); | 
| 77 |     void test_grid_animated_rightToLeft(); | 
| 78 |     void test_grid_animated_rightToLeft_padding(); | 
| 79 |     void test_grid_zero_columns(); | 
| 80 |     void test_grid_H_alignment(); | 
| 81 |     void test_grid_H_alignment_padding(); | 
| 82 |     void test_grid_V_alignment(); | 
| 83 |     void test_grid_V_alignment_padding(); | 
| 84 |     void test_propertychanges(); | 
| 85 |     void test_repeater(); | 
| 86 |     void test_repeater_padding(); | 
| 87 |     void test_flow(); | 
| 88 |     void test_flow_padding(); | 
| 89 |     void test_flow_rightToLeft(); | 
| 90 |     void test_flow_topToBottom(); | 
| 91 |     void test_flow_topToBottom_padding(); | 
| 92 |     void test_flow_resize(); | 
| 93 |     void test_flow_resize_padding(); | 
| 94 |     void test_flow_resize_rightToLeft(); | 
| 95 |     void test_flow_resize_rightToLeft_padding(); | 
| 96 |     void test_flow_implicit_resize(); | 
| 97 |     void test_flow_implicit_resize_padding(); | 
| 98 |     void test_conflictinganchors(); | 
| 99 |     void test_mirroring(); | 
| 100 |     void test_allInvisible(); | 
| 101 |     void test_attachedproperties(); | 
| 102 |     void test_attachedproperties_data(); | 
| 103 |     void test_attachedproperties_dynamic(); | 
| 104 |  | 
| 105 |     void populateTransitions_row(); | 
| 106 |     void populateTransitions_row_data(); | 
| 107 |     void populateTransitions_column(); | 
| 108 |     void populateTransitions_column_data(); | 
| 109 |     void populateTransitions_grid(); | 
| 110 |     void populateTransitions_grid_data(); | 
| 111 |     void populateTransitions_flow(); | 
| 112 |     void populateTransitions_flow_data(); | 
| 113 |     void addTransitions_row(); | 
| 114 |     void addTransitions_row_data(); | 
| 115 |     void addTransitions_column(); | 
| 116 |     void addTransitions_column_data(); | 
| 117 |     void addTransitions_grid(); | 
| 118 |     void addTransitions_grid_data(); | 
| 119 |     void addTransitions_flow(); | 
| 120 |     void addTransitions_flow_data(); | 
| 121 |     void moveTransitions_row(); | 
| 122 |     void moveTransitions_row_data(); | 
| 123 |     void moveTransitions_column(); | 
| 124 |     void moveTransitions_column_data(); | 
| 125 |     void moveTransitions_grid(); | 
| 126 |     void moveTransitions_grid_data(); | 
| 127 |     void moveTransitions_flow(); | 
| 128 |     void moveTransitions_flow_data(); | 
| 129 |  | 
| 130 | private: | 
| 131 |     QQuickView *createView(const QString &filename, bool wait=true); | 
| 132 |  | 
| 133 |     void populateTransitions(const QString &positionerObjectName); | 
| 134 |     void populateTransitions_data(); | 
| 135 |     void addTransitions(const QString &positionerObjectName); | 
| 136 |     void addTransitions_data(); | 
| 137 |     void moveTransitions(const QString &positionerObjectName); | 
| 138 |     void moveTransitions_data(); | 
| 139 |     void matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes); | 
| 140 |     void matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList<int> &expectedIndexes); | 
| 141 |     void matchItemLists(const QVariantList &itemLists, const QList<QQuickItem *> &expectedItems); | 
| 142 |     void checkItemPositions(QQuickItem *positioner, QaimModel *model, qreal incrementalSize); | 
| 143 | }; | 
| 144 |  | 
| 145 | void tst_qquickpositioners::populateTransitions_row() | 
| 146 | { | 
| 147 |     populateTransitions(positionerObjectName: "row" ); | 
| 148 | } | 
| 149 |  | 
| 150 | void tst_qquickpositioners::populateTransitions_row_data() | 
| 151 | { | 
| 152 |     populateTransitions_data(); | 
| 153 | } | 
| 154 |  | 
| 155 | void tst_qquickpositioners::populateTransitions_column() | 
| 156 | { | 
| 157 |     populateTransitions(positionerObjectName: "column" ); | 
| 158 | } | 
| 159 |  | 
| 160 | void tst_qquickpositioners::populateTransitions_column_data() | 
| 161 | { | 
| 162 |     populateTransitions_data(); | 
| 163 | } | 
| 164 |  | 
| 165 | void tst_qquickpositioners::populateTransitions_grid() | 
| 166 | { | 
| 167 |     populateTransitions(positionerObjectName: "grid" ); | 
| 168 | } | 
| 169 |  | 
| 170 | void tst_qquickpositioners::populateTransitions_grid_data() | 
| 171 | { | 
| 172 |     populateTransitions_data(); | 
| 173 | } | 
| 174 |  | 
| 175 | void tst_qquickpositioners::populateTransitions_flow() | 
| 176 | { | 
| 177 |     populateTransitions(positionerObjectName: "flow" ); | 
| 178 | } | 
| 179 |  | 
| 180 | void tst_qquickpositioners::populateTransitions_flow_data() | 
| 181 | { | 
| 182 |     populateTransitions_data(); | 
| 183 | } | 
| 184 |  | 
| 185 | void tst_qquickpositioners::addTransitions_row() | 
| 186 | { | 
| 187 |     addTransitions(positionerObjectName: "row" ); | 
| 188 | } | 
| 189 |  | 
| 190 | void tst_qquickpositioners::addTransitions_row_data() | 
| 191 | { | 
| 192 |     addTransitions_data(); | 
| 193 | } | 
| 194 |  | 
| 195 | void tst_qquickpositioners::addTransitions_column() | 
| 196 | { | 
| 197 |     addTransitions(positionerObjectName: "column" ); | 
| 198 | } | 
| 199 |  | 
| 200 | void tst_qquickpositioners::addTransitions_column_data() | 
| 201 | { | 
| 202 |     addTransitions_data(); | 
| 203 | } | 
| 204 |  | 
| 205 | void tst_qquickpositioners::addTransitions_grid() | 
| 206 | { | 
| 207 |     addTransitions(positionerObjectName: "grid" ); | 
| 208 | } | 
| 209 |  | 
| 210 | void tst_qquickpositioners::addTransitions_grid_data() | 
| 211 | { | 
| 212 |     // don't use addTransitions_data() because grid displaces items differently | 
| 213 |     // (adding items further down the grid can cause displace transitions at | 
| 214 |     // previous indexes, since grid is auto-resized to tightly fit all of its items) | 
| 215 |  | 
| 216 |     QTest::addColumn<QString>(name: "qmlFile" ); | 
| 217 |     QTest::addColumn<int>(name: "initialItemCount" ); | 
| 218 |     QTest::addColumn<int>(name: "insertionIndex" ); | 
| 219 |     QTest::addColumn<int>(name: "insertionCount" ); | 
| 220 |     QTest::addColumn<ListRange>(name: "expectedDisplacedIndexes" ); | 
| 221 |  | 
| 222 |     QTest::newRow(dataTag: "add one @ start" ) << "transitions.qml"  << 10 << 0 << 1 << ListRange(0, 9); | 
| 223 |     QTest::newRow(dataTag: "add one @ middle" ) << "transitions.qml"  << 10 << 5 << 1 << ListRange(3, 3) + ListRange(5, 9); | 
| 224 |     QTest::newRow(dataTag: "add one @ end" ) << "transitions.qml"  << 10 << 10 << 1 << ListRange(3, 3) + ListRange(7, 7); | 
| 225 |     QTest::newRow(dataTag: "padding, add one @ start" ) << "transitions-padding.qml"  << 10 << 0 << 1 << ListRange(0, 9); | 
| 226 |     QTest::newRow(dataTag: "padding, add one @ middle" ) << "transitions-padding.qml"  << 10 << 5 << 1 << ListRange(3, 3) + ListRange(5, 9); | 
| 227 |     QTest::newRow(dataTag: "padding, add one @ end" ) << "transitions-padding.qml"  << 10 << 10 << 1 << ListRange(3, 3) + ListRange(7, 7); | 
| 228 |  | 
| 229 |     QTest::newRow(dataTag: "add multiple @ start" ) << "transitions.qml"  << 10 << 0 << 3 << ListRange(0, 9); | 
| 230 |     QTest::newRow(dataTag: "add multiple @ middle" ) << "transitions.qml"  << 10 << 5 << 3 << ListRange(1, 3) + ListRange(5, 9); | 
| 231 |     QTest::newRow(dataTag: "add multiple @ end" ) << "transitions.qml"  << 10 << 10 << 3 << ListRange(1, 3) + ListRange(5, 7) + ListRange(9, 9); | 
| 232 |     QTest::newRow(dataTag: "padding, add multiple @ start" ) << "transitions-padding.qml"  << 10 << 0 << 3 << ListRange(0, 9); | 
| 233 |     QTest::newRow(dataTag: "padding, add multiple @ middle" ) << "transitions-padding.qml"  << 10 << 5 << 3 << ListRange(1, 3) + ListRange(5, 9); | 
| 234 |     QTest::newRow(dataTag: "padding, add multiple @ end" ) << "transitions-padding.qml"  << 10 << 10 << 3 << ListRange(1, 3) + ListRange(5, 7) + ListRange(9, 9); | 
| 235 | } | 
| 236 |  | 
| 237 | void tst_qquickpositioners::addTransitions_flow() | 
| 238 | { | 
| 239 |     addTransitions(positionerObjectName: "flow" ); | 
| 240 | } | 
| 241 |  | 
| 242 | void tst_qquickpositioners::addTransitions_flow_data() | 
| 243 | { | 
| 244 |     addTransitions_data(); | 
| 245 | } | 
| 246 |  | 
| 247 | void tst_qquickpositioners::moveTransitions_row() | 
| 248 | { | 
| 249 |     moveTransitions(positionerObjectName: "row" ); | 
| 250 | } | 
| 251 |  | 
| 252 | void tst_qquickpositioners::moveTransitions_row_data() | 
| 253 | { | 
| 254 |     moveTransitions_data(); | 
| 255 | } | 
| 256 |  | 
| 257 | void tst_qquickpositioners::moveTransitions_column() | 
| 258 | { | 
| 259 |     moveTransitions(positionerObjectName: "column" ); | 
| 260 | } | 
| 261 |  | 
| 262 | void tst_qquickpositioners::moveTransitions_column_data() | 
| 263 | { | 
| 264 |     moveTransitions_data(); | 
| 265 | } | 
| 266 |  | 
| 267 | void tst_qquickpositioners::moveTransitions_grid() | 
| 268 | { | 
| 269 |     moveTransitions(positionerObjectName: "grid" ); | 
| 270 | } | 
| 271 |  | 
| 272 | void tst_qquickpositioners::moveTransitions_grid_data() | 
| 273 | { | 
| 274 |     // don't use moveTransitions_data() because grid displaces items differently | 
| 275 |     // (removing items further down the grid can cause displace transitions at | 
| 276 |     // previous indexes, since grid is auto-resized to tightly fit all of its items) | 
| 277 |  | 
| 278 |     QTest::addColumn<QString>(name: "qmlFile" ); | 
| 279 |     QTest::addColumn<int>(name: "initialItemCount" ); | 
| 280 |     QTest::addColumn<ListChange>(name: "change" ); | 
| 281 |     QTest::addColumn<ListRange>(name: "expectedDisplacedIndexes" ); | 
| 282 |  | 
| 283 |     QTest::newRow(dataTag: "remove one @ start" ) << "transitions.qml"  << 10 << ListChange::remove(index: 0, count: 1) << ListRange(1, 9); | 
| 284 |     QTest::newRow(dataTag: "remove one @ middle" ) << "transitions.qml"  << 10 << ListChange::remove(index: 4, count: 1) << ListRange(2, 3) + ListRange(5, 9); | 
| 285 |     QTest::newRow(dataTag: "remove one @ end" ) << "transitions.qml"  << 10 << ListChange::remove(index: 9, count: 1) << ListRange(2, 3) + ListRange(6, 7); | 
| 286 |     QTest::newRow(dataTag: "padding, remove one @ start" ) << "transitions-padding.qml"  << 10 << ListChange::remove(index: 0, count: 1) << ListRange(1, 9); | 
| 287 |     QTest::newRow(dataTag: "padding, remove one @ middle" ) << "transitions-padding.qml"  << 10 << ListChange::remove(index: 4, count: 1) << ListRange(2, 3) + ListRange(5, 9); | 
| 288 |     QTest::newRow(dataTag: "padding, remove one @ end" ) << "transitions-padding.qml"  << 10 << ListChange::remove(index: 9, count: 1) << ListRange(2, 3) + ListRange(6, 7); | 
| 289 |  | 
| 290 |     QTest::newRow(dataTag: "remove multiple @ start" ) << "transitions.qml"  << 10 << ListChange::remove(index: 0, count: 3) << ListRange(3, 9); | 
| 291 |     QTest::newRow(dataTag: "remove multiple @ middle" ) << "transitions.qml"  << 10 << ListChange::remove(index: 4, count: 3) << ListRange(1, 3) + ListRange(7, 9); | 
| 292 |     QTest::newRow(dataTag: "remove multiple @ end" ) << "transitions.qml"  << 10 << ListChange::remove(index: 7, count: 3) << ListRange(1, 3) + ListRange(5, 6); | 
| 293 |     QTest::newRow(dataTag: "padding, remove multiple @ start" ) << "transitions-padding.qml"  << 10 << ListChange::remove(index: 0, count: 3) << ListRange(3, 9); | 
| 294 |     QTest::newRow(dataTag: "padding, remove multiple @ middle" ) << "transitions-padding.qml"  << 10 << ListChange::remove(index: 4, count: 3) << ListRange(1, 3) + ListRange(7, 9); | 
| 295 |     QTest::newRow(dataTag: "padding, remove multiple @ end" ) << "transitions-padding.qml"  << 10 << ListChange::remove(index: 7, count: 3) << ListRange(1, 3) + ListRange(5, 6); | 
| 296 | } | 
| 297 |  | 
| 298 | void tst_qquickpositioners::moveTransitions_flow() | 
| 299 | { | 
| 300 |     moveTransitions(positionerObjectName: "flow" ); | 
| 301 | } | 
| 302 |  | 
| 303 | void tst_qquickpositioners::moveTransitions_flow_data() | 
| 304 | { | 
| 305 |     moveTransitions_data(); | 
| 306 | } | 
| 307 |  | 
| 308 | tst_qquickpositioners::tst_qquickpositioners() | 
| 309 | { | 
| 310 | } | 
| 311 |  | 
| 312 | void tst_qquickpositioners::test_horizontal() | 
| 313 | { | 
| 314 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "horizontal.qml" ))); | 
| 315 |  | 
| 316 |     window->rootObject()->setProperty(name: "testRightToLeft" , value: false); | 
| 317 |  | 
| 318 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 319 |     QVERIFY(one != nullptr); | 
| 320 |  | 
| 321 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 322 |     QVERIFY(two != nullptr); | 
| 323 |  | 
| 324 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 325 |     QVERIFY(three != nullptr); | 
| 326 |  | 
| 327 |     QCOMPARE(one->x(), 0.0); | 
| 328 |     QCOMPARE(one->y(), 0.0); | 
| 329 |     QCOMPARE(two->x(), 50.0); | 
| 330 |     QCOMPARE(two->y(), 0.0); | 
| 331 |     QCOMPARE(three->x(), 70.0); | 
| 332 |     QCOMPARE(three->y(), 0.0); | 
| 333 |  | 
| 334 |     QQuickItem *row = window->rootObject()->findChild<QQuickItem*>(aName: "row" ); | 
| 335 |     QCOMPARE(row->width(), 110.0); | 
| 336 |     QCOMPARE(row->height(), 50.0); | 
| 337 |  | 
| 338 |     // test padding | 
| 339 |     row->setProperty(name: "padding" , value: 1); | 
| 340 |     row->setProperty(name: "topPadding" , value: 2); | 
| 341 |     row->setProperty(name: "leftPadding" , value: 3); | 
| 342 |     row->setProperty(name: "rightPadding" , value: 4); | 
| 343 |     row->setProperty(name: "bottomPadding" , value: 5); | 
| 344 |  | 
| 345 |     QTRY_COMPARE(row->width(), 117.0); | 
| 346 |     QCOMPARE(row->height(), 57.0); | 
| 347 |  | 
| 348 |     QCOMPARE(one->x(), 3.0); | 
| 349 |     QCOMPARE(one->y(), 2.0); | 
| 350 |     QCOMPARE(two->x(), 53.0); | 
| 351 |     QCOMPARE(two->y(), 2.0); | 
| 352 |     QCOMPARE(three->x(), 73.0); | 
| 353 |     QCOMPARE(three->y(), 2.0); | 
| 354 | } | 
| 355 |  | 
| 356 | void tst_qquickpositioners::test_horizontal_padding() | 
| 357 | { | 
| 358 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "horizontal.qml" ))); | 
| 359 |  | 
| 360 |     window->rootObject()->setProperty(name: "testRightToLeft" , value: false); | 
| 361 |  | 
| 362 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 363 |     QVERIFY(one != nullptr); | 
| 364 |  | 
| 365 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 366 |     QVERIFY(two != nullptr); | 
| 367 |  | 
| 368 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 369 |     QVERIFY(three != nullptr); | 
| 370 |  | 
| 371 |     QCOMPARE(one->x(), 0.0); | 
| 372 |     QCOMPARE(one->y(), 0.0); | 
| 373 |     QCOMPARE(two->x(), 50.0); | 
| 374 |     QCOMPARE(two->y(), 0.0); | 
| 375 |     QCOMPARE(three->x(), 70.0); | 
| 376 |     QCOMPARE(three->y(), 0.0); | 
| 377 |  | 
| 378 |     QQuickItem *row = window->rootObject()->findChild<QQuickItem*>(aName: "row" ); | 
| 379 |     QCOMPARE(row->width(), 110.0); | 
| 380 |     QCOMPARE(row->height(), 50.0); | 
| 381 |  | 
| 382 |     QQuickRow *obj = qobject_cast<QQuickRow*>(object: row); | 
| 383 |     QVERIFY(obj != nullptr); | 
| 384 |  | 
| 385 |     QCOMPARE(row->property("padding" ).toDouble(), 0.0); | 
| 386 |     QCOMPARE(row->property("topPadding" ).toDouble(), 0.0); | 
| 387 |     QCOMPARE(row->property("leftPadding" ).toDouble(), 0.0); | 
| 388 |     QCOMPARE(row->property("rightPadding" ).toDouble(), 0.0); | 
| 389 |     QCOMPARE(row->property("bottomPadding" ).toDouble(), 0.0); | 
| 390 |  | 
| 391 |     obj->setPadding(1.0); | 
| 392 |  | 
| 393 |     QCOMPARE(row->property("padding" ).toDouble(), 1.0); | 
| 394 |     QCOMPARE(row->property("topPadding" ).toDouble(), 1.0); | 
| 395 |     QCOMPARE(row->property("leftPadding" ).toDouble(), 1.0); | 
| 396 |     QCOMPARE(row->property("rightPadding" ).toDouble(), 1.0); | 
| 397 |     QCOMPARE(row->property("bottomPadding" ).toDouble(), 1.0); | 
| 398 |  | 
| 399 |     QTRY_COMPARE(row->width(), 112.0); | 
| 400 |     QCOMPARE(row->height(), 52.0); | 
| 401 |  | 
| 402 |     QCOMPARE(one->x(), 1.0); | 
| 403 |     QCOMPARE(one->y(), 1.0); | 
| 404 |     QCOMPARE(two->x(), 51.0); | 
| 405 |     QCOMPARE(two->y(), 1.0); | 
| 406 |     QCOMPARE(three->x(), 71.0); | 
| 407 |     QCOMPARE(three->y(), 1.0); | 
| 408 |  | 
| 409 |     obj->setTopPadding(2.0); | 
| 410 |  | 
| 411 |     QCOMPARE(row->property("padding" ).toDouble(), 1.0); | 
| 412 |     QCOMPARE(row->property("topPadding" ).toDouble(), 2.0); | 
| 413 |     QCOMPARE(row->property("leftPadding" ).toDouble(), 1.0); | 
| 414 |     QCOMPARE(row->property("rightPadding" ).toDouble(), 1.0); | 
| 415 |     QCOMPARE(row->property("bottomPadding" ).toDouble(), 1.0); | 
| 416 |  | 
| 417 |     QTRY_COMPARE(row->height(), 53.0); | 
| 418 |     QCOMPARE(row->width(), 112.0); | 
| 419 |  | 
| 420 |     QCOMPARE(one->x(), 1.0); | 
| 421 |     QCOMPARE(one->y(), 2.0); | 
| 422 |     QCOMPARE(two->x(), 51.0); | 
| 423 |     QCOMPARE(two->y(), 2.0); | 
| 424 |     QCOMPARE(three->x(), 71.0); | 
| 425 |     QCOMPARE(three->y(), 2.0); | 
| 426 |  | 
| 427 |     obj->setLeftPadding(3.0); | 
| 428 |  | 
| 429 |     QCOMPARE(row->property("padding" ).toDouble(), 1.0); | 
| 430 |     QCOMPARE(row->property("topPadding" ).toDouble(), 2.0); | 
| 431 |     QCOMPARE(row->property("leftPadding" ).toDouble(), 3.0); | 
| 432 |     QCOMPARE(row->property("rightPadding" ).toDouble(), 1.0); | 
| 433 |     QCOMPARE(row->property("bottomPadding" ).toDouble(), 1.0); | 
| 434 |  | 
| 435 |     QTRY_COMPARE(row->width(), 114.0); | 
| 436 |     QCOMPARE(row->height(), 53.0); | 
| 437 |  | 
| 438 |     QCOMPARE(one->x(), 3.0); | 
| 439 |     QCOMPARE(one->y(), 2.0); | 
| 440 |     QCOMPARE(two->x(), 53.0); | 
| 441 |     QCOMPARE(two->y(), 2.0); | 
| 442 |     QCOMPARE(three->x(), 73.0); | 
| 443 |     QCOMPARE(three->y(), 2.0); | 
| 444 |  | 
| 445 |     obj->setRightPadding(4.0); | 
| 446 |  | 
| 447 |     QCOMPARE(row->property("padding" ).toDouble(), 1.0); | 
| 448 |     QCOMPARE(row->property("topPadding" ).toDouble(), 2.0); | 
| 449 |     QCOMPARE(row->property("leftPadding" ).toDouble(), 3.0); | 
| 450 |     QCOMPARE(row->property("rightPadding" ).toDouble(), 4.0); | 
| 451 |     QCOMPARE(row->property("bottomPadding" ).toDouble(), 1.0); | 
| 452 |  | 
| 453 |     QTRY_COMPARE(row->width(), 117.0); | 
| 454 |     QCOMPARE(row->height(), 53.0); | 
| 455 |  | 
| 456 |     QCOMPARE(one->x(), 3.0); | 
| 457 |     QCOMPARE(one->y(), 2.0); | 
| 458 |     QCOMPARE(two->x(), 53.0); | 
| 459 |     QCOMPARE(two->y(), 2.0); | 
| 460 |     QCOMPARE(three->x(), 73.0); | 
| 461 |     QCOMPARE(three->y(), 2.0); | 
| 462 |  | 
| 463 |     obj->setBottomPadding(5.0); | 
| 464 |  | 
| 465 |     QCOMPARE(row->property("padding" ).toDouble(), 1.0); | 
| 466 |     QCOMPARE(row->property("topPadding" ).toDouble(), 2.0); | 
| 467 |     QCOMPARE(row->property("leftPadding" ).toDouble(), 3.0); | 
| 468 |     QCOMPARE(row->property("rightPadding" ).toDouble(), 4.0); | 
| 469 |     QCOMPARE(row->property("bottomPadding" ).toDouble(), 5.0); | 
| 470 |  | 
| 471 |     QTRY_COMPARE(row->height(), 57.0); | 
| 472 |     QCOMPARE(row->width(), 117.0); | 
| 473 |  | 
| 474 |     QCOMPARE(one->x(), 3.0); | 
| 475 |     QCOMPARE(one->y(), 2.0); | 
| 476 |     QCOMPARE(two->x(), 53.0); | 
| 477 |     QCOMPARE(two->y(), 2.0); | 
| 478 |     QCOMPARE(three->x(), 73.0); | 
| 479 |     QCOMPARE(three->y(), 2.0); | 
| 480 |  | 
| 481 |     obj->resetBottomPadding(); | 
| 482 |     QCOMPARE(row->property("bottomPadding" ).toDouble(), 1.0); | 
| 483 |     QTRY_COMPARE(row->height(), 53.0); | 
| 484 |     QCOMPARE(row->width(), 117.0); | 
| 485 |  | 
| 486 |     obj->resetRightPadding(); | 
| 487 |     QCOMPARE(row->property("rightPadding" ).toDouble(), 1.0); | 
| 488 |     QTRY_COMPARE(row->width(), 114.0); | 
| 489 |     QCOMPARE(row->height(), 53.0); | 
| 490 |  | 
| 491 |     obj->resetLeftPadding(); | 
| 492 |     QCOMPARE(row->property("leftPadding" ).toDouble(), 1.0); | 
| 493 |     QTRY_COMPARE(row->width(), 112.0); | 
| 494 |     QCOMPARE(row->height(), 53.0); | 
| 495 |  | 
| 496 |     obj->resetTopPadding(); | 
| 497 |     QCOMPARE(row->property("topPadding" ).toDouble(), 1.0); | 
| 498 |     QTRY_COMPARE(row->height(), 52.0); | 
| 499 |     QCOMPARE(row->width(), 112.0); | 
| 500 |  | 
| 501 |     obj->resetPadding(); | 
| 502 |     QCOMPARE(row->property("padding" ).toDouble(), 0.0); | 
| 503 |     QCOMPARE(row->property("topPadding" ).toDouble(), 0.0); | 
| 504 |     QCOMPARE(row->property("leftPadding" ).toDouble(), 0.0); | 
| 505 |     QCOMPARE(row->property("rightPadding" ).toDouble(), 0.0); | 
| 506 |     QCOMPARE(row->property("bottomPadding" ).toDouble(), 0.0); | 
| 507 |     QTRY_COMPARE(row->height(), 50.0); | 
| 508 |     QCOMPARE(row->width(), 110.0); | 
| 509 |  | 
| 510 |     QCOMPARE(one->x(), 0.0); | 
| 511 |     QCOMPARE(one->y(), 0.0); | 
| 512 |     QCOMPARE(two->x(), 50.0); | 
| 513 |     QCOMPARE(two->y(), 0.0); | 
| 514 |     QCOMPARE(three->x(), 70.0); | 
| 515 |     QCOMPARE(three->y(), 0.0); | 
| 516 | } | 
| 517 |  | 
| 518 | void tst_qquickpositioners::test_horizontal_rtl() | 
| 519 | { | 
| 520 |       QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "horizontal.qml" ))); | 
| 521 |  | 
| 522 |     window->rootObject()->setProperty(name: "testRightToLeft" , value: true); | 
| 523 |  | 
| 524 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 525 |     QVERIFY(one != nullptr); | 
| 526 |  | 
| 527 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 528 |     QVERIFY(two != nullptr); | 
| 529 |  | 
| 530 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 531 |     QVERIFY(three != nullptr); | 
| 532 |  | 
| 533 |     QCOMPARE(one->x(), 60.0); | 
| 534 |     QCOMPARE(one->y(), 0.0); | 
| 535 |     QCOMPARE(two->x(), 40.0); | 
| 536 |     QCOMPARE(two->y(), 0.0); | 
| 537 |     QCOMPARE(three->x(), 0.0); | 
| 538 |     QCOMPARE(three->y(), 0.0); | 
| 539 |  | 
| 540 |     QQuickItem *row = window->rootObject()->findChild<QQuickItem*>(aName: "row" ); | 
| 541 |     QCOMPARE(row->width(), 110.0); | 
| 542 |     QCOMPARE(row->height(), 50.0); | 
| 543 |  | 
| 544 |     // test padding | 
| 545 |     row->setProperty(name: "padding" , value: 1); | 
| 546 |     row->setProperty(name: "topPadding" , value: 2); | 
| 547 |     row->setProperty(name: "leftPadding" , value: 3); | 
| 548 |     row->setProperty(name: "rightPadding" , value: 4); | 
| 549 |     row->setProperty(name: "bottomPadding" , value: 5); | 
| 550 |  | 
| 551 |     QTRY_COMPARE(row->width(), 117.0); | 
| 552 |     QCOMPARE(row->height(), 57.0); | 
| 553 |  | 
| 554 |     QCOMPARE(one->x(), 63.0); | 
| 555 |     QCOMPARE(one->y(), 2.0); | 
| 556 |     QCOMPARE(two->x(), 43.0); | 
| 557 |     QCOMPARE(two->y(), 2.0); | 
| 558 |     QCOMPARE(three->x(), 3.0); | 
| 559 |     QCOMPARE(three->y(), 2.0); | 
| 560 |  | 
| 561 |     row->setProperty(name: "topPadding" , value: 0); | 
| 562 |     row->setProperty(name: "leftPadding" , value: 0); | 
| 563 |     row->setProperty(name: "rightPadding" , value: 0); | 
| 564 |     row->setProperty(name: "bottomPadding" , value: 0); | 
| 565 |     row->setProperty(name: "padding" , value: 0); | 
| 566 |  | 
| 567 |     QTRY_COMPARE(one->x(), 60.0); | 
| 568 |     QCOMPARE(one->y(), 0.0); | 
| 569 |     QCOMPARE(two->x(), 40.0); | 
| 570 |     QCOMPARE(two->y(), 0.0); | 
| 571 |     QCOMPARE(three->x(), 0.0); | 
| 572 |     QCOMPARE(three->y(), 0.0); | 
| 573 |  | 
| 574 |     // Change the width of the row and check that items stay to the right | 
| 575 |     row->setWidth(200); | 
| 576 |     QTRY_COMPARE(one->x(), 150.0); | 
| 577 |     QCOMPARE(one->y(), 0.0); | 
| 578 |     QCOMPARE(two->x(), 130.0); | 
| 579 |     QCOMPARE(two->y(), 0.0); | 
| 580 |     QCOMPARE(three->x(), 90.0); | 
| 581 |     QCOMPARE(three->y(), 0.0); | 
| 582 |  | 
| 583 |     row->setProperty(name: "padding" , value: 1); | 
| 584 |     row->setProperty(name: "topPadding" , value: 2); | 
| 585 |     row->setProperty(name: "leftPadding" , value: 3); | 
| 586 |     row->setProperty(name: "rightPadding" , value: 4); | 
| 587 |     row->setProperty(name: "bottomPadding" , value: 5); | 
| 588 |  | 
| 589 |     QTRY_COMPARE(one->x(), 146.0); | 
| 590 |     QCOMPARE(one->y(), 2.0); | 
| 591 |     QCOMPARE(two->x(), 126.0); | 
| 592 |     QCOMPARE(two->y(), 2.0); | 
| 593 |     QCOMPARE(three->x(), 86.0); | 
| 594 |     QCOMPARE(three->y(), 2.0); | 
| 595 | } | 
| 596 |  | 
| 597 | void tst_qquickpositioners::test_horizontal_spacing() | 
| 598 | { | 
| 599 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "horizontal-spacing.qml" ))); | 
| 600 |  | 
| 601 |     window->rootObject()->setProperty(name: "testRightToLeft" , value: false); | 
| 602 |  | 
| 603 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 604 |     QVERIFY(one != nullptr); | 
| 605 |  | 
| 606 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 607 |     QVERIFY(two != nullptr); | 
| 608 |  | 
| 609 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 610 |     QVERIFY(three != nullptr); | 
| 611 |  | 
| 612 |     QCOMPARE(one->x(), 0.0); | 
| 613 |     QCOMPARE(one->y(), 0.0); | 
| 614 |     QCOMPARE(two->x(), 60.0); | 
| 615 |     QCOMPARE(two->y(), 0.0); | 
| 616 |     QCOMPARE(three->x(), 90.0); | 
| 617 |     QCOMPARE(three->y(), 0.0); | 
| 618 |  | 
| 619 |     QQuickItem *row = window->rootObject()->findChild<QQuickItem*>(aName: "row" ); | 
| 620 |     QCOMPARE(row->width(), 130.0); | 
| 621 |     QCOMPARE(row->height(), 50.0); | 
| 622 |  | 
| 623 |     // test padding | 
| 624 |     row->setProperty(name: "padding" , value: 1); | 
| 625 |     row->setProperty(name: "topPadding" , value: 2); | 
| 626 |     row->setProperty(name: "leftPadding" , value: 3); | 
| 627 |     row->setProperty(name: "rightPadding" , value: 4); | 
| 628 |     row->setProperty(name: "bottomPadding" , value: 5); | 
| 629 |  | 
| 630 |     QTRY_COMPARE(row->width(), 137.0); | 
| 631 |     QCOMPARE(row->height(), 57.0); | 
| 632 |  | 
| 633 |     QCOMPARE(one->x(), 3.0); | 
| 634 |     QCOMPARE(one->y(), 2.0); | 
| 635 |     QCOMPARE(two->x(), 63.0); | 
| 636 |     QCOMPARE(two->y(), 2.0); | 
| 637 |     QCOMPARE(three->x(), 93.0); | 
| 638 |     QCOMPARE(three->y(), 2.0); | 
| 639 | } | 
| 640 |  | 
| 641 | void tst_qquickpositioners::test_horizontal_spacing_rightToLeft() | 
| 642 | { | 
| 643 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "horizontal-spacing.qml" ))); | 
| 644 |  | 
| 645 |     window->rootObject()->setProperty(name: "testRightToLeft" , value: true); | 
| 646 |  | 
| 647 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 648 |     QVERIFY(one != nullptr); | 
| 649 |  | 
| 650 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 651 |     QVERIFY(two != nullptr); | 
| 652 |  | 
| 653 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 654 |     QVERIFY(three != nullptr); | 
| 655 |  | 
| 656 |     QCOMPARE(one->x(), 80.0); | 
| 657 |     QCOMPARE(one->y(), 0.0); | 
| 658 |     QCOMPARE(two->x(), 50.0); | 
| 659 |     QCOMPARE(two->y(), 0.0); | 
| 660 |     QCOMPARE(three->x(), 0.0); | 
| 661 |     QCOMPARE(three->y(), 0.0); | 
| 662 |  | 
| 663 |     QQuickItem *row = window->rootObject()->findChild<QQuickItem*>(aName: "row" ); | 
| 664 |     QCOMPARE(row->width(), 130.0); | 
| 665 |     QCOMPARE(row->height(), 50.0); | 
| 666 |  | 
| 667 |     // test padding | 
| 668 |     row->setProperty(name: "padding" , value: 1); | 
| 669 |     row->setProperty(name: "topPadding" , value: 2); | 
| 670 |     row->setProperty(name: "leftPadding" , value: 3); | 
| 671 |     row->setProperty(name: "rightPadding" , value: 4); | 
| 672 |     row->setProperty(name: "bottomPadding" , value: 5); | 
| 673 |  | 
| 674 |     QTRY_COMPARE(row->width(), 137.0); | 
| 675 |     QCOMPARE(row->height(), 57.0); | 
| 676 |  | 
| 677 |     QCOMPARE(one->x(), 83.0); | 
| 678 |     QCOMPARE(one->y(), 2.0); | 
| 679 |     QCOMPARE(two->x(), 53.0); | 
| 680 |     QCOMPARE(two->y(), 2.0); | 
| 681 |     QCOMPARE(three->x(), 3.0); | 
| 682 |     QCOMPARE(three->y(), 2.0); | 
| 683 | } | 
| 684 |  | 
| 685 | void tst_qquickpositioners::test_horizontal_animated() | 
| 686 | { | 
| 687 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "horizontal-animated.qml" ), wait: false)); | 
| 688 |  | 
| 689 |     window->rootObject()->setProperty(name: "testRightToLeft" , value: false); | 
| 690 |  | 
| 691 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 692 |     QVERIFY(one != nullptr); | 
| 693 |  | 
| 694 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 695 |     QVERIFY(two != nullptr); | 
| 696 |  | 
| 697 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 698 |     QVERIFY(three != nullptr); | 
| 699 |  | 
| 700 |     //Note that they animate in | 
| 701 |     QCOMPARE(one->x(), -100.0); | 
| 702 |     QCOMPARE(two->x(), -100.0); | 
| 703 |     QCOMPARE(three->x(), -100.0); | 
| 704 |  | 
| 705 |     QVERIFY(QTest::qWaitForWindowExposed(window.data())); //It may not relayout until the next frame, so it needs to be drawn | 
| 706 |  | 
| 707 |     QQuickItem *row = window->rootObject()->findChild<QQuickItem*>(aName: "row" ); | 
| 708 |     QVERIFY(row); | 
| 709 |     QCOMPARE(row->width(), 100.0); | 
| 710 |     QCOMPARE(row->height(), 50.0); | 
| 711 |  | 
| 712 |     //QTRY_COMPARE used instead of waiting for the expected time of animation completion | 
| 713 |     //Note that this means the duration of the animation is NOT tested | 
| 714 |  | 
| 715 |     QTRY_COMPARE(one->x(), 0.0); | 
| 716 |     QTRY_COMPARE(one->y(), 0.0); | 
| 717 |     QTRY_COMPARE(two->isVisible(), false); | 
| 718 |     QTRY_COMPARE(two->x(), -100.0);//Not 'in' yet | 
| 719 |     QTRY_COMPARE(two->y(), 0.0); | 
| 720 |     QTRY_COMPARE(three->x(), 50.0); | 
| 721 |     QTRY_COMPARE(three->y(), 0.0); | 
| 722 |  | 
| 723 |     //Add 'two' | 
| 724 |     two->setVisible(true); | 
| 725 |     QTRY_COMPARE(two->isVisible(), true); | 
| 726 |     QTRY_COMPARE(row->width(), 150.0); | 
| 727 |     QTRY_COMPARE(row->height(), 50.0); | 
| 728 |  | 
| 729 |     QTest::qWait(ms: 0);//Let the animation start | 
| 730 |     QVERIFY(two->x() >= -100.0 && two->x() < 50.0); | 
| 731 |     QVERIFY(three->x() >= 50.0 && three->x() < 100.0); | 
| 732 |  | 
| 733 |     QTRY_COMPARE(two->x(), 50.0); | 
| 734 |     QTRY_COMPARE(three->x(), 100.0); | 
| 735 |  | 
| 736 | } | 
| 737 |  | 
| 738 | void tst_qquickpositioners::test_horizontal_animated_padding() | 
| 739 | { | 
| 740 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "horizontal-animated.qml" ), wait: false)); | 
| 741 |  | 
| 742 |     window->rootObject()->setProperty(name: "testRightToLeft" , value: false); | 
| 743 |  | 
| 744 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 745 |     QVERIFY(one != nullptr); | 
| 746 |  | 
| 747 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 748 |     QVERIFY(two != nullptr); | 
| 749 |  | 
| 750 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 751 |     QVERIFY(three != nullptr); | 
| 752 |  | 
| 753 |     //Note that they animate in | 
| 754 |     QCOMPARE(one->x(), -100.0); | 
| 755 |     QCOMPARE(two->x(), -100.0); | 
| 756 |     QCOMPARE(three->x(), -100.0); | 
| 757 |  | 
| 758 |     QVERIFY(QTest::qWaitForWindowExposed(window.data())); //It may not relayout until the next frame, so it needs to be drawn | 
| 759 |  | 
| 760 |     QQuickItem *row = window->rootObject()->findChild<QQuickItem*>(aName: "row" ); | 
| 761 |     QVERIFY(row); | 
| 762 |     QCOMPARE(row->width(), 100.0); | 
| 763 |     QCOMPARE(row->height(), 50.0); | 
| 764 |  | 
| 765 |     // test padding | 
| 766 |     row->setProperty(name: "padding" , value: 1); | 
| 767 |     row->setProperty(name: "topPadding" , value: 2); | 
| 768 |     row->setProperty(name: "leftPadding" , value: 3); | 
| 769 |     row->setProperty(name: "rightPadding" , value: 4); | 
| 770 |     row->setProperty(name: "bottomPadding" , value: 5); | 
| 771 |  | 
| 772 |     QTRY_COMPARE(row->width(), 107.0); | 
| 773 |     QCOMPARE(row->height(), 57.0); | 
| 774 |  | 
| 775 |     //QTRY_COMPARE used instead of waiting for the expected time of animation completion | 
| 776 |     //Note that this means the duration of the animation is NOT tested | 
| 777 |  | 
| 778 |     QTRY_COMPARE(one->x(), 3.0); | 
| 779 |     QTRY_COMPARE(one->y(), 2.0); | 
| 780 |     QTRY_COMPARE(two->isVisible(), false); | 
| 781 |     QTRY_COMPARE(two->x(), -100.0);//Not 'in' yet | 
| 782 |     QTRY_COMPARE(two->y(), 0.0); | 
| 783 |     QTRY_COMPARE(three->x(), 53.0); | 
| 784 |     QTRY_COMPARE(three->y(), 2.0); | 
| 785 |  | 
| 786 |     //Add 'two' | 
| 787 |     two->setVisible(true); | 
| 788 |     QTRY_COMPARE(two->isVisible(), true); | 
| 789 |     QTRY_COMPARE(row->width(), 157.0); | 
| 790 |     QTRY_COMPARE(row->height(), 57.0); | 
| 791 |  | 
| 792 |     QTest::qWait(ms: 0);//Let the animation start | 
| 793 |     QVERIFY(two->x() >= -100.0 && two->x() < 53.0); | 
| 794 |     QVERIFY(three->x() >= 53.0 && three->x() < 103.0); | 
| 795 |  | 
| 796 |     QTRY_COMPARE(two->y(), 2.0); | 
| 797 |     QTRY_COMPARE(two->x(), 53.0); | 
| 798 |     QTRY_COMPARE(three->x(), 103.0); | 
| 799 |  | 
| 800 | } | 
| 801 |  | 
| 802 | void tst_qquickpositioners::test_horizontal_animated_rightToLeft() | 
| 803 | { | 
| 804 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "horizontal-animated.qml" ), wait: false)); | 
| 805 |  | 
| 806 |     window->rootObject()->setProperty(name: "testRightToLeft" , value: true); | 
| 807 |  | 
| 808 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 809 |     QVERIFY(one != nullptr); | 
| 810 |  | 
| 811 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 812 |     QVERIFY(two != nullptr); | 
| 813 |  | 
| 814 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 815 |     QVERIFY(three != nullptr); | 
| 816 |  | 
| 817 |     //Note that they animate in | 
| 818 |     QCOMPARE(one->x(), -100.0); | 
| 819 |     QCOMPARE(two->x(), -100.0); | 
| 820 |     QCOMPARE(three->x(), -100.0); | 
| 821 |  | 
| 822 |     QVERIFY(QTest::qWaitForWindowExposed(window.data())); //It may not relayout until the next frame, so it needs to be drawn | 
| 823 |  | 
| 824 |     QQuickItem *row = window->rootObject()->findChild<QQuickItem*>(aName: "row" ); | 
| 825 |     QVERIFY(row); | 
| 826 |     QCOMPARE(row->width(), 100.0); | 
| 827 |     QCOMPARE(row->height(), 50.0); | 
| 828 |  | 
| 829 |     //QTRY_COMPARE used instead of waiting for the expected time of animation completion | 
| 830 |     //Note that this means the duration of the animation is NOT tested | 
| 831 |  | 
| 832 |     QTRY_COMPARE(one->x(), 50.0); | 
| 833 |     QTRY_COMPARE(one->y(), 0.0); | 
| 834 |     QTRY_COMPARE(two->isVisible(), false); | 
| 835 |     QTRY_COMPARE(two->x(), -100.0);//Not 'in' yet | 
| 836 |     QTRY_COMPARE(two->y(), 0.0); | 
| 837 |     QTRY_COMPARE(three->x(), 0.0); | 
| 838 |     QTRY_COMPARE(three->y(), 0.0); | 
| 839 |  | 
| 840 |     //Add 'two' | 
| 841 |     two->setVisible(true); | 
| 842 |     QTRY_COMPARE(two->isVisible(), true); | 
| 843 |  | 
| 844 |     // New size should propagate after visible change | 
| 845 |     QTRY_COMPARE(row->width(), 150.0); | 
| 846 |     QTRY_COMPARE(row->height(), 50.0); | 
| 847 |  | 
| 848 |     QTest::qWait(ms: 0);//Let the animation start | 
| 849 |     QVERIFY(one->x() >= 50.0 && one->x() < 100); | 
| 850 |     QVERIFY(two->x() >= -100.0 && two->x() < 50.0); | 
| 851 |  | 
| 852 |     QTRY_COMPARE(one->x(), 100.0); | 
| 853 |     QTRY_COMPARE(two->x(), 50.0); | 
| 854 |  | 
| 855 | } | 
| 856 |  | 
| 857 | void tst_qquickpositioners::test_horizontal_animated_rightToLeft_padding() | 
| 858 | { | 
| 859 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "horizontal-animated.qml" ), wait: false)); | 
| 860 |  | 
| 861 |     window->rootObject()->setProperty(name: "testRightToLeft" , value: true); | 
| 862 |  | 
| 863 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 864 |     QVERIFY(one != nullptr); | 
| 865 |  | 
| 866 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 867 |     QVERIFY(two != nullptr); | 
| 868 |  | 
| 869 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 870 |     QVERIFY(three != nullptr); | 
| 871 |  | 
| 872 |     //Note that they animate in | 
| 873 |     QCOMPARE(one->x(), -100.0); | 
| 874 |     QCOMPARE(two->x(), -100.0); | 
| 875 |     QCOMPARE(three->x(), -100.0); | 
| 876 |  | 
| 877 |     QVERIFY(QTest::qWaitForWindowExposed(window.data())); //It may not relayout until the next frame, so it needs to be drawn | 
| 878 |  | 
| 879 |     QQuickItem *row = window->rootObject()->findChild<QQuickItem*>(aName: "row" ); | 
| 880 |     QVERIFY(row); | 
| 881 |     QCOMPARE(row->width(), 100.0); | 
| 882 |     QCOMPARE(row->height(), 50.0); | 
| 883 |  | 
| 884 |     // test padding | 
| 885 |     row->setProperty(name: "padding" , value: 1); | 
| 886 |     row->setProperty(name: "topPadding" , value: 2); | 
| 887 |     row->setProperty(name: "leftPadding" , value: 3); | 
| 888 |     row->setProperty(name: "rightPadding" , value: 4); | 
| 889 |     row->setProperty(name: "bottomPadding" , value: 5); | 
| 890 |  | 
| 891 |     QTRY_COMPARE(row->width(), 107.0); | 
| 892 |     QCOMPARE(row->height(), 57.0); | 
| 893 |  | 
| 894 |     //QTRY_COMPARE used instead of waiting for the expected time of animation completion | 
| 895 |     //Note that this means the duration of the animation is NOT tested | 
| 896 |  | 
| 897 |     QTRY_COMPARE(one->x(), 53.0); | 
| 898 |     QTRY_COMPARE(one->y(), 2.0); | 
| 899 |     QTRY_COMPARE(two->isVisible(), false); | 
| 900 |     QTRY_COMPARE(two->x(), -100.0);//Not 'in' yet | 
| 901 |     QTRY_COMPARE(two->y(), 0.0); | 
| 902 |     QTRY_COMPARE(three->x(), 3.0); | 
| 903 |     QTRY_COMPARE(three->y(), 2.0); | 
| 904 |  | 
| 905 |     //Add 'two' | 
| 906 |     two->setVisible(true); | 
| 907 |     QTRY_COMPARE(two->isVisible(), true); | 
| 908 |  | 
| 909 |     // New size should propagate after visible change | 
| 910 |     QTRY_COMPARE(row->width(), 157.0); | 
| 911 |     QTRY_COMPARE(row->height(), 57.0); | 
| 912 |  | 
| 913 |     QTest::qWait(ms: 0);//Let the animation start | 
| 914 |     QVERIFY(one->x() >= 53.0 && one->x() < 100); | 
| 915 |     QVERIFY(two->x() >= -100.0 && two->x() < 53.0); | 
| 916 |  | 
| 917 |     QTRY_COMPARE(one->x(), 103.0); | 
| 918 |     QTRY_COMPARE(two->y(), 2.0); | 
| 919 |     QTRY_COMPARE(two->x(), 53.0); | 
| 920 |  | 
| 921 | } | 
| 922 |  | 
| 923 | void tst_qquickpositioners::test_horizontal_animated_disabled() | 
| 924 | { | 
| 925 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "horizontal-animated-disabled.qml" ))); | 
| 926 |  | 
| 927 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 928 |     QVERIFY(one != nullptr); | 
| 929 |  | 
| 930 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 931 |     QVERIFY(two != nullptr); | 
| 932 |  | 
| 933 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 934 |     QVERIFY(three != nullptr); | 
| 935 |  | 
| 936 |     QQuickItem *row = window->rootObject()->findChild<QQuickItem*>(aName: "row" ); | 
| 937 |     QVERIFY(row); | 
| 938 |  | 
| 939 |     qApp->processEvents(); | 
| 940 |  | 
| 941 |     // test padding | 
| 942 |     row->setProperty(name: "padding" , value: 1); | 
| 943 |     row->setProperty(name: "topPadding" , value: 2); | 
| 944 |     row->setProperty(name: "leftPadding" , value: 3); | 
| 945 |     row->setProperty(name: "rightPadding" , value: 4); | 
| 946 |     row->setProperty(name: "bottomPadding" , value: 5); | 
| 947 |  | 
| 948 |     QTRY_COMPARE(row->width(), 107.0); | 
| 949 |     QCOMPARE(row->height(), 57.0); | 
| 950 |  | 
| 951 |     QCOMPARE(one->x(), 3.0); | 
| 952 |     QCOMPARE(one->y(), 2.0); | 
| 953 |     QCOMPARE(two->isVisible(), false); | 
| 954 |     QCOMPARE(two->x(), -100.0);//Not 'in' yet | 
| 955 |     QCOMPARE(two->y(), 0.0); | 
| 956 |     QCOMPARE(three->x(), 53.0); | 
| 957 |     QCOMPARE(three->y(), 2.0); | 
| 958 |  | 
| 959 |     //Add 'two' | 
| 960 |     two->setVisible(true); | 
| 961 |     QCOMPARE(two->isVisible(), true); | 
| 962 |     QTRY_COMPARE(row->width(), 157.0); | 
| 963 |     QTRY_COMPARE(row->height(), 57.0); | 
| 964 |  | 
| 965 |     QTRY_COMPARE(two->y(), 2.0); | 
| 966 |     QTRY_COMPARE(two->x(), 53.0); | 
| 967 |     QTRY_COMPARE(three->x(), 103.0); | 
| 968 |  | 
| 969 | } | 
| 970 |  | 
| 971 | void tst_qquickpositioners::test_horizontal_animated_disabled_padding() | 
| 972 | { | 
| 973 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "horizontal-animated-disabled.qml" ))); | 
| 974 |  | 
| 975 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 976 |     QVERIFY(one != nullptr); | 
| 977 |  | 
| 978 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 979 |     QVERIFY(two != nullptr); | 
| 980 |  | 
| 981 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 982 |     QVERIFY(three != nullptr); | 
| 983 |  | 
| 984 |     QQuickItem *row = window->rootObject()->findChild<QQuickItem*>(aName: "row" ); | 
| 985 |     QVERIFY(row); | 
| 986 |  | 
| 987 |     qApp->processEvents(); | 
| 988 |  | 
| 989 |     QCOMPARE(one->x(), 0.0); | 
| 990 |     QCOMPARE(one->y(), 0.0); | 
| 991 |     QCOMPARE(two->isVisible(), false); | 
| 992 |     QCOMPARE(two->x(), -100.0);//Not 'in' yet | 
| 993 |     QCOMPARE(two->y(), 0.0); | 
| 994 |     QCOMPARE(three->x(), 50.0); | 
| 995 |     QCOMPARE(three->y(), 0.0); | 
| 996 |  | 
| 997 |     //Add 'two' | 
| 998 |     two->setVisible(true); | 
| 999 |     QCOMPARE(two->isVisible(), true); | 
| 1000 |     QTRY_COMPARE(row->width(), 150.0); | 
| 1001 |     QTRY_COMPARE(row->height(), 50.0); | 
| 1002 |  | 
| 1003 |     QTRY_COMPARE(two->x(), 50.0); | 
| 1004 |     QTRY_COMPARE(three->x(), 100.0); | 
| 1005 |  | 
| 1006 | } | 
| 1007 |  | 
| 1008 | void tst_qquickpositioners::populateTransitions(const QString &positionerObjectName) | 
| 1009 | { | 
| 1010 |     QFETCH(QString, qmlFile); | 
| 1011 |     QFETCH(bool, dynamicallyPopulate); | 
| 1012 |     QFETCH(bool, usePopulateTransition); | 
| 1013 |  | 
| 1014 |     QPointF targetItems_transitionFrom(-50, -50); | 
| 1015 |     QPointF displacedItems_transitionVia(100, 100); | 
| 1016 |  | 
| 1017 |     QaimModel model; | 
| 1018 |     if (!dynamicallyPopulate) { | 
| 1019 |         for (int i = 0; i < 30; i++) | 
| 1020 |             model.addItem(name: "Original item"  + QString::number(i), number: "" ); | 
| 1021 |     } | 
| 1022 |  | 
| 1023 |     QaimModel model_targetItems_transitionFrom; | 
| 1024 |     QaimModel model_displacedItems_transitionVia; | 
| 1025 |  | 
| 1026 |     QScopedPointer<QQuickView> window(QQuickViewTestUtil::createView()); | 
| 1027 |  | 
| 1028 |     window->setInitialProperties({ | 
| 1029 |             {"usePopulateTransition" , usePopulateTransition}, | 
| 1030 |             {"enableAddTransition" , true}, | 
| 1031 |             {"dynamicallyPopulate" , dynamicallyPopulate}, | 
| 1032 |             {"testModel" , QVariant::fromValue(value: &model)}, | 
| 1033 |             {"model_targetItems_transitionFrom" , QVariant::fromValue(value: &model_targetItems_transitionFrom)}, | 
| 1034 |             {"model_displacedItems_transitionVia" , QVariant::fromValue(value: &model_displacedItems_transitionVia)}, | 
| 1035 |             {"targetItems_transitionFrom" , targetItems_transitionFrom}, | 
| 1036 |             {"displacedItems_transitionVia" , displacedItems_transitionVia}, | 
| 1037 |             {"testedPositioner" , positionerObjectName} | 
| 1038 |     }); | 
| 1039 |     window->setSource(testFileUrl(fileName: qmlFile)); | 
| 1040 |  | 
| 1041 |     QQuickItem *positioner = window->rootObject()->findChild<QQuickItem*>(aName: positionerObjectName); | 
| 1042 |     QVERIFY(positioner); | 
| 1043 |     window->show(); | 
| 1044 |     QVERIFY(QTest::qWaitForWindowExposed(window.data())); | 
| 1045 |     qApp->processEvents(); | 
| 1046 |  | 
| 1047 |     if (!dynamicallyPopulate && usePopulateTransition) { | 
| 1048 |         QTRY_COMPARE(window->rootObject()->property("populateTransitionsDone" ).toInt(), model.count()); | 
| 1049 |         QTRY_COMPARE(window->rootObject()->property("addTransitionsDone" ).toInt(), 0); | 
| 1050 |  | 
| 1051 |         QList<QPair<QString, QString> > targetData; | 
| 1052 |         QList<int> targetIndexes; | 
| 1053 |         for (int i=0; i<model.count(); i++) { | 
| 1054 |             targetData << qMakePair(x: model.name(index: i), y: model.number(index: i)); | 
| 1055 |             targetIndexes << i; | 
| 1056 |         } | 
| 1057 |         QList<QQuickItem *> targetItems = findItems<QQuickItem>(parent: positioner, objectName: "wrapper" , indexes: targetIndexes); | 
| 1058 |         model_targetItems_transitionFrom.matchAgainst(other: targetData, error1: "wasn't animated from target 'from' pos" , error2: "shouldn't have been animated from target 'from' pos" ); | 
| 1059 |         matchItemsAndIndexes(items: window->rootObject()->property(name: "targetTrans_items" ).toMap(), model, expectedIndexes: targetIndexes); | 
| 1060 |         matchIndexLists(indexLists: window->rootObject()->property(name: "targetTrans_targetIndexes" ).toList(), expectedIndexes: targetIndexes); | 
| 1061 |         matchItemLists(itemLists: window->rootObject()->property(name: "targetTrans_targetItems" ).toList(), expectedItems: targetItems); | 
| 1062 |  | 
| 1063 |     } else if (dynamicallyPopulate) { | 
| 1064 |         QTRY_COMPARE(window->rootObject()->property("populateTransitionsDone" ).toInt(), 0); | 
| 1065 |         QTRY_COMPARE(window->rootObject()->property("addTransitionsDone" ).toInt(), model.count()); | 
| 1066 |     } else { | 
| 1067 |         QVERIFY(QQuickTest::qWaitForItemPolished(positioner)); | 
| 1068 |         QTRY_COMPARE(window->rootObject()->property("populateTransitionsDone" ).toInt(), 0); | 
| 1069 |         QTRY_COMPARE(window->rootObject()->property("addTransitionsDone" ).toInt(), 0); | 
| 1070 |     } | 
| 1071 |  | 
| 1072 |     checkItemPositions(positioner, model: &model, incrementalSize: window->rootObject()->property(name: "incrementalSize" ).toInt()); | 
| 1073 |  | 
| 1074 |     // add an item and check this is done with add transition, not populate | 
| 1075 |     window->rootObject()->setProperty(name: "populateTransitionsDone" , value: 0); | 
| 1076 |     window->rootObject()->setProperty(name: "addTransitionsDone" , value: 0); | 
| 1077 |     model.insertItem(index: 0, name: "new item" , number: "" ); | 
| 1078 |     QTRY_COMPARE(window->rootObject()->property("addTransitionsDone" ).toInt(), 1); | 
| 1079 |     QTRY_COMPARE(window->rootObject()->property("populateTransitionsDone" ).toInt(), 0); | 
| 1080 | } | 
| 1081 |  | 
| 1082 | void tst_qquickpositioners::populateTransitions_data() | 
| 1083 | { | 
| 1084 |     QTest::addColumn<QString>(name: "qmlFile" ); | 
| 1085 |     QTest::addColumn<bool>(name: "dynamicallyPopulate" ); | 
| 1086 |     QTest::addColumn<bool>(name: "usePopulateTransition" ); | 
| 1087 |  | 
| 1088 |     QTest::newRow(dataTag: "statically populate" ) << "transitions.qml"  << false << true; | 
| 1089 |     QTest::newRow(dataTag: "statically populate, no populate transition" ) << "transitions.qml"  << false << false; | 
| 1090 |     QTest::newRow(dataTag: "padding, statically populate" ) << "transitions-padding.qml"  << false << true; | 
| 1091 |     QTest::newRow(dataTag: "padding, statically populate, no populate transition" ) << "transitions-padding.qml"  << false << false; | 
| 1092 |  | 
| 1093 |     QTest::newRow(dataTag: "dynamically populate" ) << "transitions.qml"  << true << true; | 
| 1094 |     QTest::newRow(dataTag: "dynamically populate, no populate transition" ) << "transitions.qml"  << true << false; | 
| 1095 |     QTest::newRow(dataTag: "padding, dynamically populate" ) << "transitions-padding.qml"  << true << true; | 
| 1096 |     QTest::newRow(dataTag: "padding, dynamically populate, no populate transition" ) << "transitions-padding.qml"  << true << false; | 
| 1097 | } | 
| 1098 |  | 
| 1099 | void tst_qquickpositioners::addTransitions(const QString &positionerObjectName) | 
| 1100 | { | 
| 1101 |     QFETCH(QString, qmlFile); | 
| 1102 |     QFETCH(int, initialItemCount); | 
| 1103 |     QFETCH(int, insertionIndex); | 
| 1104 |     QFETCH(int, insertionCount); | 
| 1105 |     QFETCH(ListRange, expectedDisplacedIndexes); | 
| 1106 |  | 
| 1107 |     QPointF targetItems_transitionFrom(-50, -50); | 
| 1108 |     QPointF displacedItems_transitionVia(100, 100); | 
| 1109 |  | 
| 1110 |     QaimModel model; | 
| 1111 |     QaimModel model_targetItems_transitionFrom; | 
| 1112 |     QaimModel model_displacedItems_transitionVia; | 
| 1113 |  | 
| 1114 |     QScopedPointer<QQuickView> window(QQuickViewTestUtil::createView()); | 
| 1115 |     window->setInitialProperties({ | 
| 1116 |             {"usePopulateTransition" , QVariant(false)}, | 
| 1117 |             {"enableAddTransition" , QVariant(true)}, | 
| 1118 |             {"dynamicallyPopulate" , QVariant(false)}, | 
| 1119 |             {"testModel" , QVariant::fromValue(value: &model)}, | 
| 1120 |             {"model_targetItems_transitionFrom" , QVariant::fromValue(value: &model_targetItems_transitionFrom)}, | 
| 1121 |             {"model_displacedItems_transitionVia" , QVariant::fromValue(value: &model_displacedItems_transitionVia)}, | 
| 1122 |             {"targetItems_transitionFrom" , targetItems_transitionFrom}, | 
| 1123 |             {"displacedItems_transitionVia" , displacedItems_transitionVia}, | 
| 1124 |             {"testedPositioner" , QString()} | 
| 1125 |     }); | 
| 1126 |     window->setSource(testFileUrl(fileName: qmlFile)); | 
| 1127 |     window->show(); | 
| 1128 |     QVERIFY(QTest::qWaitForWindowExposed(window.data())); | 
| 1129 |     qApp->processEvents(); | 
| 1130 |  | 
| 1131 |     QQuickItem *positioner = window->rootObject()->findChild<QQuickItem*>(aName: positionerObjectName); | 
| 1132 |     QVERIFY(positioner); | 
| 1133 |     positioner->findChild<QQuickItem*>(aName: "repeater" )->setProperty(name: "model" , value: QVariant::fromValue(value: &model)); | 
| 1134 |     QVERIFY(QQuickTest::qWaitForItemPolished(positioner)); | 
| 1135 |  | 
| 1136 |     for (int i = 0; i < initialItemCount; i++) | 
| 1137 |         model.addItem(name: "Original item"  + QString::number(i), number: "" ); | 
| 1138 |  | 
| 1139 |     QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); | 
| 1140 |     QList<QPair<QString, QString> > targetData; | 
| 1141 |     QList<int> targetIndexes; | 
| 1142 |     for (int i=0; i<model.count(); i++) { | 
| 1143 |         targetData << qMakePair(x: model.name(index: i), y: model.number(index: i)); | 
| 1144 |         targetIndexes << i; | 
| 1145 |     } | 
| 1146 |     QList<QQuickItem *> targetItems = findItems<QQuickItem>(parent: positioner, objectName: "wrapper" , indexes: targetIndexes); | 
| 1147 |  | 
| 1148 |     // check add transition was run for first lot of added items | 
| 1149 |     QTRY_COMPARE(window->rootObject()->property("populateTransitionsDone" ).toInt(), 0); | 
| 1150 |     QTRY_COMPARE(window->rootObject()->property("addTransitionsDone" ).toInt(), initialItemCount); | 
| 1151 |     QTRY_COMPARE(window->rootObject()->property("displaceTransitionsDone" ).toInt(), 0); | 
| 1152 |     model_targetItems_transitionFrom.matchAgainst(other: targetData, error1: "wasn't animated from target 'from' pos" , error2: "shouldn't have been animated from target 'from' pos" ); | 
| 1153 |     matchItemsAndIndexes(items: window->rootObject()->property(name: "targetTrans_items" ).toMap(), model, expectedIndexes: targetIndexes); | 
| 1154 |     matchIndexLists(indexLists: window->rootObject()->property(name: "targetTrans_targetIndexes" ).toList(), expectedIndexes: targetIndexes); | 
| 1155 |     matchItemLists(itemLists: window->rootObject()->property(name: "targetTrans_targetItems" ).toList(), expectedItems: targetItems); | 
| 1156 |  | 
| 1157 |     model_targetItems_transitionFrom.clear(); | 
| 1158 |     window->rootObject()->setProperty(name: "addTransitionsDone" , value: 0); | 
| 1159 |     window->rootObject()->setProperty(name: "targetTrans_items" , value: QVariantMap()); | 
| 1160 |     window->rootObject()->setProperty(name: "targetTrans_targetIndexes" , value: QVariantList()); | 
| 1161 |     window->rootObject()->setProperty(name: "targetTrans_targetItems" , value: QVariantList()); | 
| 1162 |  | 
| 1163 |     // do insertion | 
| 1164 |     targetData.clear(); | 
| 1165 |     targetIndexes.clear(); | 
| 1166 |     for (int i=insertionIndex; i<insertionIndex+insertionCount; i++) { | 
| 1167 |         targetData << qMakePair(x: QString("New item %1" ).arg(a: i), y: QString("" )); | 
| 1168 |         targetIndexes << i; | 
| 1169 |     } | 
| 1170 |     model.insertItems(index: insertionIndex, items: targetData); | 
| 1171 |     QTRY_COMPARE(model.count(), positioner->property("count" ).toInt()); | 
| 1172 |  | 
| 1173 |     targetItems = findItems<QQuickItem>(parent: positioner, objectName: "wrapper" , indexes: targetIndexes); | 
| 1174 |  | 
| 1175 |     QTRY_COMPARE(window->rootObject()->property("addTransitionsDone" ).toInt(), targetData.count()); | 
| 1176 |     QTRY_COMPARE(window->rootObject()->property("displaceTransitionsDone" ).toInt(), expectedDisplacedIndexes.count()); | 
| 1177 |  | 
| 1178 |     // check the target and displaced items were animated | 
| 1179 |     model_targetItems_transitionFrom.matchAgainst(other: targetData, error1: "wasn't animated from target 'from' pos" , error2: "shouldn't have been animated from target 'from' pos" ); | 
| 1180 |     model_displacedItems_transitionVia.matchAgainst(other: expectedDisplacedValues, error1: "wasn't animated with displaced anim" , error2: "shouldn't have been animated with displaced anim" ); | 
| 1181 |  | 
| 1182 |     // check attached properties | 
| 1183 |     matchItemsAndIndexes(items: window->rootObject()->property(name: "targetTrans_items" ).toMap(), model, expectedIndexes: targetIndexes); | 
| 1184 |     matchIndexLists(indexLists: window->rootObject()->property(name: "targetTrans_targetIndexes" ).toList(), expectedIndexes: targetIndexes); | 
| 1185 |     matchItemLists(itemLists: window->rootObject()->property(name: "targetTrans_targetItems" ).toList(), expectedItems: targetItems); | 
| 1186 |     if (expectedDisplacedIndexes.isValid()) { | 
| 1187 |         // adjust expectedDisplacedIndexes to their final values after the move | 
| 1188 |         QList<int> displacedIndexes = adjustIndexesForAddDisplaced(indexes: expectedDisplacedIndexes.indexes, index: insertionIndex, count: insertionCount); | 
| 1189 |         matchItemsAndIndexes(items: window->rootObject()->property(name: "displacedTrans_items" ).toMap(), model, expectedIndexes: displacedIndexes); | 
| 1190 |         matchIndexLists(indexLists: window->rootObject()->property(name: "displacedTrans_targetIndexes" ).toList(), expectedIndexes: targetIndexes); | 
| 1191 |         matchItemLists(itemLists: window->rootObject()->property(name: "displacedTrans_targetItems" ).toList(), expectedItems: targetItems); | 
| 1192 |     } | 
| 1193 |  | 
| 1194 |     checkItemPositions(positioner, model: &model, incrementalSize: window->rootObject()->property(name: "incrementalSize" ).toInt()); | 
| 1195 | } | 
| 1196 |  | 
| 1197 | void tst_qquickpositioners::addTransitions_data() | 
| 1198 | { | 
| 1199 |     // If this data changes, update addTransitions_grid_data() also | 
| 1200 |  | 
| 1201 |     QTest::addColumn<QString>(name: "qmlFile" ); | 
| 1202 |     QTest::addColumn<int>(name: "initialItemCount" ); | 
| 1203 |     QTest::addColumn<int>(name: "insertionIndex" ); | 
| 1204 |     QTest::addColumn<int>(name: "insertionCount" ); | 
| 1205 |     QTest::addColumn<ListRange>(name: "expectedDisplacedIndexes" ); | 
| 1206 |  | 
| 1207 |     QTest::newRow(dataTag: "add one @ start" ) << "transitions.qml"  << 10 << 0 << 1 << ListRange(0, 9); | 
| 1208 |     QTest::newRow(dataTag: "add one @ middle" ) << "transitions.qml"  << 10 << 5 << 1 << ListRange(5, 9); | 
| 1209 |     QTest::newRow(dataTag: "add one @ end" ) << "transitions.qml"  << 10 << 10 << 1 << ListRange(); | 
| 1210 |     QTest::newRow(dataTag: "padding, add one @ start" ) << "transitions-padding.qml"  << 10 << 0 << 1 << ListRange(0, 9); | 
| 1211 |     QTest::newRow(dataTag: "padding, add one @ middle" ) << "transitions-padding.qml"  << 10 << 5 << 1 << ListRange(5, 9); | 
| 1212 |     QTest::newRow(dataTag: "padding, add one @ end" ) << "transitions-padding.qml"  << 10 << 10 << 1 << ListRange(); | 
| 1213 |  | 
| 1214 |     QTest::newRow(dataTag: "add multiple @ start" ) << "transitions.qml"  << 10 << 0 << 3 << ListRange(0, 9); | 
| 1215 |     QTest::newRow(dataTag: "add multiple @ middle" ) << "transitions.qml"  << 10 << 5 << 3 << ListRange(5, 9); | 
| 1216 |     QTest::newRow(dataTag: "add multiple @ end" ) << "transitions.qml"  << 10 << 10 << 3 << ListRange(); | 
| 1217 |     QTest::newRow(dataTag: "padding, add multiple @ start" ) << "transitions-padding.qml"  << 10 << 0 << 3 << ListRange(0, 9); | 
| 1218 |     QTest::newRow(dataTag: "padding, add multiple @ middle" ) << "transitions-padding.qml"  << 10 << 5 << 3 << ListRange(5, 9); | 
| 1219 |     QTest::newRow(dataTag: "padding, add multiple @ end" ) << "transitions-padding.qml"  << 10 << 10 << 3 << ListRange(); | 
| 1220 | } | 
| 1221 |  | 
| 1222 | void tst_qquickpositioners::moveTransitions(const QString &positionerObjectName) | 
| 1223 | { | 
| 1224 |     QFETCH(QString, qmlFile); | 
| 1225 |     QFETCH(int, initialItemCount); | 
| 1226 |     QFETCH(ListChange, change); | 
| 1227 |     QFETCH(ListRange, expectedDisplacedIndexes); | 
| 1228 |  | 
| 1229 |     QPointF targetItems_transitionFrom(-50, -50); | 
| 1230 |     QPointF displacedItems_transitionVia(100, 100); | 
| 1231 |  | 
| 1232 |     QaimModel model; | 
| 1233 |     for (int i = 0; i < initialItemCount; i++) | 
| 1234 |         model.addItem(name: "Item"  + QString::number(i), number: "" ); | 
| 1235 |     QaimModel model_targetItems_transitionFrom; | 
| 1236 |     QaimModel model_displacedItems_transitionVia; | 
| 1237 |  | 
| 1238 |     QScopedPointer<QQuickView> window(QQuickViewTestUtil::createView()); | 
| 1239 |     window->setInitialProperties({ | 
| 1240 |             {"usePopulateTransition" , QVariant(false)}, | 
| 1241 |             {"enableAddTransition" , QVariant(false)}, | 
| 1242 |             {"dynamicallyPopulate" , QVariant(false)}, | 
| 1243 |             {"testModel" , QVariant::fromValue(value: &model)}, | 
| 1244 |             {"model_targetItems_transitionFrom" , QVariant::fromValue(value: &model_targetItems_transitionFrom)}, | 
| 1245 |             {"model_displacedItems_transitionVia" , QVariant::fromValue(value: &model_displacedItems_transitionVia)}, | 
| 1246 |             {"targetItems_transitionFrom" , targetItems_transitionFrom}, | 
| 1247 |             {"displacedItems_transitionVia" , displacedItems_transitionVia}, | 
| 1248 |             {"testedPositioner" , QString()} | 
| 1249 |     }); | 
| 1250 |     window->setSource(testFileUrl(fileName: qmlFile)); | 
| 1251 |     window->show(); | 
| 1252 |     QVERIFY(QTest::qWaitForWindowExposed(window.data())); | 
| 1253 |     qApp->processEvents(); | 
| 1254 |  | 
| 1255 |     QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); | 
| 1256 |  | 
| 1257 |     QQuickItem *positioner = window->rootObject()->findChild<QQuickItem*>(aName: positionerObjectName); | 
| 1258 |     QVERIFY(positioner); | 
| 1259 |     positioner->findChild<QQuickItem*>(aName: "repeater" )->setProperty(name: "model" , value: QVariant::fromValue(value: &model)); | 
| 1260 |     QVERIFY(QQuickTest::qWaitForItemPolished(positioner)); | 
| 1261 |  | 
| 1262 |     switch (change.type) { | 
| 1263 |         case ListChange::Removed: | 
| 1264 |             model.removeItems(index: change.index, count: change.count); | 
| 1265 |             QTRY_COMPARE(model.count(), positioner->property("count" ).toInt()); | 
| 1266 |             break; | 
| 1267 |         case ListChange::Moved: | 
| 1268 |             model.moveItems(from: change.index, to: change.to, count: change.count); | 
| 1269 |             QVERIFY(QQuickTest::qWaitForItemPolished(positioner)); | 
| 1270 |             break; | 
| 1271 |         case ListChange::Inserted: | 
| 1272 |         case ListChange::SetCurrent: | 
| 1273 |         case ListChange::SetContentY: | 
| 1274 |             QVERIFY(false); | 
| 1275 |             break; | 
| 1276 |          case ListChange::Polish: | 
| 1277 |             break; | 
| 1278 |     } | 
| 1279 |  | 
| 1280 |     QTRY_COMPARE(window->rootObject()->property("displaceTransitionsDone" ).toInt(), expectedDisplacedIndexes.count()); | 
| 1281 |     QCOMPARE(window->rootObject()->property("addTransitionsDone" ).toInt(), 0); | 
| 1282 |  | 
| 1283 |     // check the target and displaced items were animated | 
| 1284 |     QCOMPARE(model_targetItems_transitionFrom.count(), 0); | 
| 1285 |     model_displacedItems_transitionVia.matchAgainst(other: expectedDisplacedValues, error1: "wasn't animated with displaced anim" , error2: "shouldn't have been animated with displaced anim" ); | 
| 1286 |  | 
| 1287 |     // check attached properties | 
| 1288 |     QCOMPARE(window->rootObject()->property("targetTrans_items" ).toMap().count(), 0); | 
| 1289 |     QCOMPARE(window->rootObject()->property("targetTrans_targetIndexes" ).toList().count(), 0); | 
| 1290 |     QCOMPARE(window->rootObject()->property("targetTrans_targetItems" ).toList().count(), 0); | 
| 1291 |     if (expectedDisplacedIndexes.isValid()) { | 
| 1292 |         // adjust expectedDisplacedIndexes to their final values after the move | 
| 1293 |         QList<int> displacedIndexes; | 
| 1294 |         if (change.type == ListChange::Inserted) | 
| 1295 |             displacedIndexes = adjustIndexesForAddDisplaced(indexes: expectedDisplacedIndexes.indexes, index: change.index, count: change.count); | 
| 1296 |         else if (change.type == ListChange::Moved) | 
| 1297 |             displacedIndexes = adjustIndexesForMove(indexes: expectedDisplacedIndexes.indexes, from: change.index, to: change.to, count: change.count); | 
| 1298 |         else if (change.type == ListChange::Removed) | 
| 1299 |             displacedIndexes = adjustIndexesForRemoveDisplaced(indexes: expectedDisplacedIndexes.indexes, index: change.index, count: change.count); | 
| 1300 |         else | 
| 1301 |             QVERIFY(false); | 
| 1302 |         matchItemsAndIndexes(items: window->rootObject()->property(name: "displacedTrans_items" ).toMap(), model, expectedIndexes: displacedIndexes); | 
| 1303 |  | 
| 1304 |         QVariantList listOfEmptyIntLists; | 
| 1305 |         for (int i=0; i<displacedIndexes.count(); i++) | 
| 1306 |             listOfEmptyIntLists << QVariant::fromValue(value: QList<int>()); | 
| 1307 |         QCOMPARE(window->rootObject()->property("displacedTrans_targetIndexes" ).toList(), listOfEmptyIntLists); | 
| 1308 |         QVariantList listOfEmptyObjectLists; | 
| 1309 |         for (int i=0; i<displacedIndexes.count(); i++) | 
| 1310 |             listOfEmptyObjectLists.insert(i: listOfEmptyObjectLists.count(), t: QVariantList()); | 
| 1311 |         QCOMPARE(window->rootObject()->property("displacedTrans_targetItems" ).toList(), listOfEmptyObjectLists); | 
| 1312 |     } | 
| 1313 |  | 
| 1314 |     checkItemPositions(positioner, model: &model, incrementalSize: window->rootObject()->property(name: "incrementalSize" ).toInt()); | 
| 1315 | } | 
| 1316 |  | 
| 1317 | void tst_qquickpositioners::moveTransitions_data() | 
| 1318 | { | 
| 1319 |     // If this data changes, update moveTransitions_grid_data() also | 
| 1320 |  | 
| 1321 |     QTest::addColumn<QString>(name: "qmlFile" ); | 
| 1322 |     QTest::addColumn<int>(name: "initialItemCount" ); | 
| 1323 |     QTest::addColumn<ListChange>(name: "change" ); | 
| 1324 |     QTest::addColumn<ListRange>(name: "expectedDisplacedIndexes" ); | 
| 1325 |  | 
| 1326 |     QTest::newRow(dataTag: "remove one @ start" ) << "transitions.qml"  << 10 << ListChange::remove(index: 0, count: 1) << ListRange(1, 9); | 
| 1327 |     QTest::newRow(dataTag: "remove one @ middle" ) << "transitions.qml"  << 10 << ListChange::remove(index: 4, count: 1) << ListRange(5, 9); | 
| 1328 |     QTest::newRow(dataTag: "remove one @ end" ) << "transitions.qml"  << 10 << ListChange::remove(index: 9, count: 1) << ListRange(); | 
| 1329 |     QTest::newRow(dataTag: "padding, remove one @ start" ) << "transitions-padding.qml"  << 10 << ListChange::remove(index: 0, count: 1) << ListRange(1, 9); | 
| 1330 |     QTest::newRow(dataTag: "padding, remove one @ middle" ) << "transitions-padding.qml"  << 10 << ListChange::remove(index: 4, count: 1) << ListRange(5, 9); | 
| 1331 |     QTest::newRow(dataTag: "padding, remove one @ end" ) << "transitions-padding.qml"  << 10 << ListChange::remove(index: 9, count: 1) << ListRange(); | 
| 1332 |  | 
| 1333 |     QTest::newRow(dataTag: "remove multiple @ start" ) << "transitions.qml"  << 10 << ListChange::remove(index: 0, count: 3) << ListRange(3, 9); | 
| 1334 |     QTest::newRow(dataTag: "remove multiple @ middle" ) << "transitions.qml"  << 10 << ListChange::remove(index: 4, count: 3) << ListRange(7, 9); | 
| 1335 |     QTest::newRow(dataTag: "remove multiple @ end" ) << "transitions.qml"  << 10 << ListChange::remove(index: 7, count: 3) << ListRange(); | 
| 1336 |     QTest::newRow(dataTag: "padding, remove multiple @ start" ) << "transitions-padding.qml"  << 10 << ListChange::remove(index: 0, count: 3) << ListRange(3, 9); | 
| 1337 |     QTest::newRow(dataTag: "padding, remove multiple @ middle" ) << "transitions-padding.qml"  << 10 << ListChange::remove(index: 4, count: 3) << ListRange(7, 9); | 
| 1338 |     QTest::newRow(dataTag: "padding, remove multiple @ end" ) << "transitions-padding.qml"  << 10 << ListChange::remove(index: 7, count: 3) << ListRange(); | 
| 1339 | } | 
| 1340 |  | 
| 1341 | void tst_qquickpositioners::checkItemPositions(QQuickItem *positioner, QaimModel *model, qreal incrementalSize) | 
| 1342 | { | 
| 1343 |     QVERIFY(model->count() > 0); | 
| 1344 |  | 
| 1345 |     QQuickBasePositioner *p = qobject_cast<QQuickBasePositioner*>(object: positioner); | 
| 1346 |  | 
| 1347 |     qreal padding = 0; | 
| 1348 |     qreal currentSize = 30; | 
| 1349 |     qreal rowX = p->leftPadding(); | 
| 1350 |     qreal rowY = p->topPadding(); | 
| 1351 |  | 
| 1352 |     for (int i=0; i<model->count(); ++i) { | 
| 1353 |         QQuickItem *item = findItem<QQuickItem>(parent: positioner, objectName: "wrapper" , index: i); | 
| 1354 |         QVERIFY2(item, QTest::toString(QString("Item %1 not found" ).arg(i))); | 
| 1355 |  | 
| 1356 |         QCOMPARE(item->width(), currentSize); | 
| 1357 |         QCOMPARE(item->height(), currentSize); | 
| 1358 |  | 
| 1359 |         if (qobject_cast<QQuickRow*>(object: positioner)) { | 
| 1360 |             QCOMPARE(item->x(), (i * 30.0) + padding + p->leftPadding()); | 
| 1361 |             QCOMPARE(item->y(), p->topPadding()); | 
| 1362 |         } else if (qobject_cast<QQuickColumn*>(object: positioner)) { | 
| 1363 |             QCOMPARE(item->x(), p->leftPadding()); | 
| 1364 |             QCOMPARE(item->y(), (i * 30.0) + padding + p->topPadding()); | 
| 1365 |         } else if (qobject_cast<QQuickGrid*>(object: positioner)) { | 
| 1366 |             int columns = 4; | 
| 1367 |             int rows = qCeil(v: model->count() / qreal(columns)); | 
| 1368 |             int lastMatchingRowIndex = (rows * columns) - (columns - i%columns); | 
| 1369 |             if (lastMatchingRowIndex >= model->count()) | 
| 1370 |                 lastMatchingRowIndex -= columns; | 
| 1371 |             if (i % columns > 0) { | 
| 1372 |                 QQuickItem *finalAlignedRowItem = findItem<QQuickItem>(parent: positioner, objectName: "wrapper" , index: lastMatchingRowIndex); | 
| 1373 |                 QVERIFY(finalAlignedRowItem); | 
| 1374 |                 QCOMPARE(item->x(), finalAlignedRowItem->x()); | 
| 1375 |             } else { | 
| 1376 |                 QCOMPARE(item->x(), p->leftPadding()); | 
| 1377 |             } | 
| 1378 |             if (i / columns > 0) { | 
| 1379 |                 QQuickItem *prevRowLastItem = findItem<QQuickItem>(parent: positioner, objectName: "wrapper" , index: (i/columns * columns) - 1); | 
| 1380 |                 QVERIFY(prevRowLastItem); | 
| 1381 |                 QCOMPARE(item->y(), prevRowLastItem->y() + prevRowLastItem->height()); | 
| 1382 |             } else { | 
| 1383 |                 QCOMPARE(item->y(), p->topPadding()); | 
| 1384 |             } | 
| 1385 |         } else if (qobject_cast<QQuickFlow*>(object: positioner)) { | 
| 1386 |             if (rowX + item->width() > positioner->width()) { | 
| 1387 |                 QQuickItem *prevItem = findItem<QQuickItem>(parent: positioner, objectName: "wrapper" , index: i-1); | 
| 1388 |                 QVERIFY(prevItem); | 
| 1389 |                 rowX = p->leftPadding(); | 
| 1390 |                 rowY = prevItem->y() + prevItem->height(); | 
| 1391 |             } | 
| 1392 |             QCOMPARE(item->x(), rowX); | 
| 1393 |             QCOMPARE(item->y(), rowY); | 
| 1394 |             rowX += item->width(); | 
| 1395 |         } else { | 
| 1396 |             QVERIFY2(false, "Unknown positioner type" ); | 
| 1397 |         } | 
| 1398 |         QQuickText *name = findItem<QQuickText>(parent: positioner, objectName: "name" , index: i); | 
| 1399 |         QVERIFY(name != nullptr); | 
| 1400 |         QTRY_COMPARE(name->text(), model->name(i)); | 
| 1401 |  | 
| 1402 |         padding += i * incrementalSize; | 
| 1403 |         currentSize += incrementalSize; | 
| 1404 |     } | 
| 1405 | } | 
| 1406 |  | 
| 1407 | void tst_qquickpositioners::test_vertical() | 
| 1408 | { | 
| 1409 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "vertical.qml" ))); | 
| 1410 |  | 
| 1411 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 1412 |     QVERIFY(one != nullptr); | 
| 1413 |  | 
| 1414 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 1415 |     QVERIFY(two != nullptr); | 
| 1416 |  | 
| 1417 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 1418 |     QVERIFY(three != nullptr); | 
| 1419 |  | 
| 1420 |     QCOMPARE(one->x(), 0.0); | 
| 1421 |     QCOMPARE(one->y(), 0.0); | 
| 1422 |     QCOMPARE(two->x(), 0.0); | 
| 1423 |     QCOMPARE(two->y(), 50.0); | 
| 1424 |     QCOMPARE(three->x(), 0.0); | 
| 1425 |     QCOMPARE(three->y(), 60.0); | 
| 1426 |  | 
| 1427 |     QQuickItem *column = window->rootObject()->findChild<QQuickItem*>(aName: "column" ); | 
| 1428 |     QVERIFY(column); | 
| 1429 |     QCOMPARE(column->height(), 80.0); | 
| 1430 |     QCOMPARE(column->width(), 50.0); | 
| 1431 |  | 
| 1432 |     // test padding | 
| 1433 |     column->setProperty(name: "padding" , value: 1); | 
| 1434 |     column->setProperty(name: "topPadding" , value: 2); | 
| 1435 |     column->setProperty(name: "leftPadding" , value: 3); | 
| 1436 |     column->setProperty(name: "rightPadding" , value: 4); | 
| 1437 |     column->setProperty(name: "bottomPadding" , value: 5); | 
| 1438 |  | 
| 1439 |     QTRY_COMPARE(column->height(), 87.0); | 
| 1440 |     QCOMPARE(column->width(), 57.0); | 
| 1441 |  | 
| 1442 |     QCOMPARE(one->x(), 3.0); | 
| 1443 |     QCOMPARE(one->y(), 2.0); | 
| 1444 |     QCOMPARE(two->x(), 3.0); | 
| 1445 |     QCOMPARE(two->y(), 52.0); | 
| 1446 |     QCOMPARE(three->x(), 3.0); | 
| 1447 |     QCOMPARE(three->y(), 62.0); | 
| 1448 | } | 
| 1449 |  | 
| 1450 | void tst_qquickpositioners::test_vertical_padding() | 
| 1451 | { | 
| 1452 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "vertical.qml" ))); | 
| 1453 |  | 
| 1454 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 1455 |     QVERIFY(one != nullptr); | 
| 1456 |  | 
| 1457 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 1458 |     QVERIFY(two != nullptr); | 
| 1459 |  | 
| 1460 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 1461 |     QVERIFY(three != nullptr); | 
| 1462 |  | 
| 1463 |     QCOMPARE(one->x(), 0.0); | 
| 1464 |     QCOMPARE(one->y(), 0.0); | 
| 1465 |     QCOMPARE(two->x(), 0.0); | 
| 1466 |     QCOMPARE(two->y(), 50.0); | 
| 1467 |     QCOMPARE(three->x(), 0.0); | 
| 1468 |     QCOMPARE(three->y(), 60.0); | 
| 1469 |  | 
| 1470 |     QQuickItem *column = window->rootObject()->findChild<QQuickItem*>(aName: "column" ); | 
| 1471 |     QVERIFY(column); | 
| 1472 |     QCOMPARE(column->height(), 80.0); | 
| 1473 |     QCOMPARE(column->width(), 50.0); | 
| 1474 |  | 
| 1475 |     QQuickColumn *obj = qobject_cast<QQuickColumn*>(object: column); | 
| 1476 |     QVERIFY(obj != nullptr); | 
| 1477 |  | 
| 1478 |     QCOMPARE(column->property("padding" ).toDouble(), 0.0); | 
| 1479 |     QCOMPARE(column->property("topPadding" ).toDouble(), 0.0); | 
| 1480 |     QCOMPARE(column->property("leftPadding" ).toDouble(), 0.0); | 
| 1481 |     QCOMPARE(column->property("rightPadding" ).toDouble(), 0.0); | 
| 1482 |     QCOMPARE(column->property("bottomPadding" ).toDouble(), 0.0); | 
| 1483 |  | 
| 1484 |     obj->setPadding(1.0); | 
| 1485 |  | 
| 1486 |     QCOMPARE(column->property("padding" ).toDouble(), 1.0); | 
| 1487 |     QCOMPARE(column->property("topPadding" ).toDouble(), 1.0); | 
| 1488 |     QCOMPARE(column->property("leftPadding" ).toDouble(), 1.0); | 
| 1489 |     QCOMPARE(column->property("rightPadding" ).toDouble(), 1.0); | 
| 1490 |     QCOMPARE(column->property("bottomPadding" ).toDouble(), 1.0); | 
| 1491 |  | 
| 1492 |     QTRY_COMPARE(column->height(), 82.0); | 
| 1493 |     QCOMPARE(column->width(), 52.0); | 
| 1494 |  | 
| 1495 |     QCOMPARE(one->x(), 1.0); | 
| 1496 |     QCOMPARE(one->y(), 1.0); | 
| 1497 |     QCOMPARE(two->x(), 1.0); | 
| 1498 |     QCOMPARE(two->y(), 51.0); | 
| 1499 |     QCOMPARE(three->x(), 1.0); | 
| 1500 |     QCOMPARE(three->y(), 61.0); | 
| 1501 |  | 
| 1502 |     obj->setTopPadding(2.0); | 
| 1503 |  | 
| 1504 |     QCOMPARE(column->property("padding" ).toDouble(), 1.0); | 
| 1505 |     QCOMPARE(column->property("topPadding" ).toDouble(), 2.0); | 
| 1506 |     QCOMPARE(column->property("leftPadding" ).toDouble(), 1.0); | 
| 1507 |     QCOMPARE(column->property("rightPadding" ).toDouble(), 1.0); | 
| 1508 |     QCOMPARE(column->property("bottomPadding" ).toDouble(), 1.0); | 
| 1509 |  | 
| 1510 |     QTRY_COMPARE(column->height(), 83.0); | 
| 1511 |     QCOMPARE(column->width(), 52.0); | 
| 1512 |  | 
| 1513 |     QCOMPARE(one->x(), 1.0); | 
| 1514 |     QCOMPARE(one->y(), 2.0); | 
| 1515 |     QCOMPARE(two->x(), 1.0); | 
| 1516 |     QCOMPARE(two->y(), 52.0); | 
| 1517 |     QCOMPARE(three->x(), 1.0); | 
| 1518 |     QCOMPARE(three->y(), 62.0); | 
| 1519 |  | 
| 1520 |     obj->setLeftPadding(3.0); | 
| 1521 |  | 
| 1522 |     QCOMPARE(column->property("padding" ).toDouble(), 1.0); | 
| 1523 |     QCOMPARE(column->property("topPadding" ).toDouble(), 2.0); | 
| 1524 |     QCOMPARE(column->property("leftPadding" ).toDouble(), 3.0); | 
| 1525 |     QCOMPARE(column->property("rightPadding" ).toDouble(), 1.0); | 
| 1526 |     QCOMPARE(column->property("bottomPadding" ).toDouble(), 1.0); | 
| 1527 |  | 
| 1528 |     QTRY_COMPARE(column->width(), 54.0); | 
| 1529 |     QCOMPARE(column->height(), 83.0); | 
| 1530 |  | 
| 1531 |     QCOMPARE(one->x(), 3.0); | 
| 1532 |     QCOMPARE(one->y(), 2.0); | 
| 1533 |     QCOMPARE(two->x(), 3.0); | 
| 1534 |     QCOMPARE(two->y(), 52.0); | 
| 1535 |     QCOMPARE(three->x(), 3.0); | 
| 1536 |     QCOMPARE(three->y(), 62.0); | 
| 1537 |  | 
| 1538 |     obj->setRightPadding(4.0); | 
| 1539 |  | 
| 1540 |     QCOMPARE(column->property("padding" ).toDouble(), 1.0); | 
| 1541 |     QCOMPARE(column->property("topPadding" ).toDouble(), 2.0); | 
| 1542 |     QCOMPARE(column->property("leftPadding" ).toDouble(), 3.0); | 
| 1543 |     QCOMPARE(column->property("rightPadding" ).toDouble(), 4.0); | 
| 1544 |     QCOMPARE(column->property("bottomPadding" ).toDouble(), 1.0); | 
| 1545 |  | 
| 1546 |     QTRY_COMPARE(column->width(), 57.0); | 
| 1547 |     QCOMPARE(column->height(), 83.0); | 
| 1548 |  | 
| 1549 |     QCOMPARE(one->x(), 3.0); | 
| 1550 |     QCOMPARE(one->y(), 2.0); | 
| 1551 |     QCOMPARE(two->x(), 3.0); | 
| 1552 |     QCOMPARE(two->y(), 52.0); | 
| 1553 |     QCOMPARE(three->x(), 3.0); | 
| 1554 |     QCOMPARE(three->y(), 62.0); | 
| 1555 |  | 
| 1556 |     obj->setBottomPadding(5.0); | 
| 1557 |  | 
| 1558 |     QCOMPARE(column->property("padding" ).toDouble(), 1.0); | 
| 1559 |     QCOMPARE(column->property("topPadding" ).toDouble(), 2.0); | 
| 1560 |     QCOMPARE(column->property("leftPadding" ).toDouble(), 3.0); | 
| 1561 |     QCOMPARE(column->property("rightPadding" ).toDouble(), 4.0); | 
| 1562 |     QCOMPARE(column->property("bottomPadding" ).toDouble(), 5.0); | 
| 1563 |  | 
| 1564 |     QTRY_COMPARE(column->height(), 87.0); | 
| 1565 |     QCOMPARE(column->width(), 57.0); | 
| 1566 |  | 
| 1567 |     QCOMPARE(one->x(), 3.0); | 
| 1568 |     QCOMPARE(one->y(), 2.0); | 
| 1569 |     QCOMPARE(two->x(), 3.0); | 
| 1570 |     QCOMPARE(two->y(), 52.0); | 
| 1571 |     QCOMPARE(three->x(), 3.0); | 
| 1572 |     QCOMPARE(three->y(), 62.0); | 
| 1573 |  | 
| 1574 |     obj->resetBottomPadding(); | 
| 1575 |     QCOMPARE(column->property("bottomPadding" ).toDouble(), 1.0); | 
| 1576 |     QTRY_COMPARE(column->height(), 83.0); | 
| 1577 |     QCOMPARE(column->width(), 57.0); | 
| 1578 |  | 
| 1579 |     obj->resetRightPadding(); | 
| 1580 |     QCOMPARE(column->property("rightPadding" ).toDouble(), 1.0); | 
| 1581 |     QTRY_COMPARE(column->width(), 54.0); | 
| 1582 |     QCOMPARE(column->height(), 83.0); | 
| 1583 |  | 
| 1584 |     obj->resetLeftPadding(); | 
| 1585 |     QCOMPARE(column->property("leftPadding" ).toDouble(), 1.0); | 
| 1586 |     QTRY_COMPARE(column->width(), 52.0); | 
| 1587 |     QCOMPARE(column->height(), 83.0); | 
| 1588 |  | 
| 1589 |     obj->resetTopPadding(); | 
| 1590 |     QCOMPARE(column->property("topPadding" ).toDouble(), 1.0); | 
| 1591 |     QTRY_COMPARE(column->height(), 82.0); | 
| 1592 |     QCOMPARE(column->width(), 52.0); | 
| 1593 |  | 
| 1594 |     obj->resetPadding(); | 
| 1595 |     QCOMPARE(column->property("padding" ).toDouble(), 0.0); | 
| 1596 |     QCOMPARE(column->property("topPadding" ).toDouble(), 0.0); | 
| 1597 |     QCOMPARE(column->property("leftPadding" ).toDouble(), 0.0); | 
| 1598 |     QCOMPARE(column->property("rightPadding" ).toDouble(), 0.0); | 
| 1599 |     QCOMPARE(column->property("bottomPadding" ).toDouble(), 0.0); | 
| 1600 |     QTRY_COMPARE(column->height(), 80.0); | 
| 1601 |     QCOMPARE(column->width(), 50.0); | 
| 1602 |  | 
| 1603 |     QCOMPARE(one->x(), 0.0); | 
| 1604 |     QCOMPARE(one->y(), 0.0); | 
| 1605 |     QCOMPARE(two->x(), 0.0); | 
| 1606 |     QCOMPARE(two->y(), 50.0); | 
| 1607 |     QCOMPARE(three->x(), 0.0); | 
| 1608 |     QCOMPARE(three->y(), 60.0); | 
| 1609 | } | 
| 1610 |  | 
| 1611 | void tst_qquickpositioners::test_vertical_spacing() | 
| 1612 | { | 
| 1613 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "vertical-spacing.qml" ))); | 
| 1614 |  | 
| 1615 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 1616 |     QVERIFY(one != nullptr); | 
| 1617 |  | 
| 1618 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 1619 |     QVERIFY(two != nullptr); | 
| 1620 |  | 
| 1621 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 1622 |     QVERIFY(three != nullptr); | 
| 1623 |  | 
| 1624 |     QCOMPARE(one->x(), 0.0); | 
| 1625 |     QCOMPARE(one->y(), 0.0); | 
| 1626 |     QCOMPARE(two->x(), 0.0); | 
| 1627 |     QCOMPARE(two->y(), 60.0); | 
| 1628 |     QCOMPARE(three->x(), 0.0); | 
| 1629 |     QCOMPARE(three->y(), 80.0); | 
| 1630 |  | 
| 1631 |     QQuickItem *column = window->rootObject()->findChild<QQuickItem*>(aName: "column" ); | 
| 1632 |     QCOMPARE(column->height(), 100.0); | 
| 1633 |     QCOMPARE(column->width(), 50.0); | 
| 1634 |  | 
| 1635 |     // test padding | 
| 1636 |     column->setProperty(name: "padding" , value: 1); | 
| 1637 |     column->setProperty(name: "topPadding" , value: 2); | 
| 1638 |     column->setProperty(name: "leftPadding" , value: 3); | 
| 1639 |     column->setProperty(name: "rightPadding" , value: 4); | 
| 1640 |     column->setProperty(name: "bottomPadding" , value: 5); | 
| 1641 |  | 
| 1642 |     QTRY_COMPARE(column->height(), 107.0); | 
| 1643 |     QCOMPARE(column->width(), 57.0); | 
| 1644 |  | 
| 1645 |     QCOMPARE(one->x(), 3.0); | 
| 1646 |     QCOMPARE(one->y(), 2.0); | 
| 1647 |     QCOMPARE(two->x(), 3.0); | 
| 1648 |     QCOMPARE(two->y(), 62.0); | 
| 1649 |     QCOMPARE(three->x(), 3.0); | 
| 1650 |     QCOMPARE(three->y(), 82.0); | 
| 1651 | } | 
| 1652 |  | 
| 1653 | void tst_qquickpositioners::test_vertical_animated() | 
| 1654 | { | 
| 1655 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "vertical-animated.qml" ), wait: false)); | 
| 1656 |  | 
| 1657 |     //Note that they animate in | 
| 1658 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 1659 |     QVERIFY(one != nullptr); | 
| 1660 |     QCOMPARE(one->y(), -100.0); | 
| 1661 |  | 
| 1662 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 1663 |     QVERIFY(two != nullptr); | 
| 1664 |     QCOMPARE(two->y(), -100.0); | 
| 1665 |  | 
| 1666 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 1667 |     QVERIFY(three != nullptr); | 
| 1668 |     QCOMPARE(three->y(), -100.0); | 
| 1669 |  | 
| 1670 |     QVERIFY(QTest::qWaitForWindowExposed(window.data())); //It may not relayout until the next frame, so it needs to be drawn | 
| 1671 |  | 
| 1672 |     QQuickItem *column = window->rootObject()->findChild<QQuickItem*>(aName: "column" ); | 
| 1673 |     QVERIFY(column); | 
| 1674 |     QCOMPARE(column->height(), 100.0); | 
| 1675 |     QCOMPARE(column->width(), 50.0); | 
| 1676 |  | 
| 1677 |     //QTRY_COMPARE used instead of waiting for the expected time of animation completion | 
| 1678 |     //Note that this means the duration of the animation is NOT tested | 
| 1679 |  | 
| 1680 |     QTRY_COMPARE(one->y(), 0.0); | 
| 1681 |     QTRY_COMPARE(one->x(), 0.0); | 
| 1682 |     QTRY_COMPARE(two->isVisible(), false); | 
| 1683 |     QTRY_COMPARE(two->y(), -100.0);//Not 'in' yet | 
| 1684 |     QTRY_COMPARE(two->x(), 0.0); | 
| 1685 |     QTRY_COMPARE(three->y(), 50.0); | 
| 1686 |     QTRY_COMPARE(three->x(), 0.0); | 
| 1687 |  | 
| 1688 |     //Add 'two' | 
| 1689 |     two->setVisible(true); | 
| 1690 |     QTRY_COMPARE(two->isVisible(), true); | 
| 1691 |     QTRY_COMPARE(column->height(), 150.0); | 
| 1692 |     QTRY_COMPARE(column->width(), 50.0); | 
| 1693 |     QTest::qWait(ms: 0);//Let the animation start | 
| 1694 |     QVERIFY(two->y() >= -100.0 && two->y() < 50.0); | 
| 1695 |     QVERIFY(three->y() >= 50.0 && three->y() < 100.0); | 
| 1696 |  | 
| 1697 |     QTRY_COMPARE(two->y(), 50.0); | 
| 1698 |     QTRY_COMPARE(three->y(), 100.0); | 
| 1699 |  | 
| 1700 | } | 
| 1701 |  | 
| 1702 | void tst_qquickpositioners::test_vertical_animated_padding() | 
| 1703 | { | 
| 1704 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "vertical-animated.qml" ), wait: false)); | 
| 1705 |  | 
| 1706 |     //Note that they animate in | 
| 1707 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 1708 |     QVERIFY(one != nullptr); | 
| 1709 |     QCOMPARE(one->y(), -100.0); | 
| 1710 |  | 
| 1711 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 1712 |     QVERIFY(two != nullptr); | 
| 1713 |     QCOMPARE(two->y(), -100.0); | 
| 1714 |  | 
| 1715 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 1716 |     QVERIFY(three != nullptr); | 
| 1717 |     QCOMPARE(three->y(), -100.0); | 
| 1718 |  | 
| 1719 |     QVERIFY(QTest::qWaitForWindowExposed(window.data())); //It may not relayout until the next frame, so it needs to be drawn | 
| 1720 |  | 
| 1721 |     QQuickItem *column = window->rootObject()->findChild<QQuickItem*>(aName: "column" ); | 
| 1722 |     QVERIFY(column); | 
| 1723 |     QCOMPARE(column->height(), 100.0); | 
| 1724 |     QCOMPARE(column->width(), 50.0); | 
| 1725 |  | 
| 1726 |     // test padding | 
| 1727 |     column->setProperty(name: "padding" , value: 1); | 
| 1728 |     column->setProperty(name: "topPadding" , value: 2); | 
| 1729 |     column->setProperty(name: "leftPadding" , value: 3); | 
| 1730 |     column->setProperty(name: "rightPadding" , value: 4); | 
| 1731 |     column->setProperty(name: "bottomPadding" , value: 5); | 
| 1732 |  | 
| 1733 |     QTRY_COMPARE(column->height(), 107.0); | 
| 1734 |     QCOMPARE(column->width(), 57.0); | 
| 1735 |  | 
| 1736 |     //QTRY_COMPARE used instead of waiting for the expected time of animation completion | 
| 1737 |     //Note that this means the duration of the animation is NOT tested | 
| 1738 |  | 
| 1739 |     QTRY_COMPARE(one->y(), 2.0); | 
| 1740 |     QTRY_COMPARE(one->x(), 3.0); | 
| 1741 |     QTRY_COMPARE(two->isVisible(), false); | 
| 1742 |     QTRY_COMPARE(two->y(), -100.0);//Not 'in' yet | 
| 1743 |     QTRY_COMPARE(two->x(), 0.0); | 
| 1744 |     QTRY_COMPARE(three->y(), 52.0); | 
| 1745 |     QTRY_COMPARE(three->x(), 3.0); | 
| 1746 |  | 
| 1747 |     //Add 'two' | 
| 1748 |     two->setVisible(true); | 
| 1749 |     QTRY_COMPARE(two->isVisible(), true); | 
| 1750 |     QTRY_COMPARE(column->height(), 157.0); | 
| 1751 |     QTRY_COMPARE(column->width(), 57.0); | 
| 1752 |     QTest::qWait(ms: 0);//Let the animation start | 
| 1753 |     QVERIFY(two->y() >= -100.0 && two->y() < 52.0); | 
| 1754 |     QVERIFY(three->y() >= 52.0 && three->y() < 102.0); | 
| 1755 |  | 
| 1756 |     QTRY_COMPARE(two->x(), 3.0); | 
| 1757 |     QTRY_COMPARE(two->y(), 52.0); | 
| 1758 |     QTRY_COMPARE(three->y(), 102.0); | 
| 1759 |  | 
| 1760 | } | 
| 1761 |  | 
| 1762 | void tst_qquickpositioners::test_grid() | 
| 1763 | { | 
| 1764 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "gridtest.qml" ))); | 
| 1765 |  | 
| 1766 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 1767 |     QVERIFY(one != nullptr); | 
| 1768 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 1769 |     QVERIFY(two != nullptr); | 
| 1770 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 1771 |     QVERIFY(three != nullptr); | 
| 1772 |     QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>(aName: "four" ); | 
| 1773 |     QVERIFY(four != nullptr); | 
| 1774 |     QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>(aName: "five" ); | 
| 1775 |     QVERIFY(five != nullptr); | 
| 1776 |  | 
| 1777 |     QCOMPARE(one->x(), 0.0); | 
| 1778 |     QCOMPARE(one->y(), 0.0); | 
| 1779 |     QCOMPARE(two->x(), 50.0); | 
| 1780 |     QCOMPARE(two->y(), 0.0); | 
| 1781 |     QCOMPARE(three->x(), 70.0); | 
| 1782 |     QCOMPARE(three->y(), 0.0); | 
| 1783 |     QCOMPARE(four->x(), 0.0); | 
| 1784 |     QCOMPARE(four->y(), 50.0); | 
| 1785 |     QCOMPARE(five->x(), 50.0); | 
| 1786 |     QCOMPARE(five->y(), 50.0); | 
| 1787 |  | 
| 1788 |     QQuickGrid *grid = window->rootObject()->findChild<QQuickGrid*>(aName: "grid" ); | 
| 1789 |     QCOMPARE(grid->flow(), QQuickGrid::LeftToRight); | 
| 1790 |     QCOMPARE(grid->width(), 100.0); | 
| 1791 |     QCOMPARE(grid->height(), 100.0); | 
| 1792 |  | 
| 1793 |     // test padding | 
| 1794 |     grid->setProperty(name: "padding" , value: 1); | 
| 1795 |     grid->setProperty(name: "topPadding" , value: 2); | 
| 1796 |     grid->setProperty(name: "leftPadding" , value: 3); | 
| 1797 |     grid->setProperty(name: "rightPadding" , value: 4); | 
| 1798 |     grid->setProperty(name: "bottomPadding" , value: 5); | 
| 1799 |  | 
| 1800 |     QTRY_COMPARE(grid->width(), 107.0); | 
| 1801 |     QCOMPARE(grid->height(), 107.0); | 
| 1802 |  | 
| 1803 |     QCOMPARE(one->x(), 3.0); | 
| 1804 |     QCOMPARE(one->y(), 2.0); | 
| 1805 |     QCOMPARE(two->x(), 53.0); | 
| 1806 |     QCOMPARE(two->y(), 2.0); | 
| 1807 |     QCOMPARE(three->x(), 73.0); | 
| 1808 |     QCOMPARE(three->y(), 2.0); | 
| 1809 |     QCOMPARE(four->x(), 3.0); | 
| 1810 |     QCOMPARE(four->y(), 52.0); | 
| 1811 |     QCOMPARE(five->x(), 53.0); | 
| 1812 |     QCOMPARE(five->y(), 52.0); | 
| 1813 | } | 
| 1814 |  | 
| 1815 | void tst_qquickpositioners::test_grid_padding() | 
| 1816 | { | 
| 1817 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "gridtest.qml" ))); | 
| 1818 |  | 
| 1819 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 1820 |     QVERIFY(one != nullptr); | 
| 1821 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 1822 |     QVERIFY(two != nullptr); | 
| 1823 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 1824 |     QVERIFY(three != nullptr); | 
| 1825 |     QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>(aName: "four" ); | 
| 1826 |     QVERIFY(four != nullptr); | 
| 1827 |     QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>(aName: "five" ); | 
| 1828 |     QVERIFY(five != nullptr); | 
| 1829 |  | 
| 1830 |     QCOMPARE(one->x(), 0.0); | 
| 1831 |     QCOMPARE(one->y(), 0.0); | 
| 1832 |     QCOMPARE(two->x(), 50.0); | 
| 1833 |     QCOMPARE(two->y(), 0.0); | 
| 1834 |     QCOMPARE(three->x(), 70.0); | 
| 1835 |     QCOMPARE(three->y(), 0.0); | 
| 1836 |     QCOMPARE(four->x(), 0.0); | 
| 1837 |     QCOMPARE(four->y(), 50.0); | 
| 1838 |     QCOMPARE(five->x(), 50.0); | 
| 1839 |     QCOMPARE(five->y(), 50.0); | 
| 1840 |  | 
| 1841 |     QQuickGrid *grid = window->rootObject()->findChild<QQuickGrid*>(aName: "grid" ); | 
| 1842 |     QCOMPARE(grid->flow(), QQuickGrid::LeftToRight); | 
| 1843 |     QCOMPARE(grid->width(), 100.0); | 
| 1844 |     QCOMPARE(grid->height(), 100.0); | 
| 1845 |  | 
| 1846 |     QCOMPARE(grid->property("padding" ).toDouble(), 0.0); | 
| 1847 |     QCOMPARE(grid->property("topPadding" ).toDouble(), 0.0); | 
| 1848 |     QCOMPARE(grid->property("leftPadding" ).toDouble(), 0.0); | 
| 1849 |     QCOMPARE(grid->property("rightPadding" ).toDouble(), 0.0); | 
| 1850 |     QCOMPARE(grid->property("bottomPadding" ).toDouble(), 0.0); | 
| 1851 |  | 
| 1852 |     grid->setPadding(1.0); | 
| 1853 |  | 
| 1854 |     QCOMPARE(grid->property("padding" ).toDouble(), 1.0); | 
| 1855 |     QCOMPARE(grid->property("topPadding" ).toDouble(), 1.0); | 
| 1856 |     QCOMPARE(grid->property("leftPadding" ).toDouble(), 1.0); | 
| 1857 |     QCOMPARE(grid->property("rightPadding" ).toDouble(), 1.0); | 
| 1858 |     QCOMPARE(grid->property("bottomPadding" ).toDouble(), 1.0); | 
| 1859 |  | 
| 1860 |     QTRY_COMPARE(grid->width(), 102.0); | 
| 1861 |     QCOMPARE(grid->height(), 102.0); | 
| 1862 |  | 
| 1863 |     QCOMPARE(one->x(), 1.0); | 
| 1864 |     QCOMPARE(one->y(), 1.0); | 
| 1865 |     QCOMPARE(two->x(), 51.0); | 
| 1866 |     QCOMPARE(two->y(), 1.0); | 
| 1867 |     QCOMPARE(three->x(), 71.0); | 
| 1868 |     QCOMPARE(three->y(), 1.0); | 
| 1869 |     QCOMPARE(four->x(), 1.0); | 
| 1870 |     QCOMPARE(four->y(), 51.0); | 
| 1871 |     QCOMPARE(five->x(), 51.0); | 
| 1872 |     QCOMPARE(five->y(), 51.0); | 
| 1873 |  | 
| 1874 |     grid->setTopPadding(2.0); | 
| 1875 |  | 
| 1876 |     QCOMPARE(grid->property("padding" ).toDouble(), 1.0); | 
| 1877 |     QCOMPARE(grid->property("topPadding" ).toDouble(), 2.0); | 
| 1878 |     QCOMPARE(grid->property("leftPadding" ).toDouble(), 1.0); | 
| 1879 |     QCOMPARE(grid->property("rightPadding" ).toDouble(), 1.0); | 
| 1880 |     QCOMPARE(grid->property("bottomPadding" ).toDouble(), 1.0); | 
| 1881 |  | 
| 1882 |     QTRY_COMPARE(grid->height(), 103.0); | 
| 1883 |     QCOMPARE(grid->width(), 102.0); | 
| 1884 |  | 
| 1885 |     QCOMPARE(one->x(), 1.0); | 
| 1886 |     QCOMPARE(one->y(), 2.0); | 
| 1887 |     QCOMPARE(two->x(), 51.0); | 
| 1888 |     QCOMPARE(two->y(), 2.0); | 
| 1889 |     QCOMPARE(three->x(), 71.0); | 
| 1890 |     QCOMPARE(three->y(), 2.0); | 
| 1891 |     QCOMPARE(four->x(), 1.0); | 
| 1892 |     QCOMPARE(four->y(), 52.0); | 
| 1893 |     QCOMPARE(five->x(), 51.0); | 
| 1894 |     QCOMPARE(five->y(), 52.0); | 
| 1895 |  | 
| 1896 |     grid->setLeftPadding(3.0); | 
| 1897 |  | 
| 1898 |     QCOMPARE(grid->property("padding" ).toDouble(), 1.0); | 
| 1899 |     QCOMPARE(grid->property("topPadding" ).toDouble(), 2.0); | 
| 1900 |     QCOMPARE(grid->property("leftPadding" ).toDouble(), 3.0); | 
| 1901 |     QCOMPARE(grid->property("rightPadding" ).toDouble(), 1.0); | 
| 1902 |     QCOMPARE(grid->property("bottomPadding" ).toDouble(), 1.0); | 
| 1903 |  | 
| 1904 |     QTRY_COMPARE(grid->width(), 104.0); | 
| 1905 |     QCOMPARE(grid->height(), 103.0); | 
| 1906 |  | 
| 1907 |     QCOMPARE(one->x(), 3.0); | 
| 1908 |     QCOMPARE(one->y(), 2.0); | 
| 1909 |     QCOMPARE(two->x(), 53.0); | 
| 1910 |     QCOMPARE(two->y(), 2.0); | 
| 1911 |     QCOMPARE(three->x(), 73.0); | 
| 1912 |     QCOMPARE(three->y(), 2.0); | 
| 1913 |     QCOMPARE(four->x(), 3.0); | 
| 1914 |     QCOMPARE(four->y(), 52.0); | 
| 1915 |     QCOMPARE(five->x(), 53.0); | 
| 1916 |     QCOMPARE(five->y(), 52.0); | 
| 1917 |  | 
| 1918 |     grid->setRightPadding(4.0); | 
| 1919 |  | 
| 1920 |     QCOMPARE(grid->property("padding" ).toDouble(), 1.0); | 
| 1921 |     QCOMPARE(grid->property("topPadding" ).toDouble(), 2.0); | 
| 1922 |     QCOMPARE(grid->property("leftPadding" ).toDouble(), 3.0); | 
| 1923 |     QCOMPARE(grid->property("rightPadding" ).toDouble(), 4.0); | 
| 1924 |     QCOMPARE(grid->property("bottomPadding" ).toDouble(), 1.0); | 
| 1925 |  | 
| 1926 |     QTRY_COMPARE(grid->width(), 107.0); | 
| 1927 |     QCOMPARE(grid->height(), 103.0); | 
| 1928 |  | 
| 1929 |     QCOMPARE(one->x(), 3.0); | 
| 1930 |     QCOMPARE(one->y(), 2.0); | 
| 1931 |     QCOMPARE(two->x(), 53.0); | 
| 1932 |     QCOMPARE(two->y(), 2.0); | 
| 1933 |     QCOMPARE(three->x(), 73.0); | 
| 1934 |     QCOMPARE(three->y(), 2.0); | 
| 1935 |     QCOMPARE(four->x(), 3.0); | 
| 1936 |     QCOMPARE(four->y(), 52.0); | 
| 1937 |     QCOMPARE(five->x(), 53.0); | 
| 1938 |     QCOMPARE(five->y(), 52.0); | 
| 1939 |  | 
| 1940 |     grid->setBottomPadding(5.0); | 
| 1941 |  | 
| 1942 |     QCOMPARE(grid->property("padding" ).toDouble(), 1.0); | 
| 1943 |     QCOMPARE(grid->property("topPadding" ).toDouble(), 2.0); | 
| 1944 |     QCOMPARE(grid->property("leftPadding" ).toDouble(), 3.0); | 
| 1945 |     QCOMPARE(grid->property("rightPadding" ).toDouble(), 4.0); | 
| 1946 |     QCOMPARE(grid->property("bottomPadding" ).toDouble(), 5.0); | 
| 1947 |  | 
| 1948 |     QTRY_COMPARE(grid->height(), 107.0); | 
| 1949 |     QCOMPARE(grid->width(), 107.0); | 
| 1950 |  | 
| 1951 |     QCOMPARE(one->x(), 3.0); | 
| 1952 |     QCOMPARE(one->y(), 2.0); | 
| 1953 |     QCOMPARE(two->x(), 53.0); | 
| 1954 |     QCOMPARE(two->y(), 2.0); | 
| 1955 |     QCOMPARE(three->x(), 73.0); | 
| 1956 |     QCOMPARE(three->y(), 2.0); | 
| 1957 |     QCOMPARE(four->x(), 3.0); | 
| 1958 |     QCOMPARE(four->y(), 52.0); | 
| 1959 |     QCOMPARE(five->x(), 53.0); | 
| 1960 |     QCOMPARE(five->y(), 52.0); | 
| 1961 |  | 
| 1962 |     grid->resetBottomPadding(); | 
| 1963 |     QCOMPARE(grid->property("bottomPadding" ).toDouble(), 1.0); | 
| 1964 |     QTRY_COMPARE(grid->height(), 103.0); | 
| 1965 |     QCOMPARE(grid->width(), 107.0); | 
| 1966 |  | 
| 1967 |     grid->resetRightPadding(); | 
| 1968 |     QCOMPARE(grid->property("rightPadding" ).toDouble(), 1.0); | 
| 1969 |     QTRY_COMPARE(grid->width(), 104.0); | 
| 1970 |     QCOMPARE(grid->height(), 103.0); | 
| 1971 |  | 
| 1972 |     grid->resetLeftPadding(); | 
| 1973 |     QCOMPARE(grid->property("leftPadding" ).toDouble(), 1.0); | 
| 1974 |     QTRY_COMPARE(grid->width(), 102.0); | 
| 1975 |     QCOMPARE(grid->height(), 103.0); | 
| 1976 |  | 
| 1977 |     grid->resetTopPadding(); | 
| 1978 |     QCOMPARE(grid->property("topPadding" ).toDouble(), 1.0); | 
| 1979 |     QTRY_COMPARE(grid->height(), 102.0); | 
| 1980 |     QCOMPARE(grid->width(), 102.0); | 
| 1981 |  | 
| 1982 |     grid->resetPadding(); | 
| 1983 |     QCOMPARE(grid->property("padding" ).toDouble(), 0.0); | 
| 1984 |     QCOMPARE(grid->property("topPadding" ).toDouble(), 0.0); | 
| 1985 |     QCOMPARE(grid->property("leftPadding" ).toDouble(), 0.0); | 
| 1986 |     QCOMPARE(grid->property("rightPadding" ).toDouble(), 0.0); | 
| 1987 |     QCOMPARE(grid->property("bottomPadding" ).toDouble(), 0.0); | 
| 1988 |     QTRY_COMPARE(grid->height(), 100.0); | 
| 1989 |     QCOMPARE(grid->width(), 100.0); | 
| 1990 |  | 
| 1991 |     QCOMPARE(one->x(), 0.0); | 
| 1992 |     QCOMPARE(one->y(), 0.0); | 
| 1993 |     QCOMPARE(two->x(), 50.0); | 
| 1994 |     QCOMPARE(two->y(), 0.0); | 
| 1995 |     QCOMPARE(three->x(), 70.0); | 
| 1996 |     QCOMPARE(three->y(), 0.0); | 
| 1997 |     QCOMPARE(four->x(), 0.0); | 
| 1998 |     QCOMPARE(four->y(), 50.0); | 
| 1999 |     QCOMPARE(five->x(), 50.0); | 
| 2000 |     QCOMPARE(five->y(), 50.0); | 
| 2001 | } | 
| 2002 |  | 
| 2003 | void tst_qquickpositioners::test_grid_topToBottom() | 
| 2004 | { | 
| 2005 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "grid-toptobottom.qml" ))); | 
| 2006 |  | 
| 2007 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 2008 |     QVERIFY(one != nullptr); | 
| 2009 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 2010 |     QVERIFY(two != nullptr); | 
| 2011 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 2012 |     QVERIFY(three != nullptr); | 
| 2013 |     QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>(aName: "four" ); | 
| 2014 |     QVERIFY(four != nullptr); | 
| 2015 |     QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>(aName: "five" ); | 
| 2016 |     QVERIFY(five != nullptr); | 
| 2017 |  | 
| 2018 |     QCOMPARE(one->x(), 0.0); | 
| 2019 |     QCOMPARE(one->y(), 0.0); | 
| 2020 |     QCOMPARE(two->x(), 0.0); | 
| 2021 |     QCOMPARE(two->y(), 50.0); | 
| 2022 |     QCOMPARE(three->x(), 0.0); | 
| 2023 |     QCOMPARE(three->y(), 100.0); | 
| 2024 |     QCOMPARE(four->x(), 50.0); | 
| 2025 |     QCOMPARE(four->y(), 0.0); | 
| 2026 |     QCOMPARE(five->x(), 50.0); | 
| 2027 |     QCOMPARE(five->y(), 50.0); | 
| 2028 |  | 
| 2029 |     QQuickGrid *grid = window->rootObject()->findChild<QQuickGrid*>(aName: "grid" ); | 
| 2030 |     QCOMPARE(grid->flow(), QQuickGrid::TopToBottom); | 
| 2031 |     QCOMPARE(grid->width(), 100.0); | 
| 2032 |     QCOMPARE(grid->height(), 120.0); | 
| 2033 |  | 
| 2034 |     // test padding | 
| 2035 |     grid->setProperty(name: "padding" , value: 1); | 
| 2036 |     grid->setProperty(name: "topPadding" , value: 2); | 
| 2037 |     grid->setProperty(name: "leftPadding" , value: 3); | 
| 2038 |     grid->setProperty(name: "rightPadding" , value: 4); | 
| 2039 |     grid->setProperty(name: "bottomPadding" , value: 5); | 
| 2040 |  | 
| 2041 |     QTRY_COMPARE(grid->width(), 107.0); | 
| 2042 |     QCOMPARE(grid->height(), 127.0); | 
| 2043 |  | 
| 2044 |     QCOMPARE(one->x(), 3.0); | 
| 2045 |     QCOMPARE(one->y(), 2.0); | 
| 2046 |     QCOMPARE(two->x(), 3.0); | 
| 2047 |     QCOMPARE(two->y(), 52.0); | 
| 2048 |     QCOMPARE(three->x(), 3.0); | 
| 2049 |     QCOMPARE(three->y(), 102.0); | 
| 2050 |     QCOMPARE(four->x(), 53.0); | 
| 2051 |     QCOMPARE(four->y(), 2.0); | 
| 2052 |     QCOMPARE(five->x(), 53.0); | 
| 2053 |     QCOMPARE(five->y(), 52.0); | 
| 2054 | } | 
| 2055 |  | 
| 2056 | void tst_qquickpositioners::test_grid_rightToLeft() | 
| 2057 | { | 
| 2058 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "gridtest.qml" ))); | 
| 2059 |  | 
| 2060 |     window->rootObject()->setProperty(name: "testRightToLeft" , value: true); | 
| 2061 |  | 
| 2062 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 2063 |     QVERIFY(one != nullptr); | 
| 2064 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 2065 |     QVERIFY(two != nullptr); | 
| 2066 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 2067 |     QVERIFY(three != nullptr); | 
| 2068 |     QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>(aName: "four" ); | 
| 2069 |     QVERIFY(four != nullptr); | 
| 2070 |     QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>(aName: "five" ); | 
| 2071 |     QVERIFY(five != nullptr); | 
| 2072 |  | 
| 2073 |     QCOMPARE(one->x(), 50.0); | 
| 2074 |     QCOMPARE(one->y(), 0.0); | 
| 2075 |     QCOMPARE(two->x(), 30.0); | 
| 2076 |     QCOMPARE(two->y(), 0.0); | 
| 2077 |     QCOMPARE(three->x(), 0.0); | 
| 2078 |     QCOMPARE(three->y(), 0.0); | 
| 2079 |     QCOMPARE(four->x(), 50.0); | 
| 2080 |     QCOMPARE(four->y(), 50.0); | 
| 2081 |     QCOMPARE(five->x(), 40.0); | 
| 2082 |     QCOMPARE(five->y(), 50.0); | 
| 2083 |  | 
| 2084 |     QQuickGrid *grid = window->rootObject()->findChild<QQuickGrid*>(aName: "grid" ); | 
| 2085 |     QCOMPARE(grid->layoutDirection(), Qt::RightToLeft); | 
| 2086 |     QCOMPARE(grid->width(), 100.0); | 
| 2087 |     QCOMPARE(grid->height(), 100.0); | 
| 2088 |  | 
| 2089 |     // test padding | 
| 2090 |     grid->setProperty(name: "padding" , value: 1); | 
| 2091 |     grid->setProperty(name: "topPadding" , value: 2); | 
| 2092 |     grid->setProperty(name: "leftPadding" , value: 3); | 
| 2093 |     grid->setProperty(name: "rightPadding" , value: 4); | 
| 2094 |     grid->setProperty(name: "bottomPadding" , value: 5); | 
| 2095 |  | 
| 2096 |     QTRY_COMPARE(grid->width(), 107.0); | 
| 2097 |     QCOMPARE(grid->height(), 107.0); | 
| 2098 |  | 
| 2099 |     QCOMPARE(one->x(), 53.0); | 
| 2100 |     QCOMPARE(one->y(), 2.0); | 
| 2101 |     QCOMPARE(two->x(), 33.0); | 
| 2102 |     QCOMPARE(two->y(), 2.0); | 
| 2103 |     QCOMPARE(three->x(), 3.0); | 
| 2104 |     QCOMPARE(three->y(), 2.0); | 
| 2105 |     QCOMPARE(four->x(), 53.0); | 
| 2106 |     QCOMPARE(four->y(), 52.0); | 
| 2107 |     QCOMPARE(five->x(), 43.0); | 
| 2108 |     QCOMPARE(five->y(), 52.0); | 
| 2109 |  | 
| 2110 |     grid->setProperty(name: "topPadding" , value: 0); | 
| 2111 |     grid->setProperty(name: "leftPadding" , value: 0); | 
| 2112 |     grid->setProperty(name: "rightPadding" , value: 0); | 
| 2113 |     grid->setProperty(name: "bottomPadding" , value: 0); | 
| 2114 |     grid->setProperty(name: "padding" , value: 0); | 
| 2115 |  | 
| 2116 |     QTRY_COMPARE(one->x(), 50.0); | 
| 2117 |     QCOMPARE(one->y(), 0.0); | 
| 2118 |     QCOMPARE(two->x(), 30.0); | 
| 2119 |     QCOMPARE(two->y(), 0.0); | 
| 2120 |     QCOMPARE(three->x(), 0.0); | 
| 2121 |     QCOMPARE(three->y(), 0.0); | 
| 2122 |     QCOMPARE(four->x(), 50.0); | 
| 2123 |     QCOMPARE(four->y(), 50.0); | 
| 2124 |     QCOMPARE(five->x(), 40.0); | 
| 2125 |     QCOMPARE(five->y(), 50.0); | 
| 2126 |  | 
| 2127 |     // Change the width of the grid and check that items stay to the right | 
| 2128 |     grid->setWidth(200); | 
| 2129 |     QTRY_COMPARE(one->x(), 150.0); | 
| 2130 |     QCOMPARE(one->y(), 0.0); | 
| 2131 |     QCOMPARE(two->x(), 130.0); | 
| 2132 |     QCOMPARE(two->y(), 0.0); | 
| 2133 |     QCOMPARE(three->x(), 100.0); | 
| 2134 |     QCOMPARE(three->y(), 0.0); | 
| 2135 |     QCOMPARE(four->x(), 150.0); | 
| 2136 |     QCOMPARE(four->y(), 50.0); | 
| 2137 |     QCOMPARE(five->x(), 140.0); | 
| 2138 |     QCOMPARE(five->y(), 50.0); | 
| 2139 |  | 
| 2140 |     grid->setProperty(name: "padding" , value: 1); | 
| 2141 |     grid->setProperty(name: "topPadding" , value: 2); | 
| 2142 |     grid->setProperty(name: "leftPadding" , value: 3); | 
| 2143 |     grid->setProperty(name: "rightPadding" , value: 4); | 
| 2144 |     grid->setProperty(name: "bottomPadding" , value: 5); | 
| 2145 |  | 
| 2146 |     QTRY_COMPARE(one->x(), 146.0); | 
| 2147 |     QCOMPARE(one->y(), 2.0); | 
| 2148 |     QCOMPARE(two->x(), 126.0); | 
| 2149 |     QCOMPARE(two->y(), 2.0); | 
| 2150 |     QCOMPARE(three->x(), 96.0); | 
| 2151 |     QCOMPARE(three->y(), 2.0); | 
| 2152 |     QCOMPARE(four->x(), 146.0); | 
| 2153 |     QCOMPARE(four->y(), 52.0); | 
| 2154 |     QCOMPARE(five->x(), 136.0); | 
| 2155 |     QCOMPARE(five->y(), 52.0); | 
| 2156 | } | 
| 2157 |  | 
| 2158 | void tst_qquickpositioners::test_grid_spacing() | 
| 2159 | { | 
| 2160 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "grid-spacing.qml" ))); | 
| 2161 |  | 
| 2162 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 2163 |     QVERIFY(one != nullptr); | 
| 2164 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 2165 |     QVERIFY(two != nullptr); | 
| 2166 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 2167 |     QVERIFY(three != nullptr); | 
| 2168 |     QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>(aName: "four" ); | 
| 2169 |     QVERIFY(four != nullptr); | 
| 2170 |     QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>(aName: "five" ); | 
| 2171 |     QVERIFY(five != nullptr); | 
| 2172 |  | 
| 2173 |     QCOMPARE(one->x(), 0.0); | 
| 2174 |     QCOMPARE(one->y(), 0.0); | 
| 2175 |     QCOMPARE(two->x(), 54.0); | 
| 2176 |     QCOMPARE(two->y(), 0.0); | 
| 2177 |     QCOMPARE(three->x(), 78.0); | 
| 2178 |     QCOMPARE(three->y(), 0.0); | 
| 2179 |     QCOMPARE(four->x(), 0.0); | 
| 2180 |     QCOMPARE(four->y(), 54.0); | 
| 2181 |     QCOMPARE(five->x(), 54.0); | 
| 2182 |     QCOMPARE(five->y(), 54.0); | 
| 2183 |  | 
| 2184 |     QQuickItem *grid = window->rootObject()->findChild<QQuickItem*>(aName: "grid" ); | 
| 2185 |     QCOMPARE(grid->width(), 128.0); | 
| 2186 |     QCOMPARE(grid->height(), 104.0); | 
| 2187 |  | 
| 2188 |     // test padding | 
| 2189 |     grid->setProperty(name: "padding" , value: 1); | 
| 2190 |     grid->setProperty(name: "topPadding" , value: 2); | 
| 2191 |     grid->setProperty(name: "leftPadding" , value: 3); | 
| 2192 |     grid->setProperty(name: "rightPadding" , value: 4); | 
| 2193 |     grid->setProperty(name: "bottomPadding" , value: 5); | 
| 2194 |  | 
| 2195 |     QTRY_COMPARE(grid->width(), 135.0); | 
| 2196 |     QCOMPARE(grid->height(), 111.0); | 
| 2197 |  | 
| 2198 |     QCOMPARE(one->x(), 3.0); | 
| 2199 |     QCOMPARE(one->y(), 2.0); | 
| 2200 |     QCOMPARE(two->x(), 57.0); | 
| 2201 |     QCOMPARE(two->y(), 2.0); | 
| 2202 |     QCOMPARE(three->x(), 81.0); | 
| 2203 |     QCOMPARE(three->y(), 2.0); | 
| 2204 |     QCOMPARE(four->x(), 3.0); | 
| 2205 |     QCOMPARE(four->y(), 56.0); | 
| 2206 |     QCOMPARE(five->x(), 57.0); | 
| 2207 |     QCOMPARE(five->y(), 56.0); | 
| 2208 | } | 
| 2209 |  | 
| 2210 | void tst_qquickpositioners::test_grid_row_column_spacing() | 
| 2211 | { | 
| 2212 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "grid-row-column-spacing.qml" ))); | 
| 2213 |  | 
| 2214 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 2215 |     QVERIFY(one != nullptr); | 
| 2216 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 2217 |     QVERIFY(two != nullptr); | 
| 2218 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 2219 |     QVERIFY(three != nullptr); | 
| 2220 |     QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>(aName: "four" ); | 
| 2221 |     QVERIFY(four != nullptr); | 
| 2222 |     QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>(aName: "five" ); | 
| 2223 |     QVERIFY(five != nullptr); | 
| 2224 |  | 
| 2225 |     QCOMPARE(one->x(), 0.0); | 
| 2226 |     QCOMPARE(one->y(), 0.0); | 
| 2227 |     QCOMPARE(two->x(), 61.0); | 
| 2228 |     QCOMPARE(two->y(), 0.0); | 
| 2229 |     QCOMPARE(three->x(), 92.0); | 
| 2230 |     QCOMPARE(three->y(), 0.0); | 
| 2231 |     QCOMPARE(four->x(), 0.0); | 
| 2232 |     QCOMPARE(four->y(), 57.0); | 
| 2233 |     QCOMPARE(five->x(), 61.0); | 
| 2234 |     QCOMPARE(five->y(), 57.0); | 
| 2235 |  | 
| 2236 |     QQuickItem *grid = window->rootObject()->findChild<QQuickItem*>(aName: "grid" ); | 
| 2237 |     QCOMPARE(grid->width(), 142.0); | 
| 2238 |     QCOMPARE(grid->height(), 107.0); | 
| 2239 |  | 
| 2240 |     // test padding | 
| 2241 |     grid->setProperty(name: "padding" , value: 1); | 
| 2242 |     grid->setProperty(name: "topPadding" , value: 2); | 
| 2243 |     grid->setProperty(name: "leftPadding" , value: 3); | 
| 2244 |     grid->setProperty(name: "rightPadding" , value: 4); | 
| 2245 |     grid->setProperty(name: "bottomPadding" , value: 5); | 
| 2246 |  | 
| 2247 |     QTRY_COMPARE(grid->width(), 149.0); | 
| 2248 |     QCOMPARE(grid->height(), 114.0); | 
| 2249 |  | 
| 2250 |     QCOMPARE(one->x(), 3.0); | 
| 2251 |     QCOMPARE(one->y(), 2.0); | 
| 2252 |     QCOMPARE(two->x(), 64.0); | 
| 2253 |     QCOMPARE(two->y(), 2.0); | 
| 2254 |     QCOMPARE(three->x(), 95.0); | 
| 2255 |     QCOMPARE(three->y(), 2.0); | 
| 2256 |     QCOMPARE(four->x(), 3.0); | 
| 2257 |     QCOMPARE(four->y(), 59.0); | 
| 2258 |     QCOMPARE(five->x(), 64.0); | 
| 2259 |     QCOMPARE(five->y(), 59.0); | 
| 2260 | } | 
| 2261 |  | 
| 2262 | void tst_qquickpositioners::test_grid_animated() | 
| 2263 | { | 
| 2264 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "grid-animated.qml" ), wait: false)); | 
| 2265 |  | 
| 2266 |     window->rootObject()->setProperty(name: "testRightToLeft" , value: false); | 
| 2267 |  | 
| 2268 |     //Note that all animate in | 
| 2269 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 2270 |     QVERIFY(one != nullptr); | 
| 2271 |     QCOMPARE(one->x(), -100.0); | 
| 2272 |     QCOMPARE(one->y(), -100.0); | 
| 2273 |  | 
| 2274 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 2275 |     QVERIFY(two != nullptr); | 
| 2276 |     QCOMPARE(two->x(), -100.0); | 
| 2277 |     QCOMPARE(two->y(), -100.0); | 
| 2278 |  | 
| 2279 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 2280 |     QVERIFY(three != nullptr); | 
| 2281 |     QCOMPARE(three->x(), -100.0); | 
| 2282 |     QCOMPARE(three->y(), -100.0); | 
| 2283 |  | 
| 2284 |     QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>(aName: "four" ); | 
| 2285 |     QVERIFY(four != nullptr); | 
| 2286 |     QCOMPARE(four->x(), -100.0); | 
| 2287 |     QCOMPARE(four->y(), -100.0); | 
| 2288 |  | 
| 2289 |     QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>(aName: "five" ); | 
| 2290 |     QVERIFY(five != nullptr); | 
| 2291 |     QCOMPARE(five->x(), -100.0); | 
| 2292 |     QCOMPARE(five->y(), -100.0); | 
| 2293 |  | 
| 2294 |     QVERIFY(QTest::qWaitForWindowExposed(window.data())); //It may not relayout until the next frame, so it needs to be drawn | 
| 2295 |  | 
| 2296 |     QQuickItem *grid = window->rootObject()->findChild<QQuickItem*>(aName: "grid" ); | 
| 2297 |     QVERIFY(grid); | 
| 2298 |     QCOMPARE(grid->width(), 150.0); | 
| 2299 |     QCOMPARE(grid->height(), 100.0); | 
| 2300 |  | 
| 2301 |     //QTRY_COMPARE used instead of waiting for the expected time of animation completion | 
| 2302 |     //Note that this means the duration of the animation is NOT tested | 
| 2303 |  | 
| 2304 |     QTRY_COMPARE(one->y(), 0.0); | 
| 2305 |     QTRY_COMPARE(one->x(), 0.0); | 
| 2306 |     QTRY_COMPARE(two->isVisible(), false); | 
| 2307 |     QTRY_COMPARE(two->y(), -100.0); | 
| 2308 |     QTRY_COMPARE(two->x(), -100.0); | 
| 2309 |     QTRY_COMPARE(three->y(), 0.0); | 
| 2310 |     QTRY_COMPARE(three->x(), 50.0); | 
| 2311 |     QTRY_COMPARE(four->y(), 0.0); | 
| 2312 |     QTRY_COMPARE(four->x(), 100.0); | 
| 2313 |     QTRY_COMPARE(five->y(), 50.0); | 
| 2314 |     QTRY_COMPARE(five->x(), 0.0); | 
| 2315 |  | 
| 2316 |     //Add 'two' | 
| 2317 |     two->setVisible(true); | 
| 2318 |     QCOMPARE(two->isVisible(), true); | 
| 2319 |     QCOMPARE(grid->width(), 150.0); | 
| 2320 |     QCOMPARE(grid->height(), 100.0); | 
| 2321 |     QTest::qWait(ms: 0);//Let the animation start | 
| 2322 |     QCOMPARE(two->x(), -100.0); | 
| 2323 |     QCOMPARE(two->y(), -100.0); | 
| 2324 |     QCOMPARE(one->x(), 0.0); | 
| 2325 |     QCOMPARE(one->y(), 0.0); | 
| 2326 |     QCOMPARE(three->x(), 50.0); | 
| 2327 |     QCOMPARE(three->y(), 0.0); | 
| 2328 |     QCOMPARE(four->x(), 100.0); | 
| 2329 |     QCOMPARE(four->y(), 0.0); | 
| 2330 |     QCOMPARE(five->x(), 0.0); | 
| 2331 |     QCOMPARE(five->y(), 50.0); | 
| 2332 |     //Let the animation complete | 
| 2333 |     QTRY_COMPARE(two->x(), 50.0); | 
| 2334 |     QTRY_COMPARE(two->y(), 0.0); | 
| 2335 |     QTRY_COMPARE(one->x(), 0.0); | 
| 2336 |     QTRY_COMPARE(one->y(), 0.0); | 
| 2337 |     QTRY_COMPARE(three->x(), 100.0); | 
| 2338 |     QTRY_COMPARE(three->y(), 0.0); | 
| 2339 |     QTRY_COMPARE(four->x(), 0.0); | 
| 2340 |     QTRY_COMPARE(four->y(), 50.0); | 
| 2341 |     QTRY_COMPARE(five->x(), 50.0); | 
| 2342 |     QTRY_COMPARE(five->y(), 50.0); | 
| 2343 |  | 
| 2344 | } | 
| 2345 |  | 
| 2346 | void tst_qquickpositioners::test_grid_animated_padding() | 
| 2347 | { | 
| 2348 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "grid-animated.qml" ), wait: false)); | 
| 2349 |  | 
| 2350 |     window->rootObject()->setProperty(name: "testRightToLeft" , value: false); | 
| 2351 |  | 
| 2352 |     //Note that all animate in | 
| 2353 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 2354 |     QVERIFY(one != nullptr); | 
| 2355 |     QCOMPARE(one->x(), -100.0); | 
| 2356 |     QCOMPARE(one->y(), -100.0); | 
| 2357 |  | 
| 2358 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 2359 |     QVERIFY(two != nullptr); | 
| 2360 |     QCOMPARE(two->x(), -100.0); | 
| 2361 |     QCOMPARE(two->y(), -100.0); | 
| 2362 |  | 
| 2363 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 2364 |     QVERIFY(three != nullptr); | 
| 2365 |     QCOMPARE(three->x(), -100.0); | 
| 2366 |     QCOMPARE(three->y(), -100.0); | 
| 2367 |  | 
| 2368 |     QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>(aName: "four" ); | 
| 2369 |     QVERIFY(four != nullptr); | 
| 2370 |     QCOMPARE(four->x(), -100.0); | 
| 2371 |     QCOMPARE(four->y(), -100.0); | 
| 2372 |  | 
| 2373 |     QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>(aName: "five" ); | 
| 2374 |     QVERIFY(five != nullptr); | 
| 2375 |     QCOMPARE(five->x(), -100.0); | 
| 2376 |     QCOMPARE(five->y(), -100.0); | 
| 2377 |  | 
| 2378 |     QVERIFY(QTest::qWaitForWindowExposed(window.data())); //It may not relayout until the next frame, so it needs to be drawn | 
| 2379 |  | 
| 2380 |     QQuickItem *grid = window->rootObject()->findChild<QQuickItem*>(aName: "grid" ); | 
| 2381 |     QVERIFY(grid); | 
| 2382 |     QCOMPARE(grid->width(), 150.0); | 
| 2383 |     QCOMPARE(grid->height(), 100.0); | 
| 2384 |  | 
| 2385 |     // test padding | 
| 2386 |     grid->setProperty(name: "padding" , value: 1); | 
| 2387 |     grid->setProperty(name: "topPadding" , value: 2); | 
| 2388 |     grid->setProperty(name: "leftPadding" , value: 3); | 
| 2389 |     grid->setProperty(name: "rightPadding" , value: 4); | 
| 2390 |     grid->setProperty(name: "bottomPadding" , value: 5); | 
| 2391 |  | 
| 2392 |     QTRY_COMPARE(grid->width(), 157.0); | 
| 2393 |     QCOMPARE(grid->height(), 107.0); | 
| 2394 |  | 
| 2395 |     //QTRY_COMPARE used instead of waiting for the expected time of animation completion | 
| 2396 |     //Note that this means the duration of the animation is NOT tested | 
| 2397 |  | 
| 2398 |     QTRY_COMPARE(one->y(), 2.0); | 
| 2399 |     QTRY_COMPARE(one->x(), 3.0); | 
| 2400 |     QTRY_COMPARE(two->isVisible(), false); | 
| 2401 |     QTRY_COMPARE(two->y(), -100.0); | 
| 2402 |     QTRY_COMPARE(two->x(), -100.0); | 
| 2403 |     QTRY_COMPARE(three->y(), 2.0); | 
| 2404 |     QTRY_COMPARE(three->x(), 53.0); | 
| 2405 |     QTRY_COMPARE(four->y(), 2.0); | 
| 2406 |     QTRY_COMPARE(four->x(), 103.0); | 
| 2407 |     QTRY_COMPARE(five->y(), 52.0); | 
| 2408 |     QTRY_COMPARE(five->x(), 3.0); | 
| 2409 |  | 
| 2410 |     //Add 'two' | 
| 2411 |     two->setVisible(true); | 
| 2412 |     QCOMPARE(two->isVisible(), true); | 
| 2413 |     QCOMPARE(grid->width(), 157.0); | 
| 2414 |     QCOMPARE(grid->height(), 107.0); | 
| 2415 |     QTest::qWait(ms: 0);//Let the animation start | 
| 2416 |     QCOMPARE(two->x(), -100.0); | 
| 2417 |     QCOMPARE(two->y(), -100.0); | 
| 2418 |     QCOMPARE(one->x(), 3.0); | 
| 2419 |     QCOMPARE(one->y(), 2.0); | 
| 2420 |     QCOMPARE(three->x(), 53.0); | 
| 2421 |     QCOMPARE(three->y(), 2.0); | 
| 2422 |     QCOMPARE(four->x(), 103.0); | 
| 2423 |     QCOMPARE(four->y(), 2.0); | 
| 2424 |     QCOMPARE(five->x(), 3.0); | 
| 2425 |     QCOMPARE(five->y(), 52.0); | 
| 2426 |     //Let the animation complete | 
| 2427 |     QTRY_COMPARE(two->x(), 53.0); | 
| 2428 |     QTRY_COMPARE(two->y(), 2.0); | 
| 2429 |     QTRY_COMPARE(one->x(), 3.0); | 
| 2430 |     QTRY_COMPARE(one->y(), 2.0); | 
| 2431 |     QTRY_COMPARE(three->x(), 103.0); | 
| 2432 |     QTRY_COMPARE(three->y(), 2.0); | 
| 2433 |     QTRY_COMPARE(four->x(), 3.0); | 
| 2434 |     QTRY_COMPARE(four->y(), 52.0); | 
| 2435 |     QTRY_COMPARE(five->x(), 53.0); | 
| 2436 |     QTRY_COMPARE(five->y(), 52.0); | 
| 2437 |  | 
| 2438 | } | 
| 2439 |  | 
| 2440 | void tst_qquickpositioners::test_grid_animated_rightToLeft() | 
| 2441 | { | 
| 2442 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "grid-animated.qml" ), wait: false)); | 
| 2443 |  | 
| 2444 |     window->rootObject()->setProperty(name: "testRightToLeft" , value: true); | 
| 2445 |  | 
| 2446 |     //Note that all animate in | 
| 2447 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 2448 |     QVERIFY(one != nullptr); | 
| 2449 |     QCOMPARE(one->x(), -100.0); | 
| 2450 |     QCOMPARE(one->y(), -100.0); | 
| 2451 |  | 
| 2452 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 2453 |     QVERIFY(two != nullptr); | 
| 2454 |     QCOMPARE(two->x(), -100.0); | 
| 2455 |     QCOMPARE(two->y(), -100.0); | 
| 2456 |  | 
| 2457 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 2458 |     QVERIFY(three != nullptr); | 
| 2459 |     QCOMPARE(three->x(), -100.0); | 
| 2460 |     QCOMPARE(three->y(), -100.0); | 
| 2461 |  | 
| 2462 |     QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>(aName: "four" ); | 
| 2463 |     QVERIFY(four != nullptr); | 
| 2464 |     QCOMPARE(four->x(), -100.0); | 
| 2465 |     QCOMPARE(four->y(), -100.0); | 
| 2466 |  | 
| 2467 |     QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>(aName: "five" ); | 
| 2468 |     QVERIFY(five != nullptr); | 
| 2469 |     QCOMPARE(five->x(), -100.0); | 
| 2470 |     QCOMPARE(five->y(), -100.0); | 
| 2471 |  | 
| 2472 |     QVERIFY(QTest::qWaitForWindowExposed(window.data())); //It may not relayout until the next frame, so it needs to be drawn | 
| 2473 |  | 
| 2474 |     QQuickItem *grid = window->rootObject()->findChild<QQuickItem*>(aName: "grid" ); | 
| 2475 |     QVERIFY(grid); | 
| 2476 |     QCOMPARE(grid->width(), 150.0); | 
| 2477 |     QCOMPARE(grid->height(), 100.0); | 
| 2478 |  | 
| 2479 |     //QTRY_COMPARE used instead of waiting for the expected time of animation completion | 
| 2480 |     //Note that this means the duration of the animation is NOT tested | 
| 2481 |  | 
| 2482 |     QTRY_COMPARE(one->y(), 0.0); | 
| 2483 |     QTRY_COMPARE(one->x(), 100.0); | 
| 2484 |     QTRY_COMPARE(two->isVisible(), false); | 
| 2485 |     QTRY_COMPARE(two->y(), -100.0); | 
| 2486 |     QTRY_COMPARE(two->x(), -100.0); | 
| 2487 |     QTRY_COMPARE(three->y(), 0.0); | 
| 2488 |     QTRY_COMPARE(three->x(), 50.0); | 
| 2489 |     QTRY_COMPARE(four->y(), 0.0); | 
| 2490 |     QTRY_COMPARE(four->x(), 0.0); | 
| 2491 |     QTRY_COMPARE(five->y(), 50.0); | 
| 2492 |     QTRY_COMPARE(five->x(), 100.0); | 
| 2493 |  | 
| 2494 |     //Add 'two' | 
| 2495 |     two->setVisible(true); | 
| 2496 |     QCOMPARE(two->isVisible(), true); | 
| 2497 |     QCOMPARE(grid->width(), 150.0); | 
| 2498 |     QCOMPARE(grid->height(), 100.0); | 
| 2499 |     QTest::qWait(ms: 0);//Let the animation start | 
| 2500 |     QCOMPARE(two->x(), -100.0); | 
| 2501 |     QCOMPARE(two->y(), -100.0); | 
| 2502 |     QCOMPARE(one->x(), 100.0); | 
| 2503 |     QCOMPARE(one->y(), 0.0); | 
| 2504 |     QCOMPARE(three->x(), 50.0); | 
| 2505 |     QCOMPARE(three->y(), 0.0); | 
| 2506 |     QCOMPARE(four->x(), 0.0); | 
| 2507 |     QCOMPARE(four->y(), 0.0); | 
| 2508 |     QCOMPARE(five->x(), 100.0); | 
| 2509 |     QCOMPARE(five->y(), 50.0); | 
| 2510 |     //Let the animation complete | 
| 2511 |     QTRY_COMPARE(two->x(), 50.0); | 
| 2512 |     QTRY_COMPARE(two->y(), 0.0); | 
| 2513 |     QTRY_COMPARE(one->x(), 100.0); | 
| 2514 |     QTRY_COMPARE(one->y(), 0.0); | 
| 2515 |     QTRY_COMPARE(three->x(), 0.0); | 
| 2516 |     QTRY_COMPARE(three->y(), 0.0); | 
| 2517 |     QTRY_COMPARE(four->x(), 100.0); | 
| 2518 |     QTRY_COMPARE(four->y(), 50.0); | 
| 2519 |     QTRY_COMPARE(five->x(), 50.0); | 
| 2520 |     QTRY_COMPARE(five->y(), 50.0); | 
| 2521 |  | 
| 2522 | } | 
| 2523 |  | 
| 2524 | void tst_qquickpositioners::test_grid_animated_rightToLeft_padding() | 
| 2525 | { | 
| 2526 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "grid-animated.qml" ), wait: false)); | 
| 2527 |  | 
| 2528 |     window->rootObject()->setProperty(name: "testRightToLeft" , value: true); | 
| 2529 |  | 
| 2530 |     //Note that all animate in | 
| 2531 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 2532 |     QVERIFY(one != nullptr); | 
| 2533 |     QCOMPARE(one->x(), -100.0); | 
| 2534 |     QCOMPARE(one->y(), -100.0); | 
| 2535 |  | 
| 2536 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 2537 |     QVERIFY(two != nullptr); | 
| 2538 |     QCOMPARE(two->x(), -100.0); | 
| 2539 |     QCOMPARE(two->y(), -100.0); | 
| 2540 |  | 
| 2541 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 2542 |     QVERIFY(three != nullptr); | 
| 2543 |     QCOMPARE(three->x(), -100.0); | 
| 2544 |     QCOMPARE(three->y(), -100.0); | 
| 2545 |  | 
| 2546 |     QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>(aName: "four" ); | 
| 2547 |     QVERIFY(four != nullptr); | 
| 2548 |     QCOMPARE(four->x(), -100.0); | 
| 2549 |     QCOMPARE(four->y(), -100.0); | 
| 2550 |  | 
| 2551 |     QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>(aName: "five" ); | 
| 2552 |     QVERIFY(five != nullptr); | 
| 2553 |     QCOMPARE(five->x(), -100.0); | 
| 2554 |     QCOMPARE(five->y(), -100.0); | 
| 2555 |  | 
| 2556 |     QVERIFY(QTest::qWaitForWindowExposed(window.data())); //It may not relayout until the next frame, so it needs to be drawn | 
| 2557 |  | 
| 2558 |     QQuickItem *grid = window->rootObject()->findChild<QQuickItem*>(aName: "grid" ); | 
| 2559 |     QVERIFY(grid); | 
| 2560 |     QCOMPARE(grid->width(), 150.0); | 
| 2561 |     QCOMPARE(grid->height(), 100.0); | 
| 2562 |  | 
| 2563 |     // test padding | 
| 2564 |     grid->setProperty(name: "padding" , value: 1); | 
| 2565 |     grid->setProperty(name: "topPadding" , value: 2); | 
| 2566 |     grid->setProperty(name: "leftPadding" , value: 3); | 
| 2567 |     grid->setProperty(name: "rightPadding" , value: 4); | 
| 2568 |     grid->setProperty(name: "bottomPadding" , value: 5); | 
| 2569 |  | 
| 2570 |     QTRY_COMPARE(grid->width(), 157.0); | 
| 2571 |     QCOMPARE(grid->height(), 107.0); | 
| 2572 |  | 
| 2573 |     //QTRY_COMPARE used instead of waiting for the expected time of animation completion | 
| 2574 |     //Note that this means the duration of the animation is NOT tested | 
| 2575 |  | 
| 2576 |     QTRY_COMPARE(one->y(), 2.0); | 
| 2577 |     QTRY_COMPARE(one->x(), 103.0); | 
| 2578 |     QTRY_COMPARE(two->isVisible(), false); | 
| 2579 |     QTRY_COMPARE(two->y(), -100.0); | 
| 2580 |     QTRY_COMPARE(two->x(), -100.0); | 
| 2581 |     QTRY_COMPARE(three->y(), 2.0); | 
| 2582 |     QTRY_COMPARE(three->x(), 53.0); | 
| 2583 |     QTRY_COMPARE(four->y(), 2.0); | 
| 2584 |     QTRY_COMPARE(four->x(), 3.0); | 
| 2585 |     QTRY_COMPARE(five->y(), 52.0); | 
| 2586 |     QTRY_COMPARE(five->x(), 103.0); | 
| 2587 |  | 
| 2588 |     //Add 'two' | 
| 2589 |     two->setVisible(true); | 
| 2590 |     QCOMPARE(two->isVisible(), true); | 
| 2591 |     QCOMPARE(grid->width(), 157.0); | 
| 2592 |     QCOMPARE(grid->height(), 107.0); | 
| 2593 |     QTest::qWait(ms: 0);//Let the animation start | 
| 2594 |     QCOMPARE(two->x(), -100.0); | 
| 2595 |     QCOMPARE(two->y(), -100.0); | 
| 2596 |     QCOMPARE(one->x(), 103.0); | 
| 2597 |     QCOMPARE(one->y(), 2.0); | 
| 2598 |     QCOMPARE(three->x(), 53.0); | 
| 2599 |     QCOMPARE(three->y(), 2.0); | 
| 2600 |     QCOMPARE(four->x(), 3.0); | 
| 2601 |     QCOMPARE(four->y(), 2.0); | 
| 2602 |     QCOMPARE(five->x(), 103.0); | 
| 2603 |     QCOMPARE(five->y(), 52.0); | 
| 2604 |     //Let the animation complete | 
| 2605 |     QTRY_COMPARE(two->x(), 53.0); | 
| 2606 |     QTRY_COMPARE(two->y(), 2.0); | 
| 2607 |     QTRY_COMPARE(one->x(), 103.0); | 
| 2608 |     QTRY_COMPARE(one->y(), 2.0); | 
| 2609 |     QTRY_COMPARE(three->x(), 3.0); | 
| 2610 |     QTRY_COMPARE(three->y(), 2.0); | 
| 2611 |     QTRY_COMPARE(four->x(), 103.0); | 
| 2612 |     QTRY_COMPARE(four->y(), 52.0); | 
| 2613 |     QTRY_COMPARE(five->x(), 53.0); | 
| 2614 |     QTRY_COMPARE(five->y(), 52.0); | 
| 2615 |  | 
| 2616 | } | 
| 2617 |  | 
| 2618 | void tst_qquickpositioners::test_grid_zero_columns() | 
| 2619 | { | 
| 2620 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "gridzerocolumns.qml" ))); | 
| 2621 |  | 
| 2622 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 2623 |     QVERIFY(one != nullptr); | 
| 2624 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 2625 |     QVERIFY(two != nullptr); | 
| 2626 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 2627 |     QVERIFY(three != nullptr); | 
| 2628 |     QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>(aName: "four" ); | 
| 2629 |     QVERIFY(four != nullptr); | 
| 2630 |     QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>(aName: "five" ); | 
| 2631 |     QVERIFY(five != nullptr); | 
| 2632 |  | 
| 2633 |     QCOMPARE(one->x(), 0.0); | 
| 2634 |     QCOMPARE(one->y(), 0.0); | 
| 2635 |     QCOMPARE(two->x(), 50.0); | 
| 2636 |     QCOMPARE(two->y(), 0.0); | 
| 2637 |     QCOMPARE(three->x(), 70.0); | 
| 2638 |     QCOMPARE(three->y(), 0.0); | 
| 2639 |     QCOMPARE(four->x(), 120.0); | 
| 2640 |     QCOMPARE(four->y(), 0.0); | 
| 2641 |     QCOMPARE(five->x(), 0.0); | 
| 2642 |     QCOMPARE(five->y(), 50.0); | 
| 2643 |  | 
| 2644 |     QQuickItem *grid = window->rootObject()->findChild<QQuickItem*>(aName: "grid" ); | 
| 2645 |     QCOMPARE(grid->width(), 170.0); | 
| 2646 |     QCOMPARE(grid->height(), 60.0); | 
| 2647 |  | 
| 2648 |     // test padding | 
| 2649 |     grid->setProperty(name: "padding" , value: 1); | 
| 2650 |     grid->setProperty(name: "topPadding" , value: 2); | 
| 2651 |     grid->setProperty(name: "leftPadding" , value: 3); | 
| 2652 |     grid->setProperty(name: "rightPadding" , value: 4); | 
| 2653 |     grid->setProperty(name: "bottomPadding" , value: 5); | 
| 2654 |  | 
| 2655 |     QTRY_COMPARE(grid->width(), 177.0); | 
| 2656 |     QCOMPARE(grid->height(), 67.0); | 
| 2657 |  | 
| 2658 |     QCOMPARE(one->x(), 3.0); | 
| 2659 |     QCOMPARE(one->y(), 2.0); | 
| 2660 |     QCOMPARE(two->x(), 53.0); | 
| 2661 |     QCOMPARE(two->y(), 2.0); | 
| 2662 |     QCOMPARE(three->x(), 73.0); | 
| 2663 |     QCOMPARE(three->y(), 2.0); | 
| 2664 |     QCOMPARE(four->x(), 123.0); | 
| 2665 |     QCOMPARE(four->y(), 2.0); | 
| 2666 |     QCOMPARE(five->x(), 3.0); | 
| 2667 |     QCOMPARE(five->y(), 52.0); | 
| 2668 | } | 
| 2669 |  | 
| 2670 | void tst_qquickpositioners::test_grid_H_alignment() | 
| 2671 | { | 
| 2672 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "gridtest.qml" ))); | 
| 2673 |  | 
| 2674 |     window->rootObject()->setProperty(name: "testHAlignment" , value: QQuickGrid::AlignHCenter); | 
| 2675 |  | 
| 2676 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 2677 |     QVERIFY(one != nullptr); | 
| 2678 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 2679 |     QVERIFY(two != nullptr); | 
| 2680 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 2681 |     QVERIFY(three != nullptr); | 
| 2682 |     QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>(aName: "four" ); | 
| 2683 |     QVERIFY(four != nullptr); | 
| 2684 |     QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>(aName: "five" ); | 
| 2685 |     QVERIFY(five != nullptr); | 
| 2686 |  | 
| 2687 |     QCOMPARE(one->x(), 0.0); | 
| 2688 |     QCOMPARE(one->y(), 0.0); | 
| 2689 |     QCOMPARE(two->x(), 50.0); | 
| 2690 |     QCOMPARE(two->y(), 0.0); | 
| 2691 |     QCOMPARE(three->x(), 70.0); | 
| 2692 |     QCOMPARE(three->y(), 0.0); | 
| 2693 |     QCOMPARE(four->x(), 0.0); | 
| 2694 |     QCOMPARE(four->y(), 50.0); | 
| 2695 |     QCOMPARE(five->x(), 55.0); | 
| 2696 |     QCOMPARE(five->y(), 50.0); | 
| 2697 |  | 
| 2698 |     QQuickItem *grid = window->rootObject()->findChild<QQuickItem*>(aName: "grid" ); | 
| 2699 |     QCOMPARE(grid->width(), 100.0); | 
| 2700 |     QCOMPARE(grid->height(), 100.0); | 
| 2701 |  | 
| 2702 |     window->rootObject()->setProperty(name: "testHAlignment" , value: QQuickGrid::AlignRight); | 
| 2703 |  | 
| 2704 |     QCOMPARE(one->x(), 0.0); | 
| 2705 |     QCOMPARE(one->y(), 0.0); | 
| 2706 |     QCOMPARE(two->x(), 50.0); | 
| 2707 |     QCOMPARE(two->y(), 0.0); | 
| 2708 |     QCOMPARE(three->x(), 70.0); | 
| 2709 |     QCOMPARE(three->y(), 0.0); | 
| 2710 |     QCOMPARE(four->x(), 0.0); | 
| 2711 |     QCOMPARE(four->y(), 50.0); | 
| 2712 |     QCOMPARE(five->x(), 60.0); | 
| 2713 |     QCOMPARE(five->y(), 50.0); | 
| 2714 |     QCOMPARE(grid->width(), 100.0); | 
| 2715 |     QCOMPARE(grid->height(), 100.0); | 
| 2716 |  | 
| 2717 |     window->rootObject()->setProperty(name: "testRightToLeft" , value: true); | 
| 2718 |  | 
| 2719 |     QCOMPARE(one->x(), 50.0); | 
| 2720 |     QCOMPARE(one->y(), 0.0); | 
| 2721 |     QCOMPARE(two->x(), 30.0); | 
| 2722 |     QCOMPARE(two->y(), 0.0); | 
| 2723 |     QCOMPARE(three->x(), 0.0); | 
| 2724 |     QCOMPARE(three->y(), 0.0); | 
| 2725 |     QCOMPARE(four->x(), 50.0); | 
| 2726 |     QCOMPARE(four->y(), 50.0); | 
| 2727 |     QCOMPARE(five->x(), 30.0); | 
| 2728 |     QCOMPARE(five->y(), 50.0); | 
| 2729 |     QCOMPARE(grid->width(), 100.0); | 
| 2730 |     QCOMPARE(grid->height(), 100.0); | 
| 2731 |  | 
| 2732 |     window->rootObject()->setProperty(name: "testHAlignment" , value: QQuickGrid::AlignHCenter); | 
| 2733 |  | 
| 2734 |     QCOMPARE(one->x(), 50.0); | 
| 2735 |     QCOMPARE(one->y(), 0.0); | 
| 2736 |     QCOMPARE(two->x(), 30.0); | 
| 2737 |     QCOMPARE(two->y(), 0.0); | 
| 2738 |     QCOMPARE(three->x(), 0.0); | 
| 2739 |     QCOMPARE(three->y(), 0.0); | 
| 2740 |     QCOMPARE(four->x(), 50.0); | 
| 2741 |     QCOMPARE(four->y(), 50.0); | 
| 2742 |     QCOMPARE(five->x(), 35.0); | 
| 2743 |     QCOMPARE(five->y(), 50.0); | 
| 2744 |     QCOMPARE(grid->width(), 100.0); | 
| 2745 |     QCOMPARE(grid->height(), 100.0); | 
| 2746 |  | 
| 2747 | } | 
| 2748 |  | 
| 2749 | void tst_qquickpositioners::test_grid_H_alignment_padding() | 
| 2750 | { | 
| 2751 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "gridtest.qml" ))); | 
| 2752 |  | 
| 2753 |     window->rootObject()->setProperty(name: "testHAlignment" , value: QQuickGrid::AlignHCenter); | 
| 2754 |  | 
| 2755 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 2756 |     QVERIFY(one != nullptr); | 
| 2757 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 2758 |     QVERIFY(two != nullptr); | 
| 2759 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 2760 |     QVERIFY(three != nullptr); | 
| 2761 |     QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>(aName: "four" ); | 
| 2762 |     QVERIFY(four != nullptr); | 
| 2763 |     QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>(aName: "five" ); | 
| 2764 |     QVERIFY(five != nullptr); | 
| 2765 |  | 
| 2766 |     QCOMPARE(one->x(), 0.0); | 
| 2767 |     QCOMPARE(one->y(), 0.0); | 
| 2768 |     QCOMPARE(two->x(), 50.0); | 
| 2769 |     QCOMPARE(two->y(), 0.0); | 
| 2770 |     QCOMPARE(three->x(), 70.0); | 
| 2771 |     QCOMPARE(three->y(), 0.0); | 
| 2772 |     QCOMPARE(four->x(), 0.0); | 
| 2773 |     QCOMPARE(four->y(), 50.0); | 
| 2774 |     QCOMPARE(five->x(), 55.0); | 
| 2775 |     QCOMPARE(five->y(), 50.0); | 
| 2776 |  | 
| 2777 |     QQuickItem *grid = window->rootObject()->findChild<QQuickItem*>(aName: "grid" ); | 
| 2778 |     QCOMPARE(grid->width(), 100.0); | 
| 2779 |     QCOMPARE(grid->height(), 100.0); | 
| 2780 |  | 
| 2781 |     // test padding | 
| 2782 |     grid->setProperty(name: "padding" , value: 1); | 
| 2783 |     grid->setProperty(name: "topPadding" , value: 2); | 
| 2784 |     grid->setProperty(name: "leftPadding" , value: 3); | 
| 2785 |     grid->setProperty(name: "rightPadding" , value: 4); | 
| 2786 |     grid->setProperty(name: "bottomPadding" , value: 5); | 
| 2787 |  | 
| 2788 |     QTRY_COMPARE(grid->width(), 107.0); | 
| 2789 |     QCOMPARE(grid->height(), 107.0); | 
| 2790 |  | 
| 2791 |     window->rootObject()->setProperty(name: "testHAlignment" , value: QQuickGrid::AlignRight); | 
| 2792 |  | 
| 2793 |     QCOMPARE(one->x(), 3.0); | 
| 2794 |     QCOMPARE(one->y(), 2.0); | 
| 2795 |     QCOMPARE(two->x(), 53.0); | 
| 2796 |     QCOMPARE(two->y(), 2.0); | 
| 2797 |     QCOMPARE(three->x(), 73.0); | 
| 2798 |     QCOMPARE(three->y(), 2.0); | 
| 2799 |     QCOMPARE(four->x(), 3.0); | 
| 2800 |     QCOMPARE(four->y(), 52.0); | 
| 2801 |     QCOMPARE(five->x(), 63.0); | 
| 2802 |     QCOMPARE(five->y(), 52.0); | 
| 2803 |     QCOMPARE(grid->width(), 107.0); | 
| 2804 |     QCOMPARE(grid->height(), 107.0); | 
| 2805 |  | 
| 2806 |     window->rootObject()->setProperty(name: "testRightToLeft" , value: true); | 
| 2807 |  | 
| 2808 |     QCOMPARE(one->x(), 53.0); | 
| 2809 |     QCOMPARE(one->y(), 2.0); | 
| 2810 |     QCOMPARE(two->x(), 33.0); | 
| 2811 |     QCOMPARE(two->y(), 2.0); | 
| 2812 |     QCOMPARE(three->x(), 3.0); | 
| 2813 |     QCOMPARE(three->y(), 2.0); | 
| 2814 |     QCOMPARE(four->x(), 53.0); | 
| 2815 |     QCOMPARE(four->y(), 52.0); | 
| 2816 |     QCOMPARE(five->x(), 33.0); | 
| 2817 |     QCOMPARE(five->y(), 52.0); | 
| 2818 |     QCOMPARE(grid->width(), 107.0); | 
| 2819 |     QCOMPARE(grid->height(), 107.0); | 
| 2820 |  | 
| 2821 |     window->rootObject()->setProperty(name: "testHAlignment" , value: QQuickGrid::AlignHCenter); | 
| 2822 |  | 
| 2823 |     QCOMPARE(one->x(), 53.0); | 
| 2824 |     QCOMPARE(one->y(), 2.0); | 
| 2825 |     QCOMPARE(two->x(), 33.0); | 
| 2826 |     QCOMPARE(two->y(), 2.0); | 
| 2827 |     QCOMPARE(three->x(), 3.0); | 
| 2828 |     QCOMPARE(three->y(), 2.0); | 
| 2829 |     QCOMPARE(four->x(), 53.0); | 
| 2830 |     QCOMPARE(four->y(), 52.0); | 
| 2831 |     QCOMPARE(five->x(), 38.0); | 
| 2832 |     QCOMPARE(five->y(), 52.0); | 
| 2833 |     QCOMPARE(grid->width(), 107.0); | 
| 2834 |     QCOMPARE(grid->height(), 107.0); | 
| 2835 |  | 
| 2836 | } | 
| 2837 |  | 
| 2838 | void tst_qquickpositioners::test_grid_V_alignment() | 
| 2839 | { | 
| 2840 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "gridtest.qml" ))); | 
| 2841 |  | 
| 2842 |     window->rootObject()->setProperty(name: "testVAlignment" , value: QQuickGrid::AlignVCenter); | 
| 2843 |  | 
| 2844 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 2845 |     QVERIFY(one != nullptr); | 
| 2846 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 2847 |     QVERIFY(two != nullptr); | 
| 2848 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 2849 |     QVERIFY(three != nullptr); | 
| 2850 |     QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>(aName: "four" ); | 
| 2851 |     QVERIFY(four != nullptr); | 
| 2852 |     QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>(aName: "five" ); | 
| 2853 |     QVERIFY(five != nullptr); | 
| 2854 |  | 
| 2855 |     QCOMPARE(one->x(), 0.0); | 
| 2856 |     QCOMPARE(one->y(), 0.0); | 
| 2857 |     QCOMPARE(two->x(), 50.0); | 
| 2858 |     QCOMPARE(two->y(), 0.0); | 
| 2859 |     QCOMPARE(three->x(), 70.0); | 
| 2860 |     QCOMPARE(three->y(), 15.0); | 
| 2861 |     QCOMPARE(four->x(), 0.0); | 
| 2862 |     QCOMPARE(four->y(), 50.0); | 
| 2863 |     QCOMPARE(five->x(), 50.0); | 
| 2864 |     QCOMPARE(five->y(), 70.0); | 
| 2865 |  | 
| 2866 |     window->rootObject()->setProperty(name: "testVAlignment" , value: QQuickGrid::AlignBottom); | 
| 2867 |  | 
| 2868 |     QCOMPARE(one->x(), 0.0); | 
| 2869 |     QCOMPARE(one->y(), 0.0); | 
| 2870 |     QCOMPARE(two->x(), 50.0); | 
| 2871 |     QCOMPARE(two->y(), 0.0); | 
| 2872 |     QCOMPARE(three->x(), 70.0); | 
| 2873 |     QCOMPARE(three->y(), 30.0); | 
| 2874 |     QCOMPARE(four->x(), 0.0); | 
| 2875 |     QCOMPARE(four->y(), 50.0); | 
| 2876 |     QCOMPARE(five->x(), 50.0); | 
| 2877 |     QCOMPARE(five->y(), 90.0); | 
| 2878 |  | 
| 2879 | } | 
| 2880 |  | 
| 2881 | void tst_qquickpositioners::test_grid_V_alignment_padding() | 
| 2882 | { | 
| 2883 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "gridtest.qml" ))); | 
| 2884 |  | 
| 2885 |     window->rootObject()->setProperty(name: "testVAlignment" , value: QQuickGrid::AlignVCenter); | 
| 2886 |  | 
| 2887 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 2888 |     QVERIFY(one != nullptr); | 
| 2889 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 2890 |     QVERIFY(two != nullptr); | 
| 2891 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 2892 |     QVERIFY(three != nullptr); | 
| 2893 |     QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>(aName: "four" ); | 
| 2894 |     QVERIFY(four != nullptr); | 
| 2895 |     QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>(aName: "five" ); | 
| 2896 |     QVERIFY(five != nullptr); | 
| 2897 |  | 
| 2898 |     QQuickItem *grid = window->rootObject()->findChild<QQuickItem*>(aName: "grid" ); | 
| 2899 |     QCOMPARE(grid->width(), 100.0); | 
| 2900 |     QCOMPARE(grid->height(), 100.0); | 
| 2901 |  | 
| 2902 |     // test padding | 
| 2903 |     grid->setProperty(name: "padding" , value: 1); | 
| 2904 |     grid->setProperty(name: "topPadding" , value: 2); | 
| 2905 |     grid->setProperty(name: "leftPadding" , value: 3); | 
| 2906 |     grid->setProperty(name: "rightPadding" , value: 4); | 
| 2907 |     grid->setProperty(name: "bottomPadding" , value: 5); | 
| 2908 |  | 
| 2909 |     QTRY_COMPARE(grid->width(), 107.0); | 
| 2910 |     QCOMPARE(grid->height(), 107.0); | 
| 2911 |  | 
| 2912 |     QCOMPARE(one->x(), 3.0); | 
| 2913 |     QCOMPARE(one->y(), 2.0); | 
| 2914 |     QCOMPARE(two->x(), 53.0); | 
| 2915 |     QCOMPARE(two->y(), 2.0); | 
| 2916 |     QCOMPARE(three->x(), 73.0); | 
| 2917 |     QCOMPARE(three->y(), 17.0); | 
| 2918 |     QCOMPARE(four->x(), 3.0); | 
| 2919 |     QCOMPARE(four->y(), 52.0); | 
| 2920 |     QCOMPARE(five->x(), 53.0); | 
| 2921 |     QCOMPARE(five->y(), 72.0); | 
| 2922 |  | 
| 2923 |     window->rootObject()->setProperty(name: "testVAlignment" , value: QQuickGrid::AlignBottom); | 
| 2924 |  | 
| 2925 |     QCOMPARE(one->x(), 3.0); | 
| 2926 |     QCOMPARE(one->y(), 2.0); | 
| 2927 |     QCOMPARE(two->x(), 53.0); | 
| 2928 |     QCOMPARE(two->y(), 2.0); | 
| 2929 |     QCOMPARE(three->x(), 73.0); | 
| 2930 |     QCOMPARE(three->y(), 32.0); | 
| 2931 |     QCOMPARE(four->x(), 3.0); | 
| 2932 |     QCOMPARE(four->y(), 52.0); | 
| 2933 |     QCOMPARE(five->x(), 53.0); | 
| 2934 |     QCOMPARE(five->y(), 92.0); | 
| 2935 |  | 
| 2936 | } | 
| 2937 |  | 
| 2938 | void tst_qquickpositioners::test_propertychanges() | 
| 2939 | { | 
| 2940 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "propertychangestest.qml" ))); | 
| 2941 |  | 
| 2942 |     QQuickGrid *grid = qobject_cast<QQuickGrid*>(object: window->rootObject()); | 
| 2943 |     QVERIFY(grid != nullptr); | 
| 2944 |     QQuickTransition *rowTransition = window->rootObject()->findChild<QQuickTransition*>(aName: "rowTransition" ); | 
| 2945 |     QQuickTransition *columnTransition = window->rootObject()->findChild<QQuickTransition*>(aName: "columnTransition" ); | 
| 2946 |  | 
| 2947 |     QSignalSpy addSpy(grid, SIGNAL(addChanged())); | 
| 2948 |     QSignalSpy moveSpy(grid, SIGNAL(moveChanged())); | 
| 2949 |     QSignalSpy columnsSpy(grid, SIGNAL(columnsChanged())); | 
| 2950 |     QSignalSpy rowsSpy(grid, SIGNAL(rowsChanged())); | 
| 2951 |  | 
| 2952 |     QVERIFY(grid); | 
| 2953 |     QVERIFY(rowTransition); | 
| 2954 |     QVERIFY(columnTransition); | 
| 2955 |     QCOMPARE(grid->add(), columnTransition); | 
| 2956 |     QCOMPARE(grid->move(), columnTransition); | 
| 2957 |     QCOMPARE(grid->columns(), 4); | 
| 2958 |     QCOMPARE(grid->rows(), -1); | 
| 2959 |  | 
| 2960 |     grid->setAdd(rowTransition); | 
| 2961 |     grid->setMove(rowTransition); | 
| 2962 |     QCOMPARE(grid->add(), rowTransition); | 
| 2963 |     QCOMPARE(grid->move(), rowTransition); | 
| 2964 |     QCOMPARE(addSpy.count(),1); | 
| 2965 |     QCOMPARE(moveSpy.count(),1); | 
| 2966 |  | 
| 2967 |     grid->setAdd(rowTransition); | 
| 2968 |     grid->setMove(rowTransition); | 
| 2969 |     QCOMPARE(addSpy.count(),1); | 
| 2970 |     QCOMPARE(moveSpy.count(),1); | 
| 2971 |  | 
| 2972 |     grid->setAdd(nullptr); | 
| 2973 |     grid->setMove(nullptr); | 
| 2974 |     QCOMPARE(addSpy.count(),2); | 
| 2975 |     QCOMPARE(moveSpy.count(),2); | 
| 2976 |  | 
| 2977 |     grid->setColumns(-1); | 
| 2978 |     grid->setRows(3); | 
| 2979 |     QCOMPARE(grid->columns(), -1); | 
| 2980 |     QCOMPARE(grid->rows(), 3); | 
| 2981 |     QCOMPARE(columnsSpy.count(),1); | 
| 2982 |     QCOMPARE(rowsSpy.count(),1); | 
| 2983 |  | 
| 2984 |     grid->setColumns(-1); | 
| 2985 |     grid->setRows(3); | 
| 2986 |     QCOMPARE(columnsSpy.count(),1); | 
| 2987 |     QCOMPARE(rowsSpy.count(),1); | 
| 2988 |  | 
| 2989 |     grid->setColumns(2); | 
| 2990 |     grid->setRows(2); | 
| 2991 |     QCOMPARE(columnsSpy.count(),2); | 
| 2992 |     QCOMPARE(rowsSpy.count(),2); | 
| 2993 |  | 
| 2994 | } | 
| 2995 |  | 
| 2996 | void tst_qquickpositioners::test_repeater() | 
| 2997 | { | 
| 2998 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "repeatertest.qml" ))); | 
| 2999 |  | 
| 3000 |     QQuickRectangle *one = findItem<QQuickRectangle>(parent: window->contentItem(), objectName: "one" ); | 
| 3001 |     QVERIFY(one != nullptr); | 
| 3002 |  | 
| 3003 |     QQuickRectangle *two = findItem<QQuickRectangle>(parent: window->contentItem(), objectName: "two" ); | 
| 3004 |     QVERIFY(two != nullptr); | 
| 3005 |  | 
| 3006 |     QQuickRectangle *three = findItem<QQuickRectangle>(parent: window->contentItem(), objectName: "three" ); | 
| 3007 |     QVERIFY(three != nullptr); | 
| 3008 |  | 
| 3009 |     QCOMPARE(one->x(), 0.0); | 
| 3010 |     QCOMPARE(one->y(), 0.0); | 
| 3011 |     QCOMPARE(two->x(), 50.0); | 
| 3012 |     QCOMPARE(two->y(), 0.0); | 
| 3013 |     QCOMPARE(three->x(), 100.0); | 
| 3014 |     QCOMPARE(three->y(), 0.0); | 
| 3015 |  | 
| 3016 | } | 
| 3017 |  | 
| 3018 | void tst_qquickpositioners::test_repeater_padding() | 
| 3019 | { | 
| 3020 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "repeatertest-padding.qml" ))); | 
| 3021 |  | 
| 3022 |     QQuickRectangle *one = findItem<QQuickRectangle>(parent: window->contentItem(), objectName: "one" ); | 
| 3023 |     QVERIFY(one != nullptr); | 
| 3024 |  | 
| 3025 |     QQuickRectangle *two = findItem<QQuickRectangle>(parent: window->contentItem(), objectName: "two" ); | 
| 3026 |     QVERIFY(two != nullptr); | 
| 3027 |  | 
| 3028 |     QQuickRectangle *three = findItem<QQuickRectangle>(parent: window->contentItem(), objectName: "three" ); | 
| 3029 |     QVERIFY(three != nullptr); | 
| 3030 |  | 
| 3031 |     QCOMPARE(one->x(), 3.0); | 
| 3032 |     QCOMPARE(one->y(), 2.0); | 
| 3033 |     QCOMPARE(two->x(), 53.0); | 
| 3034 |     QCOMPARE(two->y(), 2.0); | 
| 3035 |     QCOMPARE(three->x(), 103.0); | 
| 3036 |     QCOMPARE(three->y(), 2.0); | 
| 3037 |  | 
| 3038 | } | 
| 3039 |  | 
| 3040 | void tst_qquickpositioners::test_flow() | 
| 3041 | { | 
| 3042 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "flowtest.qml" ))); | 
| 3043 |  | 
| 3044 |     window->rootObject()->setProperty(name: "testRightToLeft" , value: false); | 
| 3045 |  | 
| 3046 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 3047 |     QVERIFY(one != nullptr); | 
| 3048 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 3049 |     QVERIFY(two != nullptr); | 
| 3050 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 3051 |     QVERIFY(three != nullptr); | 
| 3052 |     QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>(aName: "four" ); | 
| 3053 |     QVERIFY(four != nullptr); | 
| 3054 |     QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>(aName: "five" ); | 
| 3055 |     QVERIFY(five != nullptr); | 
| 3056 |  | 
| 3057 |     QCOMPARE(one->x(), 0.0); | 
| 3058 |     QCOMPARE(one->y(), 0.0); | 
| 3059 |     QCOMPARE(two->x(), 50.0); | 
| 3060 |     QCOMPARE(two->y(), 0.0); | 
| 3061 |     QCOMPARE(three->x(), 0.0); | 
| 3062 |     QCOMPARE(three->y(), 50.0); | 
| 3063 |     QCOMPARE(four->x(), 0.0); | 
| 3064 |     QCOMPARE(four->y(), 70.0); | 
| 3065 |     QCOMPARE(five->x(), 50.0); | 
| 3066 |     QCOMPARE(five->y(), 70.0); | 
| 3067 |  | 
| 3068 |     QQuickItem *flow = window->rootObject()->findChild<QQuickItem*>(aName: "flow" ); | 
| 3069 |     QVERIFY(flow); | 
| 3070 |     QCOMPARE(flow->width(), 90.0); | 
| 3071 |     QCOMPARE(flow->height(), 120.0); | 
| 3072 |  | 
| 3073 |     // test padding | 
| 3074 |     flow->setProperty(name: "padding" , value: 1); | 
| 3075 |     flow->setProperty(name: "topPadding" , value: 2); | 
| 3076 |     flow->setProperty(name: "leftPadding" , value: 3); | 
| 3077 |     flow->setProperty(name: "rightPadding" , value: 4); | 
| 3078 |     flow->setProperty(name: "bottomPadding" , value: 5); | 
| 3079 |  | 
| 3080 |     QTRY_COMPARE(flow->height(), 127.0); | 
| 3081 |     QCOMPARE(flow->width(), 90.0); | 
| 3082 |  | 
| 3083 |     QCOMPARE(one->x(), 3.0); | 
| 3084 |     QCOMPARE(one->y(), 2.0); | 
| 3085 |     QCOMPARE(two->x(), 53.0); | 
| 3086 |     QCOMPARE(two->y(), 2.0); | 
| 3087 |     QCOMPARE(three->x(), 3.0); | 
| 3088 |     QCOMPARE(three->y(), 52.0); | 
| 3089 |     QCOMPARE(four->x(), 3.0); | 
| 3090 |     QCOMPARE(four->y(), 72.0); | 
| 3091 |     QCOMPARE(five->x(), 53.0); | 
| 3092 |     QCOMPARE(five->y(), 72.0); | 
| 3093 | } | 
| 3094 |  | 
| 3095 | void tst_qquickpositioners::test_flow_padding() | 
| 3096 | { | 
| 3097 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "flowtest.qml" ))); | 
| 3098 |  | 
| 3099 |     window->rootObject()->setProperty(name: "testRightToLeft" , value: false); | 
| 3100 |  | 
| 3101 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 3102 |     QVERIFY(one != nullptr); | 
| 3103 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 3104 |     QVERIFY(two != nullptr); | 
| 3105 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 3106 |     QVERIFY(three != nullptr); | 
| 3107 |     QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>(aName: "four" ); | 
| 3108 |     QVERIFY(four != nullptr); | 
| 3109 |     QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>(aName: "five" ); | 
| 3110 |     QVERIFY(five != nullptr); | 
| 3111 |  | 
| 3112 |     QCOMPARE(one->x(), 0.0); | 
| 3113 |     QCOMPARE(one->y(), 0.0); | 
| 3114 |     QCOMPARE(two->x(), 50.0); | 
| 3115 |     QCOMPARE(two->y(), 0.0); | 
| 3116 |     QCOMPARE(three->x(), 0.0); | 
| 3117 |     QCOMPARE(three->y(), 50.0); | 
| 3118 |     QCOMPARE(four->x(), 0.0); | 
| 3119 |     QCOMPARE(four->y(), 70.0); | 
| 3120 |     QCOMPARE(five->x(), 50.0); | 
| 3121 |     QCOMPARE(five->y(), 70.0); | 
| 3122 |  | 
| 3123 |     QQuickItem *flow = window->rootObject()->findChild<QQuickItem*>(aName: "flow" ); | 
| 3124 |     QVERIFY(flow); | 
| 3125 |     QCOMPARE(flow->width(), 90.0); | 
| 3126 |     QCOMPARE(flow->height(), 120.0); | 
| 3127 |  | 
| 3128 |     QQuickFlow *obj = qobject_cast<QQuickFlow*>(object: flow); | 
| 3129 |     QVERIFY(obj != nullptr); | 
| 3130 |  | 
| 3131 |     QCOMPARE(flow->property("padding" ).toDouble(), 0.0); | 
| 3132 |     QCOMPARE(flow->property("topPadding" ).toDouble(), 0.0); | 
| 3133 |     QCOMPARE(flow->property("leftPadding" ).toDouble(), 0.0); | 
| 3134 |     QCOMPARE(flow->property("rightPadding" ).toDouble(), 0.0); | 
| 3135 |     QCOMPARE(flow->property("bottomPadding" ).toDouble(), 0.0); | 
| 3136 |  | 
| 3137 |     obj->setPadding(1.0); | 
| 3138 |  | 
| 3139 |     QCOMPARE(flow->property("padding" ).toDouble(), 1.0); | 
| 3140 |     QCOMPARE(flow->property("topPadding" ).toDouble(), 1.0); | 
| 3141 |     QCOMPARE(flow->property("leftPadding" ).toDouble(), 1.0); | 
| 3142 |     QCOMPARE(flow->property("rightPadding" ).toDouble(), 1.0); | 
| 3143 |     QCOMPARE(flow->property("bottomPadding" ).toDouble(), 1.0); | 
| 3144 |  | 
| 3145 |     QTRY_COMPARE(flow->height(), 122.0); | 
| 3146 |     QCOMPARE(flow->width(), 90.0); | 
| 3147 |  | 
| 3148 |     QCOMPARE(one->x(), 1.0); | 
| 3149 |     QCOMPARE(one->y(), 1.0); | 
| 3150 |     QCOMPARE(two->x(), 51.0); | 
| 3151 |     QCOMPARE(two->y(), 1.0); | 
| 3152 |     QCOMPARE(three->x(), 1.0); | 
| 3153 |     QCOMPARE(three->y(), 51.0); | 
| 3154 |     QCOMPARE(four->x(), 1.0); | 
| 3155 |     QCOMPARE(four->y(), 71.0); | 
| 3156 |     QCOMPARE(five->x(), 51.0); | 
| 3157 |     QCOMPARE(five->y(), 71.0); | 
| 3158 |  | 
| 3159 |     obj->setTopPadding(2.0); | 
| 3160 |  | 
| 3161 |     QCOMPARE(flow->property("padding" ).toDouble(), 1.0); | 
| 3162 |     QCOMPARE(flow->property("topPadding" ).toDouble(), 2.0); | 
| 3163 |     QCOMPARE(flow->property("leftPadding" ).toDouble(), 1.0); | 
| 3164 |     QCOMPARE(flow->property("rightPadding" ).toDouble(), 1.0); | 
| 3165 |     QCOMPARE(flow->property("bottomPadding" ).toDouble(), 1.0); | 
| 3166 |  | 
| 3167 |     QTRY_COMPARE(flow->height(), 123.0); | 
| 3168 |     QCOMPARE(flow->width(), 90.0); | 
| 3169 |  | 
| 3170 |     QCOMPARE(one->x(), 1.0); | 
| 3171 |     QCOMPARE(one->y(), 2.0); | 
| 3172 |     QCOMPARE(two->x(), 51.0); | 
| 3173 |     QCOMPARE(two->y(), 2.0); | 
| 3174 |     QCOMPARE(three->x(), 1.0); | 
| 3175 |     QCOMPARE(three->y(), 52.0); | 
| 3176 |     QCOMPARE(four->x(), 1.0); | 
| 3177 |     QCOMPARE(four->y(), 72.0); | 
| 3178 |     QCOMPARE(five->x(), 51.0); | 
| 3179 |     QCOMPARE(five->y(), 72.0); | 
| 3180 |  | 
| 3181 |     obj->setLeftPadding(3.0); | 
| 3182 |  | 
| 3183 |     QCOMPARE(flow->property("padding" ).toDouble(), 1.0); | 
| 3184 |     QCOMPARE(flow->property("topPadding" ).toDouble(), 2.0); | 
| 3185 |     QCOMPARE(flow->property("leftPadding" ).toDouble(), 3.0); | 
| 3186 |     QCOMPARE(flow->property("rightPadding" ).toDouble(), 1.0); | 
| 3187 |     QCOMPARE(flow->property("bottomPadding" ).toDouble(), 1.0); | 
| 3188 |  | 
| 3189 |     QCOMPARE(flow->height(), 123.0); | 
| 3190 |     QCOMPARE(flow->width(), 90.0); | 
| 3191 |  | 
| 3192 |     QTRY_COMPARE(one->x(), 3.0); | 
| 3193 |     QCOMPARE(one->y(), 2.0); | 
| 3194 |     QCOMPARE(two->x(), 53.0); | 
| 3195 |     QCOMPARE(two->y(), 2.0); | 
| 3196 |     QCOMPARE(three->x(), 3.0); | 
| 3197 |     QCOMPARE(three->y(), 52.0); | 
| 3198 |     QCOMPARE(four->x(), 3.0); | 
| 3199 |     QCOMPARE(four->y(), 72.0); | 
| 3200 |     QCOMPARE(five->x(), 53.0); | 
| 3201 |     QCOMPARE(five->y(), 72.0); | 
| 3202 |  | 
| 3203 |     obj->setRightPadding(4.0); | 
| 3204 |  | 
| 3205 |     QCOMPARE(flow->property("padding" ).toDouble(), 1.0); | 
| 3206 |     QCOMPARE(flow->property("topPadding" ).toDouble(), 2.0); | 
| 3207 |     QCOMPARE(flow->property("leftPadding" ).toDouble(), 3.0); | 
| 3208 |     QCOMPARE(flow->property("rightPadding" ).toDouble(), 4.0); | 
| 3209 |     QCOMPARE(flow->property("bottomPadding" ).toDouble(), 1.0); | 
| 3210 |  | 
| 3211 |     QCOMPARE(flow->height(), 123.0); | 
| 3212 |     QCOMPARE(flow->width(), 90.0); | 
| 3213 |  | 
| 3214 |     QTRY_COMPARE(one->x(), 3.0); | 
| 3215 |     QCOMPARE(one->y(), 2.0); | 
| 3216 |     QCOMPARE(two->x(), 53.0); | 
| 3217 |     QCOMPARE(two->y(), 2.0); | 
| 3218 |     QCOMPARE(three->x(), 3.0); | 
| 3219 |     QCOMPARE(three->y(), 52.0); | 
| 3220 |     QCOMPARE(four->x(), 3.0); | 
| 3221 |     QCOMPARE(four->y(), 72.0); | 
| 3222 |     QCOMPARE(five->x(), 53.0); | 
| 3223 |     QCOMPARE(five->y(), 72.0); | 
| 3224 |  | 
| 3225 |     obj->setBottomPadding(5.0); | 
| 3226 |  | 
| 3227 |     QCOMPARE(flow->property("padding" ).toDouble(), 1.0); | 
| 3228 |     QCOMPARE(flow->property("topPadding" ).toDouble(), 2.0); | 
| 3229 |     QCOMPARE(flow->property("leftPadding" ).toDouble(), 3.0); | 
| 3230 |     QCOMPARE(flow->property("rightPadding" ).toDouble(), 4.0); | 
| 3231 |     QCOMPARE(flow->property("bottomPadding" ).toDouble(), 5.0); | 
| 3232 |  | 
| 3233 |     QTRY_COMPARE(flow->height(), 127.0); | 
| 3234 |     QCOMPARE(flow->width(), 90.0); | 
| 3235 |  | 
| 3236 |     QCOMPARE(one->x(), 3.0); | 
| 3237 |     QCOMPARE(one->y(), 2.0); | 
| 3238 |     QCOMPARE(two->x(), 53.0); | 
| 3239 |     QCOMPARE(two->y(), 2.0); | 
| 3240 |     QCOMPARE(three->x(), 3.0); | 
| 3241 |     QCOMPARE(three->y(), 52.0); | 
| 3242 |     QCOMPARE(four->x(), 3.0); | 
| 3243 |     QCOMPARE(four->y(), 72.0); | 
| 3244 |     QCOMPARE(five->x(), 53.0); | 
| 3245 |     QCOMPARE(five->y(), 72.0); | 
| 3246 |  | 
| 3247 |     obj->resetBottomPadding(); | 
| 3248 |     QCOMPARE(flow->property("bottomPadding" ).toDouble(), 1.0); | 
| 3249 |     QTRY_COMPARE(flow->height(), 123.0); | 
| 3250 |     QCOMPARE(flow->width(), 90.0); | 
| 3251 |  | 
| 3252 |     obj->resetRightPadding(); | 
| 3253 |     QCOMPARE(flow->property("rightPadding" ).toDouble(), 1.0); | 
| 3254 |     QTRY_COMPARE(flow->height(), 123.0); | 
| 3255 |     QCOMPARE(flow->width(), 90.0); | 
| 3256 |  | 
| 3257 |     obj->resetLeftPadding(); | 
| 3258 |     QCOMPARE(flow->property("leftPadding" ).toDouble(), 1.0); | 
| 3259 |     QTRY_COMPARE(flow->height(), 123.0); | 
| 3260 |     QCOMPARE(flow->width(), 90.0); | 
| 3261 |  | 
| 3262 |     obj->resetTopPadding(); | 
| 3263 |     QCOMPARE(flow->property("topPadding" ).toDouble(), 1.0); | 
| 3264 |     QTRY_COMPARE(flow->height(), 122.0); | 
| 3265 |     QCOMPARE(flow->width(), 90.0); | 
| 3266 |  | 
| 3267 |     obj->resetPadding(); | 
| 3268 |     QCOMPARE(flow->property("padding" ).toDouble(), 0.0); | 
| 3269 |     QCOMPARE(flow->property("topPadding" ).toDouble(), 0.0); | 
| 3270 |     QCOMPARE(flow->property("leftPadding" ).toDouble(), 0.0); | 
| 3271 |     QCOMPARE(flow->property("rightPadding" ).toDouble(), 0.0); | 
| 3272 |     QCOMPARE(flow->property("bottomPadding" ).toDouble(), 0.0); | 
| 3273 |     QTRY_COMPARE(flow->height(), 120.0); | 
| 3274 |     QCOMPARE(flow->width(), 90.0); | 
| 3275 |  | 
| 3276 |     QCOMPARE(one->x(), 0.0); | 
| 3277 |     QCOMPARE(one->y(), 0.0); | 
| 3278 |     QCOMPARE(two->x(), 50.0); | 
| 3279 |     QCOMPARE(two->y(), 0.0); | 
| 3280 |     QCOMPARE(three->x(), 0.0); | 
| 3281 |     QCOMPARE(three->y(), 50.0); | 
| 3282 |     QCOMPARE(four->x(), 0.0); | 
| 3283 |     QCOMPARE(four->y(), 70.0); | 
| 3284 |     QCOMPARE(five->x(), 50.0); | 
| 3285 |     QCOMPARE(five->y(), 70.0); | 
| 3286 | } | 
| 3287 |  | 
| 3288 | void tst_qquickpositioners::test_flow_rightToLeft() | 
| 3289 | { | 
| 3290 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "flowtest.qml" ))); | 
| 3291 |  | 
| 3292 |     window->rootObject()->setProperty(name: "testRightToLeft" , value: true); | 
| 3293 |  | 
| 3294 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 3295 |     QVERIFY(one != nullptr); | 
| 3296 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 3297 |     QVERIFY(two != nullptr); | 
| 3298 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 3299 |     QVERIFY(three != nullptr); | 
| 3300 |     QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>(aName: "four" ); | 
| 3301 |     QVERIFY(four != nullptr); | 
| 3302 |     QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>(aName: "five" ); | 
| 3303 |     QVERIFY(five != nullptr); | 
| 3304 |  | 
| 3305 |     QCOMPARE(one->x(), 40.0); | 
| 3306 |     QCOMPARE(one->y(), 0.0); | 
| 3307 |     QCOMPARE(two->x(), 20.0); | 
| 3308 |     QCOMPARE(two->y(), 0.0); | 
| 3309 |     QCOMPARE(three->x(), 40.0); | 
| 3310 |     QCOMPARE(three->y(), 50.0); | 
| 3311 |     QCOMPARE(four->x(), 40.0); | 
| 3312 |     QCOMPARE(four->y(), 70.0); | 
| 3313 |     QCOMPARE(five->x(), 30.0); | 
| 3314 |     QCOMPARE(five->y(), 70.0); | 
| 3315 |  | 
| 3316 |     QQuickItem *flow = window->rootObject()->findChild<QQuickItem*>(aName: "flow" ); | 
| 3317 |     QVERIFY(flow); | 
| 3318 |     QCOMPARE(flow->width(), 90.0); | 
| 3319 |     QCOMPARE(flow->height(), 120.0); | 
| 3320 |  | 
| 3321 |     // test padding | 
| 3322 |     flow->setProperty(name: "padding" , value: 1); | 
| 3323 |     flow->setProperty(name: "topPadding" , value: 2); | 
| 3324 |     flow->setProperty(name: "leftPadding" , value: 3); | 
| 3325 |     flow->setProperty(name: "rightPadding" , value: 4); | 
| 3326 |     flow->setProperty(name: "bottomPadding" , value: 5); | 
| 3327 |  | 
| 3328 |     QTRY_COMPARE(flow->height(), 127.0); | 
| 3329 |     QCOMPARE(flow->width(), 90.0); | 
| 3330 |  | 
| 3331 |     QCOMPARE(one->x(), 36.0); | 
| 3332 |     QCOMPARE(one->y(), 2.0); | 
| 3333 |     QCOMPARE(two->x(), 16.0); | 
| 3334 |     QCOMPARE(two->y(), 2.0); | 
| 3335 |     QCOMPARE(three->x(), 36.0); | 
| 3336 |     QCOMPARE(three->y(), 52.0); | 
| 3337 |     QCOMPARE(four->x(), 36.0); | 
| 3338 |     QCOMPARE(four->y(), 72.0); | 
| 3339 |     QCOMPARE(five->x(), 26.0); | 
| 3340 |     QCOMPARE(five->y(), 72.0); | 
| 3341 | } | 
| 3342 |  | 
| 3343 | void tst_qquickpositioners::test_flow_topToBottom() | 
| 3344 | { | 
| 3345 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "flowtest-toptobottom.qml" ))); | 
| 3346 |  | 
| 3347 |     window->rootObject()->setProperty(name: "testRightToLeft" , value: false); | 
| 3348 |  | 
| 3349 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 3350 |     QVERIFY(one != nullptr); | 
| 3351 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 3352 |     QVERIFY(two != nullptr); | 
| 3353 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 3354 |     QVERIFY(three != nullptr); | 
| 3355 |     QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>(aName: "four" ); | 
| 3356 |     QVERIFY(four != nullptr); | 
| 3357 |     QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>(aName: "five" ); | 
| 3358 |     QVERIFY(five != nullptr); | 
| 3359 |  | 
| 3360 |     QCOMPARE(one->x(), 0.0); | 
| 3361 |     QCOMPARE(one->y(), 0.0); | 
| 3362 |     QCOMPARE(two->x(), 50.0); | 
| 3363 |     QCOMPARE(two->y(), 0.0); | 
| 3364 |     QCOMPARE(three->x(), 50.0); | 
| 3365 |     QCOMPARE(three->y(), 50.0); | 
| 3366 |     QCOMPARE(four->x(), 100.0); | 
| 3367 |     QCOMPARE(four->y(), 0.0); | 
| 3368 |     QCOMPARE(five->x(), 100.0); | 
| 3369 |     QCOMPARE(five->y(), 50.0); | 
| 3370 |  | 
| 3371 |     QQuickItem *flow = window->rootObject()->findChild<QQuickItem*>(aName: "flow" ); | 
| 3372 |     QVERIFY(flow); | 
| 3373 |     QCOMPARE(flow->height(), 90.0); | 
| 3374 |     QCOMPARE(flow->width(), 150.0); | 
| 3375 |  | 
| 3376 |     window->rootObject()->setProperty(name: "testRightToLeft" , value: true); | 
| 3377 |  | 
| 3378 |     QVERIFY(flow); | 
| 3379 |     QCOMPARE(flow->height(), 90.0); | 
| 3380 |     QCOMPARE(flow->width(), 150.0); | 
| 3381 |  | 
| 3382 |     QCOMPARE(one->x(), 100.0); | 
| 3383 |     QCOMPARE(one->y(), 0.0); | 
| 3384 |     QCOMPARE(two->x(), 80.0); | 
| 3385 |     QCOMPARE(two->y(), 0.0); | 
| 3386 |     QCOMPARE(three->x(), 50.0); | 
| 3387 |     QCOMPARE(three->y(), 50.0); | 
| 3388 |     QCOMPARE(four->x(), 0.0); | 
| 3389 |     QCOMPARE(four->y(), 0.0); | 
| 3390 |     QCOMPARE(five->x(), 40.0); | 
| 3391 |     QCOMPARE(five->y(), 50.0); | 
| 3392 |  | 
| 3393 | } | 
| 3394 |  | 
| 3395 | void tst_qquickpositioners::test_flow_topToBottom_padding() | 
| 3396 | { | 
| 3397 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "flowtest-toptobottom.qml" ))); | 
| 3398 |  | 
| 3399 |     window->rootObject()->setProperty(name: "testRightToLeft" , value: false); | 
| 3400 |  | 
| 3401 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 3402 |     QVERIFY(one != nullptr); | 
| 3403 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 3404 |     QVERIFY(two != nullptr); | 
| 3405 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 3406 |     QVERIFY(three != nullptr); | 
| 3407 |     QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>(aName: "four" ); | 
| 3408 |     QVERIFY(four != nullptr); | 
| 3409 |     QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>(aName: "five" ); | 
| 3410 |     QVERIFY(five != nullptr); | 
| 3411 |  | 
| 3412 |     QCOMPARE(one->x(), 0.0); | 
| 3413 |     QCOMPARE(one->y(), 0.0); | 
| 3414 |     QCOMPARE(two->x(), 50.0); | 
| 3415 |     QCOMPARE(two->y(), 0.0); | 
| 3416 |     QCOMPARE(three->x(), 50.0); | 
| 3417 |     QCOMPARE(three->y(), 50.0); | 
| 3418 |     QCOMPARE(four->x(), 100.0); | 
| 3419 |     QCOMPARE(four->y(), 0.0); | 
| 3420 |     QCOMPARE(five->x(), 100.0); | 
| 3421 |     QCOMPARE(five->y(), 50.0); | 
| 3422 |  | 
| 3423 |     QQuickItem *flow = window->rootObject()->findChild<QQuickItem*>(aName: "flow" ); | 
| 3424 |     QVERIFY(flow); | 
| 3425 |     QCOMPARE(flow->height(), 90.0); | 
| 3426 |     QCOMPARE(flow->width(), 150.0); | 
| 3427 |  | 
| 3428 |     // test padding | 
| 3429 |     flow->setProperty(name: "padding" , value: 1); | 
| 3430 |     flow->setProperty(name: "topPadding" , value: 2); | 
| 3431 |     flow->setProperty(name: "leftPadding" , value: 3); | 
| 3432 |     flow->setProperty(name: "rightPadding" , value: 4); | 
| 3433 |     flow->setProperty(name: "bottomPadding" , value: 5); | 
| 3434 |  | 
| 3435 |     QTRY_COMPARE(flow->width(), 157.0); | 
| 3436 |     QCOMPARE(flow->height(), 90.0); | 
| 3437 |  | 
| 3438 |     QCOMPARE(one->x(), 3.0); | 
| 3439 |     QCOMPARE(one->y(), 2.0); | 
| 3440 |     QCOMPARE(two->x(), 53.0); | 
| 3441 |     QCOMPARE(two->y(), 2.0); | 
| 3442 |     QCOMPARE(three->x(), 53.0); | 
| 3443 |     QCOMPARE(three->y(), 52.0); | 
| 3444 |     QCOMPARE(four->x(), 103.0); | 
| 3445 |     QCOMPARE(four->y(), 2.0); | 
| 3446 |     QCOMPARE(five->x(), 103.0); | 
| 3447 |     QCOMPARE(five->y(), 52.0); | 
| 3448 |  | 
| 3449 |     window->rootObject()->setProperty(name: "testRightToLeft" , value: true); | 
| 3450 |  | 
| 3451 |     QVERIFY(flow); | 
| 3452 |     QTRY_COMPARE(flow->width(), 157.0); | 
| 3453 |     QCOMPARE(flow->height(), 90.0); | 
| 3454 |  | 
| 3455 |     QCOMPARE(one->x(), 103.0); | 
| 3456 |     QCOMPARE(one->y(), 2.0); | 
| 3457 |     QCOMPARE(two->x(), 83.0); | 
| 3458 |     QCOMPARE(two->y(), 2.0); | 
| 3459 |     QCOMPARE(three->x(), 53.0); | 
| 3460 |     QCOMPARE(three->y(), 52.0); | 
| 3461 |     QCOMPARE(four->x(), 3.0); | 
| 3462 |     QCOMPARE(four->y(), 2.0); | 
| 3463 |     QCOMPARE(five->x(), 43.0); | 
| 3464 |     QCOMPARE(five->y(), 52.0); | 
| 3465 |  | 
| 3466 | } | 
| 3467 |  | 
| 3468 | void tst_qquickpositioners::test_flow_resize() | 
| 3469 | { | 
| 3470 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "flowtest.qml" ))); | 
| 3471 |  | 
| 3472 |     QQuickItem *root = qobject_cast<QQuickItem*>(object: window->rootObject()); | 
| 3473 |     QVERIFY(root); | 
| 3474 |     root->setWidth(125); | 
| 3475 |     root->setProperty(name: "testRightToLeft" , value: false); | 
| 3476 |  | 
| 3477 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 3478 |     QVERIFY(one != nullptr); | 
| 3479 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 3480 |     QVERIFY(two != nullptr); | 
| 3481 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 3482 |     QVERIFY(three != nullptr); | 
| 3483 |     QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>(aName: "four" ); | 
| 3484 |     QVERIFY(four != nullptr); | 
| 3485 |     QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>(aName: "five" ); | 
| 3486 |     QVERIFY(five != nullptr); | 
| 3487 |  | 
| 3488 |     QTRY_COMPARE(one->x(), 0.0); | 
| 3489 |     QTRY_COMPARE(one->y(), 0.0); | 
| 3490 |     QTRY_COMPARE(two->x(), 50.0); | 
| 3491 |     QTRY_COMPARE(two->y(), 0.0); | 
| 3492 |     QTRY_COMPARE(three->x(), 70.0); | 
| 3493 |     QTRY_COMPARE(three->y(), 0.0); | 
| 3494 |     QTRY_COMPARE(four->x(), 0.0); | 
| 3495 |     QTRY_COMPARE(four->y(), 50.0); | 
| 3496 |     QTRY_COMPARE(five->x(), 50.0); | 
| 3497 |     QTRY_COMPARE(five->y(), 50.0); | 
| 3498 |  | 
| 3499 | } | 
| 3500 |  | 
| 3501 | void tst_qquickpositioners::test_flow_resize_padding() | 
| 3502 | { | 
| 3503 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "flowtest-padding.qml" ))); | 
| 3504 |  | 
| 3505 |     QQuickItem *root = qobject_cast<QQuickItem*>(object: window->rootObject()); | 
| 3506 |     QVERIFY(root); | 
| 3507 |     root->setWidth(125); | 
| 3508 |     root->setProperty(name: "testRightToLeft" , value: false); | 
| 3509 |  | 
| 3510 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 3511 |     QVERIFY(one != nullptr); | 
| 3512 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 3513 |     QVERIFY(two != nullptr); | 
| 3514 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 3515 |     QVERIFY(three != nullptr); | 
| 3516 |     QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>(aName: "four" ); | 
| 3517 |     QVERIFY(four != nullptr); | 
| 3518 |     QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>(aName: "five" ); | 
| 3519 |     QVERIFY(five != nullptr); | 
| 3520 |  | 
| 3521 |     QTRY_COMPARE(one->x(), 3.0); | 
| 3522 |     QTRY_COMPARE(one->y(), 2.0); | 
| 3523 |     QTRY_COMPARE(two->x(), 53.0); | 
| 3524 |     QTRY_COMPARE(two->y(), 2.0); | 
| 3525 |     QTRY_COMPARE(three->x(), 3.0); | 
| 3526 |     QTRY_COMPARE(three->y(), 52.0); | 
| 3527 |     QTRY_COMPARE(four->x(), 53.0); | 
| 3528 |     QTRY_COMPARE(four->y(), 52.0); | 
| 3529 |     QTRY_COMPARE(five->x(), 103.0); | 
| 3530 |     QTRY_COMPARE(five->y(), 52.0); | 
| 3531 |  | 
| 3532 | } | 
| 3533 |  | 
| 3534 | void tst_qquickpositioners::test_flow_resize_rightToLeft() | 
| 3535 | { | 
| 3536 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "flowtest.qml" ))); | 
| 3537 |  | 
| 3538 |     QQuickItem *root = qobject_cast<QQuickItem*>(object: window->rootObject()); | 
| 3539 |     QVERIFY(root); | 
| 3540 |     root->setWidth(125); | 
| 3541 |     root->setProperty(name: "testRightToLeft" , value: true); | 
| 3542 |  | 
| 3543 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 3544 |     QTRY_VERIFY(one != nullptr); | 
| 3545 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 3546 |     QVERIFY(two != nullptr); | 
| 3547 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 3548 |     QVERIFY(three != nullptr); | 
| 3549 |     QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>(aName: "four" ); | 
| 3550 |     QVERIFY(four != nullptr); | 
| 3551 |     QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>(aName: "five" ); | 
| 3552 |     QVERIFY(five != nullptr); | 
| 3553 |  | 
| 3554 |     QCOMPARE(one->x(), 75.0); | 
| 3555 |     QCOMPARE(one->y(), 0.0); | 
| 3556 |     QCOMPARE(two->x(), 55.0); | 
| 3557 |     QCOMPARE(two->y(), 0.0); | 
| 3558 |     QCOMPARE(three->x(), 5.0); | 
| 3559 |     QCOMPARE(three->y(), 0.0); | 
| 3560 |     QCOMPARE(four->x(), 75.0); | 
| 3561 |     QCOMPARE(four->y(), 50.0); | 
| 3562 |     QCOMPARE(five->x(), 65.0); | 
| 3563 |     QCOMPARE(five->y(), 50.0); | 
| 3564 |  | 
| 3565 | } | 
| 3566 |  | 
| 3567 | void tst_qquickpositioners::test_flow_resize_rightToLeft_padding() | 
| 3568 | { | 
| 3569 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "flowtest-padding.qml" ))); | 
| 3570 |  | 
| 3571 |     QQuickItem *root = qobject_cast<QQuickItem*>(object: window->rootObject()); | 
| 3572 |     QVERIFY(root); | 
| 3573 |     root->setWidth(125); | 
| 3574 |     root->setProperty(name: "testRightToLeft" , value: true); | 
| 3575 |  | 
| 3576 |     QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>(aName: "one" ); | 
| 3577 |     QTRY_VERIFY(one != nullptr); | 
| 3578 |     QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>(aName: "two" ); | 
| 3579 |     QVERIFY(two != nullptr); | 
| 3580 |     QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>(aName: "three" ); | 
| 3581 |     QVERIFY(three != nullptr); | 
| 3582 |     QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>(aName: "four" ); | 
| 3583 |     QVERIFY(four != nullptr); | 
| 3584 |     QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>(aName: "five" ); | 
| 3585 |     QVERIFY(five != nullptr); | 
| 3586 |  | 
| 3587 |     QCOMPARE(one->x(), 71.0); | 
| 3588 |     QCOMPARE(one->y(), 2.0); | 
| 3589 |     QCOMPARE(two->x(), 51.0); | 
| 3590 |     QCOMPARE(two->y(), 2.0); | 
| 3591 |     QCOMPARE(three->x(), 71.0); | 
| 3592 |     QCOMPARE(three->y(), 52.0); | 
| 3593 |     QCOMPARE(four->x(), 21.0); | 
| 3594 |     QCOMPARE(four->y(), 52.0); | 
| 3595 |     QCOMPARE(five->x(), 11.0); | 
| 3596 |     QCOMPARE(five->y(), 52.0); | 
| 3597 |  | 
| 3598 | } | 
| 3599 |  | 
| 3600 | void tst_qquickpositioners::test_flow_implicit_resize() | 
| 3601 | { | 
| 3602 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "flow-testimplicitsize.qml" ))); | 
| 3603 |     QVERIFY(window->rootObject() != nullptr); | 
| 3604 |  | 
| 3605 |     QQuickFlow *flow = window->rootObject()->findChild<QQuickFlow*>(aName: "flow" ); | 
| 3606 |     QVERIFY(flow != nullptr); | 
| 3607 |  | 
| 3608 |     QCOMPARE(flow->width(), 100.0); | 
| 3609 |     QCOMPARE(flow->height(), 120.0); | 
| 3610 |  | 
| 3611 |     window->rootObject()->setProperty(name: "flowLayout" , value: 0); | 
| 3612 |     QCOMPARE(flow->flow(), QQuickFlow::LeftToRight); | 
| 3613 |     QCOMPARE(flow->width(), 220.0); | 
| 3614 |     QCOMPARE(flow->height(), 50.0); | 
| 3615 |  | 
| 3616 |     window->rootObject()->setProperty(name: "flowLayout" , value: 1); | 
| 3617 |     QCOMPARE(flow->flow(), QQuickFlow::TopToBottom); | 
| 3618 |     QCOMPARE(flow->width(), 100.0); | 
| 3619 |     QCOMPARE(flow->height(), 120.0); | 
| 3620 |  | 
| 3621 |     window->rootObject()->setProperty(name: "flowLayout" , value: 2); | 
| 3622 |     QCOMPARE(flow->layoutDirection(), Qt::RightToLeft); | 
| 3623 |     QCOMPARE(flow->width(), 220.0); | 
| 3624 |     QCOMPARE(flow->height(), 50.0); | 
| 3625 |  | 
| 3626 | } | 
| 3627 |  | 
| 3628 | void tst_qquickpositioners::test_flow_implicit_resize_padding() | 
| 3629 | { | 
| 3630 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "flow-testimplicitsize.qml" ))); | 
| 3631 |     QVERIFY(window->rootObject() != nullptr); | 
| 3632 |  | 
| 3633 |     QQuickFlow *flow = window->rootObject()->findChild<QQuickFlow*>(aName: "flow" ); | 
| 3634 |     QVERIFY(flow != nullptr); | 
| 3635 |  | 
| 3636 |     QCOMPARE(flow->width(), 100.0); | 
| 3637 |     QCOMPARE(flow->height(), 120.0); | 
| 3638 |  | 
| 3639 |     // test padding | 
| 3640 |     flow->setProperty(name: "padding" , value: 1); | 
| 3641 |     flow->setProperty(name: "topPadding" , value: 2); | 
| 3642 |     flow->setProperty(name: "leftPadding" , value: 3); | 
| 3643 |     flow->setProperty(name: "rightPadding" , value: 4); | 
| 3644 |     flow->setProperty(name: "bottomPadding" , value: 5); | 
| 3645 |  | 
| 3646 |     QTRY_COMPARE(flow->width(), 107.0); | 
| 3647 |     QCOMPARE(flow->height(), 127.0); | 
| 3648 |  | 
| 3649 |     window->rootObject()->setProperty(name: "flowLayout" , value: 0); | 
| 3650 |     QCOMPARE(flow->flow(), QQuickFlow::LeftToRight); | 
| 3651 |     QCOMPARE(flow->width(), 227.0); | 
| 3652 |     QCOMPARE(flow->height(), 57.0); | 
| 3653 |  | 
| 3654 |     window->rootObject()->setProperty(name: "flowLayout" , value: 1); | 
| 3655 |     QCOMPARE(flow->flow(), QQuickFlow::TopToBottom); | 
| 3656 |     QCOMPARE(flow->width(), 107.0); | 
| 3657 |     QCOMPARE(flow->height(), 127.0); | 
| 3658 |  | 
| 3659 |     window->rootObject()->setProperty(name: "flowLayout" , value: 2); | 
| 3660 |     QCOMPARE(flow->layoutDirection(), Qt::RightToLeft); | 
| 3661 |     QCOMPARE(flow->width(), 227.0); | 
| 3662 |     QCOMPARE(flow->height(), 57.0); | 
| 3663 |  | 
| 3664 | } | 
| 3665 |  | 
| 3666 | void tst_qquickpositioners::test_conflictinganchors() | 
| 3667 | { | 
| 3668 |     QQmlTestMessageHandler messageHandler; | 
| 3669 |     QQmlEngine engine; | 
| 3670 |     QQmlComponent component(&engine); | 
| 3671 |  | 
| 3672 |     component.setData("import QtQuick 2.0\nColumn { Item { width: 100; height: 100; } }" , baseUrl: QUrl::fromLocalFile(localfile: "" )); | 
| 3673 |     QQuickItem *item = qobject_cast<QQuickItem*>(object: component.create()); | 
| 3674 |     QVERIFY(item); | 
| 3675 |     QVERIFY2(messageHandler.messages().isEmpty(), qPrintable(messageHandler.messageString())); | 
| 3676 |     delete item; | 
| 3677 |  | 
| 3678 |     component.setData("import QtQuick 2.0\nRow { Item { width: 100; height: 100; } }" , baseUrl: QUrl::fromLocalFile(localfile: "" )); | 
| 3679 |     item = qobject_cast<QQuickItem*>(object: component.create()); | 
| 3680 |     QVERIFY(item); | 
| 3681 |     QVERIFY2(messageHandler.messages().isEmpty(), qPrintable(messageHandler.messageString())); | 
| 3682 |     delete item; | 
| 3683 |  | 
| 3684 |     component.setData("import QtQuick 2.0\nGrid { Item { width: 100; height: 100; } }" , baseUrl: QUrl::fromLocalFile(localfile: "" )); | 
| 3685 |     item = qobject_cast<QQuickItem*>(object: component.create()); | 
| 3686 |     QVERIFY(item); | 
| 3687 |     QVERIFY2(messageHandler.messages().isEmpty(), qPrintable(messageHandler.messageString())); | 
| 3688 |     delete item; | 
| 3689 |  | 
| 3690 |     component.setData("import QtQuick 2.0\nFlow { Item { width: 100; height: 100; } }" , baseUrl: QUrl::fromLocalFile(localfile: "" )); | 
| 3691 |     item = qobject_cast<QQuickItem*>(object: component.create()); | 
| 3692 |     QVERIFY(item); | 
| 3693 |     QVERIFY2(messageHandler.messages().isEmpty(), qPrintable(messageHandler.messageString())); | 
| 3694 |     delete item; | 
| 3695 |  | 
| 3696 |     component.setData("import QtQuick 2.0\nColumn { Item { width: 100; height: 100; anchors.top: parent.top } }" , baseUrl: QUrl::fromLocalFile(localfile: "" )); | 
| 3697 |     item = qobject_cast<QQuickItem*>(object: component.create()); | 
| 3698 |     QVERIFY(item); | 
| 3699 |     QCOMPARE(messageHandler.messages().size(), 1); | 
| 3700 |     QCOMPARE(messageHandler.messages().back(), QString("<Unknown File>:2:1: QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column. Column will not function." )); | 
| 3701 |     messageHandler.clear(); | 
| 3702 |     delete item; | 
| 3703 |  | 
| 3704 |     component.setData("import QtQuick 2.0\nColumn { Item { width: 100; height: 100; anchors.centerIn: parent } }" , baseUrl: QUrl::fromLocalFile(localfile: "" )); | 
| 3705 |     item = qobject_cast<QQuickItem*>(object: component.create()); | 
| 3706 |     QVERIFY(item); | 
| 3707 |     QCOMPARE(messageHandler.messages().size(), 1); | 
| 3708 |     QCOMPARE(messageHandler.messages().back(), QString("<Unknown File>:2:1: QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column. Column will not function." )); | 
| 3709 |     messageHandler.clear(); | 
| 3710 |     delete item; | 
| 3711 |  | 
| 3712 |     component.setData("import QtQuick 2.0\nColumn { Item { width: 100; height: 100; anchors.left: parent.left } }" , baseUrl: QUrl::fromLocalFile(localfile: "" )); | 
| 3713 |     item = qobject_cast<QQuickItem*>(object: component.create()); | 
| 3714 |     QVERIFY(item); | 
| 3715 |     QVERIFY2(messageHandler.messages().isEmpty(), qPrintable(messageHandler.messageString())); | 
| 3716 |     delete item; | 
| 3717 |  | 
| 3718 |     component.setData("import QtQuick 2.0\nRow { Item { width: 100; height: 100; anchors.left: parent.left } }" , baseUrl: QUrl::fromLocalFile(localfile: "" )); | 
| 3719 |     item = qobject_cast<QQuickItem*>(object: component.create()); | 
| 3720 |     QVERIFY(item); | 
| 3721 |     QCOMPARE(messageHandler.messages().size(), 1); | 
| 3722 |     QCOMPARE(messageHandler.messages().back(), QString("<Unknown File>:2:1: QML Row: Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row. Row will not function." )); | 
| 3723 |     messageHandler.clear(); | 
| 3724 |     delete item; | 
| 3725 |  | 
| 3726 |     component.setData("import QtQuick 2.0\nRow { width: 100; height: 100; Item { anchors.fill: parent } }" , baseUrl: QUrl::fromLocalFile(localfile: "" )); | 
| 3727 |     item = qobject_cast<QQuickItem*>(object: component.create()); | 
| 3728 |     QVERIFY(item); | 
| 3729 |     QCOMPARE(messageHandler.messages().size(), 1); | 
| 3730 |     QCOMPARE(messageHandler.messages().back(), QString("<Unknown File>:2:1: QML Row: Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row. Row will not function." )); | 
| 3731 |     messageHandler.clear(); | 
| 3732 |     delete item; | 
| 3733 |  | 
| 3734 |     component.setData("import QtQuick 2.0\nRow { Item { width: 100; height: 100; anchors.top: parent.top } }" , baseUrl: QUrl::fromLocalFile(localfile: "" )); | 
| 3735 |     item = qobject_cast<QQuickItem*>(object: component.create()); | 
| 3736 |     QVERIFY(item); | 
| 3737 |     QVERIFY2(messageHandler.messages().isEmpty(), qPrintable(messageHandler.messageString())); | 
| 3738 |     delete item; | 
| 3739 |  | 
| 3740 |     component.setData("import QtQuick 2.0\nGrid { Item { width: 100; height: 100; anchors.horizontalCenter: parent.horizontalCenter } }" , baseUrl: QUrl::fromLocalFile(localfile: "" )); | 
| 3741 |     item = qobject_cast<QQuickItem*>(object: component.create()); | 
| 3742 |     QVERIFY(item); | 
| 3743 |     QCOMPARE(messageHandler.messages().size(), 1); | 
| 3744 |     QCOMPARE(messageHandler.messages().back(), QString("<Unknown File>:2:1: QML Grid: Cannot specify anchors for items inside Grid. Grid will not function." )); | 
| 3745 |     messageHandler.clear(); | 
| 3746 |     delete item; | 
| 3747 |  | 
| 3748 |     component.setData("import QtQuick 2.0\nGrid { Item { width: 100; height: 100; anchors.centerIn: parent } }" , baseUrl: QUrl::fromLocalFile(localfile: "" )); | 
| 3749 |     item = qobject_cast<QQuickItem*>(object: component.create()); | 
| 3750 |     QVERIFY(item); | 
| 3751 |     QCOMPARE(messageHandler.messages().size(), 1); | 
| 3752 |     QCOMPARE(messageHandler.messages().back(), QString("<Unknown File>:2:1: QML Grid: Cannot specify anchors for items inside Grid. Grid will not function." )); | 
| 3753 |     messageHandler.clear(); | 
| 3754 |     delete item; | 
| 3755 |  | 
| 3756 |     component.setData("import QtQuick 2.0\nFlow { Item { width: 100; height: 100; anchors.verticalCenter: parent.verticalCenter } }" , baseUrl: QUrl::fromLocalFile(localfile: "" )); | 
| 3757 |     item = qobject_cast<QQuickItem*>(object: component.create()); | 
| 3758 |     QVERIFY(item); | 
| 3759 |     QCOMPARE(messageHandler.messages().size(), 1); | 
| 3760 |     QCOMPARE(messageHandler.messages().back(), QString("<Unknown File>:2:1: QML Flow: Cannot specify anchors for items inside Flow. Flow will not function." )); | 
| 3761 |     messageHandler.clear(); | 
| 3762 |     delete item; | 
| 3763 |  | 
| 3764 |     component.setData("import QtQuick 2.0\nFlow {  width: 100; height: 100; Item { anchors.fill: parent } }" , baseUrl: QUrl::fromLocalFile(localfile: "" )); | 
| 3765 |     item = qobject_cast<QQuickItem*>(object: component.create()); | 
| 3766 |     QVERIFY(item); | 
| 3767 |     QCOMPARE(messageHandler.messages().size(), 1); | 
| 3768 |     QCOMPARE(messageHandler.messages().back(), QString("<Unknown File>:2:1: QML Flow: Cannot specify anchors for items inside Flow. Flow will not function." )); | 
| 3769 |     delete item; | 
| 3770 | } | 
| 3771 |  | 
| 3772 | void tst_qquickpositioners::test_mirroring() | 
| 3773 | { | 
| 3774 |     QList<QString> qmlFiles; | 
| 3775 |     qmlFiles << "horizontal.qml"  << "horizontal-padding.qml"  | 
| 3776 |              << "gridtest.qml"  << "gridtest-padding.qml"  | 
| 3777 |              << "flowtest.qml"  << "flowtest-padding.qml" ; | 
| 3778 |     QList<QString> objectNames; | 
| 3779 |     objectNames << "one"  << "two"  << "three"  << "four"  << "five" ; | 
| 3780 |  | 
| 3781 |     foreach (const QString qmlFile, qmlFiles) { | 
| 3782 |         QScopedPointer<QQuickView> windowA(createView(filename: testFile(fileName: qmlFile))); | 
| 3783 |         QQuickItem *rootA = qobject_cast<QQuickItem*>(object: windowA->rootObject()); | 
| 3784 |  | 
| 3785 |         QScopedPointer<QQuickView> windowB(createView(filename: testFile(fileName: qmlFile))); | 
| 3786 |         QQuickItem *rootB = qobject_cast<QQuickItem*>(object: windowB->rootObject()); | 
| 3787 |         // On OS X the windows might get positioned exactly on top of each other | 
| 3788 |         // that means no repaint for the bottom window will ever occur | 
| 3789 |         windowB->setPosition(windowB->position() + QPoint(10, 10)); | 
| 3790 |  | 
| 3791 |         rootA->setProperty(name: "testRightToLeft" , value: true); // layoutDirection: Qt.RightToLeft | 
| 3792 |  | 
| 3793 |         // LTR != RTL | 
| 3794 |         foreach (const QString objectName, objectNames) { | 
| 3795 |             // horizontal.qml and horizontal-padding.qml only have three items | 
| 3796 |             if (qmlFile.startsWith(s: QString("horizontal" )) && objectName == QString("four" )) | 
| 3797 |                 break; | 
| 3798 |             QQuickItem *itemA = rootA->findChild<QQuickItem*>(aName: objectName); | 
| 3799 |             QQuickItem *itemB = rootB->findChild<QQuickItem*>(aName: objectName); | 
| 3800 |             QTRY_VERIFY(itemA->x() != itemB->x()); | 
| 3801 |         } | 
| 3802 |  | 
| 3803 |         QQmlProperty enabledProp(rootB, "LayoutMirroring.enabled" , qmlContext(rootB)); | 
| 3804 |         enabledProp.write(true); | 
| 3805 |         QQmlProperty inheritProp(rootB, "LayoutMirroring.childrenInherit" , qmlContext(rootB)); | 
| 3806 |         inheritProp.write(true); | 
| 3807 |  | 
| 3808 |         // RTL == mirror | 
| 3809 |         foreach (const QString objectName, objectNames) { | 
| 3810 |             // horizontal.qml and horizontal-padding.qml only have three items | 
| 3811 |             if (qmlFile.startsWith(s: QString("horizontal" )) && objectName == QString("four" )) | 
| 3812 |                 break; | 
| 3813 |             QQuickItem *itemA = rootA->findChild<QQuickItem*>(aName: objectName); | 
| 3814 |             QQuickItem *itemB = rootB->findChild<QQuickItem*>(aName: objectName); | 
| 3815 |             QTRY_COMPARE(itemA->x(), itemB->x()); | 
| 3816 |  | 
| 3817 |             // after resize (QTBUG-35095) | 
| 3818 |             QQuickItem *positionerA = itemA->parentItem(); | 
| 3819 |             QQuickItem *positionerB = itemB->parentItem(); | 
| 3820 |             positionerA->setWidth(positionerA->width() * 2); | 
| 3821 |             positionerB->setWidth(positionerB->width() * 2); | 
| 3822 |             QVERIFY(QQuickTest::qWaitForItemPolished(positionerA) && QQuickTest::qWaitForItemPolished(positionerB)); | 
| 3823 |             QTRY_COMPARE(itemA->x(), itemB->x()); | 
| 3824 |         } | 
| 3825 |  | 
| 3826 |         rootA->setProperty(name: "testRightToLeft" , value: false); // layoutDirection: Qt.LeftToRight | 
| 3827 |         rootB->setProperty(name: "testRightToLeft" , value: true); // layoutDirection: Qt.RightToLeft | 
| 3828 |  | 
| 3829 |         // LTR == RTL + mirror | 
| 3830 |         foreach (const QString objectName, objectNames) { | 
| 3831 |             // horizontal.qml and horizontal-padding.qml only have three items | 
| 3832 |             if (qmlFile.startsWith(s: QString("horizontal" )) && objectName == QString("four" )) | 
| 3833 |                 break; | 
| 3834 |             QQuickItem *itemA = rootA->findChild<QQuickItem*>(aName: objectName); | 
| 3835 |             QQuickItem *itemB = rootB->findChild<QQuickItem*>(aName: objectName); | 
| 3836 |             QTRY_COMPARE(itemA->x(), itemB->x()); | 
| 3837 |         } | 
| 3838 |     } | 
| 3839 | } | 
| 3840 |  | 
| 3841 | void tst_qquickpositioners::test_allInvisible() | 
| 3842 | { | 
| 3843 |     //QTBUG-19361 | 
| 3844 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "allInvisible.qml" ))); | 
| 3845 |  | 
| 3846 |     QQuickItem *root = qobject_cast<QQuickItem*>(object: window->rootObject()); | 
| 3847 |     QVERIFY(root); | 
| 3848 |  | 
| 3849 |     QQuickRow *row = window->rootObject()->findChild<QQuickRow*>(aName: "row" ); | 
| 3850 |     QVERIFY(row != nullptr); | 
| 3851 |     QCOMPARE(row->width(), qreal(0)); | 
| 3852 |     QCOMPARE(row->height(), qreal(0)); | 
| 3853 |  | 
| 3854 |     // test padding | 
| 3855 |     row->setProperty(name: "padding" , value: 1); | 
| 3856 |     row->setProperty(name: "topPadding" , value: 2); | 
| 3857 |     row->setProperty(name: "leftPadding" , value: 3); | 
| 3858 |     row->setProperty(name: "rightPadding" , value: 4); | 
| 3859 |     row->setProperty(name: "bottomPadding" , value: 5); | 
| 3860 |  | 
| 3861 |     QTRY_COMPARE(row->height(), 7.0); | 
| 3862 |     QCOMPARE(row->width(), 7.0); | 
| 3863 |  | 
| 3864 |     QQuickColumn *column = window->rootObject()->findChild<QQuickColumn*>(aName: "column" ); | 
| 3865 |     QVERIFY(column != nullptr); | 
| 3866 |     QCOMPARE(column->width(), qreal(0)); | 
| 3867 |     QCOMPARE(column->height(), qreal(0)); | 
| 3868 |  | 
| 3869 |     // test padding | 
| 3870 |     column->setProperty(name: "padding" , value: 1); | 
| 3871 |     column->setProperty(name: "topPadding" , value: 2); | 
| 3872 |     column->setProperty(name: "leftPadding" , value: 3); | 
| 3873 |     column->setProperty(name: "rightPadding" , value: 4); | 
| 3874 |     column->setProperty(name: "bottomPadding" , value: 5); | 
| 3875 |  | 
| 3876 |     QTRY_COMPARE(column->height(), 7.0); | 
| 3877 |     QCOMPARE(column->width(), 7.0); | 
| 3878 |  | 
| 3879 |     QQuickGrid *grid = window->rootObject()->findChild<QQuickGrid*>(aName: "grid" ); | 
| 3880 |     QVERIFY(grid != nullptr); | 
| 3881 |     QCOMPARE(grid->width(), qreal(0)); | 
| 3882 |     QCOMPARE(grid->height(), qreal(0)); | 
| 3883 |  | 
| 3884 |     // test padding | 
| 3885 |     grid->setProperty(name: "padding" , value: 1); | 
| 3886 |     grid->setProperty(name: "topPadding" , value: 2); | 
| 3887 |     grid->setProperty(name: "leftPadding" , value: 3); | 
| 3888 |     grid->setProperty(name: "rightPadding" , value: 4); | 
| 3889 |     grid->setProperty(name: "bottomPadding" , value: 5); | 
| 3890 |  | 
| 3891 |     QTRY_COMPARE(grid->height(), 7.0); | 
| 3892 |     QCOMPARE(grid->width(), 7.0); | 
| 3893 |  | 
| 3894 |     QQuickFlow *flow = window->rootObject()->findChild<QQuickFlow*>(aName: "flow" ); | 
| 3895 |     QVERIFY(flow != nullptr); | 
| 3896 |     QCOMPARE(flow->width(), qreal(0)); | 
| 3897 |     QCOMPARE(flow->height(), qreal(0)); | 
| 3898 |  | 
| 3899 |     // test padding | 
| 3900 |     flow->setProperty(name: "padding" , value: 1); | 
| 3901 |     flow->setProperty(name: "topPadding" , value: 2); | 
| 3902 |     flow->setProperty(name: "leftPadding" , value: 3); | 
| 3903 |     flow->setProperty(name: "rightPadding" , value: 4); | 
| 3904 |     flow->setProperty(name: "bottomPadding" , value: 5); | 
| 3905 |  | 
| 3906 |     QTRY_COMPARE(flow->height(), 7.0); | 
| 3907 |     QCOMPARE(flow->width(), 7.0); | 
| 3908 | } | 
| 3909 |  | 
| 3910 | void tst_qquickpositioners::test_attachedproperties() | 
| 3911 | { | 
| 3912 |     QFETCH(QString, filename); | 
| 3913 |  | 
| 3914 |     QScopedPointer<QQuickView> window(createView(filename)); | 
| 3915 |     QVERIFY(window->rootObject() != nullptr); | 
| 3916 |  | 
| 3917 |     QQuickRectangle *greenRect = window->rootObject()->findChild<QQuickRectangle *>(aName: "greenRect" ); | 
| 3918 |     QVERIFY(greenRect != nullptr); | 
| 3919 |  | 
| 3920 |     int posIndex = greenRect->property(name: "posIndex" ).toInt(); | 
| 3921 |     QCOMPARE(posIndex, 0); | 
| 3922 |     bool isFirst = greenRect->property(name: "isFirstItem" ).toBool(); | 
| 3923 |     QVERIFY(isFirst); | 
| 3924 |     bool isLast = greenRect->property(name: "isLastItem" ).toBool(); | 
| 3925 |     QVERIFY(!isLast); | 
| 3926 |  | 
| 3927 |     QQuickRectangle *yellowRect = window->rootObject()->findChild<QQuickRectangle *>(aName: "yellowRect" ); | 
| 3928 |     QVERIFY(yellowRect != nullptr); | 
| 3929 |  | 
| 3930 |     posIndex = yellowRect->property(name: "posIndex" ).toInt(); | 
| 3931 |     QCOMPARE(posIndex, -1); | 
| 3932 |     isFirst = yellowRect->property(name: "isFirstItem" ).toBool(); | 
| 3933 |     QVERIFY(!isFirst); | 
| 3934 |     isLast = yellowRect->property(name: "isLastItem" ).toBool(); | 
| 3935 |     QVERIFY(!isLast); | 
| 3936 |  | 
| 3937 |     yellowRect->metaObject()->invokeMethod(obj: yellowRect, member: "onDemandPositioner" ); | 
| 3938 |  | 
| 3939 |     posIndex = yellowRect->property(name: "posIndex" ).toInt(); | 
| 3940 |     QCOMPARE(posIndex, 1); | 
| 3941 |     isFirst = yellowRect->property(name: "isFirstItem" ).toBool(); | 
| 3942 |     QVERIFY(!isFirst); | 
| 3943 |     isLast = yellowRect->property(name: "isLastItem" ).toBool(); | 
| 3944 |     QVERIFY(isLast); | 
| 3945 |  | 
| 3946 | } | 
| 3947 |  | 
| 3948 | void tst_qquickpositioners::test_attachedproperties_data() | 
| 3949 | { | 
| 3950 |     QTest::addColumn<QString>(name: "filename" ); | 
| 3951 |  | 
| 3952 |     QTest::newRow(dataTag: "column" ) << testFile(fileName: "attachedproperties-column.qml" ); | 
| 3953 |     QTest::newRow(dataTag: "row" ) << testFile(fileName: "attachedproperties-row.qml" ); | 
| 3954 |     QTest::newRow(dataTag: "grid" ) << testFile(fileName: "attachedproperties-grid.qml" ); | 
| 3955 |     QTest::newRow(dataTag: "flow" ) << testFile(fileName: "attachedproperties-flow.qml" ); | 
| 3956 | } | 
| 3957 |  | 
| 3958 | void tst_qquickpositioners::test_attachedproperties_dynamic() | 
| 3959 | { | 
| 3960 |     QScopedPointer<QQuickView> window(createView(filename: testFile(fileName: "attachedproperties-dynamic.qml" ))); | 
| 3961 |     QVERIFY(window->rootObject() != nullptr); | 
| 3962 |  | 
| 3963 |     QQuickRow *row = window->rootObject()->findChild<QQuickRow *>(aName: "pos" ); | 
| 3964 |     QVERIFY(row != nullptr); | 
| 3965 |  | 
| 3966 |     QQuickRectangle *rect0 = window->rootObject()->findChild<QQuickRectangle *>(aName: "rect0" ); | 
| 3967 |     QVERIFY(rect0 != nullptr); | 
| 3968 |  | 
| 3969 |     int posIndex = rect0->property(name: "index" ).toInt(); | 
| 3970 |     QCOMPARE(posIndex, 0); | 
| 3971 |     bool isFirst = rect0->property(name: "firstItem" ).toBool(); | 
| 3972 |     QVERIFY(isFirst); | 
| 3973 |     bool isLast = rect0->property(name: "lastItem" ).toBool(); | 
| 3974 |     QVERIFY(!isLast); | 
| 3975 |  | 
| 3976 |     QQuickRectangle *rect1 = window->rootObject()->findChild<QQuickRectangle *>(aName: "rect1" ); | 
| 3977 |     QVERIFY(rect1 != nullptr); | 
| 3978 |  | 
| 3979 |     posIndex = rect1->property(name: "index" ).toInt(); | 
| 3980 |     QCOMPARE(posIndex, 1); | 
| 3981 |     isFirst = rect1->property(name: "firstItem" ).toBool(); | 
| 3982 |     QVERIFY(!isFirst); | 
| 3983 |     isLast = rect1->property(name: "lastItem" ).toBool(); | 
| 3984 |     QVERIFY(isLast); | 
| 3985 |  | 
| 3986 |     row->metaObject()->invokeMethod(obj: row, member: "createSubRect" ); | 
| 3987 |  | 
| 3988 |     QTRY_COMPARE(rect1->property("index" ).toInt(), 1); | 
| 3989 |     QTRY_VERIFY(!rect1->property("firstItem" ).toBool()); | 
| 3990 |     QTRY_VERIFY(!rect1->property("lastItem" ).toBool()); | 
| 3991 |  | 
| 3992 |     QQuickRectangle *rect2 = window->rootObject()->findChild<QQuickRectangle *>(aName: "rect2" ); | 
| 3993 |     QVERIFY(rect2 != nullptr); | 
| 3994 |  | 
| 3995 |     posIndex = rect2->property(name: "index" ).toInt(); | 
| 3996 |     QCOMPARE(posIndex, 2); | 
| 3997 |     isFirst = rect2->property(name: "firstItem" ).toBool(); | 
| 3998 |     QVERIFY(!isFirst); | 
| 3999 |     isLast = rect2->property(name: "lastItem" ).toBool(); | 
| 4000 |     QVERIFY(isLast); | 
| 4001 |  | 
| 4002 |     row->metaObject()->invokeMethod(obj: row, member: "destroySubRect" ); | 
| 4003 |  | 
| 4004 |     QCoreApplication::sendPostedEvents(receiver: nullptr, event_type: QEvent::DeferredDelete); | 
| 4005 |     QCoreApplication::processEvents(); | 
| 4006 |  | 
| 4007 |     QTRY_COMPARE(rect1->property("index" ).toInt(), 1); | 
| 4008 |     QTRY_VERIFY(!rect1->property("firstItem" ).toBool()); | 
| 4009 |     QTRY_VERIFY(rect1->property("lastItem" ).toBool()); | 
| 4010 |  | 
| 4011 | } | 
| 4012 |  | 
| 4013 | QQuickView *tst_qquickpositioners::createView(const QString &filename, bool wait) | 
| 4014 | { | 
| 4015 |     QQuickView *window = new QQuickView(nullptr); | 
| 4016 |     qCDebug(lcTests) << "created window" ; | 
| 4017 |  | 
| 4018 |     window->setSource(QUrl::fromLocalFile(localfile: filename)); | 
| 4019 |     qCDebug(lcTests) << "loaded content from"  << filename; | 
| 4020 |     window->show(); | 
| 4021 |     qCDebug(lcTests) << "window shown" ; | 
| 4022 |     bool exposed = true; | 
| 4023 |     if (wait) | 
| 4024 |         exposed = QTest::qWaitForWindowExposed(window); //It may not relayout until the next frame, so it needs to be drawn | 
| 4025 |     if (exposed) | 
| 4026 |         qCDebug(lcTests) << "window exposed" ; | 
| 4027 |     else | 
| 4028 |         qCWarning(lcTests) << "window NOT exposed" ; | 
| 4029 |  | 
| 4030 |     return window; | 
| 4031 | } | 
| 4032 |  | 
| 4033 | void tst_qquickpositioners::matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes) | 
| 4034 | { | 
| 4035 |     const QSet<int> expectedIndexSet(expectedIndexes.cbegin(), expectedIndexes.cend()); | 
| 4036 |     for (int i=0; i<indexLists.count(); i++) { | 
| 4037 |         const auto ¤tList = indexLists[i].value<QList<int> >(); | 
| 4038 |         const QSet<int> current(currentList.cbegin(), currentList.cend()); | 
| 4039 |         if (current != expectedIndexSet) | 
| 4040 |             qDebug() << "Cannot match actual targets"  << current << "with expected"  << expectedIndexes; | 
| 4041 |         QCOMPARE(current, expectedIndexSet); | 
| 4042 |     } | 
| 4043 | } | 
| 4044 |  | 
| 4045 | void tst_qquickpositioners::matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList<int> &expectedIndexes) | 
| 4046 | { | 
| 4047 |     for (QVariantMap::const_iterator it = items.begin(); it != items.end(); ++it) { | 
| 4048 |         QCOMPARE(it.value().type(), QVariant::Int); | 
| 4049 |         QString name = it.key(); | 
| 4050 |         int itemIndex = it.value().toInt(); | 
| 4051 |         QVERIFY2(expectedIndexes.contains(itemIndex), QTest::toString(QString("Index %1 not found in expectedIndexes" ).arg(itemIndex))); | 
| 4052 |         if (model.name(index: itemIndex) != name) | 
| 4053 |             qDebug() << itemIndex; | 
| 4054 |         QCOMPARE(model.name(itemIndex), name); | 
| 4055 |     } | 
| 4056 |     QCOMPARE(items.count(), expectedIndexes.count()); | 
| 4057 | } | 
| 4058 |  | 
| 4059 | void tst_qquickpositioners::matchItemLists(const QVariantList &itemLists, const QList<QQuickItem *> &expectedItems) | 
| 4060 | { | 
| 4061 |     for (int i=0; i<itemLists.count(); i++) { | 
| 4062 |         QCOMPARE(itemLists[i].type(), QVariant::List); | 
| 4063 |         QVariantList current = itemLists[i].toList(); | 
| 4064 |         for (int j=0; j<current.count(); j++) { | 
| 4065 |             QQuickItem *o = qobject_cast<QQuickItem*>(object: current[j].value<QObject*>()); | 
| 4066 |             QVERIFY2(o, QTest::toString(QString("Invalid actual item at %1" ).arg(j))); | 
| 4067 |             QVERIFY2(expectedItems.contains(o), QTest::toString(QString("Cannot match item %1" ).arg(j))); | 
| 4068 |         } | 
| 4069 |         QCOMPARE(current.count(), expectedItems.count()); | 
| 4070 |     } | 
| 4071 | } | 
| 4072 |  | 
| 4073 | QTEST_MAIN(tst_qquickpositioners) | 
| 4074 |  | 
| 4075 | #include "tst_qquickpositioners.moc" | 
| 4076 |  |