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