228 QFETCH(bool, supported); |
230 QFETCH(bool, supported); |
229 |
231 |
230 QtTestVideoSurface surface(supportedFormats); |
232 QtTestVideoSurface surface(supportedFormats); |
231 |
233 |
232 QCOMPARE(surface.isFormatSupported(format), supported); |
234 QCOMPARE(surface.isFormatSupported(format), supported); |
|
235 } |
|
236 |
|
237 void tst_QAbstractVideoSurface::nearestFormat_data() |
|
238 { |
|
239 isFormatSupported_data(); |
|
240 } |
|
241 |
|
242 void tst_QAbstractVideoSurface::nearestFormat() |
|
243 { |
|
244 QFETCH(SupportedFormatMap, supportedFormats); |
|
245 QFETCH(QVideoSurfaceFormat, format); |
|
246 QFETCH(bool, supported); |
|
247 |
|
248 QtTestVideoSurface surface(supportedFormats); |
|
249 |
|
250 QCOMPARE(surface.nearestFormat(format) == format, supported); |
233 } |
251 } |
234 |
252 |
235 void tst_QAbstractVideoSurface::start_data() |
253 void tst_QAbstractVideoSurface::start_data() |
236 { |
254 { |
237 QTest::addColumn<QVideoSurfaceFormat>("format"); |
255 QTest::addColumn<QVideoSurfaceFormat>("format"); |
254 |
272 |
255 QtTestVideoSurface surface; |
273 QtTestVideoSurface surface; |
256 surface.setError(QAbstractVideoSurface::ResourceError); |
274 surface.setError(QAbstractVideoSurface::ResourceError); |
257 |
275 |
258 QSignalSpy formatSpy(&surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat))); |
276 QSignalSpy formatSpy(&surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat))); |
259 QSignalSpy startedSpy(&surface, SIGNAL(startedChanged(bool))); |
277 QSignalSpy activeSpy(&surface, SIGNAL(activeChanged(bool))); |
260 |
278 |
261 QVERIFY(!surface.isStarted()); |
279 QVERIFY(!surface.isActive()); |
262 QCOMPARE(surface.surfaceFormat(), QVideoSurfaceFormat()); |
280 QCOMPARE(surface.surfaceFormat(), QVideoSurfaceFormat()); |
263 |
281 |
264 QVERIFY(surface.start(format)); |
282 QVERIFY(surface.start(format)); |
265 |
283 |
266 QVERIFY(surface.isStarted()); |
284 QVERIFY(surface.isActive()); |
267 QCOMPARE(surface.surfaceFormat(), format); |
285 QCOMPARE(surface.surfaceFormat(), format); |
268 |
286 |
269 QCOMPARE(formatSpy.count(), 1); |
287 QCOMPARE(formatSpy.count(), 1); |
270 QCOMPARE(qvariant_cast<QVideoSurfaceFormat>(formatSpy.at(0).at(0)), format); |
288 QCOMPARE(qvariant_cast<QVideoSurfaceFormat>(formatSpy.last().at(0)), format); |
271 |
289 |
272 QCOMPARE(startedSpy.count(), 1); |
290 QCOMPARE(activeSpy.count(), 1); |
273 QCOMPARE(startedSpy.at(0).at(0).toBool(), true); |
291 QCOMPARE(activeSpy.last().at(0).toBool(), true); |
274 |
292 |
275 // error() is reset on a successful start. |
293 // error() is reset on a successful start. |
276 QCOMPARE(surface.error(), QAbstractVideoSurface::NoError); |
294 QCOMPARE(surface.error(), QAbstractVideoSurface::NoError); |
277 |
295 |
278 surface.stop(); |
296 surface.stop(); |
279 |
297 |
280 QVERIFY(!surface.isStarted()); |
298 QVERIFY(!surface.isActive()); |
281 QCOMPARE(surface.surfaceFormat(), QVideoSurfaceFormat()); |
299 QCOMPARE(surface.surfaceFormat(), QVideoSurfaceFormat()); |
282 |
300 |
283 QCOMPARE(formatSpy.count(), 2); |
301 QCOMPARE(formatSpy.count(), 2); |
284 QCOMPARE(qvariant_cast<QVideoSurfaceFormat>(formatSpy.at(1).at(0)), QVideoSurfaceFormat()); |
302 QCOMPARE(qvariant_cast<QVideoSurfaceFormat>(formatSpy.last().at(0)), QVideoSurfaceFormat()); |
285 |
303 |
286 QCOMPARE(startedSpy.count(), 2); |
304 QCOMPARE(activeSpy.count(), 2); |
287 QCOMPARE(startedSpy.at(1).at(0).toBool(), false); |
305 QCOMPARE(activeSpy.last().at(0).toBool(), false); |
288 } |
306 } |
289 |
307 |
290 QTEST_MAIN(tst_QAbstractVideoSurface) |
308 QTEST_MAIN(tst_QAbstractVideoSurface) |
291 |
309 |
292 #include "tst_qabstractvideosurface.moc" |
310 #include "tst_qabstractvideosurface.moc" |