diff options
Diffstat (limited to 'tests/auto/declarative')
17 files changed, 247 insertions, 17 deletions
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/compiled.qml b/tests/auto/declarative/qdeclarativeecmascript/data/compiled.qml index a883e85..1655905 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/compiled.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/compiled.qml @@ -31,6 +31,8 @@ QtObject { property string test21: g property string test22: h property bool test23: i + property color test24: j + property color test25: k property real a: 4.5 property real b: 11.2 @@ -41,4 +43,6 @@ QtObject { property variant g: 6.7 property variant h: "!" property variant i: true + property string j: "#112233" + property string k: "#aa112233" } diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 9a88237..9a8ad64 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -2090,6 +2090,8 @@ void tst_qdeclarativeecmascript::compiled() QCOMPARE(object->property("test21").toString(), QLatin1String("6.7")); QCOMPARE(object->property("test22").toString(), QLatin1String("!")); QCOMPARE(object->property("test23").toBool(), true); + QCOMPARE(qvariant_cast<QColor>(object->property("test24")), QColor(0x11,0x22,0x33)); + QCOMPARE(qvariant_cast<QColor>(object->property("test25")), QColor(0x11,0x22,0x33,0xAA)); delete object; } @@ -2102,20 +2104,21 @@ void tst_qdeclarativeecmascript::numberAssignment() QObject *object = component.create(); QVERIFY(object != 0); - QVERIFY(object->property("test1") == QVariant((qreal)6.7)); - QVERIFY(object->property("test2") == QVariant((qreal)6.7)); - QVERIFY(object->property("test3") == QVariant((qreal)6)); - QVERIFY(object->property("test4") == QVariant((qreal)6)); + QCOMPARE(object->property("test1"), QVariant((qreal)6.7)); + QCOMPARE(object->property("test2"), QVariant((qreal)6.7)); + QCOMPARE(object->property("test2"), QVariant((qreal)6.7)); + QCOMPARE(object->property("test3"), QVariant((qreal)6)); + QCOMPARE(object->property("test4"), QVariant((qreal)6)); - QVERIFY(object->property("test5") == QVariant((int)7)); - QVERIFY(object->property("test6") == QVariant((int)7)); - QVERIFY(object->property("test7") == QVariant((int)6)); - QVERIFY(object->property("test8") == QVariant((int)6)); + QCOMPARE(object->property("test5"), QVariant((int)7)); + QCOMPARE(object->property("test6"), QVariant((int)7)); + QCOMPARE(object->property("test7"), QVariant((int)6)); + QCOMPARE(object->property("test8"), QVariant((int)6)); - QVERIFY(object->property("test9") == QVariant((unsigned int)7)); - QVERIFY(object->property("test10") == QVariant((unsigned int)7)); - QVERIFY(object->property("test11") == QVariant((unsigned int)6)); - QVERIFY(object->property("test12") == QVariant((unsigned int)6)); + QCOMPARE(object->property("test9"), QVariant((unsigned int)7)); + QCOMPARE(object->property("test10"), QVariant((unsigned int)7)); + QCOMPARE(object->property("test11"), QVariant((unsigned int)6)); + QCOMPARE(object->property("test12"), QVariant((unsigned int)6)); delete object; } @@ -2427,7 +2430,6 @@ void tst_qdeclarativeecmascript::include() // Including file with ".pragma library" { QDeclarativeComponent component(&engine, TEST_FILE("include_pragma.qml")); - qDebug() << "errors:" << component.errorsString(); QObject *o = component.create(); QVERIFY(o != 0); QCOMPARE(o->property("test1").toInt(), 100); diff --git a/tests/auto/declarative/qdeclarativegridview/data/manual-highlight.qml b/tests/auto/declarative/qdeclarativegridview/data/manual-highlight.qml new file mode 100644 index 0000000..510fcc5 --- /dev/null +++ b/tests/auto/declarative/qdeclarativegridview/data/manual-highlight.qml @@ -0,0 +1,48 @@ +import Qt 4.7 + +Item { + + ListModel { + id: model + ListElement { + name: "Bill Smith" + number: "555 3264" + } + ListElement { + name: "John Brown" + number: "555 8426" + } + ListElement { + name: "Sam Wise" + number: "555 0473" + } + ListElement { + name: "Bob Brown" + number: "555 5845" + } + } + + Component { + id: highlight + Rectangle { + objectName: "highlight" + width: 80; height: 80 + color: "lightsteelblue"; radius: 5 + y: grid.currentItem.y + x: grid.currentItem.x + } + } + + GridView { + id: grid + objectName: "grid" + anchors.fill: parent + model: model + delegate: Text { objectName: "wrapper"; text: name; width: 80; height: 80 } + + highlight: highlight + highlightFollowsCurrentItem: false + focus: true + } + +} diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp index 89be151..2db3ee6 100644 --- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp +++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp @@ -75,6 +75,7 @@ private slots: void resetModel(); void enforceRange(); void QTBUG_8456(); + void manualHighlight(); private: QDeclarativeView *createView(); @@ -1107,6 +1108,35 @@ void tst_QDeclarativeGridView::QTBUG_8456() QTRY_COMPARE(gridview->currentIndex(), 0); } +void tst_QDeclarativeGridView::manualHighlight() +{ + QDeclarativeView *canvas = createView(); + + QString filename(SRCDIR "/data/manual-highlight.qml"); + canvas->setSource(QUrl::fromLocalFile(filename)); + + qApp->processEvents(); + + QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + + QDeclarativeItem *viewport = gridview->viewport(); + QTRY_VERIFY(viewport != 0); + + QTRY_COMPARE(gridview->currentIndex(), 0); + QTRY_COMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 0)); + QTRY_COMPARE(gridview->highlightItem()->y(), gridview->currentItem()->y()); + QTRY_COMPARE(gridview->highlightItem()->x(), gridview->currentItem()->x()); + + gridview->setCurrentIndex(2); + + QTRY_COMPARE(gridview->currentIndex(), 2); + QTRY_COMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 2)); + QTRY_COMPARE(gridview->highlightItem()->y(), gridview->currentItem()->y()); + QTRY_COMPARE(gridview->highlightItem()->x(), gridview->currentItem()->x()); +} + + QDeclarativeView *tst_QDeclarativeGridView::createView() { QDeclarativeView *canvas = new QDeclarativeView(0); diff --git a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp index 9ae26f2..1e88255 100644 --- a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp +++ b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp @@ -534,7 +534,6 @@ void tst_qdeclarativeinstruction::dump() << "-------------------------------------------------------------------------------" << "0\t\t0\tINIT\t\t\t0\t3\t-1\t-1" << "1\t\t1\tCREATE\t\t\t0\t\t\t\"Test\"" - << "1\t\t1\tCREATE_SIMPLE\t\t-1" << "2\t\t2\tSETID\t\t\t0\t\t\t\"testId\"" << "3\t\t3\tSET_DEFAULT" << "4\t\t4\tCREATE_COMPONENT\t3" diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.2.qml new file mode 100644 index 0000000..df3de20 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.2.qml @@ -0,0 +1,11 @@ +import Qt 4.7 +import Qt 4.7 as Qt47 + +Qt.QtObject { + property Qt47.QtObject objectProperty + property list<Qt47.QtObject> objectPropertyList + + objectProperty: QtObject {} + objectPropertyList: QtObject {} +} + diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 200f016..011870c 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -683,6 +683,7 @@ void tst_qdeclarativelanguage::listProperties() // ### Not complete void tst_qdeclarativelanguage::dynamicObjectProperties() { + { QDeclarativeComponent component(&engine, TEST_FILE("dynamicObjectProperties.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); @@ -690,6 +691,16 @@ void tst_qdeclarativelanguage::dynamicObjectProperties() QVERIFY(object->property("objectProperty") == qVariantFromValue((QObject*)0)); QVERIFY(object->property("objectProperty2") != qVariantFromValue((QObject*)0)); + } + { + QDeclarativeComponent component(&engine, TEST_FILE("dynamicObjectProperties.2.qml")); + QEXPECT_FAIL("", "QTBUG-10822", Abort); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + QVERIFY(object->property("objectProperty") != qVariantFromValue((QObject*)0)); + } } // Tests the declaration of dynamic signals and slots diff --git a/tests/auto/declarative/qdeclarativelistview/data/manual-highlight.qml b/tests/auto/declarative/qdeclarativelistview/data/manual-highlight.qml new file mode 100644 index 0000000..4913ebe --- /dev/null +++ b/tests/auto/declarative/qdeclarativelistview/data/manual-highlight.qml @@ -0,0 +1,47 @@ +import Qt 4.7 + +Item { + + ListModel { + id: model + ListElement { + name: "Bill Smith" + number: "555 3264" + } + ListElement { + name: "John Brown" + number: "555 8426" + } + ListElement { + name: "Sam Wise" + number: "555 0473" + } + ListElement { + name: "Bob Brown" + number: "555 5845" + } + } + + Component { + id: highlight + Rectangle { + objectName: "highlight" + width: 180; height: 20 + color: "lightsteelblue"; radius: 5 + y: list.currentItem.y + } + } + + ListView { + id: list + objectName: "list" + anchors.fill: parent + model: model + delegate: Text { objectName: "wrapper"; text: name } + + highlight: highlight + highlightFollowsCurrentItem: false + focus: true + } + +} diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index fde2e43..203760e 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -90,6 +90,7 @@ private slots: void componentChanges(); void modelChanges(); void QTBUG_9791(); + void manualHighlight(); private: template <class T> void items(); @@ -1463,6 +1464,34 @@ void tst_QDeclarativeListView::QTBUG_9791() delete canvas; } +void tst_QDeclarativeListView::manualHighlight() +{ + QDeclarativeView *canvas = new QDeclarativeView(0); + canvas->setFixedSize(240,320); + + QDeclarativeContext *ctxt = canvas->rootContext(); + + QString filename(SRCDIR "/data/manual-highlight.qml"); + canvas->setSource(QUrl::fromLocalFile(filename)); + + qApp->processEvents(); + + QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + + QDeclarativeItem *viewport = listview->viewport(); + QTRY_VERIFY(viewport != 0); + + QTRY_COMPARE(listview->currentIndex(), 0); + QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 0)); + QTRY_COMPARE(listview->highlightItem()->y(), listview->currentItem()->y()); + + listview->setCurrentIndex(2); + + QTRY_COMPARE(listview->currentIndex(), 2); + QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 2)); + QTRY_COMPARE(listview->highlightItem()->y(), listview->currentItem()->y()); +} void tst_QDeclarativeListView::qListModelInterface_items() { diff --git a/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_default.qml b/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_default.qml new file mode 100644 index 0000000..f1cf86c --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_default.qml @@ -0,0 +1,7 @@ +import Qt 4.7 + +TextEdit { + focus: true + text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" + selectByMouse: false +} diff --git a/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_false.qml b/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_false.qml new file mode 100644 index 0000000..f1cf86c --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_false.qml @@ -0,0 +1,7 @@ +import Qt 4.7 + +TextEdit { + focus: true + text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" + selectByMouse: false +} diff --git a/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_true.qml b/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_true.qml new file mode 100644 index 0000000..90383b9 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_true.qml @@ -0,0 +1,7 @@ +import Qt 4.7 + +TextEdit { + focus: true + text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" + selectByMouse: true +} diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.5.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.5.qml new file mode 100644 index 0000000..a66e9d6 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.5.qml @@ -0,0 +1,10 @@ +import Test 1.0 +import Qt 4.7 as MyQt + +MyTypeObject { + MyQt.Component.onCompleted: { + font.capitalization = MyQt.Font.AllUppercase + } +} + + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h index 1da9990..7ed3993 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h +++ b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h @@ -99,7 +99,7 @@ public: m_font.setOverline(true); m_font.setStrikeOut(true); m_font.setPointSize(29); - m_font.setCapitalization(QFont::AllUppercase); + m_font.setCapitalization(QFont::AllLowercase); m_font.setLetterSpacing(QFont::AbsoluteSpacing, 10.2); m_font.setWordSpacing(19.7); } diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp index 95b9baa..53fd68c 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp +++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp @@ -838,6 +838,14 @@ void tst_qdeclarativevaluetypes::enums() QVERIFY(object->font().capitalization() == QFont::AllUppercase); delete object; } + + { + QDeclarativeComponent component(&engine, TEST_FILE("enums.5.qml")); + MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); + QVERIFY(object != 0); + QVERIFY(object->font().capitalization() == QFont::AllUppercase); + delete object; + } } // Tests switching between "conflicting" bindings (eg. a binding on the core diff --git a/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp b/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp index dd2f46e..b183105 100644 --- a/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp +++ b/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp @@ -45,6 +45,7 @@ #include <QtDeclarative/qdeclarativeview.h> #include <QtDeclarative/qdeclarativeitem.h> #include <QtGui/qgraphicswidget.h> +#include "../../../shared/util.h" class tst_QDeclarativeView : public QObject @@ -106,9 +107,9 @@ void tst_QDeclarativeView::resizemodedeclarativeitem() // size update from root object declarativeItem->setWidth(250); declarativeItem->setHeight(350); - qApp->processEvents(); QCOMPARE(declarativeItem->width(), 250.0); QCOMPARE(declarativeItem->height(), 350.0); + QTRY_COMPARE(canvas->size(), QSize(250, 350)); QCOMPARE(canvas->size(), QSize(250, 350)); QCOMPARE(canvas->size(), canvas->sizeHint()); QCOMPARE(sceneResizedSpy.count(), 4); @@ -134,9 +135,9 @@ void tst_QDeclarativeView::resizemodedeclarativeitem() // size update from root object declarativeItem->setWidth(80); declarativeItem->setHeight(100); - qApp->processEvents(); QCOMPARE(declarativeItem->width(), 80.0); QCOMPARE(declarativeItem->height(), 100.0); + QTRY_COMPARE(canvas->size(), QSize(80, 100)); QCOMPARE(canvas->size(), QSize(80, 100)); QCOMPARE(canvas->size(), canvas->sizeHint()); QCOMPARE(sceneResizedSpy2.count(), 2); diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp index 4173a44..7769979 100644 --- a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp +++ b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp @@ -268,10 +268,12 @@ void tst_qdeclarativexmllistmodel::xml() QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create()); QSignalSpy spy(model, SIGNAL(statusChanged(QDeclarativeXmlListModel::Status))); + QVERIFY(model->errorString().isEmpty()); QCOMPARE(model->progress(), qreal(0.0)); QCOMPARE(model->status(), QDeclarativeXmlListModel::Loading); QTRY_COMPARE(spy.count(), 1); spy.clear(); QCOMPARE(model->status(), QDeclarativeXmlListModel::Ready); + QVERIFY(model->errorString().isEmpty()); QCOMPARE(model->progress(), qreal(1.0)); QCOMPARE(model->count(), 9); @@ -284,6 +286,7 @@ void tst_qdeclarativexmllistmodel::xml() QCOMPARE(model->status(), QDeclarativeXmlListModel::Loading); QTRY_COMPARE(spy.count(), 1); spy.clear(); QCOMPARE(model->status(), QDeclarativeXmlListModel::Ready); + QVERIFY(model->errorString().isEmpty()); QCOMPARE(model->count(), count); delete model; @@ -309,10 +312,12 @@ void tst_qdeclarativexmllistmodel::source() QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create()); QSignalSpy spy(model, SIGNAL(statusChanged(QDeclarativeXmlListModel::Status))); + QVERIFY(model->errorString().isEmpty()); QCOMPARE(model->progress(), qreal(0.0)); QCOMPARE(model->status(), QDeclarativeXmlListModel::Loading); QTRY_COMPARE(spy.count(), 1); spy.clear(); QCOMPARE(model->status(), QDeclarativeXmlListModel::Ready); + QVERIFY(model->errorString().isEmpty()); QCOMPARE(model->progress(), qreal(1.0)); QCOMPARE(model->count(), 9); @@ -320,6 +325,7 @@ void tst_qdeclarativexmllistmodel::source() QCOMPARE(model->progress(), qreal(0.0)); QTRY_COMPARE(spy.count(), 1); spy.clear(); QCOMPARE(model->status(), QDeclarativeXmlListModel::Loading); + QVERIFY(model->errorString().isEmpty()); QEventLoop loop; QTimer timer; @@ -337,9 +343,12 @@ void tst_qdeclarativexmllistmodel::source() QCOMPARE(model->status(), status); QCOMPARE(model->count(), count); + if (status == QDeclarativeXmlListModel::Ready) QCOMPARE(model->progress(), qreal(1.0)); + QCOMPARE(model->errorString().isEmpty(), status == QDeclarativeXmlListModel::Ready); + delete model; } |