365 QVERIFY(item); |
365 QVERIFY(item); |
366 QCOMPARE(item->x(), 110.0); |
366 QCOMPARE(item->x(), 110.0); |
367 QCOMPARE(item->y(), 10.0); |
367 QCOMPARE(item->y(), 10.0); |
368 |
368 |
369 model.insertItem(4, "orange", "10"); |
369 model.insertItem(4, "orange", "10"); |
370 |
370 QTest::qWait(100); |
371 int itemCount = findItems<QDeclarativeItem>(pathview, "wrapper").count(); |
371 |
372 QCOMPARE(itemCount, 10); |
372 QTRY_COMPARE(findItems<QDeclarativeItem>(pathview, "wrapper").count(), 10); |
|
373 |
|
374 QVERIFY(pathview->currentIndex() == 0); |
373 |
375 |
374 QDeclarativeText *text = findItem<QDeclarativeText>(pathview, "myText", 4); |
376 QDeclarativeText *text = findItem<QDeclarativeText>(pathview, "myText", 4); |
375 QVERIFY(text); |
377 QVERIFY(text); |
376 QCOMPARE(text->text(), model.name(4)); |
378 QCOMPARE(text->text(), model.name(4)); |
377 |
379 |
382 |
384 |
383 testObject->setPathItemCount(5); |
385 testObject->setPathItemCount(5); |
384 QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); |
386 QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); |
385 QVERIFY(testObject->error() == false); |
387 QVERIFY(testObject->error() == false); |
386 |
388 |
387 itemCount = findItems<QDeclarativeItem>(pathview, "wrapper").count(); |
389 QTRY_COMPARE(findItems<QDeclarativeItem>(pathview, "wrapper").count(), 5); |
388 QCOMPARE(itemCount, 5); |
|
389 |
390 |
390 QDeclarativeRectangle *testItem = findItem<QDeclarativeRectangle>(pathview, "wrapper", 4); |
391 QDeclarativeRectangle *testItem = findItem<QDeclarativeRectangle>(pathview, "wrapper", 4); |
391 QVERIFY(testItem != 0); |
392 QVERIFY(testItem != 0); |
392 testItem = findItem<QDeclarativeRectangle>(pathview, "wrapper", 5); |
393 testItem = findItem<QDeclarativeRectangle>(pathview, "wrapper", 5); |
393 QVERIFY(testItem == 0); |
394 QVERIFY(testItem == 0); |
394 |
395 |
|
396 pathview->setCurrentIndex(1); |
|
397 |
395 model.insertItem(2, "pink", "2"); |
398 model.insertItem(2, "pink", "2"); |
396 |
399 QTest::qWait(100); |
397 itemCount = findItems<QDeclarativeItem>(pathview, "wrapper").count(); |
400 |
398 QCOMPARE(itemCount, 5); |
401 QTRY_COMPARE(findItems<QDeclarativeItem>(pathview, "wrapper").count(), 5); |
|
402 QVERIFY(pathview->currentIndex() == 1); |
399 |
403 |
400 text = findItem<QDeclarativeText>(pathview, "myText", 2); |
404 text = findItem<QDeclarativeText>(pathview, "myText", 2); |
401 QVERIFY(text); |
405 QVERIFY(text); |
402 QCOMPARE(text->text(), model.name(2)); |
406 QCOMPARE(text->text(), model.name(2)); |
403 |
407 |
404 model.removeItem(3); |
408 model.removeItem(3); |
405 itemCount = findItems<QDeclarativeItem>(pathview, "wrapper").count(); |
409 QTRY_COMPARE(findItems<QDeclarativeItem>(pathview, "wrapper").count(), 5); |
406 QCOMPARE(itemCount, 5); |
|
407 text = findItem<QDeclarativeText>(pathview, "myText", 3); |
410 text = findItem<QDeclarativeText>(pathview, "myText", 3); |
408 QVERIFY(text); |
411 QVERIFY(text); |
409 QCOMPARE(text->text(), model.name(3)); |
412 QCOMPARE(text->text(), model.name(3)); |
410 |
413 |
411 delete canvas; |
414 delete canvas; |
752 QVERIFY(item); |
755 QVERIFY(item); |
753 QVERIFY(item->scale() != 1.0); |
756 QVERIFY(item->scale() != 1.0); |
754 |
757 |
755 delete canvas; |
758 delete canvas; |
756 } |
759 } |
|
760 |
|
761 //QTBUG-13017 |
|
762 void tst_QDeclarativePathView::emptyModel() |
|
763 { |
|
764 QDeclarativeView *canvas = createView(); |
|
765 |
|
766 QStringListModel model; |
|
767 |
|
768 QDeclarativeContext *ctxt = canvas->rootContext(); |
|
769 ctxt->setContextProperty("emptyModel", &model); |
|
770 |
|
771 canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/emptymodel.qml")); |
|
772 qApp->processEvents(); |
|
773 |
|
774 QDeclarativePathView *pathview = qobject_cast<QDeclarativePathView*>(canvas->rootObject()); |
|
775 QVERIFY(pathview != 0); |
|
776 |
|
777 QCOMPARE(pathview->offset(), qreal(0.0)); |
|
778 |
|
779 delete canvas; |
|
780 } |
|
781 |
757 |
782 |
758 QDeclarativeView *tst_QDeclarativePathView::createView() |
783 QDeclarativeView *tst_QDeclarativePathView::createView() |
759 { |
784 { |
760 QDeclarativeView *canvas = new QDeclarativeView(0); |
785 QDeclarativeView *canvas = new QDeclarativeView(0); |
761 canvas->setFixedSize(240,320); |
786 canvas->setFixedSize(240,320); |