summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-10-05 02:42:48 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-10-05 02:42:48 (GMT)
commit4bc735e48020c23aaa99c006ed014214a82c1a68 (patch)
tree83f4d5cc5407f1e5eb9d8afd4fc88259b9a82822 /tests
parenta7bf1cfb1a75c35e837c01f4a5b0697fc8961148 (diff)
parent5c30b5babfd1ed408a0c44dcaad2f1444acc4892 (diff)
downloadQt-4bc735e48020c23aaa99c006ed014214a82c1a68.zip
Qt-4bc735e48020c23aaa99c006ed014214a82c1a68.tar.gz
Qt-4bc735e48020c23aaa99c006ed014214a82c1a68.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: Add missing license header. Improve test coverage for declarative module. Avoid potential null dereference. Add autotest for reserved words in QML. Prevent crash in XmlListModel when appending an empty role. Remove unused, unexported class. Fix clipping behavior for non-cached text. Compile Only cache textlayout in paint engines that support transformations QmlDebugService: Fix compiler warning about cast from ascii Qt.openUrlExternally should resolve relative URLs. Doc: add missing image. Doc: typographical and spelling errors. Doc: remove unfinished and confusing mention to focus panels. Apply the QStaticText text-caching strategy for QML Documentation: input to Qt.rgba should be from 0-1, not 0-255.
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativeitem/data/keystest.qml3
-rw-r--r--tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp5
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp76
-rw-r--r--tests/auto/declarative/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp5
-rw-r--r--tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp1
-rw-r--r--tests/auto/declarative/qdeclarativepathview/data/closedPath.qml24
-rw-r--r--tests/auto/declarative/qdeclarativepathview/data/openPath.qml10
-rw-r--r--tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp21
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp8
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/openUrlExternally.qml3
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/openUrlExternally_lib.js9
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/openUrlExternally_lib.qml9
-rw-r--r--tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp30
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/data/roleCrash.qml7
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp11
15 files changed, 220 insertions, 2 deletions
diff --git a/tests/auto/declarative/qdeclarativeitem/data/keystest.qml b/tests/auto/declarative/qdeclarativeitem/data/keystest.qml
index aedccd9..3927f42 100644
--- a/tests/auto/declarative/qdeclarativeitem/data/keystest.qml
+++ b/tests/auto/declarative/qdeclarativeitem/data/keystest.qml
@@ -2,6 +2,9 @@ import QtQuick 1.0
Item {
focus: true
+
+ property bool isEnabled: Keys.enabled
+
Keys.onPressed: keysTestObject.keyPress(event.key, event.text, event.modifiers)
Keys.onReleased: { keysTestObject.keyRelease(event.key, event.text, event.modifiers); event.accepted = true; }
Keys.onReturnPressed: keysTestObject.keyPress(event.key, "Return", event.modifiers)
diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
index e9dad6b..bbbf73e 100644
--- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
+++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
@@ -214,6 +214,9 @@ void tst_QDeclarativeItem::keys()
QFocusEvent fe(QEvent::FocusIn);
QApplication::sendEvent(canvas, &fe);
+ QVERIFY(canvas->rootObject());
+ QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), true);
+
QKeyEvent key(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1);
QApplication::sendEvent(canvas, &key);
QCOMPARE(testObject->mKey, int(Qt::Key_A));
@@ -285,6 +288,7 @@ void tst_QDeclarativeItem::keys()
testObject->reset();
canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(false));
+ QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), false);
key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1);
QApplication::sendEvent(canvas, &key);
@@ -292,6 +296,7 @@ void tst_QDeclarativeItem::keys()
QVERIFY(!key.isAccepted());
canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(true));
+ QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), true);
key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1);
QApplication::sendEvent(canvas, &key);
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
index 7f81fc0..8609a7e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -128,6 +128,8 @@ private slots:
void defaultPropertyListOrder();
void declaredPropertyValues();
void dontDoubleCallClassBegin();
+ void reservedWords_data();
+ void reservedWords();
void basicRemote_data();
void basicRemote();
@@ -1222,6 +1224,80 @@ void tst_qdeclarativelanguage::dontDoubleCallClassBegin()
delete o;
}
+void tst_qdeclarativelanguage::reservedWords_data()
+{
+ QTest::addColumn<QByteArray>("word");
+
+ QTest::newRow("abstract") << QByteArray("abstract");
+ QTest::newRow("as") << QByteArray("as");
+ QTest::newRow("boolean") << QByteArray("boolean");
+ QTest::newRow("break") << QByteArray("break");
+ QTest::newRow("byte") << QByteArray("byte");
+ QTest::newRow("case") << QByteArray("case");
+ QTest::newRow("catch") << QByteArray("catch");
+ QTest::newRow("char") << QByteArray("char");
+ QTest::newRow("class") << QByteArray("class");
+ QTest::newRow("continue") << QByteArray("continue");
+ QTest::newRow("const") << QByteArray("const");
+ QTest::newRow("debugger") << QByteArray("debugger");
+ QTest::newRow("default") << QByteArray("default");
+ QTest::newRow("delete") << QByteArray("delete");
+ QTest::newRow("do") << QByteArray("do");
+ QTest::newRow("double") << QByteArray("double");
+ QTest::newRow("else") << QByteArray("else");
+ QTest::newRow("enum") << QByteArray("enum");
+ QTest::newRow("export") << QByteArray("export");
+ QTest::newRow("extends") << QByteArray("extends");
+ QTest::newRow("false") << QByteArray("false");
+ QTest::newRow("final") << QByteArray("final");
+ QTest::newRow("finally") << QByteArray("finally");
+ QTest::newRow("float") << QByteArray("float");
+ QTest::newRow("for") << QByteArray("for");
+ QTest::newRow("function") << QByteArray("function");
+ QTest::newRow("goto") << QByteArray("goto");
+ QTest::newRow("if") << QByteArray("if");
+ QTest::newRow("implements") << QByteArray("implements");
+ QTest::newRow("import") << QByteArray("import");
+ QTest::newRow("in") << QByteArray("in");
+ QTest::newRow("instanceof") << QByteArray("instanceof");
+ QTest::newRow("int") << QByteArray("int");
+ QTest::newRow("interface") << QByteArray("interface");
+ QTest::newRow("long") << QByteArray("long");
+ QTest::newRow("native") << QByteArray("native");
+ QTest::newRow("new") << QByteArray("new");
+ QTest::newRow("null") << QByteArray("null");
+ QTest::newRow("package") << QByteArray("package");
+ QTest::newRow("private") << QByteArray("private");
+ QTest::newRow("protected") << QByteArray("protected");
+ QTest::newRow("public") << QByteArray("public");
+ QTest::newRow("return") << QByteArray("return");
+ QTest::newRow("short") << QByteArray("short");
+ QTest::newRow("static") << QByteArray("static");
+ QTest::newRow("super") << QByteArray("super");
+ QTest::newRow("switch") << QByteArray("switch");
+ QTest::newRow("synchronized") << QByteArray("synchronized");
+ QTest::newRow("this") << QByteArray("this");
+ QTest::newRow("throw") << QByteArray("throw");
+ QTest::newRow("throws") << QByteArray("throws");
+ QTest::newRow("transient") << QByteArray("transient");
+ QTest::newRow("true") << QByteArray("true");
+ QTest::newRow("try") << QByteArray("try");
+ QTest::newRow("typeof") << QByteArray("typeof");
+ QTest::newRow("var") << QByteArray("var");
+ QTest::newRow("void") << QByteArray("void");
+ QTest::newRow("volatile") << QByteArray("volatile");
+ QTest::newRow("while") << QByteArray("while");
+ QTest::newRow("with") << QByteArray("with");
+}
+
+void tst_qdeclarativelanguage::reservedWords()
+{
+ QFETCH(QByteArray, word);
+ QDeclarativeComponent component(&engine);
+ component.setData("import QtQuick 1.0\nQtObject { property string " + word + " }", QUrl());
+ QCOMPARE(component.errorString(), QLatin1String(":2 Expected token `identifier'\n"));
+}
+
// Check that first child of qml is of given type. Empty type insists on error.
void tst_qdeclarativelanguage::testType(const QString& qml, const QString& type, const QString& expectederror)
{
diff --git a/tests/auto/declarative/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp b/tests/auto/declarative/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp
index bbdba74..cc0f633 100644
--- a/tests/auto/declarative/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp
+++ b/tests/auto/declarative/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp
@@ -82,6 +82,11 @@ void tst_qdeclarativelayoutitem::test_resizing()
QDeclarativeEngine engine;
QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/layoutItem.qml"));
QDeclarativeLayoutItem* obj = static_cast<QDeclarativeLayoutItem*>(c.create());
+ QVERIFY(obj);
+ QCOMPARE(obj->minimumSize(), QSizeF(100,100));
+ QCOMPARE(obj->preferredSize(), QSizeF(200,200));
+ QCOMPARE(obj->maximumSize(), QSizeF(300,300));
+
layout->addItem(obj);
layout->setContentsMargins(0,0,0,0);
widget->setContentsMargins(0,0,0,0);
diff --git a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp
index e4ec01f..5e88450 100644
--- a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp
+++ b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp
@@ -356,6 +356,7 @@ void tst_QDeclarativeMouseArea::onMousePressRejected()
canvas->show();
canvas->setFocus();
QVERIFY(canvas->rootObject() != 0);
+ QVERIFY(canvas->rootObject()->property("enabled").toBool());
QVERIFY(!canvas->rootObject()->property("mr1_pressed").toBool());
QVERIFY(!canvas->rootObject()->property("mr1_released").toBool());
diff --git a/tests/auto/declarative/qdeclarativepathview/data/closedPath.qml b/tests/auto/declarative/qdeclarativepathview/data/closedPath.qml
new file mode 100644
index 0000000..08b0d2a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepathview/data/closedPath.qml
@@ -0,0 +1,24 @@
+import QtQuick 1.0
+
+Path {
+ startY: 120
+ startX: 160
+ PathQuad {
+ y: 120
+ x: 80
+ controlY: 330
+ controlX: 100
+ }
+ PathLine {
+ y: 160
+ x: 20
+ }
+ PathCubic {
+ y: 120
+ x: 160
+ control1Y: 0
+ control1X: 100
+ control2Y: 000
+ control2X: 200
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativepathview/data/openPath.qml b/tests/auto/declarative/qdeclarativepathview/data/openPath.qml
new file mode 100644
index 0000000..328e3cd
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepathview/data/openPath.qml
@@ -0,0 +1,10 @@
+import QtQuick 1.0
+
+Path {
+ startY: 120
+ startX: 160
+ PathLine {
+ y: 160
+ x: 20
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
index 3b5d438..65007a6 100644
--- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
+++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
@@ -85,6 +85,7 @@ private slots:
void pathUpdateOnStartChanged();
void package();
void emptyModel();
+ void closed();
private:
QDeclarativeView *createView();
@@ -786,6 +787,26 @@ void tst_QDeclarativePathView::emptyModel()
delete canvas;
}
+void tst_QDeclarativePathView::closed()
+{
+ QDeclarativeEngine engine;
+
+ {
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/openPath.qml"));
+ QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create());
+ QVERIFY(obj);
+ QCOMPARE(obj->isClosed(), false);
+ delete obj;
+ }
+
+ {
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/closedPath.qml"));
+ QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create());
+ QVERIFY(obj);
+ QCOMPARE(obj->isClosed(), true);
+ delete obj;
+ }
+}
QDeclarativeView *tst_QDeclarativePathView::createView()
{
diff --git a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp
index 57a8354..254349f 100644
--- a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp
+++ b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp
@@ -322,7 +322,8 @@ void tst_QDeclarativePositioners::test_grid()
QCOMPARE(five->x(), 50.0);
QCOMPARE(five->y(), 50.0);
- QDeclarativeItem *grid = canvas->rootObject()->findChild<QDeclarativeItem*>("grid");
+ QDeclarativeGrid *grid = canvas->rootObject()->findChild<QDeclarativeGrid*>("grid");
+ QCOMPARE(grid->flow(), QDeclarativeGrid::LeftToRight);
QCOMPARE(grid->width(), 120.0);
QCOMPARE(grid->height(), 100.0);
@@ -355,7 +356,8 @@ void tst_QDeclarativePositioners::test_grid_topToBottom()
QCOMPARE(five->x(), 50.0);
QCOMPARE(five->y(), 50.0);
- QDeclarativeItem *grid = canvas->rootObject()->findChild<QDeclarativeItem*>("grid");
+ QDeclarativeGrid *grid = canvas->rootObject()->findChild<QDeclarativeGrid*>("grid");
+ QCOMPARE(grid->flow(), QDeclarativeGrid::TopToBottom);
QCOMPARE(grid->width(), 100.0);
QCOMPARE(grid->height(), 120.0);
@@ -670,10 +672,12 @@ void tst_QDeclarativePositioners::test_flow_implicit_resize()
QCOMPARE(flow->height(), 120.0);
canvas->rootObject()->setProperty("leftToRight", true);
+ QCOMPARE(flow->flow(), QDeclarativeFlow::LeftToRight);
QCOMPARE(flow->width(), 220.0);
QCOMPARE(flow->height(), 50.0);
canvas->rootObject()->setProperty("leftToRight", false);
+ QCOMPARE(flow->flow(), QDeclarativeFlow::TopToBottom);
QCOMPARE(flow->width(), 100.0);
QCOMPARE(flow->height(), 120.0);
diff --git a/tests/auto/declarative/qdeclarativeqt/data/openUrlExternally.qml b/tests/auto/declarative/qdeclarativeqt/data/openUrlExternally.qml
index c9fb25e..dc4049c 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/openUrlExternally.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/openUrlExternally.qml
@@ -2,4 +2,7 @@ import QtQuick 1.0
QtObject {
Component.onCompleted: Qt.openUrlExternally("test:url")
+
+ property bool testFile
+ onTestFileChanged: Qt.openUrlExternally("test.html")
}
diff --git a/tests/auto/declarative/qdeclarativeqt/data/openUrlExternally_lib.js b/tests/auto/declarative/qdeclarativeqt/data/openUrlExternally_lib.js
new file mode 100644
index 0000000..702357a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeqt/data/openUrlExternally_lib.js
@@ -0,0 +1,9 @@
+.pragma library
+
+function loadTest() {
+ Qt.openUrlExternally("test:url")
+}
+
+function loadFile() {
+ Qt.openUrlExternally("test.html")
+}
diff --git a/tests/auto/declarative/qdeclarativeqt/data/openUrlExternally_lib.qml b/tests/auto/declarative/qdeclarativeqt/data/openUrlExternally_lib.qml
new file mode 100644
index 0000000..456653b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeqt/data/openUrlExternally_lib.qml
@@ -0,0 +1,9 @@
+import QtQuick 1.0
+import "openUrlExternally_lib.js" as Test
+
+Item {
+ Component.onCompleted: Test.loadTest();
+
+ property bool testFile
+ onTestFileChanged: Test.loadFile();
+}
diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
index 739b10a..9f45d74 100644
--- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
+++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
@@ -75,6 +75,7 @@ private slots:
void darker();
void tint();
void openUrlExternally();
+ void openUrlExternally_pragmaLibrary();
void md5();
void createComponent();
void createComponent_pragmaLibrary();
@@ -321,6 +322,7 @@ void tst_qdeclarativeqt::openUrlExternally()
MyUrlHandler handler;
QDesktopServices::setUrlHandler("test", &handler, "noteCall");
+ QDesktopServices::setUrlHandler("file", &handler, "noteCall");
QDeclarativeComponent component(&engine, TEST_FILE("openUrlExternally.qml"));
QObject *object = component.create();
@@ -328,7 +330,35 @@ void tst_qdeclarativeqt::openUrlExternally()
QCOMPARE(handler.called,1);
QCOMPARE(handler.last, QUrl("test:url"));
+ object->setProperty("testFile", true);
+
+ QCOMPARE(handler.called,2);
+ QCOMPARE(handler.last, TEST_FILE("test.html"));
+
+ QDesktopServices::unsetUrlHandler("test");
+ QDesktopServices::unsetUrlHandler("file");
+}
+
+void tst_qdeclarativeqt::openUrlExternally_pragmaLibrary()
+{
+ MyUrlHandler handler;
+
+ QDesktopServices::setUrlHandler("test", &handler, "noteCall");
+ QDesktopServices::setUrlHandler("file", &handler, "noteCall");
+
+ QDeclarativeComponent component(&engine, TEST_FILE("openUrlExternally_lib.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(handler.called,1);
+ QCOMPARE(handler.last, QUrl("test:url"));
+
+ object->setProperty("testFile", true);
+
+ QCOMPARE(handler.called,2);
+ QCOMPARE(handler.last, TEST_FILE("test.html"));
+
QDesktopServices::unsetUrlHandler("test");
+ QDesktopServices::unsetUrlHandler("file");
}
void tst_qdeclarativeqt::md5()
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/data/roleCrash.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/roleCrash.qml
new file mode 100644
index 0000000..492dad9
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/roleCrash.qml
@@ -0,0 +1,7 @@
+import QtQuick 1.0
+
+XmlListModel {
+ id: model
+ XmlRole {}
+ Component.onCompleted: model.roles = 0
+}
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
index bd19bd3..a14f942 100644
--- a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
@@ -96,6 +96,8 @@ private slots:
void threading_data();
void propertyChanges();
+ void roleCrash();
+
private:
QString makeItemXmlAndData(const QString &data, QDeclarativeXmlModelData *modelData = 0) const
{
@@ -825,6 +827,15 @@ void tst_qdeclarativexmllistmodel::propertyChanges()
delete model;
}
+void tst_qdeclarativexmllistmodel::roleCrash()
+{
+ // don't crash
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleCrash.qml"));
+ QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QVERIFY(model != 0);
+ delete model;
+}
+
QTEST_MAIN(tst_qdeclarativexmllistmodel)
#include "tst_qdeclarativexmllistmodel.moc"