1 /****************************************************************************
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
6 ** This file is part of the test suite of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:BSD$
9 ** You may use this file under the terms of the BSD license as follows:
11 ** "Redistribution and use in source and binary forms, with or without
12 ** modification, are permitted provided that the following conditions are
14 ** * Redistributions of source code must retain the above copyright
15 ** notice, this list of conditions and the following disclaimer.
16 ** * Redistributions in binary form must reproduce the above copyright
17 ** notice, this list of conditions and the following disclaimer in
18 ** the documentation and/or other materials provided with the
20 ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
21 ** of its contributors may be used to endorse or promote products derived
22 ** from this software without specific prior written permission.
25 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
39 ****************************************************************************/
47 property string srcImage: "logo.png"
48 property bool canconnect
49 property bool checkfinished: false
51 Component.onCompleted: {
52 var check = new XMLHttpRequest;
53 check.open("GET", "http://127.0.0.1:14445/logo.png");
54 check.onreadystatechange = function() {
55 if (check.readyState == XMLHttpRequest.DONE) {
56 if (check.status == 404) {
57 top.canconnect = false;
59 top.canconnect = true;
61 top.checkfinished = true;
105 fillMode: Image.TileVertically
112 fillMode: Image.TileHorizontally
118 function test_noSource() {
119 compare(noSource.source, "")
120 compare(noSource.width, 0)
121 compare(noSource.height, 0)
122 compare(noSource.fillMode, Image.Stretch)
125 function test_imageSource_data() {
134 tag: "local not found",
135 source: "no-such-file.png",
137 error: "SUBinline:1:21: QML Image: Cannot open: SUBno-such-file.png"
141 source: "http://127.0.0.1:14445/logo.png",
148 function test_imageSource(row) {
149 var expectError = (row.error.length != 0)
151 var parentUrl = Qt.resolvedUrl(".")
152 ignoreWarning(row.error.replace(/SUB/g, parentUrl))
155 var img = Qt.createQmlObject('import QtQuick 2.0; Image { source: "'+row.source+'" }', top)
158 skip("Remote solution not yet complete")
159 tryCompare(img, "status", Image.Loading)
160 tryCompare(top, "checkfinished", true, 10000)
161 if (top.canconnect == false)
162 skip("Cannot access remote")
166 tryCompare(img, "status", Image.Ready, 10000)
167 compare(img.width, 59)
168 compare(img.height, 71)
169 compare(img.fillMode, Image.Stretch)
171 tryCompare(img, "status", Image.Error)
177 function test_clearSource() {
178 compare(clearSource.source, Qt.resolvedUrl(srcImage))
179 compare(clearSource.width, 59)
180 compare(clearSource.height, 71)
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.fillMode, Image.Stretch)
194 function test_smooth() {
195 compare(smooth.smooth, true)
196 compare(smooth.width, 300)
197 compare(smooth.height, 300)
198 compare(smooth.fillMode, Image.Stretch)
201 function test_tileModes() {
202 compare(tileModes1.width, 100)
203 compare(tileModes1.height, 300)
204 compare(tileModes1.fillMode, Image.Tile)
206 compare(tileModes2.width, 300)
207 compare(tileModes2.height, 150)
208 compare(tileModes2.fillMode, Image.TileVertically)
210 compare(tileModes3.width, 300)
211 compare(tileModes3.height, 150)
212 compare(tileModes3.fillMode, Image.TileHorizontally)