summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-08-31 04:02:08 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-08-31 04:02:08 (GMT)
commita0b413c14b94c1ac3f394f22076fd12c370d07f3 (patch)
tree6db2374a2d956c5922c3de0e9ad5bdc5d04b30d4 /tests/auto
parenta4d3ffe03359e415f4a4a5740eb19bbb9dfddc0b (diff)
parent33b1332d1b8593f488cf5f926315a6df68eee7df (diff)
downloadQt-a0b413c14b94c1ac3f394f22076fd12c370d07f3.zip
Qt-a0b413c14b94c1ac3f394f22076fd12c370d07f3.tar.gz
Qt-a0b413c14b94c1ac3f394f22076fd12c370d07f3.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml2
-rw-r--r--tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp9
-rw-r--r--tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp1
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml6
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp43
-rw-r--r--tests/auto/declarative/qdeclarativevisualdatamodel/data/datalist.qml16
-rw-r--r--tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp61
-rw-r--r--tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp195
-rw-r--r--tests/auto/qpen/tst_qpen.cpp1
9 files changed, 325 insertions, 9 deletions
diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml b/tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml
index 804559c..d41add3 100644
--- a/tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml
@@ -11,7 +11,7 @@ Rectangle {
width: 100
height: 100
Behavior on x {
- NumberAnimation {}
+ NumberAnimation { duration: 500 }
}
}
}
diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
index 896d69e..d4d8bf6 100644
--- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
+++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
@@ -655,6 +655,15 @@ void tst_QDeclarativeGridView::currentIndex()
gridview->setFlow(QDeclarativeGridView::TopToBottom);
+ qApp->setActiveWindow(canvas);
+#ifdef Q_WS_X11
+ // to be safe and avoid failing setFocus with window managers
+ qt_x11_wait_for_window_manager(canvas);
+#endif
+ QTRY_VERIFY(canvas->hasFocus());
+ QTRY_VERIFY(canvas->scene()->hasFocus());
+ qApp->processEvents();
+
QTest::keyClick(canvas, Qt::Key_Right);
QCOMPARE(gridview->currentIndex(), 5);
diff --git a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp
index 6d5a357..d0afc8a 100644
--- a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp
+++ b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp
@@ -389,6 +389,7 @@ void tst_qdeclarativeimageprovider::threadTest()
}
provider->ok = true;
provider->cond.wakeAll();
+ QTest::qWait(250);
foreach(QDeclarativeImage *img, images) {
TRY_WAIT(img->status() == QDeclarativeImage::Ready);
}
diff --git a/tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml b/tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml
index 3b2db5e..d5d3365 100644
--- a/tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml
+++ b/tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml
@@ -4,6 +4,12 @@ Rectangle {
width: 240
height: 320
color: "#ffffff"
+
+ property real hr: list.visibleArea.heightRatio
+ function heightRatio() {
+ return list.visibleArea.heightRatio
+ }
+
function checkProperties() {
testObject.error = false;
if (list.model != testModel) {
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index bf4754d..377a9e5 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -98,6 +98,7 @@ private slots:
void manualHighlight();
void QTBUG_11105();
void footer();
+ void resizeView();
private:
template <class T> void items();
@@ -1591,6 +1592,48 @@ void tst_QDeclarativeListView::footer()
QTRY_COMPARE(footer->y(), 0.0);
}
+void tst_QDeclarativeListView::resizeView()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ for (int i = 0; i < 40; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.);
+ }
+
+ QVariant heightRatio;
+ QMetaObject::invokeMethod(canvas->rootObject(), "heightRatio", Q_RETURN_ARG(QVariant, heightRatio));
+ QCOMPARE(heightRatio.toReal(), 0.4);
+
+ listview->setHeight(200);
+
+ QMetaObject::invokeMethod(canvas->rootObject(), "heightRatio", Q_RETURN_ARG(QVariant, heightRatio));
+ QCOMPARE(heightRatio.toReal(), 0.25);
+}
+
void tst_QDeclarativeListView::qListModelInterface_items()
{
items<TestModel>();
diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/data/datalist.qml b/tests/auto/declarative/qdeclarativevisualdatamodel/data/datalist.qml
index a798f77..c5e945a 100644
--- a/tests/auto/declarative/qdeclarativevisualdatamodel/data/datalist.qml
+++ b/tests/auto/declarative/qdeclarativevisualdatamodel/data/datalist.qml
@@ -4,12 +4,16 @@ ListView {
width: 100
height: 100
anchors.fill: parent
- model: myModel
- delegate: Component {
- Rectangle {
- height: 25
- width: 100
- Text { objectName: "display"; text: display }
+ model: VisualDataModel {
+ id: visualModel
+ objectName: "visualModel"
+ model: myModel
+ delegate: Component {
+ Rectangle {
+ height: 25
+ width: 100
+ Text { objectName: "display"; text: display }
+ }
}
}
}
diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
index 3cd786f..95ef4fc 100644
--- a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
+++ b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
@@ -84,6 +84,7 @@ public:
private slots:
void rootIndex();
void updateLayout();
+ void childChanged();
void objectListModel();
private:
@@ -174,22 +175,82 @@ void tst_qdeclarativevisualdatamodel::updateLayout()
QVERIFY(contentItem != 0);
QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "display", 0);
+ QVERIFY(name);
QCOMPARE(name->text(), QString("Row 1 Item"));
name = findItem<QDeclarativeText>(contentItem, "display", 1);
+ QVERIFY(name);
QCOMPARE(name->text(), QString("Row 2 Item"));
name = findItem<QDeclarativeText>(contentItem, "display", 2);
+ QVERIFY(name);
QCOMPARE(name->text(), QString("Row 3 Item"));
model.invisibleRootItem()->sortChildren(0, Qt::DescendingOrder);
name = findItem<QDeclarativeText>(contentItem, "display", 0);
+ QVERIFY(name);
QCOMPARE(name->text(), QString("Row 3 Item"));
name = findItem<QDeclarativeText>(contentItem, "display", 1);
+ QVERIFY(name);
QCOMPARE(name->text(), QString("Row 2 Item"));
name = findItem<QDeclarativeText>(contentItem, "display", 2);
+ QVERIFY(name);
QCOMPARE(name->text(), QString("Row 1 Item"));
}
+void tst_qdeclarativevisualdatamodel::childChanged()
+{
+ QDeclarativeView view;
+
+ QStandardItemModel model;
+ initStandardTreeModel(&model);
+
+ view.rootContext()->setContextProperty("myModel", &model);
+
+ view.setSource(QUrl::fromLocalFile(SRCDIR "/data/datalist.qml"));
+
+ QDeclarativeListView *listview = qobject_cast<QDeclarativeListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QDeclarativeVisualDataModel *vdm = listview->findChild<QDeclarativeVisualDataModel*>("visualModel");
+ vdm->setRootIndex(QVariant::fromValue(model.indexFromItem(model.item(1,0))));
+
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "display", 0);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 2 Child Item"));
+
+ model.item(1,0)->child(0,0)->setText("Row 2 updated child");
+
+ name = findItem<QDeclarativeText>(contentItem, "display", 0);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 2 updated child"));
+
+ model.item(1,0)->appendRow(new QStandardItem(QLatin1String("Row 2 Child Item 2")));
+ QTest::qWait(300);
+
+ name = findItem<QDeclarativeText>(contentItem, "display", 1);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), QString("Row 2 Child Item 2"));
+
+ model.item(1,0)->takeRow(1);
+ name = findItem<QDeclarativeText>(contentItem, "display", 1);
+ QVERIFY(name == 0);
+
+ vdm->setRootIndex(QVariant::fromValue(QModelIndex()));
+ QTest::qWait(300);
+ name = findItem<QDeclarativeText>(contentItem, "display", 0);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 1 Item"));
+ name = findItem<QDeclarativeText>(contentItem, "display", 1);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 2 Item"));
+ name = findItem<QDeclarativeText>(contentItem, "display", 2);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 3 Item"));
+}
+
void tst_qdeclarativevisualdatamodel::objectListModel()
{
QDeclarativeView view;
diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
index e5628d1..ddc4f73 100644
--- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
+++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
@@ -172,6 +172,12 @@ private slots:
void itemChangeEvents();
void itemSendGeometryPosChangesDeactivated();
+ void fontPropagatesResolveToChildren();
+ void fontPropagatesResolveToGrandChildren();
+ void fontPropagatesResolveInParentChange();
+ void fontPropagatesResolveViaNonWidget();
+ void fontPropagatesResolveFromScene();
+
// Task fixes
void task236127_bspTreeIndexFails();
void task243004_setStyleCrash();
@@ -622,6 +628,192 @@ void tst_QGraphicsWidget::font()
QCOMPARE(widget.font().family(), font.family());
}
+void tst_QGraphicsWidget::fontPropagatesResolveToChildren()
+{
+ QGraphicsWidget *root = new QGraphicsWidget();
+ QGraphicsWidget *child1 = new QGraphicsWidget(root);
+
+ QGraphicsScene scene;
+ scene.addItem(root);
+
+ QFont font;
+ font.setItalic(true);
+ root->setFont(font);
+
+ QGraphicsWidget *child2 = new QGraphicsWidget(root);
+ QGraphicsWidget *child3 = new QGraphicsWidget();
+ child3->setParentItem(root);
+
+ QGraphicsView view;
+ view.setScene(&scene);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ QCOMPARE(font.resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(root->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(child1->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(child2->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(child3->font().resolve(), uint(QFont::StyleResolved));
+}
+
+void tst_QGraphicsWidget::fontPropagatesResolveToGrandChildren()
+{
+ QGraphicsWidget *root = new QGraphicsWidget();
+ QGraphicsWidget *child1 = new QGraphicsWidget(root);
+ QGraphicsWidget *grandChild1 = new QGraphicsWidget(child1);
+
+ QGraphicsScene scene;
+ scene.addItem(root);
+
+ QFont font;
+ font.setItalic(true);
+ root->setFont(font);
+
+ QGraphicsWidget *child2 = new QGraphicsWidget(root);
+ QGraphicsWidget *grandChild2 = new QGraphicsWidget(child2);
+ QGraphicsWidget *grandChild3 = new QGraphicsWidget(child2);
+
+ QGraphicsWidget *child3 = new QGraphicsWidget();
+ QGraphicsWidget *grandChild4 = new QGraphicsWidget(child3);
+ QGraphicsWidget *grandChild5 = new QGraphicsWidget(child3);
+ child3->setParentItem(root);
+ grandChild5->setParentItem(child3);
+
+ QGraphicsView view;
+ view.setScene(&scene);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ QCOMPARE(font.resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild1->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild2->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild3->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild4->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild5->font().resolve(), uint(QFont::StyleResolved));
+}
+
+void tst_QGraphicsWidget::fontPropagatesResolveViaNonWidget()
+{
+ QGraphicsWidget *root = new QGraphicsWidget();
+ QGraphicsPixmapItem *child1 = new QGraphicsPixmapItem(root);
+ QGraphicsWidget *grandChild1 = new QGraphicsWidget(child1);
+
+ QGraphicsScene scene;
+ scene.addItem(root);
+
+ QFont font;
+ font.setItalic(true);
+ root->setFont(font);
+
+ QGraphicsPixmapItem *child2 = new QGraphicsPixmapItem(root);
+ QGraphicsWidget *grandChild2 = new QGraphicsWidget(child2);
+ QGraphicsWidget *grandChild3 = new QGraphicsWidget(child2);
+
+ QGraphicsPixmapItem *child3 = new QGraphicsPixmapItem();
+ QGraphicsWidget *grandChild4 = new QGraphicsWidget(child3);
+ QGraphicsWidget *grandChild5 = new QGraphicsWidget(child3);
+ child3->setParentItem(root);
+ grandChild5->setParentItem(child3);
+
+ QGraphicsView view;
+ view.setScene(&scene);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ QCOMPARE(font.resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild1->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild2->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild3->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild4->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild5->font().resolve(), uint(QFont::StyleResolved));
+}
+
+void tst_QGraphicsWidget::fontPropagatesResolveFromScene()
+{
+ QGraphicsWidget *root = new QGraphicsWidget();
+ QGraphicsWidget *child1 = new QGraphicsWidget(root);
+ QGraphicsWidget *grandChild1 = new QGraphicsWidget(child1);
+
+ QGraphicsScene scene;
+ scene.addItem(root);
+
+ QFont font;
+ font.setItalic(true);
+ scene.setFont(font);
+
+ QGraphicsWidget *child2 = new QGraphicsWidget(root);
+ QGraphicsWidget *grandChild2 = new QGraphicsWidget(child2);
+ QGraphicsWidget *grandChild3 = new QGraphicsWidget(child2);
+
+ QGraphicsWidget *child3 = new QGraphicsWidget();
+ QGraphicsWidget *grandChild4 = new QGraphicsWidget(child3);
+ QGraphicsWidget *grandChild5 = new QGraphicsWidget(child3);
+ child3->setParentItem(root);
+ grandChild5->setParentItem(child3);
+
+ QGraphicsView view;
+ view.setScene(&scene);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ QCOMPARE(font.resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(root->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(child1->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(child2->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(child3->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild1->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild2->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild3->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild4->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild5->font().resolve(), uint(QFont::StyleResolved));
+}
+
+void tst_QGraphicsWidget::fontPropagatesResolveInParentChange()
+{
+ QGraphicsWidget *root = new QGraphicsWidget();
+
+ QGraphicsWidget *child1 = new QGraphicsWidget(root);
+ QGraphicsWidget *grandChild1 = new QGraphicsWidget(child1);
+
+ QGraphicsWidget *child2 = new QGraphicsWidget(root);
+ QGraphicsWidget *grandChild2 = new QGraphicsWidget(child2);
+
+ QGraphicsScene scene;
+ scene.addItem(root);
+
+ QFont italicFont;
+ italicFont.setItalic(true);
+ child1->setFont(italicFont);
+
+ QFont boldFont;
+ boldFont.setBold(true);
+ child2->setFont(boldFont);
+
+ QVERIFY(grandChild1->font().italic());
+ QVERIFY(!grandChild1->font().bold());
+ QVERIFY(!grandChild2->font().italic());
+ QVERIFY(grandChild2->font().bold());
+
+ QCOMPARE(grandChild1->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild2->font().resolve(), uint(QFont::WeightResolved));
+
+ grandChild2->setParentItem(child1);
+
+ QGraphicsView view;
+ view.setScene(&scene);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ QVERIFY(grandChild1->font().italic());
+ QVERIFY(!grandChild1->font().bold());
+ QVERIFY(grandChild2->font().italic());
+ QVERIFY(!grandChild2->font().bold());
+
+ QCOMPARE(grandChild1->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild2->font().resolve(), uint(QFont::StyleResolved));
+
+}
+
void tst_QGraphicsWidget::fontPropagation()
{
QGraphicsWidget *root = new QGraphicsWidget;
@@ -728,11 +920,12 @@ void tst_QGraphicsWidget::fontPropagationWidgetItemWidget()
widget->setFont(font);
QCOMPARE(widget2->font().pointSize(), 43);
- QCOMPARE(widget2->font().resolve(), QFont().resolve());
+ QCOMPARE(widget2->font().resolve(), uint(QFont::SizeResolved));
widget->setFont(QFont());
QCOMPARE(widget2->font().pointSize(), qApp->font().pointSize());
+ QCOMPARE(widget2->font().resolve(), QFont().resolve());
}
void tst_QGraphicsWidget::fontPropagationSceneChange()
diff --git a/tests/auto/qpen/tst_qpen.cpp b/tests/auto/qpen/tst_qpen.cpp
index 149f462..b0c2cad 100644
--- a/tests/auto/qpen/tst_qpen.cpp
+++ b/tests/auto/qpen/tst_qpen.cpp
@@ -213,6 +213,5 @@ void tst_QPen::stream()
QCOMPARE(pen, cmp);
}
-
QTEST_APPLESS_MAIN(tst_QPen)
#include "tst_qpen.moc"