author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 04 Oct 2010 01:19:32 +0300 | |
changeset 37 | 758a864f9613 |
parent 18 | 2f34d5167611 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the test suite of the Qt Toolkit. |
|
8 |
** |
|
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 |
|
14 |
** this package. |
|
15 |
** |
|
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. |
|
23 |
** |
|
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. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#include <QtTest/QtTest> |
|
43 |
||
44 |
#include <QtMultimedia/QVideoSurfaceFormat> |
|
45 |
||
46 |
class tst_QVideoSurfaceFormat : public QObject |
|
47 |
{ |
|
48 |
Q_OBJECT |
|
49 |
public: |
|
50 |
tst_QVideoSurfaceFormat(); |
|
51 |
~tst_QVideoSurfaceFormat(); |
|
52 |
||
53 |
public slots: |
|
54 |
void initTestCase(); |
|
55 |
void cleanupTestCase(); |
|
56 |
void init(); |
|
57 |
void cleanup(); |
|
58 |
||
59 |
private slots: |
|
60 |
void constructNull(); |
|
61 |
void construct_data(); |
|
62 |
void construct(); |
|
63 |
void frameSize_data(); |
|
64 |
void frameSize(); |
|
65 |
void viewport_data(); |
|
66 |
void viewport(); |
|
67 |
void scanLineDirection_data(); |
|
68 |
void scanLineDirection(); |
|
69 |
void frameRate_data(); |
|
70 |
void frameRate(); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
71 |
void yCbCrColorSpace_data(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
72 |
void yCbCrColorSpace(); |
0 | 73 |
void pixelAspectRatio_data(); |
74 |
void pixelAspectRatio(); |
|
75 |
void sizeHint_data(); |
|
76 |
void sizeHint(); |
|
77 |
void staticPropertyNames(); |
|
78 |
void dynamicProperty(); |
|
79 |
void compare(); |
|
80 |
void copy(); |
|
81 |
void assign(); |
|
82 |
}; |
|
83 |
||
84 |
tst_QVideoSurfaceFormat::tst_QVideoSurfaceFormat() |
|
85 |
{ |
|
86 |
} |
|
87 |
||
88 |
tst_QVideoSurfaceFormat::~tst_QVideoSurfaceFormat() |
|
89 |
{ |
|
90 |
} |
|
91 |
||
92 |
void tst_QVideoSurfaceFormat::initTestCase() |
|
93 |
{ |
|
94 |
} |
|
95 |
||
96 |
void tst_QVideoSurfaceFormat::cleanupTestCase() |
|
97 |
{ |
|
98 |
} |
|
99 |
||
100 |
void tst_QVideoSurfaceFormat::init() |
|
101 |
{ |
|
102 |
} |
|
103 |
||
104 |
void tst_QVideoSurfaceFormat::cleanup() |
|
105 |
{ |
|
106 |
} |
|
107 |
||
108 |
void tst_QVideoSurfaceFormat::constructNull() |
|
109 |
{ |
|
110 |
QVideoSurfaceFormat format; |
|
111 |
||
112 |
QVERIFY(!format.isValid()); |
|
113 |
QCOMPARE(format.handleType(), QAbstractVideoBuffer::NoHandle); |
|
114 |
QCOMPARE(format.pixelFormat(), QVideoFrame::Format_Invalid); |
|
115 |
QCOMPARE(format.frameSize(), QSize()); |
|
116 |
QCOMPARE(format.frameWidth(), -1); |
|
117 |
QCOMPARE(format.frameHeight(), -1); |
|
118 |
QCOMPARE(format.viewport(), QRect()); |
|
119 |
QCOMPARE(format.scanLineDirection(), QVideoSurfaceFormat::TopToBottom); |
|
120 |
QCOMPARE(format.frameRate(), 0.0); |
|
121 |
QCOMPARE(format.pixelAspectRatio(), QSize(1, 1)); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
122 |
QCOMPARE(format.yCbCrColorSpace(), QVideoSurfaceFormat::YCbCr_Undefined); |
0 | 123 |
} |
124 |
||
125 |
void tst_QVideoSurfaceFormat::construct_data() |
|
126 |
{ |
|
127 |
QTest::addColumn<QSize>("frameSize"); |
|
128 |
QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat"); |
|
129 |
QTest::addColumn<QAbstractVideoBuffer::HandleType>("handleType"); |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
130 |
QTest::addColumn<bool>("valid"); |
0 | 131 |
|
132 |
QTest::newRow("32x32 rgb32 no handle") |
|
133 |
<< QSize(32, 32) |
|
134 |
<< QVideoFrame::Format_RGB32 |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
135 |
<< QAbstractVideoBuffer::NoHandle |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
136 |
<< true; |
0 | 137 |
|
138 |
QTest::newRow("1024x768 YUV444 GL texture") |
|
139 |
<< QSize(32, 32) |
|
140 |
<< QVideoFrame::Format_YUV444 |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
141 |
<< QAbstractVideoBuffer::GLTextureHandle |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
142 |
<< true; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
143 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
144 |
QTest::newRow("32x32 invalid no handle") |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
145 |
<< QSize(32, 32) |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
146 |
<< QVideoFrame::Format_Invalid |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
147 |
<< QAbstractVideoBuffer::NoHandle |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
148 |
<< false; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
149 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
150 |
QTest::newRow("invalid size, rgb32 no handle") |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
151 |
<< QSize() |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
152 |
<< QVideoFrame::Format_RGB32 |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
153 |
<< QAbstractVideoBuffer::NoHandle |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
154 |
<< false; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
155 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
156 |
QTest::newRow("0x0 rgb32 no handle") |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
157 |
<< QSize(0,0) |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
158 |
<< QVideoFrame::Format_RGB32 |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
159 |
<< QAbstractVideoBuffer::NoHandle |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
160 |
<< true; |
0 | 161 |
} |
162 |
||
163 |
void tst_QVideoSurfaceFormat::construct() |
|
164 |
{ |
|
165 |
QFETCH(QSize, frameSize); |
|
166 |
QFETCH(QVideoFrame::PixelFormat, pixelFormat); |
|
167 |
QFETCH(QAbstractVideoBuffer::HandleType, handleType); |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
168 |
QFETCH(bool, valid); |
0 | 169 |
|
170 |
QRect viewport(QPoint(0, 0), frameSize); |
|
171 |
||
172 |
QVideoSurfaceFormat format(frameSize, pixelFormat, handleType); |
|
173 |
||
174 |
QCOMPARE(format.handleType(), handleType); |
|
175 |
QCOMPARE(format.pixelFormat(), pixelFormat); |
|
176 |
QCOMPARE(format.frameSize(), frameSize); |
|
177 |
QCOMPARE(format.frameWidth(), frameSize.width()); |
|
178 |
QCOMPARE(format.frameHeight(), frameSize.height()); |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
179 |
QCOMPARE(format.isValid(), valid); |
0 | 180 |
QCOMPARE(format.viewport(), viewport); |
181 |
QCOMPARE(format.scanLineDirection(), QVideoSurfaceFormat::TopToBottom); |
|
182 |
QCOMPARE(format.frameRate(), 0.0); |
|
183 |
QCOMPARE(format.pixelAspectRatio(), QSize(1, 1)); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
184 |
QCOMPARE(format.yCbCrColorSpace(), QVideoSurfaceFormat::YCbCr_Undefined); |
0 | 185 |
} |
186 |
||
187 |
void tst_QVideoSurfaceFormat::frameSize_data() |
|
188 |
{ |
|
189 |
QTest::addColumn<QSize>("initialSize"); |
|
190 |
QTest::addColumn<QSize>("newSize"); |
|
191 |
||
192 |
QTest::newRow("grow") |
|
193 |
<< QSize(64, 64) |
|
194 |
<< QSize(1024, 1024); |
|
195 |
QTest::newRow("shrink") |
|
196 |
<< QSize(1024, 1024) |
|
197 |
<< QSize(64, 64); |
|
198 |
QTest::newRow("unchanged") |
|
199 |
<< QSize(512, 512) |
|
200 |
<< QSize(512, 512); |
|
201 |
} |
|
202 |
||
203 |
void tst_QVideoSurfaceFormat::frameSize() |
|
204 |
{ |
|
205 |
QFETCH(QSize, initialSize); |
|
206 |
QFETCH(QSize, newSize); |
|
207 |
||
208 |
QVideoSurfaceFormat format(initialSize, QVideoFrame::Format_RGB32); |
|
209 |
||
210 |
format.setFrameSize(newSize); |
|
211 |
||
212 |
QCOMPARE(format.frameSize(), newSize); |
|
213 |
QCOMPARE(format.property("frameSize").toSize(), newSize); |
|
214 |
QCOMPARE(format.frameWidth(), newSize.width()); |
|
215 |
QCOMPARE(format.property("frameWidth").toInt(), newSize.width()); |
|
216 |
QCOMPARE(format.frameHeight(), newSize.height()); |
|
217 |
QCOMPARE(format.property("frameHeight").toInt(), newSize.height()); |
|
218 |
} |
|
219 |
||
220 |
void tst_QVideoSurfaceFormat::viewport_data() |
|
221 |
{ |
|
222 |
QTest::addColumn<QSize>("initialSize"); |
|
223 |
QTest::addColumn<QRect>("viewport"); |
|
224 |
QTest::addColumn<QSize>("newSize"); |
|
225 |
QTest::addColumn<QRect>("expectedViewport"); |
|
226 |
||
227 |
QTest::newRow("grow reset") |
|
228 |
<< QSize(64, 64) |
|
229 |
<< QRect(8, 8, 48, 48) |
|
230 |
<< QSize(1024, 1024) |
|
231 |
<< QRect(0, 0, 1024, 1024); |
|
232 |
QTest::newRow("shrink reset") |
|
233 |
<< QSize(1024, 1024) |
|
234 |
<< QRect(8, 8, 1008, 1008) |
|
235 |
<< QSize(64, 64) |
|
236 |
<< QRect(0, 0, 64, 64); |
|
237 |
QTest::newRow("unchanged reset") |
|
238 |
<< QSize(512, 512) |
|
239 |
<< QRect(8, 8, 496, 496) |
|
240 |
<< QSize(512, 512) |
|
241 |
<< QRect(0, 0, 512, 512); |
|
242 |
} |
|
243 |
||
244 |
void tst_QVideoSurfaceFormat::viewport() |
|
245 |
{ |
|
246 |
QFETCH(QSize, initialSize); |
|
247 |
QFETCH(QRect, viewport); |
|
248 |
QFETCH(QSize, newSize); |
|
249 |
QFETCH(QRect, expectedViewport); |
|
250 |
||
251 |
{ |
|
252 |
QRect initialViewport(QPoint(0, 0), initialSize); |
|
253 |
||
254 |
QVideoSurfaceFormat format(initialSize, QVideoFrame::Format_RGB32); |
|
255 |
||
256 |
format.setViewport(viewport); |
|
257 |
||
258 |
QCOMPARE(format.viewport(), viewport); |
|
259 |
QCOMPARE(format.property("viewport").toRect(), viewport); |
|
260 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
261 |
format.setFrameSize(newSize); |
0 | 262 |
|
263 |
QCOMPARE(format.viewport(), expectedViewport); |
|
264 |
QCOMPARE(format.property("viewport").toRect(), expectedViewport); |
|
265 |
} |
|
266 |
{ |
|
267 |
QVideoSurfaceFormat format(initialSize, QVideoFrame::Format_RGB32); |
|
268 |
||
269 |
format.setProperty("viewport", viewport); |
|
270 |
||
271 |
QCOMPARE(format.viewport(), viewport); |
|
272 |
QCOMPARE(format.property("viewport").toRect(), viewport); |
|
273 |
} |
|
274 |
} |
|
275 |
||
276 |
void tst_QVideoSurfaceFormat::scanLineDirection_data() |
|
277 |
{ |
|
278 |
QTest::addColumn<QVideoSurfaceFormat::Direction>("direction"); |
|
279 |
||
280 |
QTest::newRow("top to bottom") |
|
281 |
<< QVideoSurfaceFormat::TopToBottom; |
|
282 |
||
283 |
QTest::newRow("bottom to top") |
|
284 |
<< QVideoSurfaceFormat::BottomToTop; |
|
285 |
} |
|
286 |
||
287 |
void tst_QVideoSurfaceFormat::scanLineDirection() |
|
288 |
{ |
|
289 |
QFETCH(QVideoSurfaceFormat::Direction, direction); |
|
290 |
||
291 |
{ |
|
292 |
QVideoSurfaceFormat format(QSize(16, 16), QVideoFrame::Format_RGB32); |
|
293 |
||
294 |
format.setScanLineDirection(direction); |
|
295 |
||
296 |
QCOMPARE(format.scanLineDirection(), direction); |
|
297 |
QCOMPARE( |
|
298 |
qvariant_cast<QVideoSurfaceFormat::Direction>(format.property("scanLineDirection")), |
|
299 |
direction); |
|
300 |
} |
|
301 |
{ |
|
302 |
QVideoSurfaceFormat format(QSize(16, 16), QVideoFrame::Format_RGB32); |
|
303 |
||
304 |
format.setProperty("scanLineDirection", qVariantFromValue(direction)); |
|
305 |
||
306 |
QCOMPARE(format.scanLineDirection(), direction); |
|
307 |
QCOMPARE( |
|
308 |
qvariant_cast<QVideoSurfaceFormat::Direction>(format.property("scanLineDirection")), |
|
309 |
direction); |
|
310 |
} |
|
311 |
} |
|
312 |
||
313 |
void tst_QVideoSurfaceFormat::frameRate_data() |
|
314 |
{ |
|
315 |
QTest::addColumn<qreal>("frameRate"); |
|
316 |
||
317 |
QTest::newRow("null") |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
318 |
<< qreal(0.0); |
0 | 319 |
QTest::newRow("1/1") |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
320 |
<< qreal(1.0); |
0 | 321 |
QTest::newRow("24/1") |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
322 |
<< qreal(24.0); |
0 | 323 |
QTest::newRow("15/2") |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
324 |
<< qreal(7.5); |
0 | 325 |
} |
326 |
||
327 |
void tst_QVideoSurfaceFormat::frameRate() |
|
328 |
{ |
|
329 |
QFETCH(qreal, frameRate); |
|
330 |
||
331 |
{ |
|
332 |
QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); |
|
333 |
||
334 |
format.setFrameRate(frameRate); |
|
335 |
||
336 |
QCOMPARE(format.frameRate(), frameRate); |
|
337 |
QCOMPARE(qvariant_cast<qreal>(format.property("frameRate")), frameRate); |
|
338 |
} |
|
339 |
{ |
|
340 |
QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); |
|
341 |
||
342 |
format.setFrameRate(frameRate); |
|
343 |
format.setProperty("frameRate", frameRate); |
|
344 |
||
345 |
QCOMPARE(format.frameRate(), frameRate); |
|
346 |
QCOMPARE(qvariant_cast<qreal>(format.property("frameRate")), frameRate); |
|
347 |
} |
|
348 |
} |
|
349 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
350 |
void tst_QVideoSurfaceFormat::yCbCrColorSpace_data() |
0 | 351 |
{ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
352 |
QTest::addColumn<QVideoSurfaceFormat::YCbCrColorSpace>("colorspace"); |
0 | 353 |
|
354 |
QTest::newRow("undefined") |
|
355 |
<< QVideoSurfaceFormat::YCbCr_Undefined; |
|
356 |
QTest::newRow("bt709") |
|
357 |
<< QVideoSurfaceFormat::YCbCr_BT709; |
|
358 |
QTest::newRow("xvYCC601") |
|
359 |
<< QVideoSurfaceFormat::YCbCr_xvYCC601; |
|
360 |
QTest::newRow("JPEG") |
|
361 |
<< QVideoSurfaceFormat::YCbCr_JPEG; |
|
362 |
} |
|
363 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
364 |
void tst_QVideoSurfaceFormat::yCbCrColorSpace() |
0 | 365 |
{ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
366 |
QFETCH(QVideoSurfaceFormat::YCbCrColorSpace, colorspace); |
0 | 367 |
|
368 |
{ |
|
369 |
QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
370 |
format.setYCbCrColorSpace(colorspace); |
0 | 371 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
372 |
QCOMPARE(format.yCbCrColorSpace(), colorspace); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
373 |
QCOMPARE(qvariant_cast<QVideoSurfaceFormat::YCbCrColorSpace>(format.property("yCbCrColorSpace")), |
0 | 374 |
colorspace); |
375 |
} |
|
376 |
{ |
|
377 |
QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
378 |
format.setProperty("yCbCrColorSpace", qVariantFromValue(colorspace)); |
0 | 379 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
380 |
QCOMPARE(format.yCbCrColorSpace(), colorspace); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
381 |
QCOMPARE(qvariant_cast<QVideoSurfaceFormat::YCbCrColorSpace>(format.property("yCbCrColorSpace")), |
0 | 382 |
colorspace); |
383 |
} |
|
384 |
} |
|
385 |
||
386 |
void tst_QVideoSurfaceFormat::pixelAspectRatio_data() |
|
387 |
{ |
|
388 |
QTest::addColumn<QSize>("aspectRatio"); |
|
389 |
||
390 |
QTest::newRow("1:1") |
|
391 |
<< QSize(1, 1); |
|
392 |
QTest::newRow("4:3") |
|
393 |
<< QSize(4, 3); |
|
394 |
QTest::newRow("16:9") |
|
395 |
<< QSize(16, 9); |
|
396 |
} |
|
397 |
||
398 |
void tst_QVideoSurfaceFormat::pixelAspectRatio() |
|
399 |
{ |
|
400 |
QFETCH(QSize, aspectRatio); |
|
401 |
||
402 |
{ |
|
403 |
QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); |
|
404 |
format.setPixelAspectRatio(aspectRatio); |
|
405 |
||
406 |
QCOMPARE(format.pixelAspectRatio(), aspectRatio); |
|
407 |
QCOMPARE(format.property("pixelAspectRatio").toSize(), aspectRatio); |
|
408 |
} |
|
409 |
{ |
|
410 |
QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); |
|
411 |
format.setPixelAspectRatio(aspectRatio.width(), aspectRatio.height()); |
|
412 |
||
413 |
QCOMPARE(format.pixelAspectRatio(), aspectRatio); |
|
414 |
QCOMPARE(format.property("pixelAspectRatio").toSize(), aspectRatio); |
|
415 |
} |
|
416 |
{ |
|
417 |
QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); |
|
418 |
format.setProperty("pixelAspectRatio", aspectRatio); |
|
419 |
||
420 |
QCOMPARE(format.pixelAspectRatio(), aspectRatio); |
|
421 |
QCOMPARE(format.property("pixelAspectRatio").toSize(), aspectRatio); |
|
422 |
} |
|
423 |
} |
|
424 |
||
425 |
void tst_QVideoSurfaceFormat::sizeHint_data() |
|
426 |
{ |
|
427 |
QTest::addColumn<QSize>("frameSize"); |
|
428 |
QTest::addColumn<QRect>("viewport"); |
|
429 |
QTest::addColumn<QSize>("aspectRatio"); |
|
430 |
QTest::addColumn<QSize>("sizeHint"); |
|
431 |
||
432 |
QTest::newRow("(0, 0, 1024x768), 1:1") |
|
433 |
<< QSize(1024, 768) |
|
434 |
<< QRect(0, 0, 1024, 768) |
|
435 |
<< QSize(1, 1) |
|
436 |
<< QSize(1024, 768); |
|
437 |
QTest::newRow("0, 0, 1024x768), 4:3") |
|
438 |
<< QSize(1024, 768) |
|
439 |
<< QRect(0, 0, 1024, 768) |
|
440 |
<< QSize(4, 3) |
|
441 |
<< QSize(1365, 768); |
|
442 |
QTest::newRow("(168, 84, 800x600), 1:1") |
|
443 |
<< QSize(1024, 768) |
|
444 |
<< QRect(168, 84, 800, 600) |
|
445 |
<< QSize(1, 1) |
|
446 |
<< QSize(800, 600); |
|
447 |
QTest::newRow("(168, 84, 800x600), 4:3") |
|
448 |
<< QSize(1024, 768) |
|
449 |
<< QRect(168, 84, 800, 600) |
|
450 |
<< QSize(4, 3) |
|
451 |
<< QSize(1066, 600); |
|
452 |
} |
|
453 |
||
454 |
void tst_QVideoSurfaceFormat::sizeHint() |
|
455 |
{ |
|
456 |
QFETCH(QSize, frameSize); |
|
457 |
QFETCH(QRect, viewport); |
|
458 |
QFETCH(QSize, aspectRatio); |
|
459 |
QFETCH(QSize, sizeHint); |
|
460 |
||
461 |
QVideoSurfaceFormat format(frameSize, QVideoFrame::Format_RGB32); |
|
462 |
format.setViewport(viewport); |
|
463 |
format.setPixelAspectRatio(aspectRatio); |
|
464 |
||
465 |
QCOMPARE(format.sizeHint(), sizeHint); |
|
466 |
QCOMPARE(format.property("sizeHint").toSize(), sizeHint); |
|
467 |
} |
|
468 |
||
469 |
void tst_QVideoSurfaceFormat::staticPropertyNames() |
|
470 |
{ |
|
471 |
QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); |
|
472 |
||
473 |
QList<QByteArray> propertyNames = format.propertyNames(); |
|
474 |
||
475 |
QVERIFY(propertyNames.contains("handleType")); |
|
476 |
QVERIFY(propertyNames.contains("pixelFormat")); |
|
477 |
QVERIFY(propertyNames.contains("frameSize")); |
|
478 |
QVERIFY(propertyNames.contains("frameWidth")); |
|
479 |
QVERIFY(propertyNames.contains("viewport")); |
|
480 |
QVERIFY(propertyNames.contains("scanLineDirection")); |
|
481 |
QVERIFY(propertyNames.contains("frameRate")); |
|
482 |
QVERIFY(propertyNames.contains("pixelAspectRatio")); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
483 |
QVERIFY(propertyNames.contains("yCbCrColorSpace")); |
0 | 484 |
QVERIFY(propertyNames.contains("sizeHint")); |
485 |
QCOMPARE(propertyNames.count(), 10); |
|
486 |
} |
|
487 |
||
488 |
void tst_QVideoSurfaceFormat::dynamicProperty() |
|
489 |
{ |
|
490 |
QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); |
|
491 |
||
492 |
QCOMPARE(format.property("integer"), QVariant()); |
|
493 |
QCOMPARE(format.property("size"), QVariant()); |
|
494 |
QCOMPARE(format.property("string"), QVariant()); |
|
495 |
QCOMPARE(format.property("null"), QVariant()); |
|
496 |
||
497 |
QList<QByteArray> propertyNames = format.propertyNames(); |
|
498 |
||
499 |
QCOMPARE(propertyNames.count(QByteArray("integer")), 0); |
|
500 |
QCOMPARE(propertyNames.count(QByteArray("string")), 0); |
|
501 |
QCOMPARE(propertyNames.count(QByteArray("size")), 0); |
|
502 |
QCOMPARE(propertyNames.count(QByteArray("null")), 0); |
|
503 |
||
504 |
format.setProperty("string", QString::fromLatin1("Hello")); |
|
505 |
format.setProperty("integer", 198); |
|
506 |
format.setProperty("size", QSize(43, 65)); |
|
507 |
||
508 |
QCOMPARE(format.property("integer").toInt(), 198); |
|
509 |
QCOMPARE(format.property("size").toSize(), QSize(43, 65)); |
|
510 |
QCOMPARE(format.property("string").toString(), QString::fromLatin1("Hello")); |
|
511 |
||
512 |
propertyNames = format.propertyNames(); |
|
513 |
||
514 |
QCOMPARE(propertyNames.count(QByteArray("integer")), 1); |
|
515 |
QCOMPARE(propertyNames.count(QByteArray("string")), 1); |
|
516 |
QCOMPARE(propertyNames.count(QByteArray("size")), 1); |
|
517 |
||
518 |
format.setProperty("integer", 125423); |
|
519 |
format.setProperty("size", QSize(1, 986)); |
|
520 |
||
521 |
QCOMPARE(format.property("integer").toInt(), 125423); |
|
522 |
QCOMPARE(format.property("size").toSize(), QSize(1, 986)); |
|
523 |
QCOMPARE(format.property("string").toString(), QString::fromLatin1("Hello")); |
|
524 |
||
525 |
propertyNames = format.propertyNames(); |
|
526 |
||
527 |
QCOMPARE(propertyNames.count(QByteArray("integer")), 1); |
|
528 |
QCOMPARE(propertyNames.count(QByteArray("string")), 1); |
|
529 |
QCOMPARE(propertyNames.count(QByteArray("size")), 1); |
|
530 |
||
531 |
format.setProperty("string", QVariant()); |
|
532 |
format.setProperty("size", QVariant()); |
|
533 |
format.setProperty("null", QVariant()); |
|
534 |
||
535 |
QCOMPARE(format.property("integer").toInt(), 125423); |
|
536 |
QCOMPARE(format.property("size"), QVariant()); |
|
537 |
QCOMPARE(format.property("string"), QVariant()); |
|
538 |
QCOMPARE(format.property("null"), QVariant()); |
|
539 |
||
540 |
propertyNames = format.propertyNames(); |
|
541 |
||
542 |
QCOMPARE(propertyNames.count(QByteArray("integer")), 1); |
|
543 |
QCOMPARE(propertyNames.count(QByteArray("string")), 0); |
|
544 |
QCOMPARE(propertyNames.count(QByteArray("size")), 0); |
|
545 |
QCOMPARE(propertyNames.count(QByteArray("null")), 0); |
|
546 |
} |
|
547 |
||
548 |
void tst_QVideoSurfaceFormat::compare() |
|
549 |
{ |
|
550 |
QVideoSurfaceFormat format1( |
|
551 |
QSize(16, 16), QVideoFrame::Format_RGB32, QAbstractVideoBuffer::GLTextureHandle); |
|
552 |
QVideoSurfaceFormat format2( |
|
553 |
QSize(16, 16), QVideoFrame::Format_RGB32, QAbstractVideoBuffer::GLTextureHandle); |
|
554 |
QVideoSurfaceFormat format3( |
|
555 |
QSize(32, 32), QVideoFrame::Format_YUV444, QAbstractVideoBuffer::GLTextureHandle); |
|
556 |
QVideoSurfaceFormat format4( |
|
557 |
QSize(16, 16), QVideoFrame::Format_RGB32, QAbstractVideoBuffer::UserHandle); |
|
558 |
||
559 |
QCOMPARE(format1 == format2, true); |
|
560 |
QCOMPARE(format1 != format2, false); |
|
561 |
QCOMPARE(format1 == format3, false); |
|
562 |
QCOMPARE(format1 != format3, true); |
|
563 |
QCOMPARE(format1 == format4, false); |
|
564 |
QCOMPARE(format1 != format4, true); |
|
565 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
566 |
format2.setFrameSize(1024, 768); |
0 | 567 |
|
568 |
// Not equal, frame size differs. |
|
569 |
QCOMPARE(format1 == format2, false); |
|
570 |
QCOMPARE(format1 != format2, true); |
|
571 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
572 |
format1.setFrameSize(1024, 768); |
0 | 573 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
574 |
// Equal. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
575 |
QCOMPARE(format1 == format2, true); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
576 |
QCOMPARE(format1 != format2, false); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
577 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
578 |
format1.setViewport(QRect(0, 0, 800, 600)); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
579 |
format2.setViewport(QRect(112, 84, 800, 600)); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
580 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
581 |
// Not equal, viewports differ. |
0 | 582 |
QCOMPARE(format1 == format2, false); |
583 |
QCOMPARE(format1 != format2, true); |
|
584 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
585 |
format1.setViewport(QRect(112, 84, 800, 600)); |
0 | 586 |
|
587 |
// Equal. |
|
588 |
QCOMPARE(format1 == format2, true); |
|
589 |
QCOMPARE(format1 != format2, false); |
|
590 |
||
591 |
format2.setScanLineDirection(QVideoSurfaceFormat::BottomToTop); |
|
592 |
||
593 |
// Not equal scan line direction differs. |
|
594 |
QCOMPARE(format1 == format2, false); |
|
595 |
QCOMPARE(format1 != format2, true); |
|
596 |
||
597 |
format1.setScanLineDirection(QVideoSurfaceFormat::BottomToTop); |
|
598 |
||
599 |
// Equal. |
|
600 |
QCOMPARE(format1 == format2, true); |
|
601 |
QCOMPARE(format1 != format2, false); |
|
602 |
||
603 |
format1.setFrameRate(7.5); |
|
604 |
||
605 |
// Not equal frame rate differs. |
|
606 |
QCOMPARE(format1 == format2, false); |
|
607 |
QCOMPARE(format1 != format2, true); |
|
608 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
609 |
format2.setFrameRate(qreal(7.50001)); |
0 | 610 |
|
611 |
// Equal. |
|
612 |
QCOMPARE(format1 == format2, true); |
|
613 |
QCOMPARE(format1 != format2, false); |
|
614 |
||
615 |
format2.setPixelAspectRatio(4, 3); |
|
616 |
||
617 |
// Not equal pixel aspect ratio differs. |
|
618 |
QCOMPARE(format1 == format2, false); |
|
619 |
QCOMPARE(format1 != format2, true); |
|
620 |
||
621 |
format1.setPixelAspectRatio(QSize(4, 3)); |
|
622 |
||
623 |
// Equal. |
|
624 |
QCOMPARE(format1 == format2, true); |
|
625 |
QCOMPARE(format1 != format2, false); |
|
626 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
627 |
format2.setYCbCrColorSpace(QVideoSurfaceFormat::YCbCr_xvYCC601); |
0 | 628 |
|
629 |
// Not equal yuv color space differs. |
|
630 |
QCOMPARE(format1 == format2, false); |
|
631 |
QCOMPARE(format1 != format2, true); |
|
632 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
633 |
format1.setYCbCrColorSpace(QVideoSurfaceFormat::YCbCr_xvYCC601); |
0 | 634 |
|
635 |
// Equal. |
|
636 |
QCOMPARE(format1 == format2, true); |
|
637 |
QCOMPARE(format1 != format2, false); |
|
638 |
||
639 |
format1.setProperty("integer", 12); |
|
640 |
||
641 |
// Not equal, property mismatch. |
|
642 |
QCOMPARE(format1 == format2, false); |
|
643 |
QCOMPARE(format1 != format2, true); |
|
644 |
||
645 |
format2.setProperty("integer", 45); |
|
646 |
||
647 |
// Not equal, integer differs. |
|
648 |
QCOMPARE(format1 == format2, false); |
|
649 |
QCOMPARE(format1 != format2, true); |
|
650 |
||
651 |
format2.setProperty("integer", 12); |
|
652 |
||
653 |
// Equal. |
|
654 |
QCOMPARE(format1 == format2, true); |
|
655 |
QCOMPARE(format1 != format2, false); |
|
656 |
||
657 |
format1.setProperty("string", QString::fromLatin1("Hello")); |
|
658 |
format2.setProperty("size", QSize(12, 54)); |
|
659 |
||
660 |
// Not equal, property mismatch. |
|
661 |
QCOMPARE(format1 == format2, false); |
|
662 |
QCOMPARE(format1 != format2, true); |
|
663 |
||
664 |
format2.setProperty("string", QString::fromLatin1("Hello")); |
|
665 |
format1.setProperty("size", QSize(12, 54)); |
|
666 |
||
667 |
// Equal. |
|
668 |
QCOMPARE(format1 == format2, true); |
|
669 |
QCOMPARE(format1 != format2, false); |
|
670 |
||
671 |
format1.setProperty("string", QVariant()); |
|
672 |
||
673 |
// Not equal, property mismatch. |
|
674 |
QCOMPARE(format1 == format2, false); |
|
675 |
QCOMPARE(format1 != format2, true); |
|
676 |
} |
|
677 |
||
678 |
||
679 |
void tst_QVideoSurfaceFormat::copy() |
|
680 |
{ |
|
681 |
QVideoSurfaceFormat original( |
|
682 |
QSize(1024, 768), QVideoFrame::Format_ARGB32, QAbstractVideoBuffer::GLTextureHandle); |
|
683 |
original.setScanLineDirection(QVideoSurfaceFormat::BottomToTop); |
|
684 |
||
685 |
QVideoSurfaceFormat copy(original); |
|
686 |
||
687 |
QCOMPARE(copy.handleType(), QAbstractVideoBuffer::GLTextureHandle); |
|
688 |
QCOMPARE(copy.pixelFormat(), QVideoFrame::Format_ARGB32); |
|
689 |
QCOMPARE(copy.frameSize(), QSize(1024, 768)); |
|
690 |
QCOMPARE(copy.scanLineDirection(), QVideoSurfaceFormat::BottomToTop); |
|
691 |
||
692 |
QCOMPARE(original == copy, true); |
|
693 |
QCOMPARE(original != copy, false); |
|
694 |
||
695 |
copy.setScanLineDirection(QVideoSurfaceFormat::TopToBottom); |
|
696 |
||
697 |
QCOMPARE(copy.scanLineDirection(), QVideoSurfaceFormat::TopToBottom); |
|
698 |
||
699 |
QCOMPARE(original.scanLineDirection(), QVideoSurfaceFormat::BottomToTop); |
|
700 |
||
701 |
QCOMPARE(original == copy, false); |
|
702 |
QCOMPARE(original != copy, true); |
|
703 |
} |
|
704 |
||
705 |
void tst_QVideoSurfaceFormat::assign() |
|
706 |
{ |
|
707 |
QVideoSurfaceFormat copy( |
|
708 |
QSize(64, 64), QVideoFrame::Format_AYUV444, QAbstractVideoBuffer::UserHandle); |
|
709 |
||
710 |
QVideoSurfaceFormat original( |
|
711 |
QSize(1024, 768), QVideoFrame::Format_ARGB32, QAbstractVideoBuffer::GLTextureHandle); |
|
712 |
original.setScanLineDirection(QVideoSurfaceFormat::BottomToTop); |
|
713 |
||
714 |
copy = original; |
|
715 |
||
716 |
QCOMPARE(copy.handleType(), QAbstractVideoBuffer::GLTextureHandle); |
|
717 |
QCOMPARE(copy.pixelFormat(), QVideoFrame::Format_ARGB32); |
|
718 |
QCOMPARE(copy.frameSize(), QSize(1024, 768)); |
|
719 |
QCOMPARE(copy.scanLineDirection(), QVideoSurfaceFormat::BottomToTop); |
|
720 |
||
721 |
QCOMPARE(original == copy, true); |
|
722 |
QCOMPARE(original != copy, false); |
|
723 |
||
724 |
copy.setScanLineDirection(QVideoSurfaceFormat::TopToBottom); |
|
725 |
||
726 |
QCOMPARE(copy.scanLineDirection(), QVideoSurfaceFormat::TopToBottom); |
|
727 |
||
728 |
QCOMPARE(original.scanLineDirection(), QVideoSurfaceFormat::BottomToTop); |
|
729 |
||
730 |
QCOMPARE(original == copy, false); |
|
731 |
QCOMPARE(original != copy, true); |
|
732 |
} |
|
733 |
||
734 |
QTEST_MAIN(tst_QVideoSurfaceFormat) |
|
735 |
||
736 |
#include "tst_qvideosurfaceformat.moc" |