1 /****************************************************************************
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the test suite of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** No Commercial Usage
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file. Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights. These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
53 property string srcImage: "colors.png"
80 horizontalTileMode: BorderImage.Repeat
81 verticalTileMode: BorderImage.Repeat
89 horizontalTileMode: BorderImage.Round
90 verticalTileMode: BorderImage.Round
96 function test_noSource() {
97 compare(noSource.source, "")
98 compare(noSource.width, 0)
99 compare(noSource.height, 0)
100 compare(noSource.horizontalTileMode, BorderImage.Stretch)
101 compare(noSource.verticalTileMode, BorderImage.Stretch)
104 function test_imageSource_data() {
108 source: "colors.png",
113 tag: "local not found",
114 source: "no-such-file.png",
116 error: "SUBinline:1:21: QML BorderImage: Cannot open: SUBno-such-file.png"
118 // TODO: remote tests that need to use http
122 function test_imageSource(row) {
123 var expectError = (row.error.length != 0)
125 var parentUrl = Qt.resolvedUrl(".")
126 ignoreWarning(row.error.replace(/SUB/g, parentUrl))
129 var img = Qt.createQmlObject
130 ('import QtQuick 1.0; BorderImage { source: "' +
131 row.source + '" }', top)
134 tryCompare(img, "status", BorderImage.Loading)
137 tryCompare(img, "status", BorderImage.Ready)
138 compare(img.width, 120)
139 compare(img.height, 120)
140 compare(img.horizontalTileMode, BorderImage.Stretch)
141 compare(img.verticalTileMode, BorderImage.Stretch)
143 tryCompare(img, "status", BorderImage.Error)
149 function test_clearSource() {
150 compare(clearSource.source, Qt.resolvedUrl("colors.png"))
151 compare(clearSource.width, 120)
152 compare(clearSource.height, 120)
155 compare(clearSource.source, "")
156 compare(clearSource.width, 0)
157 compare(clearSource.height, 0)
160 function test_resized() {
161 compare(resized.width, 300)
162 compare(resized.height, 300)
163 compare(resized.horizontalTileMode, BorderImage.Stretch)
164 compare(resized.verticalTileMode, BorderImage.Stretch)
167 function test_smooth() {
168 compare(smooth.smooth, true)
169 compare(smooth.width, 300)
170 compare(smooth.height, 300)
171 compare(smooth.horizontalTileMode, BorderImage.Stretch)
172 compare(smooth.verticalTileMode, BorderImage.Stretch)
175 function test_tileModes() {
176 compare(tileModes1.width, 100)
177 compare(tileModes1.height, 300)
178 compare(tileModes1.horizontalTileMode, BorderImage.Repeat)
179 compare(tileModes1.verticalTileMode, BorderImage.Repeat)
181 compare(tileModes2.width, 300)
182 compare(tileModes2.height, 150)
183 compare(tileModes2.horizontalTileMode, BorderImage.Round)
184 compare(tileModes2.verticalTileMode, BorderImage.Round)
187 function test_sciSource_data() {
191 source: "colors-round.sci",
196 tag: "local not found",
197 source: "no-such-file.sci",
201 // TODO: remote tests that need to use http
205 function test_sciSource(row) {
206 var img = Qt.createQmlObject
207 ('import QtQuick 1.0; BorderImage { source: "' +
208 row.source + '"; width: 300; height: 300 }', top)
211 tryCompare(img, "status", BorderImage.Loading)
213 compare(img.source, Qt.resolvedUrl(row.source))
214 compare(img.width, 300)
215 compare(img.height, 300)
218 tryCompare(img, "status", BorderImage.Ready)
219 compare(img.border.left, 10)
220 compare(img.border.top, 20)
221 compare(img.border.right, 30)
222 compare(img.border.bottom, 40)
223 compare(img.horizontalTileMode, BorderImage.Round)
224 compare(img.verticalTileMode, BorderImage.Repeat)
226 tryCompare(img, "status", BorderImage.Error)
233 function test_invalidSciFile() {
234 ignoreWarning("QDeclarativeGridScaledImage: Invalid tile rule specified. Using Stretch.") // for "Roun"
235 ignoreWarning("QDeclarativeGridScaledImage: Invalid tile rule specified. Using Stretch.") // for "Repea"
237 var component = Qt.createComponent("InvalidSciFile.qml")
238 var invalidSciFile = component.createObject(top)
240 compare(invalidSciFile.status, Image.Error)
241 compare(invalidSciFile.width, 300)
242 compare(invalidSciFile.height, 300)
243 compare(invalidSciFile.horizontalTileMode, BorderImage.Stretch)
244 compare(invalidSciFile.verticalTileMode, BorderImage.Stretch)