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 ****************************************************************************/
46 property string srcImage: "stickman.gif"
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/stickman.gif");
53 check.onreadystatechange = function() {
55 console.log("Status: ", check.status)
56 console.log("Readystate", check.readyState)
57 if (check.readyState == XMLHttpRequest.DONE) {
58 if (check.status == 404) {
59 top.canconnect = false;
61 top.canconnect = true;
63 top.checkfinished = true;
99 fillMode: AnimatedImage.Tile
107 fillMode: AnimatedImage.TileVertically
114 fillMode: AnimatedImage.TileHorizontally
118 name: "AnimatedImage"
120 function test_noSource() {
121 compare(noSource.source, "")
122 compare(noSource.width, 0)
123 compare(noSource.height, 0)
124 compare(noSource.fillMode, AnimatedImage.Stretch)
127 function test_imageSource_data() {
131 source: "stickman.gif",
136 tag: "local not found",
137 source: "no-such-file.png",
139 error: "SUBinline:1:21: QML AnimatedImage: Error Reading Animated Image File SUBno-such-file.png"
143 source: "http://127.0.0.1:14445/stickman.gif",
150 function test_imageSource(row) {
151 var expectError = (row.error.length != 0)
152 var canconnect = false;
155 var parentUrl = Qt.resolvedUrl(".")
156 ignoreWarning(row.error.replace(/SUB/g, parentUrl))
159 var img = Qt.createQmlObject('import QtQuick 2.0; AnimatedImage { source: "'+row.source+'" }', top)
162 skip("Remote solution not yet complete")
163 tryCompare(img, "status", AnimatedImage.Loading)
164 tryCompare(top, "checkfinished", true, 10000)
165 if (top.canconnect == false)
166 skip("Cannot access remote")
170 tryCompare(img, "status", AnimatedImage.Ready, 10000)
171 compare(img.width, 160)
172 compare(img.height, 120)
173 compare(img.fillMode, AnimatedImage.Stretch)
175 tryCompare(img, "status", AnimatedImage.Error)
181 function test_clearSource() {
182 compare(clearSource.source, Qt.resolvedUrl(srcImage))
183 compare(clearSource.width, 160)
184 compare(clearSource.height, 120)
187 compare(clearSource.source, "")
188 compare(clearSource.width, 0)
189 compare(clearSource.height, 0)
192 function test_resized() {
193 compare(resized.width, 300)
194 compare(resized.height, 300)
195 compare(resized.fillMode, AnimatedImage.Stretch)
198 function test_smooth() {
199 compare(smooth.smooth, true)
200 compare(smooth.width, 300)
201 compare(smooth.height, 300)
202 compare(smooth.fillMode, AnimatedImage.Stretch)
205 function test_tileModes() {
206 compare(tileModes1.width, 100)
207 compare(tileModes1.height, 300)
208 compare(tileModes1.fillMode, AnimatedImage.Tile)
210 compare(tileModes2.width, 300)
211 compare(tileModes2.height, 150)
212 compare(tileModes2.fillMode, AnimatedImage.TileVertically)
214 compare(tileModes3.width, 300)
215 compare(tileModes3.height, 150)
216 compare(tileModes3.fillMode, AnimatedImage.TileHorizontally)