summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r--tests/auto/declarative/qdeclarativeborderimage/data/colors-round-remote.sci7
-rw-r--r--tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp1
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp13
-rw-r--r--tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp94
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp12
5 files changed, 73 insertions, 54 deletions
diff --git a/tests/auto/declarative/qdeclarativeborderimage/data/colors-round-remote.sci b/tests/auto/declarative/qdeclarativeborderimage/data/colors-round-remote.sci
new file mode 100644
index 0000000..c673bed
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeborderimage/data/colors-round-remote.sci
@@ -0,0 +1,7 @@
+border.left:10
+border.top:20
+border.right:30
+border.bottom:40
+horizontalTileRule:Round
+verticalTileRule:Repeat
+source:http://127.0.0.1:14446/colors.png
diff --git a/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp b/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp
index e6543e6..bc2f170 100644
--- a/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp
+++ b/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp
@@ -294,6 +294,7 @@ void tst_qdeclarativeborderimage::sciSource_data()
QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors-round.sci").toString() << true;
QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.sci").toString() << false;
QTest::newRow("remote") << SERVER_ADDR "/colors-round.sci" << true;
+ QTest::newRow("remote image") << SERVER_ADDR "/colors-round-remote.sci" << true;
QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.sci" << false;
}
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index b343010..9b6f04c 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -1329,6 +1329,19 @@ void tst_QDeclarativeListView::positionViewAtIndex()
QTRY_COMPARE(item->y(), i*20.);
}
+ // Position at End using last index
+ listview->positionViewAtIndex(model.count()-1, QDeclarativeListView::End);
+ QTRY_COMPARE(listview->contentY(), 480.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
+ for (int i = 24; i < model.count(); ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.);
+ }
+
// Position at End
listview->positionViewAtIndex(20, QDeclarativeListView::End);
QTRY_COMPARE(listview->contentY(), 100.);
diff --git a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp
index 358822e..bfa81ed 100644
--- a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp
+++ b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp
@@ -69,8 +69,9 @@ public:
tst_QDeclarativeLoader();
private slots:
- void sourceOrComponent();
- void sourceOrComponent_data();
+ void url();
+ void invalidUrl();
+ void component();
void clear();
void urlToComponent();
void componentToUrl();
@@ -99,71 +100,56 @@ tst_QDeclarativeLoader::tst_QDeclarativeLoader()
{
}
-void tst_QDeclarativeLoader::sourceOrComponent()
+void tst_QDeclarativeLoader::url()
{
- QFETCH(QString, sourceDefinition);
- QFETCH(QUrl, sourceUrl);
- QFETCH(QString, errorString);
-
- bool error = !errorString.isEmpty();
- if (error)
- QTest::ignoreMessage(QtWarningMsg, errorString.toUtf8().constData());
-
QDeclarativeComponent component(&engine);
- component.setData(QByteArray(
- "import QtQuick 1.0\n"
- "Loader {\n"
- " property int onItemChangedCount: 0\n"
- " property int onSourceChangedCount: 0\n"
- " property int onStatusChangedCount: 0\n"
- " property int onProgressChangedCount: 0\n"
- " property int onLoadedCount: 0\n")
- + sourceDefinition.toUtf8()
- + QByteArray(
- " onItemChanged: onItemChangedCount += 1\n"
- " onSourceChanged: onSourceChangedCount += 1\n"
- " onStatusChanged: onStatusChangedCount += 1\n"
- " onProgressChanged: onProgressChangedCount += 1\n"
- " onLoaded: onLoadedCount += 1\n"
- "}")
- , TEST_FILE(""));
-
+ component.setData(QByteArray("import QtQuick 1.0\nLoader { property int did_load: 0; onLoaded: did_load=123; source: \"Rect120x60.qml\" }"), TEST_FILE(""));
QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
QVERIFY(loader != 0);
- QCOMPARE(loader->item() == 0, error);
- QCOMPARE(loader->source(), sourceUrl);
+ QVERIFY(loader->item());
+ QVERIFY(loader->source() == QUrl::fromLocalFile(SRCDIR "/data/Rect120x60.qml"));
QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(loader->status(), QDeclarativeLoader::Ready);
+ QCOMPARE(loader->property("did_load").toInt(), 123);
+ QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
- QCOMPARE(loader->status(), error ? QDeclarativeLoader::Error : QDeclarativeLoader::Ready);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), error ? 0: 1);
+ delete loader;
+}
- if (!error) {
- QDeclarativeComponent *c = qobject_cast<QDeclarativeComponent*>(loader->QGraphicsObject::children().at(0));
- QVERIFY(c);
- QCOMPARE(loader->sourceComponent(), c);
- }
+void tst_QDeclarativeLoader::component()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("/SetSourceComponent.qml"));
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
- QCOMPARE(loader->property("onSourceChangedCount").toInt(), 1);
- QCOMPARE(loader->property("onStatusChangedCount").toInt(), 1);
- QCOMPARE(loader->property("onProgressChangedCount").toInt(), 1);
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(item->QGraphicsObject::children().at(1));
+ QVERIFY(loader);
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(loader->status(), QDeclarativeLoader::Ready);
+ QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
- QCOMPARE(loader->property("onItemChangedCount").toInt(), error ? 0 : 1);
- QCOMPARE(loader->property("onLoadedCount").toInt(), error ? 0 : 1);
+ QDeclarativeComponent *c = qobject_cast<QDeclarativeComponent*>(item->QGraphicsObject::children().at(0));
+ QVERIFY(c);
+ QCOMPARE(loader->sourceComponent(), c);
- delete loader;
+ delete item;
}
-void tst_QDeclarativeLoader::sourceOrComponent_data()
+void tst_QDeclarativeLoader::invalidUrl()
{
- QTest::addColumn<QString>("sourceDefinition");
- QTest::addColumn<QUrl>("sourceUrl");
- QTest::addColumn<QString>("errorString");
+ QTest::ignoreMessage(QtWarningMsg, QString(QUrl::fromLocalFile(SRCDIR "/data/IDontExist.qml").toString() + ": File not found").toUtf8().constData());
- QTest::newRow("source") << "source: 'Rect120x60.qml'\n" << QUrl::fromLocalFile(SRCDIR "/data/Rect120x60.qml") << "";
- QTest::newRow("sourceComponent") << "Component { id: comp; Rectangle { width: 100; height: 50 } }\n sourceComponent: comp\n" << QUrl() << "";
+ QDeclarativeComponent component(&engine);
+ component.setData(QByteArray("import QtQuick 1.0\nLoader { source: \"IDontExist.qml\" }"), TEST_FILE(""));
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
+ QVERIFY(loader != 0);
+ QVERIFY(loader->item() == 0);
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(loader->status(), QDeclarativeLoader::Error);
+ QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 0);
- QTest::newRow("invalid source") << "source: 'IDontExist.qml'\n" << QUrl::fromLocalFile(SRCDIR "/data/IDontExist.qml")
- << QString(QUrl::fromLocalFile(SRCDIR "/data/IDontExist.qml").toString() + ": File not found");
+ delete loader;
}
void tst_QDeclarativeLoader::clear()
@@ -460,7 +446,7 @@ void tst_QDeclarativeLoader::networkRequestUrl()
server.serveDirectory(SRCDIR "/data");
QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 1.0\nLoader { property int signalCount : 0; source: \"http://127.0.0.1:14450/Rect120x60.qml\"; onLoaded: signalCount += 1 }"), QUrl::fromLocalFile(SRCDIR "/dummy.qml"));
+ component.setData(QByteArray("import QtQuick 1.0\nLoader { property int did_load : 0; source: \"http://127.0.0.1:14450/Rect120x60.qml\"; onLoaded: did_load=123 }"), QUrl::fromLocalFile(SRCDIR "/dummy.qml"));
if (component.isError())
qDebug() << component.errors();
QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
@@ -470,7 +456,7 @@ void tst_QDeclarativeLoader::networkRequestUrl()
QVERIFY(loader->item());
QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(loader->property("signalCount").toInt(), 1);
+ QCOMPARE(loader->property("did_load").toInt(), 123);
QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
delete loader;
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
index 615b919..ba1a95f 100644
--- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
+++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
@@ -373,6 +373,8 @@ void tst_qdeclarativetextedit::alignments()
QImage expect(expectfile);
QCOMPARE(actual,expect);
+
+ delete canvas;
}
@@ -745,6 +747,8 @@ void tst_qdeclarativetextedit::mouseSelection()
QVERIFY(str.length() > 3); // don't reallly care *what* was selected (and it's too sensitive to platform)
else
QVERIFY(str.isEmpty());
+
+ delete canvas;
}
void tst_qdeclarativetextedit::inputMethodHints()
@@ -759,6 +763,8 @@ void tst_qdeclarativetextedit::inputMethodHints()
QVERIFY(textEditObject->inputMethodHints() & Qt::ImhNoPredictiveText);
textEditObject->setInputMethodHints(Qt::ImhUppercaseOnly);
QVERIFY(textEditObject->inputMethodHints() & Qt::ImhUppercaseOnly);
+
+ delete canvas;
}
void tst_qdeclarativetextedit::cursorDelegate()
@@ -785,6 +791,8 @@ void tst_qdeclarativetextedit::cursorDelegate()
//Test Delegate gets deleted
textEditObject->setCursorDelegate(0);
QVERIFY(!textEditObject->findChild<QDeclarativeItem*>("cursorInstance"));
+
+ delete view;
}
void tst_qdeclarativetextedit::delegateLoading_data()
@@ -867,6 +875,8 @@ void tst_qdeclarativetextedit::navigation()
QVERIFY(input->hasActiveFocus() == false);
simulateKey(canvas, Qt::Key_Left);
QVERIFY(input->hasActiveFocus() == true);
+
+ delete canvas;
}
void tst_qdeclarativetextedit::copyAndPaste() {
@@ -941,6 +951,8 @@ void tst_qdeclarativetextedit::readOnly()
simulateKey(canvas, Qt::Key_Space);
simulateKey(canvas, Qt::Key_Escape);
QCOMPARE(edit->text(), initial);
+
+ delete canvas;
}
void tst_qdeclarativetextedit::simulateKey(QDeclarativeView *view, int key)