| 1 | /**************************************************************************** | 
| 2 | ** | 
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | 
| 4 | ** Contact: https://www.qt.io/licensing/ | 
| 5 | ** | 
| 6 | ** This file is part of the test suite of the Qt Toolkit. | 
| 7 | ** | 
| 8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ | 
| 9 | ** Commercial License Usage | 
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | 
| 11 | ** accordance with the commercial license agreement provided with the | 
| 12 | ** Software or, alternatively, in accordance with the terms contained in | 
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | 
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | 
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | 
| 16 | ** | 
| 17 | ** GNU General Public License Usage | 
| 18 | ** Alternatively, this file may be used under the terms of the GNU | 
| 19 | ** General Public License version 3 as published by the Free Software | 
| 20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT | 
| 21 | ** included in the packaging of this file. Please review the following | 
| 22 | ** information to ensure the GNU General Public License requirements will | 
| 23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | 
| 24 | ** | 
| 25 | ** $QT_END_LICENSE$ | 
| 26 | ** | 
| 27 | ****************************************************************************/ | 
| 28 |  | 
| 29 | //TESTED_COMPONENT=src/multimedia | 
| 30 |  | 
| 31 | #include <QtTest/QtTest> | 
| 32 |  | 
| 33 | #include <qvideosurfaceformat.h> | 
| 34 |  | 
| 35 | // Adds an enum, and the stringized version | 
| 36 | #define ADD_ENUM_TEST(x) \ | 
| 37 |     QTest::newRow(#x) \ | 
| 38 |         << QVideoSurfaceFormat::x \ | 
| 39 |     << QString(QLatin1String(#x)); | 
| 40 |  | 
| 41 | class tst_QVideoSurfaceFormat : public QObject | 
| 42 | { | 
| 43 |     Q_OBJECT | 
| 44 | public: | 
| 45 |     tst_QVideoSurfaceFormat(); | 
| 46 |     ~tst_QVideoSurfaceFormat(); | 
| 47 |  | 
| 48 | public slots: | 
| 49 |     void initTestCase(); | 
| 50 |     void cleanupTestCase(); | 
| 51 |     void init(); | 
| 52 |     void cleanup(); | 
| 53 |  | 
| 54 | private slots: | 
| 55 |     void constructNull(); | 
| 56 |     void construct_data(); | 
| 57 |     void construct(); | 
| 58 |     void frameSize_data(); | 
| 59 |     void frameSize(); | 
| 60 |     void viewport_data(); | 
| 61 |     void viewport(); | 
| 62 |     void scanLineDirection_data(); | 
| 63 |     void scanLineDirection(); | 
| 64 |     void frameRate_data(); | 
| 65 |     void frameRate(); | 
| 66 |     void pixelAspectRatio_data(); | 
| 67 |     void pixelAspectRatio(); | 
| 68 |     void sizeHint_data(); | 
| 69 |     void sizeHint(); | 
| 70 |     void yCbCrColorSpaceEnum_data(); | 
| 71 |     void yCbCrColorSpaceEnum (); | 
| 72 |     void staticPropertyNames(); | 
| 73 |     void dynamicProperty(); | 
| 74 |     void compare(); | 
| 75 |     void copy(); | 
| 76 |     void assign(); | 
| 77 |  | 
| 78 |     void isValid(); | 
| 79 |     void copyAllParameters (); | 
| 80 |     void assignAllParameters (); | 
| 81 |  | 
| 82 |     void propertyEdgeCases(); | 
| 83 | }; | 
| 84 |  | 
| 85 | tst_QVideoSurfaceFormat::tst_QVideoSurfaceFormat() | 
| 86 | { | 
| 87 | } | 
| 88 |  | 
| 89 | tst_QVideoSurfaceFormat::~tst_QVideoSurfaceFormat() | 
| 90 | { | 
| 91 | } | 
| 92 |  | 
| 93 | void tst_QVideoSurfaceFormat::initTestCase() | 
| 94 | { | 
| 95 | } | 
| 96 |  | 
| 97 | void tst_QVideoSurfaceFormat::cleanupTestCase() | 
| 98 | { | 
| 99 | } | 
| 100 |  | 
| 101 | void tst_QVideoSurfaceFormat::init() | 
| 102 | { | 
| 103 | } | 
| 104 |  | 
| 105 | void tst_QVideoSurfaceFormat::cleanup() | 
| 106 | { | 
| 107 | } | 
| 108 |  | 
| 109 | void tst_QVideoSurfaceFormat::constructNull() | 
| 110 | { | 
| 111 |     QVideoSurfaceFormat format; | 
| 112 |  | 
| 113 |     QVERIFY(!format.isValid()); | 
| 114 |     QCOMPARE(format.handleType(), QAbstractVideoBuffer::NoHandle); | 
| 115 |     QCOMPARE(format.pixelFormat(), QVideoFrame::Format_Invalid); | 
| 116 |     QCOMPARE(format.frameSize(), QSize()); | 
| 117 |     QCOMPARE(format.frameWidth(), -1); | 
| 118 |     QCOMPARE(format.frameHeight(), -1); | 
| 119 |     QCOMPARE(format.viewport(), QRect()); | 
| 120 |     QCOMPARE(format.scanLineDirection(), QVideoSurfaceFormat::TopToBottom); | 
| 121 |     QCOMPARE(format.frameRate(), 0.0); | 
| 122 |     QCOMPARE(format.pixelAspectRatio(), QSize(1, 1)); | 
| 123 |     QCOMPARE(format.yCbCrColorSpace(), QVideoSurfaceFormat::YCbCr_Undefined); | 
| 124 | } | 
| 125 |  | 
| 126 | void tst_QVideoSurfaceFormat::construct_data() | 
| 127 | { | 
| 128 |     QTest::addColumn<QSize>(name: "frameSize" ); | 
| 129 |     QTest::addColumn<QVideoFrame::PixelFormat>(name: "pixelFormat" ); | 
| 130 |     QTest::addColumn<QAbstractVideoBuffer::HandleType>(name: "handleType" ); | 
| 131 |     QTest::addColumn<bool>(name: "valid" ); | 
| 132 |  | 
| 133 |     QTest::newRow(dataTag: "32x32 rgb32 no handle" ) | 
| 134 |             << QSize(32, 32) | 
| 135 |             << QVideoFrame::Format_RGB32 | 
| 136 |             << QAbstractVideoBuffer::NoHandle | 
| 137 |             << true; | 
| 138 |  | 
| 139 |     QTest::newRow(dataTag: "1024x768 YUV444 GL texture" ) | 
| 140 |             << QSize(32, 32) | 
| 141 |             << QVideoFrame::Format_YUV444 | 
| 142 |             << QAbstractVideoBuffer::GLTextureHandle | 
| 143 |             << true; | 
| 144 |  | 
| 145 |     QTest::newRow(dataTag: "32x32 invalid no handle" ) | 
| 146 |             << QSize(32, 32) | 
| 147 |             << QVideoFrame::Format_Invalid | 
| 148 |             << QAbstractVideoBuffer::NoHandle | 
| 149 |             << false; | 
| 150 |  | 
| 151 |     QTest::newRow(dataTag: "invalid size, rgb32 no handle" ) | 
| 152 |             << QSize() | 
| 153 |             << QVideoFrame::Format_RGB32 | 
| 154 |             << QAbstractVideoBuffer::NoHandle | 
| 155 |             << false; | 
| 156 |  | 
| 157 |     QTest::newRow(dataTag: "0x0 rgb32 no handle" ) | 
| 158 |             << QSize(0,0) | 
| 159 |             << QVideoFrame::Format_RGB32 | 
| 160 |             << QAbstractVideoBuffer::NoHandle | 
| 161 |             << true; | 
| 162 | } | 
| 163 |  | 
| 164 | void tst_QVideoSurfaceFormat::construct() | 
| 165 | { | 
| 166 |     QFETCH(QSize, frameSize); | 
| 167 |     QFETCH(QVideoFrame::PixelFormat, pixelFormat); | 
| 168 |     QFETCH(QAbstractVideoBuffer::HandleType, handleType); | 
| 169 |     QFETCH(bool, valid); | 
| 170 |  | 
| 171 |     QRect viewport(QPoint(0, 0), frameSize); | 
| 172 |  | 
| 173 |     QVideoSurfaceFormat format(frameSize, pixelFormat, handleType); | 
| 174 |  | 
| 175 |     QCOMPARE(format.handleType(), handleType); | 
| 176 |     QCOMPARE(format.property("handleType" ).value<QAbstractVideoBuffer::HandleType>(), handleType); | 
| 177 |     QCOMPARE(format.pixelFormat(), pixelFormat); | 
| 178 |     QCOMPARE(format.property("pixelFormat" ).value<QVideoFrame::PixelFormat>(), pixelFormat); | 
| 179 |     QCOMPARE(format.frameSize(), frameSize); | 
| 180 |     QCOMPARE(format.frameWidth(), frameSize.width()); | 
| 181 |     QCOMPARE(format.property("frameWidth" ).toInt(), frameSize.width()); | 
| 182 |     QCOMPARE(format.frameHeight(), frameSize.height()); | 
| 183 |     QCOMPARE(format.property("frameHeight" ).toInt(), frameSize.height()); | 
| 184 |     QCOMPARE(format.isValid(), valid); | 
| 185 |     QCOMPARE(format.viewport(), viewport); | 
| 186 |     QCOMPARE(format.scanLineDirection(), QVideoSurfaceFormat::TopToBottom); | 
| 187 |     QCOMPARE(format.frameRate(), 0.0); | 
| 188 |     QCOMPARE(format.pixelAspectRatio(), QSize(1, 1)); | 
| 189 |     QCOMPARE(format.yCbCrColorSpace(), QVideoSurfaceFormat::YCbCr_Undefined); | 
| 190 | } | 
| 191 |  | 
| 192 | void tst_QVideoSurfaceFormat::frameSize_data() | 
| 193 | { | 
| 194 |     QTest::addColumn<QSize>(name: "initialSize" ); | 
| 195 |     QTest::addColumn<QSize>(name: "newSize" ); | 
| 196 |  | 
| 197 |     QTest::newRow(dataTag: "grow" ) | 
| 198 |             << QSize(64, 64) | 
| 199 |             << QSize(1024, 1024); | 
| 200 |     QTest::newRow(dataTag: "shrink" ) | 
| 201 |             << QSize(1024, 1024) | 
| 202 |             << QSize(64, 64); | 
| 203 |     QTest::newRow(dataTag: "unchanged" ) | 
| 204 |             << QSize(512, 512) | 
| 205 |             << QSize(512, 512); | 
| 206 | } | 
| 207 |  | 
| 208 | void tst_QVideoSurfaceFormat::frameSize() | 
| 209 | { | 
| 210 |     QFETCH(QSize, initialSize); | 
| 211 |     QFETCH(QSize, newSize); | 
| 212 |  | 
| 213 |     { | 
| 214 |         QVideoSurfaceFormat format(initialSize, QVideoFrame::Format_RGB32); | 
| 215 |  | 
| 216 |         format.setFrameSize(newSize); | 
| 217 |  | 
| 218 |         QCOMPARE(format.frameSize(), newSize); | 
| 219 |         QCOMPARE(format.property("frameSize" ).toSize(), newSize); | 
| 220 |         QCOMPARE(format.frameWidth(), newSize.width()); | 
| 221 |         QCOMPARE(format.property("frameWidth" ).toInt(), newSize.width()); | 
| 222 |         QCOMPARE(format.frameHeight(), newSize.height()); | 
| 223 |         QCOMPARE(format.property("frameHeight" ).toInt(), newSize.height()); | 
| 224 |     } | 
| 225 |  | 
| 226 |     { | 
| 227 |         QVideoSurfaceFormat format(initialSize, QVideoFrame::Format_RGB32); | 
| 228 |  | 
| 229 |         format.setProperty(name: "frameSize" , value: newSize); | 
| 230 |  | 
| 231 |         QCOMPARE(format.frameSize(), newSize); | 
| 232 |         QCOMPARE(format.property("frameSize" ).toSize(), newSize); | 
| 233 |         QCOMPARE(format.frameWidth(), newSize.width()); | 
| 234 |         QCOMPARE(format.property("frameWidth" ).toInt(), newSize.width()); | 
| 235 |         QCOMPARE(format.frameHeight(), newSize.height()); | 
| 236 |         QCOMPARE(format.property("frameHeight" ).toInt(), newSize.height()); | 
| 237 |     } | 
| 238 |  | 
| 239 | } | 
| 240 |  | 
| 241 | void tst_QVideoSurfaceFormat::viewport_data() | 
| 242 | { | 
| 243 |     QTest::addColumn<QSize>(name: "initialSize" ); | 
| 244 |     QTest::addColumn<QRect>(name: "viewport" ); | 
| 245 |     QTest::addColumn<QSize>(name: "newSize" ); | 
| 246 |     QTest::addColumn<QRect>(name: "expectedViewport" ); | 
| 247 |  | 
| 248 |     QTest::newRow(dataTag: "grow reset" ) | 
| 249 |             << QSize(64, 64) | 
| 250 |             << QRect(8, 8, 48, 48) | 
| 251 |             << QSize(1024, 1024) | 
| 252 |             << QRect(0, 0, 1024, 1024); | 
| 253 |     QTest::newRow(dataTag: "shrink reset" ) | 
| 254 |             << QSize(1024, 1024) | 
| 255 |             << QRect(8, 8, 1008, 1008) | 
| 256 |             << QSize(64, 64) | 
| 257 |             << QRect(0, 0, 64, 64); | 
| 258 |     QTest::newRow(dataTag: "unchanged reset" ) | 
| 259 |             << QSize(512, 512) | 
| 260 |             << QRect(8, 8, 496, 496) | 
| 261 |             << QSize(512, 512) | 
| 262 |             << QRect(0, 0, 512, 512); | 
| 263 | } | 
| 264 |  | 
| 265 | void tst_QVideoSurfaceFormat::viewport() | 
| 266 | { | 
| 267 |     QFETCH(QSize, initialSize); | 
| 268 |     QFETCH(QRect, viewport); | 
| 269 |     QFETCH(QSize, newSize); | 
| 270 |     QFETCH(QRect, expectedViewport); | 
| 271 |  | 
| 272 |     { | 
| 273 |         QRect initialViewport(QPoint(0, 0), initialSize); | 
| 274 |  | 
| 275 |         QVideoSurfaceFormat format(initialSize, QVideoFrame::Format_RGB32); | 
| 276 |  | 
| 277 |         format.setViewport(viewport); | 
| 278 |  | 
| 279 |         QCOMPARE(format.viewport(), viewport); | 
| 280 |         QCOMPARE(format.property("viewport" ).toRect(), viewport); | 
| 281 |  | 
| 282 |         format.setFrameSize(newSize); | 
| 283 |  | 
| 284 |         QCOMPARE(format.viewport(), expectedViewport); | 
| 285 |         QCOMPARE(format.property("viewport" ).toRect(), expectedViewport); | 
| 286 |     } | 
| 287 |     { | 
| 288 |         QVideoSurfaceFormat format(initialSize, QVideoFrame::Format_RGB32); | 
| 289 |  | 
| 290 |         format.setProperty(name: "viewport" , value: viewport); | 
| 291 |  | 
| 292 |         QCOMPARE(format.viewport(), viewport); | 
| 293 |         QCOMPARE(format.property("viewport" ).toRect(), viewport); | 
| 294 |     } | 
| 295 | } | 
| 296 |  | 
| 297 | void tst_QVideoSurfaceFormat::scanLineDirection_data() | 
| 298 | { | 
| 299 |     QTest::addColumn<QVideoSurfaceFormat::Direction>(name: "direction" ); | 
| 300 |     QTest::addColumn<QString>(name: "stringized" ); | 
| 301 |  | 
| 302 |     ADD_ENUM_TEST(TopToBottom); | 
| 303 |     ADD_ENUM_TEST(BottomToTop); | 
| 304 | } | 
| 305 |  | 
| 306 | void tst_QVideoSurfaceFormat::scanLineDirection() | 
| 307 | { | 
| 308 |     QFETCH(QVideoSurfaceFormat::Direction, direction); | 
| 309 |     QFETCH(QString, stringized); | 
| 310 |  | 
| 311 |     { | 
| 312 |         QVideoSurfaceFormat format(QSize(16, 16), QVideoFrame::Format_RGB32); | 
| 313 |  | 
| 314 |         format.setScanLineDirection(direction); | 
| 315 |  | 
| 316 |         QCOMPARE(format.scanLineDirection(), direction); | 
| 317 |         QCOMPARE( | 
| 318 |                 qvariant_cast<QVideoSurfaceFormat::Direction>(format.property("scanLineDirection" )), | 
| 319 |                 direction); | 
| 320 |     } | 
| 321 |     { | 
| 322 |         QVideoSurfaceFormat format(QSize(16, 16), QVideoFrame::Format_RGB32); | 
| 323 |  | 
| 324 |         format.setProperty(name: "scanLineDirection" , value: QVariant::fromValue(value: direction)); | 
| 325 |  | 
| 326 |         QCOMPARE(format.scanLineDirection(), direction); | 
| 327 |         QCOMPARE( | 
| 328 |                 qvariant_cast<QVideoSurfaceFormat::Direction>(format.property("scanLineDirection" )), | 
| 329 |                 direction); | 
| 330 |     } | 
| 331 |  | 
| 332 |     QTest::ignoreMessage(type: QtDebugMsg, message: stringized.toLatin1().constData()); | 
| 333 |     qDebug() << direction; | 
| 334 | } | 
| 335 |  | 
| 336 | void tst_QVideoSurfaceFormat::yCbCrColorSpaceEnum_data() | 
| 337 | { | 
| 338 |     QTest::addColumn<QVideoSurfaceFormat::YCbCrColorSpace>(name: "colorspace" ); | 
| 339 |     QTest::addColumn<QString>(name: "stringized" ); | 
| 340 |  | 
| 341 |     ADD_ENUM_TEST(YCbCr_BT601); | 
| 342 |     ADD_ENUM_TEST(YCbCr_BT709); | 
| 343 |     ADD_ENUM_TEST(YCbCr_xvYCC601); | 
| 344 |     ADD_ENUM_TEST(YCbCr_xvYCC709); | 
| 345 |     ADD_ENUM_TEST(YCbCr_JPEG); | 
| 346 |     ADD_ENUM_TEST(YCbCr_CustomMatrix); | 
| 347 |     ADD_ENUM_TEST(YCbCr_Undefined); | 
| 348 | } | 
| 349 |  | 
| 350 | /* Test case for Enum YCbCr_BT601, YCbCr_xvYCC709 */ | 
| 351 | void tst_QVideoSurfaceFormat::yCbCrColorSpaceEnum() | 
| 352 | { | 
| 353 |     QFETCH(QVideoSurfaceFormat::YCbCrColorSpace, colorspace); | 
| 354 |     QFETCH(QString, stringized); | 
| 355 |  | 
| 356 |     { | 
| 357 |         QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); | 
| 358 |         format.setYCbCrColorSpace(colorspace); | 
| 359 |  | 
| 360 |         QCOMPARE(format.yCbCrColorSpace(), colorspace); | 
| 361 |         QCOMPARE(qvariant_cast<QVideoSurfaceFormat::YCbCrColorSpace>(format.property("yCbCrColorSpace" )), | 
| 362 |                 colorspace); | 
| 363 |     } | 
| 364 |     { | 
| 365 |         QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); | 
| 366 |         format.setProperty(name: "yCbCrColorSpace" , value: QVariant::fromValue(value: colorspace)); | 
| 367 |  | 
| 368 |         QCOMPARE(format.yCbCrColorSpace(), colorspace); | 
| 369 |         QCOMPARE(qvariant_cast<QVideoSurfaceFormat::YCbCrColorSpace>(format.property("yCbCrColorSpace" )), | 
| 370 |                 colorspace); | 
| 371 |     } | 
| 372 |  | 
| 373 |     QTest::ignoreMessage(type: QtDebugMsg, message: stringized.toLatin1().constData()); | 
| 374 |     qDebug() << colorspace; | 
| 375 | } | 
| 376 |  | 
| 377 |  | 
| 378 | void tst_QVideoSurfaceFormat::frameRate_data() | 
| 379 | { | 
| 380 |     QTest::addColumn<qreal>(name: "frameRate" ); | 
| 381 |  | 
| 382 |     QTest::newRow(dataTag: "null" ) | 
| 383 |             << qreal(0.0); | 
| 384 |     QTest::newRow(dataTag: "1/1" ) | 
| 385 |             << qreal(1.0); | 
| 386 |     QTest::newRow(dataTag: "24/1" ) | 
| 387 |             << qreal(24.0); | 
| 388 |     QTest::newRow(dataTag: "15/2" ) | 
| 389 |             << qreal(7.5); | 
| 390 | } | 
| 391 |  | 
| 392 | void tst_QVideoSurfaceFormat::frameRate() | 
| 393 | { | 
| 394 |     QFETCH(qreal, frameRate); | 
| 395 |  | 
| 396 |     { | 
| 397 |         QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); | 
| 398 |  | 
| 399 |         format.setFrameRate(frameRate); | 
| 400 |  | 
| 401 |         QCOMPARE(format.frameRate(), frameRate); | 
| 402 |         QCOMPARE(qvariant_cast<qreal>(format.property("frameRate" )), frameRate); | 
| 403 |     } | 
| 404 |     { | 
| 405 |         QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); | 
| 406 |  | 
| 407 |         format.setFrameRate(frameRate); | 
| 408 |         format.setProperty(name: "frameRate" , value: frameRate); | 
| 409 |  | 
| 410 |         QCOMPARE(format.frameRate(), frameRate); | 
| 411 |         QCOMPARE(qvariant_cast<qreal>(format.property("frameRate" )), frameRate); | 
| 412 |     } | 
| 413 | } | 
| 414 |  | 
| 415 | void tst_QVideoSurfaceFormat::pixelAspectRatio_data() | 
| 416 | { | 
| 417 |     QTest::addColumn<QSize>(name: "aspectRatio" ); | 
| 418 |  | 
| 419 |     QTest::newRow(dataTag: "1:1" ) | 
| 420 |             << QSize(1, 1); | 
| 421 |     QTest::newRow(dataTag: "4:3" ) | 
| 422 |             << QSize(4, 3); | 
| 423 |     QTest::newRow(dataTag: "16:9" ) | 
| 424 |             << QSize(16, 9); | 
| 425 | } | 
| 426 |  | 
| 427 | void tst_QVideoSurfaceFormat::pixelAspectRatio() | 
| 428 | { | 
| 429 |     QFETCH(QSize, aspectRatio); | 
| 430 |  | 
| 431 |     { | 
| 432 |         QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); | 
| 433 |         format.setPixelAspectRatio(aspectRatio); | 
| 434 |  | 
| 435 |         QCOMPARE(format.pixelAspectRatio(), aspectRatio); | 
| 436 |         QCOMPARE(format.property("pixelAspectRatio" ).toSize(), aspectRatio); | 
| 437 |     } | 
| 438 |     { | 
| 439 |         QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); | 
| 440 |         format.setPixelAspectRatio(width: aspectRatio.width(), height: aspectRatio.height()); | 
| 441 |  | 
| 442 |         QCOMPARE(format.pixelAspectRatio(), aspectRatio); | 
| 443 |         QCOMPARE(format.property("pixelAspectRatio" ).toSize(), aspectRatio); | 
| 444 |     } | 
| 445 |     { | 
| 446 |         QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); | 
| 447 |         format.setProperty(name: "pixelAspectRatio" , value: aspectRatio); | 
| 448 |  | 
| 449 |         QCOMPARE(format.pixelAspectRatio(), aspectRatio); | 
| 450 |         QCOMPARE(format.property("pixelAspectRatio" ).toSize(), aspectRatio); | 
| 451 |     } | 
| 452 | } | 
| 453 |  | 
| 454 | void tst_QVideoSurfaceFormat::sizeHint_data() | 
| 455 | { | 
| 456 |     QTest::addColumn<QSize>(name: "frameSize" ); | 
| 457 |     QTest::addColumn<QRect>(name: "viewport" ); | 
| 458 |     QTest::addColumn<QSize>(name: "aspectRatio" ); | 
| 459 |     QTest::addColumn<QSize>(name: "sizeHint" ); | 
| 460 |  | 
| 461 |     QTest::newRow(dataTag: "(0, 0, 1024x768), 1:1" ) | 
| 462 |             << QSize(1024, 768) | 
| 463 |             << QRect(0, 0, 1024, 768) | 
| 464 |             << QSize(1, 1) | 
| 465 |             << QSize(1024, 768); | 
| 466 |     QTest::newRow(dataTag: "0, 0, 1024x768), 4:3" ) | 
| 467 |             << QSize(1024, 768) | 
| 468 |             << QRect(0, 0, 1024, 768) | 
| 469 |             << QSize(4, 3) | 
| 470 |             << QSize(1365, 768); | 
| 471 |     QTest::newRow(dataTag: "(168, 84, 800x600), 1:1" ) | 
| 472 |         << QSize(1024, 768) | 
| 473 |         << QRect(168, 84, 800, 600) | 
| 474 |         << QSize(1, 1) | 
| 475 |         << QSize(800, 600); | 
| 476 |     QTest::newRow(dataTag: "(168, 84, 800x600), 4:3" ) | 
| 477 |         << QSize(1024, 768) | 
| 478 |         << QRect(168, 84, 800, 600) | 
| 479 |         << QSize(4, 3) | 
| 480 |         << QSize(1066, 600); | 
| 481 |     QTest::newRow(dataTag: "(168, 84, 800x600), 4:0" ) | 
| 482 |         << QSize(1024, 768) | 
| 483 |         << QRect(168, 84, 800, 600) | 
| 484 |         << QSize(4, 0) | 
| 485 |         << QSize(800, 600); | 
| 486 | } | 
| 487 |  | 
| 488 | void tst_QVideoSurfaceFormat::sizeHint() | 
| 489 | { | 
| 490 |     QFETCH(QSize, frameSize); | 
| 491 |     QFETCH(QRect, viewport); | 
| 492 |     QFETCH(QSize, aspectRatio); | 
| 493 |     QFETCH(QSize, sizeHint); | 
| 494 |  | 
| 495 |     QVideoSurfaceFormat format(frameSize, QVideoFrame::Format_RGB32); | 
| 496 |     format.setViewport(viewport); | 
| 497 |     format.setPixelAspectRatio(aspectRatio); | 
| 498 |  | 
| 499 |     QCOMPARE(format.sizeHint(), sizeHint); | 
| 500 |     QCOMPARE(format.property("sizeHint" ).toSize(), sizeHint); | 
| 501 | } | 
| 502 |  | 
| 503 | void tst_QVideoSurfaceFormat::staticPropertyNames() | 
| 504 | { | 
| 505 |     QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); | 
| 506 |  | 
| 507 |     QList<QByteArray> propertyNames = format.propertyNames(); | 
| 508 |  | 
| 509 |     QVERIFY(propertyNames.contains("handleType" )); | 
| 510 |     QVERIFY(propertyNames.contains("pixelFormat" )); | 
| 511 |     QVERIFY(propertyNames.contains("frameSize" )); | 
| 512 |     QVERIFY(propertyNames.contains("frameWidth" )); | 
| 513 |     QVERIFY(propertyNames.contains("viewport" )); | 
| 514 |     QVERIFY(propertyNames.contains("scanLineDirection" )); | 
| 515 |     QVERIFY(propertyNames.contains("frameRate" )); | 
| 516 |     QVERIFY(propertyNames.contains("pixelAspectRatio" )); | 
| 517 |     QVERIFY(propertyNames.contains("yCbCrColorSpace" )); | 
| 518 |     QVERIFY(propertyNames.contains("sizeHint" )); | 
| 519 |     QVERIFY(propertyNames.contains("mirrored" )); | 
| 520 |     QCOMPARE(propertyNames.count(), 11); | 
| 521 | } | 
| 522 |  | 
| 523 | void tst_QVideoSurfaceFormat::dynamicProperty() | 
| 524 | { | 
| 525 |     QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); | 
| 526 |  | 
| 527 |     QCOMPARE(format.property("integer" ), QVariant()); | 
| 528 |     QCOMPARE(format.property("size" ), QVariant()); | 
| 529 |     QCOMPARE(format.property("string" ), QVariant()); | 
| 530 |     QCOMPARE(format.property("null" ), QVariant()); | 
| 531 |  | 
| 532 |     QList<QByteArray> propertyNames = format.propertyNames(); | 
| 533 |  | 
| 534 |     QCOMPARE(propertyNames.count(QByteArray("integer" )), 0); | 
| 535 |     QCOMPARE(propertyNames.count(QByteArray("string" )), 0); | 
| 536 |     QCOMPARE(propertyNames.count(QByteArray("size" )), 0); | 
| 537 |     QCOMPARE(propertyNames.count(QByteArray("null" )), 0); | 
| 538 |  | 
| 539 |     format.setProperty(name: "string" , value: QString::fromLatin1(str: "Hello" )); | 
| 540 |     format.setProperty(name: "integer" , value: 198); | 
| 541 |     format.setProperty(name: "size" , value: QSize(43, 65)); | 
| 542 |  | 
| 543 |     QCOMPARE(format.property("integer" ).toInt(), 198); | 
| 544 |     QCOMPARE(format.property("size" ).toSize(), QSize(43, 65)); | 
| 545 |     QCOMPARE(format.property("string" ).toString(), QString::fromLatin1("Hello" )); | 
| 546 |  | 
| 547 |     propertyNames = format.propertyNames(); | 
| 548 |  | 
| 549 |     QCOMPARE(propertyNames.count(QByteArray("integer" )), 1); | 
| 550 |     QCOMPARE(propertyNames.count(QByteArray("string" )), 1); | 
| 551 |     QCOMPARE(propertyNames.count(QByteArray("size" )), 1); | 
| 552 |  | 
| 553 |     format.setProperty(name: "integer" , value: 125423); | 
| 554 |     format.setProperty(name: "size" , value: QSize(1, 986)); | 
| 555 |  | 
| 556 |     QCOMPARE(format.property("integer" ).toInt(), 125423); | 
| 557 |     QCOMPARE(format.property("size" ).toSize(), QSize(1, 986)); | 
| 558 |     QCOMPARE(format.property("string" ).toString(), QString::fromLatin1("Hello" )); | 
| 559 |  | 
| 560 |     propertyNames = format.propertyNames(); | 
| 561 |  | 
| 562 |     QCOMPARE(propertyNames.count(QByteArray("integer" )), 1); | 
| 563 |     QCOMPARE(propertyNames.count(QByteArray("string" )), 1); | 
| 564 |     QCOMPARE(propertyNames.count(QByteArray("size" )), 1); | 
| 565 |  | 
| 566 |     format.setProperty(name: "string" , value: QVariant()); | 
| 567 |     format.setProperty(name: "size" , value: QVariant()); | 
| 568 |     format.setProperty(name: "null" , value: QVariant()); | 
| 569 |  | 
| 570 |     QCOMPARE(format.property("integer" ).toInt(), 125423); | 
| 571 |     QCOMPARE(format.property("size" ), QVariant()); | 
| 572 |     QCOMPARE(format.property("string" ), QVariant()); | 
| 573 |     QCOMPARE(format.property("null" ), QVariant()); | 
| 574 |  | 
| 575 |     propertyNames = format.propertyNames(); | 
| 576 |  | 
| 577 |     QCOMPARE(propertyNames.count(QByteArray("integer" )), 1); | 
| 578 |     QCOMPARE(propertyNames.count(QByteArray("string" )), 0); | 
| 579 |     QCOMPARE(propertyNames.count(QByteArray("size" )), 0); | 
| 580 |     QCOMPARE(propertyNames.count(QByteArray("null" )), 0); | 
| 581 | } | 
| 582 |  | 
| 583 | void tst_QVideoSurfaceFormat::compare() | 
| 584 | { | 
| 585 |     QVideoSurfaceFormat format1( | 
| 586 |             QSize(16, 16), QVideoFrame::Format_RGB32, QAbstractVideoBuffer::GLTextureHandle); | 
| 587 |     QVideoSurfaceFormat format2( | 
| 588 |             QSize(16, 16), QVideoFrame::Format_RGB32, QAbstractVideoBuffer::GLTextureHandle); | 
| 589 |     QVideoSurfaceFormat format3( | 
| 590 |             QSize(32, 32), QVideoFrame::Format_YUV444, QAbstractVideoBuffer::GLTextureHandle); | 
| 591 |     QVideoSurfaceFormat format4( | 
| 592 |             QSize(16, 16), QVideoFrame::Format_RGB32, QAbstractVideoBuffer::UserHandle); | 
| 593 |  | 
| 594 |     QCOMPARE(format1 == format2, true); | 
| 595 |     QCOMPARE(format1 != format2, false); | 
| 596 |     QCOMPARE(format1 == format3, false); | 
| 597 |     QCOMPARE(format1 != format3, true); | 
| 598 |     QCOMPARE(format1 == format4, false); | 
| 599 |     QCOMPARE(format1 != format4, true); | 
| 600 |  | 
| 601 |     format2.setFrameSize(width: 1024, height: 768); | 
| 602 |  | 
| 603 |     // Not equal, frame size differs. | 
| 604 |     QCOMPARE(format1 == format2, false); | 
| 605 |     QCOMPARE(format1 != format2, true); | 
| 606 |  | 
| 607 |     format1.setFrameSize(width: 1024, height: 768); | 
| 608 |  | 
| 609 |     // Equal. | 
| 610 |     QCOMPARE(format1 == format2, true); | 
| 611 |     QCOMPARE(format1 != format2, false); | 
| 612 |  | 
| 613 |     format1.setViewport(QRect(0, 0, 800, 600)); | 
| 614 |     format2.setViewport(QRect(112, 84, 800, 600)); | 
| 615 |  | 
| 616 |     // Not equal, viewports differ. | 
| 617 |     QCOMPARE(format1 == format2, false); | 
| 618 |     QCOMPARE(format1 != format2, true); | 
| 619 |  | 
| 620 |     format1.setViewport(QRect(112, 84, 800, 600)); | 
| 621 |  | 
| 622 |     // Equal. | 
| 623 |     QCOMPARE(format1 == format2, true); | 
| 624 |     QCOMPARE(format1 != format2, false); | 
| 625 |  | 
| 626 |     format2.setScanLineDirection(QVideoSurfaceFormat::BottomToTop); | 
| 627 |  | 
| 628 |     // Not equal scan line direction differs. | 
| 629 |     QCOMPARE(format1 == format2, false); | 
| 630 |     QCOMPARE(format1 != format2, true); | 
| 631 |  | 
| 632 |     format1.setScanLineDirection(QVideoSurfaceFormat::BottomToTop); | 
| 633 |  | 
| 634 |     // Equal. | 
| 635 |     QCOMPARE(format1 == format2, true); | 
| 636 |     QCOMPARE(format1 != format2, false); | 
| 637 |  | 
| 638 |     format1.setFrameRate(7.5); | 
| 639 |  | 
| 640 |     // Not equal frame rate differs. | 
| 641 |     QCOMPARE(format1 == format2, false); | 
| 642 |     QCOMPARE(format1 != format2, true); | 
| 643 |  | 
| 644 |     format2.setFrameRate(qreal(7.50001)); | 
| 645 |  | 
| 646 |     // Equal. | 
| 647 |     QCOMPARE(format1 == format2, true); | 
| 648 |     QCOMPARE(format1 != format2, false); | 
| 649 |  | 
| 650 |     format2.setPixelAspectRatio(width: 4, height: 3); | 
| 651 |  | 
| 652 |     // Not equal pixel aspect ratio differs. | 
| 653 |     QCOMPARE(format1 == format2, false); | 
| 654 |     QCOMPARE(format1 != format2, true); | 
| 655 |  | 
| 656 |     format1.setPixelAspectRatio(QSize(4, 3)); | 
| 657 |  | 
| 658 |     // Equal. | 
| 659 |     QCOMPARE(format1 == format2, true); | 
| 660 |     QCOMPARE(format1 != format2, false); | 
| 661 |  | 
| 662 |     format2.setYCbCrColorSpace(QVideoSurfaceFormat::YCbCr_xvYCC601); | 
| 663 |  | 
| 664 |     // Not equal yuv color space differs. | 
| 665 |     QCOMPARE(format1 == format2, false); | 
| 666 |     QCOMPARE(format1 != format2, true); | 
| 667 |  | 
| 668 |     format1.setYCbCrColorSpace(QVideoSurfaceFormat::YCbCr_xvYCC601); | 
| 669 |  | 
| 670 |     // Equal. | 
| 671 |     QCOMPARE(format1 == format2, true); | 
| 672 |     QCOMPARE(format1 != format2, false); | 
| 673 |  | 
| 674 |     format1.setProperty(name: "integer" , value: 12); | 
| 675 |  | 
| 676 |     // Not equal, property mismatch. | 
| 677 |     QCOMPARE(format1 == format2, false); | 
| 678 |     QCOMPARE(format1 != format2, true); | 
| 679 |  | 
| 680 |     format2.setProperty(name: "integer" , value: 45); | 
| 681 |  | 
| 682 |     // Not equal, integer differs. | 
| 683 |     QCOMPARE(format1 == format2, false); | 
| 684 |     QCOMPARE(format1 != format2, true); | 
| 685 |  | 
| 686 |     format2.setProperty(name: "integer" , value: 12); | 
| 687 |  | 
| 688 |     // Equal. | 
| 689 |     QCOMPARE(format1 == format2, true); | 
| 690 |     QCOMPARE(format1 != format2, false); | 
| 691 |  | 
| 692 |     format1.setProperty(name: "string" , value: QString::fromLatin1(str: "Hello" )); | 
| 693 |     format2.setProperty(name: "size" , value: QSize(12, 54)); | 
| 694 |  | 
| 695 |     // Not equal, property mismatch. | 
| 696 |     QCOMPARE(format1 == format2, false); | 
| 697 |     QCOMPARE(format1 != format2, true); | 
| 698 |  | 
| 699 |     format2.setProperty(name: "string" , value: QString::fromLatin1(str: "Hello" )); | 
| 700 |     format1.setProperty(name: "size" , value: QSize(12, 54)); | 
| 701 |  | 
| 702 |     // Equal. | 
| 703 |     QCOMPARE(format1 == format2, true); | 
| 704 |     QCOMPARE(format1 != format2, false); | 
| 705 |  | 
| 706 |     format1.setProperty(name: "string" , value: QVariant()); | 
| 707 |  | 
| 708 |     // Not equal, property mismatch. | 
| 709 |     QCOMPARE(format1 == format2, false); | 
| 710 |     QCOMPARE(format1 != format2, true); | 
| 711 | } | 
| 712 |  | 
| 713 |  | 
| 714 | void tst_QVideoSurfaceFormat::copy() | 
| 715 | { | 
| 716 |     QVideoSurfaceFormat original( | 
| 717 |             QSize(1024, 768), QVideoFrame::Format_ARGB32, QAbstractVideoBuffer::GLTextureHandle); | 
| 718 |     original.setScanLineDirection(QVideoSurfaceFormat::BottomToTop); | 
| 719 |  | 
| 720 |     QVideoSurfaceFormat copy(original); | 
| 721 |  | 
| 722 |     QCOMPARE(copy.handleType(), QAbstractVideoBuffer::GLTextureHandle); | 
| 723 |     QCOMPARE(copy.pixelFormat(), QVideoFrame::Format_ARGB32); | 
| 724 |     QCOMPARE(copy.frameSize(), QSize(1024, 768)); | 
| 725 |     QCOMPARE(copy.scanLineDirection(), QVideoSurfaceFormat::BottomToTop); | 
| 726 |  | 
| 727 |     QCOMPARE(original == copy, true); | 
| 728 |     QCOMPARE(original != copy, false); | 
| 729 |  | 
| 730 |     copy.setScanLineDirection(QVideoSurfaceFormat::TopToBottom); | 
| 731 |  | 
| 732 |     QCOMPARE(copy.scanLineDirection(), QVideoSurfaceFormat::TopToBottom); | 
| 733 |  | 
| 734 |     QCOMPARE(original.scanLineDirection(), QVideoSurfaceFormat::BottomToTop); | 
| 735 |  | 
| 736 |     QCOMPARE(original == copy, false); | 
| 737 |     QCOMPARE(original != copy, true); | 
| 738 | } | 
| 739 |  | 
| 740 | void tst_QVideoSurfaceFormat::assign() | 
| 741 | { | 
| 742 |     QVideoSurfaceFormat copy( | 
| 743 |             QSize(64, 64), QVideoFrame::Format_AYUV444, QAbstractVideoBuffer::UserHandle); | 
| 744 |  | 
| 745 |     QVideoSurfaceFormat original( | 
| 746 |             QSize(1024, 768), QVideoFrame::Format_ARGB32, QAbstractVideoBuffer::GLTextureHandle); | 
| 747 |     original.setScanLineDirection(QVideoSurfaceFormat::BottomToTop); | 
| 748 |  | 
| 749 |     copy = original; | 
| 750 |  | 
| 751 |     QCOMPARE(copy.handleType(), QAbstractVideoBuffer::GLTextureHandle); | 
| 752 |     QCOMPARE(copy.pixelFormat(), QVideoFrame::Format_ARGB32); | 
| 753 |     QCOMPARE(copy.frameSize(), QSize(1024, 768)); | 
| 754 |     QCOMPARE(copy.scanLineDirection(), QVideoSurfaceFormat::BottomToTop); | 
| 755 |  | 
| 756 |     QCOMPARE(original == copy, true); | 
| 757 |     QCOMPARE(original != copy, false); | 
| 758 |  | 
| 759 |     copy.setScanLineDirection(QVideoSurfaceFormat::TopToBottom); | 
| 760 |  | 
| 761 |     QCOMPARE(copy.scanLineDirection(), QVideoSurfaceFormat::TopToBottom); | 
| 762 |  | 
| 763 |     QCOMPARE(original.scanLineDirection(), QVideoSurfaceFormat::BottomToTop); | 
| 764 |  | 
| 765 |     QCOMPARE(original == copy, false); | 
| 766 |     QCOMPARE(original != copy, true); | 
| 767 | } | 
| 768 |  | 
| 769 | /* Test case for api isValid */ | 
| 770 | void tst_QVideoSurfaceFormat::isValid() | 
| 771 | { | 
| 772 |     /* When both pixel format and framesize is not valid */ | 
| 773 |     QVideoSurfaceFormat format; | 
| 774 |     QVERIFY(!format.isValid()); | 
| 775 |  | 
| 776 |     /* When framesize is valid and pixel format is not valid */ | 
| 777 |     format.setFrameSize(width: 64,height: 64); | 
| 778 |     QVERIFY(format.frameSize() == QSize(64,64)); | 
| 779 |     QVERIFY(!format.pixelFormat()); | 
| 780 |     QVERIFY(!format.isValid()); | 
| 781 |  | 
| 782 |     /* When both the pixel format and framesize is valid. */ | 
| 783 |     QVideoSurfaceFormat format1(QSize(32, 32), QVideoFrame::Format_AYUV444); | 
| 784 |     QVERIFY(format1.isValid()); | 
| 785 |  | 
| 786 |     /* When pixel format is valid and frame size is not valid */ | 
| 787 |     format1.setFrameSize(width: -1,height: -1); | 
| 788 |     QVERIFY(!format1.frameSize().isValid()); | 
| 789 |     QVERIFY(!format1.isValid()); | 
| 790 | } | 
| 791 |  | 
| 792 | /* Test case for copy constructor with all the parameters. */ | 
| 793 | void tst_QVideoSurfaceFormat::copyAllParameters() | 
| 794 | { | 
| 795 |     /* Create the instance and set all the parameters. */ | 
| 796 |     QVideoSurfaceFormat original( | 
| 797 |             QSize(1024, 768), QVideoFrame::Format_ARGB32, QAbstractVideoBuffer::GLTextureHandle); | 
| 798 |  | 
| 799 |     original.setScanLineDirection(QVideoSurfaceFormat::BottomToTop); | 
| 800 |     original.setViewport(QRect(0, 0, 1024, 1024)); | 
| 801 |     original.setFrameRate(qreal(15.0)); | 
| 802 |     original.setPixelAspectRatio(QSize(320,480)); | 
| 803 |     original.setYCbCrColorSpace(QVideoSurfaceFormat::YCbCr_BT709); | 
| 804 |  | 
| 805 |     /* Copy the original instance to copy and verify if both the instances | 
| 806 |       have the same parameters. */ | 
| 807 |     QVideoSurfaceFormat copy(original); | 
| 808 |  | 
| 809 |     QCOMPARE(copy.handleType(), QAbstractVideoBuffer::GLTextureHandle); | 
| 810 |     QCOMPARE(copy.pixelFormat(), QVideoFrame::Format_ARGB32); | 
| 811 |     QCOMPARE(copy.frameSize(), QSize(1024, 768)); | 
| 812 |     QCOMPARE(copy.scanLineDirection(), QVideoSurfaceFormat::BottomToTop); | 
| 813 |     QCOMPARE(copy.viewport(), QRect(0, 0, 1024, 1024)); | 
| 814 |     QCOMPARE(copy.frameRate(), qreal(15.0)); | 
| 815 |     QCOMPARE(copy.pixelAspectRatio(), QSize(320,480)); | 
| 816 |     QCOMPARE(copy.yCbCrColorSpace(), QVideoSurfaceFormat::YCbCr_BT709); | 
| 817 |  | 
| 818 |     /* Verify if both the instances are eqaul */ | 
| 819 |     QCOMPARE(original == copy, true); | 
| 820 |     QCOMPARE(original != copy, false); | 
| 821 | } | 
| 822 |  | 
| 823 | /* Test case for copy constructor with all the parameters. */ | 
| 824 | void tst_QVideoSurfaceFormat::assignAllParameters() | 
| 825 | { | 
| 826 |     /* Create the instance and set all the parameters. */ | 
| 827 |     QVideoSurfaceFormat copy( | 
| 828 |             QSize(64, 64), QVideoFrame::Format_AYUV444, QAbstractVideoBuffer::UserHandle); | 
| 829 |     copy.setScanLineDirection(QVideoSurfaceFormat::TopToBottom); | 
| 830 |     copy.setViewport(QRect(0, 0, 640, 320)); | 
| 831 |     copy.setFrameRate(qreal(7.5)); | 
| 832 |     copy.setPixelAspectRatio(QSize(640,320)); | 
| 833 |     copy.setYCbCrColorSpace(QVideoSurfaceFormat::YCbCr_BT601); | 
| 834 |  | 
| 835 |     /* Create the instance and set all the parameters. */ | 
| 836 |     QVideoSurfaceFormat original( | 
| 837 |             QSize(1024, 768), QVideoFrame::Format_ARGB32, QAbstractVideoBuffer::GLTextureHandle); | 
| 838 |     original.setScanLineDirection(QVideoSurfaceFormat::BottomToTop); | 
| 839 |     original.setViewport(QRect(0, 0, 1024, 1024)); | 
| 840 |     original.setFrameRate(qreal(15.0)); | 
| 841 |     original.setPixelAspectRatio(QSize(320,480)); | 
| 842 |     original.setYCbCrColorSpace(QVideoSurfaceFormat::YCbCr_BT709); | 
| 843 |  | 
| 844 |     /* Assign the original instance to copy and verify if both the instancess | 
| 845 |       have the same parameters. */ | 
| 846 |     copy = original; | 
| 847 |  | 
| 848 |     QCOMPARE(copy.handleType(), QAbstractVideoBuffer::GLTextureHandle); | 
| 849 |     QCOMPARE(copy.pixelFormat(), QVideoFrame::Format_ARGB32); | 
| 850 |     QCOMPARE(copy.frameSize(), QSize(1024, 768)); | 
| 851 |     QCOMPARE(copy.scanLineDirection(), QVideoSurfaceFormat::BottomToTop); | 
| 852 |     QCOMPARE(copy.viewport(), QRect(0, 0, 1024, 1024)); | 
| 853 |     QCOMPARE(copy.frameRate(), qreal(15.0)); | 
| 854 |     QCOMPARE(copy.pixelAspectRatio(), QSize(320,480)); | 
| 855 |     QCOMPARE(copy.yCbCrColorSpace(), QVideoSurfaceFormat::YCbCr_BT709); | 
| 856 |  | 
| 857 |      /* Verify if both the instances are eqaul */ | 
| 858 |     QCOMPARE(original == copy, true); | 
| 859 |     QCOMPARE(original != copy, false); | 
| 860 | } | 
| 861 |  | 
| 862 | void tst_QVideoSurfaceFormat::propertyEdgeCases() | 
| 863 | { | 
| 864 |     // Test setting read only properties doesn't change anything | 
| 865 |     QVideoSurfaceFormat original( | 
| 866 |             QSize(1024, 768), QVideoFrame::Format_ARGB32, QAbstractVideoBuffer::GLTextureHandle); | 
| 867 |  | 
| 868 |     original.setProperty(name: "handleType" , value: QAbstractVideoBuffer::UserHandle); | 
| 869 |     QCOMPARE(original.handleType(), QAbstractVideoBuffer::GLTextureHandle); | 
| 870 |  | 
| 871 |     original.setProperty(name: "pixelFormat" , value: QVideoFrame::Format_AYUV444); | 
| 872 |     QCOMPARE(original.pixelFormat(), QVideoFrame::Format_ARGB32); | 
| 873 |  | 
| 874 |     original.setProperty(name: "frameWidth" , value: 512); | 
| 875 |     QCOMPARE(original.frameWidth(), 1024); | 
| 876 |  | 
| 877 |     original.setProperty(name: "frameHeight" , value: 77); | 
| 878 |     QCOMPARE(original.frameHeight(), 768); | 
| 879 |  | 
| 880 |     original.setProperty(name: "sizeHint" , value: QSize(512, 384)); | 
| 881 |     QCOMPARE(original.sizeHint(), QSize(1024,768)); | 
| 882 |  | 
| 883 |     // Now test setting some r/w properties with the wrong data type | 
| 884 |     original.setProperty(name: "frameSize" , value: QColor(Qt::red)); | 
| 885 |     QCOMPARE(original.frameSize(), QSize(1024, 768)); | 
| 886 |  | 
| 887 |     original.setProperty(name: "viewport" , value: QColor(Qt::red)); | 
| 888 |     QCOMPARE(original.viewport(), QRect(0, 0, 1024, 768)); | 
| 889 |  | 
| 890 |     original.setScanLineDirection(QVideoSurfaceFormat::BottomToTop); | 
| 891 |     original.setProperty(name: "scanLineDirection" , value: QColor(Qt::red)); | 
| 892 |     QCOMPARE(original.scanLineDirection(), QVideoSurfaceFormat::BottomToTop); | 
| 893 |  | 
| 894 |     original.setFrameRate(32); | 
| 895 |     original.setProperty(name: "frameRate" , value: QSize(32, 43)); | 
| 896 |     QCOMPARE(original.frameRate(), qreal(32)); | 
| 897 |  | 
| 898 |     original.setYCbCrColorSpace(QVideoSurfaceFormat::YCbCr_BT709); | 
| 899 |     original.setProperty(name: "yCbCrColorSpace" , value: QSize(43,43)); | 
| 900 |     QCOMPARE(original.yCbCrColorSpace(), QVideoSurfaceFormat::YCbCr_BT709); | 
| 901 |  | 
| 902 |     original.setPixelAspectRatio(width: 53, height: 45); | 
| 903 |     original.setProperty(name: "pixelAspectRatio" , value: QColor(Qt::red)); | 
| 904 |     QCOMPARE(original.pixelAspectRatio(), QSize(53, 45)); | 
| 905 | } | 
| 906 |  | 
| 907 |  | 
| 908 | QTEST_MAIN(tst_QVideoSurfaceFormat) | 
| 909 |  | 
| 910 |  | 
| 911 |  | 
| 912 | #include "tst_qvideosurfaceformat.moc" | 
| 913 |  |