1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the test suite of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
47 property bool canconnect
48 property bool checkfinished: false
50 Component.onCompleted: {
51 var check = new XMLHttpRequest;
52 check.open("GET", "http://127.0.0.1:14445/colors.png");
53 check.onreadystatechange = function() {
54 if (check.readyState == XMLHttpRequest.DONE) {
55 if (check.status == 404) {
56 top.canconnect = false;
58 top.canconnect = true;
60 top.checkfinished = true;
71 property string srcImage: "colors.png"
98 horizontalTileMode: BorderImage.Repeat
99 verticalTileMode: BorderImage.Repeat
107 horizontalTileMode: BorderImage.Round
108 verticalTileMode: BorderImage.Round
114 function test_noSource() {
115 compare(noSource.source, "")
116 compare(noSource.width, 0)
117 compare(noSource.height, 0)
118 compare(noSource.horizontalTileMode, BorderImage.Stretch)
119 compare(noSource.verticalTileMode, BorderImage.Stretch)
122 function test_imageSource_data() {
126 source: "colors.png",
131 tag: "local not found",
132 source: "no-such-file.png",
134 error: "SUBinline:1:21: QML BorderImage: Cannot open: SUBno-such-file.png"
138 source: "http://127.0.0.1:14445/colors.png",
145 function test_imageSource(row) {
146 var expectError = (row.error.length != 0)
148 var parentUrl = Qt.resolvedUrl(".")
149 ignoreWarning(row.error.replace(/SUB/g, parentUrl))
152 var img = Qt.createQmlObject
153 ('import QtQuick 2.0; BorderImage { source: "' +
154 row.source + '" }', top)
157 skip("Remote solution not yet complete")
158 tryCompare(img, "status", BorderImage.Loading)
159 tryCompare(top, "checkfinished", true, 10000)
160 if (top.canconnect == false)
161 skip("Cannot access remote")
165 tryCompare(img, "status", BorderImage.Ready, 10000)
166 compare(img.width, 120)
167 compare(img.height, 120)
168 compare(img.horizontalTileMode, BorderImage.Stretch)
169 compare(img.verticalTileMode, BorderImage.Stretch)
171 tryCompare(img, "status", BorderImage.Error)
177 function test_clearSource() {
178 compare(clearSource.source, Qt.resolvedUrl("colors.png"))
179 compare(clearSource.width, 120)
180 compare(clearSource.height, 120)
183 compare(clearSource.source, "")
184 compare(clearSource.width, 0)
185 compare(clearSource.height, 0)
188 function test_resized() {
189 compare(resized.width, 300)
190 compare(resized.height, 300)
191 compare(resized.horizontalTileMode, BorderImage.Stretch)
192 compare(resized.verticalTileMode, BorderImage.Stretch)
195 function test_smooth() {
196 compare(smooth.smooth, true)
197 compare(smooth.width, 300)
198 compare(smooth.height, 300)
199 compare(smooth.horizontalTileMode, BorderImage.Stretch)
200 compare(smooth.verticalTileMode, BorderImage.Stretch)
203 function test_tileModes() {
204 compare(tileModes1.width, 100)
205 compare(tileModes1.height, 300)
206 compare(tileModes1.horizontalTileMode, BorderImage.Repeat)
207 compare(tileModes1.verticalTileMode, BorderImage.Repeat)
209 compare(tileModes2.width, 300)
210 compare(tileModes2.height, 150)
211 compare(tileModes2.horizontalTileMode, BorderImage.Round)
212 compare(tileModes2.verticalTileMode, BorderImage.Round)
215 function test_sciSource_data() {
219 source: "colors-round.sci",
224 tag: "local not found",
225 source: "no-such-file.sci",
231 source: "remote.sci",
238 function test_sciSource(row) {
239 var img = Qt.createQmlObject('import QtQuick 2.0; BorderImage { height: 300; width: 300 }', top)
242 skip("Remote solution not yet complete")
243 img.source = row.source;
244 tryCompare(top, "checkfinished", true, 10000)
245 if (top.canconnect == false)
246 skip("Cannot access remote")
248 img.source = row.source;
251 compare(img.source, Qt.resolvedUrl(row.source))
252 compare(img.width, 300)
253 compare(img.height, 300)
256 tryCompare(img, "status", BorderImage.Ready, 10000)
257 compare(img.border.left, 10)
258 compare(img.border.top, 20)
259 compare(img.border.right, 30)
260 compare(img.border.bottom, 40)
261 compare(img.horizontalTileMode, BorderImage.Round)
262 compare(img.verticalTileMode, BorderImage.Repeat)
264 tryCompare(img, "status", BorderImage.Error)
271 function test_invalidSciFile() {
272 ignoreWarning("QQuickGridScaledImage: Invalid tile rule specified. Using Stretch.") // for "Roun"
273 ignoreWarning("QQuickGridScaledImage: Invalid tile rule specified. Using Stretch.") // for "Repea"
275 var component = Qt.createComponent("InvalidSciFile.qml")
276 var invalidSciFile = component.createObject(top)
278 compare(invalidSciFile.status, Image.Error)
279 compare(invalidSciFile.width, 300)
280 compare(invalidSciFile.height, 300)
281 compare(invalidSciFile.horizontalTileMode, BorderImage.Stretch)
282 compare(invalidSciFile.verticalTileMode, BorderImage.Stretch)