From 122e8df400e5a8bd4df1655785e6714110ffce93 Mon Sep 17 00:00:00 2001 From: Damian Jansen Date: Mon, 30 Jan 2012 15:50:02 +1000 Subject: Add more element qmltestrunner cases Added remote testing to Image, BorderImage Added several basic element tests Change-Id: I1a25f31bc66be6b096a6d3c217196d5625e8a2ed Reviewed-by: Yunqiao Yin --- tests/auto/qmltest/borderimage/remote.sci | 7 +++ tests/auto/qmltest/borderimage/tst_borderimage.qml | 68 +++++++++++++++++----- 2 files changed, 60 insertions(+), 15 deletions(-) create mode 100644 tests/auto/qmltest/borderimage/remote.sci (limited to 'tests/auto/qmltest/borderimage') diff --git a/tests/auto/qmltest/borderimage/remote.sci b/tests/auto/qmltest/borderimage/remote.sci new file mode 100644 index 0000000000..70d5213453 --- /dev/null +++ b/tests/auto/qmltest/borderimage/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:14445/colors.png diff --git a/tests/auto/qmltest/borderimage/tst_borderimage.qml b/tests/auto/qmltest/borderimage/tst_borderimage.qml index 98a71711ed..113c0de77d 100644 --- a/tests/auto/qmltest/borderimage/tst_borderimage.qml +++ b/tests/auto/qmltest/borderimage/tst_borderimage.qml @@ -44,6 +44,24 @@ import QtTest 1.0 Item { id: top + property bool canconnect + property bool checkfinished: false + + Component.onCompleted: { + var check = new XMLHttpRequest; + check.open("GET", "http://127.0.0.1:14445/colors.png"); + check.onreadystatechange = function() { + if (check.readyState == XMLHttpRequest.DONE) { + if (check.status == 404) { + top.canconnect = false; + }else{ + top.canconnect = true; + } + top.checkfinished = true; + } + } + check.send(); + } BorderImage { id: noSource @@ -59,14 +77,14 @@ Item { BorderImage { id: resized - source: "colors.png" + source: srcImage width: 300 height: 300 } BorderImage { id: smooth - source: "colors.png" + source: srcImage smooth: true width: 300 height: 300 @@ -74,7 +92,7 @@ Item { BorderImage { id: tileModes1 - source: "colors.png" + source: srcImage width: 100 height: 300 horizontalTileMode: BorderImage.Repeat @@ -83,7 +101,7 @@ Item { BorderImage { id: tileModes2 - source: "colors.png" + source: srcImage width: 300 height: 150 horizontalTileMode: BorderImage.Round @@ -114,8 +132,13 @@ Item { source: "no-such-file.png", remote: false, error: "SUBinline:1:21: QML BorderImage: Cannot open: SUBno-such-file.png" + }, + { + tag: "remote", + source: "http://127.0.0.1:14445/colors.png", + remote: true, + error: "" } - // TODO: remote tests that need to use http ] } @@ -130,11 +153,16 @@ Item { ('import QtQuick 2.0; BorderImage { source: "' + row.source + '" }', top) - if (row.remote) + if (row.remote) { + skip("Remote solution not yet complete") tryCompare(img, "status", BorderImage.Loading) + tryCompare(top, "checkfinished", true, 10000) + if (top.canconnect == false) + skip("Cannot access remote") + } if (!expectError) { - tryCompare(img, "status", BorderImage.Ready) + tryCompare(img, "status", BorderImage.Ready, 10000) compare(img.width, 120) compare(img.height, 120) compare(img.horizontalTileMode, BorderImage.Stretch) @@ -197,25 +225,35 @@ Item { source: "no-such-file.sci", remote: false, valid: false + }, + { + tag: "remote", + source: "remote.sci", + remote: true, + valid: true } - // TODO: remote tests that need to use http ] } function test_sciSource(row) { - var img = Qt.createQmlObject - ('import QtQuick 2.0; BorderImage { source: "' + - row.source + '"; width: 300; height: 300 }', top) - - if (row.remote) - tryCompare(img, "status", BorderImage.Loading) + var img = Qt.createQmlObject('import QtQuick 2.0; BorderImage { height: 300; width: 300 }', top) + + if (row.remote) { + skip("Remote solution not yet complete") + img.source = row.source; + tryCompare(top, "checkfinished", true, 10000) + if (top.canconnect == false) + skip("Cannot access remote") + }else{ + img.source = row.source; + } compare(img.source, Qt.resolvedUrl(row.source)) compare(img.width, 300) compare(img.height, 300) if (row.valid) { - tryCompare(img, "status", BorderImage.Ready) + tryCompare(img, "status", BorderImage.Ready, 10000) compare(img.border.left, 10) compare(img.border.top, 20) compare(img.border.right, 30) -- cgit v1.2.3