summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/auto/declarative/anchors/data/anchors.qml13
-rw-r--r--tests/auto/declarative/anchors/tst_anchors.cpp24
-rw-r--r--tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp62
3 files changed, 70 insertions, 29 deletions
diff --git a/tests/auto/declarative/anchors/data/anchors.qml b/tests/auto/declarative/anchors/data/anchors.qml
index b64d0b0..e6bed48 100644
--- a/tests/auto/declarative/anchors/data/anchors.qml
+++ b/tests/auto/declarative/anchors/data/anchors.qml
@@ -120,7 +120,7 @@ Rectangle {
anchors.centerIn: masterRect
}
Rectangle {
- id: rect23; objectName: "rect23"
+ id: rect23a; objectName: "rect23a"
anchors.left: masterRect.left
anchors.leftMargin: 5
anchors.right: masterRect.right
@@ -131,6 +131,17 @@ Rectangle {
anchors.bottomMargin: 5
}
Rectangle {
+ id: rect23b; objectName: "rect23b"
+ anchors.left: rect23a.anchors.left
+ anchors.leftMargin: rect23a.anchors.leftMargin
+ anchors.right: rect23a.anchors.right
+ anchors.rightMargin: rect23a.anchors.rightMargin
+ anchors.top: rect23a.anchors.top
+ anchors.topMargin: rect23a.anchors.topMargin
+ anchors.bottom: rect23a.anchors.bottom
+ anchors.bottomMargin: rect23a.anchors.bottomMargin
+ }
+ Rectangle {
id: rect24; objectName: "rect24"
width: 10; height: 10
anchors.horizontalCenter: masterRect.left
diff --git a/tests/auto/declarative/anchors/tst_anchors.cpp b/tests/auto/declarative/anchors/tst_anchors.cpp
index d340a7d..d65d289 100644
--- a/tests/auto/declarative/anchors/tst_anchors.cpp
+++ b/tests/auto/declarative/anchors/tst_anchors.cpp
@@ -143,16 +143,20 @@ void tst_anchors::basicAnchors()
QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect22"))->x(), 69.0);
QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect22"))->y(), 5.0);
- //margins
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23"))->x(), 31.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23"))->y(), 5.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23"))->width(), 86.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23"))->height(), 10.0);
-
- // offsets
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect24"))->x(), 26.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect25"))->y(), 60.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect26"))->y(), 5.0);
+ //margins
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23a"))->x(), 31.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23a"))->y(), 5.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23a"))->width(), 86.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23a"))->height(), 10.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23b"))->x(), 31.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23b"))->y(), 5.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23b"))->width(), 86.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23b"))->height(), 10.0);
+
+ // offsets
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect24"))->x(), 26.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect25"))->y(), 60.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect26"))->y(), 5.0);
//baseline
QmlGraphicsText *text1 = findItem<QmlGraphicsText>(view->root(), QLatin1String("text1"));
diff --git a/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp b/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp
index 06a05dd..b281572 100644
--- a/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp
+++ b/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp
@@ -84,6 +84,8 @@ private slots:
void sciSource();
void sciSource_data();
void invalidSciFile();
+ void pendingRemoteRequest();
+ void pendingRemoteRequest_data();
private:
QmlEngine engine;
@@ -111,13 +113,14 @@ void tst_qmlgraphicsborderimage::noSource()
void tst_qmlgraphicsborderimage::imageSource()
{
QFETCH(QString, source);
- QFETCH(bool, remote);
QFETCH(bool, valid);
- TestHTTPServer server(SERVER_PORT);
+ bool remote = source.startsWith("http");
+ TestHTTPServer *server = 0;
if (remote) {
- QVERIFY(server.isValid());
- server.serveDirectory(SRCDIR "/data");
+ server = new TestHTTPServer(SERVER_PORT);
+ QVERIFY(server->isValid());
+ server->serveDirectory(SRCDIR "/data");
}
QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + source + "\" }";
@@ -141,18 +144,18 @@ void tst_qmlgraphicsborderimage::imageSource()
}
delete obj;
+ delete server;
}
void tst_qmlgraphicsborderimage::imageSource_data()
{
QTest::addColumn<QString>("source");
- QTest::addColumn<bool>("remote");
QTest::addColumn<bool>("valid");
- QTest::newRow("local") << SRCDIR "/data/colors.png" << false << true;
- QTest::newRow("local not found") << SRCDIR "/data/no-such-file.png" << false << false;
- QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << true;
- QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true << false;
+ QTest::newRow("local") << SRCDIR "/data/colors.png" << true;
+ QTest::newRow("local not found") << SRCDIR "/data/no-such-file.png" << false;
+ QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true;
+ QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << false;
}
void tst_qmlgraphicsborderimage::resized()
@@ -215,13 +218,14 @@ void tst_qmlgraphicsborderimage::tileModes()
void tst_qmlgraphicsborderimage::sciSource()
{
QFETCH(QString, source);
- QFETCH(bool, remote);
QFETCH(bool, valid);
- TestHTTPServer server(SERVER_PORT);
+ bool remote = source.startsWith("http");
+ TestHTTPServer *server = 0;
if (remote) {
- QVERIFY(server.isValid());
- server.serveDirectory(SRCDIR "/data");
+ server = new TestHTTPServer(SERVER_PORT);
+ QVERIFY(server->isValid());
+ server->serveDirectory(SRCDIR "/data");
}
QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + source + "\"; width: 300; height: 300 }";
@@ -249,18 +253,18 @@ void tst_qmlgraphicsborderimage::sciSource()
}
delete obj;
+ delete server;
}
void tst_qmlgraphicsborderimage::sciSource_data()
{
QTest::addColumn<QString>("source");
- QTest::addColumn<bool>("remote");
QTest::addColumn<bool>("valid");
- QTest::newRow("local") << SRCDIR "/data/colors-round.sci" << false << true;
- QTest::newRow("local not found") << SRCDIR "/data/no-such-file.sci" << false << false;
- QTest::newRow("remote") << SERVER_ADDR "/colors-round.sci" << true << true;
- QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.sci" << true << false;
+ QTest::newRow("local") << SRCDIR "/data/colors-round.sci" << true;
+ QTest::newRow("local not found") << SRCDIR "/data/no-such-file.sci" << false;
+ QTest::newRow("remote") << SERVER_ADDR "/colors-round.sci" << true;
+ QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.sci" << false;
}
void tst_qmlgraphicsborderimage::invalidSciFile()
@@ -278,7 +282,29 @@ void tst_qmlgraphicsborderimage::invalidSciFile()
delete obj;
}
+void tst_qmlgraphicsborderimage::pendingRemoteRequest()
+{
+ QFETCH(QString, source);
+
+ QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + source + "\" }";
+ QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://"));
+ QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->status(), QmlGraphicsBorderImage::Loading);
+ // verify no crash
+ // This will cause a delayed "QThread: Destroyed while thread is still running" warning
+ delete obj;
+ QTest::qWait(50);
+}
+
+void tst_qmlgraphicsborderimage::pendingRemoteRequest_data()
+{
+ QTest::addColumn<QString>("source");
+
+ QTest::newRow("png file") << "http://no-such-qt-server-like-this/none.png";
+ QTest::newRow("sci file") << "http://no-such-qt-server-like-this/none.sci";
+}
QTEST_MAIN(tst_qmlgraphicsborderimage)