summaryrefslogtreecommitdiffstats
path: root/tests/auto/unit
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/unit')
-rw-r--r--tests/auto/unit/CMakeLists.txt10
-rw-r--r--tests/auto/unit/mockbackend/CMakeLists.txt33
-rw-r--r--tests/auto/unit/mockbackend/mock.json3
-rw-r--r--tests/auto/unit/mockbackend/qmockaudiodecoder.cpp139
-rw-r--r--tests/auto/unit/mockbackend/qmockaudiodecoder.h69
-rw-r--r--tests/auto/unit/mockbackend/qmockaudiooutput.h30
-rw-r--r--tests/auto/unit/mockbackend/qmockcamera.cpp158
-rw-r--r--tests/auto/unit/mockbackend/qmockcamera.h81
-rw-r--r--tests/auto/unit/mockbackend/qmockimagecapture.cpp59
-rw-r--r--tests/auto/unit/mockbackend/qmockimagecapture.h48
-rw-r--r--tests/auto/unit/mockbackend/qmockintegration.cpp198
-rw-r--r--tests/auto/unit/mockbackend/qmockintegration.h103
-rw-r--r--tests/auto/unit/mockbackend/qmockmediacapturesession.h86
-rw-r--r--tests/auto/unit/mockbackend/qmockmediadevices.cpp43
-rw-r--r--tests/auto/unit/mockbackend/qmockmediadevices.h45
-rw-r--r--tests/auto/unit/mockbackend/qmockmediaencoder.h95
-rw-r--r--tests/auto/unit/mockbackend/qmockmediaplayer.h175
-rw-r--r--tests/auto/unit/mockbackend/qmocksurfacecapture.h88
-rw-r--r--tests/auto/unit/mockbackend/qmockvideobuffer.h38
-rw-r--r--tests/auto/unit/mockbackend/qmockvideosink.h33
-rw-r--r--tests/auto/unit/multimedia.pro34
-rw-r--r--tests/auto/unit/multimedia/CMakeLists.txt40
-rw-r--r--tests/auto/unit/multimedia/gstreamer_backend/CMakeLists.txt15
-rw-r--r--tests/auto/unit/multimedia/gstreamer_backend/tst_gstreamer_backend.cpp309
-rw-r--r--tests/auto/unit/multimedia/gstreamer_backend/tst_gstreamer_backend.h49
-rw-r--r--tests/auto/unit/multimedia/qabstractvideobuffer/CMakeLists.txt16
-rw-r--r--tests/auto/unit/multimedia/qabstractvideobuffer/tst_qabstractvideobuffer.cpp113
-rw-r--r--tests/auto/unit/multimedia/qaudiobuffer/CMakeLists.txt18
-rw-r--r--tests/auto/unit/multimedia/qaudiobuffer/tst_qaudiobuffer.cpp314
-rw-r--r--tests/auto/unit/multimedia/qaudiodecoder/CMakeLists.txt21
-rw-r--r--tests/auto/unit/multimedia/qaudiodecoder/tst_qaudiodecoder.cpp337
-rw-r--r--tests/auto/unit/multimedia/qaudioformat/CMakeLists.txt16
-rw-r--r--tests/auto/unit/multimedia/qaudioformat/tst_qaudioformat.cpp (renamed from tests/auto/unit/qaudioformat/tst_qaudioformat.cpp)166
-rw-r--r--tests/auto/unit/multimedia/qaudionamespace/CMakeLists.txt16
-rw-r--r--tests/auto/unit/multimedia/qaudionamespace/tst_qaudionamespace.cpp (renamed from tests/auto/unit/qaudionamespace/tst_qaudionamespace.cpp)54
-rw-r--r--tests/auto/unit/multimedia/qaudiorecorder/CMakeLists.txt20
-rw-r--r--tests/auto/unit/multimedia/qaudiorecorder/tst_qaudiorecorder.cpp87
-rw-r--r--tests/auto/unit/multimedia/qaudiostatemachine/CMakeLists.txt11
-rw-r--r--tests/auto/unit/multimedia/qaudiostatemachine/tst_qaudiostatemachine.cpp661
-rw-r--r--tests/auto/unit/multimedia/qcamera/CMakeLists.txt20
-rw-r--r--tests/auto/unit/multimedia/qcamera/tst_qcamera.cpp845
-rw-r--r--tests/auto/unit/multimedia/qcameradevice/CMakeLists.txt20
-rw-r--r--tests/auto/unit/multimedia/qcameradevice/tst_qcameradevice.cpp139
-rw-r--r--tests/auto/unit/multimedia/qerrorinfo/CMakeLists.txt10
-rw-r--r--tests/auto/unit/multimedia/qerrorinfo/tst_qerrorinfo.cpp117
-rw-r--r--tests/auto/unit/multimedia/qimagecapture/CMakeLists.txt20
-rw-r--r--tests/auto/unit/multimedia/qimagecapture/tst_qimagecapture.cpp284
-rw-r--r--tests/auto/unit/multimedia/qmaybe/CMakeLists.txt9
-rw-r--r--tests/auto/unit/multimedia/qmaybe/tst_qmaybe.cpp124
-rw-r--r--tests/auto/unit/multimedia/qmediacapture_gstreamer/CMakeLists.txt18
-rw-r--r--tests/auto/unit/multimedia/qmediacapture_gstreamer/tst_qmediacapture_gstreamer.cpp212
-rw-r--r--tests/auto/unit/multimedia/qmediadevices/CMakeLists.txt13
-rw-r--r--tests/auto/unit/multimedia/qmediadevices/tst_qmediadevices.cpp58
-rw-r--r--tests/auto/unit/multimedia/qmediaformat/CMakeLists.txt10
-rw-r--r--tests/auto/unit/multimedia/qmediaformat/tst_qmediaformat.cpp65
-rw-r--r--tests/auto/unit/multimedia/qmediaplayer/CMakeLists.txt34
-rw-r--r--tests/auto/unit/multimedia/qmediaplayer/testdata/nokia-tune.mp3 (renamed from tests/auto/unit/qmediaplayer/testdata/nokia-tune.mp3)bin62715 -> 62715 bytes
-rw-r--r--tests/auto/unit/multimedia/qmediaplayer/tst_qmediaplayer.cpp832
-rw-r--r--tests/auto/unit/multimedia/qmediaplayer_gstreamer/CMakeLists.txt32
-rw-r--r--tests/auto/unit/multimedia/qmediaplayer_gstreamer/testdata/color_matrix.mp4bin0 -> 21412 bytes
-rw-r--r--tests/auto/unit/multimedia/qmediaplayer_gstreamer/tst_qmediaplayer_gstreamer.cpp153
-rw-r--r--tests/auto/unit/multimedia/qmediaplayer_gstreamer/tst_qmediaplayer_gstreamer.h46
-rw-r--r--tests/auto/unit/multimedia/qmediaplaylist/CMakeLists.txt23
-rw-r--r--tests/auto/unit/multimedia/qmediaplaylist/testdata/empty.pls (renamed from tests/auto/unit/qmediaplaylist/testdata/empty.pls)0
-rw-r--r--tests/auto/unit/multimedia/qmediaplaylist/testdata/test.m3u (renamed from tests/auto/unit/qmediaplaylist/testdata/test.m3u)0
-rw-r--r--tests/auto/unit/multimedia/qmediaplaylist/testdata/test.pls (renamed from tests/auto/unit/qmediaplaylist/testdata/test.pls)0
-rw-r--r--tests/auto/unit/multimedia/qmediaplaylist/testdata/testfile (renamed from tests/auto/unit/qmediaplaylist/testdata/testfile)0
-rw-r--r--tests/auto/unit/multimedia/qmediaplaylist/testdata/testfile2#suffix (renamed from tests/auto/unit/qmediaplaylist/testdata/testfile2#suffix)0
-rw-r--r--tests/auto/unit/multimedia/qmediaplaylist/testdata/totem-pl-example.pls (renamed from tests/auto/unit/qmediaplaylist/testdata/totem-pl-example.pls)0
-rw-r--r--tests/auto/unit/multimedia/qmediaplaylist/tst_qmediaplaylist.cpp (renamed from tests/auto/unit/qmediaplaylist/tst_qmediaplaylist.cpp)459
-rw-r--r--tests/auto/unit/multimedia/qmediarecorder/CMakeLists.txt20
-rw-r--r--tests/auto/unit/multimedia/qmediarecorder/tst_qmediarecorder.cpp492
-rw-r--r--tests/auto/unit/multimedia/qmediatimerange/CMakeLists.txt16
-rw-r--r--tests/auto/unit/multimedia/qmediatimerange/tst_qmediatimerange.cpp (renamed from tests/auto/unit/qmediatimerange/tst_qmediatimerange.cpp)109
-rw-r--r--tests/auto/unit/multimedia/qmultimediautils/CMakeLists.txt9
-rw-r--r--tests/auto/unit/multimedia/qmultimediautils/tst_qmultimediautils.cpp184
-rw-r--r--tests/auto/unit/multimedia/qsamplecache/CMakeLists.txt23
-rw-r--r--tests/auto/unit/multimedia/qsamplecache/testdata/test.wav (renamed from tests/auto/unit/qsamplecache/testdata/test.wav)bin88232 -> 88232 bytes
-rw-r--r--tests/auto/unit/multimedia/qsamplecache/testdata/test2.wav (renamed from tests/auto/unit/qsamplecache/testdata/test2.wav)bin88232 -> 88232 bytes
-rw-r--r--tests/auto/unit/multimedia/qsamplecache/tst_qsamplecache.cpp (renamed from tests/auto/unit/qsamplecache/tst_qsamplecache.cpp)64
-rw-r--r--tests/auto/unit/multimedia/qscreencapture/CMakeLists.txt18
-rw-r--r--tests/auto/unit/multimedia/qscreencapture/tst_qscreencapture.cpp64
-rw-r--r--tests/auto/unit/multimedia/qvideobuffers/CMakeLists.txt10
-rw-r--r--tests/auto/unit/multimedia/qvideobuffers/tst_qvideobuffers.cpp252
-rw-r--r--tests/auto/unit/multimedia/qvideoframe/CMakeLists.txt16
-rw-r--r--tests/auto/unit/multimedia/qvideoframe/tst_qvideoframe.cpp1437
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/CMakeLists.txt18
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpgbin0 -> 12786 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_adobergb_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_adobergb_full_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_adobergb_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_adobergb_video_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt2020_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt2020_full_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt2020_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt2020_video_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt601_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt601_full_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt601_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt601_video_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt709_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt709_full_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt709_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt709_video_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_adobergb_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_adobergb_full_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_adobergb_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_adobergb_video_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt2020_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt2020_full_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt2020_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt2020_video_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt601_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt601_full_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt601_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt601_video_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt709_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt709_full_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt709_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt709_video_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_adobergb_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_adobergb_full_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_adobergb_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_adobergb_video_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt2020_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt2020_full_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt2020_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt2020_video_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt601_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt601_full_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt601_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt601_video_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt709_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt709_full_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt709_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt709_video_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_adobergb_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_adobergb_full_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_adobergb_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_adobergb_video_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt2020_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt2020_full_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt2020_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt2020_video_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt601_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt601_full_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt601_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt601_video_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt709_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt709_full_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt709_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt709_video_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_adobergb_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_adobergb_full_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_adobergb_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_adobergb_video_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt2020_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt2020_full_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt2020_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt2020_video_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt601_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt601_full_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt601_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt601_video_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt709_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt709_full_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt709_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt709_video_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_adobergb_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_adobergb_full_cpu.pngbin0 -> 36154 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_adobergb_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_adobergb_video_cpu.pngbin0 -> 36154 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt2020_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt2020_full_cpu.pngbin0 -> 36154 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt2020_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt2020_video_cpu.pngbin0 -> 36154 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt601_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt601_full_cpu.pngbin0 -> 36154 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt601_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt601_video_cpu.pngbin0 -> 36154 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt709_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt709_full_cpu.pngbin0 -> 36154 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt709_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt709_video_cpu.pngbin0 -> 36154 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_adobergb_full.pngbin0 -> 40898 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_adobergb_full_cpu.pngbin0 -> 35874 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_adobergb_video.pngbin0 -> 40898 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_adobergb_video_cpu.pngbin0 -> 35874 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt2020_full.pngbin0 -> 40908 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt2020_full_cpu.pngbin0 -> 35882 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt2020_video.pngbin0 -> 40978 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt2020_video_cpu.pngbin0 -> 35946 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt601_full.pngbin0 -> 40854 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt601_full_cpu.pngbin0 -> 35877 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt601_video.pngbin0 -> 40904 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt601_video_cpu.pngbin0 -> 35900 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt709_full.pngbin0 -> 40945 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt709_full_cpu.pngbin0 -> 35877 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt709_video.pngbin0 -> 40959 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt709_video_cpu.pngbin0 -> 35898 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_adobergb_full.pngbin0 -> 40934 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_adobergb_full_cpu.pngbin0 -> 35874 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_adobergb_video.pngbin0 -> 40934 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_adobergb_video_cpu.pngbin0 -> 35874 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt2020_full.pngbin0 -> 40912 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt2020_full_cpu.pngbin0 -> 35882 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt2020_video.pngbin0 -> 41004 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt2020_video_cpu.pngbin0 -> 35946 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt601_full.pngbin0 -> 40870 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt601_full_cpu.pngbin0 -> 35877 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt601_video.pngbin0 -> 40924 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt601_video_cpu.pngbin0 -> 35900 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt709_full.pngbin0 -> 40966 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt709_full_cpu.pngbin0 -> 35877 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt709_video.pngbin0 -> 40975 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt709_video_cpu.pngbin0 -> 35898 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_adobergb_full.pngbin0 -> 40898 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_adobergb_full_cpu.pngbin0 -> 35874 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_adobergb_video.pngbin0 -> 40898 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_adobergb_video_cpu.pngbin0 -> 35874 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt2020_full.pngbin0 -> 40908 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt2020_full_cpu.pngbin0 -> 35882 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt2020_video.pngbin0 -> 40978 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt2020_video_cpu.pngbin0 -> 35946 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt601_full.pngbin0 -> 40854 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt601_full_cpu.pngbin0 -> 35877 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt601_video.pngbin0 -> 40904 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt601_video_cpu.pngbin0 -> 35900 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt709_full.pngbin0 -> 40945 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt709_full_cpu.pngbin0 -> 35877 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt709_video.pngbin0 -> 40959 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt709_video_cpu.pngbin0 -> 35898 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_adobergb_full.pngbin0 -> 40908 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_adobergb_full_cpu.pngbin0 -> 35874 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_adobergb_video.pngbin0 -> 40908 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_adobergb_video_cpu.pngbin0 -> 35874 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt2020_full.pngbin0 -> 40912 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt2020_full_cpu.pngbin0 -> 35882 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt2020_video.pngbin0 -> 40987 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt2020_video_cpu.pngbin0 -> 35946 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt601_full.pngbin0 -> 40877 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt601_full_cpu.pngbin0 -> 35877 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt601_video.pngbin0 -> 40918 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt601_video_cpu.pngbin0 -> 35900 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt709_full.pngbin0 -> 40967 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt709_full_cpu.pngbin0 -> 35877 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt709_video.pngbin0 -> 40961 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt709_video_cpu.pngbin0 -> 35898 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_adobergb_full.pngbin0 -> 40898 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_adobergb_full_cpu.pngbin0 -> 35874 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_adobergb_video.pngbin0 -> 40898 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_adobergb_video_cpu.pngbin0 -> 35874 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt2020_full.pngbin0 -> 40908 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt2020_full_cpu.pngbin0 -> 35882 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt2020_video.pngbin0 -> 40978 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt2020_video_cpu.pngbin0 -> 35946 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt601_full.pngbin0 -> 40854 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt601_full_cpu.pngbin0 -> 35877 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt601_video.pngbin0 -> 40904 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt601_video_cpu.pngbin0 -> 35900 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt709_full.pngbin0 -> 40945 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt709_full_cpu.pngbin0 -> 35877 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt709_video.pngbin0 -> 40959 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt709_video_cpu.pngbin0 -> 35898 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_adobergb_full.pngbin0 -> 40898 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_adobergb_full_cpu.pngbin0 -> 35874 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_adobergb_video.pngbin0 -> 40898 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_adobergb_video_cpu.pngbin0 -> 35874 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt2020_full.pngbin0 -> 40908 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt2020_full_cpu.pngbin0 -> 35882 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt2020_video.pngbin0 -> 40978 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt2020_video_cpu.pngbin0 -> 35946 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt601_full.pngbin0 -> 40854 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt601_full_cpu.pngbin0 -> 35877 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt601_video.pngbin0 -> 40904 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt601_video_cpu.pngbin0 -> 35900 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt709_full.pngbin0 -> 40945 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt709_full_cpu.pngbin0 -> 35877 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt709_video.pngbin0 -> 40959 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt709_video_cpu.pngbin0 -> 35898 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_adobergb_full.pngbin0 -> 40927 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_adobergb_full_cpu.pngbin0 -> 35927 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_adobergb_video.pngbin0 -> 40927 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_adobergb_video_cpu.pngbin0 -> 35927 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt2020_full.pngbin0 -> 40923 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt2020_full_cpu.pngbin0 -> 35936 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt2020_video.pngbin0 -> 40964 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt2020_video_cpu.pngbin0 -> 35927 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt601_full.pngbin0 -> 40897 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt601_full_cpu.pngbin0 -> 35887 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt601_video.pngbin0 -> 40914 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt601_video_cpu.pngbin0 -> 35881 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt709_full.pngbin0 -> 40936 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt709_full_cpu.pngbin0 -> 35887 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt709_video.pngbin0 -> 40991 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt709_video_cpu.pngbin0 -> 35933 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_adobergb_full.pngbin0 -> 40913 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_adobergb_full_cpu.pngbin0 -> 35941 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_adobergb_video.pngbin0 -> 40913 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_adobergb_video_cpu.pngbin0 -> 35941 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt2020_full.pngbin0 -> 40969 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt2020_full_cpu.pngbin0 -> 35925 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt2020_video.pngbin0 -> 40951 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt2020_video_cpu.pngbin0 -> 35968 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt601_full.pngbin0 -> 40860 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt601_full_cpu.pngbin0 -> 35857 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt601_video.pngbin0 -> 40946 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt601_video_cpu.pngbin0 -> 35908 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt709_full.pngbin0 -> 40942 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt709_full_cpu.pngbin0 -> 35857 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt709_video.pngbin0 -> 40966 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt709_video_cpu.pngbin0 -> 35945 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_adobergb_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_adobergb_full_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_adobergb_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_adobergb_video_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt2020_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt2020_full_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt2020_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt2020_video_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt601_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt601_full_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt601_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt601_video_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt709_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt709_full_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt709_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt709_video_cpu.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_adobergb_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_adobergb_full_cpu.pngbin0 -> 36154 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_adobergb_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_adobergb_video_cpu.pngbin0 -> 36154 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt2020_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt2020_full_cpu.pngbin0 -> 36154 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt2020_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt2020_video_cpu.pngbin0 -> 36154 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt601_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt601_full_cpu.pngbin0 -> 36154 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt601_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt601_video_cpu.pngbin0 -> 36154 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt709_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt709_full_cpu.pngbin0 -> 36154 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt709_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt709_video_cpu.pngbin0 -> 36154 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_adobergb_full.pngbin0 -> 39859 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_adobergb_full_cpu.pngbin0 -> 36094 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_adobergb_video.pngbin0 -> 39859 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_adobergb_video_cpu.pngbin0 -> 36094 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt2020_full.pngbin0 -> 39864 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt2020_full_cpu.pngbin0 -> 36087 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt2020_video.pngbin0 -> 39919 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt2020_video_cpu.pngbin0 -> 36215 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt601_full.pngbin0 -> 39789 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt601_full_cpu.pngbin0 -> 36021 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt601_video.pngbin0 -> 39890 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt601_video_cpu.pngbin0 -> 36258 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt709_full.pngbin0 -> 39879 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt709_full_cpu.pngbin0 -> 36021 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt709_video.pngbin0 -> 39951 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt709_video_cpu.pngbin0 -> 36189 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_adobergb_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_adobergb_full_cpu.pngbin0 -> 36154 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_adobergb_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_adobergb_video_cpu.pngbin0 -> 36154 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt2020_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt2020_full_cpu.pngbin0 -> 36154 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt2020_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt2020_video_cpu.pngbin0 -> 36154 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt601_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt601_full_cpu.pngbin0 -> 36154 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt601_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt601_video_cpu.pngbin0 -> 36154 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt709_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt709_full_cpu.pngbin0 -> 36154 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt709_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt709_video_cpu.pngbin0 -> 36154 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_adobergb_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_adobergb_full_cpu.pngbin0 -> 36154 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_adobergb_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_adobergb_video_cpu.pngbin0 -> 36154 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt2020_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt2020_full_cpu.pngbin0 -> 36154 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt2020_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt2020_video_cpu.pngbin0 -> 36154 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt601_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt601_full_cpu.pngbin0 -> 36154 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt601_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt601_video_cpu.pngbin0 -> 36154 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt709_full.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt709_full_cpu.pngbin0 -> 36154 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt709_video.pngbin0 -> 41243 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt709_video_cpu.pngbin0 -> 36154 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_adobergb_full.pngbin0 -> 25240 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_adobergb_full_cpu.pngbin0 -> 23434 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_adobergb_video.pngbin0 -> 25240 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_adobergb_video_cpu.pngbin0 -> 23434 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt2020_full.pngbin0 -> 25544 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt2020_full_cpu.pngbin0 -> 23596 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt2020_video.pngbin0 -> 24030 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt2020_video_cpu.pngbin0 -> 22241 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt601_full.pngbin0 -> 25557 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt601_full_cpu.pngbin0 -> 23545 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt601_video.pngbin0 -> 23884 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt601_video_cpu.pngbin0 -> 22208 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt709_full.pngbin0 -> 25557 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt709_full_cpu.pngbin0 -> 23545 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt709_video.pngbin0 -> 24021 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt709_video_cpu.pngbin0 -> 22392 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_adobergb_full.pngbin0 -> 25364 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_adobergb_full_cpu.pngbin0 -> 23481 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_adobergb_video.pngbin0 -> 25364 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_adobergb_video_cpu.pngbin0 -> 23481 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt2020_full.pngbin0 -> 25430 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt2020_full_cpu.pngbin0 -> 23425 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt2020_video.pngbin0 -> 23981 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt2020_video_cpu.pngbin0 -> 22350 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt601_full.pngbin0 -> 25497 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt601_full_cpu.pngbin0 -> 23568 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt601_video.pngbin0 -> 23904 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt601_video_cpu.pngbin0 -> 22203 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt709_full.pngbin0 -> 25497 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt709_full_cpu.pngbin0 -> 23568 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt709_video.pngbin0 -> 23979 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt709_video_cpu.pngbin0 -> 22331 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p10_adobergb_full.pngbin0 -> 40919 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p10_adobergb_video.pngbin0 -> 40919 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p10_bt2020_full.pngbin0 -> 40952 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p10_bt2020_video.pngbin0 -> 40967 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p10_bt601_full.pngbin0 -> 40881 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p10_bt601_video.pngbin0 -> 40962 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p10_bt709_full.pngbin0 -> 40954 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p10_bt709_video.pngbin0 -> 40987 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_adobergb_full.pngbin0 -> 40898 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_adobergb_full_cpu.pngbin0 -> 35874 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_adobergb_video.pngbin0 -> 40898 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_adobergb_video_cpu.pngbin0 -> 35874 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt2020_full.pngbin0 -> 40908 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt2020_full_cpu.pngbin0 -> 35882 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt2020_video.pngbin0 -> 40978 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt2020_video_cpu.pngbin0 -> 35946 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt601_full.pngbin0 -> 40854 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt601_full_cpu.pngbin0 -> 35877 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt601_video.pngbin0 -> 40904 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt601_video_cpu.pngbin0 -> 35900 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt709_full.pngbin0 -> 40945 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt709_full_cpu.pngbin0 -> 35877 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt709_video.pngbin0 -> 40959 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt709_video_cpu.pngbin0 -> 35898 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_adobergb_full.pngbin0 -> 41163 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_adobergb_full_cpu.pngbin0 -> 36094 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_adobergb_video.pngbin0 -> 41163 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_adobergb_video_cpu.pngbin0 -> 36094 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt2020_full.pngbin0 -> 41160 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt2020_full_cpu.pngbin0 -> 36087 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt2020_video.pngbin0 -> 41199 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt2020_video_cpu.pngbin0 -> 36215 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt601_full.pngbin0 -> 41000 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt601_full_cpu.pngbin0 -> 36021 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt601_video.pngbin0 -> 41177 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt601_video_cpu.pngbin0 -> 36258 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt709_full.pngbin0 -> 41183 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt709_full_cpu.pngbin0 -> 36021 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt709_video.pngbin0 -> 41209 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt709_video_cpu.pngbin0 -> 36189 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_adobergb_full.pngbin0 -> 39859 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_adobergb_full_cpu.pngbin0 -> 36094 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_adobergb_video.pngbin0 -> 39859 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_adobergb_video_cpu.pngbin0 -> 36094 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt2020_full.pngbin0 -> 39864 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt2020_full_cpu.pngbin0 -> 36087 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt2020_video.pngbin0 -> 39919 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt2020_video_cpu.pngbin0 -> 36215 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt601_full.pngbin0 -> 39789 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt601_full_cpu.pngbin0 -> 36021 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt601_video.pngbin0 -> 39890 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt601_video_cpu.pngbin0 -> 36258 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt709_full.pngbin0 -> 39879 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt709_full_cpu.pngbin0 -> 36021 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt709_video.pngbin0 -> 39951 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt709_video_cpu.pngbin0 -> 36189 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_adobergb_full.pngbin0 -> 40898 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_adobergb_full_cpu.pngbin0 -> 35874 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_adobergb_video.pngbin0 -> 40898 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_adobergb_video_cpu.pngbin0 -> 35874 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt2020_full.pngbin0 -> 40908 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt2020_full_cpu.pngbin0 -> 35882 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt2020_video.pngbin0 -> 40978 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt2020_video_cpu.pngbin0 -> 35946 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt601_full.pngbin0 -> 40854 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt601_full_cpu.pngbin0 -> 35877 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt601_video.pngbin0 -> 40904 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt601_video_cpu.pngbin0 -> 35900 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt709_full.pngbin0 -> 40945 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt709_full_cpu.pngbin0 -> 35877 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt709_video.pngbin0 -> 40959 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt709_video_cpu.pngbin0 -> 35898 bytes
-rw-r--r--tests/auto/unit/multimedia/qvideoframecolormanagement/tst_qvideoframecolormanagement.cpp475
-rw-r--r--tests/auto/unit/multimedia/qvideoframeformat/CMakeLists.txt16
-rw-r--r--tests/auto/unit/multimedia/qvideoframeformat/tst_qvideoframeformat.cpp567
-rw-r--r--tests/auto/unit/multimedia/qvideotexturehelper/CMakeLists.txt10
-rw-r--r--tests/auto/unit/multimedia/qvideotexturehelper/tst_qvideotexturehelper.cpp260
-rw-r--r--tests/auto/unit/multimedia/qwavedecoder/CMakeLists.txt24
-rw-r--r--tests/auto/unit/multimedia/qwavedecoder/data/corrupt_datadesc_1_16_8000.le.wav (renamed from tests/auto/unit/qwavedecoder/data/corrupt_datadesc_1_16_8000.le.wav)bin4044 -> 4044 bytes
-rw-r--r--tests/auto/unit/multimedia/qwavedecoder/data/corrupt_fmtdesc_1_16_8000.le.wav (renamed from tests/auto/unit/qwavedecoder/data/corrupt_fmtdesc_1_16_8000.le.wav)bin4044 -> 4044 bytes
-rw-r--r--tests/auto/unit/multimedia/qwavedecoder/data/corrupt_fmtstring_1_16_8000.le.wav (renamed from tests/auto/unit/qwavedecoder/data/corrupt_fmtstring_1_16_8000.le.wav)bin4044 -> 4044 bytes
-rw-r--r--tests/auto/unit/multimedia/qwavedecoder/data/empty.wav (renamed from tests/auto/unit/qwavedecoder/data/empty.wav)0
-rwxr-xr-xtests/auto/unit/multimedia/qwavedecoder/data/gendata.sh30
-rw-r--r--tests/auto/unit/multimedia/qwavedecoder/data/isawav_1_16_44100_le.wav (renamed from tests/auto/unit/qwavedecoder/data/isawav_1_16_44100_le.wav)bin22094 -> 22094 bytes
-rw-r--r--tests/auto/unit/multimedia/qwavedecoder/data/isawav_1_16_44100_le_2.wav (renamed from tests/auto/unit/qwavedecoder/data/isawav_1_16_44100_le_2.wav)bin22096 -> 22096 bytes
-rw-r--r--tests/auto/unit/multimedia/qwavedecoder/data/isawav_1_16_8000_le.wav (renamed from tests/auto/unit/qwavedecoder/data/isawav_1_16_8000_le.wav)bin4044 -> 4044 bytes
-rw-r--r--tests/auto/unit/multimedia/qwavedecoder/data/isawav_1_32_44100_le.wav (renamed from tests/auto/unit/qwavedecoder/data/isawav_1_32_44100_le.wav)bin44180 -> 44180 bytes
-rw-r--r--tests/auto/unit/multimedia/qwavedecoder/data/isawav_1_32_8000_le.wav (renamed from tests/auto/unit/qwavedecoder/data/isawav_1_32_8000_le.wav)bin8080 -> 8080 bytes
-rw-r--r--tests/auto/unit/multimedia/qwavedecoder/data/isawav_1_8_44100.wav (renamed from tests/auto/unit/qwavedecoder/data/isawav_1_8_44100.wav)bin11069 -> 11069 bytes
-rw-r--r--tests/auto/unit/multimedia/qwavedecoder/data/isawav_1_8_8000.wav (renamed from tests/auto/unit/qwavedecoder/data/isawav_1_8_8000.wav)bin2044 -> 2044 bytes
-rw-r--r--tests/auto/unit/multimedia/qwavedecoder/data/isawav_1_8_8000_even_bext.wavbin0 -> 2064 bytes
-rw-r--r--tests/auto/unit/multimedia/qwavedecoder/data/isawav_1_8_8000_odd_bext.wavbin0 -> 2064 bytes
-rw-r--r--tests/auto/unit/multimedia/qwavedecoder/data/isawav_2_16_44100_be.wav (renamed from tests/auto/unit/qwavedecoder/data/isawav_2_16_44100_be.wav)bin44144 -> 44144 bytes
-rw-r--r--tests/auto/unit/multimedia/qwavedecoder/data/isawav_2_16_8000_be.wav (renamed from tests/auto/unit/qwavedecoder/data/isawav_2_16_8000_be.wav)bin8044 -> 8044 bytes
-rw-r--r--tests/auto/unit/multimedia/qwavedecoder/data/isawav_2_32_44100_be.wav (renamed from tests/auto/unit/qwavedecoder/data/isawav_2_32_44100_be.wav)bin88280 -> 88280 bytes
-rw-r--r--tests/auto/unit/multimedia/qwavedecoder/data/isawav_2_32_8000_be.wav (renamed from tests/auto/unit/qwavedecoder/data/isawav_2_32_8000_be.wav)bin16080 -> 16080 bytes
-rw-r--r--tests/auto/unit/multimedia/qwavedecoder/data/isawav_2_8_44100.wav (renamed from tests/auto/unit/qwavedecoder/data/isawav_2_8_44100.wav)bin22094 -> 22094 bytes
-rw-r--r--tests/auto/unit/multimedia/qwavedecoder/data/isawav_2_8_8000.wav (renamed from tests/auto/unit/qwavedecoder/data/isawav_2_8_8000.wav)bin4044 -> 4044 bytes
-rw-r--r--tests/auto/unit/multimedia/qwavedecoder/data/nosampledata.wav (renamed from tests/auto/unit/qwavedecoder/data/nosampledata.wav)bin44 -> 44 bytes
-rw-r--r--tests/auto/unit/multimedia/qwavedecoder/data/notawav.wav (renamed from tests/auto/unit/qwavedecoder/data/notawav.wav)0
-rw-r--r--tests/auto/unit/multimedia/qwavedecoder/data/onebyte.wav (renamed from tests/auto/unit/qwavedecoder/data/onebyte.wav)0
-rw-r--r--tests/auto/unit/multimedia/qwavedecoder/tst_qwavedecoder.cpp (renamed from tests/auto/unit/qwavedecoder/tst_qwavedecoder.cpp)121
-rw-r--r--tests/auto/unit/multimediaqml.pro12
-rw-r--r--tests/auto/unit/multimediawidgets.pro16
-rw-r--r--tests/auto/unit/multimediawidgets/CMakeLists.txt13
-rw-r--r--tests/auto/unit/multimediawidgets/qcamerawidgets/CMakeLists.txt22
-rw-r--r--tests/auto/unit/multimediawidgets/qcamerawidgets/tst_qcamerawidgets.cpp114
-rw-r--r--tests/auto/unit/multimediawidgets/qgraphicsvideoitem/CMakeLists.txt21
-rw-r--r--tests/auto/unit/multimediawidgets/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp389
-rw-r--r--tests/auto/unit/multimediawidgets/qmediaplayerwidgets/CMakeLists.txt23
-rw-r--r--tests/auto/unit/multimediawidgets/qmediaplayerwidgets/tst_qmediaplayerwidgets.cpp107
-rw-r--r--tests/auto/unit/multimediawidgets/qvideowidget/BLACKLIST3
-rw-r--r--tests/auto/unit/multimediawidgets/qvideowidget/CMakeLists.txt21
-rw-r--r--tests/auto/unit/multimediawidgets/qvideowidget/tst_qvideowidget.cpp269
-rw-r--r--tests/auto/unit/qabstractvideobuffer/qabstractvideobuffer.pro7
-rw-r--r--tests/auto/unit/qabstractvideobuffer/tst_qabstractvideobuffer.cpp165
-rw-r--r--tests/auto/unit/qabstractvideosurface/qabstractvideosurface.pro7
-rw-r--r--tests/auto/unit/qabstractvideosurface/tst_qabstractvideosurface.cpp396
-rw-r--r--tests/auto/unit/qaudiobuffer/qaudiobuffer.pro10
-rw-r--r--tests/auto/unit/qaudiobuffer/tst_qaudiobuffer.cpp397
-rw-r--r--tests/auto/unit/qaudiodecoder/qaudiodecoder.pro15
-rw-r--r--tests/auto/unit/qaudiodecoder/tst_qaudiodecoder.cpp413
-rw-r--r--tests/auto/unit/qaudioformat/qaudioformat.pro7
-rw-r--r--tests/auto/unit/qaudionamespace/qaudionamespace.pro7
-rw-r--r--tests/auto/unit/qaudioprobe/qaudioprobe.pro10
-rw-r--r--tests/auto/unit/qaudioprobe/tst_qaudioprobe.cpp183
-rw-r--r--tests/auto/unit/qaudiorecorder/qaudiorecorder.pro10
-rw-r--r--tests/auto/unit/qaudiorecorder/tst_qaudiorecorder.cpp180
-rw-r--r--tests/auto/unit/qcamera/qcamera.pro9
-rw-r--r--tests/auto/unit/qcamera/tst_qcamera.cpp2523
-rw-r--r--tests/auto/unit/qcameraimagecapture/qcameraimagecapture.pro10
-rw-r--r--tests/auto/unit/qcameraimagecapture/tst_qcameraimagecapture.cpp422
-rw-r--r--tests/auto/unit/qcamerainfo/qcamerainfo.pro9
-rw-r--r--tests/auto/unit/qcamerainfo/tst_qcamerainfo.cpp204
-rw-r--r--tests/auto/unit/qcameraviewfinder/qcameraviewfinder.pro10
-rw-r--r--tests/auto/unit/qcameraviewfinder/tst_qcameraviewfinder.cpp101
-rw-r--r--tests/auto/unit/qcamerawidgets/qcamerawidgets.pro11
-rw-r--r--tests/auto/unit/qcamerawidgets/tst_qcamerawidgets.cpp304
-rw-r--r--tests/auto/unit/qdeclarativeaudio/qdeclarativeaudio.pro20
-rw-r--r--tests/auto/unit/qdeclarativeaudio/tst_qdeclarativeaudio.cpp1257
-rw-r--r--tests/auto/unit/qdeclarativecamera/qdeclarativecamera.pro14
-rw-r--r--tests/auto/unit/qdeclarativecamera/tst_qdeclarativecamera.cpp42
-rw-r--r--tests/auto/unit/qdeclarativecamera/tst_qdeclarativecamera.qml296
-rw-r--r--tests/auto/unit/qdeclarativemultimediaglobal/qdeclarativemultimediaglobal.pro14
-rw-r--r--tests/auto/unit/qdeclarativemultimediaglobal/tst_qdeclarativemultimediaglobal.cpp42
-rw-r--r--tests/auto/unit/qdeclarativemultimediaglobal/tst_qdeclarativemultimediaglobal.qml180
-rw-r--r--tests/auto/unit/qdeclarativevideo/qdeclarativevideo.pro18
-rw-r--r--tests/auto/unit/qdeclarativevideo/tst_qdeclarativevideo.cpp978
-rw-r--r--tests/auto/unit/qgraphicsvideoitem/qgraphicsvideoitem.pro8
-rw-r--r--tests/auto/unit/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp705
-rw-r--r--tests/auto/unit/qmediabindableinterface/qmediabindableinterface.pro10
-rw-r--r--tests/auto/unit/qmediabindableinterface/tst_qmediabindableinterface.cpp124
-rw-r--r--tests/auto/unit/qmediacontainercontrol/qmediacontainercontrol.pro9
-rw-r--r--tests/auto/unit/qmediacontainercontrol/tst_qmediacontainercontrol.cpp66
-rw-r--r--tests/auto/unit/qmediacontent/qmediacontent.pro6
-rw-r--r--tests/auto/unit/qmediacontent/tst_qmediacontent.cpp160
-rw-r--r--tests/auto/unit/qmediaobject/qmediaobject.pro8
-rw-r--r--tests/auto/unit/qmediaobject/tst_qmediaobject.cpp502
-rw-r--r--tests/auto/unit/qmediaplayer/qmediaplayer.pro8
-rw-r--r--tests/auto/unit/qmediaplayer/testdata.qrc5
-rw-r--r--tests/auto/unit/qmediaplayer/tst_qmediaplayer.cpp1399
-rw-r--r--tests/auto/unit/qmediaplayerwidgets/qmediaplayerwidgets.pro7
-rw-r--r--tests/auto/unit/qmediaplayerwidgets/tst_qmediaplayerwidgets.cpp174
-rw-r--r--tests/auto/unit/qmediaplaylist/qmediaplaylist.pro13
-rw-r--r--tests/auto/unit/qmediaplaylistnavigator/qmediaplaylistnavigator.pro7
-rw-r--r--tests/auto/unit/qmediaplaylistnavigator/tst_qmediaplaylistnavigator.cpp509
-rw-r--r--tests/auto/unit/qmediapluginloader/qmediapluginloader.pro6
-rw-r--r--tests/auto/unit/qmediapluginloader/tst_qmediapluginloader.cpp110
-rw-r--r--tests/auto/unit/qmediarecorder/qmediarecorder.pro7
-rw-r--r--tests/auto/unit/qmediarecorder/tst_qmediarecorder.cpp1497
-rw-r--r--tests/auto/unit/qmediaservice/qmediaservice.pro6
-rw-r--r--tests/auto/unit/qmediaservice/tst_qmediaservice.cpp267
-rw-r--r--tests/auto/unit/qmediaserviceprovider/mockservice.h46
-rw-r--r--tests/auto/unit/qmediaserviceprovider/mockserviceplugin1/mockserviceplugin1.cpp78
-rw-r--r--tests/auto/unit/qmediaserviceprovider/mockserviceplugin1/mockserviceplugin1.json4
-rw-r--r--tests/auto/unit/qmediaserviceprovider/mockserviceplugin1/mockserviceplugin1.pro22
-rw-r--r--tests/auto/unit/qmediaserviceprovider/mockserviceplugin2/mockserviceplugin2.cpp85
-rw-r--r--tests/auto/unit/qmediaserviceprovider/mockserviceplugin2/mockserviceplugin2.json4
-rw-r--r--tests/auto/unit/qmediaserviceprovider/mockserviceplugin2/mockserviceplugin2.pro22
-rw-r--r--tests/auto/unit/qmediaserviceprovider/mockserviceplugin3/mockserviceplugin3.cpp114
-rw-r--r--tests/auto/unit/qmediaserviceprovider/mockserviceplugin3/mockserviceplugin3.json4
-rw-r--r--tests/auto/unit/qmediaserviceprovider/mockserviceplugin3/mockserviceplugin3.pro22
-rw-r--r--tests/auto/unit/qmediaserviceprovider/mockserviceplugin4/mockserviceplugin4.cpp86
-rw-r--r--tests/auto/unit/qmediaserviceprovider/mockserviceplugin4/mockserviceplugin4.json4
-rw-r--r--tests/auto/unit/qmediaserviceprovider/mockserviceplugin4/mockserviceplugin4.pro22
-rw-r--r--tests/auto/unit/qmediaserviceprovider/mockserviceplugin5/mockserviceplugin5.cpp105
-rw-r--r--tests/auto/unit/qmediaserviceprovider/mockserviceplugin5/mockserviceplugin5.json4
-rw-r--r--tests/auto/unit/qmediaserviceprovider/mockserviceplugin5/mockserviceplugin5.pro22
-rw-r--r--tests/auto/unit/qmediaserviceprovider/qmediaserviceprovider.pro14
-rw-r--r--tests/auto/unit/qmediaserviceprovider/test/test.pro17
-rw-r--r--tests/auto/unit/qmediaserviceprovider/tst_qmediaserviceprovider.cpp381
-rw-r--r--tests/auto/unit/qmediatimerange/qmediatimerange.pro7
-rw-r--r--tests/auto/unit/qmetadatareadercontrol/qmetadatareadercontrol.pro9
-rw-r--r--tests/auto/unit/qmetadatareadercontrol/tst_qmetadatareadercontrol.cpp110
-rw-r--r--tests/auto/unit/qmetadatawritercontrol/qmetadatawritercontrol.pro8
-rw-r--r--tests/auto/unit/qmetadatawritercontrol/tst_qmetadatawritercontrol.cpp74
-rw-r--r--tests/auto/unit/qmultimedia_common/mock.pri8
-rw-r--r--tests/auto/unit/qmultimedia_common/mockaudiodecodercontrol.h206
-rw-r--r--tests/auto/unit/qmultimedia_common/mockaudiodecoderservice.h81
-rw-r--r--tests/auto/unit/qmultimedia_common/mockaudioencodercontrol.h94
-rw-r--r--tests/auto/unit/qmultimedia_common/mockaudioinputselector.h104
-rw-r--r--tests/auto/unit/qmultimedia_common/mockaudioprobecontrol.h48
-rw-r--r--tests/auto/unit/qmultimedia_common/mockaudiorolecontrol.h66
-rw-r--r--tests/auto/unit/qmultimedia_common/mockavailabilitycontrol.h62
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcamera.pri26
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcameracapturebuffercontrol.h70
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcameracapturedestinationcontrol.h67
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcameracontrol.h132
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcameraexposurecontrol.h280
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcameraflashcontrol.h76
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcamerafocuscontrol.h124
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcameraimagecapturecontrol.h118
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcameraimageprocessingcontrol.h150
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcamerainfocontrol.h72
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcameralockscontrol.h131
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcameraservice.h198
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcameraviewfindersettingscontrol.h106
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcamerazoomcontrol.h121
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcontainer.pri7
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcustomaudiorolecontrol.h65
-rw-r--r--tests/auto/unit/qmultimedia_common/mockdecoder.pri9
-rw-r--r--tests/auto/unit/qmultimedia_common/mockimageencodercontrol.h90
-rw-r--r--tests/auto/unit/qmultimedia_common/mockmediacontainercontrol.h84
-rw-r--r--tests/auto/unit/qmultimedia_common/mockmediaobject.h44
-rw-r--r--tests/auto/unit/qmultimedia_common/mockmediaplayercontrol.h120
-rw-r--r--tests/auto/unit/qmultimedia_common/mockmediaplayerservice.h170
-rw-r--r--tests/auto/unit/qmultimedia_common/mockmediaplaylistcontrol.h136
-rw-r--r--tests/auto/unit/qmultimedia_common/mockmediaplaylistsourcecontrol.h61
-rw-r--r--tests/auto/unit/qmultimedia_common/mockmediarecordercontrol.h164
-rw-r--r--tests/auto/unit/qmultimedia_common/mockmediarecorderservice.h99
-rw-r--r--tests/auto/unit/qmultimedia_common/mockmediaservice.h65
-rw-r--r--tests/auto/unit/qmultimedia_common/mockmediaserviceprovider.h108
-rw-r--r--tests/auto/unit/qmultimedia_common/mockmediastreamscontrol.h65
-rw-r--r--tests/auto/unit/qmultimedia_common/mockmetadatareadercontrol.h87
-rw-r--r--tests/auto/unit/qmultimedia_common/mockmetadatawritercontrol.h93
-rw-r--r--tests/auto/unit/qmultimedia_common/mockplayer.pri15
-rw-r--r--tests/auto/unit/qmultimedia_common/mockplaylist.pri8
-rw-r--r--tests/auto/unit/qmultimedia_common/mockplaylistservice.h64
-rw-r--r--tests/auto/unit/qmultimedia_common/mockreadonlyplaylistprovider.h55
-rw-r--r--tests/auto/unit/qmultimedia_common/mockrecorder.pri15
-rw-r--r--tests/auto/unit/qmultimedia_common/mockvideo.pri10
-rw-r--r--tests/auto/unit/qmultimedia_common/mockvideodeviceselectorcontrol.h86
-rw-r--r--tests/auto/unit/qmultimedia_common/mockvideoencodercontrol.h79
-rw-r--r--tests/auto/unit/qmultimedia_common/mockvideoprobecontrol.h48
-rw-r--r--tests/auto/unit/qmultimedia_common/mockvideorenderercontrol.h45
-rw-r--r--tests/auto/unit/qmultimedia_common/mockvideosurface.h46
-rw-r--r--tests/auto/unit/qmultimedia_common/mockvideowindowcontrol.h58
-rw-r--r--tests/auto/unit/qpaintervideosurface/qpaintervideosurface.pro13
-rw-r--r--tests/auto/unit/qpaintervideosurface/tst_qpaintervideosurface.cpp1279
-rw-r--r--tests/auto/unit/qsamplecache/qsamplecache.pro8
-rw-r--r--tests/auto/unit/qvideoencodersettingscontrol/qvideoencodersettingscontrol.pro8
-rw-r--r--tests/auto/unit/qvideoencodersettingscontrol/tst_qvideoencodersettingscontrol.cpp105
-rw-r--r--tests/auto/unit/qvideoframe/qvideoframe.pro7
-rw-r--r--tests/auto/unit/qvideoframe/tst_qvideoframe.cpp1316
-rw-r--r--tests/auto/unit/qvideoprobe/qvideoprobe.pro10
-rw-r--r--tests/auto/unit/qvideoprobe/tst_qvideoprobe.cpp176
-rw-r--r--tests/auto/unit/qvideosurfaceformat/qvideosurfaceformat.pro7
-rw-r--r--tests/auto/unit/qvideosurfaceformat/tst_qvideosurfaceformat.cpp912
-rw-r--r--tests/auto/unit/qvideowidget/qvideowidget.pro8
-rw-r--r--tests/auto/unit/qvideowidget/tst_qvideowidget.cpp1643
-rwxr-xr-xtests/auto/unit/qwavedecoder/data/gendata.sh55
-rw-r--r--tests/auto/unit/qwavedecoder/qwavedecoder.pro9
-rw-r--r--tests/auto/unit/unit.pro5
687 files changed, 11811 insertions, 25853 deletions
diff --git a/tests/auto/unit/CMakeLists.txt b/tests/auto/unit/CMakeLists.txt
new file mode 100644
index 000000000..d43c29198
--- /dev/null
+++ b/tests/auto/unit/CMakeLists.txt
@@ -0,0 +1,10 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+# Generated from unit.pro.
+
+add_subdirectory(mockbackend)
+add_subdirectory(multimedia)
+if(TARGET Qt::Widgets)
+ add_subdirectory(multimediawidgets)
+endif()
diff --git a/tests/auto/unit/mockbackend/CMakeLists.txt b/tests/auto/unit/mockbackend/CMakeLists.txt
new file mode 100644
index 000000000..959341366
--- /dev/null
+++ b/tests/auto/unit/mockbackend/CMakeLists.txt
@@ -0,0 +1,33 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+# Generated from mockbackend.pro.
+
+#####################################################################
+## MockMultimediaPlugin Generic Library:
+#####################################################################
+
+qt_internal_add_plugin(MockMultimediaPlugin
+ STATIC
+ OUTPUT_NAME mockmultimediaplugin
+ PLUGIN_TYPE multimedia
+ OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../plugins"
+ DEFAULT_IF FALSE
+ SOURCES
+ qmockaudiodecoder.cpp qmockaudiodecoder.h
+ qmockaudiooutput.h
+ qmockcamera.cpp qmockcamera.h
+ qmockimagecapture.cpp qmockimagecapture.h
+ qmockmediaplayer.h
+ qmockmediaencoder.h
+ qmockmediacapturesession.h
+ qmockvideosink.h
+ qmockmediadevices.cpp qmockmediadevices.h
+ qmockintegration.cpp qmockintegration.h
+ LIBRARIES
+ Qt::MultimediaPrivate
+ Qt::CorePrivate
+)
+
+#### Keys ignored in scope 1:.:.:mockbackend.pro:<TRUE>:
+# TEMPLATE = "lib"
diff --git a/tests/auto/unit/mockbackend/mock.json b/tests/auto/unit/mockbackend/mock.json
new file mode 100644
index 000000000..499a3de8c
--- /dev/null
+++ b/tests/auto/unit/mockbackend/mock.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "mock" ]
+}
diff --git a/tests/auto/unit/mockbackend/qmockaudiodecoder.cpp b/tests/auto/unit/mockbackend/qmockaudiodecoder.cpp
new file mode 100644
index 000000000..3c6b940a9
--- /dev/null
+++ b/tests/auto/unit/mockbackend/qmockaudiodecoder.cpp
@@ -0,0 +1,139 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include "qmockaudiodecoder.h"
+
+QT_BEGIN_NAMESPACE
+
+QMockAudioDecoder::QMockAudioDecoder(QAudioDecoder *parent)
+ : QPlatformAudioDecoder(parent), mDevice(0), mPosition(-1), mSerial(0)
+{
+ mFormat.setChannelCount(1);
+ mFormat.setSampleFormat(QAudioFormat::UInt8);
+ mFormat.setSampleRate(1000);
+}
+
+QUrl QMockAudioDecoder::source() const
+{
+ return mSource;
+}
+
+void QMockAudioDecoder::setSource(const QUrl &fileName)
+{
+ mSource = fileName;
+ mDevice = 0;
+ stop();
+}
+
+QIODevice *QMockAudioDecoder::sourceDevice() const
+{
+ return mDevice;
+}
+
+void QMockAudioDecoder::setSourceDevice(QIODevice *device)
+{
+ mDevice = device;
+ mSource.clear();
+ stop();
+}
+
+QAudioFormat QMockAudioDecoder::audioFormat() const
+{
+ return mFormat;
+}
+
+void QMockAudioDecoder::setAudioFormat(const QAudioFormat &format)
+{
+ if (mFormat != format) {
+ mFormat = format;
+ formatChanged(mFormat);
+ }
+}
+
+// When decoding we decode to first buffer, then second buffer
+// we then stop until the first is read again and so on, for
+// 5 buffers
+void QMockAudioDecoder::start()
+{
+ if (!isDecoding()) {
+ if (!mSource.isEmpty()) {
+ setIsDecoding(true);
+ durationChanged(duration());
+
+ QTimer::singleShot(50, this, &QMockAudioDecoder::pretendDecode);
+ } else {
+ error(QAudioDecoder::ResourceError, "No source set");
+ }
+ }
+}
+
+void QMockAudioDecoder::stop()
+{
+ if (isDecoding()) {
+ mSerial = 0;
+ mPosition = 0;
+ mBuffers.clear();
+ setIsDecoding(false);
+ bufferAvailableChanged(false);
+ }
+}
+
+QAudioBuffer QMockAudioDecoder::read()
+{
+ QAudioBuffer a;
+ if (mBuffers.size() > 0) {
+ a = mBuffers.takeFirst();
+ mPosition = a.startTime() / 1000;
+ positionChanged(mPosition);
+
+ if (mBuffers.isEmpty())
+ bufferAvailableChanged(false);
+
+ if (mBuffers.isEmpty() && mSerial >= MOCK_DECODER_MAX_BUFFERS) {
+ finished();
+ } else
+ QTimer::singleShot(50, this, &QMockAudioDecoder::pretendDecode);
+ }
+
+ return a;
+}
+
+bool QMockAudioDecoder::bufferAvailable() const
+{
+ return mBuffers.size() > 0;
+}
+
+qint64 QMockAudioDecoder::position() const
+{
+ return mPosition;
+}
+
+qint64 QMockAudioDecoder::duration() const
+{
+ return (sizeof(mSerial) * MOCK_DECODER_MAX_BUFFERS * qint64(1000))
+ / (mFormat.sampleRate() * mFormat.channelCount());
+}
+
+void QMockAudioDecoder::pretendDecode()
+{
+ // Check if we've reached end of stream
+ if (mSerial >= MOCK_DECODER_MAX_BUFFERS)
+ return;
+
+ // We just keep the length of mBuffers to 3 or less.
+ if (mBuffers.size() < 3) {
+ QByteArray b(sizeof(mSerial), 0);
+ memcpy(b.data(), &mSerial, sizeof(mSerial));
+ qint64 position = (sizeof(mSerial) * mSerial * qint64(1000000))
+ / (mFormat.sampleRate() * mFormat.channelCount());
+ mSerial++;
+ mBuffers.push_back(QAudioBuffer(b, mFormat, position));
+ bufferReady();
+ if (mBuffers.size() == 1)
+ bufferAvailableChanged(true);
+ }
+}
+
+QT_END_NAMESPACE
+
+#include "moc_qmockaudiodecoder.cpp"
diff --git a/tests/auto/unit/mockbackend/qmockaudiodecoder.h b/tests/auto/unit/mockbackend/qmockaudiodecoder.h
new file mode 100644
index 000000000..89e21ef23
--- /dev/null
+++ b/tests/auto/unit/mockbackend/qmockaudiodecoder.h
@@ -0,0 +1,69 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef MOCKAUDIODECODERCONTROL_H
+#define MOCKAUDIODECODERCONTROL_H
+
+#include "private/qplatformaudiodecoder_p.h"
+
+#include <QtCore/qpair.h>
+#include <QtCore/qurl.h>
+
+#include "qaudiobuffer.h"
+#include <QTimer>
+#include <QIODevice>
+
+#define MOCK_DECODER_MAX_BUFFERS 10
+
+QT_BEGIN_NAMESPACE
+
+class QMockAudioDecoder : public QPlatformAudioDecoder
+{
+ Q_OBJECT
+
+public:
+ QMockAudioDecoder(QAudioDecoder *parent = nullptr);
+
+ QUrl source() const override;
+
+ void setSource(const QUrl &fileName) override;
+
+ QIODevice *sourceDevice() const override;
+
+ void setSourceDevice(QIODevice *device) override;
+
+ QAudioFormat audioFormat() const override;
+
+ void setAudioFormat(const QAudioFormat &format) override;
+
+ // When decoding we decode to first buffer, then second buffer
+ // we then stop until the first is read again and so on, for
+ // 5 buffers
+ void start() override;
+
+ void stop() override;
+
+ QAudioBuffer read() override;
+
+ bool bufferAvailable() const override;
+
+ qint64 position() const override;
+
+ qint64 duration() const override;
+
+private slots:
+ void pretendDecode();
+
+public:
+ QUrl mSource;
+ QIODevice *mDevice;
+ QAudioFormat mFormat;
+ qint64 mPosition;
+
+ int mSerial;
+ QList<QAudioBuffer> mBuffers;
+};
+
+QT_END_NAMESPACE
+
+#endif // QAUDIODECODERCONTROL_H
diff --git a/tests/auto/unit/mockbackend/qmockaudiooutput.h b/tests/auto/unit/mockbackend/qmockaudiooutput.h
new file mode 100644
index 000000000..a35fc8fe4
--- /dev/null
+++ b/tests/auto/unit/mockbackend/qmockaudiooutput.h
@@ -0,0 +1,30 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+#ifndef QMOCKAUDIOOUTPUT_H
+#define QMOCKAUDIOOUTPUT_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qplatformaudiooutput_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QMockAudioOutput : public QPlatformAudioOutput
+{
+public:
+ QMockAudioOutput(QAudioOutput *qq) : QPlatformAudioOutput(qq) {}
+};
+
+QT_END_NAMESPACE
+
+
+#endif // QMOCKAUDIOOUTPUT_H
diff --git a/tests/auto/unit/mockbackend/qmockcamera.cpp b/tests/auto/unit/mockbackend/qmockcamera.cpp
new file mode 100644
index 000000000..23ecc36ae
--- /dev/null
+++ b/tests/auto/unit/mockbackend/qmockcamera.cpp
@@ -0,0 +1,158 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include "qmockcamera.h"
+
+QT_BEGIN_NAMESPACE
+
+QMockCamera::QMockCamera(QCamera *parent)
+ : QPlatformCamera(parent), m_propertyChangesSupported(false)
+{
+ if (!simpleCamera) {
+ minIsoChanged(100);
+ maxIsoChanged(800);
+ minExposureTimeChanged(.001f);
+ maxExposureTimeChanged(1.f);
+ exposureCompensationRangeChanged(-2, 2);
+ maximumZoomFactorChanged(4.);
+ setFlashMode(QCamera::FlashAuto);
+ }
+}
+
+QMockCamera::~QMockCamera() { }
+
+bool QMockCamera::isActive() const
+{
+ return m_active;
+}
+
+void QMockCamera::setActive(bool active)
+{
+ if (m_active == active)
+ return;
+ m_active = active;
+ emit activeChanged(active);
+}
+
+void QMockCamera::setCamera(const QCameraDevice &camera)
+{
+ m_camera = camera;
+}
+
+bool QMockCamera::setCameraFormat(const QCameraFormat &format)
+{
+ if (!format.isNull() && !m_camera.videoFormats().contains(format))
+ return false;
+ return true;
+}
+
+void QMockCamera::setFocusMode(QCamera::FocusMode mode)
+{
+ if (isFocusModeSupported(mode))
+ focusModeChanged(mode);
+}
+
+bool QMockCamera::isFocusModeSupported(QCamera::FocusMode mode) const
+{
+ return simpleCamera ? mode == QCamera::FocusModeAuto : mode != QCamera::FocusModeInfinity;
+}
+
+void QMockCamera::setCustomFocusPoint(const QPointF &point)
+{
+ if (!simpleCamera)
+ customFocusPointChanged(point);
+}
+
+void QMockCamera::setFocusDistance(float d)
+{
+ if (!simpleCamera)
+ focusDistanceChanged(d);
+}
+
+void QMockCamera::zoomTo(float newZoomFactor, float /*rate*/)
+{
+ zoomFactorChanged(newZoomFactor);
+}
+
+void QMockCamera::setFlashMode(QCamera::FlashMode mode)
+{
+ if (!simpleCamera)
+ flashModeChanged(mode);
+ flashReadyChanged(mode != QCamera::FlashOff);
+}
+bool QMockCamera::isFlashModeSupported(QCamera::FlashMode mode) const
+{
+ return simpleCamera ? mode == QCamera::FlashOff : true;
+}
+
+bool QMockCamera::isFlashReady() const
+{
+ return flashMode() != QCamera::FlashOff;
+}
+
+void QMockCamera::setExposureMode(QCamera::ExposureMode mode)
+{
+ if (!simpleCamera && isExposureModeSupported(mode))
+ exposureModeChanged(mode);
+}
+
+bool QMockCamera::isExposureModeSupported(QCamera::ExposureMode mode) const
+{
+ return simpleCamera ? mode == QCamera::ExposureAuto : mode <= QCamera::ExposureBeach;
+}
+
+void QMockCamera::setExposureCompensation(float c)
+{
+ if (!simpleCamera)
+ exposureCompensationChanged(qBound(-2., c, 2.));
+}
+
+int QMockCamera::isoSensitivity() const
+{
+ if (simpleCamera)
+ return -1;
+ return manualIsoSensitivity() > 0 ? manualIsoSensitivity() : 100;
+}
+
+void QMockCamera::setManualIsoSensitivity(int iso)
+{
+ if (!simpleCamera)
+ isoSensitivityChanged(qBound(100, iso, 800));
+}
+
+void QMockCamera::setManualExposureTime(float secs)
+{
+ if (!simpleCamera)
+ exposureTimeChanged(qBound(0.001, secs, 1.));
+}
+
+float QMockCamera::exposureTime() const
+{
+ if (simpleCamera)
+ return -1.;
+ return manualExposureTime() > 0 ? manualExposureTime() : .05;
+}
+
+bool QMockCamera::isWhiteBalanceModeSupported(QCamera::WhiteBalanceMode mode) const
+{
+ if (simpleCamera)
+ return mode == QCamera::WhiteBalanceAuto;
+ return mode == QCamera::WhiteBalanceAuto || mode == QCamera::WhiteBalanceManual
+ || mode == QCamera::WhiteBalanceSunlight;
+}
+
+void QMockCamera::setWhiteBalanceMode(QCamera::WhiteBalanceMode mode)
+{
+ if (isWhiteBalanceModeSupported(mode))
+ whiteBalanceModeChanged(mode);
+}
+
+void QMockCamera::setColorTemperature(int temperature)
+{
+ if (!simpleCamera)
+ colorTemperatureChanged(temperature);
+}
+
+QT_END_NAMESPACE
+
+#include "moc_qmockcamera.cpp"
diff --git a/tests/auto/unit/mockbackend/qmockcamera.h b/tests/auto/unit/mockbackend/qmockcamera.h
new file mode 100644
index 000000000..3d8159e84
--- /dev/null
+++ b/tests/auto/unit/mockbackend/qmockcamera.h
@@ -0,0 +1,81 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef QMOCKCAMERA_H
+#define QMOCKCAMERA_H
+
+#include "private/qplatformcamera_p.h"
+#include "qcameradevice.h"
+#include <qtimer.h>
+
+QT_BEGIN_NAMESPACE
+
+class QMockCamera : public QPlatformCamera
+{
+ friend class MockCaptureControl;
+ Q_OBJECT
+
+ static bool simpleCamera;
+public:
+
+ struct Simple {
+ Simple() { simpleCamera = true; }
+ ~Simple() { simpleCamera = false; }
+ };
+
+ QMockCamera(QCamera *parent);
+
+ ~QMockCamera() override;
+
+ bool isActive() const override;
+
+ void setActive(bool active) override;
+
+ void setCamera(const QCameraDevice &camera) override;
+
+ bool setCameraFormat(const QCameraFormat &format) override;
+
+ void setFocusMode(QCamera::FocusMode mode) override;
+
+ bool isFocusModeSupported(QCamera::FocusMode mode) const override;
+
+ void setCustomFocusPoint(const QPointF &point) override;
+
+ void setFocusDistance(float d) override;
+
+ void zoomTo(float newZoomFactor, float /*rate*/) override;
+
+ void setFlashMode(QCamera::FlashMode mode) override;
+
+ bool isFlashModeSupported(QCamera::FlashMode mode) const override;
+
+ bool isFlashReady() const override;
+
+ void setExposureMode(QCamera::ExposureMode mode) override;
+
+ bool isExposureModeSupported(QCamera::ExposureMode mode) const override;
+
+ void setExposureCompensation(float c) override;
+
+ int isoSensitivity() const override;
+
+ void setManualIsoSensitivity(int iso) override;
+
+ void setManualExposureTime(float secs) override;
+
+ float exposureTime() const override;
+
+ bool isWhiteBalanceModeSupported(QCamera::WhiteBalanceMode mode) const override;
+
+ void setWhiteBalanceMode(QCamera::WhiteBalanceMode mode) override;
+
+ void setColorTemperature(int temperature) override;
+
+ bool m_active = false;
+ QCameraDevice m_camera;
+ bool m_propertyChangesSupported;
+};
+
+QT_END_NAMESPACE
+
+#endif // QMOCKCAMERA_H
diff --git a/tests/auto/unit/mockbackend/qmockimagecapture.cpp b/tests/auto/unit/mockbackend/qmockimagecapture.cpp
new file mode 100644
index 000000000..96e53b2f4
--- /dev/null
+++ b/tests/auto/unit/mockbackend/qmockimagecapture.cpp
@@ -0,0 +1,59 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <qmockimagecapture.h>
+#include <qmockcamera.h>
+#include <qmockmediacapturesession.h>
+#include <qimagecapture.h>
+#include <qcamera.h>
+
+QT_BEGIN_NAMESPACE
+
+QMockImageCapture::QMockImageCapture(QImageCapture *parent)
+ : QPlatformImageCapture(parent)
+{
+}
+
+bool QMockImageCapture::isReadyForCapture() const
+{
+ return m_ready;
+}
+
+int QMockImageCapture::capture(const QString &fileName)
+{
+ if (isReadyForCapture()) {
+ m_fileName = fileName;
+ m_captureRequest++;
+ emit readyForCaptureChanged(m_ready = false);
+ QTimer::singleShot(5, this, &QMockImageCapture::captured);
+ return m_captureRequest;
+ } else {
+ emit error(-1, QImageCapture::NotReadyError,
+ QLatin1String("Could not capture in stopped state"));
+ }
+
+ return -1;
+}
+
+void QMockImageCapture::captured()
+{
+ emit imageCaptured(m_captureRequest, QImage());
+
+ QMediaMetaData metaData;
+ metaData.insert(QMediaMetaData::Author, QStringLiteral("Author"));
+ metaData.insert(QMediaMetaData::Date, QDateTime(QDate(2021, 1, 1), QTime()));
+
+ emit imageMetadataAvailable(m_captureRequest, metaData);
+
+ if (!m_ready)
+ {
+ emit readyForCaptureChanged(m_ready = true);
+ emit imageExposed(m_captureRequest);
+ }
+
+ emit imageSaved(m_captureRequest, m_fileName);
+}
+
+QT_END_NAMESPACE
+
+#include "moc_qmockimagecapture.cpp"
diff --git a/tests/auto/unit/mockbackend/qmockimagecapture.h b/tests/auto/unit/mockbackend/qmockimagecapture.h
new file mode 100644
index 000000000..376f53cbc
--- /dev/null
+++ b/tests/auto/unit/mockbackend/qmockimagecapture.h
@@ -0,0 +1,48 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef QMOCKCAMERAIMAGECAPTURE_H
+#define QMOCKCAMERAIMAGECAPTURE_H
+
+#include <QDateTime>
+#include <QTimer>
+#include <QtMultimedia/qmediametadata.h>
+
+#include "private/qplatformimagecapture_p.h"
+#include "private/qplatformcamera_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QMockMediaCaptureSession;
+
+class QMockImageCapture : public QPlatformImageCapture
+{
+ Q_OBJECT
+public:
+ QMockImageCapture(QImageCapture *parent);
+
+ ~QMockImageCapture()
+ {
+ }
+
+ bool isReadyForCapture() const override;
+
+ int capture(const QString &fileName) override;
+ int captureToBuffer() override { return -1; }
+
+ QImageEncoderSettings imageSettings() const override { return m_settings; }
+ void setImageSettings(const QImageEncoderSettings &settings) override { m_settings = settings; }
+
+private Q_SLOTS:
+ void captured();
+
+private:
+ QString m_fileName;
+ int m_captureRequest = 0;
+ bool m_ready = true;
+ QImageEncoderSettings m_settings;
+};
+
+QT_END_NAMESPACE
+
+#endif // QMOCKCAMERAIMAGECAPTURE_H
diff --git a/tests/auto/unit/mockbackend/qmockintegration.cpp b/tests/auto/unit/mockbackend/qmockintegration.cpp
new file mode 100644
index 000000000..b554b31e0
--- /dev/null
+++ b/tests/auto/unit/mockbackend/qmockintegration.cpp
@@ -0,0 +1,198 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QtMultimedia/private/qplatformmediaplugin_p.h>
+#include "qmockintegration.h"
+#include "qmockmediaplayer.h"
+#include "qmockaudiodecoder.h"
+#include "qmockcamera.h"
+#include "qmockmediacapturesession.h"
+#include "qmockvideosink.h"
+#include "qmockimagecapture.h"
+#include "qmockaudiooutput.h"
+#include "qmocksurfacecapture.h"
+#include <private/qcameradevice_p.h>
+#include <private/qplatformvideodevices_p.h>
+
+#include "qmockmediadevices.h"
+
+QT_BEGIN_NAMESPACE
+
+class MockMultimediaPlugin : public QPlatformMediaPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QPlatformMediaPlugin_iid FILE "mock.json")
+
+public:
+ MockMultimediaPlugin() : QPlatformMediaPlugin() { }
+
+ QPlatformMediaIntegration *create(const QString &name) override
+ {
+ if (name == QLatin1String("mock"))
+ return new QMockIntegration;
+ return nullptr;
+ }
+};
+
+class QMockVideoDevices : public QPlatformVideoDevices
+{
+public:
+ QMockVideoDevices(QPlatformMediaIntegration *pmi)
+ : QPlatformVideoDevices(pmi)
+ {
+ QCameraDevicePrivate *info = new QCameraDevicePrivate;
+ info->description = QStringLiteral("defaultCamera");
+ info->id = "default";
+ info->isDefault = true;
+ auto *f = new QCameraFormatPrivate{
+ QSharedData(),
+ QVideoFrameFormat::Format_ARGB8888,
+ QSize(640, 480),
+ 0,
+ 30
+ };
+ info->videoFormats << f->create();
+ m_cameraDevices.append(info->create());
+ info = new QCameraDevicePrivate;
+ info->description = QStringLiteral("frontCamera");
+ info->id = "front";
+ info->isDefault = false;
+ info->position = QCameraDevice::FrontFace;
+ f = new QCameraFormatPrivate{
+ QSharedData(),
+ QVideoFrameFormat::Format_XRGB8888,
+ QSize(1280, 720),
+ 0,
+ 30
+ };
+ info->videoFormats << f->create();
+ m_cameraDevices.append(info->create());
+ info = new QCameraDevicePrivate;
+ info->description = QStringLiteral("backCamera");
+ info->id = "back";
+ info->isDefault = false;
+ info->position = QCameraDevice::BackFace;
+ m_cameraDevices.append(info->create());
+ }
+
+ void addNewCamera()
+ {
+ auto info = new QCameraDevicePrivate;
+ info->description = QLatin1String("newCamera") + QString::number(m_cameraDevices.size());
+ info->id =
+ QString(QLatin1String("camera") + QString::number(m_cameraDevices.size())).toUtf8();
+ info->isDefault = false;
+ m_cameraDevices.append(info->create());
+
+ emit videoInputsChanged();
+ }
+
+ QList<QCameraDevice> videoDevices() const override
+ {
+ return m_cameraDevices;
+ }
+
+private:
+ QList<QCameraDevice> m_cameraDevices;
+};
+
+QMockIntegration::QMockIntegration() : QPlatformMediaIntegration(QLatin1String("mock")) { }
+QMockIntegration::~QMockIntegration() = default;
+
+QPlatformVideoDevices *QMockIntegration::createVideoDevices()
+{
+ return new QMockVideoDevices(this);
+}
+
+std::unique_ptr<QPlatformMediaDevices> QMockIntegration::createMediaDevices()
+{
+ return std::make_unique<QMockMediaDevices>();
+}
+
+QMaybe<QPlatformAudioDecoder *> QMockIntegration::createAudioDecoder(QAudioDecoder *decoder)
+{
+ if (m_flags & NoAudioDecoderInterface)
+ m_lastAudioDecoderControl = nullptr;
+ else
+ m_lastAudioDecoderControl = new QMockAudioDecoder(decoder);
+ return m_lastAudioDecoderControl;
+}
+
+QMaybe<QPlatformMediaPlayer *> QMockIntegration::createPlayer(QMediaPlayer *parent)
+{
+ if (m_flags & NoPlayerInterface)
+ m_lastPlayer = nullptr;
+ else
+ m_lastPlayer = new QMockMediaPlayer(parent);
+ return m_lastPlayer;
+}
+
+QMaybe<QPlatformCamera *> QMockIntegration::createCamera(QCamera *parent)
+{
+ if (m_flags & NoCaptureInterface)
+ m_lastCamera = nullptr;
+ else
+ m_lastCamera = new QMockCamera(parent);
+ return m_lastCamera;
+}
+
+QMaybe<QPlatformImageCapture *> QMockIntegration::createImageCapture(QImageCapture *capture)
+{
+ return new QMockImageCapture(capture);
+}
+
+QMaybe<QPlatformMediaRecorder *> QMockIntegration::createRecorder(QMediaRecorder *recorder)
+{
+ return new QMockMediaEncoder(recorder);
+}
+
+QPlatformSurfaceCapture *QMockIntegration::createScreenCapture(QScreenCapture * /*capture*/)
+{
+ if (m_flags & NoCaptureInterface)
+ m_lastScreenCapture = nullptr;
+ else
+ m_lastScreenCapture = new QMockSurfaceCapture(QPlatformSurfaceCapture::ScreenSource{});
+
+ return m_lastScreenCapture;
+}
+
+QPlatformSurfaceCapture *QMockIntegration::createWindowCapture(QWindowCapture *)
+{
+ if (m_flags & NoCaptureInterface)
+ m_lastWindowCapture = nullptr;
+ else
+ m_lastWindowCapture = new QMockSurfaceCapture(QPlatformSurfaceCapture::WindowSource{});
+
+ return m_lastWindowCapture;
+}
+
+QMaybe<QPlatformMediaCaptureSession *> QMockIntegration::createCaptureSession()
+{
+ if (m_flags & NoCaptureInterface)
+ m_lastCaptureService = nullptr;
+ else
+ m_lastCaptureService = new QMockMediaCaptureSession();
+ return m_lastCaptureService;
+}
+
+QMaybe<QPlatformVideoSink *> QMockIntegration::createVideoSink(QVideoSink *sink)
+{
+ m_lastVideoSink = new QMockVideoSink(sink);
+ return m_lastVideoSink;
+}
+
+QMaybe<QPlatformAudioOutput *> QMockIntegration::createAudioOutput(QAudioOutput *q)
+{
+ return new QMockAudioOutput(q);
+}
+
+void QMockIntegration::addNewCamera()
+{
+ static_cast<QMockVideoDevices *>(videoDevices())->addNewCamera();
+}
+
+bool QMockCamera::simpleCamera = false;
+
+QT_END_NAMESPACE
+
+#include "qmockintegration.moc"
diff --git a/tests/auto/unit/mockbackend/qmockintegration.h b/tests/auto/unit/mockbackend/qmockintegration.h
new file mode 100644
index 000000000..20b61721c
--- /dev/null
+++ b/tests/auto/unit/mockbackend/qmockintegration.h
@@ -0,0 +1,103 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef QMOCKINTEGRATION_H
+#define QMOCKINTEGRATION_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qplatformmediaintegration_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QMockMediaPlayer;
+class QMockAudioDecoder;
+class QMockCamera;
+class QMockMediaCaptureSession;
+class QMockVideoSink;
+class QMockSurfaceCapture;
+
+class QMockIntegration : public QPlatformMediaIntegration
+{
+public:
+ QMockIntegration();
+ ~QMockIntegration();
+
+ static QMockIntegration *instance()
+ {
+ return static_cast<QMockIntegration *>(QPlatformMediaIntegration::instance());
+ }
+
+ QMaybe<QPlatformAudioDecoder *> createAudioDecoder(QAudioDecoder *decoder) override;
+ QMaybe<QPlatformMediaPlayer *> createPlayer(QMediaPlayer *) override;
+ QMaybe<QPlatformCamera *> createCamera(QCamera *) override;
+ QMaybe<QPlatformMediaRecorder *> createRecorder(QMediaRecorder *) override;
+ QMaybe<QPlatformImageCapture *> createImageCapture(QImageCapture *) override;
+ QMaybe<QPlatformMediaCaptureSession *> createCaptureSession() override;
+ QMaybe<QPlatformVideoSink *> createVideoSink(QVideoSink *) override;
+
+ QMaybe<QPlatformAudioOutput *> createAudioOutput(QAudioOutput *) override;
+
+ QPlatformSurfaceCapture *createScreenCapture(QScreenCapture *) override;
+ QPlatformSurfaceCapture *createWindowCapture(QWindowCapture *) override;
+
+ void addNewCamera();
+
+ enum Flag { NoPlayerInterface = 0x1, NoAudioDecoderInterface = 0x2, NoCaptureInterface = 0x4 };
+ Q_DECLARE_FLAGS(Flags, Flag);
+
+ void setFlags(Flags f) { m_flags = f; }
+ Flags flags() const { return m_flags; }
+
+ QMockMediaPlayer *lastPlayer() const { return m_lastPlayer; }
+ QMockAudioDecoder *lastAudioDecoder() const { return m_lastAudioDecoderControl; }
+ QMockCamera *lastCamera() const { return m_lastCamera; }
+ // QMockMediaEncoder *lastEncoder const { return m_lastEncoder; }
+ QMockMediaCaptureSession *lastCaptureService() const { return m_lastCaptureService; }
+ QMockVideoSink *lastVideoSink() const { return m_lastVideoSink; }
+ QMockSurfaceCapture *lastScreenCapture() { return m_lastScreenCapture; }
+ QMockSurfaceCapture *lastWindowCapture() { return m_lastWindowCapture; }
+
+protected:
+ QPlatformVideoDevices *createVideoDevices() override;
+ std::unique_ptr<QPlatformMediaDevices> createMediaDevices() override;
+
+private:
+
+ Flags m_flags = {};
+ QMockMediaPlayer *m_lastPlayer = nullptr;
+ QMockAudioDecoder *m_lastAudioDecoderControl = nullptr;
+ QMockCamera *m_lastCamera = nullptr;
+ // QMockMediaEncoder *m_lastEncoder = nullptr;
+ QMockMediaCaptureSession *m_lastCaptureService = nullptr;
+ QMockVideoSink *m_lastVideoSink = nullptr;
+ QMockSurfaceCapture *m_lastScreenCapture = nullptr;
+ QMockSurfaceCapture *m_lastWindowCapture = nullptr;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QMockIntegration::Flags);
+
+#define Q_ENABLE_MOCK_MULTIMEDIA_PLUGIN \
+ Q_IMPORT_PLUGIN(MockMultimediaPlugin) \
+ struct EnableMockPlugin \
+ { \
+ EnableMockPlugin() \
+ { \
+ qputenv("QT_MEDIA_BACKEND", "mock"); \
+ } \
+ }; \
+ static EnableMockPlugin s_mockMultimediaPluginEnabler;
+
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/tests/auto/unit/mockbackend/qmockmediacapturesession.h b/tests/auto/unit/mockbackend/qmockmediacapturesession.h
new file mode 100644
index 000000000..0a2d3fb60
--- /dev/null
+++ b/tests/auto/unit/mockbackend/qmockmediacapturesession.h
@@ -0,0 +1,86 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef QMOCKMEDIACAPTURESESSION_H
+#define QMOCKMEDIACAPTURESESSION_H
+
+#include "qmockmediaencoder.h"
+#include "qmockimagecapture.h"
+#include "qmockcamera.h"
+#include "qmockimagecapture.h"
+#include "qmocksurfacecapture.h"
+#include <private/qplatformmediacapture_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QMockMediaCaptureSession : public QPlatformMediaCaptureSession
+{
+public:
+ QMockMediaCaptureSession()
+ : hasControls(true)
+ {
+ }
+ ~QMockMediaCaptureSession()
+ {
+ }
+
+ QPlatformCamera *camera() override { return hasControls ? mockCameraControl : nullptr; }
+
+ void setCamera(QPlatformCamera *camera) override
+ {
+ QMockCamera *control = static_cast<QMockCamera *>(camera);
+ if (mockCameraControl == control)
+ return;
+
+ mockCameraControl = control;
+ }
+
+ void setImageCapture(QPlatformImageCapture *imageCapture) override
+ {
+ mockImageCapture = imageCapture;
+ }
+ QPlatformImageCapture *imageCapture() override { return hasControls ? mockImageCapture : nullptr; }
+
+ QPlatformMediaRecorder *mediaRecorder() override { return hasControls ? mockControl : nullptr; }
+ void setMediaRecorder(QPlatformMediaRecorder *recorder) override
+ {
+ if (!hasControls) {
+ mockControl = nullptr;
+ return;
+ }
+ QMockMediaEncoder *control = static_cast<QMockMediaEncoder *>(recorder);
+ if (mockControl == control)
+ return;
+
+ mockControl = control;
+ }
+
+ void setVideoPreview(QVideoSink *) override {}
+
+ void setAudioInput(QPlatformAudioInput *input) override
+ {
+ m_audioInput = input;
+ }
+
+ QPlatformSurfaceCapture *screenCapture() override { return m_screenCapture; }
+ void setScreenCapture(QPlatformSurfaceCapture *capture) override { m_screenCapture = capture; }
+
+ QPlatformSurfaceCapture *windowCapture() override { return m_windowCapture; }
+ void setWindowCapture(QPlatformSurfaceCapture *capture) override { m_windowCapture = capture; }
+
+ QPlatformVideoFrameInput *videoFrameInput() override { return m_videoFrameInput; }
+ void setVideoFrameInput(QPlatformVideoFrameInput *input) override { m_videoFrameInput = input; }
+
+ QMockCamera *mockCameraControl = nullptr;
+ QPlatformImageCapture *mockImageCapture = nullptr;
+ QMockMediaEncoder *mockControl = nullptr;
+ QPlatformAudioInput *m_audioInput = nullptr;
+ QPlatformSurfaceCapture *m_screenCapture = nullptr;
+ QPlatformSurfaceCapture *m_windowCapture = nullptr;
+ QPlatformVideoFrameInput *m_videoFrameInput = nullptr;
+ bool hasControls;
+};
+
+QT_END_NAMESPACE
+
+#endif // QMOCKMEDIACAPTURESESSION_H
diff --git a/tests/auto/unit/mockbackend/qmockmediadevices.cpp b/tests/auto/unit/mockbackend/qmockmediadevices.cpp
new file mode 100644
index 000000000..7f2478741
--- /dev/null
+++ b/tests/auto/unit/mockbackend/qmockmediadevices.cpp
@@ -0,0 +1,43 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include "qmockmediadevices.h"
+#include "private/qcameradevice_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QMockMediaDevices::QMockMediaDevices()
+ : QPlatformMediaDevices()
+{
+}
+
+QMockMediaDevices::~QMockMediaDevices() = default;
+
+QList<QAudioDevice> QMockMediaDevices::audioInputs() const
+{
+ return m_inputDevices;
+}
+
+QList<QAudioDevice> QMockMediaDevices::audioOutputs() const
+{
+ return m_outputDevices;
+}
+
+QPlatformAudioSource *QMockMediaDevices::createAudioSource(const QAudioDevice &info,
+ QObject *parent)
+{
+ Q_UNUSED(info);
+ Q_UNUSED(parent);
+ return nullptr;// ###
+}
+
+QPlatformAudioSink *QMockMediaDevices::createAudioSink(const QAudioDevice &info,
+ QObject *parent)
+{
+ Q_UNUSED(info);
+ Q_UNUSED(parent);
+ return nullptr; //###
+}
+
+
+QT_END_NAMESPACE
diff --git a/tests/auto/unit/mockbackend/qmockmediadevices.h b/tests/auto/unit/mockbackend/qmockmediadevices.h
new file mode 100644
index 000000000..e9e823194
--- /dev/null
+++ b/tests/auto/unit/mockbackend/qmockmediadevices.h
@@ -0,0 +1,45 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef QMOCKMEDIADEVICES_H
+#define QMOCKMEDIADEVICES_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qplatformmediadevices_p.h>
+#include <qelapsedtimer.h>
+#include <qaudiodevice.h>
+#include <qcameradevice.h>
+
+QT_BEGIN_NAMESPACE
+
+class QCameraDevice;
+
+class QMockMediaDevices : public QPlatformMediaDevices
+{
+public:
+ QMockMediaDevices();
+ ~QMockMediaDevices();
+
+ QList<QAudioDevice> audioInputs() const override;
+ QList<QAudioDevice> audioOutputs() const override;
+ QPlatformAudioSource *createAudioSource(const QAudioDevice &info, QObject *parent) override;
+ QPlatformAudioSink *createAudioSink(const QAudioDevice &info, QObject *parent) override;
+
+private:
+ QList<QAudioDevice> m_inputDevices;
+ QList<QAudioDevice> m_outputDevices;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/tests/auto/unit/mockbackend/qmockmediaencoder.h b/tests/auto/unit/mockbackend/qmockmediaencoder.h
new file mode 100644
index 000000000..cf855488b
--- /dev/null
+++ b/tests/auto/unit/mockbackend/qmockmediaencoder.h
@@ -0,0 +1,95 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef MOCKRECORDERCONTROL_H
+#define MOCKRECORDERCONTROL_H
+
+#include <QUrl>
+#include <qaudiodevice.h>
+
+#include "private/qplatformmediarecorder_p.h"
+
+class QMockMediaEncoder : public QPlatformMediaRecorder
+{
+public:
+ QMockMediaEncoder(QMediaRecorder *parent):
+ QPlatformMediaRecorder(parent),
+ m_state(QMediaRecorder::StoppedState),
+ m_position(0)
+ {
+ }
+
+ bool isLocationWritable(const QUrl &) const override
+ {
+ return true;
+ }
+
+ QMediaRecorder::RecorderState state() const override
+ {
+ return m_state;
+ }
+
+ qint64 duration() const override
+ {
+ return m_position;
+ }
+
+ virtual void setMetaData(const QMediaMetaData &m) override
+ {
+ m_metaData = m;
+ metaDataChanged();
+ }
+ virtual QMediaMetaData metaData() const override { return m_metaData; }
+
+ using QPlatformMediaRecorder::updateError;
+
+public:
+ void record(QMediaEncoderSettings &settings) override
+ {
+ m_state = QMediaRecorder::RecordingState;
+ m_settings = settings;
+ m_position=1;
+ stateChanged(m_state);
+ durationChanged(m_position);
+
+ QUrl actualLocation = outputLocation().isEmpty() ? QUrl::fromLocalFile("default_name.mp4") : outputLocation();
+ actualLocationChanged(actualLocation);
+ }
+
+ void pause() override
+ {
+ m_state = QMediaRecorder::PausedState;
+ stateChanged(m_state);
+ }
+
+ void resume() override
+ {
+ m_state = QMediaRecorder::RecordingState;
+ stateChanged(m_state);
+ }
+
+ void stop() override
+ {
+ m_position=0;
+ m_state = QMediaRecorder::StoppedState;
+ stateChanged(m_state);
+ }
+
+ void reset()
+ {
+ m_state = QMediaRecorder::StoppedState;
+ m_settings = QMediaEncoderSettings();
+ m_position = 0;
+ stateChanged(m_state);
+ durationChanged(m_position);
+ clearActualLocation();
+ }
+
+public:
+ QMediaMetaData m_metaData;
+ QMediaRecorder::RecorderState m_state;
+ QMediaEncoderSettings m_settings;
+ qint64 m_position;
+};
+
+#endif // MOCKRECORDERCONTROL_H
diff --git a/tests/auto/unit/mockbackend/qmockmediaplayer.h b/tests/auto/unit/mockbackend/qmockmediaplayer.h
new file mode 100644
index 000000000..a3ba76beb
--- /dev/null
+++ b/tests/auto/unit/mockbackend/qmockmediaplayer.h
@@ -0,0 +1,175 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef QMOCKMEDIAPLAYER_H
+#define QMOCKMEDIAPLAYER_H
+
+#include "private/qplatformmediaplayer_p.h"
+#include <qurl.h>
+
+QT_BEGIN_NAMESPACE
+
+class QMockMediaPlayer : public QPlatformMediaPlayer
+{
+ friend class QMockMediaPlayerService;
+
+public:
+ QMockMediaPlayer(QMediaPlayer *parent)
+ : QPlatformMediaPlayer(parent)
+ , _state(QMediaPlayer::StoppedState)
+ , _error(QMediaPlayer::NoError)
+ , _duration(0)
+ , _position(0)
+ , _bufferProgress(0)
+ , _audioAvailable(false)
+ , _videoAvailable(false)
+ , _isSeekable(true)
+ , _playbackRate(qreal(1.0))
+ , _stream(0)
+ , _isValid(false)
+ {
+ }
+ ~QMockMediaPlayer()
+ {
+ }
+
+ QMediaPlayer::PlaybackState state() const override { return _state; }
+ void updateState(QMediaPlayer::PlaybackState state) { setState(state); }
+ void updateMediaStatus(QMediaPlayer::MediaStatus status, QMediaPlayer::PlaybackState state)
+ {
+ _state = state;
+
+ mediaStatusChanged(status);
+ stateChanged(_state);
+ }
+
+ qint64 duration() const override { return _duration; }
+ void setDuration(qint64 duration) { durationChanged(_duration = duration); }
+
+ qint64 position() const override { return _position; }
+
+ void setPosition(qint64 position) override
+ {
+ if (position != _position)
+ positionChanged(_position = position);
+ }
+
+ float bufferProgress() const override { return _bufferProgress; }
+ void setBufferStatus(float status)
+ {
+ if (_bufferProgress == status)
+ return;
+ _bufferProgress = status;
+ bufferProgressChanged(status);
+ }
+
+ bool isAudioAvailable() const override { return _audioAvailable; }
+ bool isVideoAvailable() const override { return _videoAvailable; }
+
+ bool isSeekable() const override { return _isSeekable; }
+ void setSeekable(bool seekable) { seekableChanged(_isSeekable = seekable); }
+
+ QMediaTimeRange availablePlaybackRanges() const override { return QMediaTimeRange(_seekRange.first, _seekRange.second); }
+ void setSeekRange(qint64 minimum, qint64 maximum) { _seekRange = qMakePair(minimum, maximum); }
+
+ qreal playbackRate() const override { return _playbackRate; }
+ void setPlaybackRate(qreal rate) override
+ {
+ if (rate != _playbackRate)
+ playbackRateChanged(_playbackRate = rate);
+ }
+
+ QUrl media() const override { return _media; }
+ void setMedia(const QUrl &content, QIODevice *stream) override
+ {
+ _stream = stream;
+ _media = content;
+ setState(QMediaPlayer::StoppedState);
+ mediaStatusChanged(_media.isEmpty() ? QMediaPlayer::NoMedia : QMediaPlayer::LoadingMedia);
+ }
+ QIODevice *mediaStream() const override { return _stream; }
+
+ bool streamPlaybackSupported() const override { return m_supportsStreamPlayback; }
+ void setStreamPlaybackSupported(bool b) { m_supportsStreamPlayback = b; }
+
+ void play() override { if (_isValid && !_media.isEmpty()) setState(QMediaPlayer::PlayingState); }
+ void pause() override { if (_isValid && !_media.isEmpty()) setState(QMediaPlayer::PausedState); }
+ void stop() override { if (_state != QMediaPlayer::StoppedState) setState(QMediaPlayer::StoppedState); }
+
+ void setVideoSink(QVideoSink *) override {}
+
+ void setAudioOutput(QPlatformAudioOutput *output) override { m_audioOutput = output; }
+
+ void emitError(QMediaPlayer::Error err, const QString &errorString) { error(err, errorString); }
+
+ void setState(QMediaPlayer::PlaybackState state)
+ {
+ if (_state == state)
+ return;
+ _state = state;
+ stateChanged(state);
+ }
+ void setState(QMediaPlayer::PlaybackState state, QMediaPlayer::MediaStatus status)
+ {
+ _state = state;
+ mediaStatusChanged(status);
+ stateChanged(state);
+ }
+ void setMediaStatus(QMediaPlayer::MediaStatus status)
+ {
+ if (status == QMediaPlayer::StalledMedia || status == QMediaPlayer::BufferingMedia)
+ bufferProgressChanged(_bufferProgress);
+ mediaStatusChanged(status);
+ }
+ void setIsValid(bool isValid) { _isValid = isValid; }
+ void setMedia(QUrl media) { _media = media; }
+ void setVideoAvailable(bool videoAvailable) { _videoAvailable = videoAvailable; }
+ void setError(QMediaPlayer::Error err)
+ {
+ _error = err;
+ error(_error, _errorString);
+ }
+ void setErrorString(QString errorString)
+ {
+ _errorString = errorString;
+ error(_error, _errorString);
+ }
+
+ void reset()
+ {
+ _state = QMediaPlayer::StoppedState;
+ _error = QMediaPlayer::NoError;
+ _duration = 0;
+ _position = 0;
+ _bufferProgress = 0;
+ _videoAvailable = false;
+ _isSeekable = false;
+ _playbackRate = 0.0;
+ _media = QUrl();
+ _stream = 0;
+ _isValid = false;
+ _errorString = QString();
+ }
+
+
+ QMediaPlayer::PlaybackState _state;
+ QMediaPlayer::Error _error;
+ qint64 _duration;
+ qint64 _position;
+ float _bufferProgress;
+ bool _audioAvailable;
+ bool _videoAvailable;
+ bool _isSeekable;
+ QPair<qint64, qint64> _seekRange;
+ qreal _playbackRate;
+ QUrl _media;
+ QIODevice *_stream;
+ bool _isValid;
+ QString _errorString;
+ bool m_supportsStreamPlayback = false;
+ QPlatformAudioOutput *m_audioOutput = nullptr;
+};
+
+QT_END_NAMESPACE
+
+#endif // QMOCKMEDIAPLAYER_H
diff --git a/tests/auto/unit/mockbackend/qmocksurfacecapture.h b/tests/auto/unit/mockbackend/qmocksurfacecapture.h
new file mode 100644
index 000000000..00ce80ebb
--- /dev/null
+++ b/tests/auto/unit/mockbackend/qmocksurfacecapture.h
@@ -0,0 +1,88 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef QMOCKSURFACECAPTURE_H
+#define QMOCKSURFACECAPTURE_H
+
+#include "private/qplatformsurfacecapture_p.h"
+#include "private/qvideoframe_p.h"
+
+#include "qmockvideobuffer.h"
+#include "qthread.h"
+
+QT_BEGIN_NAMESPACE
+
+class QMockSurfaceCapture : public QPlatformSurfaceCapture
+{
+ class Grabber : public QThread
+ {
+ public:
+ Grabber(QMockSurfaceCapture &capture) : QThread(&capture), m_capture(capture) { }
+
+ void run() override
+ {
+ for (int i = 0; !isInterruptionRequested(); ++i) {
+ QImage image(m_capture.m_imageSize, QImage::Format_ARGB32);
+
+ image.fill(i % 2 ? Qt::red : Qt::blue);
+
+ QVideoFrame frame = QVideoFramePrivate::createFrame(
+ std::make_unique<QMockVideoBuffer>(image),
+ QVideoFrameFormat(m_capture.m_imageSize,
+ QVideoFrameFormat::pixelFormatFromImageFormat(
+ m_capture.m_imageFormat)));
+
+ emit m_capture.newVideoFrame(frame);
+ }
+ }
+
+ private:
+ QMockSurfaceCapture &m_capture;
+ };
+
+public:
+ using QPlatformSurfaceCapture::QPlatformSurfaceCapture;
+
+ ~QMockSurfaceCapture() { resetGrabber(); }
+
+ bool setActiveInternal(bool active) override
+ {
+ if (active) {
+ m_grabber = std::make_unique<Grabber>(*this);
+ m_grabber->start();
+ } else {
+ resetGrabber();
+ }
+
+ return true;
+ }
+
+ bool isActive() const override { return bool(m_grabber); }
+
+ QVideoFrameFormat frameFormat() const override
+ {
+ return m_grabber ? QVideoFrameFormat(
+ m_imageSize, QVideoFrameFormat::pixelFormatFromImageFormat(m_imageFormat))
+ : QVideoFrameFormat{};
+ }
+
+private:
+ void resetGrabber()
+ {
+ if (m_grabber) {
+ m_grabber->requestInterruption();
+ m_grabber->quit();
+ m_grabber->wait();
+ m_grabber.reset();
+ }
+ }
+
+private:
+ std::unique_ptr<Grabber> m_grabber;
+ const QImage::Format m_imageFormat = QImage::Format_ARGB32;
+ const QSize m_imageSize = QSize(2, 3);
+};
+
+QT_END_NAMESPACE
+
+#endif // QMOCKSURFACECAPTURE_H
diff --git a/tests/auto/unit/mockbackend/qmockvideobuffer.h b/tests/auto/unit/mockbackend/qmockvideobuffer.h
new file mode 100644
index 000000000..0ee32416c
--- /dev/null
+++ b/tests/auto/unit/mockbackend/qmockvideobuffer.h
@@ -0,0 +1,38 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef QMOCKVIDEOBUFFER_H
+#define QMOCKVIDEOBUFFER_H
+
+#include "qimage.h"
+#include "private/qhwvideobuffer_p.h"
+
+class QMockVideoBuffer : public QHwVideoBuffer
+{
+public:
+ QMockVideoBuffer(QImage image) : QHwVideoBuffer(QVideoFrame::NoHandle), m_image(image) { }
+
+ MapData map(QtVideo::MapMode mode) override
+ {
+ MapData mapData;
+ if (m_mapMode == QtVideo::MapMode::NotMapped && !m_image.isNull()
+ && mode != QtVideo::MapMode::NotMapped) {
+ m_mapMode = mode;
+
+ mapData.planeCount = 1;
+ mapData.bytesPerLine[0] = m_image.bytesPerLine();
+ mapData.data[0] = m_image.bits();
+ mapData.dataSize[0] = m_image.sizeInBytes();
+ }
+
+ return mapData;
+ }
+
+ void unmap() override { m_mapMode = QtVideo::MapMode::NotMapped; }
+
+private:
+ QtVideo::MapMode m_mapMode = QtVideo::MapMode::NotMapped;
+ QImage m_image;
+};
+
+#endif // QMOCKVIDEOBUFFER_H
diff --git a/tests/auto/unit/mockbackend/qmockvideosink.h b/tests/auto/unit/mockbackend/qmockvideosink.h
new file mode 100644
index 000000000..d93178668
--- /dev/null
+++ b/tests/auto/unit/mockbackend/qmockvideosink.h
@@ -0,0 +1,33 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef QMOCKVIDEOSINK_H
+#define QMOCKVIDEOSINK_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qplatformvideosink_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QMockVideoSink : public QPlatformVideoSink
+{
+public:
+ explicit QMockVideoSink(QVideoSink *parent)
+ : QPlatformVideoSink(parent)
+ {}
+ void setRhi(QRhi * /*rhi*/) override {}
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/tests/auto/unit/multimedia.pro b/tests/auto/unit/multimedia.pro
deleted file mode 100644
index 3e0311a66..000000000
--- a/tests/auto/unit/multimedia.pro
+++ /dev/null
@@ -1,34 +0,0 @@
-
-TEMPLATE = subdirs
-SUBDIRS += \
- qabstractvideobuffer \
- qabstractvideosurface \
- qaudiorecorder \
- qaudioformat \
- qaudionamespace \
- qcamera \
- qcamerainfo \
- qcameraimagecapture \
- qmediabindableinterface \
- qmediacontainercontrol \
- qmediacontent \
- qmediaobject \
- qmediaplayer \
- qmediaplaylist \
- qmediaplaylistnavigator \
- qmediapluginloader \
- qmediarecorder \
- qmediaservice \
- qmediaserviceprovider \
- qmediatimerange \
- qmetadatareadercontrol \
- qmetadatawritercontrol \
- qvideoencodersettingscontrol \
- qvideoframe \
- qvideosurfaceformat \
- qwavedecoder \
- qaudiobuffer \
- qaudiodecoder \
- qaudioprobe \
- qvideoprobe \
- qsamplecache
diff --git a/tests/auto/unit/multimedia/CMakeLists.txt b/tests/auto/unit/multimedia/CMakeLists.txt
new file mode 100644
index 000000000..f259691d0
--- /dev/null
+++ b/tests/auto/unit/multimedia/CMakeLists.txt
@@ -0,0 +1,40 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+# Generated from multimedia.pro.
+
+add_subdirectory(qabstractvideobuffer)
+add_subdirectory(qaudiorecorder)
+add_subdirectory(qaudioformat)
+add_subdirectory(qaudionamespace)
+add_subdirectory(qaudiostatemachine)
+add_subdirectory(qcamera)
+add_subdirectory(qcameradevice)
+add_subdirectory(qimagecapture)
+add_subdirectory(qmediaformat)
+add_subdirectory(qmediaplayer)
+#add_subdirectory(qmediaplaylist)
+add_subdirectory(qmediarecorder)
+add_subdirectory(qmediatimerange)
+add_subdirectory(qmultimediautils)
+add_subdirectory(qvideoframe)
+add_subdirectory(qvideoframeformat)
+if(QT_FEATURE_ffmpeg)
+ add_subdirectory(qvideoframecolormanagement)
+endif()
+add_subdirectory(qaudiobuffer)
+add_subdirectory(qaudiodecoder)
+add_subdirectory(qsamplecache)
+add_subdirectory(qscreencapture)
+add_subdirectory(qvideotexturehelper)
+add_subdirectory(qmaybe)
+add_subdirectory(qmediadevices)
+add_subdirectory(qerrorinfo)
+add_subdirectory(qvideobuffers)
+add_subdirectory(qwavedecoder)
+
+if(QT_FEATURE_gstreamer)
+ add_subdirectory(gstreamer_backend)
+ add_subdirectory(qmediacapture_gstreamer)
+ add_subdirectory(qmediaplayer_gstreamer)
+endif()
diff --git a/tests/auto/unit/multimedia/gstreamer_backend/CMakeLists.txt b/tests/auto/unit/multimedia/gstreamer_backend/CMakeLists.txt
new file mode 100644
index 000000000..6d52d09e1
--- /dev/null
+++ b/tests/auto/unit/multimedia/gstreamer_backend/CMakeLists.txt
@@ -0,0 +1,15 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+#####################################################################
+## tst_gstreamer_backend Test:
+#####################################################################
+
+qt_internal_add_test(tst_gstreamer_backend
+ SOURCES
+ tst_gstreamer_backend.cpp
+ tst_gstreamer_backend.h
+ LIBRARIES
+ Qt::MultimediaPrivate
+ Qt::QGstreamerMediaPluginPrivate
+)
diff --git a/tests/auto/unit/multimedia/gstreamer_backend/tst_gstreamer_backend.cpp b/tests/auto/unit/multimedia/gstreamer_backend/tst_gstreamer_backend.cpp
new file mode 100644
index 000000000..929c46b3e
--- /dev/null
+++ b/tests/auto/unit/multimedia/gstreamer_backend/tst_gstreamer_backend.cpp
@@ -0,0 +1,309 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include "tst_gstreamer_backend.h"
+
+#include <QtTest/QtTest>
+#include <QtMultimedia/qmediaformat.h>
+
+#include <QtQGstreamerMediaPlugin/private/qgst_handle_types_p.h>
+#include <QtQGstreamerMediaPlugin/private/qgst_p.h>
+#include <QtQGstreamerMediaPlugin/private/qgst_debug_p.h>
+#include <QtQGstreamerMediaPlugin/private/qgstpipeline_p.h>
+#include <QtQGstreamerMediaPlugin/private/qgstreamermetadata_p.h>
+
+QT_USE_NAMESPACE
+
+// NOLINTBEGIN(readability-convert-member-functions-to-static)
+
+using namespace Qt::Literals;
+
+namespace {
+
+template <typename... Pairs>
+QMediaMetaData makeQMediaMetaData(Pairs &&...pairs)
+{
+ QMediaMetaData metadata;
+
+ auto addKeyValuePair = [&](auto &&pair) {
+ metadata.insert(pair.first, pair.second);
+ return;
+ };
+
+ (addKeyValuePair(pairs), ...);
+
+ return metadata;
+}
+
+} // namespace
+
+QGstTagListHandle tst_GStreamer::parseTagList(const char *str)
+{
+ QGstTagListHandle tagList{
+ gst_tag_list_new_from_string(str),
+ QGstTagListHandle::NeedsRef,
+ };
+ return tagList;
+}
+
+QGstTagListHandle tst_GStreamer::parseTagList(const QByteArray &ba)
+{
+ return parseTagList(ba.constData());
+}
+
+void tst_GStreamer::qGstCasts_withElement()
+{
+ QGstElement element = QGstElement::createFromFactory("identity", "myPipeline");
+ QVERIFY(element);
+
+ QVERIFY(!qIsGstObjectOfType<GstPipeline>(element.element()));
+ QVERIFY(!qIsGstObjectOfType<GstBin>(element.element()));
+}
+
+void tst_GStreamer::qGstCasts_withBin()
+{
+ QGstBin bin = QGstBin::create("bin");
+ QVERIFY(bin);
+
+ QVERIFY(!qIsGstObjectOfType<GstPipeline>(bin.element()));
+ QVERIFY(qIsGstObjectOfType<GstBin>(bin.element()));
+}
+
+void tst_GStreamer::qGstCasts_withPipeline()
+{
+ QGstPipeline pipeline = QGstPipeline::create("myPipeline");
+
+ QGstElement element{
+ qGstSafeCast<GstElement>(pipeline.pipeline()),
+ QGstElement::NeedsRef,
+ };
+
+ QVERIFY(element);
+ QVERIFY(qIsGstObjectOfType<GstPipeline>(element.element()));
+ QVERIFY(qIsGstObjectOfType<GstBin>(element.element()));
+}
+
+void tst_GStreamer::metadata_taglistToMetaData()
+{
+ QGstTagListHandle tagList = parseTagList(R"(taglist, title="My Video", comment="yada")");
+
+ QMediaMetaData parsed = taglistToMetaData(tagList);
+
+ QCOMPARE(parsed.stringValue(QMediaMetaData::Title), u"My Video"_s);
+ QCOMPARE(parsed.stringValue(QMediaMetaData::Comment), u"yada"_s);
+}
+
+void tst_GStreamer::metadata_taglistToMetaData_extractsOrientation()
+{
+ QFETCH(QByteArray, taglist);
+ QFETCH(QtVideo::Rotation, rotation);
+
+ QGstTagListHandle tagList = parseTagList(taglist);
+ QMediaMetaData parsed = taglistToMetaData(tagList);
+ QCOMPARE(parsed[QMediaMetaData::Orientation].value<QtVideo::Rotation>(), rotation);
+}
+
+void tst_GStreamer::metadata_taglistToMetaData_extractsOrientation_data()
+{
+ QTest::addColumn<QByteArray>("taglist");
+ QTest::addColumn<QtVideo::Rotation>("rotation");
+
+ QTest::newRow("no rotation") << R"(taglist, title="My Video", comment="yada")"_ba
+ << QtVideo::Rotation::None;
+ QTest::newRow("90 degree")
+ << R"(taglist, title="My Video", comment="yada", image-orientation=(string)rotate-90)"_ba
+ << QtVideo::Rotation::Clockwise90;
+ QTest::newRow("180 degree")
+ << R"(taglist, title="My Video", comment="yada", image-orientation=(string)rotate-180)"_ba
+ << QtVideo::Rotation::Clockwise180;
+ QTest::newRow("270 degree")
+ << R"(taglist, title="My Video", comment="yada", image-orientation=(string)rotate-270)"_ba
+ << QtVideo::Rotation::Clockwise270;
+}
+
+void tst_GStreamer::metadata_taglistToMetaData_extractsDuration()
+{
+ QGstTagListHandle tagList = parseTagList(
+ R"__(taglist, video-codec=(string)"On2\ VP9", container-specific-track-id=(string)1, extended-comment=(string){ "ALPHA_MODE\=1", "HANDLER_NAME\=Apple\ Video\ Media\ Handler", "VENDOR_ID\=appl", "TIMECODE\=00:00:00:00", "DURATION\=00:00:00.400000000" }, encoder=(string)"Lavc59.37.100\ libvpx-vp9")__");
+
+ QMediaMetaData parsed = taglistToMetaData(tagList);
+ QCOMPARE(parsed[QMediaMetaData::Duration].value<int>(), 400);
+}
+
+void tst_GStreamer::metadata_taglistToMetaData_extractsLanguage()
+{
+ QFETCH(QByteArray, tagListString);
+ QFETCH(QLocale::Language, language);
+
+ QGstTagListHandle tagList = parseTagList(tagListString);
+ QVERIFY(tagList);
+
+ QMediaMetaData parsed = taglistToMetaData(tagList);
+ QCOMPARE(parsed[QMediaMetaData::Language].value<QLocale::Language>(), language);
+}
+
+void tst_GStreamer::metadata_taglistToMetaData_extractsLanguage_data()
+{
+ QTest::addColumn<QByteArray>("tagListString");
+ QTest::addColumn<QLocale::Language>("language");
+
+ QTest::newRow("english, en")
+ << R"__(taglist, container-format=(string)Matroska, audio-codec=(string)"MPEG-4\ AAC", language-code=(string)en, container-specific-track-id=(string)5, encoder=(string)Lavf60.16.100, extended-comment=(string)"DURATION\=00:00:05.055000000")__"_ba
+ << QLocale::Language::English;
+ QTest::newRow("spanish, es")
+ << R"__(taglist, container-format=(string)Matroska, audio-codec=(string)"MPEG-4\ AAC", language-code=(string)es, container-specific-track-id=(string)5, encoder=(string)Lavf60.16.100, extended-comment=(string)"DURATION\=00:00:05.055000000")__"_ba
+ << QLocale::Language::Spanish;
+ QTest::newRow("english, eng")
+ << R"__(taglist, container-format=(string)Matroska, audio-codec=(string)"MPEG-4\ AAC", language-code=(string)eng, container-specific-track-id=(string)5, encoder=(string)Lavf60.16.100, extended-comment=(string)"DURATION\=00:00:05.055000000")__"_ba
+ << QLocale::Language::English;
+ QTest::newRow("spanish, spa")
+ << R"__(taglist, container-format=(string)Matroska, audio-codec=(string)"MPEG-4\ AAC", language-code=(string)spa, container-specific-track-id=(string)5, encoder=(string)Lavf60.16.100, extended-comment=(string)"DURATION\=00:00:05.055000000")__"_ba
+ << QLocale::Language::Spanish;
+}
+
+void tst_GStreamer::metadata_capsToMetaData()
+{
+ QFETCH(QByteArray, capsString);
+ QFETCH(QMediaMetaData, expectedMetadata);
+
+ QGstCaps caps{
+ gst_caps_from_string(capsString.constData()),
+ QGstCaps::HasRef,
+ };
+
+ QMediaMetaData md = capsToMetaData(caps);
+
+ QCOMPARE(md, expectedMetadata);
+}
+
+void tst_GStreamer::metadata_capsToMetaData_data()
+{
+ using Key = QMediaMetaData::Key;
+ using KVPair = std::pair<QMediaMetaData::Key, QVariant>;
+
+ auto makeKVPair = [](Key key, auto value) {
+ return KVPair{
+ key,
+ QVariant::fromValue(value),
+ };
+ };
+
+ QTest::addColumn<QByteArray>("capsString");
+ QTest::addColumn<QMediaMetaData>("expectedMetadata");
+
+ QTest::newRow("container") << R"(video/quicktime, variant=(string)iso)"_ba
+ << makeQMediaMetaData(makeKVPair(Key::FileFormat,
+ QMediaFormat::FileFormat::MPEG4));
+
+ QTest::newRow("video")
+ << R"(video/x-h264, stream-format=(string)avc, alignment=(string)au, level=(string)3.1, profile=(string)main, codec_data=(buffer)014d401fffe10017674d401fda014016ec0440000003004000000c83c60ca801000468ef3c80, width=(int)1280, height=(int)720, framerate=(fraction)25/1, pixel-aspect-ratio=(fraction)1/1)"_ba
+ << makeQMediaMetaData(makeKVPair(Key::VideoCodec, QMediaFormat::VideoCodec::H264),
+ makeKVPair(Key::VideoFrameRate, 25),
+ makeKVPair(Key::Resolution, QSize(1280, 720)));
+
+ QTest::newRow("audio")
+ << R"(audio/mpeg, mpegversion=(int)4, framed=(boolean)true, stream-format=(string)raw, level=(string)4, base-profile=(string)lc, profile=(string)lc, codec_data=(buffer)11b0, rate=(int)48000, channels=(int)6)"_ba
+ << makeQMediaMetaData(makeKVPair(Key::AudioCodec, QMediaFormat::AudioCodec::AAC));
+}
+
+void tst_GStreamer::QGstBin_createFromPipelineDescription()
+{
+ QGstBin bin = QGstBin::createFromPipelineDescription("identity name=foo ! identity name=bar");
+
+ QVERIFY(bin);
+ QVERIFY(bin.findByName("foo"));
+ QCOMPARE_EQ(bin.findByName("foo").getParent(), bin);
+ QVERIFY(bin.findByName("bar"));
+ QVERIFY(!bin.findByName("baz"));
+ bin.dumpGraph("QGstBin_createFromPipelineDescription");
+}
+
+void tst_GStreamer::QGstElement_createFromPipelineDescription()
+{
+ using namespace std::string_view_literals;
+ QGstElement element = QGstElement::createFromPipelineDescription("identity name=foo");
+ QCOMPARE_EQ(element.name(), "foo"sv);
+ QCOMPARE_EQ(element.typeName(), "GstIdentity"sv);
+}
+
+void tst_GStreamer::QGstElement_createFromPipelineDescription_multipleElementsCreatesBin()
+{
+ using namespace std::string_view_literals;
+ QGstElement element =
+ QGstElement::createFromPipelineDescription("identity name=foo ! identity name=bar");
+
+ QVERIFY(element);
+ QCOMPARE_EQ(element.typeName(), "GstPipeline"sv);
+
+ QGstBin bin{
+ qGstSafeCast<GstBin>(element.element()),
+ QGstBin::NeedsRef,
+ };
+
+ QVERIFY(bin);
+ QVERIFY(bin.findByName("foo"));
+ QCOMPARE_EQ(bin.findByName("foo").getParent(), bin);
+ QVERIFY(bin.findByName("bar"));
+ QVERIFY(!bin.findByName("baz"));
+
+ bin.dumpGraph("QGstElement_createFromPipelineDescription_multipleElements");
+}
+
+void tst_GStreamer::QGstPad_inferTypeFromName()
+{
+ auto makePad = [](const char *name, GstPadDirection direction) {
+ return QGstPad{
+ gst_pad_new(name, direction),
+ QGstPad::NeedsRef,
+ };
+ };
+
+ QVERIFY(makePad("audio_0", GST_PAD_SRC).inferTrackTypeFromName()
+ == QPlatformMediaPlayer::AudioStream);
+ QVERIFY(makePad("video_0", GST_PAD_SRC).inferTrackTypeFromName()
+ == QPlatformMediaPlayer::VideoStream);
+ QVERIFY(makePad("text_0", GST_PAD_SRC).inferTrackTypeFromName()
+ == QPlatformMediaPlayer::SubtitleStream);
+ QVERIFY(makePad("src_0", GST_PAD_SRC).inferTrackTypeFromName() == std::nullopt);
+ QVERIFY(makePad("text", GST_PAD_SRC).inferTrackTypeFromName() == std::nullopt);
+}
+
+void tst_GStreamer::qDebug_GstPadDirection()
+{
+ auto validate = [](GstPadDirection direction, QString expectedString) {
+ QString str;
+ QDebug dbg(&str);
+
+ dbg << direction;
+
+ QCOMPARE_EQ(str, expectedString);
+ };
+
+ validate(GST_PAD_UNKNOWN, u"GST_PAD_UNKNOWN "_s);
+ validate(GST_PAD_SRC, u"GST_PAD_SRC "_s);
+ validate(GST_PAD_SINK, u"GST_PAD_SINK "_s);
+}
+
+void tst_GStreamer::qDebug_GstStreamStatusType()
+{
+ auto validate = [](GstStreamStatusType type, QString expectedString) {
+ QString str;
+ QDebug dbg(&str);
+
+ dbg << type;
+
+ QCOMPARE_EQ(str, expectedString);
+ };
+
+ validate(GST_STREAM_STATUS_TYPE_CREATE, u"GST_STREAM_STATUS_TYPE_CREATE "_s);
+ validate(GST_STREAM_STATUS_TYPE_ENTER, u"GST_STREAM_STATUS_TYPE_ENTER "_s);
+ validate(GST_STREAM_STATUS_TYPE_LEAVE, u"GST_STREAM_STATUS_TYPE_LEAVE "_s);
+ validate(GST_STREAM_STATUS_TYPE_DESTROY, u"GST_STREAM_STATUS_TYPE_DESTROY "_s);
+ validate(GST_STREAM_STATUS_TYPE_START, u"GST_STREAM_STATUS_TYPE_START "_s);
+ validate(GST_STREAM_STATUS_TYPE_PAUSE, u"GST_STREAM_STATUS_TYPE_PAUSE "_s);
+ validate(GST_STREAM_STATUS_TYPE_STOP, u"GST_STREAM_STATUS_TYPE_STOP "_s);
+}
+
+QTEST_GUILESS_MAIN(tst_GStreamer)
+
+#include "moc_tst_gstreamer_backend.cpp"
diff --git a/tests/auto/unit/multimedia/gstreamer_backend/tst_gstreamer_backend.h b/tests/auto/unit/multimedia/gstreamer_backend/tst_gstreamer_backend.h
new file mode 100644
index 000000000..7252dffdd
--- /dev/null
+++ b/tests/auto/unit/multimedia/gstreamer_backend/tst_gstreamer_backend.h
@@ -0,0 +1,49 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef TST_GSTREAMER_BACKEND_H
+#define TST_GSTREAMER_BACKEND_H
+
+#include <QtTest/QtTest>
+
+#include <QtQGstreamerMediaPlugin/private/qgstreamerintegration_p.h>
+#include <QtQGstreamerMediaPlugin/private/qgst_handle_types_p.h>
+
+QT_USE_NAMESPACE
+
+class tst_GStreamer : public QObject
+{
+ Q_OBJECT
+
+ QGstTagListHandle parseTagList(const char *);
+ QGstTagListHandle parseTagList(const QByteArray &);
+
+private slots:
+ void qGstCasts_withElement();
+ void qGstCasts_withBin();
+ void qGstCasts_withPipeline();
+
+ void metadata_taglistToMetaData();
+ void metadata_taglistToMetaData_extractsOrientation();
+ void metadata_taglistToMetaData_extractsOrientation_data();
+ void metadata_taglistToMetaData_extractsDuration();
+ void metadata_taglistToMetaData_extractsLanguage();
+ void metadata_taglistToMetaData_extractsLanguage_data();
+
+ void metadata_capsToMetaData();
+ void metadata_capsToMetaData_data();
+
+ void QGstBin_createFromPipelineDescription();
+ void QGstElement_createFromPipelineDescription();
+ void QGstElement_createFromPipelineDescription_multipleElementsCreatesBin();
+
+ void QGstPad_inferTypeFromName();
+
+ void qDebug_GstPadDirection();
+ void qDebug_GstStreamStatusType();
+
+private:
+ QGstreamerIntegration integration;
+};
+
+#endif // TST_GSTREAMER_BACKEND_H
diff --git a/tests/auto/unit/multimedia/qabstractvideobuffer/CMakeLists.txt b/tests/auto/unit/multimedia/qabstractvideobuffer/CMakeLists.txt
new file mode 100644
index 000000000..8f59a0e40
--- /dev/null
+++ b/tests/auto/unit/multimedia/qabstractvideobuffer/CMakeLists.txt
@@ -0,0 +1,16 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+# Generated from qabstractvideobuffer.pro.
+
+#####################################################################
+## tst_qabstractvideobuffer Test:
+#####################################################################
+
+qt_internal_add_test(tst_qabstractvideobuffer
+ SOURCES
+ tst_qabstractvideobuffer.cpp
+ LIBRARIES
+ Qt::Gui
+ Qt::MultimediaPrivate
+)
diff --git a/tests/auto/unit/multimedia/qabstractvideobuffer/tst_qabstractvideobuffer.cpp b/tests/auto/unit/multimedia/qabstractvideobuffer/tst_qabstractvideobuffer.cpp
new file mode 100644
index 000000000..852c17f30
--- /dev/null
+++ b/tests/auto/unit/multimedia/qabstractvideobuffer/tst_qabstractvideobuffer.cpp
@@ -0,0 +1,113 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QtTest/QtTest>
+
+#include <private/qhwvideobuffer_p.h>
+
+class tst_QAbstractVideoBuffer : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QAbstractVideoBuffer();
+ ~tst_QAbstractVideoBuffer() override;
+
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+private slots:
+ void handleType_data();
+ void handleType();
+ void handle();
+ void mapModeDebug_data();
+ void mapModeDebug();
+};
+
+class QtTestVideoBuffer : public QHwVideoBuffer
+{
+public:
+ QtTestVideoBuffer(QVideoFrame::HandleType type) : QHwVideoBuffer(type) { }
+
+ MapData map(QtVideo::MapMode) override { return {}; }
+ void unmap() override {}
+};
+
+tst_QAbstractVideoBuffer::tst_QAbstractVideoBuffer()
+{
+}
+
+tst_QAbstractVideoBuffer::~tst_QAbstractVideoBuffer()
+{
+}
+
+void tst_QAbstractVideoBuffer::initTestCase()
+{
+}
+
+void tst_QAbstractVideoBuffer::cleanupTestCase()
+{
+}
+
+void tst_QAbstractVideoBuffer::init()
+{
+}
+
+void tst_QAbstractVideoBuffer::cleanup()
+{
+}
+
+void tst_QAbstractVideoBuffer::handleType_data()
+{
+ QTest::addColumn<QVideoFrame::HandleType>("type");
+ QTest::addColumn<QString>("stringized");
+
+ QTest::newRow("NoHandle") << QVideoFrame::NoHandle << QStringLiteral("NoHandle");
+ QTest::newRow("RhiTextureHandle") << QVideoFrame::RhiTextureHandle << QStringLiteral("RhiTextureHandle");
+}
+
+void tst_QAbstractVideoBuffer::handleType()
+{
+ QFETCH(QVideoFrame::HandleType, type);
+ QFETCH(QString, stringized);
+
+ QtTestVideoBuffer buffer(type);
+
+ QCOMPARE(buffer.handleType(), type);
+
+ QTest::ignoreMessage(QtDebugMsg, stringized.toLatin1().constData());
+ qDebug() << type;
+}
+
+void tst_QAbstractVideoBuffer::handle()
+{
+ QtTestVideoBuffer buffer(QVideoFrame::NoHandle);
+
+ QVERIFY(buffer.textureHandle(nullptr, 0) == 0);
+}
+
+void tst_QAbstractVideoBuffer::mapModeDebug_data()
+{
+ QTest::addColumn<QtVideo::MapMode>("mapMode");
+ QTest::addColumn<QString>("stringized");
+
+ QTest::newRow("NotMapped") << QtVideo::MapMode::NotMapped << QStringLiteral("NotMapped");
+ QTest::newRow("ReadOnly") << QtVideo::MapMode::ReadOnly << QStringLiteral("ReadOnly");
+ QTest::newRow("WriteOnly") << QtVideo::MapMode::WriteOnly << QStringLiteral("WriteOnly");
+ QTest::newRow("ReadWrite") << QtVideo::MapMode::ReadWrite << QStringLiteral("ReadWrite");
+}
+
+void tst_QAbstractVideoBuffer::mapModeDebug()
+{
+ QFETCH(QtVideo::MapMode, mapMode);
+ QFETCH(QString, stringized);
+
+ QTest::ignoreMessage(QtDebugMsg, stringized.toLatin1().constData());
+ qDebug() << mapMode;
+}
+
+QTEST_MAIN(tst_QAbstractVideoBuffer)
+
+#include "tst_qabstractvideobuffer.moc"
diff --git a/tests/auto/unit/multimedia/qaudiobuffer/CMakeLists.txt b/tests/auto/unit/multimedia/qaudiobuffer/CMakeLists.txt
new file mode 100644
index 000000000..807f3acaa
--- /dev/null
+++ b/tests/auto/unit/multimedia/qaudiobuffer/CMakeLists.txt
@@ -0,0 +1,18 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+# Generated from qaudiobuffer.pro.
+
+#####################################################################
+## tst_qaudiobuffer Test:
+#####################################################################
+
+qt_internal_add_test(tst_qaudiobuffer
+ SOURCES
+ tst_qaudiobuffer.cpp
+ LIBRARIES
+ Qt::Multimedia
+)
+
+#### Keys ignored in scope 1:.:.:qaudiobuffer.pro:<TRUE>:
+# TEMPLATE = "app"
diff --git a/tests/auto/unit/multimedia/qaudiobuffer/tst_qaudiobuffer.cpp b/tests/auto/unit/multimedia/qaudiobuffer/tst_qaudiobuffer.cpp
new file mode 100644
index 000000000..7c74fe994
--- /dev/null
+++ b/tests/auto/unit/multimedia/qaudiobuffer/tst_qaudiobuffer.cpp
@@ -0,0 +1,314 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QtCore/QString>
+#include <QtTest/QtTest>
+
+#include <qaudiobuffer.h>
+
+class tst_QAudioBuffer : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QAudioBuffer();
+ ~tst_QAudioBuffer() override;
+
+private Q_SLOTS:
+ void ctors();
+ void assign();
+ void constData() const;
+ void data_const() const;
+ void data();
+ void durations();
+ void durations_data();
+ void stereoSample();
+
+private:
+ QAudioFormat mFormat;
+ QAudioBuffer *mNull;
+ QAudioBuffer *mEmpty;
+ QAudioBuffer *mFromArray;
+};
+
+tst_QAudioBuffer::tst_QAudioBuffer()
+{
+ // Initialize some common buffers
+ mFormat.setChannelCount(2);
+ mFormat.setSampleFormat(QAudioFormat::Int16);
+ mFormat.setSampleRate(10000);
+
+ QByteArray b(4000, char(0x80));
+ mNull = new QAudioBuffer;
+ mEmpty = new QAudioBuffer(500, mFormat); // 500 stereo frames of 16 bits -> 2KB
+ mFromArray = new QAudioBuffer(b, mFormat);
+}
+
+
+tst_QAudioBuffer::~tst_QAudioBuffer()
+{
+ delete mNull;
+ delete mEmpty;
+ delete mFromArray;
+}
+
+void tst_QAudioBuffer::ctors()
+{
+ // Null buffer
+ QVERIFY(!mNull->isValid());
+ QVERIFY(mNull->constData<char>() == nullptr);
+ QVERIFY(mNull->data<char>() == nullptr);
+ QVERIFY(((const QAudioBuffer*)mNull)->data<char>() == nullptr);
+ QCOMPARE(mNull->duration(), 0LL);
+ QCOMPARE(mNull->byteCount(), 0);
+ QCOMPARE(mNull->sampleCount(), 0);
+ QCOMPARE(mNull->frameCount(), 0);
+ QCOMPARE(mNull->startTime(), -1LL);
+
+ // Empty buffer
+ QVERIFY(mEmpty->isValid());
+ QVERIFY(mEmpty->constData<char>() != nullptr);
+ QVERIFY(mEmpty->data<char>() != nullptr);
+ QVERIFY(((const QAudioBuffer*)mEmpty)->data<char>() != nullptr);
+ QCOMPARE(mEmpty->sampleCount(), 1000);
+ QCOMPARE(mEmpty->frameCount(), 500);
+ QCOMPARE(mEmpty->duration(), 50000LL);
+ QCOMPARE(mEmpty->byteCount(), 2000);
+ QCOMPARE(mEmpty->startTime(), -1LL);
+
+ // bytearray buffer
+ QVERIFY(mFromArray->isValid());
+ QVERIFY(mFromArray->constData<char>() != nullptr);
+ QVERIFY(mFromArray->data<char>() != nullptr);
+ QVERIFY(((const QAudioBuffer*)mFromArray)->data<char>() != nullptr);
+ /// 4000 bytes at 10KHz, 2ch, 16bit = 40kBps -> 0.1s
+ QCOMPARE(mFromArray->duration(), 100000LL);
+ QCOMPARE(mFromArray->byteCount(), 4000);
+ QCOMPARE(mFromArray->sampleCount(), 2000);
+ QCOMPARE(mFromArray->frameCount(), 1000);
+ QCOMPARE(mFromArray->startTime(), -1LL);
+
+
+ // Now some invalid buffers
+ QAudioBuffer badFormat(1000, QAudioFormat());
+ QVERIFY(!badFormat.isValid());
+ QVERIFY(badFormat.constData<char>() == nullptr);
+ QVERIFY(badFormat.data<char>() == nullptr);
+ QVERIFY(((const QAudioBuffer*)&badFormat)->data<char>() == nullptr);
+ QCOMPARE(badFormat.duration(), 0LL);
+ QCOMPARE(badFormat.byteCount(), 0);
+ QCOMPARE(badFormat.sampleCount(), 0);
+ QCOMPARE(badFormat.frameCount(), 0);
+ QCOMPARE(badFormat.startTime(), -1LL);
+
+ QAudioBuffer badArray(QByteArray(), mFormat);
+ QVERIFY(!badArray.isValid());
+ QVERIFY(badArray.constData<char>() == nullptr);
+ QVERIFY(badArray.data<char>() == nullptr);
+ QVERIFY(((const QAudioBuffer*)&badArray)->data<char>() == nullptr);
+ QCOMPARE(badArray.duration(), 0LL);
+ QCOMPARE(badArray.byteCount(), 0);
+ QCOMPARE(badArray.sampleCount(), 0);
+ QCOMPARE(badArray.frameCount(), 0);
+ QCOMPARE(badArray.startTime(), -1LL);
+
+ QAudioBuffer badBoth = QAudioBuffer(QByteArray(), QAudioFormat());
+ QVERIFY(!badBoth.isValid());
+ QVERIFY(badBoth.constData<char>() == nullptr);
+ QVERIFY(badBoth.data<char>() == nullptr);
+ QVERIFY(((const QAudioBuffer*)&badBoth)->data<char>() == nullptr);
+ QCOMPARE(badBoth.duration(), 0LL);
+ QCOMPARE(badBoth.byteCount(), 0);
+ QCOMPARE(badBoth.sampleCount(), 0);
+ QCOMPARE(badBoth.frameCount(), 0);
+ QCOMPARE(badBoth.startTime(), -1LL);
+}
+
+void tst_QAudioBuffer::assign()
+{
+ // TODO Needs strong behaviour definition
+}
+
+void tst_QAudioBuffer::constData() const
+{
+ const void *data = mEmpty->constData<void *>();
+ QVERIFY(data != nullptr);
+
+ const unsigned int *idata = reinterpret_cast<const unsigned int*>(data);
+ QCOMPARE(*idata, 0U);
+
+ const QAudioBuffer::U8S *sdata = mEmpty->constData<QAudioBuffer::U8S>();
+ QVERIFY(sdata);
+ QCOMPARE(sdata->value(QAudioFormat::FrontLeft), (unsigned char)0);
+ QCOMPARE(sdata->value(QAudioFormat::FrontRight), (unsigned char)0);
+
+ // The bytearray one should be 0x80
+ data = mFromArray->constData<void *>();
+ QVERIFY(data != nullptr);
+
+ idata = reinterpret_cast<const unsigned int *>(data);
+ QCOMPARE(*idata, 0x80808080);
+
+ sdata = mFromArray->constData<QAudioBuffer::U8S>();
+ QCOMPARE(sdata->value(QAudioFormat::FrontLeft), (unsigned char)0x80);
+ QCOMPARE(sdata->value(QAudioFormat::FrontRight), (unsigned char)0x80);
+}
+
+void tst_QAudioBuffer::data_const() const
+{
+ const void *data = ((const QAudioBuffer*)mEmpty)->data<void *>();
+ QVERIFY(data != nullptr);
+
+ const unsigned int *idata = reinterpret_cast<const unsigned int*>(data);
+ QCOMPARE(*idata, 0U);
+
+ const QAudioBuffer::U8S *sdata = ((const QAudioBuffer*)mEmpty)->constData<QAudioBuffer::U8S>();
+ QVERIFY(sdata);
+ QCOMPARE(sdata->value(QAudioFormat::FrontLeft), (unsigned char)0);
+ QCOMPARE(sdata->value(QAudioFormat::FrontRight), (unsigned char)0);
+
+ // The bytearray one should be 0x80
+ data = ((const QAudioBuffer*)mFromArray)->data<void *>();
+ QVERIFY(data != nullptr);
+
+ idata = reinterpret_cast<const unsigned int *>(data);
+ QCOMPARE(*idata, 0x80808080);
+
+ sdata = ((const QAudioBuffer*)mFromArray)->constData<QAudioBuffer::U8S>();
+ QCOMPARE(sdata->value(QAudioFormat::FrontLeft), (unsigned char)0x80);
+ QCOMPARE(sdata->value(QAudioFormat::FrontRight), (unsigned char)0x80);
+}
+
+void tst_QAudioBuffer::data()
+{
+ void *data = mEmpty->data<void *>();
+ QVERIFY(data != nullptr);
+
+ unsigned int *idata = reinterpret_cast<unsigned int*>(data);
+ QCOMPARE(*idata, 0U);
+
+ QAudioBuffer::U8S *sdata = mEmpty->data<QAudioBuffer::U8S>();
+ QVERIFY(sdata);
+ QCOMPARE(sdata->value(QAudioFormat::FrontLeft), (unsigned char)0);
+ QCOMPARE(sdata->value(QAudioFormat::FrontRight), (unsigned char)0);
+
+ // The bytearray one should be 0x80
+ data = mFromArray->data<void *>();
+ QVERIFY(data != nullptr);
+
+ idata = reinterpret_cast<unsigned int *>(data);
+ QCOMPARE(*idata, 0x80808080);
+
+ sdata = mFromArray->data<QAudioBuffer::U8S>();
+ QCOMPARE(sdata->value(QAudioFormat::FrontLeft), (unsigned char)0x80);
+ QCOMPARE(sdata->value(QAudioFormat::FrontRight), (unsigned char)0x80);
+}
+
+void tst_QAudioBuffer::durations()
+{
+ QFETCH(int, channelCount);
+ QFETCH(int, frameCount);
+ int sampleCount = frameCount * channelCount;
+ QFETCH(QAudioFormat::SampleFormat, sampleFormat);
+ QFETCH(int, sampleRate);
+ QFETCH(qint64, duration);
+ QFETCH(int, byteCount);
+
+ QAudioFormat f;
+ f.setChannelCount(channelCount);
+ f.setSampleFormat(sampleFormat);
+ f.setSampleRate(sampleRate);
+
+ QAudioBuffer b(frameCount, f);
+
+ QCOMPARE(b.frameCount(), frameCount);
+ QCOMPARE(b.sampleCount(), sampleCount);
+ QCOMPARE(b.duration(), duration);
+ QCOMPARE(b.byteCount(), byteCount);
+}
+
+void tst_QAudioBuffer::durations_data()
+{
+ QTest::addColumn<int>("channelCount");
+ QTest::addColumn<int>("frameCount");
+ QTest::addColumn<QAudioFormat::SampleFormat>("sampleFormat");
+ QTest::addColumn<int>("sampleRate");
+ QTest::addColumn<qint64>("duration");
+ QTest::addColumn<int>("byteCount");
+ QTest::newRow("M8_1000_8K") << 1 << 1000 << QAudioFormat::UInt8 << 8000 << 125000LL << 1000;
+ QTest::newRow("M8_2000_8K") << 1 << 2000 << QAudioFormat::UInt8 << 8000 << 250000LL << 2000;
+ QTest::newRow("M8_1000_4K") << 1 << 1000 << QAudioFormat::UInt8 << 4000 << 250000LL << 1000;
+
+ QTest::newRow("S8_1000_8K") << 2 << 500 << QAudioFormat::UInt8 << 8000 << 62500LL << 1000;
+
+ QTest::newRow("SF_1000_8K") << 2 << 500 << QAudioFormat::Float << 8000 << 62500LL << 4000;
+
+ QTest::newRow("S32_1000_16K") << 4 << 250 << QAudioFormat::Int32 << 16000 << 15625LL << 4000;
+}
+
+void tst_QAudioBuffer::stereoSample()
+{
+ // Uninitialized (should default to zero level for type)
+ QAudioBuffer::U8S u8s;
+ QAudioBuffer::S16S s16s;
+ QAudioBuffer::F32S f32s;
+ u8s.clear();
+ s16s.clear();
+ f32s.clear();
+
+ QCOMPARE(u8s[QAudioFormat::FrontLeft], (unsigned char) 0x80);
+ QCOMPARE(u8s[QAudioFormat::FrontRight], (unsigned char) 0x80);
+
+ QCOMPARE(s16s[QAudioFormat::FrontLeft], (signed short) 0x0);
+ QCOMPARE(s16s[QAudioFormat::FrontRight], (signed short) 0x0);
+
+ QCOMPARE(f32s[QAudioFormat::FrontLeft], 0.0f);
+ QCOMPARE(f32s[QAudioFormat::FrontRight], 0.0f);
+
+ // Initialized
+ QAudioBuffer::U8S u8s2{34, 145};
+ QAudioBuffer::S16S s16s2{-10000, 346};
+ QAudioBuffer::F32S f32s2{500.7f, -123.1f};
+
+ QCOMPARE(u8s2[QAudioFormat::FrontLeft], (unsigned char) 34);
+ QCOMPARE(u8s2[QAudioFormat::FrontRight], (unsigned char) 145);
+
+ QCOMPARE(s16s2[QAudioFormat::FrontLeft], (signed short) -10000);
+ QCOMPARE(s16s2[QAudioFormat::FrontRight], (signed short) 346);
+
+ QCOMPARE(f32s2[QAudioFormat::FrontLeft], 500.7f);
+ QCOMPARE(f32s2[QAudioFormat::FrontRight], -123.1f);
+
+ // Assigned
+ u8s = u8s2;
+ s16s = s16s2;
+ f32s = f32s2;
+
+ QCOMPARE(u8s[QAudioFormat::FrontLeft], (unsigned char) 34);
+ QCOMPARE(u8s[QAudioFormat::FrontRight], (unsigned char) 145);
+
+ QCOMPARE(s16s[QAudioFormat::FrontLeft], (signed short) -10000);
+ QCOMPARE(s16s[QAudioFormat::FrontRight], (signed short) 346);
+
+ QCOMPARE(f32s[QAudioFormat::FrontLeft], 500.7f);
+ QCOMPARE(f32s[QAudioFormat::FrontRight], -123.1f);
+
+ // Cleared
+ u8s.clear();
+ s16s.clear();
+ f32s.clear();
+
+ QCOMPARE(u8s[QAudioFormat::FrontLeft], (unsigned char) 0x80);
+ QCOMPARE(u8s[QAudioFormat::FrontRight], (unsigned char) 0x80);
+
+ QCOMPARE(s16s[QAudioFormat::FrontLeft], (signed short) 0x0);
+ QCOMPARE(s16s[QAudioFormat::FrontRight], (signed short) 0x0);
+
+ QCOMPARE(f32s[QAudioFormat::FrontLeft], 0.0f);
+ QCOMPARE(f32s[QAudioFormat::FrontRight], 0.0f);
+}
+
+
+QTEST_APPLESS_MAIN(tst_QAudioBuffer);
+
+#include "tst_qaudiobuffer.moc"
diff --git a/tests/auto/unit/multimedia/qaudiodecoder/CMakeLists.txt b/tests/auto/unit/multimedia/qaudiodecoder/CMakeLists.txt
new file mode 100644
index 000000000..cced66bda
--- /dev/null
+++ b/tests/auto/unit/multimedia/qaudiodecoder/CMakeLists.txt
@@ -0,0 +1,21 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+# Generated from qaudiodecoder.pro.
+
+#####################################################################
+## tst_qaudiodecoder Test:
+#####################################################################
+
+qt_internal_add_test(tst_qaudiodecoder
+ SOURCES
+ tst_qaudiodecoder.cpp
+ INCLUDE_DIRECTORIES
+ ../../mockbackend
+ LIBRARIES
+ # Remove: L${CMAKE_CURRENT_SOURCE_DIR}
+ Qt::Gui
+ Qt::Multimedia
+ Qt::MultimediaPrivate
+ MockMultimediaPlugin
+)
diff --git a/tests/auto/unit/multimedia/qaudiodecoder/tst_qaudiodecoder.cpp b/tests/auto/unit/multimedia/qaudiodecoder/tst_qaudiodecoder.cpp
new file mode 100644
index 000000000..77e161fda
--- /dev/null
+++ b/tests/auto/unit/multimedia/qaudiodecoder/tst_qaudiodecoder.cpp
@@ -0,0 +1,337 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+
+#include <QtCore/QString>
+#include <QtTest/QtTest>
+
+#include "qaudiodecoder.h"
+#include "qmockaudiodecoder.h"
+#include "qmockintegration.h"
+
+QT_USE_NAMESPACE
+
+Q_ENABLE_MOCK_MULTIMEDIA_PLUGIN
+
+class tst_QAudioDecoder : public QObject
+{
+ Q_OBJECT
+
+public:
+
+ tst_QAudioDecoder();
+
+private Q_SLOTS:
+ void ctors();
+ void read();
+ void stop();
+ void format();
+ void source();
+ void readAll();
+ void nullControl();
+};
+
+tst_QAudioDecoder::tst_QAudioDecoder()
+{
+}
+
+void tst_QAudioDecoder::ctors()
+{
+ QAudioDecoder d;
+ QVERIFY(!d.isDecoding());
+ QVERIFY(d.bufferAvailable() == false);
+ QCOMPARE(d.source(), QStringLiteral(""));
+
+ d.setSource(QUrl());
+ QVERIFY(!d.isDecoding());
+ QVERIFY(d.bufferAvailable() == false);
+ QCOMPARE(d.source(), QUrl());
+}
+
+void tst_QAudioDecoder::read()
+{
+ QAudioDecoder d;
+ QVERIFY(!d.isDecoding());
+ QVERIFY(d.bufferAvailable() == false);
+
+ QSignalSpy readySpy(&d, &QAudioDecoder::bufferReady);
+ QSignalSpy bufferChangedSpy(&d, &QAudioDecoder::bufferAvailableChanged);
+ QSignalSpy errorSpy(&d, SIGNAL(error(QAudioDecoder::Error)));
+
+ // Starting with empty source == error
+ d.start();
+
+ QVERIFY(!d.isDecoding());
+ QVERIFY(d.bufferAvailable() == false);
+
+ QCOMPARE(readySpy.size(), 0);
+ QCOMPARE(bufferChangedSpy.size(), 0);
+ QCOMPARE(errorSpy.size(), 1);
+
+ // Set the source to something
+ d.setSource(QUrl::fromLocalFile("Blah"));
+ QCOMPARE(d.source(), QUrl::fromLocalFile("Blah"));
+
+ readySpy.clear();
+ errorSpy.clear();
+ bufferChangedSpy.clear();
+
+ d.start();
+ QVERIFY(d.isDecoding());
+ QCOMPARE(d.bufferAvailable(), false); // not yet
+
+ // Try to read
+ QAudioBuffer b = d.read();
+ QVERIFY(!b.isValid());
+
+ // Read again with no parameter
+ b = d.read();
+ QVERIFY(!b.isValid());
+
+ // Wait a while
+ QTRY_VERIFY(d.bufferAvailable());
+
+ QVERIFY(d.bufferAvailable());
+
+ b = d.read();
+ QVERIFY(b.format().isValid());
+ QVERIFY(b.isValid());
+ QVERIFY(b.format().channelCount() == 1);
+ QVERIFY(b.sampleCount() == 4);
+
+ QVERIFY(readySpy.size() >= 1);
+ QVERIFY(errorSpy.size() == 0);
+
+ if (d.bufferAvailable()) {
+ QVERIFY(bufferChangedSpy.size() == 1);
+ } else {
+ QVERIFY(bufferChangedSpy.size() == 2);
+ }
+}
+
+void tst_QAudioDecoder::stop()
+{
+ QAudioDecoder d;
+ QVERIFY(!d.isDecoding());
+ QVERIFY(d.bufferAvailable() == false);
+
+ QSignalSpy readySpy(&d, &QAudioDecoder::bufferReady);
+ QSignalSpy bufferChangedSpy(&d, &QAudioDecoder::bufferAvailableChanged);
+ QSignalSpy errorSpy(&d, SIGNAL(error(QAudioDecoder::Error)));
+
+ // Starting with empty source == error
+ d.start();
+
+ QVERIFY(!d.isDecoding());
+ QVERIFY(d.bufferAvailable() == false);
+
+ QCOMPARE(readySpy.size(), 0);
+ QCOMPARE(bufferChangedSpy.size(), 0);
+ QCOMPARE(errorSpy.size(), 1);
+
+ // Set the source to something
+ d.setSource(QUrl::fromLocalFile("Blah"));
+ QCOMPARE(d.source(), QUrl::fromLocalFile("Blah"));
+
+ readySpy.clear();
+ errorSpy.clear();
+ bufferChangedSpy.clear();
+
+ d.start();
+ QVERIFY(d.isDecoding());
+ QCOMPARE(d.bufferAvailable(), false); // not yet
+
+ // Try to read
+ QAudioBuffer b = d.read();
+ QVERIFY(!b.isValid());
+
+ // Read again with no parameter
+ b = d.read();
+ QVERIFY(!b.isValid());
+
+ // Wait a while
+ QTRY_VERIFY(d.bufferAvailable());
+
+ QVERIFY(d.bufferAvailable());
+
+ // Now stop
+ d.stop();
+
+ QVERIFY(!d.isDecoding());
+ QVERIFY(d.bufferAvailable() == false);
+}
+
+void tst_QAudioDecoder::format()
+{
+ QAudioDecoder d;
+ QVERIFY(!d.isDecoding());
+ QVERIFY(d.bufferAvailable() == false);
+
+ QSignalSpy readySpy(&d, &QAudioDecoder::bufferReady);
+ QSignalSpy bufferChangedSpy(&d, &QAudioDecoder::bufferAvailableChanged);
+ QSignalSpy errorSpy(&d, SIGNAL(error(QAudioDecoder::Error)));
+
+ // Set the source to something
+ d.setSource(QUrl::fromLocalFile("Blah"));
+ QCOMPARE(d.source(), QUrl::fromLocalFile("Blah"));
+
+ readySpy.clear();
+ errorSpy.clear();
+ bufferChangedSpy.clear();
+
+ d.start();
+ QVERIFY(d.isDecoding());
+ QCOMPARE(d.bufferAvailable(), false); // not yet
+
+ // Try to read
+ QAudioBuffer b = d.read();
+ QVERIFY(!b.isValid());
+
+ // Read again with no parameter
+ b = d.read();
+ QVERIFY(!b.isValid());
+
+ // Wait a while
+ QTRY_VERIFY(d.bufferAvailable());
+
+ b = d.read();
+ QVERIFY(b.format().isValid());
+ QVERIFY(d.audioFormat() == b.format());
+
+ // Setting format while decoding is forbidden
+ QAudioFormat f(d.audioFormat());
+ f.setChannelCount(2);
+
+ d.setAudioFormat(f);
+ QVERIFY(d.audioFormat() != f);
+ QVERIFY(d.audioFormat() == b.format());
+
+ // Now stop, and set something specific
+ d.stop();
+ d.setAudioFormat(f);
+ QVERIFY(d.audioFormat() == f);
+
+ // Decode again
+ d.start();
+ QTRY_VERIFY(d.bufferAvailable());
+
+ b = d.read();
+ QVERIFY(d.audioFormat() == f);
+ QVERIFY(b.format() == f);
+}
+
+void tst_QAudioDecoder::source()
+{
+ QAudioDecoder d;
+
+ QVERIFY(d.source().isEmpty());
+ QVERIFY(d.sourceDevice() == nullptr);
+
+ QFile f;
+ d.setSourceDevice(&f);
+ QVERIFY(d.source().isEmpty());
+ QVERIFY(d.sourceDevice() == &f);
+
+ d.setSource(QUrl::fromLocalFile("Foo"));
+ QVERIFY(d.source() == QUrl::fromLocalFile("Foo"));
+ QVERIFY(d.sourceDevice() == nullptr);
+
+ d.setSourceDevice(nullptr);
+ QVERIFY(d.source().isEmpty());
+ QVERIFY(d.sourceDevice() == nullptr);
+
+ d.setSource(QUrl::fromLocalFile("Foo"));
+ QVERIFY(d.source() == QUrl::fromLocalFile("Foo"));
+ QVERIFY(d.sourceDevice() == nullptr);
+
+ d.setSource(QString());
+ QVERIFY(d.source() == QString());
+ QVERIFY(d.sourceDevice() == nullptr);
+}
+
+void tst_QAudioDecoder::readAll()
+{
+ QAudioDecoder d;
+ d.setSource(QUrl::fromLocalFile("Foo"));
+ QVERIFY(!d.isDecoding());
+
+ QSignalSpy durationSpy(&d, &QAudioDecoder::durationChanged);
+ QSignalSpy positionSpy(&d, &QAudioDecoder::positionChanged);
+ QSignalSpy isDecodingSpy(&d, &QAudioDecoder::isDecodingChanged);
+ QSignalSpy finishedSpy(&d, &QAudioDecoder::finished);
+ QSignalSpy bufferAvailableSpy(&d, &QAudioDecoder::bufferAvailableChanged);
+ d.start();
+ int i = 0;
+ forever {
+ QVERIFY(d.isDecoding());
+ QCOMPARE(isDecodingSpy.size(), 1);
+ QCOMPARE(durationSpy.size(), 1);
+ QVERIFY(finishedSpy.isEmpty());
+ QTRY_VERIFY(bufferAvailableSpy.size() >= 1);
+ if (d.bufferAvailable()) {
+ QAudioBuffer b = d.read();
+ QVERIFY(b.isValid());
+ QCOMPARE(b.startTime() / 1000, d.position());
+ QVERIFY(!positionSpy.isEmpty());
+ QList<QVariant> arguments = positionSpy.takeLast();
+ QCOMPARE(arguments.at(0).toLongLong(), b.startTime() / 1000);
+
+ i++;
+ if (i == MOCK_DECODER_MAX_BUFFERS) {
+ QCOMPARE(finishedSpy.size(), 1);
+ QCOMPARE(isDecodingSpy.size(), 2);
+ QVERIFY(!d.isDecoding());
+ QList<QVariant> arguments = isDecodingSpy.takeLast();
+ QVERIFY(arguments.at(0).toBool() == false);
+ QVERIFY(!d.bufferAvailable());
+ QVERIFY(!bufferAvailableSpy.isEmpty());
+ arguments = bufferAvailableSpy.takeLast();
+ QVERIFY(arguments.at(0).toBool() == false);
+ break;
+ }
+ } else
+ QTest::qWait(30);
+ }
+}
+
+void tst_QAudioDecoder::nullControl()
+{
+ QMockIntegration::instance()->setFlags(QMockIntegration::NoAudioDecoderInterface);
+ QAudioDecoder d;
+
+ QVERIFY(d.error() == QAudioDecoder::NotSupportedError);
+ QVERIFY(!d.errorString().isEmpty());
+
+ QVERIFY(!d.isDecoding());
+
+ QVERIFY(d.source().isEmpty());
+ d.setSource(QUrl::fromLocalFile("test"));
+ QVERIFY(d.source().isEmpty());
+
+ QFile f;
+ QVERIFY(d.sourceDevice() == nullptr);
+ d.setSourceDevice(&f);
+ QVERIFY(d.sourceDevice() == nullptr);
+
+ QAudioFormat format;
+ format.setChannelCount(2);
+ QVERIFY(!d.audioFormat().isValid());
+ d.setAudioFormat(format);
+ QVERIFY(!d.audioFormat().isValid());
+
+ QVERIFY(!d.read().isValid());
+ QVERIFY(!d.bufferAvailable());
+
+ QVERIFY(d.position() == -1);
+ QVERIFY(d.duration() == -1);
+
+ d.start();
+ QVERIFY(d.error() == QAudioDecoder::NotSupportedError);
+ QVERIFY(!d.errorString().isEmpty());
+ QVERIFY(!d.isDecoding());
+ d.stop();
+}
+
+QTEST_MAIN(tst_QAudioDecoder)
+
+#include "tst_qaudiodecoder.moc"
diff --git a/tests/auto/unit/multimedia/qaudioformat/CMakeLists.txt b/tests/auto/unit/multimedia/qaudioformat/CMakeLists.txt
new file mode 100644
index 000000000..5f4c47bd7
--- /dev/null
+++ b/tests/auto/unit/multimedia/qaudioformat/CMakeLists.txt
@@ -0,0 +1,16 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+# Generated from qaudioformat.pro.
+
+#####################################################################
+## tst_qaudioformat Test:
+#####################################################################
+
+qt_internal_add_test(tst_qaudioformat
+ SOURCES
+ tst_qaudioformat.cpp
+ LIBRARIES
+ Qt::Gui
+ Qt::MultimediaPrivate
+)
diff --git a/tests/auto/unit/qaudioformat/tst_qaudioformat.cpp b/tests/auto/unit/multimedia/qaudioformat/tst_qaudioformat.cpp
index 91b60090e..c4f4e10cf 100644
--- a/tests/auto/unit/qaudioformat/tst_qaudioformat.cpp
+++ b/tests/auto/unit/multimedia/qaudioformat/tst_qaudioformat.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtTest/QtTest>
@@ -34,26 +9,23 @@
#include <QStringList>
#include <QList>
-//TESTED_COMPONENT=src/multimedia
-
class tst_QAudioFormat : public QObject
{
Q_OBJECT
public:
- tst_QAudioFormat(QObject* parent=0) : QObject(parent) {}
+ tst_QAudioFormat(QObject* parent=nullptr) : QObject(parent) {}
private slots:
void checkNull();
- void checkSampleSize();
- void checkCodec();
- void checkByteOrder();
- void checkSampleType();
+ void checkSampleFormat();
void checkEquality();
void checkAssignment();
void checkSampleRate();
void checkChannelCount();
+ void channelConfig();
+
void checkSizes();
void checkSizes_data();
};
@@ -70,62 +42,30 @@ void tst_QAudioFormat::checkNull()
audioFormat0.setSampleRate(44100);
audioFormat0.setChannelCount(2);
- audioFormat0.setSampleSize(16);
- audioFormat0.setCodec("audio/pcm");
- audioFormat0.setSampleType(QAudioFormat::SignedInt);
+ audioFormat0.setSampleFormat(QAudioFormat::Int16);
QVERIFY(audioFormat0.isValid());
}
-void tst_QAudioFormat::checkSampleSize()
-{
- QAudioFormat audioFormat;
- audioFormat.setSampleSize(16);
- QVERIFY(audioFormat.sampleSize() == 16);
-}
-
-void tst_QAudioFormat::checkCodec()
-{
- QAudioFormat audioFormat;
- audioFormat.setCodec(QString::fromLatin1("audio/pcm"));
- QVERIFY(audioFormat.codec() == QString::fromLatin1("audio/pcm"));
-}
-
-void tst_QAudioFormat::checkByteOrder()
-{
- QAudioFormat audioFormat;
- audioFormat.setByteOrder(QAudioFormat::LittleEndian);
- QVERIFY(audioFormat.byteOrder() == QAudioFormat::LittleEndian);
-
- QTest::ignoreMessage(QtDebugMsg, "LittleEndian");
- qDebug() << QAudioFormat::LittleEndian;
-
- audioFormat.setByteOrder(QAudioFormat::BigEndian);
- QVERIFY(audioFormat.byteOrder() == QAudioFormat::BigEndian);
-
- QTest::ignoreMessage(QtDebugMsg, "BigEndian");
- qDebug() << QAudioFormat::BigEndian;
-}
-
-void tst_QAudioFormat::checkSampleType()
+void tst_QAudioFormat::checkSampleFormat()
{
QAudioFormat audioFormat;
- audioFormat.setSampleType(QAudioFormat::SignedInt);
- QVERIFY(audioFormat.sampleType() == QAudioFormat::SignedInt);
- QTest::ignoreMessage(QtDebugMsg, "SignedInt");
- qDebug() << QAudioFormat::SignedInt;
+ audioFormat.setSampleFormat(QAudioFormat::Int16);
+ QVERIFY(audioFormat.sampleFormat() == QAudioFormat::Int16);
+ QTest::ignoreMessage(QtDebugMsg, "Int16");
+ qDebug() << QAudioFormat::Int16;
- audioFormat.setSampleType(QAudioFormat::Unknown);
- QVERIFY(audioFormat.sampleType() == QAudioFormat::Unknown);
+ audioFormat.setSampleFormat(QAudioFormat::Unknown);
+ QVERIFY(audioFormat.sampleFormat() == QAudioFormat::Unknown);
QTest::ignoreMessage(QtDebugMsg, "Unknown");
qDebug() << QAudioFormat::Unknown;
- audioFormat.setSampleType(QAudioFormat::UnSignedInt);
- QVERIFY(audioFormat.sampleType() == QAudioFormat::UnSignedInt);
- QTest::ignoreMessage(QtDebugMsg, "UnSignedInt");
- qDebug() << QAudioFormat::UnSignedInt;
+ audioFormat.setSampleFormat(QAudioFormat::UInt8);
+ QVERIFY(audioFormat.sampleFormat() == QAudioFormat::UInt8);
+ QTest::ignoreMessage(QtDebugMsg, "UInt8");
+ qDebug() << QAudioFormat::UInt8;
- audioFormat.setSampleType(QAudioFormat::Float);
- QVERIFY(audioFormat.sampleType() == QAudioFormat::Float);
+ audioFormat.setSampleFormat(QAudioFormat::Float);
+ QVERIFY(audioFormat.sampleFormat() == QAudioFormat::Float);
QTest::ignoreMessage(QtDebugMsg, "Float");
qDebug() << QAudioFormat::Float;
}
@@ -142,17 +82,11 @@ void tst_QAudioFormat::checkEquality()
// on filled formats
audioFormat0.setSampleRate(8000);
audioFormat0.setChannelCount(1);
- audioFormat0.setSampleSize(8);
- audioFormat0.setCodec("audio/pcm");
- audioFormat0.setByteOrder(QAudioFormat::LittleEndian);
- audioFormat0.setSampleType(QAudioFormat::UnSignedInt);
+ audioFormat0.setSampleFormat(QAudioFormat::UInt8);
audioFormat1.setSampleRate(8000);
audioFormat1.setChannelCount(1);
- audioFormat1.setSampleSize(8);
- audioFormat1.setCodec("audio/pcm");
- audioFormat1.setByteOrder(QAudioFormat::LittleEndian);
- audioFormat1.setSampleType(QAudioFormat::UnSignedInt);
+ audioFormat1.setSampleFormat(QAudioFormat::UInt8);
QVERIFY(audioFormat0 == audioFormat1);
QVERIFY(!(audioFormat0 != audioFormat1));
@@ -169,10 +103,7 @@ void tst_QAudioFormat::checkAssignment()
audioFormat0.setSampleRate(8000);
audioFormat0.setChannelCount(1);
- audioFormat0.setSampleSize(8);
- audioFormat0.setCodec("audio/pcm");
- audioFormat0.setByteOrder(QAudioFormat::LittleEndian);
- audioFormat0.setSampleType(QAudioFormat::UnSignedInt);
+ audioFormat0.setSampleFormat(QAudioFormat::UInt8);
audioFormat1 = audioFormat0;
QVERIFY(audioFormat1 == audioFormat0);
@@ -185,7 +116,7 @@ void tst_QAudioFormat::checkAssignment()
void tst_QAudioFormat::checkSampleRate()
{
QAudioFormat audioFormat;
- QVERIFY(audioFormat.sampleRate() == -1);
+ QVERIFY(audioFormat.sampleRate() == 0);
audioFormat.setSampleRate(123);
QVERIFY(audioFormat.sampleRate() == 123);
@@ -197,16 +128,50 @@ void tst_QAudioFormat::checkChannelCount()
// channels is the old name for channelCount, so
// they should always be equal
QAudioFormat audioFormat;
- QVERIFY(audioFormat.channelCount() == -1);
- QVERIFY(audioFormat.channelCount() == -1);
+ QVERIFY(audioFormat.channelCount() == 0);
audioFormat.setChannelCount(123);
QVERIFY(audioFormat.channelCount() == 123);
- QVERIFY(audioFormat.channelCount() == 123);
audioFormat.setChannelCount(5);
QVERIFY(audioFormat.channelCount() == 5);
- QVERIFY(audioFormat.channelCount() == 5);
+}
+
+void tst_QAudioFormat::channelConfig()
+{
+ QAudioFormat format;
+ format.setChannelConfig(QAudioFormat::ChannelConfig2Dot1);
+ QVERIFY(format.channelConfig() == QAudioFormat::ChannelConfig2Dot1);
+ QVERIFY(format.channelCount() == 3);
+ QVERIFY(format.channelOffset(QAudioFormat::FrontLeft) == 0);
+ QVERIFY(format.channelOffset(QAudioFormat::FrontRight) == 1);
+ QVERIFY(format.channelOffset(QAudioFormat::BackCenter) == -1);
+
+ format.setChannelConfig(QAudioFormat::ChannelConfigSurround5Dot1);
+ QVERIFY(format.channelConfig() == QAudioFormat::ChannelConfigSurround5Dot1);
+ QVERIFY(format.channelCount() == 6);
+ QVERIFY(format.channelOffset(QAudioFormat::FrontLeft) == 0);
+ QVERIFY(format.channelOffset(QAudioFormat::FrontRight) == 1);
+ QVERIFY(format.channelOffset(QAudioFormat::FrontCenter) == 2);
+ QVERIFY(format.channelOffset(QAudioFormat::LFE) == 3);
+ QVERIFY(format.channelOffset(QAudioFormat::BackLeft) == 4);
+ QVERIFY(format.channelOffset(QAudioFormat::BackRight) == 5);
+ QVERIFY(format.channelOffset(QAudioFormat::BackCenter) == -1);
+
+ auto config = QAudioFormat::channelConfig(QAudioFormat::FrontCenter, QAudioFormat::BackCenter, QAudioFormat::LFE);
+ format.setChannelConfig(config);
+ QVERIFY(format.channelConfig() == config);
+ QVERIFY(format.channelCount() == 3);
+ QVERIFY(format.channelOffset(QAudioFormat::FrontLeft) == -1);
+ QVERIFY(format.channelOffset(QAudioFormat::FrontRight) == -1);
+ QVERIFY(format.channelOffset(QAudioFormat::FrontCenter) == 0);
+ QVERIFY(format.channelOffset(QAudioFormat::LFE) == 1);
+ QVERIFY(format.channelOffset(QAudioFormat::BackLeft) == -1);
+ QVERIFY(format.channelOffset(QAudioFormat::BackRight) == -1);
+ QVERIFY(format.channelOffset(QAudioFormat::BackCenter) == 2);
+
+ format.setChannelCount(2);
+ QVERIFY(format.channelConfig() == QAudioFormat::ChannelConfigUnknown);
}
void tst_QAudioFormat::checkSizes()
@@ -252,12 +217,9 @@ void tst_QAudioFormat::checkSizes_data()
QAudioFormat f;
QTest::newRow("invalid") << f << 0 << 0 << 0LL << 0 << 0 << 0LL << 0 << 0;
- f.setByteOrder(QAudioFormat::LittleEndian);
f.setChannelCount(1);
f.setSampleRate(8000);
- f.setCodec("audio/pcm");
- f.setSampleSize(8);
- f.setSampleType(QAudioFormat::SignedInt);
+ f.setSampleFormat(QAudioFormat::UInt8);
qint64 qrtr = 250000LL;
qint64 half = 500000LL;
@@ -270,7 +232,7 @@ void tst_QAudioFormat::checkSizes_data()
QTest::newRow("1ch_8b_8k_signed_16000") << f << 1 << 16000 << two << 16000 << 16000 << two << 16000 << 16000;
// Mono 16bit
- f.setSampleSize(16);
+ f.setSampleFormat(QAudioFormat::Int16);
QTest::newRow("1ch_16b_8k_signed_8000") << f << 2 << 8000 << half << 4000 << 8000 << half << 8000 << 4000;
QTest::newRow("1ch_16b_8k_signed_16000") << f << 2 << 16000 << one << 8000 << 16000 << one << 16000 << 8000;
diff --git a/tests/auto/unit/multimedia/qaudionamespace/CMakeLists.txt b/tests/auto/unit/multimedia/qaudionamespace/CMakeLists.txt
new file mode 100644
index 000000000..3d4ac7126
--- /dev/null
+++ b/tests/auto/unit/multimedia/qaudionamespace/CMakeLists.txt
@@ -0,0 +1,16 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+# Generated from qaudionamespace.pro.
+
+#####################################################################
+## tst_qaudionamespace Test:
+#####################################################################
+
+qt_internal_add_test(tst_qaudionamespace
+ SOURCES
+ tst_qaudionamespace.cpp
+ LIBRARIES
+ Qt::Gui
+ Qt::MultimediaPrivate
+)
diff --git a/tests/auto/unit/qaudionamespace/tst_qaudionamespace.cpp b/tests/auto/unit/multimedia/qaudionamespace/tst_qaudionamespace.cpp
index 5cd89ec3e..cae002306 100644
--- a/tests/auto/unit/qaudionamespace/tst_qaudionamespace.cpp
+++ b/tests/auto/unit/multimedia/qaudionamespace/tst_qaudionamespace.cpp
@@ -1,36 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//TESTED_COMPONENT=src/multimedia
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtTest/QtTest>
#include <QtMultimedia/qaudio.h>
+#include <QtMultimedia/qaudiodevice.h>
// Adds an enum, and the stringized version
#define ADD_ENUM_TEST(x) \
@@ -47,8 +21,6 @@ private slots:
void debugError_data();
void debugState();
void debugState_data();
- void debugMode();
- void debugMode_data();
void debugVolumeScale();
void debugVolumeScale_data();
void convertVolume();
@@ -96,24 +68,6 @@ void tst_QAudioNamespace::debugState()
qDebug() << state;
}
-void tst_QAudioNamespace::debugMode_data()
-{
- QTest::addColumn<QAudio::Mode>("mode");
- QTest::addColumn<QString>("stringized");
-
- ADD_ENUM_TEST(AudioInput);
- ADD_ENUM_TEST(AudioOutput);
-}
-
-void tst_QAudioNamespace::debugMode()
-{
- QFETCH(QAudio::Mode, mode);
- QFETCH(QString, stringized);
-
- QTest::ignoreMessage(QtDebugMsg, stringized.toLatin1().constData());
- qDebug() << mode;
-}
-
void tst_QAudioNamespace::debugVolumeScale_data()
{
QTest::addColumn<QAudio::VolumeScale>("volumeScale");
@@ -254,7 +208,7 @@ void tst_QAudioNamespace::convertVolume()
qreal actualOutput = QAudio::convertVolume(input, from, to);
QVERIFY2(qAbs(actualOutput - expectedOutput) < 0.01,
- QString("actual: %1, expected: %2").arg(actualOutput).arg(expectedOutput).toLocal8Bit().constData());
+ QStringLiteral("actual: %1, expected: %2").arg(actualOutput).arg(expectedOutput).toLocal8Bit().constData());
}
QTEST_MAIN(tst_QAudioNamespace)
diff --git a/tests/auto/unit/multimedia/qaudiorecorder/CMakeLists.txt b/tests/auto/unit/multimedia/qaudiorecorder/CMakeLists.txt
new file mode 100644
index 000000000..b2dc16b69
--- /dev/null
+++ b/tests/auto/unit/multimedia/qaudiorecorder/CMakeLists.txt
@@ -0,0 +1,20 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+# Generated from qaudiorecorder.pro.
+
+#####################################################################
+## tst_qaudiorecorder Test:
+#####################################################################
+
+qt_internal_add_test(tst_qaudiorecorder
+ SOURCES
+ tst_qaudiorecorder.cpp
+ INCLUDE_DIRECTORIES
+ ../../mockbackend
+ LIBRARIES
+ # Remove: L${CMAKE_CURRENT_SOURCE_DIR}
+ Qt::Gui
+ Qt::MultimediaPrivate
+ MockMultimediaPlugin
+)
diff --git a/tests/auto/unit/multimedia/qaudiorecorder/tst_qaudiorecorder.cpp b/tests/auto/unit/multimedia/qaudiorecorder/tst_qaudiorecorder.cpp
new file mode 100644
index 000000000..7d6309976
--- /dev/null
+++ b/tests/auto/unit/multimedia/qaudiorecorder/tst_qaudiorecorder.cpp
@@ -0,0 +1,87 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QtTest/QtTest>
+#include <QDebug>
+
+#include <qaudioformat.h>
+
+#include <qmediarecorder.h>
+#include <private/qplatformmediarecorder_p.h>
+#include <qaudiodevice.h>
+#include <qaudiosource.h>
+#include <qmediacapturesession.h>
+
+#include "qmockmediacapturesession.h"
+#include "qmockintegration.h"
+
+QT_USE_NAMESPACE
+
+Q_ENABLE_MOCK_MULTIMEDIA_PLUGIN
+
+class tst_QAudioRecorder: public QObject
+{
+ Q_OBJECT
+
+public slots:
+ void init();
+ void cleanup();
+
+private slots:
+ void testAudioSource();
+ void testDevices();
+ void testAvailability();
+
+private:
+ QMediaRecorder *encoder = nullptr;
+};
+
+void tst_QAudioRecorder::init()
+{
+ encoder = nullptr;
+}
+
+void tst_QAudioRecorder::cleanup()
+{
+ delete encoder;
+ encoder = nullptr;
+}
+
+void tst_QAudioRecorder::testAudioSource()
+{
+ QMediaCaptureSession session;
+ encoder = new QMediaRecorder;
+ session.setRecorder(encoder);
+
+ QCOMPARE(session.camera(), nullptr);
+}
+
+void tst_QAudioRecorder::testDevices()
+{
+// audiosource = new QMediaRecorder;
+// QList<QAudioDevice> devices = mockIntegration->audioInputs();
+// QVERIFY(devices.size() > 0);
+// QVERIFY(devices.at(0).id() == "device1");
+// QVERIFY(audiosource->audioInputDescription("device1").compare("dev1 comment") == 0);
+// QVERIFY(audiosource->defaultAudioInput() == "device1");
+// QVERIFY(audiosource->isAvailable() == true);
+
+// QSignalSpy checkSignal(audiosource, SIGNAL(audioInputChanged(QString)));
+// audiosource->setAudioInput("device2");
+// QVERIFY(audiosource->audioInput().compare("device2") == 0);
+// QVERIFY(checkSignal.count() == 1);
+// QVERIFY(audiosource->isAvailable() == true);
+}
+
+void tst_QAudioRecorder::testAvailability()
+{
+ QMediaCaptureSession session;
+ QMediaRecorder source;
+ session.setRecorder(&source);
+
+ QVERIFY(source.isAvailable());
+}
+
+QTEST_GUILESS_MAIN(tst_QAudioRecorder)
+
+#include "tst_qaudiorecorder.moc"
diff --git a/tests/auto/unit/multimedia/qaudiostatemachine/CMakeLists.txt b/tests/auto/unit/multimedia/qaudiostatemachine/CMakeLists.txt
new file mode 100644
index 000000000..715091dac
--- /dev/null
+++ b/tests/auto/unit/multimedia/qaudiostatemachine/CMakeLists.txt
@@ -0,0 +1,11 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+qt_internal_add_test(tst_qaudiostatemachine
+ SOURCES
+ tst_qaudiostatemachine.cpp
+ LIBRARIES
+ Qt::Gui
+ Qt::MultimediaPrivate
+)
+
diff --git a/tests/auto/unit/multimedia/qaudiostatemachine/tst_qaudiostatemachine.cpp b/tests/auto/unit/multimedia/qaudiostatemachine/tst_qaudiostatemachine.cpp
new file mode 100644
index 000000000..433590d09
--- /dev/null
+++ b/tests/auto/unit/multimedia/qaudiostatemachine/tst_qaudiostatemachine.cpp
@@ -0,0 +1,661 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+// TESTED_COMPONENT=src/multimedia
+
+#include <QtTest/QtTest>
+#include <private/qaudiostatemachine_p.h>
+#include <private/qaudiosystem_p.h>
+#include <QThread>
+
+QT_USE_NAMESPACE
+
+template<typename F>
+static std::unique_ptr<QThread> createTestThread(std::vector<std::atomic_int> &counters,
+ size_t index, F &&functor,
+ int minAttemptsCount = 2000)
+{
+ return std::unique_ptr<QThread>(QThread::create([=, &counters]() {
+ auto checkCounter = [=](int counter) { return counter < minAttemptsCount; };
+ for (; !QTest::currentTestFailed()
+ && std::any_of(counters.begin(), counters.end(), checkCounter);
+ ++counters[index])
+ functor();
+ }));
+}
+
+class tst_QAudioStateMachine : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void constructor_setsStoppedStateWithNoError();
+
+ void start_changesState_whenStateIsStopped_data();
+ void start_changesState_whenStateIsStopped();
+
+ void start_doesntChangeState_whenStateIsNotStopped_data();
+ void start_doesntChangeState_whenStateIsNotStopped();
+
+ void stop_changesState_whenStateIsNotStopped_data();
+ void stop_changesState_whenStateIsNotStopped();
+
+ void stop_doesntChangeState_whenStateIsStopped_data();
+ void stop_doesntChangeState_whenStateIsStopped();
+
+ void stopWithDraining_changesState_whenStateIsNotStopped_data();
+ void stopWithDraining_changesState_whenStateIsNotStopped();
+
+ void methods_dontChangeState_whenDraining();
+
+ void onDrained_finishesDraining();
+
+ void onDrained_getsFailed_whenDrainHasntBeenCalled_data();
+ void onDrained_getsFailed_whenDrainHasntBeenCalled();
+
+ void updateActiveOrIdle_doesntChangeState_whenStateIsNotActiveOrIdle_data();
+ void updateActiveOrIdle_doesntChangeState_whenStateIsNotActiveOrIdle();
+
+ void updateActiveOrIdle_changesState_whenStateIsActiveOrIdle_data();
+ void updateActiveOrIdle_changesState_whenStateIsActiveOrIdle();
+
+ void suspendAndResume_saveAndRestoreState_whenStateIsActiveOrIdle_data();
+ void suspendAndResume_saveAndRestoreState_whenStateIsActiveOrIdle();
+
+ void suspend_doesntChangeState_whenStateIsNotActiveOrIdle_data();
+ void suspend_doesntChangeState_whenStateIsNotActiveOrIdle();
+
+ void resume_doesntChangeState_whenStateIsNotSuspended_data();
+ void resume_doesntChangeState_whenStateIsNotSuspended();
+
+ void deleteNotifierInSlot_suppressesAdjacentSignal();
+
+ void twoThreadsToggleSuspendResumeAndIdleActive_statesAreConsistent();
+
+ void twoThreadsToggleStartStop_statesAreConsistent();
+
+private:
+ void generateNotStoppedPrevStates()
+ {
+ QTest::addColumn<QAudio::State>("prevState");
+ QTest::addColumn<QAudio::Error>("prevError");
+
+ QTest::newRow("from IdleState") << QAudio::IdleState << QAudio::UnderrunError;
+ QTest::newRow("from ActiveState") << QAudio::ActiveState << QAudio::NoError;
+ QTest::newRow("from SuspendedState") << QAudio::SuspendedState << QAudio::NoError;
+ }
+
+ void generateStoppedAndSuspendedPrevStates()
+ {
+ QTest::addColumn<QAudio::State>("prevState");
+
+ QTest::newRow("from StoppedState") << QAudio::StoppedState;
+ QTest::newRow("from SuspendedState") << QAudio::SuspendedState;
+ }
+};
+
+void tst_QAudioStateMachine::constructor_setsStoppedStateWithNoError()
+{
+ QAudioStateChangeNotifier changeNotifier;
+ QAudioStateMachine stateMachine(changeNotifier);
+
+ QCOMPARE(stateMachine.state(), QAudio::StoppedState);
+ QCOMPARE(stateMachine.error(), QAudio::NoError);
+ QVERIFY(!stateMachine.isActiveOrIdle());
+}
+
+void tst_QAudioStateMachine::start_changesState_whenStateIsStopped_data()
+{
+ QTest::addColumn<bool>("active");
+ QTest::addColumn<QAudio::State>("expectedState");
+
+ QTest::newRow("to active") << true << QAudio::ActiveState;
+ QTest::newRow("to not active") << false << QAudio::IdleState;
+}
+
+void tst_QAudioStateMachine::start_changesState_whenStateIsStopped()
+{
+ QFETCH(bool, active);
+ QFETCH(QAudio::State, expectedState);
+
+ QAudioStateChangeNotifier changeNotifier;
+ QAudioStateMachine stateMachine(changeNotifier);
+
+ QSignalSpy stateSpy(&changeNotifier, &QAudioStateChangeNotifier::stateChanged);
+ QSignalSpy errorSpy(&changeNotifier, &QAudioStateChangeNotifier::errorChanged);
+
+ QVERIFY(stateMachine.start(active));
+
+ QCOMPARE(stateSpy.size(), 1);
+ QCOMPARE(stateSpy.front().front().value<QAudio::State>(), expectedState);
+ QCOMPARE(errorSpy.size(), 0);
+ QCOMPARE(stateMachine.state(), expectedState);
+ QCOMPARE(stateMachine.error(), QAudio::NoError);
+}
+
+void tst_QAudioStateMachine::start_doesntChangeState_whenStateIsNotStopped_data()
+{
+ generateNotStoppedPrevStates();
+}
+
+void tst_QAudioStateMachine::start_doesntChangeState_whenStateIsNotStopped()
+{
+ QFETCH(QAudio::State, prevState);
+ QFETCH(QAudio::Error, prevError);
+
+ QAudioStateChangeNotifier changeNotifier;
+ QAudioStateMachine stateMachine(changeNotifier);
+ stateMachine.forceSetState(prevState, prevError);
+
+ QSignalSpy stateSpy(&changeNotifier, &QAudioStateChangeNotifier::stateChanged);
+ QSignalSpy errorSpy(&changeNotifier, &QAudioStateChangeNotifier::errorChanged);
+
+ QVERIFY2(!stateMachine.start(), "Cannot start (active)");
+ QVERIFY2(!stateMachine.start(false), "Cannot start (not active)");
+
+ QCOMPARE(stateSpy.size(), 0);
+ QCOMPARE(errorSpy.size(), 0);
+
+ QCOMPARE(stateMachine.state(), prevState);
+ QCOMPARE(stateMachine.error(), prevError);
+}
+
+void tst_QAudioStateMachine::stop_changesState_whenStateIsNotStopped_data()
+{
+ generateNotStoppedPrevStates();
+}
+
+void tst_QAudioStateMachine::stop_changesState_whenStateIsNotStopped()
+{
+ QFETCH(QAudio::State, prevState);
+ QFETCH(QAudio::Error, prevError);
+
+ QAudioStateChangeNotifier changeNotifier;
+ QAudioStateMachine stateMachine(changeNotifier);
+
+ stateMachine.forceSetState(prevState, prevError);
+
+ QSignalSpy stateSpy(&changeNotifier, &QAudioStateChangeNotifier::stateChanged);
+ QSignalSpy errorSpy(&changeNotifier, &QAudioStateChangeNotifier::errorChanged);
+
+ auto notifier = stateMachine.stop();
+ QVERIFY(notifier);
+
+ QCOMPARE(stateMachine.state(), QAudio::StoppedState);
+ QCOMPARE(stateMachine.error(), QAudio::NoError);
+
+ QCOMPARE(stateSpy.size(), 0);
+ QCOMPARE(errorSpy.size(), 0);
+ QVERIFY(!notifier.isDraining());
+
+ notifier.reset();
+
+ QCOMPARE(stateSpy.size(), 1);
+ QCOMPARE(stateSpy.front().front().value<QAudio::State>(), QAudio::StoppedState);
+ QCOMPARE(errorSpy.size(), prevError == QAudio::NoError ? 0 : 1);
+ if (!errorSpy.empty())
+ QCOMPARE(errorSpy.front().front().value<QAudio::Error>(), QAudio::NoError);
+
+ QCOMPARE(stateMachine.state(), QAudio::StoppedState);
+ QCOMPARE(stateMachine.error(), QAudio::NoError);
+ QVERIFY(!stateMachine.isDraining());
+}
+
+void tst_QAudioStateMachine::stop_doesntChangeState_whenStateIsStopped_data()
+{
+ QTest::addColumn<QAudio::Error>("error");
+
+ QTest::newRow("from NoError") << QAudio::NoError;
+ QTest::newRow("from IOError") << QAudio::IOError;
+}
+
+void tst_QAudioStateMachine::stop_doesntChangeState_whenStateIsStopped()
+{
+ QFETCH(QAudio::Error, error);
+
+ QAudioStateChangeNotifier changeNotifier;
+ QAudioStateMachine stateMachine(changeNotifier);
+
+ stateMachine.setError(error);
+
+ QSignalSpy stateSpy(&changeNotifier, &QAudioStateChangeNotifier::stateChanged);
+ QSignalSpy errorSpy(&changeNotifier, &QAudioStateChangeNotifier::errorChanged);
+
+ QVERIFY2(!stateMachine.stop(), "should return false if already stopped");
+
+ QCOMPARE(stateSpy.size(), 0);
+ QCOMPARE(errorSpy.size(), 0);
+ QCOMPARE(stateMachine.state(), QAudio::StoppedState);
+ QCOMPARE(stateMachine.error(), error);
+ QVERIFY(!stateMachine.isDraining());
+}
+
+void tst_QAudioStateMachine::stopWithDraining_changesState_whenStateIsNotStopped_data()
+{
+ generateNotStoppedPrevStates();
+}
+
+void tst_QAudioStateMachine::stopWithDraining_changesState_whenStateIsNotStopped()
+{
+ QFETCH(QAudio::State, prevState);
+ QFETCH(QAudio::Error, prevError);
+
+ QAudioStateChangeNotifier changeNotifier;
+ QAudioStateMachine stateMachine(changeNotifier);
+
+ stateMachine.forceSetState(prevState, prevError);
+
+ QSignalSpy stateSpy(&changeNotifier, &QAudioStateChangeNotifier::stateChanged);
+
+ auto notifier = stateMachine.stop(QAudio::NoError, true);
+ QVERIFY(notifier);
+ QCOMPARE(notifier.isDraining(), prevState == QAudio::ActiveState);
+ notifier.reset();
+
+ QCOMPARE(stateMachine.state(), QAudio::StoppedState);
+ QCOMPARE(stateMachine.error(), QAudio::NoError);
+ QCOMPARE(stateMachine.isDraining(), prevState == QAudio::ActiveState);
+
+ QCOMPARE(stateSpy.size(), 1);
+}
+
+void tst_QAudioStateMachine::methods_dontChangeState_whenDraining()
+{
+ QAudioStateChangeNotifier changeNotifier;
+ QAudioStateMachine stateMachine(changeNotifier);
+
+ stateMachine.forceSetState(QAudio::ActiveState);
+ stateMachine.stop(QAudio::IOError, true);
+ QVERIFY(stateMachine.isDraining());
+
+ QSignalSpy stateSpy(&changeNotifier, &QAudioStateChangeNotifier::stateChanged);
+ QSignalSpy errorSpy(&changeNotifier, &QAudioStateChangeNotifier::errorChanged);
+
+ QVERIFY(!stateMachine.start());
+ QVERIFY(!stateMachine.stop());
+ QVERIFY(!stateMachine.stop(QAudio::NoError, true));
+ QVERIFY(!stateMachine.suspend());
+ QVERIFY(!stateMachine.resume());
+ QVERIFY(!stateMachine.updateActiveOrIdle(false));
+ QVERIFY(!stateMachine.updateActiveOrIdle(true));
+
+ QCOMPARE(stateMachine.state(), QAudio::StoppedState);
+ QCOMPARE(stateMachine.error(), QAudio::IOError);
+
+ QCOMPARE(stateSpy.size(), 0);
+ QCOMPARE(errorSpy.size(), 0);
+
+ QVERIFY(stateMachine.isDraining());
+}
+
+void tst_QAudioStateMachine::onDrained_finishesDraining()
+{
+ QAudioStateChangeNotifier changeNotifier;
+ QAudioStateMachine stateMachine(changeNotifier);
+
+ stateMachine.forceSetState(QAudio::ActiveState);
+ stateMachine.stop(QAudio::IOError, true);
+ QVERIFY(stateMachine.isDraining());
+
+ QSignalSpy stateSpy(&changeNotifier, &QAudioStateChangeNotifier::stateChanged);
+ QSignalSpy errorSpy(&changeNotifier, &QAudioStateChangeNotifier::errorChanged);
+
+ QVERIFY(stateMachine.onDrained());
+ QVERIFY(!stateMachine.isDraining());
+
+ QCOMPARE(stateSpy.size(), 0);
+ QCOMPARE(errorSpy.size(), 0);
+
+ QCOMPARE(stateMachine.state(), QAudio::StoppedState);
+ QCOMPARE(stateMachine.error(), QAudio::IOError);
+
+ QVERIFY(stateMachine.start());
+}
+
+void tst_QAudioStateMachine::onDrained_getsFailed_whenDrainHasntBeenCalled_data()
+{
+ generateNotStoppedPrevStates();
+ QTest::newRow("from Stopped State") << QAudio::StoppedState << QAudio::IOError;
+}
+
+void tst_QAudioStateMachine::onDrained_getsFailed_whenDrainHasntBeenCalled()
+{
+ QFETCH(QAudio::State, prevState);
+ QFETCH(QAudio::Error, prevError);
+
+ QAudioStateChangeNotifier changeNotifier;
+ QAudioStateMachine stateMachine(changeNotifier);
+
+ stateMachine.forceSetState(prevState, prevError);
+
+ QVERIFY(!stateMachine.onDrained());
+
+ QCOMPARE(stateMachine.state(), prevState);
+ QCOMPARE(stateMachine.error(), prevError);
+}
+
+void tst_QAudioStateMachine::updateActiveOrIdle_doesntChangeState_whenStateIsNotActiveOrIdle_data()
+{
+ generateStoppedAndSuspendedPrevStates();
+}
+
+void tst_QAudioStateMachine::updateActiveOrIdle_doesntChangeState_whenStateIsNotActiveOrIdle()
+{
+ QFETCH(QAudio::State, prevState);
+
+ QAudioStateChangeNotifier changeNotifier;
+ QAudioStateMachine stateMachine(changeNotifier);
+
+ stateMachine.forceSetState(prevState);
+
+ QSignalSpy stateSpy(&changeNotifier, &QAudioStateChangeNotifier::stateChanged);
+ QSignalSpy errorSpy(&changeNotifier, &QAudioStateChangeNotifier::errorChanged);
+
+ QVERIFY(!stateMachine.updateActiveOrIdle(true));
+ QVERIFY(!stateMachine.updateActiveOrIdle(false));
+
+ QCOMPARE(stateSpy.size(), 0);
+ QCOMPARE(errorSpy.size(), 0);
+}
+
+void tst_QAudioStateMachine::updateActiveOrIdle_changesState_whenStateIsActiveOrIdle_data()
+{
+ QTest::addColumn<QAudio::State>("prevState");
+ QTest::addColumn<QAudio::Error>("prevError");
+ QTest::addColumn<bool>("active");
+ QTest::addColumn<QAudio::Error>("error");
+
+ QTest::newRow("from ActiveState+NoError -> not active+NoError")
+ << QAudio::ActiveState << QAudio::NoError << false << QAudio::NoError;
+ QTest::newRow("from Idle(UnderrunError) -> active+NoError")
+ << QAudio::IdleState << QAudio::UnderrunError << true << QAudio::NoError;
+ QTest::newRow("from Idle(UnderrunError) -> not active+UnderrunError")
+ << QAudio::IdleState << QAudio::UnderrunError << false << QAudio::UnderrunError;
+}
+
+void tst_QAudioStateMachine::updateActiveOrIdle_changesState_whenStateIsActiveOrIdle()
+{
+ QFETCH(QAudio::State, prevState);
+ QFETCH(QAudio::Error, prevError);
+ QFETCH(bool, active);
+ QFETCH(QAudio::Error, error);
+
+ QAudioStateChangeNotifier changeNotifier;
+ QAudioStateMachine stateMachine(changeNotifier);
+
+ stateMachine.forceSetState(prevState, prevError);
+
+ QSignalSpy stateSpy(&changeNotifier, &QAudioStateChangeNotifier::stateChanged);
+ QSignalSpy errorSpy(&changeNotifier, &QAudioStateChangeNotifier::errorChanged);
+
+ const auto expectedState = active ? QAudio::ActiveState : QAudio::IdleState;
+
+ auto notifier = stateMachine.updateActiveOrIdle(active, error);
+ QVERIFY(notifier);
+
+ QCOMPARE(stateSpy.size(), 0);
+ QCOMPARE(errorSpy.size(), 0);
+
+ QCOMPARE(stateMachine.state(), expectedState);
+ QCOMPARE(stateMachine.error(), error);
+
+ notifier.reset();
+
+ QCOMPARE(stateSpy.size(), expectedState == prevState ? 0 : 1);
+ if (!stateSpy.empty())
+ QCOMPARE(stateSpy.front().front().value<QAudio::State>(), expectedState);
+
+ QCOMPARE(errorSpy.size(), prevError == error ? 0 : 1);
+ if (!errorSpy.empty())
+ QCOMPARE(errorSpy.front().front().value<QAudio::Error>(), error);
+
+ QCOMPARE(stateMachine.state(), expectedState);
+ QCOMPARE(stateMachine.error(), error);
+}
+
+void tst_QAudioStateMachine::suspendAndResume_saveAndRestoreState_whenStateIsActiveOrIdle_data()
+{
+ QTest::addColumn<QAudio::State>("prevState");
+ QTest::addColumn<QAudio::Error>("prevError");
+
+ QTest::newRow("from Active+NoError") << QAudio::ActiveState << QAudio::NoError;
+ QTest::newRow("from Idle+UnderrunError") << QAudio::IdleState << QAudio::UnderrunError;
+}
+
+void tst_QAudioStateMachine::suspendAndResume_saveAndRestoreState_whenStateIsActiveOrIdle()
+{
+ QFETCH(QAudio::State, prevState);
+ QFETCH(QAudio::Error, prevError);
+
+ QAudioStateChangeNotifier changeNotifier;
+ QAudioStateMachine stateMachine(changeNotifier);
+
+ stateMachine.forceSetState(prevState, prevError);
+
+ QSignalSpy stateSpy(&changeNotifier, &QAudioStateChangeNotifier::stateChanged);
+ QSignalSpy errorSpy(&changeNotifier, &QAudioStateChangeNotifier::errorChanged);
+
+ QVERIFY(stateMachine.suspend());
+
+ QCOMPARE(stateSpy.size(), 1);
+ QCOMPARE(stateSpy.front().front().value<QAudio::State>(), QAudio::SuspendedState);
+ QCOMPARE(errorSpy.size(), prevError == QAudio::NoError ? 0 : 1);
+
+ QCOMPARE(stateMachine.state(), QAudio::SuspendedState);
+ QCOMPARE(stateMachine.error(), QAudio::NoError);
+
+ stateSpy.clear();
+ errorSpy.clear();
+
+ QVERIFY(!stateMachine.suspend());
+ QVERIFY(stateMachine.resume());
+
+ QCOMPARE(stateSpy.size(), 1);
+ QCOMPARE(stateSpy.front().front().value<QAudio::State>(), prevState);
+ QCOMPARE(errorSpy.size(), 0);
+
+ QCOMPARE(stateMachine.state(), prevState);
+ QCOMPARE(stateMachine.error(), QAudio::NoError);
+}
+
+void tst_QAudioStateMachine::suspend_doesntChangeState_whenStateIsNotActiveOrIdle_data()
+{
+ generateStoppedAndSuspendedPrevStates();
+}
+
+void tst_QAudioStateMachine::suspend_doesntChangeState_whenStateIsNotActiveOrIdle()
+{
+ QFETCH(QAudio::State, prevState);
+
+ QAudioStateChangeNotifier changeNotifier;
+ QAudioStateMachine stateMachine(changeNotifier);
+
+ stateMachine.forceSetState(prevState);
+
+ QSignalSpy stateSpy(&changeNotifier, &QAudioStateChangeNotifier::stateChanged);
+ QSignalSpy errorSpy(&changeNotifier, &QAudioStateChangeNotifier::errorChanged);
+
+ QVERIFY(!stateMachine.suspend());
+
+ QCOMPARE(stateSpy.size(), 0);
+ QCOMPARE(errorSpy.size(), 0);
+
+ QCOMPARE(stateMachine.state(), prevState);
+ QCOMPARE(stateMachine.error(), QAudio::NoError);
+}
+
+void tst_QAudioStateMachine::resume_doesntChangeState_whenStateIsNotSuspended_data()
+{
+ QTest::addColumn<QAudio::State>("prevState");
+
+ QTest::newRow("from StoppedState") << QAudio::StoppedState;
+ QTest::newRow("from ActiveState") << QAudio::ActiveState;
+ QTest::newRow("from IdleState") << QAudio::IdleState;
+}
+
+void tst_QAudioStateMachine::resume_doesntChangeState_whenStateIsNotSuspended()
+{
+ QFETCH(QAudio::State, prevState);
+
+ QAudioStateChangeNotifier changeNotifier;
+ QAudioStateMachine stateMachine(changeNotifier);
+
+ stateMachine.forceSetState(prevState);
+
+ QSignalSpy stateSpy(&changeNotifier, &QAudioStateChangeNotifier::stateChanged);
+ QSignalSpy errorSpy(&changeNotifier, &QAudioStateChangeNotifier::errorChanged);
+
+ QVERIFY(!stateMachine.resume());
+
+ QCOMPARE(stateSpy.size(), 0);
+ QCOMPARE(errorSpy.size(), 0);
+
+ QCOMPARE(stateMachine.state(), prevState);
+ QCOMPARE(stateMachine.error(), QAudio::NoError);
+}
+
+void tst_QAudioStateMachine::deleteNotifierInSlot_suppressesAdjacentSignal()
+{
+ auto changeNotifier = std::make_unique<QAudioStateChangeNotifier>();
+ QAudioStateMachine stateMachine(*changeNotifier);
+ stateMachine.start();
+
+ auto onSignal = [&]() {
+ QVERIFY2(changeNotifier, "The 2nd signal shouldn't be emitted");
+ changeNotifier.reset();
+ };
+
+ connect(changeNotifier.get(), &QAudioStateChangeNotifier::errorChanged,
+ this, onSignal, Qt::DirectConnection);
+ connect(changeNotifier.get(), &QAudioStateChangeNotifier::stateChanged,
+ this, onSignal, Qt::DirectConnection);
+
+ stateMachine.stop(QAudio::IOError);
+}
+
+void tst_QAudioStateMachine::twoThreadsToggleSuspendResumeAndIdleActive_statesAreConsistent()
+{
+ QAudioStateChangeNotifier changeNotifier;
+ QAudioStateMachine stateMachine(changeNotifier);
+
+ QVERIFY(stateMachine.start());
+ QCOMPARE(stateMachine.state(), QAudio::ActiveState);
+
+ std::atomic<int> signalsCount = 0;
+ std::atomic<int> changesCount = 0;
+
+ connect(&changeNotifier, &QAudioStateChangeNotifier::stateChanged,
+ this, [&](QAudio::State) { ++signalsCount; }, Qt::DirectConnection);
+
+ std::vector<std::atomic_int> counters(2);
+
+ auto threadSuspendResume = createTestThread(counters, 0, [&]() {
+ {
+ auto notifier = stateMachine.suspend();
+ QVERIFY(notifier);
+ QVERIFY(notifier.isStateChanged());
+ QCOMPARE(notifier.audioState(), QAudio::SuspendedState);
+ ++changesCount;
+ }
+
+ {
+ auto notifier = stateMachine.resume();
+ QVERIFY(notifier);
+ QVERIFY(notifier.isStateChanged());
+ QCOMPARE_NE(notifier.audioState(), QAudio::SuspendedState);
+ ++changesCount;
+ }
+ });
+
+ auto threadIdleActive = createTestThread(counters, 1, [&]() {
+ if (auto notifier = stateMachine.updateActiveOrIdle(false)) {
+ if (notifier.isStateChanged())
+ ++changesCount;
+
+ QCOMPARE(notifier.audioState(), QAudio::IdleState);
+ }
+
+ if (auto notifier = stateMachine.updateActiveOrIdle(true)) {
+ if (notifier.isStateChanged())
+ ++changesCount;
+
+ QCOMPARE(notifier.audioState(), QAudio::ActiveState);
+ }
+ });
+
+ threadSuspendResume->start();
+ threadIdleActive->start();
+
+ threadSuspendResume->wait();
+ threadIdleActive->wait();
+
+ if (QTest::currentTestFailed()) {
+ qDebug() << "counterSuspendResume:" << counters[0];
+ qDebug() << "counterIdleActive:" << counters[1];
+ }
+
+ QCOMPARE(signalsCount, changesCount);
+}
+
+void tst_QAudioStateMachine::twoThreadsToggleStartStop_statesAreConsistent()
+{
+ QAudioStateChangeNotifier changeNotifier;
+ QAudioStateMachine stateMachine(changeNotifier);
+
+ QVERIFY(stateMachine.start());
+ QCOMPARE(stateMachine.state(), QAudio::ActiveState);
+
+ std::atomic<int> signalsCount = 0;
+ std::atomic<int> changesCount = 0;
+
+ connect(&changeNotifier, &QAudioStateChangeNotifier::stateChanged,
+ this, [&](QAudio::State) { ++signalsCount; }, Qt::DirectConnection);
+
+ std::vector<std::atomic_int> counters(2);
+
+ auto threadStartActive = createTestThread(counters, 0, [&]() {
+ if (auto startNotifier = stateMachine.start()) {
+ QCOMPARE(startNotifier.prevAudioState(), QAudio::StoppedState);
+ QCOMPARE(startNotifier.audioState(), QAudio::ActiveState);
+ ++changesCount;
+ startNotifier.reset();
+
+ auto stopNotifier = stateMachine.stop();
+ ++changesCount;
+ QVERIFY(stopNotifier);
+ QCOMPARE(stopNotifier.prevAudioState(), QAudio::ActiveState);
+ }
+ });
+
+ auto threadStartIdle = createTestThread(counters, 1, [&]() {
+ if (auto startNotifier = stateMachine.start(false)) {
+ QCOMPARE(startNotifier.prevAudioState(), QAudio::StoppedState);
+ QCOMPARE(startNotifier.audioState(), QAudio::IdleState);
+ ++changesCount;
+ startNotifier.reset();
+
+ auto stopNotifier = stateMachine.stop();
+ ++changesCount;
+ QVERIFY(stopNotifier);
+ QCOMPARE(stopNotifier.audioState(), QAudio::StoppedState);
+ QCOMPARE(stopNotifier.prevAudioState(), QAudio::IdleState);
+ }
+ });
+
+ threadStartActive->start();
+ threadStartIdle->start();
+
+ threadStartActive->wait();
+ threadStartIdle->wait();
+
+ if (QTest::currentTestFailed()) {
+ qDebug() << "counterSuspendResume:" << counters[0];
+ qDebug() << "counterIdleActive:" << counters[1];
+ }
+
+ QCOMPARE(signalsCount, changesCount);
+}
+
+QTEST_GUILESS_MAIN(tst_QAudioStateMachine)
+
+#include "tst_qaudiostatemachine.moc"
diff --git a/tests/auto/unit/multimedia/qcamera/CMakeLists.txt b/tests/auto/unit/multimedia/qcamera/CMakeLists.txt
new file mode 100644
index 000000000..484793923
--- /dev/null
+++ b/tests/auto/unit/multimedia/qcamera/CMakeLists.txt
@@ -0,0 +1,20 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+# Generated from qcamera.pro.
+
+#####################################################################
+## tst_qcamera Test:
+#####################################################################
+
+qt_internal_add_test(tst_multimedia_qcamera
+ SOURCES
+ tst_qcamera.cpp
+ INCLUDE_DIRECTORIES
+ ../../mockbackend
+ LIBRARIES
+ # Remove: L${CMAKE_CURRENT_SOURCE_DIR}
+ Qt::Gui
+ Qt::MultimediaPrivate
+ MockMultimediaPlugin
+)
diff --git a/tests/auto/unit/multimedia/qcamera/tst_qcamera.cpp b/tests/auto/unit/multimedia/qcamera/tst_qcamera.cpp
new file mode 100644
index 000000000..bd1972550
--- /dev/null
+++ b/tests/auto/unit/multimedia/qcamera/tst_qcamera.cpp
@@ -0,0 +1,845 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QtTest/QtTest>
+#include <QDebug>
+
+#include <qvideosink.h>
+#include <private/qplatformcamera_p.h>
+#include <private/qplatformimagecapture_p.h>
+#include <qcamera.h>
+#include <qcameradevice.h>
+#include <qimagecapture.h>
+#include <qmediacapturesession.h>
+#include <qobject.h>
+#include <qmediadevices.h>
+
+#include "qmockintegration.h"
+#include "qmockmediacapturesession.h"
+#include "qmockcamera.h"
+
+QT_USE_NAMESPACE
+
+Q_ENABLE_MOCK_MULTIMEDIA_PLUGIN
+
+class tst_QCamera: public QObject
+{
+ Q_OBJECT
+
+public slots:
+ void initTestCase();
+ void init();
+ void cleanup();
+
+private slots:
+ void testSimpleCamera();
+ void testSimpleCameraWhiteBalance();
+ void testSimpleCameraExposure();
+ void testSimpleCameraFocus();
+ void testSimpleCameraCapture();
+
+ void testCameraWhiteBalance();
+ void testCameraExposure();
+ void testCameraFocus();
+ void testCameraCapture();
+ void testCameraCaptureMetadata();
+ void testCameraEncodingProperyChange();
+
+ void testConstructor();
+ void testQCameraIsAvailable();
+ void testErrorSignal();
+ void testError();
+ void testErrorString();
+
+ void testSetCameraFormat();
+
+ // Test cases to for focus handling
+ void testFocusMode();
+ void testZoomChanged();
+ void testMaxZoomChangedSignal();
+
+ // Test cases for QPlatformCamera class.
+ void testCameraControl();
+
+ void testSetVideoOutput();
+ void testSetVideoOutputDestruction();
+
+ void testEnumDebug();
+
+ // Signals test cases for exposure related properties
+ void testSignalExposureCompensationChanged();
+ void testSignalIsoSensitivityChanged();
+ void testSignalShutterSpeedChanged();
+ void testSignalFlashReady();
+};
+
+void tst_QCamera::initTestCase()
+{
+#ifdef Q_OS_MACOS
+ if (qEnvironmentVariable("QTEST_ENVIRONMENT").toLower() == "ci")
+ QSKIP("Flakiness on macOS CI, to be investigated, QTBUG-111812");
+#endif
+}
+
+void tst_QCamera::init()
+{
+}
+
+void tst_QCamera::cleanup()
+{
+}
+
+void tst_QCamera::testSimpleCamera()
+{
+ QMockCamera::Simple simple;
+ QCamera camera;
+
+ QCOMPARE(camera.isActive(), false);
+ camera.start();
+ QCOMPARE(camera.isActive(), true);
+ camera.stop();
+ QCOMPARE(camera.isActive(), false);
+}
+
+void tst_QCamera::testSimpleCameraWhiteBalance()
+{
+ QMockCamera::Simple simple;
+ QCamera camera;
+
+ //only WhiteBalanceAuto is supported
+ QVERIFY(camera.isWhiteBalanceModeSupported(QCamera::WhiteBalanceAuto));
+ QVERIFY(!camera.isWhiteBalanceModeSupported(QCamera::WhiteBalanceManual));
+ QVERIFY(!camera.isWhiteBalanceModeSupported(QCamera::WhiteBalanceCloudy));
+ QCOMPARE(camera.whiteBalanceMode(), QCamera::WhiteBalanceAuto);
+ camera.setWhiteBalanceMode(QCamera::WhiteBalanceCloudy);
+ QCOMPARE(camera.whiteBalanceMode(), QCamera::WhiteBalanceAuto);
+ QCOMPARE(camera.colorTemperature(), 0);
+ camera.setColorTemperature(5000);
+ QCOMPARE(camera.colorTemperature(), 0);
+}
+
+void tst_QCamera::testSimpleCameraExposure()
+{
+ QMockCamera::Simple simple;
+
+ QCamera camera;
+ QVERIFY(camera.isExposureModeSupported(QCamera::ExposureAuto));
+ QVERIFY(!camera.isExposureModeSupported(QCamera::ExposureManual));
+ QCOMPARE(camera.exposureMode(), QCamera::ExposureAuto);
+ camera.setExposureMode(QCamera::ExposureManual);//should be ignored
+ QCOMPARE(camera.exposureMode(), QCamera::ExposureAuto);
+
+ QVERIFY(!camera.isFlashModeSupported(QCamera::FlashOn));
+ QCOMPARE(camera.flashMode(), QCamera::FlashOff);
+ QCOMPARE(camera.isFlashReady(), false);
+ camera.setFlashMode(QCamera::FlashOn);
+ QCOMPARE(camera.flashMode(), QCamera::FlashOff);
+
+ QCOMPARE(camera.exposureCompensation(), 0.0);
+ camera.setExposureCompensation(2.0);
+ QCOMPARE(camera.exposureCompensation(), 0.0);
+
+ QCOMPARE(camera.isoSensitivity(), -1);
+ QCOMPARE(camera.minimumIsoSensitivity(), -1);
+ QCOMPARE(camera.maximumIsoSensitivity(), -1);
+ camera.setManualIsoSensitivity(100);
+ QCOMPARE(camera.isoSensitivity(), -1);
+ camera.setAutoIsoSensitivity();
+ QCOMPARE(camera.isoSensitivity(), -1);
+
+ QVERIFY(camera.exposureTime() < 0);
+ QCOMPARE(camera.minimumExposureTime(), -1.);
+ QCOMPARE(camera.maximumExposureTime(), -1.);
+ camera.setAutoExposureTime();
+ QVERIFY(camera.exposureTime() < 0);
+ camera.setManualExposureTime(1/128.0);
+ QVERIFY(camera.exposureTime() < 0);
+}
+
+void tst_QCamera::testSimpleCameraFocus()
+{
+ QMockCamera::Simple simple;
+
+ QCamera camera;
+
+ QVERIFY(camera.isFocusModeSupported(QCamera::FocusModeAuto));
+ QVERIFY(!camera.isFocusModeSupported(QCamera::FocusModeInfinity));
+
+ QCOMPARE(camera.focusMode(), QCamera::FocusModeAuto);
+ camera.setFocusMode(QCamera::FocusModeInfinity);
+ QCOMPARE(camera.focusMode(), QCamera::FocusModeAuto);
+
+ QCOMPARE(camera.maximumZoomFactor(), 1.0);
+ QCOMPARE(camera.minimumZoomFactor(), 1.0);
+ QCOMPARE(camera.zoomFactor(), 1.0);
+
+ camera.zoomTo(100.0, 100.0);
+ QCOMPARE(camera.zoomFactor(), 1.0);
+
+ QCOMPARE(camera.customFocusPoint(), QPointF(-1., -1.));
+ camera.setCustomFocusPoint(QPointF(1.0, 1.0));
+ QCOMPARE(camera.customFocusPoint(), QPointF(-1., -1.));
+}
+
+void tst_QCamera::testSimpleCameraCapture()
+{
+ QMockCamera::Simple simple;
+
+ QMediaCaptureSession session;
+ QCamera camera;
+ QImageCapture imageCapture;
+ session.setCamera(&camera);
+ session.setImageCapture(&imageCapture);
+
+ QVERIFY(!imageCapture.isReadyForCapture());
+ QVERIFY(imageCapture.isAvailable());
+
+ QCOMPARE(imageCapture.error(), QImageCapture::NoError);
+ QVERIFY(imageCapture.errorString().isEmpty());
+
+ QSignalSpy errorSignal(&imageCapture, &QImageCapture::errorOccurred);
+ imageCapture.captureToFile(QStringLiteral("/dev/null"));
+ QCOMPARE(errorSignal.size(), 1);
+ QCOMPARE(imageCapture.error(), QImageCapture::NotReadyError);
+ QVERIFY(!imageCapture.errorString().isEmpty());
+
+ camera.start();
+ imageCapture.captureToFile(QStringLiteral("/dev/null"));
+ QCOMPARE(errorSignal.size(), 1);
+ QCOMPARE(imageCapture.error(), QImageCapture::NoError);
+ QVERIFY(imageCapture.errorString().isEmpty());
+}
+
+void tst_QCamera::testCameraCapture()
+{
+ QMediaCaptureSession session;
+ QCamera camera;
+ QImageCapture imageCapture;
+ session.setCamera(&camera);
+ session.setImageCapture(&imageCapture);
+
+ QVERIFY(!imageCapture.isReadyForCapture());
+
+ QSignalSpy capturedSignal(&imageCapture, &QImageCapture::imageCaptured);
+ QSignalSpy errorSignal(&imageCapture, &QImageCapture::errorOccurred);
+
+ imageCapture.captureToFile(QStringLiteral("/dev/null"));
+ QCOMPARE(capturedSignal.size(), 0);
+ QCOMPARE(errorSignal.size(), 1);
+ QCOMPARE(imageCapture.error(), QImageCapture::NotReadyError);
+
+ errorSignal.clear();
+
+ camera.start();
+ QVERIFY(imageCapture.isReadyForCapture());
+ QCOMPARE(errorSignal.size(), 0);
+
+ imageCapture.captureToFile(QStringLiteral("/dev/null"));
+
+ QTRY_COMPARE(capturedSignal.size(), 1);
+ QCOMPARE(errorSignal.size(), 0);
+ QCOMPARE(imageCapture.error(), QImageCapture::NoError);
+}
+
+void tst_QCamera::testCameraCaptureMetadata()
+{
+ QMediaCaptureSession session;
+ QCamera camera;
+ QImageCapture imageCapture;
+ session.setCamera(&camera);
+ session.setImageCapture(&imageCapture);
+
+ QSignalSpy metadataSignal(&imageCapture, &QImageCapture::imageMetadataAvailable);
+ QSignalSpy savedSignal(&imageCapture, &QImageCapture::imageSaved);
+
+ camera.start();
+ int id = imageCapture.captureToFile(QStringLiteral("/dev/null"));
+
+ QTRY_COMPARE(savedSignal.size(), 1);
+
+ QCOMPARE(metadataSignal.size(), 1);
+
+ QVariantList metadata = metadataSignal[0];
+ QCOMPARE(metadata[0].toInt(), id);
+ QMediaMetaData data = metadata[1].value<QMediaMetaData>();
+ QCOMPARE(data.keys().size(), 2);
+ QCOMPARE(data[QMediaMetaData::Author].toString(), "Author");
+ QCOMPARE(data[QMediaMetaData::Date].toDateTime().date().year(), 2021);
+}
+
+void tst_QCamera::testCameraWhiteBalance()
+{
+ QCamera camera;
+
+ QCOMPARE(camera.whiteBalanceMode(), QCamera::WhiteBalanceAuto);
+ camera.setWhiteBalanceMode(QCamera::WhiteBalanceFlash);
+ QCOMPARE(camera.whiteBalanceMode(), QCamera::WhiteBalanceAuto);
+ QVERIFY(camera.isWhiteBalanceModeSupported(QCamera::WhiteBalanceAuto));
+ QVERIFY(camera.isWhiteBalanceModeSupported(QCamera::WhiteBalanceManual));
+ QVERIFY(camera.isWhiteBalanceModeSupported(QCamera::WhiteBalanceSunlight));
+ QVERIFY(!camera.isWhiteBalanceModeSupported(QCamera::WhiteBalanceCloudy));
+
+ camera.setWhiteBalanceMode(QCamera::WhiteBalanceSunlight);
+ QCOMPARE(camera.whiteBalanceMode(), QCamera::WhiteBalanceSunlight);
+
+ camera.setWhiteBalanceMode(QCamera::WhiteBalanceManual);
+ QCOMPARE(camera.whiteBalanceMode(), QCamera::WhiteBalanceManual);
+ camera.setColorTemperature(4000);
+ QCOMPARE(camera.colorTemperature(), 4000);
+
+ camera.setColorTemperature(8000);
+ QCOMPARE(camera.colorTemperature(), 8000);
+
+ camera.setWhiteBalanceMode(QCamera::WhiteBalanceAuto);
+ QCOMPARE(camera.whiteBalanceMode(), QCamera::WhiteBalanceAuto);
+ camera.setColorTemperature(4000);
+ QCOMPARE(camera.colorTemperature(), 4000);
+ QCOMPARE(camera.whiteBalanceMode(), QCamera::WhiteBalanceManual);
+
+ camera.setColorTemperature(0);
+ QCOMPARE(camera.colorTemperature(), 0);
+ QCOMPARE(camera.whiteBalanceMode(), QCamera::WhiteBalanceAuto);
+}
+
+void tst_QCamera::testCameraExposure()
+{
+ QCamera camera;
+
+ QVERIFY(camera.isExposureModeSupported(QCamera::ExposureAuto));
+ QCOMPARE(camera.exposureMode(), QCamera::ExposureAuto);
+
+ QVERIFY(camera.isExposureModeSupported(QCamera::ExposureManual));
+ camera.setExposureMode(QCamera::ExposureManual);
+ QCOMPARE(camera.exposureMode(), QCamera::ExposureManual);
+
+ QVERIFY(camera.isExposureModeSupported(QCamera::ExposureNight));
+ camera.setExposureMode(QCamera::ExposureNight);
+ QCOMPARE(camera.exposureMode(), QCamera::ExposureNight);
+
+ QVERIFY(camera.isExposureModeSupported(QCamera::ExposureSports ));
+ camera.setExposureMode(QCamera::ExposureSports);
+ QCOMPARE(camera.exposureMode(), QCamera::ExposureSports);
+
+ QVERIFY(camera.isExposureModeSupported(QCamera::ExposureSnow ));
+ camera.setExposureMode(QCamera::ExposureSnow);
+ QCOMPARE(camera.exposureMode(), QCamera::ExposureSnow);
+
+ QVERIFY(camera.isExposureModeSupported(QCamera::ExposureBeach ));
+ camera.setExposureMode(QCamera::ExposureBeach);
+ QCOMPARE(camera.exposureMode(), QCamera::ExposureBeach);
+
+ QVERIFY(camera.isExposureModeSupported(QCamera::ExposurePortrait ));
+ camera.setExposureMode(QCamera::ExposurePortrait);
+ QCOMPARE(camera.exposureMode(), QCamera::ExposurePortrait);
+
+
+ camera.setFlashMode(QCamera::FlashAuto);
+ QCOMPARE(camera.flashMode(), QCamera::FlashAuto);
+ QCOMPARE(camera.isFlashReady(), true);
+ camera.setFlashMode(QCamera::FlashOn);
+ QCOMPARE(camera.flashMode(), QCamera::FlashOn);
+
+ QCOMPARE(camera.exposureCompensation(), 0.0);
+ camera.setExposureCompensation(2.0);
+ QCOMPARE(camera.exposureCompensation(), 2.0);
+
+ int minIso = camera.minimumIsoSensitivity();
+ int maxIso = camera.maximumIsoSensitivity();
+ QCOMPARE(camera.isoSensitivity(), 100);
+ QVERIFY(minIso > 0);
+ QVERIFY(maxIso > 0);
+ camera.setManualIsoSensitivity(minIso);
+ QCOMPARE(camera.isoSensitivity(), minIso);
+ camera.setManualIsoSensitivity(maxIso*10);
+ QCOMPARE(camera.isoSensitivity(), maxIso);
+
+ camera.setManualIsoSensitivity(-10);
+ QCOMPARE(camera.isoSensitivity(), minIso);
+ camera.setAutoIsoSensitivity();
+ QCOMPARE(camera.isoSensitivity(), 100);
+
+ qreal minExposureTime = camera.minimumExposureTime();
+ qreal maxExposureTime = camera.maximumExposureTime();
+ QVERIFY(minExposureTime > 0);
+ QVERIFY(maxExposureTime > 0);
+ QVERIFY(camera.exposureTime() >= minExposureTime);
+ QVERIFY(camera.exposureTime() <= maxExposureTime);
+
+ camera.setAutoExposureTime();
+ QVERIFY(camera.exposureTime() >= minExposureTime);
+ QVERIFY(camera.exposureTime() <= maxExposureTime);
+
+ camera.setManualExposureTime(0);
+ QCOMPARE(camera.exposureTime(), minExposureTime);
+
+ camera.setManualExposureTime(10000);
+ QCOMPARE(camera.exposureTime(), maxExposureTime);
+
+ camera.setAutoExposureTime();
+}
+
+void tst_QCamera::testCameraFocus()
+{
+ QCamera camera;
+
+ QVERIFY(camera.isFocusModeSupported(QCamera::FocusModeAuto));
+ QVERIFY(camera.isFocusModeSupported(QCamera::FocusModeAuto));
+ QVERIFY(!camera.isFocusModeSupported(QCamera::FocusModeInfinity));
+
+ QCOMPARE(camera.focusMode(), QCamera::FocusModeAuto);
+ camera.setFocusMode(QCamera::FocusModeManual);
+ QCOMPARE(camera.focusMode(), QCamera::FocusModeManual);
+ camera.setFocusMode(QCamera::FocusModeInfinity);
+ QCOMPARE(camera.focusMode(), QCamera::FocusModeManual);
+ camera.setFocusMode(QCamera::FocusModeAuto);
+ QCOMPARE(camera.focusMode(), QCamera::FocusModeAuto);
+
+ QVERIFY(camera.maximumZoomFactor() == 4.0);
+ QVERIFY(camera.minimumZoomFactor() == 1.0);
+ QCOMPARE(camera.zoomFactor(), 1.0);
+ camera.zoomTo(0.5, 1.0);
+ QCOMPARE(camera.zoomFactor(), 1.0);
+ camera.zoomTo(2.0, 0.5);
+ QCOMPARE(camera.zoomFactor(), 2.0);
+ camera.zoomTo(2.5, 1);
+ QCOMPARE(camera.zoomFactor(), 2.5);
+ camera.zoomTo(2000000.0, 0);
+ QCOMPARE(camera.zoomFactor(), camera.maximumZoomFactor());
+
+ QCOMPARE(camera.customFocusPoint(), QPointF(-1, -1));
+ camera.setCustomFocusPoint(QPointF(1.0, 1.0));
+ QCOMPARE(camera.customFocusPoint(), QPointF(1.0, 1.0));
+}
+
+void tst_QCamera::testCameraEncodingProperyChange()
+{
+ QMediaCaptureSession session;
+ QCamera camera;
+ QImageCapture imageCapture;
+ session.setCamera(&camera);
+ session.setImageCapture(&imageCapture);
+
+ QSignalSpy activeChangedSignal(&camera, &QCamera::activeChanged);
+
+ camera.start();
+ QCOMPARE(camera.isActive(), true);
+ QCOMPARE(activeChangedSignal.size(), 1);
+}
+
+void tst_QCamera::testSetVideoOutput()
+{
+ QMediaCaptureSession session;
+ QVideoSink surface;
+ QCamera camera;
+ session.setCamera(&camera);
+
+ QVERIFY(!session.videoOutput());
+
+ session.setVideoOutput(&surface);
+ QVERIFY(session.videoOutput() == &surface);
+ QVERIFY(session.videoSink() == &surface);
+
+ session.setVideoOutput(static_cast<QVideoSink *>(nullptr));
+ QVERIFY(session.videoOutput() == nullptr);
+ QVERIFY(session.videoSink() == nullptr);
+
+ session.setVideoOutput(&surface);
+ QVERIFY(session.videoOutput() == &surface);
+ QVERIFY(session.videoSink() == &surface);
+
+ session.setVideoSink(&surface);
+ QVERIFY(session.videoOutput() == nullptr);
+ QVERIFY(session.videoSink() == &surface);
+
+ session.setVideoOutput(&surface);
+ QVERIFY(session.videoOutput() == &surface);
+ QVERIFY(session.videoSink() == &surface);
+
+ session.setVideoSink(nullptr);
+ QVERIFY(session.videoOutput() == nullptr);
+ QVERIFY(session.videoSink() == nullptr);
+}
+
+
+
+void tst_QCamera::testSetVideoOutputDestruction()
+{
+ {
+ QVideoSink surface;
+ {
+ QMediaCaptureSession session;
+ QCamera camera;
+ session.setCamera(&camera);
+
+ QVERIFY(session.videoOutput() == nullptr);
+ session.setVideoOutput(&surface);
+ }
+ }
+
+ {
+ QMediaCaptureSession session;
+ {
+ QVideoSink surface;
+ QCamera camera;
+ session.setCamera(&camera);
+
+ QVERIFY(session.videoOutput() == nullptr);
+ session.setVideoOutput(&surface);
+ }
+ }
+
+ {
+ QCamera camera;
+ {
+ QMediaCaptureSession session;
+ QVideoSink surface;
+ session.setCamera(&camera);
+
+ QVERIFY(session.videoOutput() == nullptr);
+ session.setVideoOutput(&surface);
+ }
+ }
+ {
+ QMediaCaptureSession session;
+ {
+ QVideoSink surface;
+ QCamera camera;
+ session.setCamera(&camera);
+
+ QVERIFY(session.videoOutput() == nullptr);
+ session.setVideoOutput(&surface);
+ }
+ }
+}
+
+void tst_QCamera::testEnumDebug()
+{
+ QTest::ignoreMessage(QtDebugMsg, "QCamera::CameraError");
+ qDebug() << QCamera::CameraError;
+// QTest::ignoreMessage(QtDebugMsg, "QCameraDevice::FrontFace");
+// qDebug() << QCameraDevice::FrontFace;
+}
+
+void tst_QCamera::testCameraControl()
+{
+ QCamera camera;
+ QMockCamera *m_cameraControl = new QMockCamera(&camera);
+ QVERIFY(m_cameraControl != nullptr);
+}
+
+void tst_QCamera::testConstructor()
+{
+ auto cameras = QMediaDevices::videoInputs();
+ QCameraDevice defaultCamera = QMediaDevices::defaultVideoInput();
+ QCameraDevice frontCamera, backCamera;
+ for (const auto &c : cameras) {
+ if (frontCamera.isNull() && c.position() == QCameraDevice::FrontFace)
+ frontCamera = c;
+ if (backCamera.isNull() && c.position() == QCameraDevice::BackFace)
+ backCamera = c;
+ }
+ QVERIFY(!defaultCamera.isNull());
+ QVERIFY(!frontCamera.isNull());
+ QVERIFY(!backCamera.isNull());
+
+ {
+ QCamera camera;
+ QCOMPARE(camera.isAvailable(), true);
+ QCOMPARE(camera.error(), QCamera::NoError);
+ QCOMPARE(camera.cameraDevice(), defaultCamera);
+ }
+
+ {
+ QCamera camera(QCameraDevice::FrontFace);
+ QCOMPARE(camera.isAvailable(), true);
+ QCOMPARE(camera.error(), QCamera::NoError);
+ QCOMPARE(camera.cameraDevice(), frontCamera);
+ }
+
+ {
+ QCamera camera(QMediaDevices::defaultVideoInput());
+ QCOMPARE(camera.isAvailable(), true);
+ QCOMPARE(camera.error(), QCamera::NoError);
+ QCOMPARE(camera.cameraDevice(), defaultCamera);
+ }
+
+ {
+ QCameraDevice cameraDevice = QMediaDevices::videoInputs().at(0);
+ QCamera camera(cameraDevice);
+ QCOMPARE(camera.isAvailable(), true);
+ QCOMPARE(camera.error(), QCamera::NoError);
+ QCOMPARE(camera.cameraDevice(), cameraDevice);
+ }
+
+ {
+ QCamera camera(QCameraDevice::BackFace);
+ QCOMPARE(camera.isAvailable(), true);
+ QCOMPARE(camera.error(), QCamera::NoError);
+ QCOMPARE(camera.cameraDevice(), backCamera);
+ }
+
+ {
+ // Should load the default camera when UnspecifiedPosition is requested
+ QCamera camera(QCameraDevice::UnspecifiedPosition);
+ QCOMPARE(camera.isAvailable(), true);
+ QCOMPARE(camera.error(), QCamera::NoError);
+ QCOMPARE(camera.cameraDevice(), defaultCamera);
+ }
+}
+
+/* Test case for isAvailable */
+void tst_QCamera::testQCameraIsAvailable()
+{
+ QCamera camera;
+ QVERIFY(camera.isAvailable());
+}
+
+/* Test case for verifying if error signal generated correctly */
+void tst_QCamera::testErrorSignal()
+{
+ QMediaCaptureSession session;
+ QCamera camera;
+ session.setCamera(&camera);
+ auto *service = QMockIntegration::instance()->lastCaptureService();
+ Q_ASSERT(service);
+ Q_ASSERT(service->mockCameraControl);
+
+ QSignalSpy spyError(&camera, &QCamera::errorOccurred);
+
+ /* Set the QPlatformCamera error and verify if the signal is emitted correctly in QCamera */
+ service->mockCameraControl->updateError(QCamera::CameraError, QStringLiteral("Camera Error"));
+
+ QVERIFY(spyError.size() == 1);
+ QCamera::Error err = qvariant_cast<QCamera::Error >(spyError.at(0).at(0));
+ QVERIFY(err == QCamera::CameraError);
+
+ spyError.clear();
+
+ /* Set the QPlatformCamera error and verify if the signal is emitted correctly in QCamera */
+ service->mockCameraControl->updateError(QCamera::CameraError,
+ QStringLiteral("InvalidRequestError Error"));
+ QVERIFY(spyError.size() == 1);
+ err = qvariant_cast<QCamera::Error >(spyError.at(0).at(0));
+ QVERIFY(err == QCamera::CameraError);
+
+ spyError.clear();
+
+ /* Set the QPlatformCamera error and verify if the signal is emitted correctly in QCamera */
+ service->mockCameraControl->updateError(QCamera::CameraError,
+ QStringLiteral("NotSupportedFeatureError Error"));
+ QVERIFY(spyError.size() == 1);
+ err = qvariant_cast<QCamera::Error >(spyError.at(0).at(0));
+ QVERIFY(err == QCamera::CameraError);
+
+}
+
+/* Test case for verifying the QCamera error */
+void tst_QCamera::testError()
+{
+ QMediaCaptureSession session;
+ QCamera camera;
+ session.setCamera(&camera);
+ auto *service = QMockIntegration::instance()->lastCaptureService();
+
+ /* Set the QPlatformCamera error and verify if it is set correctly in QCamera */
+ service->mockCameraControl->updateError(QCamera::CameraError, QStringLiteral("Camera Error"));
+ QVERIFY(camera.error() == QCamera::CameraError);
+
+ /* Set the QPlatformCamera error and verify if it is set correctly in QCamera */
+ service->mockCameraControl->updateError(QCamera::CameraError,
+ QStringLiteral("InvalidRequestError Error"));
+ QVERIFY(camera.error() == QCamera::CameraError);
+
+ /* Set the QPlatformCamera error and verify if it is set correctly in QCamera */
+ service->mockCameraControl->updateError(QCamera::CameraError,
+ QStringLiteral("CameraError Error"));
+ QVERIFY(camera.error() == QCamera::CameraError);
+
+}
+
+/* Test the error strings for QCamera class */
+void tst_QCamera::testErrorString()
+{
+ QMediaCaptureSession session;
+ QCamera camera;
+ session.setCamera(&camera);
+ auto *service = QMockIntegration::instance()->lastCaptureService();
+
+ /* Set the QPlatformCamera error and verify if it is set correctly in QCamera */
+ service->mockCameraControl->updateError(QCamera::CameraError, QStringLiteral("Camera Error"));
+ QVERIFY(camera.errorString() == QStringLiteral("Camera Error"));
+
+ /* Set the QPlatformCamera error and verify if it is set correctly in QCamera */
+ service->mockCameraControl->updateError(QCamera::CameraError,
+ QStringLiteral("InvalidRequestError Error"));
+ QVERIFY(camera.errorString() == QStringLiteral("InvalidRequestError Error"));
+
+ /* Set the QPlatformCamera error and verify if it is set correctly in QCamera */
+ service->mockCameraControl->updateError(QCamera::CameraError,
+ QStringLiteral("CameraError Error"));
+ QVERIFY(camera.errorString() == QStringLiteral("CameraError Error"));
+}
+
+void tst_QCamera::testSetCameraFormat()
+{
+ QCamera camera;
+ QCameraDevice device = camera.cameraDevice();
+ auto videoFormats = device.videoFormats();
+ QVERIFY(videoFormats.size());
+ QCameraFormat cameraFormat = videoFormats.first();
+ QSignalSpy spy(&camera, &QCamera::cameraFormatChanged);
+ QVERIFY(spy.size() == 0);
+ camera.setCameraFormat(cameraFormat);
+ QCOMPARE(spy.size(), 1);
+ QCOMPARE(camera.cameraFormat(), cameraFormat);
+ QCOMPARE(camera.cameraFormat().pixelFormat(), QVideoFrameFormat::Format_ARGB8888);
+ QCOMPARE(camera.cameraFormat().resolution(), QSize(640, 480));
+ QCOMPARE(camera.cameraFormat().minFrameRate(), 0);
+ QCOMPARE(camera.cameraFormat().maxFrameRate(), 30);
+ QCOMPARE(spy.size(), 1);
+
+ spy.clear();
+ camera.setCameraFormat({});
+ QCOMPARE(spy.size(), 1);
+ QCOMPARE(camera.cameraFormat(), QCameraFormat());
+
+ spy.clear();
+ camera.setCameraDevice(QMediaDevices::videoInputs().at(1));
+ QCOMPARE(spy.size(), 1);
+ QCOMPARE(camera.cameraFormat(), QCameraFormat());
+ camera.setCameraFormat(camera.cameraDevice().videoFormats().first());
+ QCOMPARE(camera.cameraFormat().pixelFormat(), QVideoFrameFormat::Format_XRGB8888);
+ QCOMPARE(camera.cameraFormat().resolution(), QSize(1280, 720));
+ QCOMPARE(camera.cameraFormat().minFrameRate(), 0);
+ QCOMPARE(camera.cameraFormat().maxFrameRate(), 30);
+ QCOMPARE(spy.size(), 2);
+}
+
+//Added this code to cover QCamera::FocusModeHyperfocal and QCamera::FocusModeAutoNear
+//As the FocusModeHyperfocal and FocusModeAutoNear are not supported we can not set the focus mode to these Focus Modes
+void tst_QCamera::testFocusMode()
+{
+ QMediaCaptureSession session;
+ QCamera camera;
+ session.setCamera(&camera);
+
+ QVERIFY(!camera.isFocusModeSupported(QCamera::FocusModeInfinity));
+ QVERIFY(camera.isFocusModeSupported(QCamera::FocusModeAutoNear));
+ QCOMPARE(camera.focusMode(), QCamera::FocusModeAuto);
+ camera.setFocusMode(QCamera::FocusModeInfinity);
+ QVERIFY(camera.focusMode() != QCamera::FocusModeInfinity);
+ QCOMPARE(camera.focusMode(), QCamera::FocusModeAuto);
+ camera.setFocusMode(QCamera::FocusModeAutoNear);
+ QVERIFY(camera.focusMode() == QCamera::FocusModeAutoNear);
+}
+
+void tst_QCamera::testZoomChanged()
+{
+ QMediaCaptureSession session;
+ QCamera camera;
+ session.setCamera(&camera);
+
+ QSignalSpy spy(&camera, &QCamera::zoomFactorChanged);
+ QVERIFY(spy.size() == 0);
+ camera.setZoomFactor(2.0);
+ QVERIFY(spy.size() == 1);
+ camera.zoomTo(3.0, 1);
+ QVERIFY(spy.size() == 2);
+ camera.zoomTo(1.0, 0);
+ QVERIFY(spy.size() == 3);
+}
+
+void tst_QCamera::testMaxZoomChangedSignal()
+{
+ QMediaCaptureSession session;
+ QCamera camera;
+ session.setCamera(&camera);
+ QMockCamera *mock = QMockIntegration::instance()->lastCamera();
+
+ // ### change max zoom factor on backend, e.g. by changing camera
+ QSignalSpy spy(&camera, &QCamera::maximumZoomFactorChanged);
+ mock->maximumZoomFactorChanged(55);
+ QVERIFY(spy.size() == 1);
+ QCOMPARE(camera.maximumZoomFactor(), 55);
+}
+
+void tst_QCamera::testSignalExposureCompensationChanged()
+{
+ QMediaCaptureSession session;
+ QCamera camera;
+ session.setCamera(&camera);
+
+ QSignalSpy spyExposureCompensationChanged(&camera, &QCamera::exposureCompensationChanged);
+
+ QVERIFY(spyExposureCompensationChanged.size() == 0);
+
+ QVERIFY(camera.exposureCompensation() != 800);
+ camera.setExposureCompensation(2.0);
+
+ QTest::qWait(100);
+
+ QVERIFY(camera.exposureCompensation() == 2.0);
+
+ QCOMPARE(spyExposureCompensationChanged.size(),1);
+
+ // Setting the same should not result in a signal
+ camera.setExposureCompensation(2.0);
+ QTest::qWait(100);
+
+ QVERIFY(camera.exposureCompensation() == 2.0);
+ QCOMPARE(spyExposureCompensationChanged.size(),1);
+}
+
+void tst_QCamera::testSignalIsoSensitivityChanged()
+{
+ QMediaCaptureSession session;
+ QCamera camera;
+ session.setCamera(&camera);
+
+ QSignalSpy spyisoSensitivityChanged(&camera, &QCamera::isoSensitivityChanged);
+
+ QVERIFY(spyisoSensitivityChanged.size() ==0);
+
+ camera.setManualIsoSensitivity(800); //set the manualiso sentivity to 800
+ QTest::qWait(100);
+ QVERIFY(spyisoSensitivityChanged.size() ==1);
+
+}
+void tst_QCamera::testSignalShutterSpeedChanged()
+{
+ QMediaCaptureSession session;
+ QCamera camera;
+ session.setCamera(&camera);
+
+ QSignalSpy spySignalExposureTimeChanged(&camera, &QCamera::exposureTimeChanged);
+
+ QVERIFY(spySignalExposureTimeChanged.size() == 0);
+
+ camera.setManualExposureTime(2.0);//set the ManualShutterSpeed to 2.0
+ QTest::qWait(100);
+
+ QVERIFY(spySignalExposureTimeChanged.size() ==1);
+}
+
+void tst_QCamera::testSignalFlashReady()
+{
+ QMediaCaptureSession session;
+ QCamera camera;
+ session.setCamera(&camera);
+
+ QSignalSpy spyflashReady(&camera, &QCamera::flashReady);
+
+ QVERIFY(spyflashReady.size() == 0);
+
+ QVERIFY(camera.flashMode() == QCamera::FlashAuto);
+
+ camera.setFlashMode(QCamera::FlashOff);//set theFlashMode to QCamera::FlashOff
+
+ QVERIFY(camera.flashMode() == QCamera::FlashOff);
+
+ QCOMPARE(spyflashReady.size(), 1);
+}
+
+QTEST_MAIN(tst_QCamera)
+
+#include "tst_qcamera.moc"
diff --git a/tests/auto/unit/multimedia/qcameradevice/CMakeLists.txt b/tests/auto/unit/multimedia/qcameradevice/CMakeLists.txt
new file mode 100644
index 000000000..4d9977e8e
--- /dev/null
+++ b/tests/auto/unit/multimedia/qcameradevice/CMakeLists.txt
@@ -0,0 +1,20 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+# Generated from qcameradevice.pro.
+
+#####################################################################
+## tst_qcameradevice Test:
+#####################################################################
+
+qt_internal_add_test(tst_qcameradevice
+ SOURCES
+ tst_qcameradevice.cpp
+ INCLUDE_DIRECTORIES
+ ../../mockbackend
+ LIBRARIES
+ # Remove: L${CMAKE_CURRENT_SOURCE_DIR}
+ Qt::Gui
+ Qt::MultimediaPrivate
+ MockMultimediaPlugin
+)
diff --git a/tests/auto/unit/multimedia/qcameradevice/tst_qcameradevice.cpp b/tests/auto/unit/multimedia/qcameradevice/tst_qcameradevice.cpp
new file mode 100644
index 000000000..455586243
--- /dev/null
+++ b/tests/auto/unit/multimedia/qcameradevice/tst_qcameradevice.cpp
@@ -0,0 +1,139 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QtTest/QtTest>
+#include <QDebug>
+
+#include <qcamera.h>
+#include <qcameradevice.h>
+#include <qmediadevices.h>
+
+#include "qmockintegration.h"
+
+QT_USE_NAMESPACE
+
+Q_ENABLE_MOCK_MULTIMEDIA_PLUGIN
+
+using namespace Qt::Literals;
+
+class tst_QCameraDevice: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void constructor();
+ void defaultCamera();
+ void availableCameras();
+ void equality_operators();
+ void qDebug_operator();
+};
+
+void tst_QCameraDevice::constructor()
+{
+ {
+ // default camera
+ QCamera camera;
+ QCameraDevice info(camera.cameraDevice());
+ QVERIFY(!info.isNull());
+ QCOMPARE(info.id(), u"default"_s);
+ QCOMPARE(info.description(), u"defaultCamera"_s);
+ QCOMPARE(info.position(), QCameraDevice::UnspecifiedPosition);
+ }
+
+ auto cameras = QMediaDevices::videoInputs();
+ QCameraDevice info;
+ for (const auto &c : cameras) {
+ if (c.position() == QCameraDevice::BackFace)
+ info = c;
+ }
+ QVERIFY(!info.isNull());
+
+ QCamera camera(info);
+ QCOMPARE(info, camera.cameraDevice());
+ QVERIFY(!info.isNull());
+ QCOMPARE(info.id(), u"back"_s);
+ QCOMPARE(info.description(), u"backCamera"_s);
+ QCOMPARE(info.position(), QCameraDevice::BackFace);
+
+ QCameraDevice info2(info);
+ QVERIFY(!info2.isNull());
+ QCOMPARE(info2.id(), u"back"_s);
+ QCOMPARE(info2.description(), u"backCamera"_s);
+ QCOMPARE(info2.position(), QCameraDevice::BackFace);
+}
+
+void tst_QCameraDevice::defaultCamera()
+{
+ QCameraDevice info = QMediaDevices::defaultVideoInput();
+
+ QVERIFY(!info.isNull());
+ QCOMPARE(info.id(), u"default"_s);
+ QCOMPARE(info.description(), u"defaultCamera"_s);
+ QCOMPARE(info.position(), QCameraDevice::UnspecifiedPosition);
+
+ QCamera camera(info);
+ QCOMPARE(camera.cameraDevice(), info);
+}
+
+void tst_QCameraDevice::availableCameras()
+{
+ QList<QCameraDevice> cameras = QMediaDevices::videoInputs();
+ QCOMPARE(cameras.size(), 3);
+
+ QCameraDevice info = cameras.at(0);
+ QVERIFY(!info.isNull());
+ QCOMPARE(info.id(), u"default"_s);
+ QCOMPARE(info.description(), u"defaultCamera"_s);
+ QCOMPARE(info.position(), QCameraDevice::UnspecifiedPosition);
+
+ info = cameras.at(1);
+ QVERIFY(!info.isNull());
+ QCOMPARE(info.id(), QStringLiteral("front"));
+ QCOMPARE(info.description(), QStringLiteral("frontCamera"));
+ QCOMPARE(info.position(), QCameraDevice::FrontFace);
+
+ QCOMPARE(cameras.size(), 3);
+ info = cameras.at(2);
+ QVERIFY(!info.isNull());
+ QCOMPARE(info.id(), u"back"_s);
+ QCOMPARE(info.description(), u"backCamera"_s);
+ QCOMPARE(info.position(), QCameraDevice::BackFace);
+}
+
+void tst_QCameraDevice::equality_operators()
+{
+ QCameraDevice defaultCamera = QMediaDevices::defaultVideoInput();
+ QList<QCameraDevice> cameras = QMediaDevices::videoInputs();
+
+ QVERIFY(defaultCamera == cameras.at(0));
+ QVERIFY(defaultCamera != cameras.at(1));
+ QVERIFY(cameras.at(0) != cameras.at(1));
+
+ {
+ QCamera camera(defaultCamera);
+ QVERIFY(camera.cameraDevice() == defaultCamera);
+ QVERIFY(camera.cameraDevice() == cameras.at(0));
+ }
+
+ {
+ QCamera camera(cameras.at(1));
+ QVERIFY(camera.cameraDevice() == cameras.at(1));
+ }
+}
+
+void tst_QCameraDevice::qDebug_operator()
+{
+ QString outputString;
+ QDebug debug(&outputString);
+ debug.nospace();
+
+ QCameraDevice defaultCamera = QMediaDevices::defaultVideoInput();
+ debug << defaultCamera;
+
+ QCOMPARE(outputString,
+ u"\"QCameraDevice(name=defaultCamera, id=default, position=UnspecifiedPosition)\" "_s);
+}
+
+QTEST_MAIN(tst_QCameraDevice)
+
+#include "tst_qcameradevice.moc"
diff --git a/tests/auto/unit/multimedia/qerrorinfo/CMakeLists.txt b/tests/auto/unit/multimedia/qerrorinfo/CMakeLists.txt
new file mode 100644
index 000000000..ea6ac5690
--- /dev/null
+++ b/tests/auto/unit/multimedia/qerrorinfo/CMakeLists.txt
@@ -0,0 +1,10 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+qt_internal_add_test(tst_qerrorinfo
+ SOURCES
+ tst_qerrorinfo.cpp
+ LIBRARIES
+ Qt::Gui
+ Qt::MultimediaPrivate
+)
diff --git a/tests/auto/unit/multimedia/qerrorinfo/tst_qerrorinfo.cpp b/tests/auto/unit/multimedia/qerrorinfo/tst_qerrorinfo.cpp
new file mode 100644
index 000000000..0d266705d
--- /dev/null
+++ b/tests/auto/unit/multimedia/qerrorinfo/tst_qerrorinfo.cpp
@@ -0,0 +1,117 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+// TESTED_COMPONENT=src/multimedia
+
+#include <QtTest/QtTest>
+#include <QSignalSpy>
+#include <private/qerrorinfo_p.h>
+
+QT_USE_NAMESPACE
+
+enum class TestError { ErrorA, ErrorB, NoError };
+
+using TestErrorInfo = QErrorInfo<TestError>;
+
+class TestNotifier : public QObject
+{
+ Q_OBJECT
+public:
+signals:
+ void errorOccurred(TestError error, QString errorDescription);
+ void errorChanged();
+};
+
+class tst_QErrorInfo : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void defaultConstructor_setsNoError();
+ void constructor_setsPassedError();
+
+ void setAndNotify_setsErrorAndNotifes_data();
+ void setAndNotify_setsErrorAndNotifes();
+};
+
+void tst_QErrorInfo::defaultConstructor_setsNoError()
+{
+ TestErrorInfo errorInfo;
+ QCOMPARE(errorInfo.code(), TestError::NoError);
+ QCOMPARE(errorInfo.description(), QString());
+}
+
+void tst_QErrorInfo::constructor_setsPassedError()
+{
+ TestErrorInfo errorInfo(TestError::ErrorB, "test error");
+ QCOMPARE(errorInfo.code(), TestError::ErrorB);
+ QCOMPARE(errorInfo.description(), "test error");
+}
+
+void tst_QErrorInfo::setAndNotify_setsErrorAndNotifes_data()
+{
+ QTest::addColumn<TestError>("initialError");
+ QTest::addColumn<QString>("initialErrorDescription");
+ QTest::addColumn<TestError>("error");
+ QTest::addColumn<QString>("errorDescription");
+ QTest::addColumn<bool>("errorChangedEmitted");
+ QTest::addColumn<bool>("errorOccurredEmitted");
+
+ QTest::newRow("No error -> No error")
+ << TestError::NoError << QString() << TestError::NoError << QString() << false << false;
+ QTest::newRow("No error -> An error with empty string")
+ << TestError::NoError << QString() << TestError::ErrorA << QString() << true << true;
+ QTest::newRow("No error -> An error with non-empty string")
+ << TestError::NoError << QString() << TestError::ErrorB << QStringLiteral("error") << true
+ << true;
+ QTest::newRow("An error with empty string -> No error")
+ << TestError::ErrorA << QString() << TestError::NoError << QString() << true << false;
+ QTest::newRow("An error with non-empty string -> No Error")
+ << TestError::ErrorA << QStringLiteral("error") << TestError::NoError << QString() << true
+ << false;
+ QTest::newRow("An error -> Another error")
+ << TestError::ErrorA << QStringLiteral("error A") << TestError::ErrorB << QStringLiteral("error B")
+ << true << true;
+ QTest::newRow("An error -> Another error with empty string")
+ << TestError::ErrorA << QStringLiteral("error A") << TestError::ErrorB << QString() << true
+ << true;
+ QTest::newRow("An error -> The same error with changed string")
+ << TestError::ErrorA << QStringLiteral("error") << TestError::ErrorA
+ << QStringLiteral("another error") << true << true;
+}
+
+void tst_QErrorInfo::setAndNotify_setsErrorAndNotifes()
+{
+ QFETCH(TestError, initialError);
+ QFETCH(QString, initialErrorDescription);
+ QFETCH(TestError, error);
+ QFETCH(QString, errorDescription);
+ QFETCH(bool, errorChangedEmitted);
+ QFETCH(bool, errorOccurredEmitted);
+
+ TestErrorInfo errorInfo(initialError, initialErrorDescription);
+
+ TestNotifier notifier;
+ QSignalSpy errorOccurredSpy(&notifier, &TestNotifier::errorOccurred);
+ QSignalSpy errorChangedSpy(&notifier, &TestNotifier::errorChanged);
+
+ errorInfo.setAndNotify(error, errorDescription, notifier);
+
+ QCOMPARE(errorInfo.code(), error);
+ QCOMPARE(errorInfo.description(), errorDescription);
+
+ QList<QList<QVariant>> expectedErrorChanged;
+ if (errorChangedEmitted)
+ expectedErrorChanged.push_back({});
+
+ QList<QList<QVariant>> expectedErrorOccured;
+ if (errorOccurredEmitted)
+ expectedErrorOccured.push_back({ QVariant::fromValue(error), errorDescription });
+
+ QCOMPARE(errorOccurredSpy, expectedErrorOccured);
+ QCOMPARE(errorChangedSpy, expectedErrorChanged);
+}
+
+QTEST_GUILESS_MAIN(tst_QErrorInfo)
+
+#include "tst_qerrorinfo.moc"
diff --git a/tests/auto/unit/multimedia/qimagecapture/CMakeLists.txt b/tests/auto/unit/multimedia/qimagecapture/CMakeLists.txt
new file mode 100644
index 000000000..908154cf9
--- /dev/null
+++ b/tests/auto/unit/multimedia/qimagecapture/CMakeLists.txt
@@ -0,0 +1,20 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+# Generated from qimagecapture.pro.
+
+#####################################################################
+## tst_qimagecapture Test:
+#####################################################################
+
+qt_internal_add_test(tst_qimagecapture
+ SOURCES
+ tst_qimagecapture.cpp
+ INCLUDE_DIRECTORIES
+ ../../mockbackend
+ LIBRARIES
+ # Remove: L${CMAKE_CURRENT_SOURCE_DIR}
+ Qt::Gui
+ Qt::MultimediaPrivate
+ MockMultimediaPlugin
+)
diff --git a/tests/auto/unit/multimedia/qimagecapture/tst_qimagecapture.cpp b/tests/auto/unit/multimedia/qimagecapture/tst_qimagecapture.cpp
new file mode 100644
index 000000000..3267b6f40
--- /dev/null
+++ b/tests/auto/unit/multimedia/qimagecapture/tst_qimagecapture.cpp
@@ -0,0 +1,284 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QtTest/QtTest>
+#include <QDebug>
+
+#include <private/qplatformcamera_p.h>
+#include <private/qplatformimagecapture_p.h>
+#include <qcamera.h>
+#include <qimagecapture.h>
+#include <qmediacapturesession.h>
+
+#include "qmockmediacapturesession.h"
+#include "qmockintegration.h"
+
+QT_USE_NAMESPACE
+
+Q_ENABLE_MOCK_MULTIMEDIA_PLUGIN
+
+class tst_QImageCapture: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void constructor();
+ void isAvailable();
+ void deleteMediaSource();
+ void isReadyForCapture();
+ void capture();
+ void encodingSettings();
+ void errors();
+ void error();
+ void imageCaptured();
+ void imageExposed();
+ void imageSaved();
+ void readyForCaptureChanged();
+};
+
+void tst_QImageCapture::constructor()
+{
+ QMediaCaptureSession session;
+ QCamera camera;
+ QImageCapture imageCapture;
+ session.setCamera(&camera);
+ session.setImageCapture(&imageCapture);
+
+ QVERIFY(imageCapture.isAvailable() == true);
+}
+
+void tst_QImageCapture::isAvailable()
+{
+ {
+ QMediaCaptureSession session;
+ QImageCapture imageCapture;
+ session.setImageCapture(&imageCapture);
+
+ QVERIFY(!imageCapture.isAvailable());
+ }
+
+ {
+ QMediaCaptureSession session;
+ QCamera camera;
+ QImageCapture imageCapture;
+ session.setCamera(&camera);
+ session.setImageCapture(&imageCapture);
+
+ QVERIFY(imageCapture.isAvailable());
+ }
+}
+
+void tst_QImageCapture::deleteMediaSource()
+{
+ QMediaCaptureSession session;
+ QCamera *camera = new QCamera;
+ QImageCapture *capture = new QImageCapture;
+ session.setCamera(camera);
+ session.setImageCapture(capture);
+
+ QVERIFY(capture->isAvailable());
+
+ delete camera;
+
+ QVERIFY(session.camera() == nullptr);
+ QVERIFY(!capture->isAvailable());
+
+ capture->captureToFile();
+ delete capture;
+}
+
+void tst_QImageCapture::isReadyForCapture()
+{
+ QMediaCaptureSession session;
+ QCamera camera;
+ QImageCapture imageCapture;
+ session.setCamera(&camera);
+ session.setImageCapture(&imageCapture);
+
+ QVERIFY(imageCapture.isAvailable() == true);
+ QVERIFY(imageCapture.isReadyForCapture() == false);
+ camera.start();
+ QVERIFY(imageCapture.isReadyForCapture() == true);
+ imageCapture.captureToFile();
+ QTRY_VERIFY(imageCapture.isReadyForCapture());
+ camera.stop();
+}
+
+void tst_QImageCapture::capture()
+{
+ QMediaCaptureSession session;
+ QCamera camera;
+ QImageCapture imageCapture;
+ session.setCamera(&camera);
+ session.setImageCapture(&imageCapture);
+
+ QVERIFY(imageCapture.isAvailable() == true);
+ QVERIFY(imageCapture.isReadyForCapture() == false);
+ QVERIFY(imageCapture.captureToFile() == -1);
+ camera.start();
+ QVERIFY(imageCapture.isReadyForCapture() == true);
+ QTest::qWait(300);
+ QVERIFY(imageCapture.captureToFile() != -1);
+ camera.stop();
+}
+
+void tst_QImageCapture::encodingSettings()
+{
+ QMediaCaptureSession session;
+ QCamera camera;
+ QImageCapture imageCapture;
+ session.setCamera(&camera);
+ session.setImageCapture(&imageCapture);
+
+ QVERIFY(imageCapture.isAvailable() == true);
+ imageCapture.setFileFormat(QImageCapture::JPEG);
+ imageCapture.setQuality(QImageCapture::NormalQuality);
+ QVERIFY(imageCapture.fileFormat() == QImageCapture::JPEG);
+ QVERIFY(imageCapture.quality() == QImageCapture::NormalQuality);
+}
+
+void tst_QImageCapture::errors()
+{
+ QMockCamera::Simple simple;
+
+ {
+ QMediaCaptureSession session;
+ QCamera camera;
+ QImageCapture imageCapture;
+ session.setCamera(&camera);
+ session.setImageCapture(&imageCapture);
+
+ QVERIFY(imageCapture.isAvailable() == true);
+ imageCapture.captureToFile(QStringLiteral("/dev/null"));
+ QCOMPARE(imageCapture.error(), QImageCapture::NotReadyError);
+ QVERIFY(!imageCapture.errorString().isEmpty());
+ }
+
+ QMediaCaptureSession session;
+ QCamera camera;
+ QImageCapture imageCapture;
+ session.setCamera(&camera);
+ session.setImageCapture(&imageCapture);
+ camera.start();
+
+ QVERIFY(imageCapture.isAvailable() == true);
+ QVERIFY(imageCapture.error() == QImageCapture::NoError);
+ QVERIFY(imageCapture.errorString().isEmpty());
+
+ imageCapture.captureToFile();
+ QVERIFY(imageCapture.error() == QImageCapture::NoError);
+ QVERIFY(imageCapture.errorString().isEmpty());
+}
+
+void tst_QImageCapture::error()
+{
+ QMediaCaptureSession session;
+ QCamera camera;
+ QImageCapture imageCapture;
+ session.setCamera(&camera);
+ session.setImageCapture(&imageCapture);
+
+ QSignalSpy spy(&imageCapture, &QImageCapture::errorOccurred);
+ imageCapture.captureToFile();
+ QTest::qWait(30);
+ QVERIFY(spy.size() == 1);
+ QVERIFY(qvariant_cast<int>(spy.at(0).at(0)) == -1);
+ QVERIFY(qvariant_cast<QImageCapture::Error>(spy.at(0).at(1)) == QImageCapture::NotReadyError);
+ QVERIFY(qvariant_cast<QString>(spy.at(0).at(2)) == "Could not capture in stopped state");
+ spy.clear();
+}
+
+void tst_QImageCapture::imageCaptured()
+{
+ QMediaCaptureSession session;
+ QCamera camera;
+ QImageCapture imageCapture;
+ session.setCamera(&camera);
+ session.setImageCapture(&imageCapture);
+
+ QSignalSpy spy(&imageCapture, &QImageCapture::imageCaptured);
+ QVERIFY(imageCapture.isAvailable() == true);
+ QVERIFY(imageCapture.isReadyForCapture() == false);
+ camera.start();
+ imageCapture.captureToFile();
+ QTRY_VERIFY(imageCapture.isReadyForCapture());
+
+ QVERIFY(spy.size() == 1);
+ QVERIFY(qvariant_cast<int>(spy.at(0).at(0)) > 0);
+ QImage image = qvariant_cast<QImage>(spy.at(0).at(1));
+ QVERIFY(image.isNull() == true);
+ spy.clear();
+ camera.stop();
+}
+
+void tst_QImageCapture::imageExposed()
+{
+ QMediaCaptureSession session;
+ QCamera camera;
+ QImageCapture imageCapture;
+ session.setCamera(&camera);
+ session.setImageCapture(&imageCapture);
+
+ QSignalSpy spy(&imageCapture, &QImageCapture::imageExposed);
+ QVERIFY(imageCapture.isAvailable() == true);
+ QVERIFY(imageCapture.isReadyForCapture() == false);
+ camera.start();
+ imageCapture.captureToFile();
+ QTRY_VERIFY(imageCapture.isReadyForCapture());
+
+ QVERIFY(spy.size() == 1);
+ QVERIFY(qvariant_cast<int>(spy.at(0).at(0)) > 0);
+ spy.clear();
+ camera.stop();
+}
+
+void tst_QImageCapture::imageSaved()
+{
+ QMediaCaptureSession session;
+ QCamera camera;
+ QImageCapture imageCapture;
+ session.setCamera(&camera);
+ session.setImageCapture(&imageCapture);
+
+ QSignalSpy spy(&imageCapture, &QImageCapture::imageSaved);
+ QVERIFY(imageCapture.isAvailable() == true);
+ QVERIFY(imageCapture.isReadyForCapture() == false);
+ camera.start();
+ imageCapture.captureToFile(QStringLiteral("/usr/share"));
+ QTRY_VERIFY(imageCapture.isReadyForCapture());
+
+ QVERIFY(spy.size() == 1);
+ QVERIFY(qvariant_cast<int>(spy.at(0).at(0)) > 0);
+ QVERIFY(qvariant_cast<QString>(spy.at(0).at(1)) == "/usr/share");
+ spy.clear();
+ camera.stop();
+}
+
+void tst_QImageCapture::readyForCaptureChanged()
+{
+ QMediaCaptureSession session;
+ QCamera camera;
+ QImageCapture imageCapture;
+ session.setCamera(&camera);
+ session.setImageCapture(&imageCapture);
+
+ QSignalSpy spy(&imageCapture, &QImageCapture::readyForCaptureChanged);
+ QVERIFY(imageCapture.isReadyForCapture() == false);
+ imageCapture.captureToFile();
+ QTest::qWait(100);
+ QVERIFY(spy.size() == 0);
+ QVERIFY2(!imageCapture.errorString().isEmpty(),"Could not capture in stopped state" );
+ camera.start();
+ QTest::qWait(100);
+ imageCapture.captureToFile();
+ QTest::qWait(100);
+ QVERIFY(spy.size() == 2);
+ QVERIFY(spy.at(0).at(0).toBool() == false);
+ QVERIFY(spy.at(1).at(0).toBool() == true);
+ camera.stop();
+ spy.clear();
+}
+
+QTEST_MAIN(tst_QImageCapture)
+
+#include "tst_qimagecapture.moc"
diff --git a/tests/auto/unit/multimedia/qmaybe/CMakeLists.txt b/tests/auto/unit/multimedia/qmaybe/CMakeLists.txt
new file mode 100644
index 000000000..a9053e87c
--- /dev/null
+++ b/tests/auto/unit/multimedia/qmaybe/CMakeLists.txt
@@ -0,0 +1,9 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+qt_internal_add_test(tst_qmaybe
+ SOURCES
+ tst_qmaybe.cpp
+ LIBRARIES
+ Qt::MultimediaPrivate
+)
diff --git a/tests/auto/unit/multimedia/qmaybe/tst_qmaybe.cpp b/tests/auto/unit/multimedia/qmaybe/tst_qmaybe.cpp
new file mode 100644
index 000000000..fbf21a26d
--- /dev/null
+++ b/tests/auto/unit/multimedia/qmaybe/tst_qmaybe.cpp
@@ -0,0 +1,124 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QtTest/QtTest>
+#include <private/qmaybe_p.h>
+#include <QtCore/private/quniquehandle_p.h>
+#ifdef Q_OS_WINDOWS
+#include <private/qcomptr_p.h>
+#include <private/qcomobject_p.h>
+#endif
+
+QT_USE_NAMESPACE
+
+using namespace Qt::StringLiterals;
+
+namespace {
+
+// Helpers used to verify interop with QUniqueHandle and ComPtr which
+// overloads operator&
+struct DummyHandleTraits
+{
+ using Type = int;
+ static Type invalidValue() { return -1; }
+ static bool close(Type /*handle*/) { return true; }
+};
+
+using DummyHandle = QUniqueHandle<DummyHandleTraits>;
+
+#ifdef Q_OS_WINDOWS
+struct DummyComObject : QComObject<IUnknown>
+{
+};
+#endif
+
+} // namespace
+
+//clang-format off
+
+class tst_QMaybe : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void operatorBool_returnsFalse_onlyWhenErrorSet()
+ {
+ {
+ const QMaybe<QString, int> error{ -1 }; // TOOD: Is it safe to deduce expected/unexpected only based on type?
+ QVERIFY(!static_cast<bool>(error));
+ }
+
+ {
+ const QMaybe<QString, int> success{ "It worked!"_L1 };
+ QVERIFY(static_cast<bool>(success));
+ }
+ }
+
+ void value_returnsReferenceToValue_whenValueSet()
+ {
+ {
+ QMaybe mutableVal{ 1 };
+ mutableVal.value() = 2;
+ QCOMPARE_EQ(*mutableVal, 2); // value() must have returned a mutable reference
+ }
+
+ {
+ const QMaybe immutableVal{ 2 };
+ QCOMPARE_EQ(*std::addressof(immutableVal.value()), 2); // value() must have returned a reference
+ static_assert(std::is_const_v<std::remove_reference_t<decltype(immutableVal.value())>>); // And it is const
+ }
+ }
+
+ void dereferenceOperator_returnsPointerToValue_whenValueTypeOverloadsAddressOfOperator()
+ {
+ {
+ QMaybe<DummyHandle, int> mutableValue{ DummyHandle{ 1 } };
+ QCOMPARE_EQ(mutableValue->get(), 1);
+ QVERIFY(mutableValue->isValid()); // We did not accidentally call operator& that resets
+ // QUniqueHandle
+ }
+
+ {
+ const QMaybe<DummyHandle, int> immutableValue{ DummyHandle{ 2 } };
+ QCOMPARE_EQ(immutableValue->get(), 2);
+ QVERIFY(immutableValue->isValid()); // We did not accidentally call operator& that
+ // resets QUniqueHandle
+ }
+ }
+
+#ifdef Q_OS_WINDOWS
+ void dereferenceOperator_returnsPointerToValue_whenValueIsComPtr()
+ {
+ // Similar test as with QUniqueHandle, but with ComPtr that is used
+ // frequently on Windows and may behave slightly differently
+
+ {
+ QMaybe<ComPtr<DummyComObject>, HRESULT> mutableObject{
+ makeComObject<DummyComObject>()
+ };
+ QCOMPARE_NE(mutableObject->Get(), nullptr);
+
+ const ComPtr<IUnknown> unknownFromMutable = mutableObject.value();
+ QVERIFY(unknownFromMutable); // We did not accidentally call operator& that resets
+ // QUniqueHandle
+ }
+
+ {
+ QMaybe<ComPtr<DummyComObject>, HRESULT> immutableObject{
+ makeComObject<DummyComObject>()
+ };
+ QCOMPARE_NE(immutableObject->Get(), nullptr);
+
+ const ComPtr<IUnknown> unknownFromImmutable = immutableObject.value();
+ QVERIFY(unknownFromImmutable); // We did not accidentally call operator& that resets
+ // QUniqueHandle
+ }
+ }
+#endif
+};
+
+QTEST_APPLESS_MAIN(tst_QMaybe)
+
+#include "tst_qmaybe.moc"
+
+//clang-format on
diff --git a/tests/auto/unit/multimedia/qmediacapture_gstreamer/CMakeLists.txt b/tests/auto/unit/multimedia/qmediacapture_gstreamer/CMakeLists.txt
new file mode 100644
index 000000000..209be5883
--- /dev/null
+++ b/tests/auto/unit/multimedia/qmediacapture_gstreamer/CMakeLists.txt
@@ -0,0 +1,18 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+#####################################################################
+## tst_qmediacapture_gstreamer Test:
+#####################################################################
+
+qt_internal_add_test(tst_qmediacapture_gstreamer
+ SOURCES
+ tst_qmediacapture_gstreamer.cpp
+ ../../../shared/qscopedenvironmentvariable.h
+ INCLUDE_DIRECTORIES
+ ../../../shared
+ LIBRARIES
+ Qt::Multimedia
+ Qt::MultimediaPrivate
+ Qt::QGstreamerMediaPluginPrivate
+)
diff --git a/tests/auto/unit/multimedia/qmediacapture_gstreamer/tst_qmediacapture_gstreamer.cpp b/tests/auto/unit/multimedia/qmediacapture_gstreamer/tst_qmediacapture_gstreamer.cpp
new file mode 100644
index 000000000..7fe6a06ac
--- /dev/null
+++ b/tests/auto/unit/multimedia/qmediacapture_gstreamer/tst_qmediacapture_gstreamer.cpp
@@ -0,0 +1,212 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QtTest/QtTest>
+#include <QtMultimedia/QAudioDevice>
+#include <QtMultimedia/QAudioInput>
+#include <QtMultimedia/QAudioOutput>
+#include <QtMultimedia/QCamera>
+#include <QtMultimedia/QMediaCaptureSession>
+#include <QtMultimedia/private/qgstreamer_platformspecificinterface_p.h>
+#include <QtMultimedia/private/qplatformmediacapture_p.h>
+#include <QtQGstreamerMediaPlugin/private/qgstpipeline_p.h>
+
+#include <qscopedenvironmentvariable.h>
+
+#include <memory>
+
+// NOLINTBEGIN(readability-convert-member-functions-to-static)
+
+QT_USE_NAMESPACE
+
+using namespace Qt::Literals;
+
+class tst_QMediaCaptureGStreamer : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QMediaCaptureGStreamer();
+
+public slots:
+ void init();
+ void cleanup();
+
+private slots:
+ void mediaIntegration_hasPlatformSpecificInterface();
+ void constructor_preparesGstPipeline();
+ void audioInput_makeCustomGStreamerAudioInput_fromPipelineDescription();
+ void audioOutput_makeCustomGStreamerAudioOutput_fromPipelineDescription();
+
+ void makeCustomGStreamerCamera_fromPipelineDescription();
+ void makeCustomGStreamerCamera_fromPipelineDescription_multipleItems();
+ void makeCustomGStreamerCamera_fromPipelineDescription_userProvidedGstElement();
+
+private:
+ std::unique_ptr<QMediaCaptureSession> session;
+
+ QGStreamerPlatformSpecificInterface *gstInterface()
+ {
+ return QGStreamerPlatformSpecificInterface::instance();
+ }
+
+ GstPipeline *getGstPipeline()
+ {
+ auto *iface = QGStreamerPlatformSpecificInterface::instance();
+ return iface ? iface->gstPipeline(session.get()) : nullptr;
+ }
+
+ QGstPipeline getPipeline()
+ {
+ return QGstPipeline{
+ getGstPipeline(),
+ QGstPipeline::NeedsRef,
+ };
+ }
+
+ void dumpGraph(const char *fileNamePrefix)
+ {
+ GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(getGstPipeline()),
+ GstDebugGraphDetails(GST_DEBUG_GRAPH_SHOW_VERBOSE),
+ fileNamePrefix);
+ }
+};
+
+tst_QMediaCaptureGStreamer::tst_QMediaCaptureGStreamer()
+{
+ qputenv("QT_MEDIA_BACKEND", "gstreamer");
+}
+
+void tst_QMediaCaptureGStreamer::init()
+{
+ session = std::make_unique<QMediaCaptureSession>();
+}
+
+void tst_QMediaCaptureGStreamer::cleanup()
+{
+ session.reset();
+}
+
+void tst_QMediaCaptureGStreamer::mediaIntegration_hasPlatformSpecificInterface()
+{
+ QVERIFY(QGStreamerPlatformSpecificInterface::instance());
+}
+
+void tst_QMediaCaptureGStreamer::constructor_preparesGstPipeline()
+{
+ auto *rawPipeline = getGstPipeline();
+ QVERIFY(rawPipeline);
+
+ QGstPipeline pipeline{
+ rawPipeline,
+ QGstPipeline::NeedsRef,
+ };
+ QVERIFY(pipeline);
+
+ dumpGraph("constructor_preparesGstPipeline");
+}
+
+void tst_QMediaCaptureGStreamer::audioInput_makeCustomGStreamerAudioInput_fromPipelineDescription()
+{
+ auto pipelineString =
+ "audiotestsrc wave=2 freq=200 name=myOscillator ! identity name=myConverter"_ba;
+
+ QAudioInput input{
+ gstInterface()->makeCustomGStreamerAudioInput(pipelineString),
+ };
+
+ session->setAudioInput(&input);
+
+ QGstPipeline pipeline = getPipeline();
+ QTEST_ASSERT(pipeline);
+
+ pipeline.finishStateChange();
+
+ QVERIFY(pipeline.findByName("myOscillator"));
+ QVERIFY(pipeline.findByName("myConverter"));
+
+ dumpGraph("audioInput_customAudioDevice");
+}
+
+void tst_QMediaCaptureGStreamer::
+ audioOutput_makeCustomGStreamerAudioOutput_fromPipelineDescription()
+{
+ auto pipelineStringInput =
+ "audiotestsrc wave=2 freq=200 name=myOscillator ! identity name=myConverter"_ba;
+ QAudioInput input{
+ gstInterface()->makeCustomGStreamerAudioInput(pipelineStringInput),
+ };
+ session->setAudioInput(&input);
+
+ auto pipelineStringOutput = "identity name=myConverter ! fakesink name=mySink"_ba;
+ QAudioOutput output{
+ gstInterface()->makeCustomGStreamerAudioOutput(pipelineStringOutput),
+ };
+ session->setAudioOutput(&output);
+
+ QGstPipeline pipeline = getPipeline();
+ QTEST_ASSERT(pipeline);
+
+ pipeline.finishStateChange();
+
+ QVERIFY(pipeline.findByName("mySink"));
+ QVERIFY(pipeline.findByName("myConverter"));
+
+ dumpGraph("audioOutput_customAudioDevice");
+}
+
+void tst_QMediaCaptureGStreamer::makeCustomGStreamerCamera_fromPipelineDescription()
+{
+ auto pipelineString = "videotestsrc name=mySrc"_ba;
+ QCamera *cam =
+ gstInterface()->makeCustomGStreamerCamera(pipelineString, /*parent=*/session.get());
+
+ session->setCamera(cam);
+ cam->start();
+
+ QGstPipeline pipeline = getPipeline();
+ QTEST_ASSERT(pipeline);
+ QVERIFY(pipeline.findByName("mySrc"));
+ dumpGraph("makeCustomGStreamerCamera_fromPipelineDescription");
+}
+
+void tst_QMediaCaptureGStreamer::makeCustomGStreamerCamera_fromPipelineDescription_multipleItems()
+{
+ auto pipelineString = "videotestsrc name=mySrc ! gamma gamma=2.0 name=myFilter"_ba;
+ QCamera *cam =
+ gstInterface()->makeCustomGStreamerCamera(pipelineString, /*parent=*/session.get());
+
+ session->setCamera(cam);
+ cam->start();
+
+ QGstPipeline pipeline = getPipeline();
+ QTEST_ASSERT(pipeline);
+ QVERIFY(pipeline.findByName("mySrc"));
+ QVERIFY(pipeline.findByName("myFilter"));
+ dumpGraph("makeCustomGStreamerCamera_fromPipelineDescription_multipleItems");
+}
+
+void tst_QMediaCaptureGStreamer::
+ makeCustomGStreamerCamera_fromPipelineDescription_userProvidedGstElement()
+{
+ QGstElement element = QGstElement::createFromPipelineDescription("videotestsrc");
+ gst_element_set_name(element.element(), "mySrc");
+
+ QCamera *cam =
+ gstInterface()->makeCustomGStreamerCamera(element.element(), /*parent=*/session.get());
+
+ session->setCamera(cam);
+ cam->start();
+
+ QGstPipeline pipeline = getPipeline();
+ QTEST_ASSERT(pipeline);
+ QCOMPARE(pipeline.findByName("mySrc"), element);
+ dumpGraph("makeCustomGStreamerCamera_fromPipelineDescription_userProvidedGstElement");
+
+ element.set("foreground-color", 0xff0000);
+ dumpGraph("makeCustomGStreamerCamera_fromPipelineDescription_userProvidedGstElement2");
+}
+
+QTEST_GUILESS_MAIN(tst_QMediaCaptureGStreamer)
+
+#include "tst_qmediacapture_gstreamer.moc"
diff --git a/tests/auto/unit/multimedia/qmediadevices/CMakeLists.txt b/tests/auto/unit/multimedia/qmediadevices/CMakeLists.txt
new file mode 100644
index 000000000..e8360f8b5
--- /dev/null
+++ b/tests/auto/unit/multimedia/qmediadevices/CMakeLists.txt
@@ -0,0 +1,13 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+qt_internal_add_test(tst_qmediadevices
+ SOURCES
+ tst_qmediadevices.cpp
+ INCLUDE_DIRECTORIES
+ ../../mockbackend
+ LIBRARIES
+ Qt::Gui
+ Qt::MultimediaPrivate
+ MockMultimediaPlugin
+)
diff --git a/tests/auto/unit/multimedia/qmediadevices/tst_qmediadevices.cpp b/tests/auto/unit/multimedia/qmediadevices/tst_qmediadevices.cpp
new file mode 100644
index 000000000..9767c0e73
--- /dev/null
+++ b/tests/auto/unit/multimedia/qmediadevices/tst_qmediadevices.cpp
@@ -0,0 +1,58 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QtTest/QtTest>
+#include <QDebug>
+
+#include <qmediadevices.h>
+
+#include "qmockintegration.h"
+
+QT_USE_NAMESPACE
+
+Q_ENABLE_MOCK_MULTIMEDIA_PLUGIN
+
+class tst_QMediaDevices : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void videoInputsChangedEmitted_whenCamerasChanged();
+ void onlyVideoInputsChangedEmitted_when2MediaDevicesCreated_andCamerasChanged();
+};
+
+void tst_QMediaDevices::videoInputsChangedEmitted_whenCamerasChanged()
+{
+ QMediaDevices mediaDevices;
+ QSignalSpy videoInputsSpy(&mediaDevices, &QMediaDevices::videoInputsChanged);
+
+ QCOMPARE(videoInputsSpy.size(), 0);
+
+ QMockIntegration::instance()->addNewCamera();
+ QTRY_COMPARE(videoInputsSpy.size(), 1);
+
+ QMockIntegration::instance()->addNewCamera();
+ QCOMPARE(videoInputsSpy.size(), 2);
+}
+
+void tst_QMediaDevices::onlyVideoInputsChangedEmitted_when2MediaDevicesCreated_andCamerasChanged()
+{
+ QMediaDevices mediaDevicesA;
+ QMediaDevices mediaDevicesB;
+
+ QSignalSpy videoInputsSpyA(&mediaDevicesA, &QMediaDevices::videoInputsChanged);
+ QSignalSpy videoInputsSpyB(&mediaDevicesB, &QMediaDevices::videoInputsChanged);
+ QSignalSpy audioInputsSpy(&mediaDevicesA, &QMediaDevices::audioInputsChanged);
+ QSignalSpy audioOutputsSpy(&mediaDevicesA, &QMediaDevices::audioOutputsChanged);
+
+ QMockIntegration::instance()->addNewCamera();
+ QCOMPARE(videoInputsSpyA.size(), 1);
+ QCOMPARE(videoInputsSpyB.size(), 1);
+
+ QCOMPARE(audioInputsSpy.size(), 0);
+ QCOMPARE(audioOutputsSpy.size(), 0);
+}
+
+QTEST_MAIN(tst_QMediaDevices)
+
+#include "tst_qmediadevices.moc"
diff --git a/tests/auto/unit/multimedia/qmediaformat/CMakeLists.txt b/tests/auto/unit/multimedia/qmediaformat/CMakeLists.txt
new file mode 100644
index 000000000..4ad36e7bb
--- /dev/null
+++ b/tests/auto/unit/multimedia/qmediaformat/CMakeLists.txt
@@ -0,0 +1,10 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+qt_internal_add_test(tst_qmediaformat
+ SOURCES
+ tst_qmediaformat.cpp
+ LIBRARIES
+ Qt::Gui
+ Qt::MultimediaPrivate
+)
diff --git a/tests/auto/unit/multimedia/qmediaformat/tst_qmediaformat.cpp b/tests/auto/unit/multimedia/qmediaformat/tst_qmediaformat.cpp
new file mode 100644
index 000000000..9f1345db6
--- /dev/null
+++ b/tests/auto/unit/multimedia/qmediaformat/tst_qmediaformat.cpp
@@ -0,0 +1,65 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QtTest/QtTest>
+#include <QDebug>
+#include <QtMultimedia/qmediaformat.h>
+
+class tst_QMediaFormat : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void testResolveForEncoding();
+};
+
+void tst_QMediaFormat::testResolveForEncoding()
+{
+ QMediaFormat format;
+
+ auto hasVideoCodecs = !format.supportedVideoCodecs(QMediaFormat::Encode).isEmpty();
+ bool hasWav = format.supportedFileFormats(QMediaFormat::Encode).contains(QMediaFormat::Wave);
+
+ // Resolve codecs for audio only stream
+ format.resolveForEncoding(QMediaFormat::NoFlags);
+ QVERIFY(format.audioCodec() != QMediaFormat::AudioCodec::Unspecified);
+ QVERIFY(format.fileFormat() != QMediaFormat::FileFormat::UnspecifiedFormat);
+ QVERIFY(format.videoCodec() == QMediaFormat::VideoCodec::Unspecified);
+
+ // Resolve codecs for audio/video stream
+ format.resolveForEncoding(QMediaFormat::RequiresVideo);
+ QVERIFY(format.audioCodec() != QMediaFormat::AudioCodec::Unspecified);
+ QVERIFY(format.fileFormat() != QMediaFormat::FileFormat::UnspecifiedFormat);
+ if (hasVideoCodecs)
+ QVERIFY(format.videoCodec() != QMediaFormat::VideoCodec::Unspecified);
+ else
+ QVERIFY(format.videoCodec() == QMediaFormat::VideoCodec::Unspecified);
+
+ // Resolve again for audio only stream
+ format.resolveForEncoding(QMediaFormat::NoFlags);
+ QVERIFY(format.videoCodec() == QMediaFormat::VideoCodec::Unspecified);
+
+ // check some specific conditions
+ if (hasWav) {
+ QMediaFormat f(QMediaFormat::Mpeg4Audio);
+ if (!f.supportedAudioCodecs(QMediaFormat::Encode).contains(QMediaFormat::AudioCodec::Wave)) {
+ qDebug() << "testing!";
+ format.setFileFormat(QMediaFormat::Mpeg4Audio);
+ format.setAudioCodec(QMediaFormat::AudioCodec::Wave);
+ format.resolveForEncoding(QMediaFormat::NoFlags);
+ QVERIFY(format.fileFormat() == QMediaFormat::Mpeg4Audio);
+ QVERIFY(format.audioCodec() != QMediaFormat::AudioCodec::Wave);
+
+ format = {};
+ format.setFileFormat(QMediaFormat::Wave);
+ format.setAudioCodec(QMediaFormat::AudioCodec::AAC);
+ format.resolveForEncoding(QMediaFormat::NoFlags);
+ QVERIFY(format.fileFormat() == QMediaFormat::Wave);
+ QVERIFY(format.audioCodec() == QMediaFormat::AudioCodec::Wave);
+ }
+ }
+
+}
+
+QTEST_MAIN(tst_QMediaFormat)
+#include "tst_qmediaformat.moc"
diff --git a/tests/auto/unit/multimedia/qmediaplayer/CMakeLists.txt b/tests/auto/unit/multimedia/qmediaplayer/CMakeLists.txt
new file mode 100644
index 000000000..4d3f2f865
--- /dev/null
+++ b/tests/auto/unit/multimedia/qmediaplayer/CMakeLists.txt
@@ -0,0 +1,34 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+# Generated from qmediaplayer.pro.
+
+#####################################################################
+## tst_qmediaplayer Test:
+#####################################################################
+
+qt_internal_add_test(tst_qmediaplayer
+ SOURCES
+ tst_qmediaplayer.cpp
+ INCLUDE_DIRECTORIES
+ ../../mockbackend
+ LIBRARIES
+ # Remove: L${CMAKE_CURRENT_SOURCE_DIR}
+ Qt::Gui
+ Qt::MultimediaPrivate
+ Qt::Network
+ MockMultimediaPlugin
+)
+
+# Resources:
+set(testdata_resource_files
+ "testdata/nokia-tune.mp3"
+)
+
+qt_internal_add_resource(tst_qmediaplayer "testdata"
+ PREFIX
+ "/"
+ FILES
+ ${testdata_resource_files}
+)
+
diff --git a/tests/auto/unit/qmediaplayer/testdata/nokia-tune.mp3 b/tests/auto/unit/multimedia/qmediaplayer/testdata/nokia-tune.mp3
index 2435f65b8..2435f65b8 100644
--- a/tests/auto/unit/qmediaplayer/testdata/nokia-tune.mp3
+++ b/tests/auto/unit/multimedia/qmediaplayer/testdata/nokia-tune.mp3
Binary files differ
diff --git a/tests/auto/unit/multimedia/qmediaplayer/tst_qmediaplayer.cpp b/tests/auto/unit/multimedia/qmediaplayer/tst_qmediaplayer.cpp
new file mode 100644
index 000000000..3fb77ca2d
--- /dev/null
+++ b/tests/auto/unit/multimedia/qmediaplayer/tst_qmediaplayer.cpp
@@ -0,0 +1,832 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QtTest/QtTest>
+
+#include <QtCore/qdebug.h>
+#include <QtCore/qbuffer.h>
+
+#include <qvideosink.h>
+#include <qmediaplayer.h>
+#include <private/qplatformmediaplayer_p.h>
+#include <qobject.h>
+
+#include "qmockintegration.h"
+#include "qmockmediaplayer.h"
+#include "qmockaudiooutput.h"
+#include "qvideosink.h"
+#include "qaudiooutput.h"
+
+QT_USE_NAMESPACE
+
+Q_ENABLE_MOCK_MULTIMEDIA_PLUGIN
+
+class AutoConnection
+{
+public:
+ AutoConnection(QObject *sender, const char *signal, QObject *receiver, const char *method)
+ : sender(sender), signal(signal), receiver(receiver), method(method)
+ {
+ QObject::connect(sender, signal, receiver, method);
+ }
+
+ ~AutoConnection()
+ {
+ QObject::disconnect(sender, signal, receiver, method);
+ }
+
+private:
+ QObject *sender;
+ const char *signal;
+ QObject *receiver;
+ const char *method;
+};
+
+class tst_QMediaPlayer: public QObject
+{
+ Q_OBJECT
+
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+private slots:
+ void testValid();
+ void testMedia_data();
+ void testMedia();
+ void testMultipleMedia_data();
+ void testMultipleMedia();
+ void testDuration_data();
+ void testDuration();
+ void testPosition_data();
+ void testPosition();
+ void testVolume_data();
+ void testVolume();
+ void testMuted_data();
+ void testMuted();
+ void testIsAvailable();
+ void testVideoAvailable_data();
+ void testVideoAvailable();
+ void testBufferStatus_data();
+ void testBufferStatus();
+ void testSeekable_data();
+ void testSeekable();
+ void testPlaybackRate_data();
+ void testPlaybackRate();
+ void testError_data();
+ void testError();
+ void testErrorString_data();
+ void testErrorString();
+ void testService();
+ void testPlay_data();
+ void testPlay();
+ void testPause_data();
+ void testPause();
+ void testStop_data();
+ void testStop();
+ void testMediaStatus_data();
+ void testMediaStatus();
+ void testSetVideoOutput();
+ void testSetVideoOutputDestruction();
+ void debugEnums();
+ void testDestructor();
+ void testQrc_data();
+ void testQrc();
+
+private:
+ void setupCommonTestData();
+
+ QMockMediaPlayer *mockPlayer;
+ QAudioOutput *audioOutput = nullptr;
+ QMediaPlayer *player;
+};
+
+class QtTestMediaPlayer : public QMediaPlayer
+{
+ Q_OBJECT
+ Q_PROPERTY(int a READ a WRITE setA NOTIFY aChanged)
+ Q_PROPERTY(int b READ b WRITE setB NOTIFY bChanged)
+ Q_PROPERTY(int c READ c WRITE setC NOTIFY cChanged)
+ Q_PROPERTY(int d READ d WRITE setD)
+public:
+ QtTestMediaPlayer() : QMediaPlayer() {}
+
+ [[nodiscard]] int a() const { return m_a; }
+ void setA(int a) { m_a = a; }
+
+ [[nodiscard]] int b() const { return m_b; }
+ void setB(int b) { m_b = b; }
+
+ [[nodiscard]] int c() const { return m_c; }
+ void setC(int c) { m_c = c; }
+
+ [[nodiscard]] int d() const { return m_d; }
+ void setD(int d) { m_d = d; }
+
+Q_SIGNALS:
+ void aChanged(int a);
+ void bChanged(int b);
+ void cChanged(int c);
+
+private:
+ int m_a = 0;
+ int m_b = 0;
+ int m_c = 0;
+ int m_d = 0;
+};
+
+void tst_QMediaPlayer::setupCommonTestData()
+{
+ QTest::addColumn<bool>("valid");
+ QTest::addColumn<QMediaPlayer::PlaybackState>("state");
+ QTest::addColumn<QMediaPlayer::MediaStatus>("status");
+ QTest::addColumn<QUrl>("mediaContent");
+ QTest::addColumn<qint64>("duration");
+ QTest::addColumn<qint64>("position");
+ QTest::addColumn<bool>("seekable");
+ QTest::addColumn<int>("volume");
+ QTest::addColumn<bool>("muted");
+ QTest::addColumn<bool>("videoAvailable");
+ QTest::addColumn<int>("bufferProgress");
+ QTest::addColumn<qreal>("playbackRate");
+ QTest::addColumn<QMediaPlayer::Error>("error");
+ QTest::addColumn<QString>("errorString");
+
+ QTest::newRow("invalid") << false << QMediaPlayer::StoppedState << QMediaPlayer::InvalidMedia <<
+ QUrl() << qint64(0) << qint64(0) << false << 0 << false << false << 0 <<
+ qreal(0) << QMediaPlayer::NoError << QString();
+ QTest::newRow("valid+null") << true << QMediaPlayer::StoppedState << QMediaPlayer::InvalidMedia <<
+ QUrl() << qint64(0) << qint64(0) << false << 0 << false << false << 50 <<
+ qreal(0) << QMediaPlayer::NoError << QString();
+ QTest::newRow("valid+content+stopped") << true << QMediaPlayer::StoppedState << QMediaPlayer::InvalidMedia <<
+ QUrl(QUrl("file:///some.mp3")) << qint64(0) << qint64(0) << false << 50 << false << false << 0 <<
+ qreal(1) << QMediaPlayer::NoError << QString();
+ QTest::newRow("valid+content+playing") << true << QMediaPlayer::PlayingState << QMediaPlayer::LoadedMedia <<
+ QUrl(QUrl("file:///some.mp3")) << qint64(10000) << qint64(10) << true << 50 << true << false << 0 <<
+ qreal(1) << QMediaPlayer::NoError << QString();
+ QTest::newRow("valid+content+paused") << true << QMediaPlayer::PausedState << QMediaPlayer::LoadedMedia <<
+ QUrl(QUrl("file:///some.mp3")) << qint64(10000) << qint64(10) << true << 50 << true << false << 0 <<
+ qreal(1) << QMediaPlayer::NoError << QString();
+ QTest::newRow("valud+streaming") << true << QMediaPlayer::PlayingState << QMediaPlayer::LoadedMedia <<
+ QUrl(QUrl("http://example.com/stream")) << qint64(10000) << qint64(10000) << false << 50 << false << true << 0 <<
+ qreal(1) << QMediaPlayer::NoError << QString();
+ QTest::newRow("valid+error") << true << QMediaPlayer::StoppedState << QMediaPlayer::InvalidMedia <<
+ QUrl(QUrl("http://example.com/stream")) << qint64(0) << qint64(0) << false << 50 << false << false << 0 <<
+ qreal(0) << QMediaPlayer::ResourceError << QStringLiteral("Resource unavailable");
+}
+
+void tst_QMediaPlayer::initTestCase()
+{
+}
+
+void tst_QMediaPlayer::cleanupTestCase()
+{
+}
+
+void tst_QMediaPlayer::init()
+{
+ player = new QMediaPlayer;
+ mockPlayer = QMockIntegration::instance()->lastPlayer();
+ Q_ASSERT(mockPlayer);
+ audioOutput = new QAudioOutput;
+ player->setAudioOutput(audioOutput);
+ Q_ASSERT(mockPlayer->m_audioOutput != nullptr);
+}
+
+void tst_QMediaPlayer::cleanup()
+{
+ delete player;
+}
+
+void tst_QMediaPlayer::testValid()
+{
+ /*
+ QFETCH(bool, valid);
+
+ mockService->setIsValid(valid);
+ QCOMPARE(player->isValid(), valid);
+ */
+}
+
+void tst_QMediaPlayer::testMedia_data()
+{
+ setupCommonTestData();
+}
+
+void tst_QMediaPlayer::testMedia()
+{
+ QFETCH(QUrl, mediaContent);
+
+ player->setSource(mediaContent);
+ QCOMPARE(player->source(), mediaContent);
+
+ QBuffer stream;
+ player->setSourceDevice(&stream, mediaContent);
+ QCOMPARE(player->source(), mediaContent);
+ QCOMPARE(player->sourceDevice(), &stream);
+}
+
+void tst_QMediaPlayer::testMultipleMedia_data()
+{
+ QTest::addColumn<QUrl>("mediaContent");
+ QTest::addColumn<QUrl>("anotherMediaContent");
+
+ QTest::newRow("multipleSources")
+ << QUrl(QUrl("file:///some.mp3")) << QUrl(QUrl("file:///someother.mp3"));
+}
+
+void tst_QMediaPlayer::testMultipleMedia()
+{
+ QFETCH(QUrl, mediaContent);
+
+ player->setSource(mediaContent);
+ QCOMPARE(player->source(), mediaContent);
+
+ QBuffer stream;
+ player->setSourceDevice(&stream, mediaContent);
+ QCOMPARE(player->source(), mediaContent);
+ QCOMPARE(player->sourceDevice(), &stream);
+
+ QFETCH(QUrl, anotherMediaContent);
+
+ player->setSource(anotherMediaContent);
+ QCOMPARE(player->source(), anotherMediaContent);
+
+ QBuffer anotherStream;
+ player->setSourceDevice(&anotherStream, anotherMediaContent);
+ QCOMPARE(player->source(), anotherMediaContent);
+ QCOMPARE(player->sourceDevice(), &anotherStream);
+}
+
+void tst_QMediaPlayer::testDuration_data()
+{
+ setupCommonTestData();
+}
+
+void tst_QMediaPlayer::testDuration()
+{
+ QFETCH(qint64, duration);
+
+ mockPlayer->setDuration(duration);
+ QVERIFY(player->duration() == duration);
+}
+
+void tst_QMediaPlayer::testPosition_data()
+{
+ setupCommonTestData();
+}
+
+void tst_QMediaPlayer::testPosition()
+{
+ QFETCH(bool, valid);
+ QFETCH(bool, seekable);
+ QFETCH(qint64, position);
+ QFETCH(qint64, duration);
+
+ mockPlayer->setIsValid(valid);
+ mockPlayer->setSeekable(seekable);
+ mockPlayer->setPosition(position);
+ mockPlayer->setDuration(duration);
+ QVERIFY(player->isSeekable() == seekable);
+ QVERIFY(player->position() == position);
+ QVERIFY(player->duration() == duration);
+
+ if (seekable) {
+ {
+ QSignalSpy spy(player, &QMediaPlayer::positionChanged);
+ player->setPosition(position);
+ QCOMPARE(player->position(), position);
+ QCOMPARE(spy.size(), 0);
+ }
+
+ mockPlayer->setPosition(position);
+ {
+ QSignalSpy spy(player, &QMediaPlayer::positionChanged);
+ player->setPosition(0);
+ QCOMPARE(player->position(), qint64(0));
+ QCOMPARE(spy.size(), position == 0 ? 0 : 1);
+ }
+
+ mockPlayer->setPosition(position);
+ {
+ QSignalSpy spy(player, &QMediaPlayer::positionChanged);
+ player->setPosition(duration);
+ QCOMPARE(player->position(), duration);
+ QCOMPARE(spy.size(), position == duration ? 0 : 1);
+ }
+
+ mockPlayer->setPosition(position);
+ {
+ QSignalSpy spy(player, &QMediaPlayer::positionChanged);
+ player->setPosition(-1);
+ QCOMPARE(player->position(), qint64(0));
+ QCOMPARE(spy.size(), position == 0 ? 0 : 1);
+ }
+
+ }
+ else {
+ QSignalSpy spy(player, &QMediaPlayer::positionChanged);
+ player->setPosition(position);
+
+ QCOMPARE(player->position(), position);
+ QCOMPARE(spy.size(), 0);
+ }
+}
+
+void tst_QMediaPlayer::testVolume_data()
+{
+ setupCommonTestData();
+}
+
+void tst_QMediaPlayer::testVolume()
+{
+ QFETCH(bool, valid);
+ QFETCH(int, volume);
+ float vol = volume/100.;
+
+ audioOutput->setVolume(vol);
+ QVERIFY(audioOutput->volume() == vol);
+
+ if (valid) {
+ {
+ QSignalSpy spy(audioOutput, &QAudioOutput::volumeChanged);
+ audioOutput->setVolume(.1f);
+ QCOMPARE(audioOutput->volume(), .1f);
+ QCOMPARE(spy.size(), 1);
+ }
+
+ {
+ QSignalSpy spy(audioOutput, &QAudioOutput::volumeChanged);
+ audioOutput->setVolume(-1000.f);
+ QCOMPARE(audioOutput->volume(), 0.f);
+ QCOMPARE(spy.size(), 1);
+ }
+
+ {
+ QSignalSpy spy(audioOutput, &QAudioOutput::volumeChanged);
+ audioOutput->setVolume(1.f);
+ QCOMPARE(audioOutput->volume(), 1.f);
+ QCOMPARE(spy.size(), 1);
+ }
+
+ {
+ QSignalSpy spy(audioOutput, &QAudioOutput::volumeChanged);
+ audioOutput->setVolume(1000.f);
+ QCOMPARE(audioOutput->volume(), 1.f);
+ QCOMPARE(spy.size(), 0);
+ }
+ }
+}
+
+void tst_QMediaPlayer::testMuted_data()
+{
+ setupCommonTestData();
+}
+
+void tst_QMediaPlayer::testMuted()
+{
+ QFETCH(bool, valid);
+ QFETCH(bool, muted);
+ QFETCH(int, volume);
+ float vol = volume/100.;
+
+ if (valid) {
+ audioOutput->setMuted(muted);
+ audioOutput->setVolume(vol);
+ QVERIFY(audioOutput->isMuted() == muted);
+
+ QSignalSpy spy(audioOutput, &QAudioOutput::mutedChanged);
+ audioOutput->setMuted(!muted);
+ QCOMPARE(audioOutput->isMuted(), !muted);
+ QCOMPARE(audioOutput->volume(), vol);
+ QCOMPARE(spy.size(), 1);
+ }
+}
+
+void tst_QMediaPlayer::testVideoAvailable_data()
+{
+ setupCommonTestData();
+}
+
+void tst_QMediaPlayer::testVideoAvailable()
+{
+ QFETCH(bool, videoAvailable);
+
+ mockPlayer->setVideoAvailable(videoAvailable);
+ QVERIFY(player->hasVideo() == videoAvailable);
+}
+
+void tst_QMediaPlayer::testBufferStatus_data()
+{
+ setupCommonTestData();
+}
+
+void tst_QMediaPlayer::testBufferStatus()
+{
+ QFETCH(int, bufferProgress);
+
+ mockPlayer->setBufferStatus(bufferProgress);
+ QVERIFY(player->bufferProgress() == bufferProgress);
+}
+
+void tst_QMediaPlayer::testSeekable_data()
+{
+ setupCommonTestData();
+}
+
+void tst_QMediaPlayer::testSeekable()
+{
+ QFETCH(bool, seekable);
+
+ mockPlayer->setSeekable(seekable);
+ QVERIFY(player->isSeekable() == seekable);
+}
+
+void tst_QMediaPlayer::testPlaybackRate_data()
+{
+ setupCommonTestData();
+}
+
+void tst_QMediaPlayer::testPlaybackRate()
+{
+ QFETCH(bool, valid);
+ QFETCH(qreal, playbackRate);
+
+ if (valid) {
+ mockPlayer->setPlaybackRate(playbackRate);
+ QVERIFY(player->playbackRate() == playbackRate);
+
+ QSignalSpy spy(player, &QMediaPlayer::playbackRateChanged);
+ player->setPlaybackRate(playbackRate + 0.5f);
+ QCOMPARE(player->playbackRate(), playbackRate + 0.5f);
+ QCOMPARE(spy.size(), 1);
+ }
+}
+
+void tst_QMediaPlayer::testError_data()
+{
+ setupCommonTestData();
+}
+
+void tst_QMediaPlayer::testError()
+{
+ QFETCH(QMediaPlayer::Error, error);
+
+ mockPlayer->setError(error);
+ QVERIFY(player->error() == error);
+}
+
+void tst_QMediaPlayer::testErrorString_data()
+{
+ setupCommonTestData();
+}
+
+void tst_QMediaPlayer::testErrorString()
+{
+ QFETCH(QString, errorString);
+
+ mockPlayer->setErrorString(errorString);
+ QVERIFY(player->errorString() == errorString);
+}
+
+void tst_QMediaPlayer::testIsAvailable()
+{
+ QCOMPARE(player->isAvailable(), true);
+}
+
+void tst_QMediaPlayer::testService()
+{
+ /*
+ QFETCH(bool, valid);
+
+ mockService->setIsValid(valid);
+
+ if (valid)
+ QVERIFY(player->service() != 0);
+ else
+ QVERIFY(player->service() == 0);
+ */
+}
+
+void tst_QMediaPlayer::testPlay_data()
+{
+ setupCommonTestData();
+}
+
+void tst_QMediaPlayer::testPlay()
+{
+ QFETCH(bool, valid);
+ QFETCH(QUrl, mediaContent);
+ QFETCH(QMediaPlayer::PlaybackState, state);
+
+ mockPlayer->setIsValid(valid);
+ player->setSource(mediaContent);
+ mockPlayer->setState(state);
+ QCOMPARE(player->playbackState(), state);
+ QCOMPARE(player->isPlaying(), state == QMediaPlayer::PlayingState);
+ QCOMPARE(player->source(), mediaContent);
+
+ QSignalSpy spy(player, &QMediaPlayer::playbackStateChanged);
+ QSignalSpy playingChanged(player, &QMediaPlayer::playingChanged);
+
+ player->play();
+
+ if (!valid || mediaContent.isEmpty()) {
+ QCOMPARE(player->playbackState(), QMediaPlayer::StoppedState);
+ QVERIFY(!player->isPlaying());
+ QCOMPARE(spy.size(), 0);
+ QVERIFY(playingChanged.empty());
+ }
+ else {
+ QCOMPARE(player->playbackState(), QMediaPlayer::PlayingState);
+ QVERIFY(player->isPlaying());
+ QCOMPARE(spy.size(), state == QMediaPlayer::PlayingState ? 0 : 1);
+ QCOMPARE_EQ(playingChanged.size(), state == QMediaPlayer::PlayingState ? 0 : 1);
+ }
+}
+
+void tst_QMediaPlayer::testPause_data()
+{
+ setupCommonTestData();
+}
+
+void tst_QMediaPlayer::testPause()
+{
+ QFETCH(bool, valid);
+ QFETCH(QUrl, mediaContent);
+ QFETCH(QMediaPlayer::PlaybackState, state);
+
+ mockPlayer->setIsValid(valid);
+ player->setSource(mediaContent);
+ mockPlayer->setState(state);
+ QVERIFY(player->playbackState() == state);
+ QCOMPARE(player->isPlaying(), state == QMediaPlayer::PlayingState);
+ QVERIFY(player->source() == mediaContent);
+
+ QSignalSpy spy(player, &QMediaPlayer::playbackStateChanged);
+ QSignalSpy playingChanged(player, &QMediaPlayer::playingChanged);
+
+ player->pause();
+
+ QVERIFY(!player->isPlaying());
+
+ if (!valid || mediaContent.isEmpty()) {
+ QCOMPARE(player->playbackState(), QMediaPlayer::StoppedState);
+ QCOMPARE(spy.size(), 0);
+ QCOMPARE(playingChanged.size(), 0);
+ }
+ else {
+ QCOMPARE(player->playbackState(), QMediaPlayer::PausedState);
+ QCOMPARE(spy.size(), state == QMediaPlayer::PausedState ? 0 : 1);
+ QCOMPARE(playingChanged.size(), state == QMediaPlayer::PlayingState ? 1 : 0);
+ }
+}
+
+void tst_QMediaPlayer::testStop_data()
+{
+ setupCommonTestData();
+}
+
+void tst_QMediaPlayer::testStop()
+{
+ QFETCH(QUrl, mediaContent);
+ QFETCH(QMediaPlayer::PlaybackState, state);
+
+ player->setSource(mediaContent);
+ mockPlayer->setState(state);
+ QVERIFY(player->playbackState() == state);
+ QCOMPARE(player->isPlaying(), state == QMediaPlayer::PlayingState);
+ QVERIFY(player->source() == mediaContent);
+
+ QSignalSpy spy(player, &QMediaPlayer::playbackStateChanged);
+ QSignalSpy playingChanged(player, &QMediaPlayer::playingChanged);
+
+ player->stop();
+
+ QVERIFY(!player->isPlaying());
+
+ if (mediaContent.isEmpty() || state == QMediaPlayer::StoppedState) {
+ QCOMPARE(player->playbackState(), QMediaPlayer::StoppedState);
+ QCOMPARE(spy.size(), 0);
+ QCOMPARE(playingChanged.size(), 0);
+ }
+ else {
+ QCOMPARE(player->playbackState(), QMediaPlayer::StoppedState);
+ QCOMPARE(spy.size(), 1);
+ QCOMPARE(playingChanged.size(), state == QMediaPlayer::PlayingState ? 1 : 0);
+ }
+}
+
+void tst_QMediaPlayer::testMediaStatus_data()
+{
+ setupCommonTestData();
+}
+
+void tst_QMediaPlayer::testMediaStatus()
+{
+ QFETCH(int, bufferProgress);
+ int bufferSignals = 0;
+
+ mockPlayer->setMediaStatus(QMediaPlayer::NoMedia);
+ mockPlayer->setBufferStatus(bufferProgress);
+
+ QSignalSpy statusSpy(player, &QMediaPlayer::mediaStatusChanged);
+ QSignalSpy bufferSpy(player, &QMediaPlayer::bufferProgressChanged);
+
+ QCOMPARE(player->mediaStatus(), QMediaPlayer::NoMedia);
+
+ mockPlayer->setMediaStatus(QMediaPlayer::LoadingMedia);
+ QCOMPARE(player->mediaStatus(), QMediaPlayer::LoadingMedia);
+ QCOMPARE(statusSpy.size(), 1);
+
+ QCOMPARE(qvariant_cast<QMediaPlayer::MediaStatus>(statusSpy.last().value(0)),
+ QMediaPlayer::LoadingMedia);
+
+ mockPlayer->setMediaStatus(QMediaPlayer::LoadedMedia);
+ QCOMPARE(player->mediaStatus(), QMediaPlayer::LoadedMedia);
+ QCOMPARE(statusSpy.size(), 2);
+
+ QCOMPARE(qvariant_cast<QMediaPlayer::MediaStatus>(statusSpy.last().value(0)),
+ QMediaPlayer::LoadedMedia);
+
+ // Verify the bufferProgressChanged() signal isn't being emitted.
+ QCOMPARE(bufferSpy.size(), 0);
+
+ mockPlayer->setMediaStatus(QMediaPlayer::StalledMedia);
+ QCOMPARE(player->mediaStatus(), QMediaPlayer::StalledMedia);
+ QCOMPARE(statusSpy.size(), 3);
+
+ QCOMPARE(qvariant_cast<QMediaPlayer::MediaStatus>(statusSpy.last().value(0)),
+ QMediaPlayer::StalledMedia);
+
+ // Verify the bufferProgressChanged() signal is being emitted.
+ QVERIFY(bufferSpy.size() > bufferSignals);
+ QCOMPARE(bufferSpy.last().value(0).toInt(), bufferProgress);
+ bufferSignals = bufferSpy.size();
+
+ mockPlayer->setMediaStatus(QMediaPlayer::BufferingMedia);
+ QCOMPARE(player->mediaStatus(), QMediaPlayer::BufferingMedia);
+ QCOMPARE(statusSpy.size(), 4);
+
+ QCOMPARE(qvariant_cast<QMediaPlayer::MediaStatus>(statusSpy.last().value(0)),
+ QMediaPlayer::BufferingMedia);
+
+ // Verify the bufferProgressChanged() signal is being emitted.
+ QVERIFY(bufferSpy.size() > bufferSignals);
+ QCOMPARE(bufferSpy.last().value(0).toInt(), bufferProgress);
+ bufferSignals = bufferSpy.size();
+
+ mockPlayer->setMediaStatus(QMediaPlayer::BufferedMedia);
+ QCOMPARE(player->mediaStatus(), QMediaPlayer::BufferedMedia);
+ QCOMPARE(statusSpy.size(), 5);
+
+ QCOMPARE(qvariant_cast<QMediaPlayer::MediaStatus>(statusSpy.last().value(0)),
+ QMediaPlayer::BufferedMedia);
+
+ // Verify the bufferProgressChanged() signal isn't being emitted.
+ QCOMPARE(bufferSpy.size(), bufferSignals);
+
+ mockPlayer->setMediaStatus(QMediaPlayer::EndOfMedia);
+ QCOMPARE(player->mediaStatus(), QMediaPlayer::EndOfMedia);
+ QCOMPARE(statusSpy.size(), 6);
+
+ QCOMPARE(qvariant_cast<QMediaPlayer::MediaStatus>(statusSpy.last().value(0)),
+ QMediaPlayer::EndOfMedia);
+}
+
+void tst_QMediaPlayer::testDestructor()
+{
+ /* create an object for player */
+ QMediaPlayer *victim = new QMediaPlayer;
+
+ /* check whether the object is created */
+ QVERIFY(victim);
+
+ /* delete the instance (a crash is a failure :) */
+ delete victim;
+}
+
+void tst_QMediaPlayer::testSetVideoOutput()
+{
+ QVideoSink surface;
+
+ player->setVideoOutput(static_cast<QObject *>(nullptr));
+
+// QCOMPARE(mockService->rendererRef, 0);
+
+ player->setVideoOutput(&surface);
+// QVERIFY(mockService->rendererControl->surface() == &surface);
+// QCOMPARE(mockService->rendererRef, 1);
+
+ player->setVideoOutput(reinterpret_cast<QVideoSink *>(0));
+// QVERIFY(mockService->rendererControl->surface() == nullptr);
+
+ //rendererControl is released
+// QCOMPARE(mockService->rendererRef, 0);
+
+ player->setVideoOutput(&surface);
+// QVERIFY(mockService->rendererControl->surface() == &surface);
+// QCOMPARE(mockService->rendererRef, 1);
+
+ player->setVideoOutput(static_cast<QObject *>(nullptr));
+// QVERIFY(mockService->rendererControl->surface() == nullptr);
+// //rendererControl is released
+// QCOMPARE(mockService->rendererRef, 0);
+
+ player->setVideoOutput(&surface);
+// QVERIFY(mockService->rendererControl->surface() == &surface);
+// QCOMPARE(mockService->rendererRef, 1);
+}
+
+void tst_QMediaPlayer::testSetVideoOutputDestruction()
+{
+ QVideoSink surface;
+ {
+ QMediaPlayer player;
+ player.setVideoOutput(&surface);
+ }
+}
+
+void tst_QMediaPlayer::debugEnums()
+{
+ QTest::ignoreMessage(QtDebugMsg, "QMediaPlayer::PlayingState");
+ qDebug() << QMediaPlayer::PlayingState;
+ QTest::ignoreMessage(QtDebugMsg, "QMediaPlayer::NoMedia");
+ qDebug() << QMediaPlayer::NoMedia;
+ QTest::ignoreMessage(QtDebugMsg, "QMediaPlayer::NetworkError");
+ qDebug() << QMediaPlayer::NetworkError;
+}
+
+void tst_QMediaPlayer::testQrc_data()
+{
+ QTest::addColumn<QUrl>("mediaContent");
+ QTest::addColumn<QMediaPlayer::MediaStatus>("status");
+ QTest::addColumn<QMediaPlayer::Error>("error");
+ QTest::addColumn<int>("errorCount");
+ QTest::addColumn<QString>("backendMediaContentScheme");
+ QTest::addColumn<bool>("backendHasStream");
+
+ QTest::newRow("invalid") << QUrl(QUrl(QLatin1String("qrc:/invalid.mp3")))
+ << QMediaPlayer::InvalidMedia
+ << QMediaPlayer::ResourceError
+ << 1 // error count
+ << QString() // backend should not have got any media (empty URL scheme)
+ << false; // backend should not have got any stream
+
+ QTest::newRow("valid+nostream") << QUrl(QUrl(QLatin1String("qrc:/testdata/nokia-tune.mp3")))
+ << QMediaPlayer::LoadingMedia
+ << QMediaPlayer::NoError
+ << 0 // error count
+ << QStringLiteral("file") // backend should have a got a temporary file
+ << false; // backend should not have got any stream
+
+ QTest::newRow("valid+stream") << QUrl(QUrl(QLatin1String("qrc:/testdata/nokia-tune.mp3")))
+ << QMediaPlayer::LoadingMedia
+ << QMediaPlayer::NoError
+ << 0 // error count
+ << QStringLiteral("qrc")
+ << true; // backend should have got a stream (QFile opened from the resource)
+}
+
+void tst_QMediaPlayer::testQrc()
+{
+ QFETCH(QUrl, mediaContent);
+ QFETCH(QMediaPlayer::MediaStatus, status);
+ QFETCH(QMediaPlayer::Error, error);
+ QFETCH(int, errorCount);
+ QFETCH(QString, backendMediaContentScheme);
+ QFETCH(bool, backendHasStream);
+
+ mockPlayer->setState(QMediaPlayer::PlayingState, QMediaPlayer::NoMedia);
+ mockPlayer->setStreamPlaybackSupported(backendHasStream);
+
+ QSignalSpy mediaSpy(player, &QMediaPlayer::sourceChanged);
+ QSignalSpy statusSpy(player, &QMediaPlayer::mediaStatusChanged);
+ QSignalSpy errorSpy(player, &QMediaPlayer::errorOccurred);
+
+ player->setSource(mediaContent);
+
+ QTRY_COMPARE(player->mediaStatus(), status);
+ QCOMPARE(statusSpy.size(), 1);
+ QCOMPARE(qvariant_cast<QMediaPlayer::MediaStatus>(statusSpy.last().value(0)), status);
+
+ QCOMPARE(player->source(), mediaContent);
+ QCOMPARE(mediaSpy.size(), 1);
+ QCOMPARE(qvariant_cast<QUrl>(mediaSpy.last().value(0)), mediaContent);
+
+ QCOMPARE(player->error(), error);
+ QCOMPARE(errorSpy.size(), errorCount);
+ if (errorCount > 0) {
+ QCOMPARE(qvariant_cast<QMediaPlayer::Error>(errorSpy.last().value(0)), error);
+ QVERIFY(!player->errorString().isEmpty());
+ }
+
+ // Check the media actually passed to the backend
+ QCOMPARE(mockPlayer->media().scheme(), backendMediaContentScheme);
+ QCOMPARE(bool(mockPlayer->mediaStream()), backendHasStream);
+}
+
+QTEST_GUILESS_MAIN(tst_QMediaPlayer)
+#include "tst_qmediaplayer.moc"
diff --git a/tests/auto/unit/multimedia/qmediaplayer_gstreamer/CMakeLists.txt b/tests/auto/unit/multimedia/qmediaplayer_gstreamer/CMakeLists.txt
new file mode 100644
index 000000000..dd54afd25
--- /dev/null
+++ b/tests/auto/unit/multimedia/qmediaplayer_gstreamer/CMakeLists.txt
@@ -0,0 +1,32 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+#####################################################################
+## tst_qmediaplayer_gstreamer Test:
+#####################################################################
+
+qt_internal_add_test(tst_qmediaplayer_gstreamer
+ SOURCES
+ tst_qmediaplayer_gstreamer.cpp
+ tst_qmediaplayer_gstreamer.h
+ ../../../shared/qscopedenvironmentvariable.h
+ INCLUDE_DIRECTORIES
+ ../../../shared
+ LIBRARIES
+ Qt::MultimediaPrivate
+ Qt::QGstreamerMediaPluginPrivate
+)
+
+
+# Resources:
+set(testdata_resource_files
+ "testdata/color_matrix.mp4"
+)
+
+qt_internal_add_resource(tst_qmediaplayer_gstreamer "testdata"
+ PREFIX
+ "/"
+ FILES
+ ${testdata_resource_files}
+)
+
diff --git a/tests/auto/unit/multimedia/qmediaplayer_gstreamer/testdata/color_matrix.mp4 b/tests/auto/unit/multimedia/qmediaplayer_gstreamer/testdata/color_matrix.mp4
new file mode 100644
index 000000000..a3661b9d2
--- /dev/null
+++ b/tests/auto/unit/multimedia/qmediaplayer_gstreamer/testdata/color_matrix.mp4
Binary files differ
diff --git a/tests/auto/unit/multimedia/qmediaplayer_gstreamer/tst_qmediaplayer_gstreamer.cpp b/tests/auto/unit/multimedia/qmediaplayer_gstreamer/tst_qmediaplayer_gstreamer.cpp
new file mode 100644
index 000000000..3bb0b626e
--- /dev/null
+++ b/tests/auto/unit/multimedia/qmediaplayer_gstreamer/tst_qmediaplayer_gstreamer.cpp
@@ -0,0 +1,153 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include "tst_qmediaplayer_gstreamer.h"
+
+#include <QtTest/QtTest>
+#include <QtMultimedia/private/qmediaplayer_p.h>
+
+#include <qscopedenvironmentvariable.h>
+
+QT_USE_NAMESPACE
+
+using namespace Qt::Literals;
+
+QGStreamerPlatformSpecificInterface *tst_QMediaPlayerGStreamer::gstInterface()
+{
+ return dynamic_cast<QGStreamerPlatformSpecificInterface *>(
+ QPlatformMediaIntegration::instance()->platformSpecificInterface());
+}
+
+GstPipeline *tst_QMediaPlayerGStreamer::getGstPipeline()
+{
+ QGStreamerPlatformSpecificInterface *iface = gstInterface();
+ return iface ? iface->gstPipeline(player.get()) : nullptr;
+}
+
+QGstPipeline tst_QMediaPlayerGStreamer::getPipeline()
+{
+ return QGstPipeline{
+ getGstPipeline(),
+ QGstPipeline::NeedsRef,
+ };
+}
+
+void tst_QMediaPlayerGStreamer::dumpGraph(const char *fileNamePrefix)
+{
+ GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(getGstPipeline()),
+ GstDebugGraphDetails(GST_DEBUG_GRAPH_SHOW_VERBOSE), fileNamePrefix);
+}
+
+tst_QMediaPlayerGStreamer::tst_QMediaPlayerGStreamer()
+{
+ qputenv("QT_MEDIA_BACKEND", "gstreamer");
+}
+
+void tst_QMediaPlayerGStreamer::initTestCase()
+{
+ using namespace std::chrono_literals;
+
+ QMediaPlayer player;
+
+ QVideoSink sink;
+ player.setVideoSink(&sink);
+ player.setSource(QUrl("qrc:/testdata/color_matrix.mp4"));
+
+ for (;;) {
+ QMediaPlayer::MediaStatus status = player.mediaStatus();
+ switch (status) {
+ case QMediaPlayer::MediaStatus::InvalidMedia: {
+ mediaSupported = false;
+ return;
+ }
+ case QMediaPlayer::MediaStatus::NoMedia:
+ case QMediaPlayer::MediaStatus::StalledMedia:
+ case QMediaPlayer::MediaStatus::LoadingMedia:
+ QTest::qWait(20ms);
+ continue;
+
+ default: {
+ mediaSupported = true;
+ return;
+ }
+ }
+ }
+}
+
+void tst_QMediaPlayerGStreamer::init()
+{
+ player = std::make_unique<QMediaPlayer>();
+}
+
+void tst_QMediaPlayerGStreamer::cleanup()
+{
+ player.reset();
+}
+
+void tst_QMediaPlayerGStreamer::constructor_preparesGstPipeline()
+{
+ auto *rawPipeline = getGstPipeline();
+ QVERIFY(rawPipeline);
+
+ QGstPipeline pipeline{
+ rawPipeline,
+ QGstPipeline::NeedsRef,
+ };
+ QVERIFY(pipeline);
+
+ QVERIFY(pipeline.findByName("videoInputSelector"));
+ QVERIFY(pipeline.findByName("audioInputSelector"));
+ QVERIFY(pipeline.findByName("subTitleInputSelector"));
+
+ dumpGraph("constructor_preparesGstPipeline");
+}
+
+void tst_QMediaPlayerGStreamer::videoSink_constructor_overridesConversionElement()
+{
+ if (!mediaSupported)
+ QSKIP("Media playback not supported");
+
+ QScopedEnvironmentVariable convOverride{
+ "QT_GSTREAMER_OVERRIDE_VIDEO_CONVERSION_ELEMENT",
+ "identity name=myConverter",
+ };
+
+ QVideoSink sink;
+ player->setVideoSink(&sink);
+ player->setSource(QUrl("qrc:/testdata/color_matrix.mp4"));
+
+ QGstPipeline pipeline = getPipeline();
+ QTEST_ASSERT(pipeline);
+
+ QTRY_VERIFY(pipeline.findByName("myConverter"));
+
+ dumpGraph("videoSink_constructor_overridesConversionElement");
+}
+
+void tst_QMediaPlayerGStreamer::
+ videoSink_constructor_overridesConversionElement_withMultipleElements()
+{
+ if (!mediaSupported)
+ QSKIP("Media playback not supported");
+
+ QScopedEnvironmentVariable convOverride{
+ "QT_GSTREAMER_OVERRIDE_VIDEO_CONVERSION_ELEMENT",
+ "identity name=myConverter ! identity name=myConverter2",
+ };
+
+ QVideoSink sink;
+ player->setVideoSink(&sink);
+ player->setSource(QUrl("qrc:/testdata/color_matrix.mp4"));
+
+ QGstPipeline pipeline = getPipeline();
+ QTEST_ASSERT(pipeline);
+
+ QTRY_VERIFY(pipeline.findByName("myConverter"));
+ QTRY_VERIFY(pipeline.findByName("myConverter2"));
+
+ dumpGraph("videoSink_constructer_overridesConversionElement_withMultipleElements");
+}
+
+QTEST_GUILESS_MAIN(tst_QMediaPlayerGStreamer)
+
+#include "moc_tst_qmediaplayer_gstreamer.cpp"
diff --git a/tests/auto/unit/multimedia/qmediaplayer_gstreamer/tst_qmediaplayer_gstreamer.h b/tests/auto/unit/multimedia/qmediaplayer_gstreamer/tst_qmediaplayer_gstreamer.h
new file mode 100644
index 000000000..08e958404
--- /dev/null
+++ b/tests/auto/unit/multimedia/qmediaplayer_gstreamer/tst_qmediaplayer_gstreamer.h
@@ -0,0 +1,46 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef TST_GMEDIAPLAYER_GSTREAMER_H
+#define TST_GMEDIAPLAYER_GSTREAMER_H
+
+#include <QtCore/qtemporaryfile.h>
+#include <QtCore/qstandardpaths.h>
+#include <QtMultimedia/qmediaplayer.h>
+#include <QtQGstreamerMediaPlugin/private/qgstpipeline_p.h>
+#include <QtMultimedia/private/qgstreamer_platformspecificinterface_p.h>
+
+#include <memory>
+
+QT_USE_NAMESPACE
+
+class tst_QMediaPlayerGStreamer : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QMediaPlayerGStreamer();
+
+public slots:
+ void initTestCase();
+ void init();
+ void cleanup();
+
+private slots:
+ void constructor_preparesGstPipeline();
+ void videoSink_constructor_overridesConversionElement();
+ void videoSink_constructor_overridesConversionElement_withMultipleElements();
+
+private:
+ std::unique_ptr<QMediaPlayer> player;
+
+ static QGStreamerPlatformSpecificInterface *gstInterface();
+
+ GstPipeline *getGstPipeline();
+ QGstPipeline getPipeline();
+ void dumpGraph(const char *fileNamePrefix);
+
+ bool mediaSupported;
+};
+
+#endif // TST_GMEDIAPLAYER_GSTREAMER_H
diff --git a/tests/auto/unit/multimedia/qmediaplaylist/CMakeLists.txt b/tests/auto/unit/multimedia/qmediaplaylist/CMakeLists.txt
new file mode 100644
index 000000000..9300394b1
--- /dev/null
+++ b/tests/auto/unit/multimedia/qmediaplaylist/CMakeLists.txt
@@ -0,0 +1,23 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+# Generated from qmediaplaylist.pro.
+
+#####################################################################
+## tst_qmediaplaylist Test:
+#####################################################################
+
+# Collect test data
+file(GLOB_RECURSE test_data_glob
+ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
+ testdata/*)
+list(APPEND test_data ${test_data_glob})
+
+qt_internal_add_test(tst_qmediaplaylist
+ SOURCES
+ tst_qmediaplaylist.cpp
+ LIBRARIES
+ Qt::Gui
+ Qt::MultimediaPrivate
+ TESTDATA ${test_data}
+)
diff --git a/tests/auto/unit/qmediaplaylist/testdata/empty.pls b/tests/auto/unit/multimedia/qmediaplaylist/testdata/empty.pls
index 639c22b0c..639c22b0c 100644
--- a/tests/auto/unit/qmediaplaylist/testdata/empty.pls
+++ b/tests/auto/unit/multimedia/qmediaplaylist/testdata/empty.pls
diff --git a/tests/auto/unit/qmediaplaylist/testdata/test.m3u b/tests/auto/unit/multimedia/qmediaplaylist/testdata/test.m3u
index e5cb7c828..e5cb7c828 100644
--- a/tests/auto/unit/qmediaplaylist/testdata/test.m3u
+++ b/tests/auto/unit/multimedia/qmediaplaylist/testdata/test.m3u
diff --git a/tests/auto/unit/qmediaplaylist/testdata/test.pls b/tests/auto/unit/multimedia/qmediaplaylist/testdata/test.pls
index 18832b101..18832b101 100644
--- a/tests/auto/unit/qmediaplaylist/testdata/test.pls
+++ b/tests/auto/unit/multimedia/qmediaplaylist/testdata/test.pls
diff --git a/tests/auto/unit/qmediaplaylist/testdata/testfile b/tests/auto/unit/multimedia/qmediaplaylist/testdata/testfile
index e69de29bb..e69de29bb 100644
--- a/tests/auto/unit/qmediaplaylist/testdata/testfile
+++ b/tests/auto/unit/multimedia/qmediaplaylist/testdata/testfile
diff --git a/tests/auto/unit/qmediaplaylist/testdata/testfile2#suffix b/tests/auto/unit/multimedia/qmediaplaylist/testdata/testfile2#suffix
index e69de29bb..e69de29bb 100644
--- a/tests/auto/unit/qmediaplaylist/testdata/testfile2#suffix
+++ b/tests/auto/unit/multimedia/qmediaplaylist/testdata/testfile2#suffix
diff --git a/tests/auto/unit/qmediaplaylist/testdata/totem-pl-example.pls b/tests/auto/unit/multimedia/qmediaplaylist/testdata/totem-pl-example.pls
index 385fe2a30..385fe2a30 100644
--- a/tests/auto/unit/qmediaplaylist/testdata/totem-pl-example.pls
+++ b/tests/auto/unit/multimedia/qmediaplaylist/testdata/totem-pl-example.pls
diff --git a/tests/auto/unit/qmediaplaylist/tst_qmediaplaylist.cpp b/tests/auto/unit/multimedia/qmediaplaylist/tst_qmediaplaylist.cpp
index 9b1385dac..8ef882bbf 100644
--- a/tests/auto/unit/qmediaplaylist/tst_qmediaplaylist.cpp
+++ b/tests/auto/unit/multimedia/qmediaplaylist/tst_qmediaplaylist.cpp
@@ -1,63 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtTest/QtTest>
#include <QDebug>
-#include "qmediaservice.h"
#include "qmediaplaylist.h"
-#include <private/qmediaplaylistcontrol_p.h>
-#include <private/qmediaplaylistsourcecontrol_p.h>
-#include <private/qmediaplaylistnavigator_p.h>
-#include <private/qmediapluginloader_p.h>
-
-#include "qm3uhandler.h"
-
-//TESTED_COMPONENT=src/multimedia
-
-#include "mockplaylistservice.h"
-#include "mockmediaplaylistcontrol.h"
-#include "mockmediaplaylistsourcecontrol.h"
-#include "mockreadonlyplaylistprovider.h"
QT_USE_NAMESPACE
-class MockPlaylistObject : public QMediaObject
-{
- Q_OBJECT
-public:
- MockPlaylistObject(QObject *parent = 0)
- : QMediaObject(parent, mockService = new MockPlaylistService)
- {
- }
-
- MockPlaylistService *mockService;
-};
-
class tst_QMediaPlaylist : public QObject
{
Q_OBJECT
@@ -79,8 +28,7 @@ private slots:
void playbackMode();
void playbackMode_data();
void shuffle();
- void readOnlyPlaylist();
- void setMediaObject();
+ void setMediaSource();
void testCurrentIndexChanged_signal();
void testCurrentMediaChanged_signal();
@@ -89,16 +37,10 @@ private slots:
void testPlaybackModeChanged_signal();
void testEnums();
- void mediaPlayListProvider();
- // TC for Abstract control classes
- void mediaPlayListControl();
- void mediaPlayListSourceControl();
-
-
private:
- QMediaContent content1;
- QMediaContent content2;
- QMediaContent content3;
+ QUrl content1;
+ QUrl content2;
+ QUrl content3;
};
void tst_QMediaPlaylist::init()
@@ -107,10 +49,9 @@ void tst_QMediaPlaylist::init()
void tst_QMediaPlaylist::initTestCase()
{
- qRegisterMetaType<QMediaContent>();
- content1 = QMediaContent(QUrl(QLatin1String("file:///1")));
- content2 = QMediaContent(QUrl(QLatin1String("file:///2")));
- content3 = QMediaContent(QUrl(QLatin1String("file:///3")));
+ content1 = QUrl(QUrl(QLatin1String("file:///1")));
+ content2 = QUrl(QUrl(QLatin1String("file:///2")));
+ content3 = QUrl(QUrl(QLatin1String("file:///3")));
}
@@ -128,7 +69,6 @@ void tst_QMediaPlaylist::construction()
void tst_QMediaPlaylist::append()
{
QMediaPlaylist playlist;
- QVERIFY(!playlist.isReadOnly());
playlist.addMedia(content1);
QCOMPARE(playlist.mediaCount(), 1);
@@ -151,9 +91,9 @@ void tst_QMediaPlaylist::append()
aboutToBeInsertedSignalSpy.clear();
insertedSignalSpy.clear();
- QMediaContent content4(QUrl(QLatin1String("file:///4")));
- QMediaContent content5(QUrl(QLatin1String("file:///5")));
- playlist.addMedia(QList<QMediaContent>() << content3 << content4 << content5);
+ QUrl content4(QUrl(QLatin1String("file:///4")));
+ QUrl content5(QUrl(QLatin1String("file:///5")));
+ playlist.addMedia(QList<QUrl>() << content3 << content4 << content5);
QCOMPARE(playlist.mediaCount(), 5);
QCOMPARE(playlist.media(2), content3);
QCOMPARE(playlist.media(3), content4);
@@ -170,7 +110,7 @@ void tst_QMediaPlaylist::append()
aboutToBeInsertedSignalSpy.clear();
insertedSignalSpy.clear();
- playlist.addMedia(QList<QMediaContent>());
+ playlist.addMedia(QList<QUrl>());
QCOMPARE(aboutToBeInsertedSignalSpy.count(), 0);
QCOMPARE(insertedSignalSpy.count(), 0);
}
@@ -178,7 +118,6 @@ void tst_QMediaPlaylist::append()
void tst_QMediaPlaylist::insert()
{
QMediaPlaylist playlist;
- QVERIFY(!playlist.isReadOnly());
playlist.addMedia(content1);
QCOMPARE(playlist.mediaCount(), 1);
@@ -208,9 +147,9 @@ void tst_QMediaPlaylist::insert()
aboutToBeInsertedSignalSpy.clear();
insertedSignalSpy.clear();
- QMediaContent content4(QUrl(QLatin1String("file:///4")));
- QMediaContent content5(QUrl(QLatin1String("file:///5")));
- playlist.insertMedia(1, QList<QMediaContent>() << content4 << content5);
+ QUrl content4(QUrl(QLatin1String("file:///4")));
+ QUrl content5(QUrl(QLatin1String("file:///5")));
+ playlist.insertMedia(1, QList<QUrl>() << content4 << content5);
QCOMPARE(playlist.media(0), content1);
QCOMPARE(playlist.media(1), content4);
@@ -228,7 +167,7 @@ void tst_QMediaPlaylist::insert()
aboutToBeInsertedSignalSpy.clear();
insertedSignalSpy.clear();
- playlist.insertMedia(1, QList<QMediaContent>());
+ playlist.insertMedia(1, QList<QUrl>());
QCOMPARE(aboutToBeInsertedSignalSpy.count(), 0);
QCOMPARE(insertedSignalSpy.count(), 0);
@@ -264,7 +203,7 @@ void tst_QMediaPlaylist::insert()
aboutToBeInsertedSignalSpy.clear();
insertedSignalSpy.clear();
- playlist.insertMedia(-10, QList<QMediaContent>() << content4 << content5);
+ playlist.insertMedia(-10, QList<QUrl>() << content4 << content5);
QCOMPARE(playlist.media(0), content4);
QCOMPARE(playlist.media(1), content5);
QCOMPARE(playlist.media(2), content2);
@@ -280,9 +219,9 @@ void tst_QMediaPlaylist::insert()
aboutToBeInsertedSignalSpy.clear();
insertedSignalSpy.clear();
- QMediaContent content6(QUrl(QLatin1String("file:///6")));
- QMediaContent content7(QUrl(QLatin1String("file:///7")));
- playlist.insertMedia(10, QList<QMediaContent>() << content6 << content7);
+ QUrl content6(QUrl(QLatin1String("file:///6")));
+ QUrl content7(QUrl(QLatin1String("file:///7")));
+ playlist.insertMedia(10, QList<QUrl>() << content6 << content7);
QCOMPARE(playlist.media(0), content4);
QCOMPARE(playlist.media(1), content5);
QCOMPARE(playlist.media(2), content2);
@@ -306,7 +245,7 @@ void tst_QMediaPlaylist::currentItem()
playlist.addMedia(content2);
QCOMPARE(playlist.currentIndex(), -1);
- QCOMPARE(playlist.currentMedia(), QMediaContent());
+ QCOMPARE(playlist.currentMedia(), QUrl());
QCOMPARE(playlist.nextIndex(), 0);
QCOMPARE(playlist.nextIndex(2), 1);
@@ -334,7 +273,7 @@ void tst_QMediaPlaylist::currentItem()
playlist.setCurrentIndex(2);
QCOMPARE(playlist.currentIndex(), -1);
- QCOMPARE(playlist.currentMedia(), QMediaContent());
+ QCOMPARE(playlist.currentMedia(), QUrl());
}
void tst_QMediaPlaylist::clear()
@@ -471,6 +410,7 @@ void tst_QMediaPlaylist::saveAndLoad()
QVERIFY(playlist.error() != QMediaPlaylist::NoError);
QVERIFY(!playlist.errorString().isEmpty());
+
res = playlist.save(QUrl::fromLocalFile(QLatin1String("tmp.unsupported_format")), "unsupported_format");
QVERIFY(!res);
QVERIFY(playlist.error() != QMediaPlaylist::NoError);
@@ -478,11 +418,13 @@ void tst_QMediaPlaylist::saveAndLoad()
loadedSignal.clear();
errorSignal.clear();
- playlist.load(QUrl::fromLocalFile(QLatin1String("tmp.unsupported_format")), "unsupported_format");
+ QUrl testFileName = QUrl::fromLocalFile(QFINDTESTDATA("testdata") + "/testfile");
+ playlist.load(testFileName, "unsupported_format");
QTRY_VERIFY(loadedSignal.isEmpty());
QCOMPARE(errorSignal.size(), 1);
QVERIFY(playlist.error() == QMediaPlaylist::FormatNotSupportedError);
QVERIFY(!playlist.errorString().isEmpty());
+ QVERIFY(playlist.mediaCount() == 3);
res = playlist.save(&buffer, "m3u");
@@ -542,24 +484,24 @@ void tst_QMediaPlaylist::loadM3uFile()
QCOMPARE(playlist.error(), QMediaPlaylist::NoError);
QCOMPARE(playlist.mediaCount(), 7);
- QCOMPARE(playlist.media(0).request().url(), QUrl(QLatin1String("http://test.host/path")));
- QCOMPARE(playlist.media(1).request().url(), QUrl(QLatin1String("http://test.host/path")));
+ QCOMPARE(playlist.media(0), QUrl(QLatin1String("http://test.host/path")));
+ QCOMPARE(playlist.media(1), QUrl(QLatin1String("http://test.host/path")));
testFileName = QFINDTESTDATA("testdata/testfile");
- QCOMPARE(playlist.media(2).request().url(),
+ QCOMPARE(playlist.media(2),
QUrl::fromLocalFile(testFileName));
testFileName = QFINDTESTDATA("testdata");
- QCOMPARE(playlist.media(3).request().url(),
+ QCOMPARE(playlist.media(3),
QUrl::fromLocalFile(testFileName + "/testdir/testfile"));
- QCOMPARE(playlist.media(4).request().url(), QUrl(QLatin1String("file:///testdir/testfile")));
- QCOMPARE(playlist.media(5).request().url(), QUrl(QLatin1String("file://path/name#suffix")));
+ QCOMPARE(playlist.media(4), QUrl(QLatin1String("file:///testdir/testfile")));
+ QCOMPARE(playlist.media(5), QUrl(QLatin1String("file://path/name#suffix")));
//ensure #2 suffix is not stripped from path
testFileName = QFINDTESTDATA("testdata/testfile2#suffix");
- QCOMPARE(playlist.media(6).request().url(), QUrl::fromLocalFile(testFileName));
+ QCOMPARE(playlist.media(6), QUrl::fromLocalFile(testFileName));
// check ability to load from QNetworkRequest
loadSpy.clear();
loadFailedSpy.clear();
- playlist.load(QNetworkRequest(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test.m3u"))));
+ playlist.load(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test.m3u")));
QTRY_VERIFY(!loadSpy.isEmpty());
QVERIFY(loadFailedSpy.isEmpty());
}
@@ -597,19 +539,19 @@ void tst_QMediaPlaylist::loadPLSFile()
QCOMPARE(playlist.error(), QMediaPlaylist::NoError);
QCOMPARE(playlist.mediaCount(), 7);
- QCOMPARE(playlist.media(0).request().url(), QUrl(QLatin1String("http://test.host/path")));
- QCOMPARE(playlist.media(1).request().url(), QUrl(QLatin1String("http://test.host/path")));
+ QCOMPARE(playlist.media(0), QUrl(QLatin1String("http://test.host/path")));
+ QCOMPARE(playlist.media(1), QUrl(QLatin1String("http://test.host/path")));
testFileName = QFINDTESTDATA("testdata/testfile");
- QCOMPARE(playlist.media(2).request().url(),
+ QCOMPARE(playlist.media(2),
QUrl::fromLocalFile(testFileName));
testFileName = QFINDTESTDATA("testdata");
- QCOMPARE(playlist.media(3).request().url(),
+ QCOMPARE(playlist.media(3),
QUrl::fromLocalFile(testFileName + "/testdir/testfile"));
- QCOMPARE(playlist.media(4).request().url(), QUrl(QLatin1String("file:///testdir/testfile")));
- QCOMPARE(playlist.media(5).request().url(), QUrl(QLatin1String("file://path/name#suffix")));
+ QCOMPARE(playlist.media(4), QUrl(QLatin1String("file:///testdir/testfile")));
+ QCOMPARE(playlist.media(5), QUrl(QLatin1String("file://path/name#suffix")));
//ensure #2 suffix is not stripped from path
testFileName = QFINDTESTDATA("testdata/testfile2#suffix");
- QCOMPARE(playlist.media(6).request().url(), QUrl::fromLocalFile(testFileName));
+ QCOMPARE(playlist.media(6), QUrl::fromLocalFile(testFileName));
// Try to load a totem-pl generated playlist
// (Format doesn't respect the spec)
@@ -622,13 +564,13 @@ void tst_QMediaPlaylist::loadPLSFile()
QVERIFY(loadFailedSpy.isEmpty());
QCOMPARE(playlist.error(), QMediaPlaylist::NoError);
QCOMPARE(playlist.mediaCount(), 1);
- QCOMPARE(playlist.media(0).request().url(), QUrl(QLatin1String("http://test.host/path")));
+ QCOMPARE(playlist.media(0), QUrl(QLatin1String("http://test.host/path")));
// check ability to load from QNetworkRequest
loadSpy.clear();
loadFailedSpy.clear();
- playlist.load(QNetworkRequest(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test.pls"))));
+ playlist.load(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test.pls")));
QTRY_VERIFY(!loadSpy.isEmpty());
QVERIFY(loadFailedSpy.isEmpty());
}
@@ -688,17 +630,17 @@ void tst_QMediaPlaylist::playbackMode()
void tst_QMediaPlaylist::shuffle()
{
QMediaPlaylist playlist;
- QList<QMediaContent> contentList;
+ QList<QUrl> contentList;
for (int i=0; i<100; i++) {
- QMediaContent content(QUrl::fromLocalFile(QString::number(i)));
+ QUrl content(QUrl::fromLocalFile(QString::number(i)));
contentList.append(content);
playlist.addMedia(content);
}
playlist.shuffle();
- QList<QMediaContent> shuffledContentList;
+ QList<QUrl> shuffledContentList;
for (int i=0; i<playlist.mediaCount(); i++)
shuffledContentList.append(playlist.media(i));
@@ -706,84 +648,15 @@ void tst_QMediaPlaylist::shuffle()
}
-void tst_QMediaPlaylist::readOnlyPlaylist()
-{
- MockPlaylistObject mediaObject;
- mediaObject.mockService->mockControl->setReadOnly(true);
-
- QMediaPlaylist playlist;
- mediaObject.bind(&playlist);
-
- QVERIFY(playlist.isReadOnly());
- QVERIFY(!playlist.isEmpty());
- QCOMPARE(playlist.mediaCount(), 3);
-
- QCOMPARE(playlist.media(0), content1);
- QCOMPARE(playlist.media(1), content2);
- QCOMPARE(playlist.media(2), content3);
- QCOMPARE(playlist.media(3), QMediaContent());
-
- //it's a read only playlist, so all the modification should fail
- QVERIFY(!playlist.addMedia(content1));
- QCOMPARE(playlist.mediaCount(), 3);
- QVERIFY(!playlist.addMedia(QList<QMediaContent>() << content1 << content2));
- QCOMPARE(playlist.mediaCount(), 3);
- QVERIFY(!playlist.insertMedia(1, content1));
- QCOMPARE(playlist.mediaCount(), 3);
- QVERIFY(!playlist.insertMedia(1, QList<QMediaContent>() << content1 << content2));
- QCOMPARE(playlist.mediaCount(), 3);
- QVERIFY(!playlist.removeMedia(1));
- QCOMPARE(playlist.mediaCount(), 3);
- QVERIFY(!playlist.removeMedia(0,2));
- QCOMPARE(playlist.mediaCount(), 3);
- QVERIFY(!playlist.clear());
- QCOMPARE(playlist.mediaCount(), 3);
-
- //but it is still allowed to append/insert an empty list
- QVERIFY(playlist.addMedia(QList<QMediaContent>()));
- QVERIFY(playlist.insertMedia(1, QList<QMediaContent>()));
-
- playlist.shuffle();
- //it's still the same
- QCOMPARE(playlist.media(0), content1);
- QCOMPARE(playlist.media(1), content2);
- QCOMPARE(playlist.media(2), content3);
- QCOMPARE(playlist.media(3), QMediaContent());
-
-
- //load to read only playlist should fail,
- //unless underlaying provider supports it
- QBuffer buffer;
- buffer.open(QBuffer::ReadWrite);
- buffer.write(QByteArray("file:///1\nfile:///2"));
- buffer.seek(0);
-
- QSignalSpy errorSignal(&playlist, SIGNAL(loadFailed()));
- playlist.load(&buffer, "m3u");
- QCOMPARE(errorSignal.size(), 1);
- QCOMPARE(playlist.error(), QMediaPlaylist::AccessDeniedError);
- QVERIFY(!playlist.errorString().isEmpty());
- QCOMPARE(playlist.mediaCount(), 3);
-
- errorSignal.clear();
- playlist.load(QUrl::fromLocalFile(QLatin1String("tmp.m3u")), "m3u");
-
- QCOMPARE(errorSignal.size(), 1);
- QCOMPARE(playlist.error(), QMediaPlaylist::AccessDeniedError);
- QVERIFY(!playlist.errorString().isEmpty());
- QCOMPARE(playlist.mediaCount(), 3);
-}
-void tst_QMediaPlaylist::setMediaObject()
+void tst_QMediaPlaylist::setMediaSource()
{
- QMediaContent content0(QUrl(QLatin1String("test://audio/song1.mp3")));
- QMediaContent content1(QUrl(QLatin1String("test://audio/song2.mp3")));
- QMediaContent content2(QUrl(QLatin1String("test://video/movie1.mp4")));
- QMediaContent content3(QUrl(QLatin1String("test://video/movie2.mp4")));
+ QUrl content0(QUrl(QLatin1String("test://audio/song1.mp3")));
+ QUrl content1(QUrl(QLatin1String("test://audio/song2.mp3")));
+ QUrl content2(QUrl(QLatin1String("test://video/movie1.mp4")));
+ QUrl content3(QUrl(QLatin1String("test://video/movie2.mp4")));
{
- MockPlaylistObject mediaObject;
-
QMediaPlaylist playlist;
QSignalSpy currentIndexSpy(&playlist, SIGNAL(currentIndexChanged(int)));
QSignalSpy playbackModeSpy(&playlist, SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode)));
@@ -795,9 +668,6 @@ void tst_QMediaPlaylist::setMediaObject()
QVERIFY(playlist.isEmpty());
- mediaObject.bind(&playlist);
-
- // Playlist is now using the service's control, nothing should have changed
QVERIFY(playlist.isEmpty());
QCOMPARE(playlist.currentIndex(), -1);
QCOMPARE(playlist.playbackMode(), QMediaPlaylist::Sequential);
@@ -809,15 +679,14 @@ void tst_QMediaPlaylist::setMediaObject()
QCOMPARE(mediaRemovedSpy.count(), 0);
QCOMPARE(mediaChangedSpy.count(), 0);
- // add items to service's playlist control
+ // add items to playlist
playlist.addMedia(content0);
playlist.addMedia(content1);
playlist.setCurrentIndex(1);
- playlist.setPlaybackMode(QMediaPlaylist::Random);
+ playlist.shuffle();
QCOMPARE(playlist.mediaCount(), 2);
QCOMPARE(playlist.currentIndex(), 1);
QCOMPARE(playlist.currentMedia(), content1);
- QCOMPARE(playlist.playbackMode(), QMediaPlaylist::Random);
currentIndexSpy.clear();
playbackModeSpy.clear();
@@ -826,24 +695,8 @@ void tst_QMediaPlaylist::setMediaObject()
mediaAboutToBeRemovedSpy.clear();
mediaRemovedSpy.clear();
mediaChangedSpy.clear();
-
- // unbind the playlist, reverting back to the internal control.
- // playlist content should't have changed.
- mediaObject.unbind(&playlist);
- QCOMPARE(playlist.mediaCount(), 2);
- QCOMPARE(playlist.currentIndex(), 1);
- QCOMPARE(playlist.currentMedia(), content1);
- QCOMPARE(playlist.playbackMode(), QMediaPlaylist::Random);
- QCOMPARE(playbackModeSpy.count(), 0);
- QCOMPARE(mediaAboutToBeInsertedSpy.count(), 0);
- QCOMPARE(mediaInsertedSpy.count(), 0);
- QCOMPARE(mediaAboutToBeRemovedSpy.count(), 0);
- QCOMPARE(mediaRemovedSpy.count(), 0);
- QCOMPARE(mediaChangedSpy.count(), 0);
}
{
- MockPlaylistObject mediaObject;
-
QMediaPlaylist playlist;
QVERIFY(playlist.isEmpty());
// Add items to playlist before binding to the service (internal control)
@@ -861,8 +714,6 @@ void tst_QMediaPlaylist::setMediaObject()
QSignalSpy mediaRemovedSpy(&playlist, SIGNAL(mediaRemoved(int, int)));
QSignalSpy mediaChangedSpy(&playlist, SIGNAL(mediaChanged(int, int)));
- // Bind playlist, content should be unchanged
- mediaObject.bind(&playlist);
QCOMPARE(playlist.mediaCount(), 3);
QCOMPARE(playlist.currentIndex(), 2);
QCOMPARE(playlist.currentMedia(), content2);
@@ -878,7 +729,7 @@ void tst_QMediaPlaylist::setMediaObject()
// Clear playlist content (service's playlist control)
playlist.clear();
playlist.setCurrentIndex(-1);
- playlist.setPlaybackMode(QMediaPlaylist::Random);
+ playlist.shuffle();
currentIndexSpy.clear();
playbackModeSpy.clear();
@@ -887,168 +738,6 @@ void tst_QMediaPlaylist::setMediaObject()
mediaAboutToBeRemovedSpy.clear();
mediaRemovedSpy.clear();
mediaChangedSpy.clear();
-
- // unbind playlist from service, reverting back to the internal control.
- // playlist should still be empty
- mediaObject.unbind(&playlist);
- QCOMPARE(playlist.mediaCount(), 0);
- QCOMPARE(playlist.currentIndex(), -1);
- QCOMPARE(playlist.currentMedia(), QMediaContent());
- QCOMPARE(playlist.playbackMode(), QMediaPlaylist::Random);
- QCOMPARE(playbackModeSpy.count(), 0);
- QCOMPARE(mediaAboutToBeInsertedSpy.count(), 0);
- QCOMPARE(mediaInsertedSpy.count(), 0);
- QCOMPARE(mediaAboutToBeRemovedSpy.count(), 0);
- QCOMPARE(mediaRemovedSpy.count(), 0);
- QCOMPARE(mediaChangedSpy.count(), 0);
- }
- {
- MockPlaylistObject mediaObject;
-
- QMediaPlaylist playlist;
- QVERIFY(playlist.isEmpty());
- // Add items to playlist before attaching to media player (internal control)
- playlist.addMedia(content0);
- playlist.addMedia(content1);
- playlist.setCurrentIndex(-1);
- playlist.setPlaybackMode(QMediaPlaylist::CurrentItemOnce);
-
- // Add items to service's playlist before binding
- QMediaPlaylistProvider *pp = mediaObject.mockService->mockControl->playlistProvider();
- pp->addMedia(content2);
- pp->addMedia(content3);
- mediaObject.mockService->mockControl->setCurrentIndex(1);
- mediaObject.mockService->mockControl->setPlaybackMode(QMediaPlaylist::Random);
-
- QSignalSpy currentIndexSpy(&playlist, SIGNAL(currentIndexChanged(int)));
- QSignalSpy playbackModeSpy(&playlist, SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode)));
- QSignalSpy mediaAboutToBeInsertedSpy(&playlist, SIGNAL(mediaAboutToBeInserted(int, int)));
- QSignalSpy mediaInsertedSpy(&playlist, SIGNAL(mediaInserted(int, int)));
- QSignalSpy mediaAboutToBeRemovedSpy(&playlist, SIGNAL(mediaAboutToBeRemoved(int, int)));
- QSignalSpy mediaRemovedSpy(&playlist, SIGNAL(mediaRemoved(int, int)));
- QSignalSpy mediaChangedSpy(&playlist, SIGNAL(mediaChanged(int, int)));
-
- // Bind playlist, it should contain only what was explicitly added to the playlist.
- // Anything that was present in the service's control should have been cleared
- mediaObject.bind(&playlist);
- QCOMPARE(playlist.mediaCount(), 2);
- QCOMPARE(playlist.currentIndex(), -1);
- QCOMPARE(playlist.playbackMode(), QMediaPlaylist::CurrentItemOnce);
- QCOMPARE(currentIndexSpy.count(), 0);
- QCOMPARE(playbackModeSpy.count(), 0);
- QCOMPARE(mediaAboutToBeInsertedSpy.count(), 0);
- QCOMPARE(mediaInsertedSpy.count(), 0);
- QCOMPARE(mediaAboutToBeRemovedSpy.count(), 0);
- QCOMPARE(mediaRemovedSpy.count(), 0);
- QCOMPARE(mediaChangedSpy.count(), 0);
-
- // do some changes
- playlist.removeMedia(0); // content0
- playlist.addMedia(content3);
- playlist.setCurrentIndex(0);
-
- currentIndexSpy.clear();
- playbackModeSpy.clear();
- mediaAboutToBeInsertedSpy.clear();
- mediaInsertedSpy.clear();
- mediaAboutToBeRemovedSpy.clear();
- mediaRemovedSpy.clear();
- mediaChangedSpy.clear();
-
- // unbind playlist from service
- mediaObject.unbind(&playlist);
- QCOMPARE(playlist.mediaCount(), 2);
- QCOMPARE(playlist.currentIndex(), 0);
- QCOMPARE(playlist.currentMedia(), content1);
- QCOMPARE(playlist.playbackMode(), QMediaPlaylist::CurrentItemOnce);
- QCOMPARE(currentIndexSpy.count(), 0);
- QCOMPARE(playbackModeSpy.count(), 0);
- QCOMPARE(mediaAboutToBeInsertedSpy.count(), 0);
- QCOMPARE(mediaInsertedSpy.count(), 0);
- QCOMPARE(mediaAboutToBeRemovedSpy.count(), 0);
- QCOMPARE(mediaRemovedSpy.count(), 0);
- QCOMPARE(mediaChangedSpy.count(), 0);
-
- // bind again, nothing should have changed
- mediaObject.bind(&playlist);
- QCOMPARE(playlist.mediaCount(), 2);
- QCOMPARE(playlist.currentIndex(), 0);
- QCOMPARE(playlist.currentMedia(), content1);
- QCOMPARE(playlist.playbackMode(), QMediaPlaylist::CurrentItemOnce);
- QCOMPARE(currentIndexSpy.count(), 0);
- QCOMPARE(playbackModeSpy.count(), 0);
- QCOMPARE(mediaAboutToBeInsertedSpy.count(), 0);
- QCOMPARE(mediaInsertedSpy.count(), 0);
- QCOMPARE(mediaAboutToBeRemovedSpy.count(), 0);
- QCOMPARE(mediaRemovedSpy.count(), 0);
- QCOMPARE(mediaChangedSpy.count(), 0);
- }
- {
- MockPlaylistObject mediaObject;
- mediaObject.mockService->mockControl->setReadOnly(true);
-
- QMediaPlaylist playlist;
- QVERIFY(playlist.isEmpty());
- // Add items to playlist before binding to the service internal control)
- playlist.addMedia(content0);
- playlist.addMedia(content1);
- playlist.setCurrentIndex(-1);
- playlist.setPlaybackMode(QMediaPlaylist::CurrentItemOnce);
-
- QSignalSpy currentIndexSpy(&playlist, SIGNAL(currentIndexChanged(int)));
- QSignalSpy playbackModeSpy(&playlist, SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode)));
- QSignalSpy mediaAboutToBeInsertedSpy(&playlist, SIGNAL(mediaAboutToBeInserted(int, int)));
- QSignalSpy mediaInsertedSpy(&playlist, SIGNAL(mediaInserted(int, int)));
- QSignalSpy mediaAboutToBeRemovedSpy(&playlist, SIGNAL(mediaAboutToBeRemoved(int, int)));
- QSignalSpy mediaRemovedSpy(&playlist, SIGNAL(mediaRemoved(int, int)));
- QSignalSpy mediaChangedSpy(&playlist, SIGNAL(mediaChanged(int, int)));
-
- // Bind playlist. Since the service's control is read-only, no synchronization
- // should be done with the internal control. The mediaRemoved() and mediaInserted()
- // should be emitted to notify about the change.
- mediaObject.bind(&playlist);
- QCOMPARE(playlist.mediaCount(), 3);
- QCOMPARE(playlist.currentIndex(), -1);
- QCOMPARE(playlist.playbackMode(), QMediaPlaylist::CurrentItemOnce);
- QCOMPARE(currentIndexSpy.count(), 0);
- QCOMPARE(playbackModeSpy.count(), 0);
-
- QCOMPARE(mediaAboutToBeRemovedSpy.count(), 1);
- QCOMPARE(mediaAboutToBeRemovedSpy.last().at(0).toInt(), 0);
- QCOMPARE(mediaAboutToBeRemovedSpy.last().at(1).toInt(), 1);
- QCOMPARE(mediaRemovedSpy.count(), 1);
- QCOMPARE(mediaRemovedSpy.last().at(0).toInt(), 0);
- QCOMPARE(mediaRemovedSpy.last().at(1).toInt(), 1);
-
- QCOMPARE(mediaAboutToBeInsertedSpy.count(), 1);
- QCOMPARE(mediaAboutToBeInsertedSpy.last().at(0).toInt(), 0);
- QCOMPARE(mediaAboutToBeInsertedSpy.last().at(1).toInt(), 2);
- QCOMPARE(mediaInsertedSpy.count(), 1);
- QCOMPARE(mediaInsertedSpy.last().at(0).toInt(), 0);
- QCOMPARE(mediaInsertedSpy.last().at(1).toInt(), 2);
-
- QCOMPARE(mediaChangedSpy.count(), 0);
-
- currentIndexSpy.clear();
- playbackModeSpy.clear();
- mediaAboutToBeInsertedSpy.clear();
- mediaInsertedSpy.clear();
- mediaAboutToBeRemovedSpy.clear();
- mediaRemovedSpy.clear();
- mediaChangedSpy.clear();
-
- // detach playlist from player
- mediaObject.unbind(&playlist);
- QCOMPARE(playlist.mediaCount(), 3);
- QCOMPARE(playlist.currentIndex(), -1);
- QCOMPARE(playlist.playbackMode(), QMediaPlaylist::CurrentItemOnce);
- QCOMPARE(currentIndexSpy.count(), 0);
- QCOMPARE(playbackModeSpy.count(), 0);
- QCOMPARE(mediaAboutToBeInsertedSpy.count(), 0);
- QCOMPARE(mediaInsertedSpy.count(), 0);
- QCOMPARE(mediaAboutToBeRemovedSpy.count(), 0);
- QCOMPARE(mediaRemovedSpy.count(), 0);
- QCOMPARE(mediaChangedSpy.count(), 0);
}
}
@@ -1081,10 +770,10 @@ void tst_QMediaPlaylist::testCurrentMediaChanged_signal()
playlist.addMedia(content1); //set the media to playlist
playlist.addMedia(content2); //set the media to playlist
- QSignalSpy spy(&playlist, SIGNAL(currentMediaChanged(QMediaContent)));
+ QSignalSpy spy(&playlist, SIGNAL(currentMediaChanged(QUrl)));
QVERIFY(spy.size()== 0);
QCOMPARE(playlist.currentIndex(), -1);
- QCOMPARE(playlist.currentMedia(), QMediaContent());
+ QCOMPARE(playlist.currentMedia(), QUrl());
//set the current index for playlist.
playlist.setCurrentIndex(0);
@@ -1111,6 +800,7 @@ void tst_QMediaPlaylist::testLoaded_signal()
QVERIFY(spy.size()== 0);
QBuffer buffer;
+ buffer.setData(QByteArray("foo.mp3"));
buffer.open(QBuffer::ReadWrite);
//load the playlist
@@ -1140,8 +830,8 @@ void tst_QMediaPlaylist::testMediaChanged_signal()
spy.clear();
//create media.
- QMediaContent content4(QUrl(QLatin1String("file:///4")));
- QMediaContent content5(QUrl(QLatin1String("file:///5")));
+ QUrl content4(QUrl(QLatin1String("file:///4")));
+ QUrl content5(QUrl(QLatin1String("file:///5")));
//insert media to playlist
playlist.insertMedia(1, content4);
@@ -1186,11 +876,6 @@ void tst_QMediaPlaylist::testPlaybackModeChanged_signal()
playlist.setPlaybackMode(QMediaPlaylist::Loop);
QVERIFY(playlist.playbackMode()== QMediaPlaylist::Loop);
QVERIFY(spy.size() == 4);
-
- // Set playback mode to the playlist
- playlist.setPlaybackMode(QMediaPlaylist::Random);
- QVERIFY(playlist.playbackMode()== QMediaPlaylist::Random);
- QVERIFY(spy.size() == 5);
}
void tst_QMediaPlaylist::testEnums()
@@ -1213,30 +898,6 @@ void tst_QMediaPlaylist::testEnums()
QVERIFY(playlist.error() == QMediaPlaylist::FormatNotSupportedError);
}
-// MaemoAPI-1849:test QMediaPlayListControl constructor
-void tst_QMediaPlaylist::mediaPlayListControl()
-{
- // To check changes in abstract classe's pure virtual functions
- QObject parent;
- MockMediaPlaylistControl plylistctrl(false, &parent);
-}
-
-// MaemoAPI-1850:test QMediaPlayListSourceControl constructor
-void tst_QMediaPlaylist::mediaPlayListSourceControl()
-{
- // To check changes in abstract classe's pure virtual functions
- QObject parent;
- MockPlaylistSourceControl plylistsrcctrl(&parent);
-}
-
-// MaemoAPI-1852:test constructor
-void tst_QMediaPlaylist::mediaPlayListProvider()
-{
- // srcs of QMediaPlaylistProvider is incomplete
- QObject parent;
- MockReadOnlyPlaylistProvider provider(&parent);
-}
-
QTEST_MAIN(tst_QMediaPlaylist)
#include "tst_qmediaplaylist.moc"
diff --git a/tests/auto/unit/multimedia/qmediarecorder/CMakeLists.txt b/tests/auto/unit/multimedia/qmediarecorder/CMakeLists.txt
new file mode 100644
index 000000000..83e40012a
--- /dev/null
+++ b/tests/auto/unit/multimedia/qmediarecorder/CMakeLists.txt
@@ -0,0 +1,20 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+# Generated from QMediaRecorder.pro.
+
+#####################################################################
+## tst_QMediaRecorder Test:
+#####################################################################
+
+qt_internal_add_test(tst_qmediarecorder
+ SOURCES
+ tst_qmediarecorder.cpp
+ INCLUDE_DIRECTORIES
+ ../../mockbackend
+ LIBRARIES
+ # Remove: L${CMAKE_CURRENT_SOURCE_DIR}
+ Qt::Gui
+ Qt::MultimediaPrivate
+ MockMultimediaPlugin
+)
diff --git a/tests/auto/unit/multimedia/qmediarecorder/tst_qmediarecorder.cpp b/tests/auto/unit/multimedia/qmediarecorder/tst_qmediarecorder.cpp
new file mode 100644
index 000000000..a11f39207
--- /dev/null
+++ b/tests/auto/unit/multimedia/qmediarecorder/tst_qmediarecorder.cpp
@@ -0,0 +1,492 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QtTest/QtTest>
+#include <QDebug>
+#include <QtMultimedia/qmediametadata.h>
+#include <private/qplatformmediarecorder_p.h>
+#include "private/qguiapplication_p.h"
+#include <qmediarecorder.h>
+#include <qaudioformat.h>
+#include <qmockintegration.h>
+#include <qmediacapturesession.h>
+#include <qscreencapture.h>
+#include <qwindowcapture.h>
+
+#include "qguiapplication_platform.h"
+#include "qmockmediacapturesession.h"
+#include "qmockmediaencoder.h"
+
+QT_USE_NAMESPACE
+
+Q_ENABLE_MOCK_MULTIMEDIA_PLUGIN
+
+class tst_QMediaRecorder : public QObject
+{
+ Q_OBJECT
+
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+
+private slots:
+ void testBasicSession();
+ void testNullControls();
+ void testDeleteMediaCapture();
+ void testError();
+ void testSink();
+ void testRecord();
+ void testEncodingSettings();
+ void testAudioSettings();
+ void testVideoSettings();
+ void testSettingsApplied();
+
+ void metaData();
+
+ void testIsAvailable();
+ void testEnum();
+
+ void testVideoSettingsQuality();
+ void testVideoSettingsEncodingMode();
+
+ void testApplicationInative();
+
+private:
+ QMediaCaptureSession *captureSession;
+ QCamera *object = nullptr;
+ QMockMediaCaptureSession *service = nullptr;
+ QMockMediaEncoder *mock;
+ QMediaRecorder *encoder;
+};
+
+void tst_QMediaRecorder::initTestCase()
+{
+ captureSession = new QMediaCaptureSession;
+ object = new QCamera;
+ encoder = new QMediaRecorder;
+ captureSession->setCamera(object);
+ captureSession->setRecorder(encoder);
+ service = QMockIntegration::instance()->lastCaptureService();
+ mock = service->mockControl;
+}
+
+void tst_QMediaRecorder::cleanupTestCase()
+{
+ delete encoder;
+ delete object;
+ delete captureSession;
+}
+
+void tst_QMediaRecorder::testBasicSession()
+{
+ QMediaCaptureSession session;
+ QCamera camera;
+ QMediaRecorder recorder;
+ session.setCamera(&camera);
+ session.setRecorder(&recorder);
+
+ QCOMPARE(recorder.outputLocation(), QUrl());
+ QCOMPARE(recorder.recorderState(), QMediaRecorder::StoppedState);
+ QCOMPARE(recorder.error(), QMediaRecorder::NoError);
+ QCOMPARE(recorder.duration(), qint64(0));
+}
+
+void tst_QMediaRecorder::testNullControls()
+{
+ // With the new changes, hasControls does not make much sense anymore
+ // since the session does not own the controls
+ // The equivalent of this test would be to not set the control to the session
+ // ???
+ QMediaCaptureSession session;
+ // mockIntegration->lastCaptureService()->hasControls = false;
+ QCamera camera;
+ QMediaRecorder recorder;
+ session.setCamera(&camera);
+ // session.setRecorder(&recorder);
+
+ QCOMPARE(recorder.outputLocation(), QUrl());
+ QCOMPARE(recorder.recorderState(), QMediaRecorder::StoppedState);
+ QCOMPARE(recorder.error(), QMediaRecorder::NoError);
+ QCOMPARE(recorder.duration(), qint64(0));
+
+ recorder.setOutputLocation(QUrl("file://test/save/file.mp4"));
+ QCOMPARE(recorder.outputLocation(), QUrl("file://test/save/file.mp4"));
+ QCOMPARE(recorder.actualLocation(), QUrl());
+
+ QMediaFormat format;
+ format.setFileFormat(QMediaFormat::MPEG4);
+ format.setAudioCodec(QMediaFormat::AudioCodec::AAC);
+ format.setVideoCodec(QMediaFormat::VideoCodec::VP9);
+ recorder.setMediaFormat(format);
+ recorder.setQuality(QMediaRecorder::LowQuality);
+ recorder.setVideoResolution(640, 480);
+
+ QCOMPARE(recorder.mediaFormat().audioCodec(), QMediaFormat::AudioCodec::AAC);
+ QCOMPARE(recorder.mediaFormat().videoCodec(), QMediaFormat::VideoCodec::VP9);
+ QCOMPARE(recorder.mediaFormat().fileFormat(), QMediaFormat::MPEG4);
+
+ QSignalSpy spy(&recorder, &QMediaRecorder::recorderStateChanged);
+
+ recorder.record();
+ QCOMPARE(recorder.recorderState(), QMediaRecorder::StoppedState);
+ QCOMPARE(recorder.error(), QMediaRecorder::NoError);
+ QCOMPARE(spy.size(), 0);
+
+ recorder.pause();
+ QCOMPARE(recorder.recorderState(), QMediaRecorder::StoppedState);
+ QCOMPARE(recorder.error(), QMediaRecorder::NoError);
+ QCOMPARE(spy.size(), 0);
+
+ recorder.stop();
+ QCOMPARE(recorder.recorderState(), QMediaRecorder::StoppedState);
+ QCOMPARE(recorder.error(), QMediaRecorder::NoError);
+ QCOMPARE(spy.size(), 0);
+}
+
+void tst_QMediaRecorder::testDeleteMediaCapture()
+{
+ QMediaCaptureSession session;
+ QMediaRecorder recorder;
+
+ session.setRecorder(&recorder);
+
+ auto checkSourceDeleting = [&](auto setter, auto getter, auto signal) {
+ using Type = std::remove_pointer_t<decltype((session.*getter)())>;
+
+ auto errorPrinter = qScopeGuard(
+ []() { qDebug() << QMetaType::fromType<Type>().name() << "deleting failed"; });
+
+ auto capture = std::make_unique<Type>();
+
+ (session.*setter)(capture.get());
+
+ QVERIFY((session.*getter)() == capture.get());
+
+ QSignalSpy spy(&session, signal);
+ capture.reset();
+
+ QCOMPARE(spy.size(), 1);
+ QCOMPARE((session.*getter)(), nullptr);
+
+ QVERIFY(recorder.isAvailable());
+
+ errorPrinter.dismiss();
+ };
+
+ checkSourceDeleting(&QMediaCaptureSession::setImageCapture,
+ &QMediaCaptureSession::imageCapture,
+ &QMediaCaptureSession::imageCaptureChanged);
+ checkSourceDeleting(&QMediaCaptureSession::setCamera, &QMediaCaptureSession::camera,
+ &QMediaCaptureSession::cameraChanged);
+ checkSourceDeleting(&QMediaCaptureSession::setScreenCapture,
+ &QMediaCaptureSession::screenCapture,
+ &QMediaCaptureSession::screenCaptureChanged);
+ checkSourceDeleting(&QMediaCaptureSession::setWindowCapture,
+ &QMediaCaptureSession::windowCapture,
+ &QMediaCaptureSession::windowCaptureChanged);
+}
+
+void tst_QMediaRecorder::testError()
+{
+ const QString errorString(QLatin1String("format error"));
+
+ QSignalSpy spy(encoder, &QMediaRecorder::errorOccurred);
+
+ QCOMPARE(encoder->error(), QMediaRecorder::NoError);
+ QCOMPARE(encoder->errorString(), QString());
+
+ mock->updateError(QMediaRecorder::FormatError, errorString);
+ QCOMPARE(encoder->error(), QMediaRecorder::FormatError);
+ QCOMPARE(encoder->errorString(), errorString);
+ QCOMPARE(spy.size(), 1);
+
+ QCOMPARE(spy.last()[0].value<QMediaRecorder::Error>(), QMediaRecorder::FormatError);
+}
+
+void tst_QMediaRecorder::testSink()
+{
+ encoder->setOutputLocation(QUrl("test.tmp"));
+ QUrl s = encoder->outputLocation();
+ QCOMPARE(s.toString(), QStringLiteral("test.tmp"));
+ QCOMPARE(encoder->actualLocation(), QUrl());
+
+ //the actual location is available after record
+ encoder->record();
+ QCOMPARE(encoder->actualLocation().toString(), QStringLiteral("test.tmp"));
+ encoder->stop();
+ QCOMPARE(encoder->actualLocation().toString(), QStringLiteral("test.tmp"));
+
+ //setOutputLocation resets the actual location
+ encoder->setOutputLocation(QUrl());
+ QCOMPARE(encoder->actualLocation(), QUrl());
+
+ encoder->record();
+ QCOMPARE(encoder->actualLocation(), QUrl::fromLocalFile("default_name.mp4"));
+ encoder->stop();
+ QCOMPARE(encoder->actualLocation(), QUrl::fromLocalFile("default_name.mp4"));
+
+ mock->reset();
+}
+
+void tst_QMediaRecorder::testRecord()
+{
+ QSignalSpy stateSignal(encoder, &QMediaRecorder::recorderStateChanged);
+ QSignalSpy progressSignal(encoder, &QMediaRecorder::durationChanged);
+ encoder->record();
+ QCOMPARE(encoder->recorderState(), QMediaRecorder::RecordingState);
+ QCOMPARE(encoder->error(), QMediaRecorder::NoError);
+ QCOMPARE(encoder->errorString(), QString());
+
+ QCOMPARE(stateSignal.size(), 1);
+ QCOMPARE(stateSignal.last()[0].value<QMediaRecorder::RecorderState>(), QMediaRecorder::RecordingState);
+
+ QTestEventLoop::instance().enterLoop(1);
+
+ QVERIFY(progressSignal.size() > 0);
+
+ encoder->pause();
+
+ QCOMPARE(encoder->recorderState(), QMediaRecorder::PausedState);
+
+ QCOMPARE(stateSignal.size(), 2);
+
+ QTestEventLoop::instance().enterLoop(1);
+
+ encoder->stop();
+
+ QCOMPARE(encoder->recorderState(), QMediaRecorder::StoppedState);
+ QCOMPARE(stateSignal.size(), 3);
+
+ QTestEventLoop::instance().enterLoop(1);
+
+ mock->stop();
+ QCOMPARE(stateSignal.size(), 3);
+
+ mock->reset();
+}
+
+void tst_QMediaRecorder::testEncodingSettings()
+{
+ QMediaFormat format = encoder->mediaFormat();
+ QCOMPARE(format.fileFormat(), QMediaFormat::UnspecifiedFormat);
+ QCOMPARE(format.audioCodec(), QMediaFormat::AudioCodec::Unspecified);
+ QCOMPARE(format.videoCodec(), QMediaFormat::VideoCodec::Unspecified);
+ QCOMPARE(encoder->quality(), QMediaRecorder::NormalQuality);
+ QCOMPARE(encoder->encodingMode(), QMediaRecorder::ConstantQualityEncoding);
+
+ format.setAudioCodec(QMediaFormat::AudioCodec::MP3);
+ encoder->setAudioSampleRate(44100);
+ encoder->setAudioBitRate(256*1024);
+ encoder->setQuality(QMediaRecorder::HighQuality);
+ encoder->setEncodingMode(QMediaRecorder::AverageBitRateEncoding);
+
+ format.setVideoCodec(QMediaFormat::VideoCodec::H264);
+ encoder->setVideoBitRate(800);
+ encoder->setVideoFrameRate(24*1024);
+ encoder->setVideoResolution(QSize(800,600));
+ encoder->setMediaFormat(format);
+
+ QCOMPARE(encoder->mediaFormat().audioCodec(), QMediaFormat::AudioCodec::MP3);
+ QCOMPARE(encoder->audioSampleRate(), 44100);
+ QCOMPARE(encoder->audioBitRate(), 256*1024);
+ QCOMPARE(encoder->quality(), QMediaRecorder::HighQuality);
+ QCOMPARE(encoder->encodingMode(), QMediaRecorder::AverageBitRateEncoding);
+
+ QCOMPARE(encoder->mediaFormat().videoCodec(), QMediaFormat::VideoCodec::H264);
+ QCOMPARE(encoder->videoBitRate(), 800);
+ QCOMPARE(encoder->videoFrameRate(), 24*1024);
+ QCOMPARE(encoder->videoResolution(), QSize(800,600));
+}
+
+void tst_QMediaRecorder::testAudioSettings()
+{
+ QMediaRecorder recorder;
+
+ QCOMPARE(recorder.mediaFormat(), QMediaFormat());
+ QCOMPARE(recorder.mediaFormat().fileFormat(), QMediaFormat::UnspecifiedFormat);
+ QCOMPARE(recorder.audioBitRate(), -1);
+ QCOMPARE(recorder.quality(), QMediaRecorder::NormalQuality);
+ QCOMPARE(recorder.audioSampleRate(), -1);
+
+ QMediaFormat format;
+ format.setFileFormat(QMediaFormat::FLAC);
+ recorder.setMediaFormat(format);
+ QCOMPARE(recorder.mediaFormat(), format);
+
+ recorder.setAudioBitRate(128000);
+ QCOMPARE(recorder.audioBitRate(), 128000);
+
+ recorder.setQuality(QMediaRecorder::HighQuality);
+ QCOMPARE(recorder.quality(), QMediaRecorder::HighQuality);
+
+ recorder.setAudioSampleRate(44100);
+ QCOMPARE(recorder.audioSampleRate(), 44100);
+
+ QCOMPARE(recorder.audioChannelCount(), -1);
+ recorder.setAudioChannelCount(2);
+ QCOMPARE(recorder.audioChannelCount(), 2);
+}
+
+void tst_QMediaRecorder::testVideoSettings()
+{
+ QMediaRecorder recorder;
+
+ QCOMPARE(recorder.mediaFormat(), QMediaFormat());
+ QCOMPARE(recorder.mediaFormat().videoCodec(), QMediaFormat::VideoCodec::Unspecified);
+ QMediaFormat format;
+ format.setVideoCodec(QMediaFormat::VideoCodec::H265);
+ recorder.setMediaFormat(format);
+ QCOMPARE(recorder.mediaFormat(), format);
+ QCOMPARE(recorder.mediaFormat().videoCodec(), QMediaFormat::VideoCodec::H265);
+
+ QCOMPARE(recorder.videoBitRate(), -1);
+ recorder.setVideoBitRate(128000);
+ QCOMPARE(recorder.videoBitRate(), 128000);
+
+ QCOMPARE(recorder.quality(), QMediaRecorder::NormalQuality);
+ recorder.setQuality(QMediaRecorder::HighQuality);
+ QCOMPARE(recorder.quality(), QMediaRecorder::HighQuality);
+
+ QCOMPARE(recorder.videoFrameRate(), -1);
+ recorder.setVideoFrameRate(60);
+ QVERIFY(qFuzzyCompare(recorder.videoFrameRate(), qreal(60)));
+ recorder.setVideoFrameRate(24.0);
+ QVERIFY(qFuzzyCompare(recorder.videoFrameRate(), qreal(24.0)));
+
+ QCOMPARE(recorder.videoResolution(), QSize());
+ recorder.setVideoResolution(QSize(320,240));
+ QCOMPARE(recorder.videoResolution(), QSize(320,240));
+ recorder.setVideoResolution(800,600);
+ QCOMPARE(recorder.videoResolution(), QSize(800,600));
+}
+
+void tst_QMediaRecorder::testSettingsApplied()
+{
+ QMediaCaptureSession session;
+ QMediaRecorder encoder;
+ session.setRecorder(&encoder);
+
+ encoder.setVideoResolution(640,480);
+
+ //encoder settings are applied before recording if changed
+ encoder.setQuality(QMediaRecorder::VeryHighQuality);
+ encoder.record();
+
+ encoder.stop();
+}
+
+void tst_QMediaRecorder::metaData()
+{
+ QMediaCaptureSession session;
+ QCamera camera;
+ QMediaRecorder recorder;
+ session.setCamera(&camera);
+ session.setRecorder(&recorder);
+
+ QVERIFY(recorder.metaData().isEmpty());
+
+ QMediaMetaData data;
+ data.insert(QMediaMetaData::Author, QStringLiteral("John Doe"));
+ recorder.setMetaData(data);
+
+ QCOMPARE(recorder.metaData().value(QMediaMetaData::Author).toString(), QStringLiteral("John Doe"));
+}
+
+void tst_QMediaRecorder::testIsAvailable()
+{
+ {
+ QMediaCaptureSession session;
+ QCamera camera;
+ QMediaRecorder recorder;
+ session.setCamera(&camera);
+ session.setRecorder(&recorder);
+ QCOMPARE(recorder.isAvailable(), true);
+ }
+ {
+ QMediaRecorder recorder;
+ QCOMPARE(recorder.isAvailable(), false);
+ }
+}
+
+/* enum QMediaRecorder::ResourceError property test. */
+void tst_QMediaRecorder::testEnum()
+{
+ const QString errorString(QLatin1String("resource error"));
+
+ QSignalSpy spy(encoder, &QMediaRecorder::errorOccurred);
+
+ QCOMPARE(encoder->error(), QMediaRecorder::NoError);
+ QCOMPARE(encoder->errorString(), QString());
+
+ mock->updateError(QMediaRecorder::ResourceError, errorString);
+ QCOMPARE(encoder->error(), QMediaRecorder::ResourceError);
+ QCOMPARE(encoder->errorString(), errorString);
+ QCOMPARE(spy.size(), 1);
+
+ QCOMPARE(spy.last()[0].value<QMediaRecorder::Error>(), QMediaRecorder::ResourceError);
+}
+
+void tst_QMediaRecorder::testVideoSettingsQuality()
+{
+ QMediaRecorder recorder;
+ /* Verify the default value is intialised correctly*/
+ QCOMPARE(recorder.quality(), QMediaRecorder::NormalQuality);
+
+ /* Set all types of Quality parameter and Verify if it is set correctly*/
+ recorder.setQuality(QMediaRecorder::HighQuality);
+ QCOMPARE(recorder.quality(), QMediaRecorder::HighQuality);
+
+ recorder.setQuality(QMediaRecorder::VeryLowQuality);
+ QCOMPARE(recorder.quality(), QMediaRecorder::VeryLowQuality);
+
+ recorder.setQuality(QMediaRecorder::LowQuality);
+ QCOMPARE(recorder.quality(), QMediaRecorder::LowQuality);
+
+ recorder.setQuality(QMediaRecorder::VeryHighQuality);
+ QCOMPARE(recorder.quality(), QMediaRecorder::VeryHighQuality);
+}
+
+void tst_QMediaRecorder::testVideoSettingsEncodingMode()
+{
+ QMediaRecorder recorder;
+
+ /* Verify the default values are initialised correctly*/
+ QCOMPARE(recorder.encodingMode(), QMediaRecorder::ConstantQualityEncoding);
+
+ /* Set each type of encoding mode and Verify if it is set correctly*/
+ recorder.setEncodingMode(QMediaRecorder::ConstantBitRateEncoding);
+ QCOMPARE(recorder.encodingMode(),QMediaRecorder::ConstantBitRateEncoding);
+
+ recorder.setEncodingMode(QMediaRecorder::AverageBitRateEncoding);
+ QCOMPARE(recorder.encodingMode(), QMediaRecorder::AverageBitRateEncoding);
+}
+
+void tst_QMediaRecorder::testApplicationInative()
+{
+ QMediaCaptureSession session;
+ QMediaRecorder encoder;
+ session.setRecorder(&encoder);
+
+ encoder.setVideoResolution(640, 480);
+ encoder.setQuality(QMediaRecorder::VeryHighQuality);
+
+ encoder.setOutputLocation(QUrl("test.tmp"));
+ QCOMPARE(encoder.outputLocation().toString(), QStringLiteral("test.tmp"));
+ QCOMPARE(encoder.actualLocation(), QUrl());
+
+ encoder.record();
+
+ QGuiApplicationPrivate::setApplicationState(Qt::ApplicationInactive);
+ QCoreApplication::processEvents();
+
+ QGuiApplicationPrivate::setApplicationState(Qt::ApplicationActive);
+ QCoreApplication::processEvents();
+
+ encoder.stop();
+
+ // the actual location is available after record
+ QCOMPARE(encoder.actualLocation().toString(), QStringLiteral("test.tmp"));
+}
+
+QTEST_GUILESS_MAIN(tst_QMediaRecorder)
+#include "tst_qmediarecorder.moc"
diff --git a/tests/auto/unit/multimedia/qmediatimerange/CMakeLists.txt b/tests/auto/unit/multimedia/qmediatimerange/CMakeLists.txt
new file mode 100644
index 000000000..507eb16fa
--- /dev/null
+++ b/tests/auto/unit/multimedia/qmediatimerange/CMakeLists.txt
@@ -0,0 +1,16 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+# Generated from qmediatimerange.pro.
+
+#####################################################################
+## tst_qmediatimerange Test:
+#####################################################################
+
+qt_internal_add_test(tst_qmediatimerange
+ SOURCES
+ tst_qmediatimerange.cpp
+ LIBRARIES
+ Qt::Gui
+ Qt::MultimediaPrivate
+)
diff --git a/tests/auto/unit/qmediatimerange/tst_qmediatimerange.cpp b/tests/auto/unit/multimedia/qmediatimerange/tst_qmediatimerange.cpp
index 439ff8f4d..750b72108 100644
--- a/tests/auto/unit/qmediatimerange/tst_qmediatimerange.cpp
+++ b/tests/auto/unit/multimedia/qmediatimerange/tst_qmediatimerange.cpp
@@ -1,32 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//TESTED_COMPONENT=src/multimedia
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtTest/QtTest>
#include <QtCore/qdebug.h>
@@ -65,20 +38,20 @@ void tst_QMediaTimeRange::testIntervalCtor()
{
//Default Ctor for Time Interval
/* create an instance for the time interval and verify the default cases */
- QMediaTimeInterval tInter;
+ QMediaTimeRange::Interval tInter;
QVERIFY(tInter.isNormal());
QVERIFY(tInter.start() == 0);
QVERIFY(tInter.end() == 0);
// (qint, qint) Ctor time interval
- /* create an instace of QMediaTimeInterval passing start and end times and verify the all possible scenario's*/
- QMediaTimeInterval time(20,50);
+ /* create an instace of QMediaTimeRange::Interval passing start and end times and verify the all possible scenario's*/
+ QMediaTimeRange::Interval time(20,50);
QVERIFY(time.isNormal());
QVERIFY(time.start() == 20);
QVERIFY(time.end() == 50);
// Copy Ctor Time interval
- QMediaTimeInterval other(time);
+ QMediaTimeRange::Interval other(time);
QVERIFY(other.isNormal() == time.isNormal());
QVERIFY(other.start() == time.start());
QVERIFY(other.end() == time.end());
@@ -88,7 +61,7 @@ void tst_QMediaTimeRange::testIntervalCtor()
void tst_QMediaTimeRange::testIntervalContains()
{
- QMediaTimeInterval time(20,50);
+ QMediaTimeRange::Interval time(20,50);
/* start() <= time <= end(). Returns true if the time interval contains the specified time. */
QVERIFY(!time.contains(10));
@@ -97,7 +70,7 @@ void tst_QMediaTimeRange::testIntervalContains()
QVERIFY(time.contains(50));
QVERIFY(!time.contains(60));
- QMediaTimeInterval x(20, 10); // denormal
+ QMediaTimeRange::Interval x(20, 10); // denormal
// Check denormal ranges
QVERIFY(!x.contains(5));
@@ -106,7 +79,7 @@ void tst_QMediaTimeRange::testIntervalContains()
QVERIFY(x.contains(20));
QVERIFY(!x.contains(25));
- QMediaTimeInterval y = x.normalized();
+ QMediaTimeRange::Interval y = x.normalized();
QVERIFY(!y.contains(5));
QVERIFY(y.contains(10));
QVERIFY(y.contains(15));
@@ -129,7 +102,7 @@ void tst_QMediaTimeRange::testCtor()
QVERIFY(b.latestTime() == 20);
// Interval Ctor
- QMediaTimeRange c(QMediaTimeInterval(30, 40));
+ QMediaTimeRange c(QMediaTimeRange::Interval(30, 40));
QVERIFY(!c.isEmpty());
QVERIFY(c.isContinuous());
@@ -137,7 +110,7 @@ void tst_QMediaTimeRange::testCtor()
QVERIFY(c.latestTime() == 40);
// Abnormal Interval Ctor
- QMediaTimeRange d(QMediaTimeInterval(20, 10));
+ QMediaTimeRange d(QMediaTimeRange::Interval(20, 10));
QVERIFY(d.isEmpty());
@@ -170,7 +143,7 @@ void tst_QMediaTimeRange::testGetters()
// isEmpty + isContinuous + intervals + start + end
QVERIFY(!x.isEmpty());
QVERIFY(!x.isContinuous());
- QVERIFY(x.intervals().count() == 2);
+ QVERIFY(x.intervals().size() == 2);
QVERIFY(x.intervals()[0].start() == 10);
QVERIFY(x.intervals()[0].end() == 20);
QVERIFY(x.intervals()[1].start() == 30);
@@ -190,7 +163,7 @@ void tst_QMediaTimeRange::testAssignment()
QVERIFY(x.latestTime() == 20);
// Interval Assignment
- x = QMediaTimeInterval(30, 40);
+ x = QMediaTimeRange::Interval(30, 40);
QVERIFY(!x.isEmpty());
QVERIFY(x.isContinuous());
@@ -211,13 +184,13 @@ void tst_QMediaTimeRange::testAssignment()
void tst_QMediaTimeRange::testIntervalNormalize()
{
- QMediaTimeInterval x(20, 10);
+ QMediaTimeRange::Interval x(20, 10);
QVERIFY(!x.isNormal());
QVERIFY(x.start() == 20);
QVERIFY(x.end() == 10);
- QMediaTimeInterval y = x.normalized();
+ QMediaTimeRange::Interval y = x.normalized();
QVERIFY(y.isNormal());
QVERIFY(y.start() == 10);
@@ -227,7 +200,7 @@ void tst_QMediaTimeRange::testIntervalNormalize()
void tst_QMediaTimeRange::testIntervalTranslate()
{
- QMediaTimeInterval x(10, 20);
+ QMediaTimeRange::Interval x(10, 20);
x = x.translated(10);
QVERIFY(x.start() == 20);
@@ -277,7 +250,7 @@ void tst_QMediaTimeRange::testContains()
QVERIFY(!x.contains(30));
// Test over a concrete interval
- QMediaTimeInterval y(10, 20);
+ QMediaTimeRange::Interval y(10, 20);
QVERIFY(y.contains(15));
QVERIFY(y.contains(10));
QVERIFY(y.contains(20));
@@ -316,7 +289,7 @@ void tst_QMediaTimeRange::testAddInterval()
QVERIFY(!x.isEmpty());
QVERIFY(!x.isContinuous());
- QVERIFY(x.intervals().count() == 2);
+ QVERIFY(x.intervals().size() == 2);
QVERIFY(x.intervals()[0].start() == 10);
QVERIFY(x.intervals()[0].end() == 40);
QVERIFY(x.intervals()[1].start() == 50);
@@ -346,9 +319,9 @@ void tst_QMediaTimeRange::testAddInterval()
// Interval Parameter - All intervals Overlap
x = QMediaTimeRange();
- x.addInterval(QMediaTimeInterval(10, 40));
- x.addInterval(QMediaTimeInterval(30, 50));
- x.addInterval(QMediaTimeInterval(20, 60));
+ x.addInterval(QMediaTimeRange::Interval(10, 40));
+ x.addInterval(QMediaTimeRange::Interval(30, 50));
+ x.addInterval(QMediaTimeRange::Interval(20, 60));
QVERIFY(!x.isEmpty());
QVERIFY(x.isContinuous());
@@ -357,7 +330,7 @@ void tst_QMediaTimeRange::testAddInterval()
// Interval Parameter - Abnormal Interval
x = QMediaTimeRange();
- x.addInterval(QMediaTimeInterval(20, 10));
+ x.addInterval(QMediaTimeRange::Interval(20, 10));
QVERIFY(x.isEmpty());
}
@@ -466,7 +439,7 @@ void tst_QMediaTimeRange::testRemoveInterval()
QVERIFY(!x.isEmpty());
QVERIFY(!x.isContinuous());
- QVERIFY(x.intervals().count() == 2);
+ QVERIFY(x.intervals().size() == 2);
QVERIFY(x.intervals()[0].start() == 10);
QVERIFY(x.intervals()[0].end() == 19);
QVERIFY(x.intervals()[1].start() == 41);
@@ -514,7 +487,7 @@ void tst_QMediaTimeRange::testRemoveInterval()
QVERIFY(!x.isEmpty());
QVERIFY(!x.isContinuous());
- QVERIFY(x.intervals().count() == 2);
+ QVERIFY(x.intervals().size() == 2);
QVERIFY(x.intervals()[0].start() == 10);
QVERIFY(x.intervals()[0].end() == 14);
QVERIFY(x.intervals()[1].start() == 36);
@@ -532,11 +505,11 @@ void tst_QMediaTimeRange::testRemoveInterval()
// Interval Parameter - Removing an interval, causing a split
x = QMediaTimeRange();
x.addInterval(10, 50);
- x.removeInterval(QMediaTimeInterval(20, 40));
+ x.removeInterval(QMediaTimeRange::Interval(20, 40));
QVERIFY(!x.isEmpty());
QVERIFY(!x.isContinuous());
- QVERIFY(x.intervals().count() == 2);
+ QVERIFY(x.intervals().size() == 2);
QVERIFY(x.intervals()[0].start() == 10);
QVERIFY(x.intervals()[0].end() == 19);
QVERIFY(x.intervals()[1].start() == 41);
@@ -545,7 +518,7 @@ void tst_QMediaTimeRange::testRemoveInterval()
// Interval Parameter - Abnormal Interval
x = QMediaTimeRange();
x.addInterval(10, 40);
- x.removeInterval(QMediaTimeInterval(30, 20));
+ x.removeInterval(QMediaTimeRange::Interval(30, 20));
QVERIFY(!x.isEmpty());
QVERIFY(x.isContinuous());
@@ -597,7 +570,7 @@ void tst_QMediaTimeRange::testRemoveTimeRange()
QVERIFY(!b.isEmpty());
QVERIFY(!b.isContinuous());
- QVERIFY(b.intervals().count() == 2);
+ QVERIFY(b.intervals().size() == 2);
QVERIFY(b.intervals()[0].start() == 10);
QVERIFY(b.intervals()[0].end() == 19);
QVERIFY(b.intervals()[1].start() == 51);
@@ -618,7 +591,7 @@ void tst_QMediaTimeRange::testRemoveTimeRange()
QVERIFY(!b.isEmpty());
QVERIFY(!b.isContinuous());
- QVERIFY(b.intervals().count() == 2);
+ QVERIFY(b.intervals().size() == 2);
QVERIFY(b.intervals()[0].start() == 10);
QVERIFY(b.intervals()[0].end() == 19);
QVERIFY(b.intervals()[1].start() == 91);
@@ -679,10 +652,10 @@ void tst_QMediaTimeRange::testClear()
void tst_QMediaTimeRange::testComparisons()
{
// Interval equality
- QVERIFY(QMediaTimeInterval(10, 20) == QMediaTimeInterval(10, 20));
- QVERIFY(QMediaTimeInterval(10, 20) != QMediaTimeInterval(10, 30));
- QVERIFY(!(QMediaTimeInterval(10, 20) != QMediaTimeInterval(10, 20)));
- QVERIFY(!(QMediaTimeInterval(10, 20) == QMediaTimeInterval(10, 30)));
+ QVERIFY(QMediaTimeRange::Interval(10, 20) == QMediaTimeRange::Interval(10, 20));
+ QVERIFY(QMediaTimeRange::Interval(10, 20) != QMediaTimeRange::Interval(10, 30));
+ QVERIFY(!(QMediaTimeRange::Interval(10, 20) != QMediaTimeRange::Interval(10, 20)));
+ QVERIFY(!(QMediaTimeRange::Interval(10, 20) == QMediaTimeRange::Interval(10, 30)));
// Time range equality - Single Interval
QMediaTimeRange a(10, 20), b(20, 30), c(10, 20);
@@ -732,27 +705,27 @@ void tst_QMediaTimeRange::testArithmetic()
QVERIFY(a.latestTime() == 19);
// Test += and -= on intervals
- a -= QMediaTimeInterval(10, 20);
- a += QMediaTimeInterval(40, 50);
+ a -= QMediaTimeRange::Interval(10, 20);
+ a += QMediaTimeRange::Interval(40, 50);
QVERIFY(a.isContinuous());
QVERIFY(a.earliestTime() == 40);
QVERIFY(a.latestTime() == 50);
// Test Interval + Interval
- a = QMediaTimeInterval(10, 20) + QMediaTimeInterval(20, 30);
+ a = QMediaTimeRange::Interval(10, 20) + QMediaTimeRange::Interval(20, 30);
QVERIFY(a.isContinuous());
QVERIFY(a.earliestTime() == 10);
QVERIFY(a.latestTime() == 30);
// Test Range + Interval
- a = a + QMediaTimeInterval(30, 40);
+ a = a + QMediaTimeRange::Interval(30, 40);
QVERIFY(a.isContinuous());
QVERIFY(a.earliestTime() == 10);
QVERIFY(a.latestTime() == 40);
// Test Interval + Range
- a = QMediaTimeInterval(40, 50) + a;
+ a = QMediaTimeRange::Interval(40, 50) + a;
QVERIFY(a.isContinuous());
QVERIFY(a.earliestTime() == 10);
QVERIFY(a.latestTime() == 50);
@@ -764,7 +737,7 @@ void tst_QMediaTimeRange::testArithmetic()
QVERIFY(a.latestTime() == 60);
// Test Range - Interval
- a = a - QMediaTimeInterval(50, 60);
+ a = a - QMediaTimeRange::Interval(50, 60);
QVERIFY(a.isContinuous());
QVERIFY(a.earliestTime() == 10);
QVERIFY(a.latestTime() == 49);
@@ -776,13 +749,13 @@ void tst_QMediaTimeRange::testArithmetic()
QVERIFY(a.latestTime() == 39);
// Test Interval - Range
- b = QMediaTimeInterval(0, 20) - a;
+ b = QMediaTimeRange::Interval(0, 20) - a;
QVERIFY(b.isContinuous());
QVERIFY(b.earliestTime() == 0);
QVERIFY(b.latestTime() == 9);
// Test Interval - Interval
- a = QMediaTimeInterval(10, 20) - QMediaTimeInterval(15, 30);
+ a = QMediaTimeRange::Interval(10, 20) - QMediaTimeRange::Interval(15, 30);
QVERIFY(a.isContinuous());
QVERIFY(a.earliestTime() == 10);
QVERIFY(a.latestTime() == 14);
diff --git a/tests/auto/unit/multimedia/qmultimediautils/CMakeLists.txt b/tests/auto/unit/multimedia/qmultimediautils/CMakeLists.txt
new file mode 100644
index 000000000..2dd805271
--- /dev/null
+++ b/tests/auto/unit/multimedia/qmultimediautils/CMakeLists.txt
@@ -0,0 +1,9 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+qt_internal_add_test(tst_qmultimediautils
+ SOURCES
+ tst_qmultimediautils.cpp
+ LIBRARIES
+ Qt::MultimediaPrivate
+)
diff --git a/tests/auto/unit/multimedia/qmultimediautils/tst_qmultimediautils.cpp b/tests/auto/unit/multimedia/qmultimediautils/tst_qmultimediautils.cpp
new file mode 100644
index 000000000..8ed54ac64
--- /dev/null
+++ b/tests/auto/unit/multimedia/qmultimediautils/tst_qmultimediautils.cpp
@@ -0,0 +1,184 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QtTest/QtTest>
+#include <QDebug>
+#include <private/qmultimediautils_p.h>
+#include <qvideoframeformat.h>
+
+class tst_QMultimediaUtils : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void fraction_of_0();
+ void fraction_of_negative_1_5();
+ void fraction_of_1_5();
+ void fraction_of_30();
+ void fraction_of_29_97();
+ void fraction_of_lower_boundary();
+ void fraction_of_upper_boundary();
+
+ void qRotatedFrameSize_returnsSizeAccordinglyToRotation();
+
+ void qMediaFromUserInput_addsFilePrefix_whenCalledWithLocalFile();
+
+ void qGetRequiredSwapChainFormat_returnsSdr_whenMaxLuminanceIsBelowSdrThreshold_data();
+ void qGetRequiredSwapChainFormat_returnsSdr_whenMaxLuminanceIsBelowSdrThreshold();
+ void qGetRequiredSwapChainFormat_returnsHdr_whenMaxLuminanceIsBelowHdrThreshold_data();
+ void qGetRequiredSwapChainFormat_returnsHdr_whenMaxLuminanceIsBelowHdrThreshold();
+
+ void qShouldUpdateSwapChainFormat_returnsFalse_whenSwapChainIsNullPointer();
+};
+
+void tst_QMultimediaUtils::fraction_of_0()
+{
+ auto [n, d] = qRealToFraction(0.);
+ QCOMPARE(n, 0);
+ QCOMPARE(d, 1);
+}
+
+void tst_QMultimediaUtils::fraction_of_negative_1_5()
+{
+ auto [n, d] = qRealToFraction(-1.5);
+ QCOMPARE(double(n) / double(d), -1.5);
+ QCOMPARE(n, -3);
+ QCOMPARE(d, 2);
+}
+
+void tst_QMultimediaUtils::fraction_of_1_5()
+{
+ auto [n, d] = qRealToFraction(1.5);
+ QCOMPARE(double(n) / double(d), 1.5);
+ QCOMPARE(n, 3);
+ QCOMPARE(d, 2);
+}
+
+void tst_QMultimediaUtils::fraction_of_30()
+{
+ auto [n, d] = qRealToFraction(30.);
+ QCOMPARE(double(n) / double(d), 30.);
+ QCOMPARE(d, 1);
+}
+
+void tst_QMultimediaUtils::fraction_of_29_97()
+{
+ auto [n, d] = qRealToFraction(29.97);
+ QCOMPARE(double(n) / double(d), 29.97);
+}
+
+void tst_QMultimediaUtils::fraction_of_lower_boundary()
+{
+ double f = 0.000001;
+ auto [n, d] = qRealToFraction(f);
+ QVERIFY(double(n) / double(d) < f);
+ QVERIFY(double(n) / double(d) >= 0.);
+}
+
+void tst_QMultimediaUtils::fraction_of_upper_boundary()
+{
+ double f = 0.999999;
+ auto [n, d] = qRealToFraction(f);
+ QVERIFY(double(n) / double(d) <= 1.);
+ QVERIFY(double(n) / double(d) > f);
+}
+
+void tst_QMultimediaUtils::qRotatedFrameSize_returnsSizeAccordinglyToRotation()
+{
+ QCOMPARE(qRotatedFrameSize({ 10, 22 }, 0), QSize(10, 22));
+ QCOMPARE(qRotatedFrameSize({ 10, 23 }, -180), QSize(10, 23));
+ QCOMPARE(qRotatedFrameSize({ 10, 24 }, 180), QSize(10, 24));
+ QCOMPARE(qRotatedFrameSize({ 10, 25 }, 360), QSize(10, 25));
+ QCOMPARE(qRotatedFrameSize({ 11, 26 }, 540), QSize(11, 26));
+
+ QCOMPARE(qRotatedFrameSize({ 10, 22 }, -90), QSize(22, 10));
+ QCOMPARE(qRotatedFrameSize({ 10, 23 }, 90), QSize(23, 10));
+ QCOMPARE(qRotatedFrameSize({ 10, 24 }, 270), QSize(24, 10));
+ QCOMPARE(qRotatedFrameSize({ 10, 25 }, 450), QSize(25, 10));
+
+ QCOMPARE(qRotatedFrameSize({ 10, 22 }, QtVideo::Rotation::None), QSize(10, 22));
+ QCOMPARE(qRotatedFrameSize({ 10, 22 }, QtVideo::Rotation::Clockwise180), QSize(10, 22));
+
+ QCOMPARE(qRotatedFrameSize({ 11, 22 }, QtVideo::Rotation::Clockwise90), QSize(22, 11));
+ QCOMPARE(qRotatedFrameSize({ 11, 22 }, QtVideo::Rotation::Clockwise270), QSize(22, 11));
+}
+
+void tst_QMultimediaUtils::qMediaFromUserInput_addsFilePrefix_whenCalledWithLocalFile()
+{
+ using namespace Qt::Literals;
+
+ QCOMPARE(qMediaFromUserInput(QUrl(u"/foo/bar/baz"_s)), QUrl(u"file:///foo/bar/baz"_s));
+ QCOMPARE(qMediaFromUserInput(QUrl::fromLocalFile(u"C:/foo/bar/baz"_s)),
+ QUrl(u"file:///C:/foo/bar/baz"_s));
+ QCOMPARE(qMediaFromUserInput(QUrl(u"file:///foo/bar/baz"_s)), QUrl(u"file:///foo/bar/baz"_s));
+ QCOMPARE(qMediaFromUserInput(QUrl(u"http://foo/bar/baz"_s)), QUrl(u"http://foo/bar/baz"_s));
+
+ QCOMPARE(qMediaFromUserInput(QUrl(u"foo/bar/baz"_s)),
+ QUrl::fromLocalFile(QDir::currentPath() + u"/foo/bar/baz"_s));
+}
+
+void tst_QMultimediaUtils::
+ qGetRequiredSwapChainFormat_returnsSdr_whenMaxLuminanceIsBelowSdrThreshold_data()
+{
+ QTest::addColumn<float>("maxLuminance");
+
+ QTest::newRow("0") << 0.0f;
+ QTest::newRow("80") << 80.0f;
+ QTest::newRow("100") << 100.0f;
+}
+
+void tst_QMultimediaUtils::
+ qGetRequiredSwapChainFormat_returnsSdr_whenMaxLuminanceIsBelowSdrThreshold()
+{
+ // Arrange
+ QFETCH(float, maxLuminance);
+
+ QVideoFrameFormat format;
+ format.setMaxLuminance(maxLuminance);
+
+ // Act
+ QRhiSwapChain::Format requiredSwapChainFormat = qGetRequiredSwapChainFormat(format);
+
+ // Assert
+ QCOMPARE(requiredSwapChainFormat, QRhiSwapChain::Format::SDR);
+}
+
+void tst_QMultimediaUtils::
+ qGetRequiredSwapChainFormat_returnsHdr_whenMaxLuminanceIsBelowHdrThreshold_data()
+{
+ QTest::addColumn<float>("maxLuminance");
+
+ QTest::newRow("101") << 101.0f;
+ QTest::newRow("300") << 300.0f;
+ QTest::newRow("1600") << 1600.0f;
+}
+
+void tst_QMultimediaUtils::
+ qGetRequiredSwapChainFormat_returnsHdr_whenMaxLuminanceIsBelowHdrThreshold()
+{
+ // Arrange
+ QVideoFrameFormat format;
+ format.setMaxLuminance(300.0f);
+
+ // Act
+ QRhiSwapChain::Format requiredSwapChainFormat = qGetRequiredSwapChainFormat(format);
+
+ // Assert
+ QCOMPARE(requiredSwapChainFormat, QRhiSwapChain::Format::HDRExtendedSrgbLinear);
+}
+
+void tst_QMultimediaUtils::qShouldUpdateSwapChainFormat_returnsFalse_whenSwapChainIsNullPointer()
+{
+ // Arrange
+ QRhiSwapChain *swapChain = nullptr;
+ QRhiSwapChain::Format requiredSwapChainFormat = QRhiSwapChain::Format::SDR;
+
+ // Act
+ bool shouldUpdate = qShouldUpdateSwapChainFormat(swapChain, requiredSwapChainFormat);
+
+ // Assert
+ QCOMPARE(shouldUpdate, false);
+}
+
+QTEST_MAIN(tst_QMultimediaUtils)
+#include "tst_qmultimediautils.moc"
diff --git a/tests/auto/unit/multimedia/qsamplecache/CMakeLists.txt b/tests/auto/unit/multimedia/qsamplecache/CMakeLists.txt
new file mode 100644
index 000000000..2f58c1f6e
--- /dev/null
+++ b/tests/auto/unit/multimedia/qsamplecache/CMakeLists.txt
@@ -0,0 +1,23 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+# Generated from qsamplecache.pro.
+
+#####################################################################
+## tst_qsamplecache Test:
+#####################################################################
+
+# Collect test data
+file(GLOB_RECURSE test_data_glob
+ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
+ testdata/*)
+list(APPEND test_data ${test_data_glob})
+
+qt_internal_add_test(tst_qsamplecache
+ SOURCES
+ tst_qsamplecache.cpp
+ LIBRARIES
+ Qt::Gui
+ Qt::MultimediaPrivate
+ TESTDATA ${test_data}
+)
diff --git a/tests/auto/unit/qsamplecache/testdata/test.wav b/tests/auto/unit/multimedia/qsamplecache/testdata/test.wav
index 4dd022661..4dd022661 100644
--- a/tests/auto/unit/qsamplecache/testdata/test.wav
+++ b/tests/auto/unit/multimedia/qsamplecache/testdata/test.wav
Binary files differ
diff --git a/tests/auto/unit/qsamplecache/testdata/test2.wav b/tests/auto/unit/multimedia/qsamplecache/testdata/test2.wav
index 4dd022661..4dd022661 100644
--- a/tests/auto/unit/qsamplecache/testdata/test2.wav
+++ b/tests/auto/unit/multimedia/qsamplecache/testdata/test2.wav
Binary files differ
diff --git a/tests/auto/unit/qsamplecache/tst_qsamplecache.cpp b/tests/auto/unit/multimedia/qsamplecache/tst_qsamplecache.cpp
index bae68a9d5..311d05a5a 100644
--- a/tests/auto/unit/qsamplecache/tst_qsamplecache.cpp
+++ b/tests/auto/unit/multimedia/qsamplecache/tst_qsamplecache.cpp
@@ -1,32 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//TESTED_COMPONENT=src/multimedia
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtTest/QtTest>
#include <private/qsamplecache_p.h>
@@ -52,19 +25,15 @@ private:
void tst_QSampleCache::testCachedSample()
{
QSampleCache cache;
- QSignalSpy loadingSpy(&cache, SIGNAL(isLoadingChanged()));
QSample* sample = cache.requestSample(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test.wav")));
QVERIFY(sample);
- QTRY_COMPARE(loadingSpy.count(), 2);
QTRY_VERIFY(!cache.isLoading());
- loadingSpy.clear();
QSample* sampleCached = cache.requestSample(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test.wav")));
QCOMPARE(sample, sampleCached); // sample is cached
QVERIFY(cache.isCached(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test.wav"))));
// loading thread still starts, but does nothing in this case
- QTRY_COMPARE(loadingSpy.count(), 2);
QTRY_VERIFY(!cache.isLoading());
sample->release();
@@ -74,11 +43,10 @@ void tst_QSampleCache::testCachedSample()
void tst_QSampleCache::testNotCachedSample()
{
QSampleCache cache;
- QSignalSpy loadingSpy(&cache, SIGNAL(isLoadingChanged()));
QSample* sample = cache.requestSample(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test.wav")));
QVERIFY(sample);
- QTRY_COMPARE(loadingSpy.count(), 2);
+ QVERIFY(cache.isLoading());
QTRY_VERIFY(!cache.isLoading());
sample->release();
@@ -88,11 +56,10 @@ void tst_QSampleCache::testNotCachedSample()
void tst_QSampleCache::testEnoughCapacity()
{
QSampleCache cache;
- QSignalSpy loadingSpy(&cache, SIGNAL(isLoadingChanged()));
QSample* sample = cache.requestSample(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test.wav")));
QVERIFY(sample);
- QTRY_COMPARE(loadingSpy.count(), 2); // make sure sample is loaded
+ QVERIFY(cache.isLoading());
QTRY_VERIFY(!cache.isLoading());
int sampleSize = sample->data().size();
sample->release();
@@ -100,33 +67,29 @@ void tst_QSampleCache::testEnoughCapacity()
QVERIFY(!cache.isCached(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test.wav"))));
- loadingSpy.clear();
sample = cache.requestSample(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test.wav")));
QVERIFY(sample);
- QTRY_COMPARE(loadingSpy.count(), 2);
+ QVERIFY(cache.isLoading());
QTRY_VERIFY(!cache.isLoading());
sample->release();
QVERIFY(cache.isCached(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test.wav"))));
// load another sample and make sure first sample is not destroyed
- loadingSpy.clear();
QSample* sampleOther = cache.requestSample(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test2.wav")));
QVERIFY(sampleOther);
- QTRY_COMPARE(loadingSpy.count(), 2);
+ QVERIFY(cache.isLoading());
QTRY_VERIFY(!cache.isLoading());
sampleOther->release();
QVERIFY(cache.isCached(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test.wav"))));
QVERIFY(cache.isCached(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test2.wav"))));
- loadingSpy.clear();
QSample* sampleCached = cache.requestSample(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test.wav")));
QCOMPARE(sample, sampleCached); // sample is cached
QVERIFY(cache.isCached(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test.wav"))));
QVERIFY(cache.isCached(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test2.wav"))));
- QTRY_COMPARE(loadingSpy.count(), 2);
- QTRY_VERIFY(!cache.isLoading());
+ QVERIFY(!cache.isLoading());
sampleCached->release();
}
@@ -134,11 +97,10 @@ void tst_QSampleCache::testEnoughCapacity()
void tst_QSampleCache::testNotEnoughCapacity()
{
QSampleCache cache;
- QSignalSpy loadingSpy(&cache, SIGNAL(isLoadingChanged()));
QSample* sample = cache.requestSample(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test.wav")));
QVERIFY(sample);
- QTRY_COMPARE(loadingSpy.count(), 2); // make sure sample is loaded
+ QVERIFY(cache.isLoading());
QTRY_VERIFY(!cache.isLoading());
int sampleSize = sample->data().size();
sample->release();
@@ -146,20 +108,18 @@ void tst_QSampleCache::testNotEnoughCapacity()
QVERIFY(!cache.isCached(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test.wav"))));
- loadingSpy.clear();
sample = cache.requestSample(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test.wav")));
QVERIFY(sample);
- QTRY_COMPARE(loadingSpy.count(), 2);
+ QVERIFY(cache.isLoading());
QTRY_VERIFY(!cache.isLoading());
sample->release();
QVERIFY(cache.isCached(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test.wav"))));
// load another sample to force sample cache to destroy first sample
- loadingSpy.clear();
QSample* sampleOther = cache.requestSample(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test2.wav")));
QVERIFY(sampleOther);
- QTRY_COMPARE(loadingSpy.count(), 2);
+ QVERIFY(cache.isLoading());
QTRY_VERIFY(!cache.isLoading());
sampleOther->release();
@@ -169,13 +129,11 @@ void tst_QSampleCache::testNotEnoughCapacity()
void tst_QSampleCache::testInvalidFile()
{
QSampleCache cache;
- QSignalSpy loadingSpy(&cache, SIGNAL(isLoadingChanged()));
QSample* sample = cache.requestSample(QUrl::fromLocalFile("invalid"));
QVERIFY(sample);
QTRY_COMPARE(sample->state(), QSample::Error);
- QTRY_COMPARE(loadingSpy.count(), 2);
- QTRY_VERIFY(!cache.isLoading());
+ QVERIFY(!cache.isLoading());
sample->release();
QVERIFY(!cache.isCached(QUrl::fromLocalFile("invalid")));
diff --git a/tests/auto/unit/multimedia/qscreencapture/CMakeLists.txt b/tests/auto/unit/multimedia/qscreencapture/CMakeLists.txt
new file mode 100644
index 000000000..f5b152034
--- /dev/null
+++ b/tests/auto/unit/multimedia/qscreencapture/CMakeLists.txt
@@ -0,0 +1,18 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+#####################################################################
+## tst_qscreencapture Test:
+#####################################################################
+
+qt_internal_add_test(tst_qscreencapture
+ SOURCES
+ tst_qscreencapture.cpp
+ INCLUDE_DIRECTORIES
+ ../../mockbackend
+ LIBRARIES
+ # Remove: L${CMAKE_CURRENT_SOURCE_DIR}
+ Qt::Gui
+ Qt::MultimediaPrivate
+ MockMultimediaPlugin
+)
diff --git a/tests/auto/unit/multimedia/qscreencapture/tst_qscreencapture.cpp b/tests/auto/unit/multimedia/qscreencapture/tst_qscreencapture.cpp
new file mode 100644
index 000000000..ad574ddf6
--- /dev/null
+++ b/tests/auto/unit/multimedia/qscreencapture/tst_qscreencapture.cpp
@@ -0,0 +1,64 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+// TESTED_COMPONENT=src/multimedia
+
+#include <QtTest/QtTest>
+#include <QDebug>
+
+#include "qmockintegration.h"
+#include "qscreencapture.h"
+#include "qmocksurfacecapture.h"
+#include "qatomic.h"
+
+QT_USE_NAMESPACE
+
+Q_ENABLE_MOCK_MULTIMEDIA_PLUGIN
+
+class tst_QScreenCapture : public QObject
+{
+ Q_OBJECT
+
+private:
+ // Use custom waiting instead of QSignalSpy since the spy tries copying not sharable object
+ // QVideoFrame to QVariant and gets an assert
+ bool waitForFrame(QPlatformSurfaceCapture &psc)
+ {
+ QAtomicInteger<bool> newFrameReceived = false;
+ QObject o;
+ auto connection = connect(&psc, &QPlatformSurfaceCapture::newVideoFrame, &o,
+ [&newFrameReceived]() { newFrameReceived = true; });
+
+ return QTest::qWaitFor([&newFrameReceived]() { return newFrameReceived; });
+ }
+
+private slots:
+ void destructionOfActiveCapture();
+
+};
+
+void tst_QScreenCapture::destructionOfActiveCapture()
+{
+ // Run a few times in order to catch random UB on deletion
+ for (int i = 0; i < 10; ++i) {
+ auto sc = std::make_unique<QScreenCapture>();
+ QPointer<QPlatformSurfaceCapture> psc = QMockIntegration::instance()->lastScreenCapture();
+ QVERIFY(psc);
+
+ sc->setActive(true);
+
+ QVERIFY(waitForFrame(*psc));
+
+ QSignalSpy spy(sc.get(), &QScreenCapture::activeChanged);
+
+ psc->setParent(nullptr);
+ sc.reset();
+
+ QVERIFY2(spy.empty(), "No signals from QScreenCapture are expected on deletion");
+ QVERIFY2(!psc, "Platform screen capture must be deleted whether or not it has a parent");
+ }
+}
+
+QTEST_MAIN(tst_QScreenCapture)
+
+#include "tst_qscreencapture.moc"
diff --git a/tests/auto/unit/multimedia/qvideobuffers/CMakeLists.txt b/tests/auto/unit/multimedia/qvideobuffers/CMakeLists.txt
new file mode 100644
index 000000000..765d02c96
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideobuffers/CMakeLists.txt
@@ -0,0 +1,10 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+qt_internal_add_test(tst_qvideobuffers
+ SOURCES
+ tst_qvideobuffers.cpp
+ LIBRARIES
+ Qt::Multimedia
+ Qt::MultimediaPrivate
+)
diff --git a/tests/auto/unit/multimedia/qvideobuffers/tst_qvideobuffers.cpp b/tests/auto/unit/multimedia/qvideobuffers/tst_qvideobuffers.cpp
new file mode 100644
index 000000000..b93e9d666
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideobuffers/tst_qvideobuffers.cpp
@@ -0,0 +1,252 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QtTest/QtTest>
+
+#include <private/qmemoryvideobuffer_p.h>
+#include <private/qimagevideobuffer_p.h>
+#include "qvideoframeformat.h"
+
+using BufferPtr = std::shared_ptr<QAbstractVideoBuffer>;
+using MapModes = std::vector<QtVideo::MapMode>;
+
+static const MapModes validMapModes = { QtVideo::MapMode::ReadOnly, QtVideo::MapMode::WriteOnly, QtVideo::MapMode::ReadWrite };
+
+class tst_QVideoBuffers : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QVideoBuffers() {}
+public slots:
+ void initTestCase();
+
+private slots:
+ void map_changesMappedStateAndReturnsProperMappings_whenBufferIsNotMapped_data();
+ void map_changesMappedStateAndReturnsProperMappings_whenBufferIsNotMapped();
+
+ void map_doesNothing_whenBufferIsMapped_data();
+ void map_doesNothing_whenBufferIsMapped();
+
+ void mapMemoryOrImageBuffer_detachesDataDependingOnMode_data();
+ void mapMemoryOrImageBuffer_detachesDataDependingOnMode();
+
+ void unmap_resetsMappedState_whenBufferIsMapped_data();
+ void unmap_resetsMappedState_whenBufferIsMapped();
+
+ void imageBuffer_fixesInputImage_data();
+ void imageBuffer_fixesInputImage();
+
+private:
+ QString mapModeToString(QtVideo::MapMode mapMode) const
+ {
+ switch (mapMode) {
+ case QtVideo::MapMode::NotMapped:
+ return QLatin1String("NotMapped");
+ case QtVideo::MapMode::ReadOnly:
+ return QLatin1String("ReadOnly");
+ case QtVideo::MapMode::WriteOnly:
+ return QLatin1String("WriteOnly");
+ case QtVideo::MapMode::ReadWrite:
+ return QLatin1String("ReadWrite");
+ default:
+ return QLatin1String("Unknown");
+ }
+ }
+
+ void generateImageAndMemoryBuffersWithAllModes(const MapModes& modes = validMapModes) const
+ {
+ QTest::addColumn<BufferPtr>("buffer");
+ QTest::addColumn<QtVideo::MapMode>("mapMode");
+ QTest::addColumn<const uint8_t *>("sourcePointer");
+
+ for (auto mode : modes) {
+ QTest::newRow(QStringLiteral("ImageBuffer, %1").arg(mapModeToString(mode)).toLocal8Bit().constData())
+ << createImageBuffer() << mode << m_image.constBits();
+ QTest::newRow(QStringLiteral("MemoryBuffer, %1").arg(mapModeToString(mode)).toLocal8Bit().constData())
+ << createMemoryBuffer() << mode << reinterpret_cast<const uint8_t *>(m_byteArray.constData());
+ }
+ }
+
+ void generateMapModes(const MapModes &modes = validMapModes) const
+ {
+ QTest::addColumn<QtVideo::MapMode>("mapMode");
+
+ for (auto mode : modes)
+ QTest::newRow(mapModeToString(mode).toLocal8Bit().constData()) << mode;
+ }
+
+ BufferPtr createImageBuffer() const
+ {
+ return std::make_shared<QImageVideoBuffer>(m_image);
+ }
+
+ BufferPtr createMemoryBuffer() const
+ {
+ return std::make_shared<QMemoryVideoBuffer>(m_byteArray, m_byteArray.size() / m_image.height());
+ }
+
+ QImage m_image = { QSize(5, 4), QImage::Format_RGBA8888 };
+ QByteArray m_byteArray;
+};
+
+
+void tst_QVideoBuffers::initTestCase()
+{
+ m_image.fill(Qt::gray);
+ m_image.setPixelColor(0, 0, Qt::green);
+ m_image.setPixelColor(m_image.width() - 1, 0, Qt::blue);
+ m_image.setPixelColor(0, m_image.height() - 1, Qt::red);
+
+ m_byteArray.assign(m_image.constBits(), m_image.constBits() + m_image.sizeInBytes());
+}
+
+void tst_QVideoBuffers::map_changesMappedStateAndReturnsProperMappings_whenBufferIsNotMapped_data()
+{
+ generateImageAndMemoryBuffersWithAllModes();
+}
+
+void tst_QVideoBuffers::map_changesMappedStateAndReturnsProperMappings_whenBufferIsNotMapped()
+{
+ QFETCH(BufferPtr, buffer);
+ QFETCH(QtVideo::MapMode, mapMode);
+
+ auto mappedData = buffer->map(mapMode);
+
+ QCOMPARE(mappedData.planeCount, 1);
+ QVERIFY(mappedData.data[0]);
+ QCOMPARE(mappedData.dataSize[0], 80);
+ QCOMPARE(mappedData.bytesPerLine[0], 20);
+
+ const auto data = reinterpret_cast<const char*>(mappedData.data[0]);
+ QCOMPARE(QByteArray(data, mappedData.dataSize[0]), m_byteArray);
+}
+
+void tst_QVideoBuffers::map_doesNothing_whenBufferIsMapped_data()
+{
+ generateImageAndMemoryBuffersWithAllModes();
+}
+
+void tst_QVideoBuffers::map_doesNothing_whenBufferIsMapped()
+{
+ QFETCH(BufferPtr, buffer);
+ QFETCH(QtVideo::MapMode, mapMode);
+
+ buffer->map(mapMode);
+ auto mappedData = buffer->map(QtVideo::MapMode::ReadOnly);
+ QCOMPARE(mappedData.planeCount, 0);
+}
+
+void tst_QVideoBuffers::mapMemoryOrImageBuffer_detachesDataDependingOnMode_data()
+{
+ generateImageAndMemoryBuffersWithAllModes();
+}
+
+void tst_QVideoBuffers::mapMemoryOrImageBuffer_detachesDataDependingOnMode()
+{
+ QFETCH(BufferPtr, buffer);
+ QFETCH(QtVideo::MapMode, mapMode);
+ QFETCH(const uint8_t *, sourcePointer);
+
+ auto mappedData = buffer->map(mapMode);
+ QCOMPARE(mappedData.planeCount, 1);
+
+ const bool isDetached = mappedData.data[0] != sourcePointer;
+ const bool isWriteMode = (mapMode & QtVideo::MapMode::WriteOnly) == QtVideo::MapMode::WriteOnly;
+ QCOMPARE(isDetached, isWriteMode);
+}
+
+void tst_QVideoBuffers::unmap_resetsMappedState_whenBufferIsMapped_data()
+{
+ generateImageAndMemoryBuffersWithAllModes();
+}
+
+void tst_QVideoBuffers::unmap_resetsMappedState_whenBufferIsMapped()
+{
+ QFETCH(BufferPtr, buffer);
+ QFETCH(QtVideo::MapMode, mapMode);
+
+ buffer->map(mapMode);
+
+ buffer->unmap();
+
+ // Check buffer is valid and it's possible to map again
+ auto mappedData = buffer->map(QtVideo::MapMode::ReadOnly);
+ QCOMPARE(mappedData.planeCount, 1);
+
+ const auto data = reinterpret_cast<const char*>(mappedData.data[0]);
+ QCOMPARE(QByteArray(data, mappedData.dataSize[0]), m_byteArray);
+}
+
+void tst_QVideoBuffers::imageBuffer_fixesInputImage_data()
+{
+ QTest::addColumn<QImage::Format>("inputImageFormat");
+ QTest::addColumn<QImage::Format>("underlyingImageFormat");
+
+ QTest::newRow("Format_RGB32 => Format_RGB32") << QImage::Format_RGB32 << QImage::Format_RGB32;
+ QTest::newRow("Format_ARGB32 => Format_ARGB32")
+ << QImage::Format_ARGB32 << QImage::Format_ARGB32;
+ QTest::newRow("Format_ARGB32_Premultiplied => Format_ARGB32_Premultiplied")
+ << QImage::Format_ARGB32_Premultiplied << QImage::Format_ARGB32_Premultiplied;
+ QTest::newRow("Format_RGBA8888 => Format_RGBA8888")
+ << QImage::Format_RGBA8888 << QImage::Format_RGBA8888;
+ QTest::newRow("Format_RGBA8888_Premultiplied => Format_RGBA8888_Premultiplied")
+ << QImage::Format_RGBA8888_Premultiplied << QImage::Format_RGBA8888_Premultiplied;
+ QTest::newRow("Format_RGBX8888 => Format_RGBX8888")
+ << QImage::Format_RGBX8888 << QImage::Format_RGBX8888;
+ QTest::newRow("Format_Grayscale8 => Format_Grayscale8")
+ << QImage::Format_Grayscale8 << QImage::Format_Grayscale8;
+ QTest::newRow("Format_Grayscale16 => Format_Grayscale16")
+ << QImage::Format_Grayscale16 << QImage::Format_Grayscale16;
+
+ QTest::newRow("Format_ARGB8565_Premultiplied => Format_ARGB32_Premultiplied")
+ << QImage::Format_ARGB8565_Premultiplied << QImage::Format_ARGB32_Premultiplied;
+ QTest::newRow("Format_ARGB6666_Premultiplied => Format_ARGB32_Premultiplied")
+ << QImage::Format_ARGB6666_Premultiplied << QImage::Format_ARGB32_Premultiplied;
+ QTest::newRow("Format_ARGB8555_Premultiplied => Format_ARGB32_Premultiplied")
+ << QImage::Format_ARGB8555_Premultiplied << QImage::Format_ARGB32_Premultiplied;
+ QTest::newRow("Format_ARGB4444_Premultiplied => Format_ARGB32_Premultiplied")
+ << QImage::Format_ARGB4444_Premultiplied << QImage::Format_ARGB32_Premultiplied;
+ QTest::newRow("Format_A2BGR30_Premultiplied => Format_ARGB32_Premultiplied")
+ << QImage::Format_A2BGR30_Premultiplied << QImage::Format_ARGB32_Premultiplied;
+ QTest::newRow("Format_A2RGB30_Premultiplied => Format_ARGB32_Premultiplied")
+ << QImage::Format_A2RGB30_Premultiplied << QImage::Format_ARGB32_Premultiplied;
+ QTest::newRow("Format_RGBA64_Premultiplied => Format_ARGB32_Premultiplied")
+ << QImage::Format_RGBA64_Premultiplied << QImage::Format_ARGB32_Premultiplied;
+ QTest::newRow("Format_RGBA16FPx4_Premultiplied => Format_ARGB32_Premultiplied")
+ << QImage::Format_RGBA16FPx4_Premultiplied << QImage::Format_ARGB32_Premultiplied;
+ QTest::newRow("Format_RGBA32FPx4_Premultiplied => Format_ARGB32_Premultiplied")
+ << QImage::Format_RGBA32FPx4_Premultiplied << QImage::Format_ARGB32_Premultiplied;
+
+ QTest::newRow("Format_Alpha8 => Format_ARGB32")
+ << QImage::Format_Alpha8 << QImage::Format_ARGB32;
+ QTest::newRow("Format_RGBA64 => Format_ARGB32")
+ << QImage::Format_RGBA64 << QImage::Format_ARGB32;
+ QTest::newRow("Format_RGBA16FPx4 => Format_ARGB32")
+ << QImage::Format_RGBA16FPx4 << QImage::Format_ARGB32;
+ QTest::newRow("Format_RGBA32FPx4 => Format_ARGB32")
+ << QImage::Format_RGBA32FPx4 << QImage::Format_ARGB32;
+}
+
+void tst_QVideoBuffers::imageBuffer_fixesInputImage()
+{
+ QFETCH(QImage::Format, inputImageFormat);
+ QFETCH(QImage::Format, underlyingImageFormat);
+
+ m_image.convertTo(inputImageFormat);
+ QImageVideoBuffer buffer(m_image);
+
+ auto underlyingImage = buffer.underlyingImage();
+
+ QCOMPARE(underlyingImage.format(), underlyingImageFormat);
+ QCOMPARE_NE(QVideoFrameFormat::pixelFormatFromImageFormat(underlyingImage.format()),
+ QVideoFrameFormat::Format_Invalid);
+ QCOMPARE(m_image.convertedTo(underlyingImageFormat), underlyingImage);
+
+ if (inputImageFormat == underlyingImageFormat)
+ QCOMPARE(m_image.constBits(), underlyingImage.constBits());
+}
+
+QTEST_APPLESS_MAIN(tst_QVideoBuffers);
+
+#include "tst_qvideobuffers.moc"
diff --git a/tests/auto/unit/multimedia/qvideoframe/CMakeLists.txt b/tests/auto/unit/multimedia/qvideoframe/CMakeLists.txt
new file mode 100644
index 000000000..29b8a413e
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframe/CMakeLists.txt
@@ -0,0 +1,16 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+# Generated from qvideoframe.pro.
+
+#####################################################################
+## tst_qvideoframe Test:
+#####################################################################
+
+qt_internal_add_test(tst_qvideoframe
+ SOURCES
+ tst_qvideoframe.cpp
+ LIBRARIES
+ Qt::Gui
+ Qt::MultimediaPrivate
+)
diff --git a/tests/auto/unit/multimedia/qvideoframe/tst_qvideoframe.cpp b/tests/auto/unit/multimedia/qvideoframe/tst_qvideoframe.cpp
new file mode 100644
index 000000000..de10177fa
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframe/tst_qvideoframe.cpp
@@ -0,0 +1,1437 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QtTest/QtTest>
+
+#include <qvideoframe.h>
+#include <qvideoframeformat.h>
+#include "QtTest/qtestcase.h"
+#include "private/qmemoryvideobuffer_p.h"
+#include "private/qhwvideobuffer_p.h"
+#include "private/qvideoframe_p.h"
+#include <QtGui/QImage>
+#include <QtCore/QPointer>
+#include <QtMultimedia/private/qtmultimedia-config_p.h>
+#include "private/qvideoframeconverter_p.h"
+
+// Adds an enum, and the stringized version
+#define ADD_ENUM_TEST(x) \
+ QTest::newRow(#x) \
+ << QVideoFrame::x \
+ << QString(QLatin1String(#x));
+
+
+// Image used for testing conversion from QImage to QVideoFrame
+QImage createTestImage(QImage::Format format)
+{
+ // +---+---+---+
+ // | r | g | b |
+ // | b | r | g |
+ // +---+---+---+
+ QImage image{ { 3, 2 }, QImage::Format_ARGB32 };
+ image.setPixelColor(0, 0, QColor(Qt::red));
+ image.setPixelColor(1, 0, QColor(Qt::green));
+ image.setPixelColor(2, 0, QColor(Qt::blue));
+ image.setPixelColor(0, 1, QColor(Qt::blue));
+ image.setPixelColor(1, 1, QColor(Qt::red));
+ image.setPixelColor(2, 1, QColor(Qt::green));
+ return image.convertToFormat(format);
+}
+
+// clang-format off
+
+// Convert a QVideoFrame pixel value from raw format to QRgb
+// Only works with little-endian byte ordering
+QRgb swizzle(uint value, QVideoFrameFormat::PixelFormat format)
+{
+ switch (format) {
+ case QVideoFrameFormat::Format_ARGB8888:
+ case QVideoFrameFormat::Format_ARGB8888_Premultiplied:
+ case QVideoFrameFormat::Format_XRGB8888:
+ Q_ASSERT(false); // not implemented
+ return 0;
+ case QVideoFrameFormat::Format_BGRA8888:
+ case QVideoFrameFormat::Format_BGRA8888_Premultiplied:
+ case QVideoFrameFormat::Format_BGRX8888:
+ return value;
+ case QVideoFrameFormat::Format_ABGR8888:
+ case QVideoFrameFormat::Format_XBGR8888:
+ Q_ASSERT(false); // not implemented
+ return 0;
+ case QVideoFrameFormat::Format_RGBA8888:
+ case QVideoFrameFormat::Format_RGBX8888:
+ return (((value >> 24) & 0xff) << 24) // a -> a
+ | ((value & 0xff) << 16) // b -> r
+ | (((value >> 8) & 0xff) << 8) // g -> g
+ | ((value >> 16) & 0xff); // r -> b
+ default:
+ qWarning() << "Unsupported format";
+ return 0;
+ }
+}
+
+std::vector<QRgb> swizzle(const std::vector<uint> &pixels, QVideoFrameFormat::PixelFormat format)
+{
+ std::vector<QRgb> rgba(pixels.size());
+ std::transform(pixels.begin(), pixels.end(), rgba.begin(),
+ [format](uint value) {
+ return swizzle(value, format);
+ });
+ return rgba;
+}
+
+// clang-format on
+
+std::optional<std::vector<QRgb>> getPixels(QVideoFrame &frame)
+{
+ if (!frame.map(QtVideo::MapMode::ReadOnly))
+ return std::nullopt;
+
+ const uint *mappedPixels = reinterpret_cast<const uint *>(frame.bits(0));
+ const unsigned long long stride = frame.bytesPerLine(0) / sizeof(QRgb);
+
+ std::vector<uint> pixels;
+ for (int j = 0; j < frame.size().height(); ++j) {
+ for (int i = 0; i < frame.size().width(); ++i) {
+ pixels.push_back(mappedPixels[i + j * stride]);
+ }
+ }
+
+ frame.unmap();
+
+ return swizzle(pixels, frame.pixelFormat());
+}
+
+bool compareEq(QVideoFrame &frame, const QImage &image)
+{
+ if (frame.size() != image.size()) {
+ qDebug() << "Size mismatch";
+ return false;
+ }
+
+ const std::vector<QRgb> expectedPixels = { image.pixel(0, 0), image.pixel(1, 0), image.pixel(2, 0),
+ image.pixel(0, 1), image.pixel(1, 1), image.pixel(2, 1) };
+
+ const std::optional<std::vector<QRgb>> actualPixels = getPixels(frame);
+ if (!actualPixels) {
+ qDebug() << "Failed to read pixels from frame";
+ return false;
+ }
+
+ for (size_t i = 0; i < expectedPixels.size(); ++i) {
+ if (expectedPixels[i] != actualPixels->at(i)) {
+ qDebug() << "Pixel difference at element" << i << ":" << Qt::hex << expectedPixels[i]
+ << "vs" << actualPixels->at(i);
+ return false;
+ }
+ }
+ return true;
+}
+
+QSet s_pixelFormats{ QVideoFrameFormat::Format_ARGB8888,
+ QVideoFrameFormat::Format_ARGB8888_Premultiplied,
+ QVideoFrameFormat::Format_XRGB8888,
+ QVideoFrameFormat::Format_BGRA8888,
+ QVideoFrameFormat::Format_BGRA8888_Premultiplied,
+ QVideoFrameFormat::Format_BGRX8888,
+ QVideoFrameFormat::Format_ABGR8888,
+ QVideoFrameFormat::Format_XBGR8888,
+ QVideoFrameFormat::Format_RGBA8888,
+ QVideoFrameFormat::Format_RGBX8888,
+ QVideoFrameFormat::Format_NV12,
+ QVideoFrameFormat::Format_NV21,
+ QVideoFrameFormat::Format_IMC1,
+ QVideoFrameFormat::Format_IMC2,
+ QVideoFrameFormat::Format_IMC3,
+ QVideoFrameFormat::Format_IMC4,
+ QVideoFrameFormat::Format_AYUV,
+ QVideoFrameFormat::Format_AYUV_Premultiplied,
+ QVideoFrameFormat::Format_YV12,
+ QVideoFrameFormat::Format_YUV420P,
+ QVideoFrameFormat::Format_YUV422P,
+ QVideoFrameFormat::Format_UYVY,
+ QVideoFrameFormat::Format_YUYV,
+ QVideoFrameFormat::Format_Y8,
+ QVideoFrameFormat::Format_Y16,
+ QVideoFrameFormat::Format_P010,
+ QVideoFrameFormat::Format_P016,
+ QVideoFrameFormat::Format_YUV420P10 };
+
+bool isSupportedPixelFormat(QVideoFrameFormat::PixelFormat pixelFormat)
+{
+#ifdef Q_OS_ANDROID
+ // TODO: QTBUG-125238
+ switch (pixelFormat) {
+ case QVideoFrameFormat::Format_Y16:
+ case QVideoFrameFormat::Format_P010:
+ case QVideoFrameFormat::Format_P016:
+ case QVideoFrameFormat::Format_YUV420P10:
+ return false;
+ default:
+ return true;
+ }
+#else
+ return true;
+#endif
+}
+
+class tst_QVideoFrame : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QVideoFrame();
+ ~tst_QVideoFrame() override;
+
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+private slots:
+ void create_data();
+ void create();
+ void createInvalid_data();
+ void createInvalid();
+ void createFromBuffer_data();
+ void createFromBuffer();
+ void createFromImage_data();
+ void createNull();
+ void destructor();
+ void copy_data();
+ void copy();
+ void assign_data();
+ void assign();
+ void map_data();
+ void map();
+ void mapPlanes_data();
+ void mapPlanes();
+ void formatConversion_data();
+ void formatConversion();
+
+ void qImageFromVideoFrame_doesNotCrash_whenCalledWithEvenAndOddSizedFrames_data();
+ void qImageFromVideoFrame_doesNotCrash_whenCalledWithEvenAndOddSizedFrames();
+
+ void isMapped();
+ void isReadable();
+ void isWritable();
+
+ void image_data();
+ void image();
+
+ void emptyData();
+
+ void mirrored_takesValue_fromVideoFrameFormat();
+ void rotation_takesValue_fromVideoFrameFormat();
+ void streamFrameRate_takesValue_fromVideoFrameFormat();
+
+ void constructor_createsInvalidFrame_whenCalledWithNullImage();
+ void constructor_createsInvalidFrame_whenCalledWithEmptyImage();
+ void constructor_createsInvalidFrame_whenCalledWithInvalidImageFormat();
+ void constructor_createsFrameWithCorrectFormat_whenCalledWithSupportedImageFormats_data();
+ void constructor_createsFrameWithCorrectFormat_whenCalledWithSupportedImageFormats();
+ void constructor_copiesImageData_whenCalledWithRGBFormats_data();
+ void constructor_copiesImageData_whenCalledWithRGBFormats();
+};
+
+class QtTestDummyVideoBuffer : public QObject, public QHwVideoBuffer
+{
+ Q_OBJECT
+public:
+ QtTestDummyVideoBuffer() : QHwVideoBuffer(QVideoFrame::NoHandle) { }
+ explicit QtTestDummyVideoBuffer(QVideoFrame::HandleType type) : QHwVideoBuffer(type) { }
+
+ MapData map(QtVideo::MapMode) override { return {}; }
+ void unmap() override {}
+};
+
+class QtTestVideoBuffer : public QHwVideoBuffer
+{
+public:
+ QtTestVideoBuffer() : QHwVideoBuffer(QVideoFrame::NoHandle) { }
+ explicit QtTestVideoBuffer(QVideoFrame::HandleType type) : QHwVideoBuffer(type) { }
+
+ MapData map(QtVideo::MapMode mode) override
+ {
+ m_mapMode = mode;
+ MapData mapData;
+ int nBytes = m_numBytes;
+ mapData.planeCount = m_planeCount;
+ for (int i = 0; i < m_planeCount; ++i) {
+ mapData.data[i] = m_data[i];
+ mapData.bytesPerLine[i] = m_bytesPerLine[i];
+ if (i) {
+ mapData.dataSize[i-1] = m_data[i] - m_data[i-1];
+ nBytes -= mapData.dataSize[i-1];
+ }
+ mapData.dataSize[i] = nBytes;
+ }
+ return mapData;
+ }
+ void unmap() override { m_mapMode = QtVideo::MapMode::NotMapped; }
+
+ uchar *m_data[4];
+ int m_bytesPerLine[4];
+ int m_planeCount = 0;
+ int m_numBytes;
+ QtVideo::MapMode m_mapMode = QtVideo::MapMode::NotMapped;
+};
+
+tst_QVideoFrame::tst_QVideoFrame()
+{
+}
+
+tst_QVideoFrame::~tst_QVideoFrame()
+{
+}
+
+void tst_QVideoFrame::initTestCase()
+{
+}
+
+void tst_QVideoFrame::cleanupTestCase()
+{
+}
+
+void tst_QVideoFrame::init()
+{
+}
+
+void tst_QVideoFrame::cleanup()
+{
+}
+
+void tst_QVideoFrame::create_data()
+{
+ QTest::addColumn<QSize>("size");
+ QTest::addColumn<QVideoFrameFormat::PixelFormat>("pixelFormat");
+ QTest::addColumn<int>("bytesPerLine");
+
+ QTest::newRow("64x64 ARGB32")
+ << QSize(64, 64)
+ << QVideoFrameFormat::Format_ARGB8888
+ << 64*4;
+ QTest::newRow("32x256 YUV420P")
+ << QSize(32, 256)
+ << QVideoFrameFormat::Format_YUV420P
+ << 32;
+ QTest::newRow("32x256 UYVY")
+ << QSize(32, 256)
+ << QVideoFrameFormat::Format_UYVY
+ << 32*2;
+}
+
+void tst_QVideoFrame::create()
+{
+ QFETCH(QSize, size);
+ QFETCH(QVideoFrameFormat::PixelFormat, pixelFormat);
+ QFETCH(int, bytesPerLine);
+
+ QVideoFrame frame(QVideoFrameFormat(size, pixelFormat));
+
+ QVERIFY(frame.isValid());
+ QCOMPARE(frame.handleType(), QVideoFrame::NoHandle);
+ QCOMPARE(QVideoFramePrivate::hwBuffer(frame), nullptr);
+ QCOMPARE_NE(QVideoFramePrivate::buffer(frame), nullptr);
+ QCOMPARE(frame.pixelFormat(), pixelFormat);
+ QCOMPARE(frame.size(), size);
+ QCOMPARE(frame.width(), size.width());
+ QCOMPARE(frame.height(), size.height());
+ QCOMPARE(frame.startTime(), qint64(-1));
+ QCOMPARE(frame.endTime(), qint64(-1));
+ frame.map(QtVideo::MapMode::ReadOnly);
+ QCOMPARE(frame.bytesPerLine(0), bytesPerLine);
+ frame.unmap();
+}
+
+void tst_QVideoFrame::createInvalid_data()
+{
+ QTest::addColumn<QSize>("size");
+ QTest::addColumn<QVideoFrameFormat::PixelFormat>("pixelFormat");
+
+ QTest::newRow("0x64 ARGB32 0 size")
+ << QSize(0, 64)
+ << QVideoFrameFormat::Format_ARGB8888;
+ QTest::newRow("32x0 YUV420P 0 size")
+ << QSize(32, 0)
+ << QVideoFrameFormat::Format_YUV420P;
+}
+
+void tst_QVideoFrame::createInvalid()
+{
+ QFETCH(QSize, size);
+ QFETCH(QVideoFrameFormat::PixelFormat, pixelFormat);
+
+ QVideoFrame frame(QVideoFrameFormat(size, pixelFormat));
+
+ QVERIFY(!frame.isValid());
+ QCOMPARE(frame.handleType(), QVideoFrame::NoHandle);
+ QCOMPARE(QVideoFramePrivate::buffer(frame), nullptr);
+ QCOMPARE(frame.pixelFormat(), pixelFormat);
+ QCOMPARE(frame.size(), size);
+ QCOMPARE(frame.width(), size.width());
+ QCOMPARE(frame.height(), size.height());
+ QCOMPARE(frame.startTime(), qint64(-1));
+ QCOMPARE(frame.endTime(), qint64(-1));
+}
+
+void tst_QVideoFrame::createFromBuffer_data()
+{
+ QTest::addColumn<QVideoFrame::HandleType>("handleType");
+ QTest::addColumn<QSize>("size");
+ QTest::addColumn<QVideoFrameFormat::PixelFormat>("pixelFormat");
+
+ QTest::newRow("64x64 ARGB32 no handle")
+ << QVideoFrame::NoHandle
+ << QSize(64, 64)
+ << QVideoFrameFormat::Format_ARGB8888;
+ QTest::newRow("64x64 ARGB32 gl handle")
+ << QVideoFrame::RhiTextureHandle
+ << QSize(64, 64)
+ << QVideoFrameFormat::Format_ARGB8888;
+}
+
+void tst_QVideoFrame::createFromBuffer()
+{
+ QFETCH(QVideoFrame::HandleType, handleType);
+ QFETCH(QSize, size);
+ QFETCH(QVideoFrameFormat::PixelFormat, pixelFormat);
+
+ QVideoFrame frame =
+ QVideoFramePrivate::createFrame(std::make_unique<QtTestDummyVideoBuffer>(handleType),
+ QVideoFrameFormat(size, pixelFormat));
+
+ QVERIFY(frame.isValid());
+ QCOMPARE(frame.handleType(), handleType);
+ QCOMPARE(frame.pixelFormat(), pixelFormat);
+ QCOMPARE(frame.size(), size);
+ QCOMPARE(frame.width(), size.width());
+ QCOMPARE(frame.height(), size.height());
+ QCOMPARE(frame.startTime(), qint64(-1));
+ QCOMPARE(frame.endTime(), qint64(-1));
+}
+
+void tst_QVideoFrame::createFromImage_data()
+{
+ QTest::addColumn<QSize>("size");
+ QTest::addColumn<QImage::Format>("imageFormat");
+ QTest::addColumn<QVideoFrameFormat::PixelFormat>("pixelFormat");
+
+ QTest::newRow("64x64 RGB32")
+ << QSize(64, 64)
+ << QImage::Format_RGB32
+ << QVideoFrameFormat::Format_XRGB8888;
+ QTest::newRow("19x46 ARGB32_Premultiplied")
+ << QSize(19, 46)
+ << QImage::Format_ARGB32_Premultiplied
+ << QVideoFrameFormat::Format_ARGB8888_Premultiplied;
+}
+
+void tst_QVideoFrame::createNull()
+{
+ // Default ctor
+ {
+ QVideoFrame frame;
+
+ QVERIFY(!frame.isValid());
+ QCOMPARE(frame.handleType(), QVideoFrame::NoHandle);
+ QCOMPARE(frame.pixelFormat(), QVideoFrameFormat::Format_Invalid);
+ QCOMPARE(frame.size(), QSize());
+ QCOMPARE(frame.width(), -1);
+ QCOMPARE(frame.height(), -1);
+ QCOMPARE(frame.startTime(), qint64(-1));
+ QCOMPARE(frame.endTime(), qint64(-1));
+ QCOMPARE(static_cast<QtVideo::MapMode>(frame.mapMode()), QtVideo::MapMode::NotMapped);
+ QVERIFY(!frame.map(QtVideo::MapMode::ReadOnly));
+ QVERIFY(!frame.map(QtVideo::MapMode::ReadWrite));
+ QVERIFY(!frame.map(QtVideo::MapMode::WriteOnly));
+ QCOMPARE(frame.isMapped(), false);
+ frame.unmap(); // Shouldn't crash
+ QCOMPARE(frame.isReadable(), false);
+ QCOMPARE(frame.isWritable(), false);
+ }
+
+ // Null buffer (shouldn't crash)
+ {
+ QVideoFrame frame = QVideoFramePrivate::createFrame(
+ std::unique_ptr<QHwVideoBuffer>(),
+ QVideoFrameFormat(QSize(1024, 768), QVideoFrameFormat::Format_ARGB8888));
+ QVERIFY(!frame.isValid());
+ QCOMPARE(frame.handleType(), QVideoFrame::NoHandle);
+ QCOMPARE(frame.pixelFormat(), QVideoFrameFormat::Format_ARGB8888);
+ QCOMPARE(frame.size(), QSize(1024, 768));
+ QCOMPARE(frame.width(), 1024);
+ QCOMPARE(frame.height(), 768);
+ QCOMPARE(frame.startTime(), qint64(-1));
+ QCOMPARE(frame.endTime(), qint64(-1));
+ QCOMPARE(static_cast<QtVideo::MapMode>(frame.mapMode()), QtVideo::MapMode::NotMapped);
+ QVERIFY(!frame.map(QtVideo::MapMode::ReadOnly));
+ QVERIFY(!frame.map(QtVideo::MapMode::ReadWrite));
+ QVERIFY(!frame.map(QtVideo::MapMode::WriteOnly));
+ QCOMPARE(frame.isMapped(), false);
+ frame.unmap(); // Shouldn't crash
+ QCOMPARE(frame.isReadable(), false);
+ QCOMPARE(frame.isWritable(), false);
+ }
+}
+
+void tst_QVideoFrame::destructor()
+{
+ QPointer<QtTestDummyVideoBuffer> buffer = new QtTestDummyVideoBuffer;
+
+ {
+ QVideoFrame frame = QVideoFramePrivate::createFrame(
+ std::unique_ptr<QHwVideoBuffer>(buffer),
+ QVideoFrameFormat(QSize(4, 1), QVideoFrameFormat::Format_ARGB8888));
+ }
+
+ QVERIFY(buffer.isNull());
+}
+
+void tst_QVideoFrame::copy_data()
+{
+ QTest::addColumn<QVideoFrame::HandleType>("handleType");
+ QTest::addColumn<QSize>("size");
+ QTest::addColumn<QVideoFrameFormat::PixelFormat>("pixelFormat");
+ QTest::addColumn<qint64>("startTime");
+ QTest::addColumn<qint64>("endTime");
+
+ QTest::newRow("64x64 ARGB32")
+ << QVideoFrame::RhiTextureHandle
+ << QSize(64, 64)
+ << QVideoFrameFormat::Format_ARGB8888
+ << qint64(63641740)
+ << qint64(63641954);
+ QTest::newRow("64x64 ARGB32")
+ << QVideoFrame::RhiTextureHandle
+ << QSize(64, 64)
+ << QVideoFrameFormat::Format_ARGB8888
+ << qint64(63641740)
+ << qint64(63641954);
+ QTest::newRow("32x256 YUV420P")
+ << QVideoFrame::NoHandle
+ << QSize(32, 256)
+ << QVideoFrameFormat::Format_YUV420P
+ << qint64(12345)
+ << qint64(12389);
+ QTest::newRow("1052x756 ARGB32")
+ << QVideoFrame::NoHandle
+ << QSize(1052, 756)
+ << QVideoFrameFormat::Format_ARGB8888
+ << qint64(12345)
+ << qint64(12389);
+ QTest::newRow("32x256 YUV420P")
+ << QVideoFrame::NoHandle
+ << QSize(32, 256)
+ << QVideoFrameFormat::Format_YUV420P
+ << qint64(12345)
+ << qint64(12389);
+}
+
+void tst_QVideoFrame::copy()
+{
+ QFETCH(QVideoFrame::HandleType, handleType);
+ QFETCH(QSize, size);
+ QFETCH(QVideoFrameFormat::PixelFormat, pixelFormat);
+ QFETCH(qint64, startTime);
+ QFETCH(qint64, endTime);
+
+ QPointer<QtTestDummyVideoBuffer> buffer = new QtTestDummyVideoBuffer(handleType);
+
+ {
+ QVideoFrame frame = QVideoFramePrivate::createFrame(std::unique_ptr<QHwVideoBuffer>(buffer),
+ QVideoFrameFormat(size, pixelFormat));
+ frame.setStartTime(startTime);
+ frame.setEndTime(endTime);
+
+ QVERIFY(frame.isValid());
+ QCOMPARE(frame.handleType(), handleType);
+ QCOMPARE(frame.pixelFormat(), pixelFormat);
+ QCOMPARE(frame.size(), size);
+ QCOMPARE(frame.width(), size.width());
+ QCOMPARE(frame.height(), size.height());
+ QCOMPARE(frame.startTime(), startTime);
+ QCOMPARE(frame.endTime(), endTime);
+
+ {
+ QVideoFrame otherFrame(frame);
+
+ QVERIFY(!buffer.isNull());
+
+ QVERIFY(otherFrame.isValid());
+ QCOMPARE(otherFrame.handleType(), handleType);
+ QCOMPARE(otherFrame.pixelFormat(), pixelFormat);
+ QCOMPARE(otherFrame.size(), size);
+ QCOMPARE(otherFrame.width(), size.width());
+ QCOMPARE(otherFrame.height(), size.height());
+ QCOMPARE(otherFrame.startTime(), startTime);
+ QCOMPARE(otherFrame.endTime(), endTime);
+
+ otherFrame.setEndTime(-1);
+
+ QVERIFY(!buffer.isNull());
+
+ QVERIFY(otherFrame.isValid());
+ QCOMPARE(otherFrame.handleType(), handleType);
+ QCOMPARE(otherFrame.pixelFormat(), pixelFormat);
+ QCOMPARE(otherFrame.size(), size);
+ QCOMPARE(otherFrame.width(), size.width());
+ QCOMPARE(otherFrame.height(), size.height());
+ QCOMPARE(otherFrame.startTime(), startTime);
+ QCOMPARE(otherFrame.endTime(), qint64(-1));
+ }
+
+ QVERIFY(!buffer.isNull());
+
+ QVERIFY(frame.isValid());
+ QCOMPARE(frame.handleType(), handleType);
+ QCOMPARE(frame.pixelFormat(), pixelFormat);
+ QCOMPARE(frame.size(), size);
+ QCOMPARE(frame.width(), size.width());
+ QCOMPARE(frame.height(), size.height());
+ QCOMPARE(frame.startTime(), startTime);
+ QCOMPARE(frame.endTime(), qint64(-1)); // Explicitly shared.
+ }
+
+ QVERIFY(buffer.isNull());
+}
+
+void tst_QVideoFrame::assign_data()
+{
+ QTest::addColumn<QVideoFrame::HandleType>("handleType");
+ QTest::addColumn<QSize>("size");
+ QTest::addColumn<QVideoFrameFormat::PixelFormat>("pixelFormat");
+ QTest::addColumn<qint64>("startTime");
+ QTest::addColumn<qint64>("endTime");
+
+ QTest::newRow("64x64 ARGB32")
+ << QVideoFrame::RhiTextureHandle
+ << QSize(64, 64)
+ << QVideoFrameFormat::Format_ARGB8888
+ << qint64(63641740)
+ << qint64(63641954);
+ QTest::newRow("32x256 YUV420P")
+ << QVideoFrame::NoHandle
+ << QSize(32, 256)
+ << QVideoFrameFormat::Format_YUV420P
+ << qint64(12345)
+ << qint64(12389);
+}
+
+void tst_QVideoFrame::assign()
+{
+ QFETCH(QVideoFrame::HandleType, handleType);
+ QFETCH(QSize, size);
+ QFETCH(QVideoFrameFormat::PixelFormat, pixelFormat);
+ QFETCH(qint64, startTime);
+ QFETCH(qint64, endTime);
+
+ QPointer<QtTestDummyVideoBuffer> buffer = new QtTestDummyVideoBuffer(handleType);
+
+ QVideoFrame frame;
+ {
+ QVideoFrame otherFrame = QVideoFramePrivate::createFrame(
+ std::unique_ptr<QHwVideoBuffer>(buffer), QVideoFrameFormat(size, pixelFormat));
+ otherFrame.setStartTime(startTime);
+ otherFrame.setEndTime(endTime);
+
+ frame = otherFrame;
+
+ QVERIFY(!buffer.isNull());
+
+ QVERIFY(otherFrame.isValid());
+ QCOMPARE(otherFrame.handleType(), handleType);
+ QCOMPARE(otherFrame.pixelFormat(), pixelFormat);
+ QCOMPARE(otherFrame.size(), size);
+ QCOMPARE(otherFrame.width(), size.width());
+ QCOMPARE(otherFrame.height(), size.height());
+ QCOMPARE(otherFrame.startTime(), startTime);
+ QCOMPARE(otherFrame.endTime(), endTime);
+
+ otherFrame.setStartTime(-1);
+
+ QVERIFY(!buffer.isNull());
+
+ QVERIFY(otherFrame.isValid());
+ QCOMPARE(otherFrame.handleType(), handleType);
+ QCOMPARE(otherFrame.pixelFormat(), pixelFormat);
+ QCOMPARE(otherFrame.size(), size);
+ QCOMPARE(otherFrame.width(), size.width());
+ QCOMPARE(otherFrame.height(), size.height());
+ QCOMPARE(otherFrame.startTime(), qint64(-1));
+ QCOMPARE(otherFrame.endTime(), endTime);
+ }
+
+ QVERIFY(!buffer.isNull());
+
+ QVERIFY(frame.isValid());
+ QCOMPARE(frame.handleType(), handleType);
+ QCOMPARE(frame.pixelFormat(), pixelFormat);
+ QCOMPARE(frame.size(), size);
+ QCOMPARE(frame.width(), size.width());
+ QCOMPARE(frame.height(), size.height());
+ QCOMPARE(frame.startTime(), qint64(-1));
+ QCOMPARE(frame.endTime(), endTime);
+
+ frame = QVideoFrame();
+
+ QVERIFY(buffer.isNull());
+
+ QVERIFY(!frame.isValid());
+ QCOMPARE(frame.handleType(), QVideoFrame::NoHandle);
+ QCOMPARE(frame.pixelFormat(), QVideoFrameFormat::Format_Invalid);
+ QCOMPARE(frame.size(), QSize());
+ QCOMPARE(frame.width(), -1);
+ QCOMPARE(frame.height(), -1);
+ QCOMPARE(frame.startTime(), qint64(-1));
+ QCOMPARE(frame.endTime(), qint64(-1));
+}
+
+void tst_QVideoFrame::map_data()
+{
+ QTest::addColumn<QSize>("size");
+ QTest::addColumn<QVideoFrameFormat::PixelFormat>("pixelFormat");
+ QTest::addColumn<QtVideo::MapMode>("mode");
+
+ QTest::newRow("read-only")
+ << QSize(64, 64)
+ << QVideoFrameFormat::Format_ARGB8888
+ << QtVideo::MapMode::ReadOnly;
+
+ QTest::newRow("write-only")
+ << QSize(64, 64)
+ << QVideoFrameFormat::Format_ARGB8888
+ << QtVideo::MapMode::WriteOnly;
+
+ QTest::newRow("read-write")
+ << QSize(64, 64)
+ << QVideoFrameFormat::Format_ARGB8888
+ << QtVideo::MapMode::ReadWrite;
+}
+
+void tst_QVideoFrame::map()
+{
+ QFETCH(QSize, size);
+ QFETCH(QVideoFrameFormat::PixelFormat, pixelFormat);
+ QFETCH(QtVideo::MapMode, mode);
+
+ QVideoFrame frame(QVideoFrameFormat(size, pixelFormat));
+
+ QVERIFY(!frame.bits(0));
+ QCOMPARE(frame.mappedBytes(0), 0);
+ QCOMPARE(frame.bytesPerLine(0), 0);
+ QCOMPARE(static_cast<QtVideo::MapMode>(frame.mapMode()), QtVideo::MapMode::NotMapped);
+
+ QVERIFY(frame.map(mode));
+
+ // Mapping multiple times is allowed in ReadOnly mode
+ if (mode == QtVideo::MapMode::ReadOnly) {
+ const uchar *bits = frame.bits(0);
+
+ QVERIFY(frame.map(QtVideo::MapMode::ReadOnly));
+ QVERIFY(frame.isMapped());
+ QCOMPARE(frame.bits(0), bits);
+
+ frame.unmap();
+ //frame should still be mapped after the first nested unmap
+ QVERIFY(frame.isMapped());
+ QCOMPARE(frame.bits(0), bits);
+
+ //re-mapping in Write or ReadWrite modes should fail
+ QVERIFY(!frame.map(QtVideo::MapMode::WriteOnly));
+ QVERIFY(!frame.map(QtVideo::MapMode::ReadWrite));
+ } else {
+ // Mapping twice in ReadWrite or WriteOnly modes should fail, but leave it mapped (and the mode is ignored)
+ QVERIFY(!frame.map(mode));
+ QVERIFY(!frame.map(QtVideo::MapMode::ReadOnly));
+ }
+
+ QVERIFY(frame.bits(0));
+ QCOMPARE(static_cast<QtVideo::MapMode>(frame.mapMode()), mode);
+
+ frame.unmap();
+
+ QVERIFY(!frame.bits(0));
+ QCOMPARE(frame.mappedBytes(0), 0);
+ QCOMPARE(frame.bytesPerLine(0), 0);
+ QCOMPARE(static_cast<QtVideo::MapMode>(frame.mapMode()), QtVideo::MapMode::NotMapped);
+}
+
+void tst_QVideoFrame::mapPlanes_data()
+{
+ QTest::addColumn<QVideoFrame>("frame");
+
+ // Distance between subsequent lines within a color plane in bytes
+ QTest::addColumn<QList<int> >("strides");
+
+ // Distance from first pixel of first color plane to first pixel
+ // of n'th plane in bytes
+ QTest::addColumn<QList<int> >("offsets");
+
+ static uchar bufferData[1024];
+
+ auto planarBuffer = std::make_unique<QtTestVideoBuffer>();
+ planarBuffer->m_data[0] = bufferData;
+ planarBuffer->m_data[1] = bufferData + 512;
+ planarBuffer->m_data[2] = bufferData + 765;
+ planarBuffer->m_bytesPerLine[0] = 64;
+ planarBuffer->m_bytesPerLine[1] = 36;
+ planarBuffer->m_bytesPerLine[2] = 36;
+ planarBuffer->m_planeCount = 3;
+ planarBuffer->m_numBytes = sizeof(bufferData);
+
+ QTest::newRow("Planar") << QVideoFramePrivate::createFrame(
+ std::move(planarBuffer),
+ QVideoFrameFormat(QSize(64, 64), QVideoFrameFormat::Format_YUV420P))
+ << (QList<int>() << 64 << 36 << 36) << (QList<int>() << 512 << 765);
+ QTest::newRow("Format_YUV420P")
+ << QVideoFrame(QVideoFrameFormat(QSize(60, 64), QVideoFrameFormat::Format_YUV420P))
+ << (QList<int>() << 64 << 32 << 32)
+ << (QList<int>() << 4096 << 5120);
+ QTest::newRow("Format_YUV422P")
+ << QVideoFrame(QVideoFrameFormat(QSize(60, 64), QVideoFrameFormat::Format_YUV422P))
+ << (QList<int>() << 64 << 64 / 2 << 64 / 2)
+ << (QList<int>() << 64 * 64 << 64 * 64 + 64 / 2 * 64);
+ QTest::newRow("Format_YV12")
+ << QVideoFrame(QVideoFrameFormat(QSize(60, 64), QVideoFrameFormat::Format_YV12))
+ << (QList<int>() << 64 << 32 << 32)
+ << (QList<int>() << 4096 << 5120);
+ QTest::newRow("Format_NV12")
+ << QVideoFrame(QVideoFrameFormat(QSize(60, 64), QVideoFrameFormat::Format_NV12))
+ << (QList<int>() << 64 << 64)
+ << (QList<int>() << 4096);
+ QTest::newRow("Format_NV21")
+ << QVideoFrame(QVideoFrameFormat(QSize(60, 64), QVideoFrameFormat::Format_NV21))
+ << (QList<int>() << 64 << 64)
+ << (QList<int>() << 4096);
+ QTest::newRow("Format_IMC2")
+ << QVideoFrame(QVideoFrameFormat(QSize(60, 64), QVideoFrameFormat::Format_IMC2))
+ << (QList<int>() << 64 << 64)
+ << (QList<int>() << 4096);
+ QTest::newRow("Format_IMC4")
+ << QVideoFrame(QVideoFrameFormat(QSize(60, 64), QVideoFrameFormat::Format_IMC4))
+ << (QList<int>() << 64 << 64)
+ << (QList<int>() << 4096);
+ QTest::newRow("Format_IMC1")
+ << QVideoFrame(QVideoFrameFormat(QSize(60, 64), QVideoFrameFormat::Format_IMC1))
+ << (QList<int>() << 64 << 64 << 64)
+ << (QList<int>() << 4096 << 6144);
+ QTest::newRow("Format_IMC3")
+ << QVideoFrame(QVideoFrameFormat(QSize(60, 64), QVideoFrameFormat::Format_IMC3))
+ << (QList<int>() << 64 << 64 << 64)
+ << (QList<int>() << 4096 << 6144);
+ QTest::newRow("Format_ARGB32")
+ << QVideoFrame(QVideoFrameFormat(QSize(60, 64), QVideoFrameFormat::Format_ARGB8888))
+ << (QList<int>() << 240)
+ << (QList<int>());
+}
+
+void tst_QVideoFrame::mapPlanes()
+{
+ QFETCH(QVideoFrame, frame);
+ QFETCH(QList<int>, strides);
+ QFETCH(QList<int>, offsets);
+
+ QCOMPARE(strides.size(), offsets.size() + 1);
+
+ QCOMPARE(frame.map(QtVideo::MapMode::ReadOnly), true);
+ QCOMPARE(frame.planeCount(), strides.size());
+
+ QVERIFY(strides.size() > 0);
+ QCOMPARE(frame.bytesPerLine(0), strides.at(0));
+ QVERIFY(frame.bits(0));
+
+ if (strides.size() > 1) {
+ QCOMPARE(frame.bytesPerLine(1), strides.at(1));
+ QCOMPARE(int(frame.bits(1) - frame.bits(0)), offsets.at(0));
+ }
+ if (strides.size() > 2) {
+ QCOMPARE(frame.bytesPerLine(2), strides.at(2));
+ QCOMPARE(int(frame.bits(2) - frame.bits(0)), offsets.at(1));
+ }
+ if (strides.size() > 3) {
+ QCOMPARE(frame.bytesPerLine(3), strides.at(3));
+ QCOMPARE(int(frame.bits(3) - frame.bits(0)), offsets.at(0));
+ }
+
+ frame.unmap();
+}
+
+void tst_QVideoFrame::formatConversion_data()
+{
+ QTest::addColumn<QImage::Format>("imageFormat");
+ QTest::addColumn<QVideoFrameFormat::PixelFormat>("pixelFormat");
+
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ QTest::newRow("QImage::Format_RGB32 | QVideoFrameFormat::Format_BGRX8888")
+ << QImage::Format_RGB32
+ << QVideoFrameFormat::Format_BGRX8888;
+ QTest::newRow("QImage::Format_ARGB32 | QVideoFrameFormat::Format_BGRA8888")
+ << QImage::Format_ARGB32
+ << QVideoFrameFormat::Format_BGRA8888;
+ QTest::newRow("QImage::Format_ARGB32_Premultiplied | QVideoFrameFormat::Format_BGRA8888_Premultiplied")
+ << QImage::Format_ARGB32_Premultiplied
+ << QVideoFrameFormat::Format_BGRA8888_Premultiplied;
+ QTest::newRow("QVideoFrameFormat::Format_ARGB8888")
+ << QImage::Format_Invalid
+ << QVideoFrameFormat::Format_ARGB8888;
+ QTest::newRow("QVideoFrameFormat::Format_ARGB8888_Premultiplied")
+ << QImage::Format_Invalid
+ << QVideoFrameFormat::Format_ARGB8888_Premultiplied;
+#else
+ QTest::newRow("QImage::Format_RGB32 | QVideoFrameFormat::Format_XRGB8888")
+ << QImage::Format_RGB32
+ << QVideoFrameFormat::Format_XRGB8888;
+ QTest::newRow("QImage::Format_ARGB32 | QVideoFrameFormat::Format_ARGB8888")
+ << QImage::Format_ARGB32
+ << QVideoFrameFormat::Format_ARGB8888;
+ QTest::newRow("QImage::Format_ARGB32_Premultiplied | QVideoFrameFormat::Format_ARGB8888_Premultiplied")
+ << QImage::Format_ARGB32_Premultiplied
+ << QVideoFrameFormat::Format_ARGB8888_Premultiplied;
+ QTest::newRow("QVideoFrameFormat::Format_BGRA8888")
+ << QImage::Format_Invalid
+ << QVideoFrameFormat::Format_BGRA8888;
+ QTest::newRow("QVideoFrameFormat::Format_BGRA8888_Premultiplied")
+ << QImage::Format_Invalid
+ << QVideoFrameFormat::Format_BGRA8888_Premultiplied;
+#endif
+
+ QTest::newRow("QImage::Format_MonoLSB")
+ << QImage::Format_MonoLSB
+ << QVideoFrameFormat::Format_Invalid;
+ QTest::newRow("QImage::Format_Indexed8")
+ << QImage::Format_Indexed8
+ << QVideoFrameFormat::Format_Invalid;
+ QTest::newRow("QImage::Format_ARGB6666_Premultiplied")
+ << QImage::Format_ARGB6666_Premultiplied
+ << QVideoFrameFormat::Format_Invalid;
+ QTest::newRow("QImage::Format_ARGB8555_Premultiplied")
+ << QImage::Format_ARGB8555_Premultiplied
+ << QVideoFrameFormat::Format_Invalid;
+ QTest::newRow("QImage::Format_RGB666")
+ << QImage::Format_RGB666
+ << QVideoFrameFormat::Format_Invalid;
+ QTest::newRow("QImage::Format_RGB444")
+ << QImage::Format_RGB444
+ << QVideoFrameFormat::Format_Invalid;
+ QTest::newRow("QImage::Format_ARGB4444_Premultiplied")
+ << QImage::Format_ARGB4444_Premultiplied
+ << QVideoFrameFormat::Format_Invalid;
+
+ QTest::newRow("QVideoFrameFormat::Format_BGR32")
+ << QImage::Format_Invalid
+ << QVideoFrameFormat::Format_XBGR8888;
+ QTest::newRow("QVideoFrameFormat::Format_AYUV")
+ << QImage::Format_Invalid
+ << QVideoFrameFormat::Format_AYUV;
+ QTest::newRow("QVideoFrameFormat::Format_AYUV_Premultiplied")
+ << QImage::Format_Invalid
+ << QVideoFrameFormat::Format_AYUV_Premultiplied;
+ QTest::newRow("QVideoFrameFormat::Format_YUV420P")
+ << QImage::Format_Invalid
+ << QVideoFrameFormat::Format_YUV420P;
+ QTest::newRow("QVideoFrameFormat::Format_YV12")
+ << QImage::Format_Invalid
+ << QVideoFrameFormat::Format_YV12;
+ QTest::newRow("QVideoFrameFormat::Format_UYVY")
+ << QImage::Format_Invalid
+ << QVideoFrameFormat::Format_UYVY;
+ QTest::newRow("QVideoFrameFormat::Format_YUYV")
+ << QImage::Format_Invalid
+ << QVideoFrameFormat::Format_YUYV;
+ QTest::newRow("QVideoFrameFormat::Format_NV12")
+ << QImage::Format_Invalid
+ << QVideoFrameFormat::Format_NV12;
+ QTest::newRow("QVideoFrameFormat::Format_NV21")
+ << QImage::Format_Invalid
+ << QVideoFrameFormat::Format_NV21;
+ QTest::newRow("QVideoFrameFormat::Format_IMC1")
+ << QImage::Format_Invalid
+ << QVideoFrameFormat::Format_IMC1;
+ QTest::newRow("QVideoFrameFormat::Format_IMC2")
+ << QImage::Format_Invalid
+ << QVideoFrameFormat::Format_IMC2;
+ QTest::newRow("QVideoFrameFormat::Format_IMC3")
+ << QImage::Format_Invalid
+ << QVideoFrameFormat::Format_IMC3;
+ QTest::newRow("QVideoFrameFormat::Format_IMC4")
+ << QImage::Format_Invalid
+ << QVideoFrameFormat::Format_IMC4;
+ QTest::newRow("QVideoFrameFormat::Format_Y8")
+ << QImage::Format_Grayscale8
+ << QVideoFrameFormat::Format_Y8;
+ QTest::newRow("QVideoFrameFormat::Format_Y16")
+ << QImage::Format_Grayscale16
+ << QVideoFrameFormat::Format_Y16;
+ QTest::newRow("QVideoFrameFormat::Format_Jpeg")
+ << QImage::Format_Invalid
+ << QVideoFrameFormat::Format_Jpeg;
+ QTest::newRow("QVideoFrameFormat::Format_RGBX8888")
+ << QImage::Format_RGBX8888 << QVideoFrameFormat::Format_RGBX8888;
+ QTest::newRow("QImage::Format_RGBA8888_Premultiplied => QVideoFrameFormat::Format_RGBX8888 "
+ "(workaround)")
+ << QImage::Format_RGBA8888_Premultiplied << QVideoFrameFormat::Format_RGBX8888;
+}
+
+void tst_QVideoFrame::formatConversion()
+{
+ QFETCH(QImage::Format, imageFormat);
+ QFETCH(QVideoFrameFormat::PixelFormat, pixelFormat);
+
+ if (imageFormat != QImage::Format_Invalid)
+ QCOMPARE(QVideoFrameFormat::pixelFormatFromImageFormat(imageFormat), pixelFormat);
+
+ if (imageFormat == QImage::Format_RGBA8888_Premultiplied) {
+ qWarning() << "Workaround: convert QImage::Format_RGBA8888_Premultiplied to "
+ "QVideoFrameFormat::Format_RGBX8888; to be removed in 6.8";
+ return;
+ }
+
+ if (pixelFormat != QVideoFrameFormat::Format_Invalid)
+ QCOMPARE(QVideoFrameFormat::imageFormatFromPixelFormat(pixelFormat), imageFormat);
+}
+
+void tst_QVideoFrame::qImageFromVideoFrame_doesNotCrash_whenCalledWithEvenAndOddSizedFrames_data() {
+ QTest::addColumn<QSize>("size");
+ QTest::addColumn<QVideoFrameFormat::PixelFormat>("pixelFormat");
+ QTest::addColumn<bool>("forceCpuConversion");
+ QTest::addColumn<bool>("supportedOnPlatform");
+
+ const std::vector<QSize> sizes{
+ // Even sized
+ { 2, 2 },
+ { 2, 10 },
+ { 10, 2 },
+ { 640, 480 },
+ { 4096, 2160 },
+ // Odd sized
+ { 0, 0 },
+ { 3, 3 },
+ { 2, 3 },
+ { 3, 2 },
+ { 641, 480 },
+ { 640, 481 },
+ // TODO: Crashes
+ // { 1, 1 } // TODO: Division by zero in QVideoFrame::map (Debug)
+ // { 1, 2 } // TODO: D3D validation error in QRhiD3D11::executeCommandBuffer
+ // { 2, 1 } // TODO: D3D validation error in QRhiD3D11::executeCommandBuffer
+ };
+
+ for (const QSize &size : sizes) {
+ for (const QVideoFrameFormat::PixelFormat pixelFormat : s_pixelFormats) {
+ for (const bool forceCpu : { false, true }) {
+
+ if (pixelFormat == QVideoFrameFormat::Format_YUV420P10 && forceCpu)
+ continue; // TODO: Cpu conversion not implemented
+
+ QString name = QStringLiteral("%1x%2_%3%4")
+ .arg(size.width())
+ .arg(size.height())
+ .arg(QVideoFrameFormat::pixelFormatToString(pixelFormat))
+ .arg(forceCpu ? "_cpu" : "");
+
+ QTest::addRow("%s", name.toLatin1().data())
+ << size << pixelFormat << forceCpu << isSupportedPixelFormat(pixelFormat);
+ }
+ }
+ }
+}
+
+void tst_QVideoFrame::qImageFromVideoFrame_doesNotCrash_whenCalledWithEvenAndOddSizedFrames() {
+ QFETCH(const QSize, size);
+ QFETCH(const QVideoFrameFormat::PixelFormat, pixelFormat);
+ QFETCH(const bool, forceCpuConversion);
+ QFETCH(const bool, supportedOnPlatform);
+
+ const QVideoFrameFormat format{ size, pixelFormat };
+ const QVideoFrame frame{ format };
+ const QImage actual = qImageFromVideoFrame(frame, QtVideo::Rotation::None, false, false,
+ forceCpuConversion);
+
+ if (supportedOnPlatform)
+ QCOMPARE_EQ(actual.isNull(), size.isEmpty());
+ // Otherwise, we don't expect an image being produced, although it might.
+ // TODO: Investigate why 16 bit formats fail on some Android flavors.
+}
+
+#define TEST_MAPPED(frame, mode) \
+do { \
+ QVERIFY(frame.bits(0)); \
+ QVERIFY(frame.isMapped()); \
+ QCOMPARE(frame.mappedBytes(0), 16384); \
+ QCOMPARE(frame.bytesPerLine(0), 256); \
+ QCOMPARE(static_cast<QtVideo::MapMode>(frame.mapMode()), mode); \
+} while (0)
+
+#define TEST_UNMAPPED(frame) \
+do { \
+ QVERIFY(!frame.bits(0)); \
+ QVERIFY(!frame.isMapped()); \
+ QCOMPARE(frame.mappedBytes(0), 0); \
+ QCOMPARE(frame.bytesPerLine(0), 0); \
+ QCOMPARE(static_cast<QtVideo::MapMode>(frame.mapMode()), QtVideo::MapMode::NotMapped); \
+} while (0)
+
+void tst_QVideoFrame::isMapped()
+{
+ QVideoFrame frame(QVideoFrameFormat(QSize(64, 64), QVideoFrameFormat::Format_ARGB8888));
+ const QVideoFrame& constFrame(frame);
+
+ TEST_UNMAPPED(frame);
+ TEST_UNMAPPED(constFrame);
+
+ QVERIFY(frame.map(QtVideo::MapMode::ReadOnly));
+ TEST_MAPPED(frame, QtVideo::MapMode::ReadOnly);
+ TEST_MAPPED(constFrame, QtVideo::MapMode::ReadOnly);
+ frame.unmap();
+ TEST_UNMAPPED(frame);
+ TEST_UNMAPPED(constFrame);
+
+ QVERIFY(frame.map(QtVideo::MapMode::WriteOnly));
+ TEST_MAPPED(frame, QtVideo::MapMode::WriteOnly);
+ TEST_MAPPED(constFrame, QtVideo::MapMode::WriteOnly);
+ frame.unmap();
+ TEST_UNMAPPED(frame);
+ TEST_UNMAPPED(constFrame);
+
+ QVERIFY(frame.map(QtVideo::MapMode::ReadWrite));
+ TEST_MAPPED(frame, QtVideo::MapMode::ReadWrite);
+ TEST_MAPPED(constFrame, QtVideo::MapMode::ReadWrite);
+ frame.unmap();
+ TEST_UNMAPPED(frame);
+ TEST_UNMAPPED(constFrame);
+}
+
+void tst_QVideoFrame::isReadable()
+{
+ QVideoFrame frame(QVideoFrameFormat(QSize(64, 64), QVideoFrameFormat::Format_ARGB8888));
+
+ QVERIFY(!frame.isMapped());
+ QVERIFY(!frame.isReadable());
+
+ QVERIFY(frame.map(QtVideo::MapMode::ReadOnly));
+ QVERIFY(frame.isMapped());
+ QVERIFY(frame.isReadable());
+ frame.unmap();
+
+ QVERIFY(frame.map(QtVideo::MapMode::WriteOnly));
+ QVERIFY(frame.isMapped());
+ QVERIFY(!frame.isReadable());
+ frame.unmap();
+
+ QVERIFY(frame.map(QtVideo::MapMode::ReadWrite));
+ QVERIFY(frame.isMapped());
+ QVERIFY(frame.isReadable());
+ frame.unmap();
+}
+
+void tst_QVideoFrame::isWritable()
+{
+ QVideoFrame frame(QVideoFrameFormat(QSize(64, 64), QVideoFrameFormat::Format_ARGB8888));
+
+ QVERIFY(!frame.isMapped());
+ QVERIFY(!frame.isWritable());
+
+ QVERIFY(frame.map(QtVideo::MapMode::ReadOnly));
+ QVERIFY(frame.isMapped());
+ QVERIFY(!frame.isWritable());
+ frame.unmap();
+
+ QVERIFY(frame.map(QtVideo::MapMode::WriteOnly));
+ QVERIFY(frame.isMapped());
+ QVERIFY(frame.isWritable());
+ frame.unmap();
+
+ QVERIFY(frame.map(QtVideo::MapMode::ReadWrite));
+ QVERIFY(frame.isMapped());
+ QVERIFY(frame.isWritable());
+ frame.unmap();
+}
+
+void tst_QVideoFrame::image_data()
+{
+ QTest::addColumn<QSize>("size");
+ QTest::addColumn<QVideoFrameFormat::PixelFormat>("pixelFormat");
+
+ QTest::newRow("64x64 ARGB32")
+ << QSize(64, 64)
+ << QVideoFrameFormat::Format_ARGB8888;
+
+ QTest::newRow("64x64 ARGB32_Premultiplied")
+ << QSize(64, 64)
+ << QVideoFrameFormat::Format_ARGB8888_Premultiplied;
+
+ QTest::newRow("64x64 RGB32")
+ << QSize(64, 64)
+ << QVideoFrameFormat::Format_XRGB8888;
+
+ QTest::newRow("64x64 BGRA32")
+ << QSize(64, 64)
+ << QVideoFrameFormat::Format_BGRA8888;
+
+ QTest::newRow("64x64 BGRA32_Premultiplied")
+ << QSize(64, 64)
+ << QVideoFrameFormat::Format_BGRA8888_Premultiplied;
+
+ QTest::newRow("64x64 BGR32")
+ << QSize(64, 64)
+ << QVideoFrameFormat::Format_XBGR8888;
+
+ QTest::newRow("64x64 AYUV")
+ << QSize(64, 64)
+ << QVideoFrameFormat::Format_AYUV;
+
+ QTest::newRow("64x64 YUV420P")
+ << QSize(64, 64)
+ << QVideoFrameFormat::Format_YUV420P;
+
+ QTest::newRow("64x64 YV12")
+ << QSize(64, 64)
+ << QVideoFrameFormat::Format_YV12;
+
+ QTest::newRow("64x64 UYVY")
+ << QSize(64, 64)
+ << QVideoFrameFormat::Format_UYVY;
+
+ QTest::newRow("64x64 YUYV")
+ << QSize(64, 64)
+ << QVideoFrameFormat::Format_YUYV;
+
+ QTest::newRow("64x64 NV12")
+ << QSize(64, 64)
+ << QVideoFrameFormat::Format_NV12;
+
+ QTest::newRow("64x64 NV21")
+ << QSize(64, 64)
+ << QVideoFrameFormat::Format_NV21;
+}
+
+void tst_QVideoFrame::image()
+{
+ QFETCH(QSize, size);
+ QFETCH(QVideoFrameFormat::PixelFormat, pixelFormat);
+
+ QVideoFrame frame(QVideoFrameFormat(size, pixelFormat));
+ QImage img = frame.toImage();
+
+ QVERIFY(!img.isNull());
+ QCOMPARE(img.size(), size);
+}
+
+void tst_QVideoFrame::emptyData()
+{
+ QByteArray data(nullptr, 0);
+ QVideoFrame f = QVideoFramePrivate::createFrame(
+ std::make_unique<QMemoryVideoBuffer>(data, 600),
+ QVideoFrameFormat(QSize(800, 600), QVideoFrameFormat::Format_ARGB8888));
+ QVERIFY(!f.map(QtVideo::MapMode::ReadOnly));
+}
+
+void tst_QVideoFrame::mirrored_takesValue_fromVideoFrameFormat()
+{
+ QVideoFrameFormat format(QSize(10, 20), QVideoFrameFormat::Format_ARGB8888);
+ format.setMirrored(true);
+
+ QVideoFrame frame(format);
+ QVERIFY(frame.mirrored());
+
+ frame.setMirrored(false);
+ frame.setRotation(QtVideo::Rotation::Clockwise180);
+ QVERIFY(!frame.mirrored());
+ QVERIFY(!frame.surfaceFormat().isMirrored());
+}
+
+void tst_QVideoFrame::rotation_takesValue_fromVideoFrameFormat()
+{
+ QVideoFrameFormat format(QSize(10, 20), QVideoFrameFormat::Format_ARGB8888);
+ format.setRotation(QtVideo::Rotation::Clockwise270);
+
+ QVideoFrame frame(format);
+ QCOMPARE(frame.rotation(), QtVideo::Rotation::Clockwise270);
+
+ frame.setRotation(QtVideo::Rotation::Clockwise180);
+
+ QCOMPARE(frame.rotation(), QtVideo::Rotation::Clockwise180);
+ QCOMPARE(frame.surfaceFormat().rotation(), QtVideo::Rotation::Clockwise180);
+}
+
+void tst_QVideoFrame::streamFrameRate_takesValue_fromVideoFrameFormat()
+{
+ QVideoFrameFormat format(QSize(10, 20), QVideoFrameFormat::Format_ARGB8888);
+ format.setStreamFrameRate(20.);
+
+ QVideoFrame frame(format);
+ QCOMPARE(frame.streamFrameRate(), 20.);
+
+ frame.setStreamFrameRate(25.);
+
+ QCOMPARE(frame.streamFrameRate(), 25.);
+ QCOMPARE(frame.surfaceFormat().streamFrameRate(), 25.);
+}
+
+void tst_QVideoFrame::constructor_createsInvalidFrame_whenCalledWithNullImage()
+{
+ const QVideoFrame frame{ QImage{} };
+ QVERIFY(!frame.isValid());
+}
+
+void tst_QVideoFrame::constructor_createsInvalidFrame_whenCalledWithEmptyImage()
+{
+ {
+ const QImage image{ QSize{}, QImage::Format_RGB32 };
+ const QVideoFrame frame{ image };
+
+ QVERIFY(!frame.isValid());
+ }
+
+ {
+ const QImage image{ { 0, 0 }, QImage::Format_RGB32 };
+ const QVideoFrame frame{ image };
+
+ QVERIFY(!frame.isValid());
+ }
+
+ {
+ const QImage image{ { 1, 0 }, QImage::Format_RGB32 };
+ const QVideoFrame frame{ image };
+
+ QVERIFY(!frame.isValid());
+ }
+
+ {
+ const QImage image{ { 0, 1 }, QImage::Format_RGB32 };
+ const QVideoFrame frame{ image };
+
+ QVERIFY(!frame.isValid());
+ }
+}
+
+void tst_QVideoFrame::constructor_createsInvalidFrame_whenCalledWithInvalidImageFormat()
+{
+ const QImage image{ { 1, 1 }, QImage::Format_Invalid};
+ const QVideoFrame frame{ image };
+
+ QVERIFY(!frame.isValid());
+}
+
+// clang-format off
+void tst_QVideoFrame::constructor_createsFrameWithCorrectFormat_whenCalledWithSupportedImageFormats_data()
+{
+ QTest::addColumn<QImage::Format>("imageFormat");
+ QTest::addColumn<QVideoFrameFormat::PixelFormat>("expectedFrameFormat");
+
+ // Formats that do not require conversion
+ QTest::newRow("Format_RGB32") << QImage::Format_RGB32 << QVideoFrameFormat::Format_BGRX8888;
+ QTest::newRow("Format_ARGB32") << QImage::Format_ARGB32 << QVideoFrameFormat::Format_BGRA8888;
+ QTest::newRow("Format_ARGB32_Premultiplied") << QImage::Format_ARGB32_Premultiplied << QVideoFrameFormat::Format_BGRA8888_Premultiplied;
+ QTest::newRow("Format_RGBA8888") << QImage::Format_RGBA8888 << QVideoFrameFormat::Format_RGBA8888;
+ QTest::newRow("Format_RGBA8888_Premultiplied") << QImage::Format_RGBA8888_Premultiplied << QVideoFrameFormat::Format_RGBX8888;
+ QTest::newRow("Format_RGBX8888") << QImage::Format_RGBX8888 << QVideoFrameFormat::Format_RGBX8888;
+ QTest::newRow("Format_Grayscale8") << QImage::Format_Grayscale8 << QVideoFrameFormat::Format_Y8;
+ QTest::newRow("Format_Grayscale16") << QImage::Format_Grayscale16 << QVideoFrameFormat::Format_Y16;
+
+ // Formats that require conversion of input image
+ QTest::newRow("Format_Mono") << QImage::Format_Mono << QVideoFrameFormat::Format_BGRX8888;
+ QTest::newRow("Format_MonoLSB") << QImage::Format_MonoLSB << QVideoFrameFormat::Format_BGRX8888;
+ QTest::newRow("Format_Indexed8") << QImage::Format_Indexed8 << QVideoFrameFormat::Format_BGRX8888;
+ QTest::newRow("Format_RGB16") << QImage::Format_RGB16 << QVideoFrameFormat::Format_BGRX8888;
+ QTest::newRow("Format_ARGB8565_Premultiplied") << QImage::Format_ARGB8565_Premultiplied << QVideoFrameFormat::Format_BGRA8888_Premultiplied;
+ QTest::newRow("Format_RGB666") << QImage::Format_RGB666 << QVideoFrameFormat::Format_BGRX8888;
+ QTest::newRow("Format_ARGB6666_Premultiplied") << QImage::Format_ARGB6666_Premultiplied << QVideoFrameFormat::Format_BGRA8888_Premultiplied;
+ QTest::newRow("Format_RGB555") << QImage::Format_RGB555 << QVideoFrameFormat::Format_BGRX8888;
+ QTest::newRow("Format_ARGB8555_Premultiplied") << QImage::Format_ARGB8555_Premultiplied << QVideoFrameFormat::Format_BGRA8888_Premultiplied;
+ QTest::newRow("Format_RGB888") << QImage::Format_RGB888 << QVideoFrameFormat::Format_BGRX8888;
+ QTest::newRow("Format_RGB444") << QImage::Format_RGB444 << QVideoFrameFormat::Format_BGRX8888;
+ QTest::newRow("Format_ARGB4444_Premultiplied") << QImage::Format_ARGB4444_Premultiplied << QVideoFrameFormat::Format_BGRA8888_Premultiplied;
+ QTest::newRow("Format_BGR30") << QImage::Format_BGR30 << QVideoFrameFormat::Format_BGRX8888;
+ QTest::newRow("Format_A2BGR30_Premultiplied") << QImage::Format_A2BGR30_Premultiplied << QVideoFrameFormat::Format_BGRA8888_Premultiplied;
+ QTest::newRow("Format_RGB30") << QImage::Format_RGB30 << QVideoFrameFormat::Format_BGRX8888;
+ QTest::newRow("Format_A2RGB30_Premultiplied") << QImage::Format_A2RGB30_Premultiplied << QVideoFrameFormat::Format_BGRA8888_Premultiplied;
+ QTest::newRow("Format_Alpha8") << QImage::Format_Alpha8 << QVideoFrameFormat::Format_BGRA8888;
+ QTest::newRow("Format_RGBX64") << QImage::Format_RGBX64 << QVideoFrameFormat::Format_BGRX8888;
+ QTest::newRow("Format_RGBA64") << QImage::Format_RGBA64 << QVideoFrameFormat::Format_BGRA8888;
+ QTest::newRow("Format_RGBA64_Premultiplied") << QImage::Format_RGBA64_Premultiplied << QVideoFrameFormat::Format_BGRA8888_Premultiplied;
+ QTest::newRow("Format_BGR888") << QImage::Format_BGR888 << QVideoFrameFormat::Format_BGRX8888;
+ QTest::newRow("Format_RGBX16FPx4") << QImage::Format_RGBX16FPx4 << QVideoFrameFormat::Format_BGRX8888;
+ QTest::newRow("Format_RGBA16FPx4") << QImage::Format_RGBA16FPx4 << QVideoFrameFormat::Format_BGRA8888;
+ QTest::newRow("Format_RGBA16FPx4_Premultiplied") << QImage::Format_RGBA16FPx4_Premultiplied << QVideoFrameFormat::Format_BGRA8888_Premultiplied;
+ QTest::newRow("Format_RGBX32FPx4") << QImage::Format_RGBX32FPx4 << QVideoFrameFormat::Format_BGRX8888;
+ QTest::newRow("Format_RGBA32FPx4") << QImage::Format_RGBA32FPx4 << QVideoFrameFormat::Format_BGRA8888;
+ QTest::newRow("Format_RGBA32FPx4_Premultiplied") << QImage::Format_RGBA32FPx4_Premultiplied << QVideoFrameFormat::Format_BGRA8888_Premultiplied;
+}
+// clang-format on
+
+void tst_QVideoFrame::constructor_createsFrameWithCorrectFormat_whenCalledWithSupportedImageFormats()
+{
+ QFETCH(const QImage::Format, imageFormat);
+ QFETCH(QVideoFrameFormat::PixelFormat, expectedFrameFormat);
+
+ const QImage image{ { 1, 1 }, imageFormat };
+ const QVideoFrame frame{ image };
+
+ QVERIFY(frame.isValid());
+ QCOMPARE_EQ(frame.pixelFormat(), expectedFrameFormat);
+}
+
+// clang-format off
+void tst_QVideoFrame::constructor_copiesImageData_whenCalledWithRGBFormats_data()
+{
+ QTest::addColumn<QImage::Format>("imageFormat");
+
+ // Formats that do not require image conversion
+ QTest::newRow("Format_RGB32") << QImage::Format_RGB32;
+ QTest::newRow("Format_RGBX8888") << QImage::Format_RGBX8888;
+ QTest::newRow("Format_ARGB32") << QImage::Format_ARGB32;
+ QTest::newRow("Format_ARGB32_Premultiplied") << QImage::Format_ARGB32_Premultiplied;
+ QTest::newRow("Format_RGBA8888") << QImage::Format_RGBA8888;
+ QTest::newRow("Format_RGBA8888_Premultiplied") << QImage::Format_RGBA8888_Premultiplied;
+
+ // Formats that require image conversion
+ QTest::newRow("Format_Mono") << QImage::Format_Mono;
+ QTest::newRow("Format_MonoLSB") << QImage::Format_MonoLSB;
+ QTest::newRow("Format_Indexed8") << QImage::Format_Indexed8;
+ QTest::newRow("Format_RGB16") << QImage::Format_RGB16;
+ QTest::newRow("Format_ARGB8565_Premultiplied") << QImage::Format_ARGB8565_Premultiplied;
+ QTest::newRow("Format_RGB666") << QImage::Format_RGB666;
+ QTest::newRow("Format_ARGB6666_Premultiplied") << QImage::Format_ARGB6666_Premultiplied;
+ QTest::newRow("Format_RGB555") << QImage::Format_RGB555;
+ QTest::newRow("Format_ARGB8555_Premultiplied") << QImage::Format_ARGB8555_Premultiplied;
+ QTest::newRow("Format_RGB888") << QImage::Format_RGB888;
+ QTest::newRow("Format_RGB444") << QImage::Format_RGB444;
+ QTest::newRow("Format_ARGB4444_Premultiplied") << QImage::Format_ARGB4444_Premultiplied;
+ QTest::newRow("Format_BGR30") << QImage::Format_BGR30;
+ QTest::newRow("Format_A2BGR30_Premultiplied") << QImage::Format_A2BGR30_Premultiplied;
+ QTest::newRow("Format_RGB30") << QImage::Format_RGB30;
+ QTest::newRow("Format_A2RGB30_Premultiplied") << QImage::Format_A2RGB30_Premultiplied;
+ QTest::newRow("Format_Alpha8") << QImage::Format_Alpha8;
+ QTest::newRow("Format_RGBX64") << QImage::Format_RGBX64;
+ QTest::newRow("Format_RGBA64") << QImage::Format_RGBA64;
+ QTest::newRow("Format_RGBA64_Premultiplied") << QImage::Format_RGBA64_Premultiplied;
+ QTest::newRow("Format_BGR888") << QImage::Format_BGR888;
+ QTest::newRow("Format_RGBX16FPx4") << QImage::Format_RGBX16FPx4;
+ QTest::newRow("Format_RGBA16FPx4") << QImage::Format_RGBA16FPx4;
+ QTest::newRow("Format_RGBA16FPx4_Premultiplied") << QImage::Format_RGBA16FPx4_Premultiplied;
+ QTest::newRow("Format_RGBX32FPx4") << QImage::Format_RGBX32FPx4;
+ QTest::newRow("Format_RGBA32FPx4") << QImage::Format_RGBA32FPx4;
+ QTest::newRow("Format_RGBA32FPx4_Premultiplied") << QImage::Format_RGBA32FPx4_Premultiplied;
+}
+
+// clang-format on
+
+void tst_QVideoFrame::constructor_copiesImageData_whenCalledWithRGBFormats()
+{
+ QFETCH(const QImage::Format, imageFormat);
+
+ // Arrange
+ const QImage image{ createTestImage(imageFormat) };
+
+ // Act
+ QVideoFrame frame{ image };
+
+ // Assert
+ QVERIFY(compareEq(frame, image));
+}
+
+QTEST_MAIN(tst_QVideoFrame)
+
+#include "tst_qvideoframe.moc"
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/CMakeLists.txt b/tests/auto/unit/multimedia/qvideoframecolormanagement/CMakeLists.txt
new file mode 100644
index 000000000..d2e3086d2
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/CMakeLists.txt
@@ -0,0 +1,18 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+
+file(GLOB_RECURSE test_data_glob
+ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
+ testdata/*)
+list(APPEND testdata_resource_files ${test_data_glob})
+
+qt_internal_add_test(tst_qvideoframecolormanagement
+ SOURCES
+ tst_qvideoframecolormanagement.cpp
+ LIBRARIES
+ Qt::Gui
+ Qt::MultimediaPrivate
+ BUILTIN_TESTDATA
+ TESTDATA ${testdata_resource_files}
+)
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg
new file mode 100644
index 000000000..52b0f620b
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_adobergb_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_adobergb_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_adobergb_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_adobergb_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_adobergb_full_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_adobergb_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_adobergb_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_adobergb_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_adobergb_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_adobergb_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_adobergb_video_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_adobergb_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt2020_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt2020_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt2020_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt2020_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt2020_full_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt2020_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt2020_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt2020_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt2020_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt2020_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt2020_video_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt2020_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt601_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt601_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt601_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt601_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt601_full_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt601_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt601_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt601_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt601_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt601_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt601_video_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt601_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt709_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt709_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt709_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt709_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt709_full_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt709_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt709_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt709_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt709_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt709_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt709_video_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_abgr8888_bt709_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_adobergb_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_adobergb_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_adobergb_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_adobergb_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_adobergb_full_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_adobergb_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_adobergb_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_adobergb_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_adobergb_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_adobergb_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_adobergb_video_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_adobergb_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt2020_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt2020_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt2020_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt2020_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt2020_full_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt2020_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt2020_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt2020_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt2020_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt2020_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt2020_video_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt2020_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt601_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt601_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt601_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt601_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt601_full_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt601_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt601_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt601_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt601_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt601_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt601_video_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt601_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt709_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt709_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt709_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt709_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt709_full_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt709_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt709_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt709_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt709_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt709_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt709_video_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_bt709_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_adobergb_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_adobergb_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_adobergb_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_adobergb_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_adobergb_full_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_adobergb_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_adobergb_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_adobergb_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_adobergb_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_adobergb_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_adobergb_video_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_adobergb_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt2020_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt2020_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt2020_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt2020_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt2020_full_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt2020_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt2020_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt2020_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt2020_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt2020_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt2020_video_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt2020_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt601_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt601_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt601_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt601_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt601_full_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt601_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt601_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt601_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt601_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt601_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt601_video_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt601_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt709_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt709_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt709_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt709_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt709_full_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt709_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt709_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt709_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt709_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt709_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt709_video_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_argb8888_premultiplied_bt709_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_adobergb_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_adobergb_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_adobergb_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_adobergb_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_adobergb_full_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_adobergb_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_adobergb_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_adobergb_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_adobergb_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_adobergb_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_adobergb_video_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_adobergb_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt2020_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt2020_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt2020_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt2020_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt2020_full_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt2020_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt2020_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt2020_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt2020_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt2020_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt2020_video_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt2020_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt601_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt601_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt601_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt601_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt601_full_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt601_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt601_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt601_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt601_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt601_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt601_video_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt601_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt709_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt709_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt709_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt709_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt709_full_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt709_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt709_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt709_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt709_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt709_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt709_video_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_bt709_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_adobergb_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_adobergb_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_adobergb_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_adobergb_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_adobergb_full_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_adobergb_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_adobergb_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_adobergb_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_adobergb_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_adobergb_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_adobergb_video_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_adobergb_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt2020_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt2020_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt2020_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt2020_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt2020_full_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt2020_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt2020_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt2020_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt2020_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt2020_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt2020_video_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt2020_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt601_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt601_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt601_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt601_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt601_full_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt601_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt601_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt601_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt601_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt601_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt601_video_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt601_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt709_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt709_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt709_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt709_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt709_full_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt709_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt709_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt709_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt709_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt709_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt709_video_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgra8888_premultiplied_bt709_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_adobergb_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_adobergb_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_adobergb_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_adobergb_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_adobergb_full_cpu.png
new file mode 100644
index 000000000..7d1d73109
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_adobergb_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_adobergb_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_adobergb_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_adobergb_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_adobergb_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_adobergb_video_cpu.png
new file mode 100644
index 000000000..7d1d73109
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_adobergb_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt2020_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt2020_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt2020_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt2020_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt2020_full_cpu.png
new file mode 100644
index 000000000..7d1d73109
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt2020_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt2020_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt2020_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt2020_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt2020_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt2020_video_cpu.png
new file mode 100644
index 000000000..7d1d73109
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt2020_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt601_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt601_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt601_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt601_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt601_full_cpu.png
new file mode 100644
index 000000000..7d1d73109
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt601_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt601_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt601_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt601_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt601_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt601_video_cpu.png
new file mode 100644
index 000000000..7d1d73109
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt601_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt709_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt709_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt709_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt709_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt709_full_cpu.png
new file mode 100644
index 000000000..7d1d73109
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt709_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt709_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt709_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt709_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt709_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt709_video_cpu.png
new file mode 100644
index 000000000..7d1d73109
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_bgrx8888_bt709_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_adobergb_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_adobergb_full.png
new file mode 100644
index 000000000..2af7cdaa4
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_adobergb_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_adobergb_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_adobergb_full_cpu.png
new file mode 100644
index 000000000..12685832f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_adobergb_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_adobergb_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_adobergb_video.png
new file mode 100644
index 000000000..2af7cdaa4
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_adobergb_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_adobergb_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_adobergb_video_cpu.png
new file mode 100644
index 000000000..12685832f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_adobergb_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt2020_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt2020_full.png
new file mode 100644
index 000000000..d6d461f5d
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt2020_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt2020_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt2020_full_cpu.png
new file mode 100644
index 000000000..2138f7b91
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt2020_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt2020_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt2020_video.png
new file mode 100644
index 000000000..2a4f7d8a7
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt2020_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt2020_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt2020_video_cpu.png
new file mode 100644
index 000000000..0de0ffbc5
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt2020_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt601_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt601_full.png
new file mode 100644
index 000000000..d291f62bb
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt601_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt601_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt601_full_cpu.png
new file mode 100644
index 000000000..33229f55f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt601_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt601_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt601_video.png
new file mode 100644
index 000000000..35296fc03
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt601_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt601_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt601_video_cpu.png
new file mode 100644
index 000000000..7b198e19b
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt601_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt709_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt709_full.png
new file mode 100644
index 000000000..64e5eb6dc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt709_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt709_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt709_full_cpu.png
new file mode 100644
index 000000000..33229f55f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt709_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt709_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt709_video.png
new file mode 100644
index 000000000..9f6bdd1ea
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt709_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt709_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt709_video_cpu.png
new file mode 100644
index 000000000..74b3efccd
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc1_bt709_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_adobergb_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_adobergb_full.png
new file mode 100644
index 000000000..90b2b3601
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_adobergb_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_adobergb_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_adobergb_full_cpu.png
new file mode 100644
index 000000000..12685832f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_adobergb_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_adobergb_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_adobergb_video.png
new file mode 100644
index 000000000..90b2b3601
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_adobergb_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_adobergb_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_adobergb_video_cpu.png
new file mode 100644
index 000000000..12685832f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_adobergb_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt2020_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt2020_full.png
new file mode 100644
index 000000000..2e78cfc31
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt2020_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt2020_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt2020_full_cpu.png
new file mode 100644
index 000000000..2138f7b91
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt2020_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt2020_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt2020_video.png
new file mode 100644
index 000000000..d673b7ce5
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt2020_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt2020_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt2020_video_cpu.png
new file mode 100644
index 000000000..0de0ffbc5
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt2020_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt601_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt601_full.png
new file mode 100644
index 000000000..8be30a706
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt601_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt601_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt601_full_cpu.png
new file mode 100644
index 000000000..33229f55f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt601_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt601_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt601_video.png
new file mode 100644
index 000000000..1f64ea0f1
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt601_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt601_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt601_video_cpu.png
new file mode 100644
index 000000000..7b198e19b
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt601_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt709_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt709_full.png
new file mode 100644
index 000000000..24fb9065e
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt709_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt709_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt709_full_cpu.png
new file mode 100644
index 000000000..33229f55f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt709_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt709_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt709_video.png
new file mode 100644
index 000000000..f737d8602
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt709_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt709_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt709_video_cpu.png
new file mode 100644
index 000000000..74b3efccd
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc2_bt709_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_adobergb_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_adobergb_full.png
new file mode 100644
index 000000000..2af7cdaa4
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_adobergb_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_adobergb_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_adobergb_full_cpu.png
new file mode 100644
index 000000000..12685832f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_adobergb_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_adobergb_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_adobergb_video.png
new file mode 100644
index 000000000..2af7cdaa4
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_adobergb_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_adobergb_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_adobergb_video_cpu.png
new file mode 100644
index 000000000..12685832f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_adobergb_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt2020_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt2020_full.png
new file mode 100644
index 000000000..d6d461f5d
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt2020_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt2020_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt2020_full_cpu.png
new file mode 100644
index 000000000..2138f7b91
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt2020_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt2020_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt2020_video.png
new file mode 100644
index 000000000..2a4f7d8a7
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt2020_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt2020_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt2020_video_cpu.png
new file mode 100644
index 000000000..0de0ffbc5
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt2020_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt601_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt601_full.png
new file mode 100644
index 000000000..d291f62bb
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt601_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt601_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt601_full_cpu.png
new file mode 100644
index 000000000..33229f55f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt601_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt601_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt601_video.png
new file mode 100644
index 000000000..35296fc03
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt601_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt601_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt601_video_cpu.png
new file mode 100644
index 000000000..7b198e19b
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt601_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt709_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt709_full.png
new file mode 100644
index 000000000..64e5eb6dc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt709_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt709_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt709_full_cpu.png
new file mode 100644
index 000000000..33229f55f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt709_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt709_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt709_video.png
new file mode 100644
index 000000000..9f6bdd1ea
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt709_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt709_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt709_video_cpu.png
new file mode 100644
index 000000000..74b3efccd
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc3_bt709_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_adobergb_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_adobergb_full.png
new file mode 100644
index 000000000..6efa73ea2
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_adobergb_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_adobergb_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_adobergb_full_cpu.png
new file mode 100644
index 000000000..12685832f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_adobergb_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_adobergb_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_adobergb_video.png
new file mode 100644
index 000000000..6efa73ea2
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_adobergb_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_adobergb_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_adobergb_video_cpu.png
new file mode 100644
index 000000000..12685832f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_adobergb_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt2020_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt2020_full.png
new file mode 100644
index 000000000..8d6a36a1c
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt2020_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt2020_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt2020_full_cpu.png
new file mode 100644
index 000000000..2138f7b91
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt2020_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt2020_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt2020_video.png
new file mode 100644
index 000000000..dab23bf0d
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt2020_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt2020_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt2020_video_cpu.png
new file mode 100644
index 000000000..0de0ffbc5
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt2020_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt601_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt601_full.png
new file mode 100644
index 000000000..36e787cef
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt601_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt601_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt601_full_cpu.png
new file mode 100644
index 000000000..33229f55f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt601_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt601_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt601_video.png
new file mode 100644
index 000000000..01e6ab967
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt601_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt601_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt601_video_cpu.png
new file mode 100644
index 000000000..7b198e19b
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt601_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt709_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt709_full.png
new file mode 100644
index 000000000..22beff2e8
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt709_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt709_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt709_full_cpu.png
new file mode 100644
index 000000000..33229f55f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt709_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt709_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt709_video.png
new file mode 100644
index 000000000..c2af074b8
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt709_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt709_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt709_video_cpu.png
new file mode 100644
index 000000000..74b3efccd
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_imc4_bt709_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_adobergb_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_adobergb_full.png
new file mode 100644
index 000000000..2af7cdaa4
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_adobergb_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_adobergb_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_adobergb_full_cpu.png
new file mode 100644
index 000000000..12685832f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_adobergb_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_adobergb_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_adobergb_video.png
new file mode 100644
index 000000000..2af7cdaa4
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_adobergb_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_adobergb_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_adobergb_video_cpu.png
new file mode 100644
index 000000000..12685832f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_adobergb_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt2020_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt2020_full.png
new file mode 100644
index 000000000..d6d461f5d
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt2020_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt2020_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt2020_full_cpu.png
new file mode 100644
index 000000000..2138f7b91
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt2020_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt2020_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt2020_video.png
new file mode 100644
index 000000000..2a4f7d8a7
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt2020_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt2020_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt2020_video_cpu.png
new file mode 100644
index 000000000..0de0ffbc5
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt2020_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt601_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt601_full.png
new file mode 100644
index 000000000..d291f62bb
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt601_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt601_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt601_full_cpu.png
new file mode 100644
index 000000000..33229f55f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt601_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt601_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt601_video.png
new file mode 100644
index 000000000..35296fc03
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt601_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt601_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt601_video_cpu.png
new file mode 100644
index 000000000..7b198e19b
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt601_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt709_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt709_full.png
new file mode 100644
index 000000000..64e5eb6dc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt709_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt709_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt709_full_cpu.png
new file mode 100644
index 000000000..33229f55f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt709_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt709_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt709_video.png
new file mode 100644
index 000000000..9f6bdd1ea
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt709_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt709_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt709_video_cpu.png
new file mode 100644
index 000000000..74b3efccd
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv12_bt709_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_adobergb_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_adobergb_full.png
new file mode 100644
index 000000000..2af7cdaa4
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_adobergb_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_adobergb_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_adobergb_full_cpu.png
new file mode 100644
index 000000000..12685832f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_adobergb_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_adobergb_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_adobergb_video.png
new file mode 100644
index 000000000..2af7cdaa4
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_adobergb_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_adobergb_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_adobergb_video_cpu.png
new file mode 100644
index 000000000..12685832f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_adobergb_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt2020_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt2020_full.png
new file mode 100644
index 000000000..d6d461f5d
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt2020_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt2020_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt2020_full_cpu.png
new file mode 100644
index 000000000..2138f7b91
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt2020_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt2020_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt2020_video.png
new file mode 100644
index 000000000..2a4f7d8a7
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt2020_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt2020_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt2020_video_cpu.png
new file mode 100644
index 000000000..0de0ffbc5
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt2020_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt601_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt601_full.png
new file mode 100644
index 000000000..d291f62bb
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt601_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt601_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt601_full_cpu.png
new file mode 100644
index 000000000..33229f55f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt601_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt601_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt601_video.png
new file mode 100644
index 000000000..35296fc03
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt601_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt601_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt601_video_cpu.png
new file mode 100644
index 000000000..7b198e19b
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt601_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt709_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt709_full.png
new file mode 100644
index 000000000..64e5eb6dc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt709_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt709_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt709_full_cpu.png
new file mode 100644
index 000000000..33229f55f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt709_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt709_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt709_video.png
new file mode 100644
index 000000000..9f6bdd1ea
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt709_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt709_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt709_video_cpu.png
new file mode 100644
index 000000000..74b3efccd
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_nv21_bt709_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_adobergb_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_adobergb_full.png
new file mode 100644
index 000000000..71e107b8a
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_adobergb_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_adobergb_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_adobergb_full_cpu.png
new file mode 100644
index 000000000..1242dd25b
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_adobergb_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_adobergb_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_adobergb_video.png
new file mode 100644
index 000000000..71e107b8a
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_adobergb_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_adobergb_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_adobergb_video_cpu.png
new file mode 100644
index 000000000..1242dd25b
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_adobergb_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt2020_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt2020_full.png
new file mode 100644
index 000000000..58a7ebc92
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt2020_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt2020_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt2020_full_cpu.png
new file mode 100644
index 000000000..4286840f8
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt2020_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt2020_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt2020_video.png
new file mode 100644
index 000000000..d8756caac
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt2020_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt2020_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt2020_video_cpu.png
new file mode 100644
index 000000000..fb6d356f8
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt2020_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt601_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt601_full.png
new file mode 100644
index 000000000..905568bf9
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt601_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt601_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt601_full_cpu.png
new file mode 100644
index 000000000..d819e478c
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt601_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt601_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt601_video.png
new file mode 100644
index 000000000..f374df207
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt601_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt601_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt601_video_cpu.png
new file mode 100644
index 000000000..2fbc2225c
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt601_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt709_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt709_full.png
new file mode 100644
index 000000000..d2ee0f8e2
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt709_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt709_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt709_full_cpu.png
new file mode 100644
index 000000000..d819e478c
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt709_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt709_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt709_video.png
new file mode 100644
index 000000000..740de7f79
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt709_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt709_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt709_video_cpu.png
new file mode 100644
index 000000000..d19223883
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p010_bt709_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_adobergb_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_adobergb_full.png
new file mode 100644
index 000000000..ad76d393a
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_adobergb_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_adobergb_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_adobergb_full_cpu.png
new file mode 100644
index 000000000..68509c232
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_adobergb_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_adobergb_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_adobergb_video.png
new file mode 100644
index 000000000..ad76d393a
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_adobergb_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_adobergb_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_adobergb_video_cpu.png
new file mode 100644
index 000000000..68509c232
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_adobergb_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt2020_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt2020_full.png
new file mode 100644
index 000000000..a6e47132c
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt2020_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt2020_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt2020_full_cpu.png
new file mode 100644
index 000000000..2cb927d35
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt2020_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt2020_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt2020_video.png
new file mode 100644
index 000000000..d9760b9c9
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt2020_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt2020_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt2020_video_cpu.png
new file mode 100644
index 000000000..3f65f27db
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt2020_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt601_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt601_full.png
new file mode 100644
index 000000000..04ae5e1cd
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt601_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt601_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt601_full_cpu.png
new file mode 100644
index 000000000..299548d61
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt601_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt601_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt601_video.png
new file mode 100644
index 000000000..9faa15fad
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt601_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt601_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt601_video_cpu.png
new file mode 100644
index 000000000..d544f8767
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt601_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt709_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt709_full.png
new file mode 100644
index 000000000..84b04ff9e
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt709_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt709_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt709_full_cpu.png
new file mode 100644
index 000000000..299548d61
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt709_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt709_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt709_video.png
new file mode 100644
index 000000000..505752c10
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt709_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt709_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt709_video_cpu.png
new file mode 100644
index 000000000..7da761925
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_p016_bt709_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_adobergb_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_adobergb_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_adobergb_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_adobergb_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_adobergb_full_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_adobergb_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_adobergb_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_adobergb_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_adobergb_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_adobergb_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_adobergb_video_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_adobergb_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt2020_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt2020_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt2020_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt2020_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt2020_full_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt2020_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt2020_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt2020_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt2020_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt2020_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt2020_video_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt2020_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt601_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt601_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt601_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt601_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt601_full_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt601_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt601_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt601_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt601_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt601_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt601_video_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt601_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt709_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt709_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt709_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt709_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt709_full_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt709_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt709_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt709_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt709_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt709_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt709_video_cpu.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgba8888_bt709_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_adobergb_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_adobergb_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_adobergb_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_adobergb_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_adobergb_full_cpu.png
new file mode 100644
index 000000000..7d1d73109
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_adobergb_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_adobergb_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_adobergb_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_adobergb_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_adobergb_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_adobergb_video_cpu.png
new file mode 100644
index 000000000..7d1d73109
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_adobergb_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt2020_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt2020_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt2020_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt2020_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt2020_full_cpu.png
new file mode 100644
index 000000000..7d1d73109
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt2020_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt2020_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt2020_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt2020_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt2020_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt2020_video_cpu.png
new file mode 100644
index 000000000..7d1d73109
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt2020_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt601_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt601_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt601_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt601_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt601_full_cpu.png
new file mode 100644
index 000000000..7d1d73109
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt601_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt601_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt601_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt601_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt601_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt601_video_cpu.png
new file mode 100644
index 000000000..7d1d73109
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt601_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt709_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt709_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt709_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt709_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt709_full_cpu.png
new file mode 100644
index 000000000..7d1d73109
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt709_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt709_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt709_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt709_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt709_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt709_video_cpu.png
new file mode 100644
index 000000000..7d1d73109
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_rgbx8888_bt709_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_adobergb_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_adobergb_full.png
new file mode 100644
index 000000000..c5243c441
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_adobergb_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_adobergb_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_adobergb_full_cpu.png
new file mode 100644
index 000000000..6a0cb7dd8
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_adobergb_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_adobergb_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_adobergb_video.png
new file mode 100644
index 000000000..c5243c441
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_adobergb_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_adobergb_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_adobergb_video_cpu.png
new file mode 100644
index 000000000..6a0cb7dd8
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_adobergb_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt2020_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt2020_full.png
new file mode 100644
index 000000000..0a9874943
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt2020_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt2020_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt2020_full_cpu.png
new file mode 100644
index 000000000..126744377
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt2020_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt2020_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt2020_video.png
new file mode 100644
index 000000000..7318c1e99
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt2020_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt2020_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt2020_video_cpu.png
new file mode 100644
index 000000000..908b28c2f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt2020_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt601_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt601_full.png
new file mode 100644
index 000000000..68789bef5
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt601_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt601_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt601_full_cpu.png
new file mode 100644
index 000000000..7ef68b58b
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt601_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt601_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt601_video.png
new file mode 100644
index 000000000..bfd6396ec
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt601_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt601_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt601_video_cpu.png
new file mode 100644
index 000000000..03e337184
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt601_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt709_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt709_full.png
new file mode 100644
index 000000000..704c59cf9
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt709_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt709_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt709_full_cpu.png
new file mode 100644
index 000000000..7ef68b58b
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt709_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt709_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt709_video.png
new file mode 100644
index 000000000..d9ad9c239
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt709_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt709_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt709_video_cpu.png
new file mode 100644
index 000000000..0030ce5bc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_uyvy_bt709_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_adobergb_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_adobergb_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_adobergb_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_adobergb_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_adobergb_full_cpu.png
new file mode 100644
index 000000000..7d1d73109
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_adobergb_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_adobergb_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_adobergb_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_adobergb_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_adobergb_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_adobergb_video_cpu.png
new file mode 100644
index 000000000..7d1d73109
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_adobergb_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt2020_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt2020_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt2020_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt2020_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt2020_full_cpu.png
new file mode 100644
index 000000000..7d1d73109
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt2020_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt2020_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt2020_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt2020_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt2020_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt2020_video_cpu.png
new file mode 100644
index 000000000..7d1d73109
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt2020_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt601_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt601_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt601_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt601_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt601_full_cpu.png
new file mode 100644
index 000000000..7d1d73109
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt601_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt601_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt601_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt601_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt601_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt601_video_cpu.png
new file mode 100644
index 000000000..7d1d73109
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt601_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt709_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt709_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt709_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt709_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt709_full_cpu.png
new file mode 100644
index 000000000..7d1d73109
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt709_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt709_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt709_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt709_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt709_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt709_video_cpu.png
new file mode 100644
index 000000000..7d1d73109
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xbgr8888_bt709_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_adobergb_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_adobergb_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_adobergb_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_adobergb_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_adobergb_full_cpu.png
new file mode 100644
index 000000000..7d1d73109
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_adobergb_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_adobergb_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_adobergb_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_adobergb_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_adobergb_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_adobergb_video_cpu.png
new file mode 100644
index 000000000..7d1d73109
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_adobergb_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt2020_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt2020_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt2020_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt2020_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt2020_full_cpu.png
new file mode 100644
index 000000000..7d1d73109
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt2020_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt2020_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt2020_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt2020_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt2020_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt2020_video_cpu.png
new file mode 100644
index 000000000..7d1d73109
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt2020_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt601_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt601_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt601_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt601_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt601_full_cpu.png
new file mode 100644
index 000000000..7d1d73109
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt601_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt601_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt601_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt601_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt601_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt601_video_cpu.png
new file mode 100644
index 000000000..7d1d73109
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt601_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt709_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt709_full.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt709_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt709_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt709_full_cpu.png
new file mode 100644
index 000000000..7d1d73109
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt709_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt709_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt709_video.png
new file mode 100644
index 000000000..682e999cc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt709_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt709_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt709_video_cpu.png
new file mode 100644
index 000000000..7d1d73109
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_xrgb8888_bt709_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_adobergb_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_adobergb_full.png
new file mode 100644
index 000000000..b1dc781f2
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_adobergb_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_adobergb_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_adobergb_full_cpu.png
new file mode 100644
index 000000000..584ad4c25
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_adobergb_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_adobergb_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_adobergb_video.png
new file mode 100644
index 000000000..b1dc781f2
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_adobergb_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_adobergb_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_adobergb_video_cpu.png
new file mode 100644
index 000000000..584ad4c25
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_adobergb_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt2020_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt2020_full.png
new file mode 100644
index 000000000..619ee36a4
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt2020_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt2020_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt2020_full_cpu.png
new file mode 100644
index 000000000..16445be0c
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt2020_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt2020_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt2020_video.png
new file mode 100644
index 000000000..881f6be33
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt2020_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt2020_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt2020_video_cpu.png
new file mode 100644
index 000000000..9c7e87238
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt2020_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt601_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt601_full.png
new file mode 100644
index 000000000..b1d3111df
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt601_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt601_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt601_full_cpu.png
new file mode 100644
index 000000000..1a3025e2d
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt601_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt601_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt601_video.png
new file mode 100644
index 000000000..e4d1ce940
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt601_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt601_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt601_video_cpu.png
new file mode 100644
index 000000000..614b71e3e
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt601_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt709_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt709_full.png
new file mode 100644
index 000000000..b1d3111df
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt709_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt709_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt709_full_cpu.png
new file mode 100644
index 000000000..1a3025e2d
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt709_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt709_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt709_video.png
new file mode 100644
index 000000000..df8df3edd
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt709_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt709_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt709_video_cpu.png
new file mode 100644
index 000000000..d6bed0482
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y16_bt709_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_adobergb_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_adobergb_full.png
new file mode 100644
index 000000000..130a3b541
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_adobergb_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_adobergb_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_adobergb_full_cpu.png
new file mode 100644
index 000000000..61d2c6ca0
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_adobergb_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_adobergb_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_adobergb_video.png
new file mode 100644
index 000000000..130a3b541
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_adobergb_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_adobergb_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_adobergb_video_cpu.png
new file mode 100644
index 000000000..61d2c6ca0
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_adobergb_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt2020_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt2020_full.png
new file mode 100644
index 000000000..21ed2218a
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt2020_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt2020_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt2020_full_cpu.png
new file mode 100644
index 000000000..188efe1d9
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt2020_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt2020_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt2020_video.png
new file mode 100644
index 000000000..f60f53d02
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt2020_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt2020_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt2020_video_cpu.png
new file mode 100644
index 000000000..512c467b6
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt2020_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt601_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt601_full.png
new file mode 100644
index 000000000..df59b71e7
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt601_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt601_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt601_full_cpu.png
new file mode 100644
index 000000000..bfc57d849
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt601_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt601_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt601_video.png
new file mode 100644
index 000000000..dbca71c70
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt601_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt601_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt601_video_cpu.png
new file mode 100644
index 000000000..52f4b0223
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt601_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt709_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt709_full.png
new file mode 100644
index 000000000..df59b71e7
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt709_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt709_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt709_full_cpu.png
new file mode 100644
index 000000000..bfc57d849
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt709_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt709_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt709_video.png
new file mode 100644
index 000000000..3479bb890
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt709_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt709_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt709_video_cpu.png
new file mode 100644
index 000000000..b3a488e2f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_y8_bt709_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p10_adobergb_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p10_adobergb_full.png
new file mode 100644
index 000000000..20b24da65
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p10_adobergb_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p10_adobergb_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p10_adobergb_video.png
new file mode 100644
index 000000000..20b24da65
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p10_adobergb_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p10_bt2020_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p10_bt2020_full.png
new file mode 100644
index 000000000..b96379a0b
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p10_bt2020_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p10_bt2020_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p10_bt2020_video.png
new file mode 100644
index 000000000..c77645b59
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p10_bt2020_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p10_bt601_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p10_bt601_full.png
new file mode 100644
index 000000000..a1b8b62da
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p10_bt601_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p10_bt601_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p10_bt601_video.png
new file mode 100644
index 000000000..7a69f6afa
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p10_bt601_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p10_bt709_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p10_bt709_full.png
new file mode 100644
index 000000000..644b083fe
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p10_bt709_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p10_bt709_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p10_bt709_video.png
new file mode 100644
index 000000000..d4e9debd7
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p10_bt709_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_adobergb_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_adobergb_full.png
new file mode 100644
index 000000000..2af7cdaa4
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_adobergb_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_adobergb_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_adobergb_full_cpu.png
new file mode 100644
index 000000000..12685832f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_adobergb_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_adobergb_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_adobergb_video.png
new file mode 100644
index 000000000..2af7cdaa4
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_adobergb_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_adobergb_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_adobergb_video_cpu.png
new file mode 100644
index 000000000..12685832f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_adobergb_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt2020_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt2020_full.png
new file mode 100644
index 000000000..d6d461f5d
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt2020_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt2020_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt2020_full_cpu.png
new file mode 100644
index 000000000..2138f7b91
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt2020_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt2020_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt2020_video.png
new file mode 100644
index 000000000..2a4f7d8a7
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt2020_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt2020_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt2020_video_cpu.png
new file mode 100644
index 000000000..0de0ffbc5
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt2020_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt601_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt601_full.png
new file mode 100644
index 000000000..d291f62bb
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt601_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt601_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt601_full_cpu.png
new file mode 100644
index 000000000..33229f55f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt601_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt601_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt601_video.png
new file mode 100644
index 000000000..35296fc03
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt601_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt601_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt601_video_cpu.png
new file mode 100644
index 000000000..7b198e19b
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt601_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt709_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt709_full.png
new file mode 100644
index 000000000..64e5eb6dc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt709_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt709_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt709_full_cpu.png
new file mode 100644
index 000000000..33229f55f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt709_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt709_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt709_video.png
new file mode 100644
index 000000000..9f6bdd1ea
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt709_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt709_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt709_video_cpu.png
new file mode 100644
index 000000000..74b3efccd
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv420p_bt709_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_adobergb_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_adobergb_full.png
new file mode 100644
index 000000000..3e255af2f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_adobergb_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_adobergb_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_adobergb_full_cpu.png
new file mode 100644
index 000000000..6a0cb7dd8
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_adobergb_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_adobergb_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_adobergb_video.png
new file mode 100644
index 000000000..3e255af2f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_adobergb_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_adobergb_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_adobergb_video_cpu.png
new file mode 100644
index 000000000..6a0cb7dd8
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_adobergb_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt2020_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt2020_full.png
new file mode 100644
index 000000000..74fd12726
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt2020_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt2020_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt2020_full_cpu.png
new file mode 100644
index 000000000..126744377
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt2020_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt2020_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt2020_video.png
new file mode 100644
index 000000000..e358d16d8
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt2020_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt2020_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt2020_video_cpu.png
new file mode 100644
index 000000000..908b28c2f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt2020_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt601_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt601_full.png
new file mode 100644
index 000000000..cb1cbbd34
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt601_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt601_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt601_full_cpu.png
new file mode 100644
index 000000000..7ef68b58b
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt601_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt601_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt601_video.png
new file mode 100644
index 000000000..6dd95a078
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt601_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt601_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt601_video_cpu.png
new file mode 100644
index 000000000..03e337184
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt601_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt709_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt709_full.png
new file mode 100644
index 000000000..3e92f3695
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt709_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt709_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt709_full_cpu.png
new file mode 100644
index 000000000..7ef68b58b
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt709_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt709_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt709_video.png
new file mode 100644
index 000000000..e94891e1c
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt709_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt709_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt709_video_cpu.png
new file mode 100644
index 000000000..0030ce5bc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuv422p_bt709_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_adobergb_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_adobergb_full.png
new file mode 100644
index 000000000..c5243c441
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_adobergb_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_adobergb_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_adobergb_full_cpu.png
new file mode 100644
index 000000000..6a0cb7dd8
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_adobergb_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_adobergb_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_adobergb_video.png
new file mode 100644
index 000000000..c5243c441
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_adobergb_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_adobergb_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_adobergb_video_cpu.png
new file mode 100644
index 000000000..6a0cb7dd8
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_adobergb_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt2020_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt2020_full.png
new file mode 100644
index 000000000..0a9874943
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt2020_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt2020_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt2020_full_cpu.png
new file mode 100644
index 000000000..126744377
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt2020_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt2020_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt2020_video.png
new file mode 100644
index 000000000..7318c1e99
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt2020_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt2020_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt2020_video_cpu.png
new file mode 100644
index 000000000..908b28c2f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt2020_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt601_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt601_full.png
new file mode 100644
index 000000000..68789bef5
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt601_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt601_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt601_full_cpu.png
new file mode 100644
index 000000000..7ef68b58b
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt601_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt601_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt601_video.png
new file mode 100644
index 000000000..bfd6396ec
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt601_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt601_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt601_video_cpu.png
new file mode 100644
index 000000000..03e337184
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt601_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt709_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt709_full.png
new file mode 100644
index 000000000..704c59cf9
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt709_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt709_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt709_full_cpu.png
new file mode 100644
index 000000000..7ef68b58b
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt709_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt709_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt709_video.png
new file mode 100644
index 000000000..d9ad9c239
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt709_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt709_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt709_video_cpu.png
new file mode 100644
index 000000000..0030ce5bc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yuyv_bt709_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_adobergb_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_adobergb_full.png
new file mode 100644
index 000000000..2af7cdaa4
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_adobergb_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_adobergb_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_adobergb_full_cpu.png
new file mode 100644
index 000000000..12685832f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_adobergb_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_adobergb_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_adobergb_video.png
new file mode 100644
index 000000000..2af7cdaa4
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_adobergb_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_adobergb_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_adobergb_video_cpu.png
new file mode 100644
index 000000000..12685832f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_adobergb_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt2020_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt2020_full.png
new file mode 100644
index 000000000..d6d461f5d
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt2020_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt2020_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt2020_full_cpu.png
new file mode 100644
index 000000000..2138f7b91
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt2020_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt2020_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt2020_video.png
new file mode 100644
index 000000000..2a4f7d8a7
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt2020_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt2020_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt2020_video_cpu.png
new file mode 100644
index 000000000..0de0ffbc5
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt2020_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt601_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt601_full.png
new file mode 100644
index 000000000..d291f62bb
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt601_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt601_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt601_full_cpu.png
new file mode 100644
index 000000000..33229f55f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt601_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt601_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt601_video.png
new file mode 100644
index 000000000..35296fc03
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt601_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt601_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt601_video_cpu.png
new file mode 100644
index 000000000..7b198e19b
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt601_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt709_full.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt709_full.png
new file mode 100644
index 000000000..64e5eb6dc
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt709_full.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt709_full_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt709_full_cpu.png
new file mode 100644
index 000000000..33229f55f
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt709_full_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt709_video.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt709_video.png
new file mode 100644
index 000000000..9f6bdd1ea
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt709_video.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt709_video_cpu.png b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt709_video_cpu.png
new file mode 100644
index 000000000..74b3efccd
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/testdata/umbrellas.jpg_yv12_bt709_video_cpu.png
Binary files differ
diff --git a/tests/auto/unit/multimedia/qvideoframecolormanagement/tst_qvideoframecolormanagement.cpp b/tests/auto/unit/multimedia/qvideoframecolormanagement/tst_qvideoframecolormanagement.cpp
new file mode 100644
index 000000000..ad221e54e
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframecolormanagement/tst_qvideoframecolormanagement.cpp
@@ -0,0 +1,475 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QtTest/QtTest>
+
+#include <qvideoframe.h>
+#include <qvideoframeformat.h>
+#include "private/qmemoryvideobuffer_p.h"
+#include "private/qvideoframeconverter_p.h"
+#include "private/qplatformmediaintegration_p.h"
+#include "private/qimagevideobuffer_p.h"
+#include "private/qvideoframe_p.h"
+#include <QtGui/QColorSpace>
+#include <QtGui/QImage>
+#include <QtCore/QPointer>
+
+#include "../../../integration/shared/mediabackendutils.h"
+
+QT_USE_NAMESPACE
+
+namespace {
+
+struct TestParams
+{
+ QString fileName;
+ QVideoFrameFormat::PixelFormat pixelFormat;
+ QVideoFrameFormat::ColorSpace colorSpace;
+ QVideoFrameFormat::ColorRange colorRange;
+ bool forceCpu;
+};
+
+QString toString(QVideoFrameFormat::ColorRange r)
+{
+ switch (r) {
+ case QVideoFrameFormat::ColorRange_Video:
+ return "Video";
+ case QVideoFrameFormat::ColorRange_Full:
+ return "Full";
+ default:
+ Q_ASSERT(false);
+ return "";
+ }
+}
+
+std::vector<QVideoFrameFormat::ColorRange> colorRanges()
+{
+ return {
+ QVideoFrameFormat::ColorRange_Video,
+ QVideoFrameFormat::ColorRange_Full,
+ };
+}
+
+const QSet s_formats{ QVideoFrameFormat::Format_ARGB8888,
+ QVideoFrameFormat::Format_ARGB8888_Premultiplied,
+ QVideoFrameFormat::Format_XRGB8888,
+ QVideoFrameFormat::Format_BGRA8888,
+ QVideoFrameFormat::Format_BGRA8888_Premultiplied,
+ QVideoFrameFormat::Format_BGRX8888,
+ QVideoFrameFormat::Format_ABGR8888,
+ QVideoFrameFormat::Format_XBGR8888,
+ QVideoFrameFormat::Format_RGBA8888,
+ QVideoFrameFormat::Format_RGBX8888,
+ QVideoFrameFormat::Format_NV12,
+ QVideoFrameFormat::Format_NV21,
+ QVideoFrameFormat::Format_IMC1,
+ QVideoFrameFormat::Format_IMC2,
+ QVideoFrameFormat::Format_IMC3,
+ QVideoFrameFormat::Format_IMC4,
+ QVideoFrameFormat::Format_AYUV,
+ QVideoFrameFormat::Format_AYUV_Premultiplied,
+ QVideoFrameFormat::Format_YV12,
+ QVideoFrameFormat::Format_YUV420P,
+ QVideoFrameFormat::Format_YUV422P,
+ QVideoFrameFormat::Format_UYVY,
+ QVideoFrameFormat::Format_YUYV,
+ QVideoFrameFormat::Format_Y8,
+ QVideoFrameFormat::Format_Y16,
+ QVideoFrameFormat::Format_P010,
+ QVideoFrameFormat::Format_P016,
+ QVideoFrameFormat::Format_YUV420P10 };
+
+bool hasCorrespondingFFmpegFormat(QVideoFrameFormat::PixelFormat format)
+{
+ return format != QVideoFrameFormat::Format_AYUV
+ && format != QVideoFrameFormat::Format_AYUV_Premultiplied;
+}
+
+bool supportsCpuConversion(QVideoFrameFormat::PixelFormat format)
+{
+ return format != QVideoFrameFormat::Format_YUV420P10;
+}
+
+QString toString(QVideoFrameFormat::PixelFormat f)
+{
+ return QVideoFrameFormat::pixelFormatToString(f);
+}
+
+QSet<QVideoFrameFormat::PixelFormat> pixelFormats()
+{
+ return s_formats;
+}
+
+bool isSupportedPixelFormat(QVideoFrameFormat::PixelFormat pixelFormat)
+{
+#ifdef Q_OS_ANDROID
+ // TODO: QTBUG-125238
+ switch (pixelFormat) {
+ case QVideoFrameFormat::Format_Y16:
+ case QVideoFrameFormat::Format_P010:
+ case QVideoFrameFormat::Format_P016:
+ case QVideoFrameFormat::Format_YUV420P10:
+ return false;
+ default:
+ return true;
+ }
+#else
+ return true;
+#endif
+}
+
+
+QString toString(QVideoFrameFormat::ColorSpace s)
+{
+ switch (s) {
+ case QVideoFrameFormat::ColorSpace_BT601:
+ return "BT601";
+ case QVideoFrameFormat::ColorSpace_BT709:
+ return "BT709";
+ case QVideoFrameFormat::ColorSpace_AdobeRgb:
+ return "AdobeRgb";
+ case QVideoFrameFormat::ColorSpace_BT2020:
+ return "BT2020";
+ default:
+ Q_ASSERT(false);
+ return "";
+ }
+}
+
+std::vector<QVideoFrameFormat::ColorSpace> colorSpaces()
+{
+ return { QVideoFrameFormat::ColorSpace_BT601, QVideoFrameFormat::ColorSpace_BT709,
+ QVideoFrameFormat::ColorSpace_AdobeRgb, QVideoFrameFormat::ColorSpace_BT2020 };
+}
+
+QString name(const TestParams &p)
+{
+ QString name = QStringLiteral("%1_%2_%3_%4%5")
+ .arg(p.fileName)
+ .arg(toString(p.pixelFormat))
+ .arg(toString(p.colorSpace))
+ .arg(toString(p.colorRange))
+ .arg(p.forceCpu ? "_cpu" : "")
+ .toLower();
+ name.replace(" ", "_");
+ return name;
+}
+
+QString path(const QTemporaryDir &dir, const TestParams &param, const QString &suffix = ".png")
+{
+ return dir.filePath(name(param) + suffix);
+}
+
+QVideoFrame createTestFrame(const TestParams &params, const QImage &image)
+{
+ QVideoFrameFormat format(image.size(), params.pixelFormat);
+ format.setColorRange(params.colorRange);
+ format.setColorSpace(params.colorSpace);
+ format.setColorTransfer(QVideoFrameFormat::ColorTransfer_Unknown);
+
+ auto buffer = std::make_unique<QImageVideoBuffer>(image);
+ QVideoFrameFormat imageFormat = {
+ image.size(), QVideoFrameFormat::pixelFormatFromImageFormat(image.format())
+ };
+
+ QVideoFrame source = QVideoFramePrivate::createFrame(std::move(buffer), imageFormat);
+ return QPlatformMediaIntegration::instance()->convertVideoFrame(source, format);
+}
+
+struct ImageDiffReport
+{
+ int DiffCountAboveThreshold; // Number of channel differences above threshold
+ int MaxDiff; // Maximum difference between two images (max across channels)
+ int PixelCount; // Number of pixels in the image
+ QImage DiffImage; // The difference image (absolute per-channel difference)
+};
+
+double aboveThresholdDiffRatio(const ImageDiffReport &report)
+{
+ return static_cast<double>(report.DiffCountAboveThreshold) / report.PixelCount;
+}
+
+int maxChannelDiff(QRgb lhs, QRgb rhs)
+{
+ // clang-format off
+ return std::max({ std::abs(qRed(lhs) - qRed(rhs)),
+ std::abs(qGreen(lhs) - qGreen(rhs)),
+ std::abs(qBlue(lhs) - qBlue(rhs)) });
+ // clang-format on
+}
+
+int clampedAbsDiff(int lhs, int rhs)
+{
+ return std::clamp(std::abs(lhs - rhs), 0, 255);
+}
+
+QRgb pixelDiff(QRgb lhs, QRgb rhs)
+{
+ return qRgb(clampedAbsDiff(qRed(lhs), qRed(rhs)), clampedAbsDiff(qGreen(lhs), qGreen(rhs)),
+ clampedAbsDiff(qBlue(lhs), qBlue(rhs)));
+}
+
+std::optional<ImageDiffReport> compareImagesRgb32(const QImage &computed, const QImage &baseline,
+ int channelThreshold)
+{
+ Q_ASSERT(baseline.format() == QImage::Format_RGB32);
+
+ if (computed.size() != baseline.size())
+ return {};
+
+ if (computed.format() != baseline.format())
+ return {};
+
+ if (computed.colorSpace() != baseline.colorSpace())
+ return {};
+
+ const QSize size = baseline.size();
+
+ ImageDiffReport report{};
+ report.PixelCount = size.width() * size.height();
+ report.DiffImage = QImage(size, baseline.format());
+
+ // Iterate over all pixels and update report
+ for (int l = 0; l < size.height(); l++) {
+ const QRgb *colorComputed = reinterpret_cast<const QRgb *>(computed.constScanLine(l));
+ const QRgb *colorBaseline = reinterpret_cast<const QRgb *>(baseline.constScanLine(l));
+ QRgb *colorDiff = reinterpret_cast<QRgb *>(report.DiffImage.scanLine(l));
+
+ int w = size.width();
+ while (w--) {
+ *colorDiff = pixelDiff(*colorComputed, *colorBaseline);
+ if (*colorComputed != *colorBaseline) {
+ const int diff = maxChannelDiff(*colorComputed, *colorBaseline);
+
+ if (diff > report.MaxDiff)
+ report.MaxDiff = diff;
+
+ if (diff > channelThreshold)
+ ++report.DiffCountAboveThreshold;
+ }
+
+ ++colorComputed;
+ ++colorBaseline;
+ ++colorDiff;
+ }
+ }
+ return report;
+}
+
+bool copyAllFiles(const QDir &source, const QDir &dest)
+{
+ if (!source.exists() || !dest.exists())
+ return false;
+
+ QDirIterator it(source);
+ while (it.hasNext()) {
+ QFileInfo file{ it.next() };
+ if (file.isFile()) {
+ const QString destination = dest.absolutePath() + "/" + file.fileName();
+ QFile::copy(file.absoluteFilePath(), destination);
+ }
+ }
+
+ return true;
+}
+
+class ReferenceData
+{
+public:
+ ReferenceData()
+ {
+ m_testdataDir = QTest::qExtractTestData("testdata");
+ if (!m_testdataDir)
+ m_testdataDir = QSharedPointer<QTemporaryDir>(new QTemporaryDir);
+ }
+
+ ~ReferenceData()
+ {
+ if (m_testdataDir->autoRemove())
+ return;
+
+ QString resultPath = m_testdataDir->path();
+ if (qEnvironmentVariableIsSet("COIN_CTEST_RESULTSDIR")) {
+ const QDir sourceDir = m_testdataDir->path();
+ const QDir resultsDir{ qEnvironmentVariable("COIN_CTEST_RESULTSDIR") };
+ if (!copyAllFiles(sourceDir, resultsDir)) {
+ qDebug() << "Failed to copy files to COIN_CTEST_RESULTSDIR";
+ } else {
+ resultPath = resultsDir.path();
+ }
+ }
+
+ qDebug() << "Images with differences were found. The output images with differences"
+ << "can be found in" << resultPath << ". Review the images and if the"
+ << "differences are expected, please update the testdata with the new"
+ << "output images";
+ }
+
+ QImage getReference(const TestParams &param) const
+ {
+ const QString referenceName = name(param);
+ const QString referencePath = m_testdataDir->filePath(referenceName + ".png");
+ QImage result;
+ if (result.load(referencePath))
+ return result;
+ return {};
+ }
+
+ void saveNewReference(const QImage &reference, const TestParams &params) const
+ {
+ const QString filename = path(*m_testdataDir, params);
+ if (!reference.save(filename)) {
+ qDebug() << "Failed to save reference file";
+ Q_ASSERT(false);
+ }
+
+ m_testdataDir->setAutoRemove(false);
+ }
+
+ bool saveComputedImage(const TestParams &params, const QImage &image, const QString& suffix) const
+ {
+ if (!image.save(path(*m_testdataDir, params, suffix))) {
+ qDebug() << "Unexpectedly failed to save actual image to file";
+ Q_ASSERT(false);
+ return false;
+ }
+ m_testdataDir->setAutoRemove(false);
+ return true;
+ }
+
+ QImage getTestdata(const QString &name)
+ {
+ const QString filePath = m_testdataDir->filePath(name);
+ QImage image;
+ if (image.load(filePath))
+ return image;
+ return {};
+ }
+
+private:
+ QSharedPointer<QTemporaryDir> m_testdataDir;
+};
+
+std::optional<ImageDiffReport> compareToReference(const TestParams &params, const QImage &actual,
+ const ReferenceData &references,
+ int maxChannelThreshold)
+{
+ const QImage expected = references.getReference(params);
+ if (expected.isNull()) {
+ // Reference image does not exist. Create one. Adding this to
+ // testdata directory is a manual job.
+ references.saveNewReference(actual, params);
+ qDebug() << "Reference image is missing. Please update testdata directory with the missing "
+ "reference image";
+ return {};
+ }
+
+ // Convert to RGB32 to simplify image comparison
+ const QImage computed = actual.convertToFormat(QImage::Format_RGB32);
+ const QImage baseline = expected.convertToFormat(QImage::Format_RGB32);
+
+ std::optional<ImageDiffReport> diffReport = compareImagesRgb32(computed, baseline, maxChannelThreshold);
+ if (!diffReport)
+ return {};
+
+ if (diffReport->MaxDiff > 0) {
+ // Images are not equal, and may require manual inspection
+ if (!references.saveComputedImage(params, computed, "_actual.png"))
+ return {};
+ if (!references.saveComputedImage(params, diffReport->DiffImage, "_diff.png"))
+ return {};
+ }
+
+ return diffReport;
+}
+
+} // namespace
+
+class tst_qvideoframecolormanagement : public QObject
+{
+ Q_OBJECT
+private slots:
+ void initTestCase()
+ {
+ if (!isFFMPEGPlatform())
+ QSKIP("This test requires the ffmpeg backend to create test frames");
+ }
+
+ void qImageFromVideoFrame_returnsQImageWithCorrectColors_data()
+ {
+ QTest::addColumn<QString>("fileName");
+ QTest::addColumn<TestParams>("params");
+ for (const char *file : { "umbrellas.jpg" }) {
+ for (const QVideoFrameFormat::PixelFormat pixelFormat : pixelFormats()) {
+ for (const QVideoFrameFormat::ColorSpace colorSpace : colorSpaces()) {
+ for (const QVideoFrameFormat::ColorRange colorRange : colorRanges()) {
+ for (const bool forceCpu : { false, true }) {
+
+ if (!isSupportedPixelFormat(pixelFormat))
+ continue;
+
+ if (forceCpu && !supportsCpuConversion(pixelFormat))
+ continue; // TODO: CPU Conversion not implemented
+
+ if (!hasCorrespondingFFmpegFormat(pixelFormat))
+ continue;
+
+ TestParams param{
+ file, pixelFormat, colorSpace, colorRange, forceCpu,
+ };
+ QTest::addRow("%s", name(param).toLatin1().data()) << file << param;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // This test is a regression test for the QMultimedia display pipeline.
+ // It compares rendered output (as created by qImageFromVideoFrame)
+ // against reference images stored to file. The reference images were
+ // created by the test itself, and does not verify correctness, just
+ // changes to render output.
+ void qImageFromVideoFrame_returnsQImageWithCorrectColors()
+ {
+ QFETCH(const QString, fileName);
+ QFETCH(const TestParams, params);
+
+ const QImage templateImage = m_reference.getTestdata(fileName);
+ QVERIFY(!templateImage.isNull());
+
+ const QVideoFrame frame = createTestFrame(params, templateImage);
+
+ // Act
+ const QImage actual =
+ qImageFromVideoFrame(frame, QtVideo::Rotation::None, false, false, params.forceCpu);
+
+ // Assert
+ constexpr int diffThreshold = 4;
+ std::optional<ImageDiffReport> result =
+ compareToReference(params, actual, m_reference, diffThreshold);
+
+ // Sanity checks
+ QVERIFY(result.has_value());
+ QCOMPARE_GT(result->PixelCount, 0);
+
+ // Verify that images are similar
+ const double ratioAboveThreshold =
+ static_cast<double>(result->DiffCountAboveThreshold) / result->PixelCount;
+
+ // These thresholds are empirically determined to allow tests to pass in CI.
+ // If tests fail, review the difference between the reference and actual
+ // output to determine if it is a platform dependent inaccuracy before
+ // adjusting the limits
+ QCOMPARE_LT(ratioAboveThreshold, 0.01); // Fraction of pixels with larger differences
+ QCOMPARE_LT(result->MaxDiff, 6); // Maximum per-channel difference
+ }
+
+
+private:
+ ReferenceData m_reference;
+};
+
+QTEST_MAIN(tst_qvideoframecolormanagement)
+
+#include "tst_qvideoframecolormanagement.moc"
diff --git a/tests/auto/unit/multimedia/qvideoframeformat/CMakeLists.txt b/tests/auto/unit/multimedia/qvideoframeformat/CMakeLists.txt
new file mode 100644
index 000000000..0d1b92d55
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframeformat/CMakeLists.txt
@@ -0,0 +1,16 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+# Generated from qvideoframeformat.pro.
+
+#####################################################################
+## tst_qvideoframeformat Test:
+#####################################################################
+
+qt_internal_add_test(tst_qvideoframeformat
+ SOURCES
+ tst_qvideoframeformat.cpp
+ LIBRARIES
+ Qt::Gui
+ Qt::MultimediaPrivate
+)
diff --git a/tests/auto/unit/multimedia/qvideoframeformat/tst_qvideoframeformat.cpp b/tests/auto/unit/multimedia/qvideoframeformat/tst_qvideoframeformat.cpp
new file mode 100644
index 000000000..41d54de0d
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideoframeformat/tst_qvideoframeformat.cpp
@@ -0,0 +1,567 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QtTest/QtTest>
+
+#include <qvideoframeformat.h>
+
+// Adds an enum, and the stringized version
+#define ADD_ENUM_TEST(x) \
+ QTest::newRow(#x) \
+ << QVideoFrameFormat::x \
+ << QString(QLatin1String(#x));
+
+class tst_QVideoFrameFormat : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QVideoFrameFormat();
+ ~tst_QVideoFrameFormat() override;
+
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+private slots:
+ void constructNull();
+ void construct_data();
+ void construct();
+ void frameSize_data();
+ void frameSize();
+ void planeCount_returnsNumberOfColorPlanesDictatedByPixelFormat_data() const;
+ void planeCount_returnsNumberOfColorPlanesDictatedByPixelFormat() const;
+ void viewport_data();
+ void viewport();
+ void scanLineDirection_data();
+ void scanLineDirection();
+ void frameRate_data();
+ void frameRate();
+ void colorSpaceEnum_data();
+ void colorSpaceEnum ();
+ void compare();
+ void copy();
+ void assign();
+
+ void isValid();
+ void copyAllParameters ();
+ void assignAllParameters ();
+};
+
+tst_QVideoFrameFormat::tst_QVideoFrameFormat()
+{
+}
+
+tst_QVideoFrameFormat::~tst_QVideoFrameFormat()
+{
+}
+
+void tst_QVideoFrameFormat::initTestCase()
+{
+}
+
+void tst_QVideoFrameFormat::cleanupTestCase()
+{
+}
+
+void tst_QVideoFrameFormat::init()
+{
+}
+
+void tst_QVideoFrameFormat::cleanup()
+{
+}
+
+void tst_QVideoFrameFormat::constructNull()
+{
+ QVideoFrameFormat format;
+
+ QVERIFY(!format.isValid());
+ QCOMPARE(format.pixelFormat(), QVideoFrameFormat::Format_Invalid);
+ QCOMPARE(format.frameSize(), QSize());
+ QCOMPARE(format.frameWidth(), -1);
+ QCOMPARE(format.frameHeight(), -1);
+ QCOMPARE(format.viewport(), QRect());
+ QCOMPARE(format.scanLineDirection(), QVideoFrameFormat::TopToBottom);
+ QCOMPARE(format.streamFrameRate(), 0.0);
+ QCOMPARE(format.colorSpace(), QVideoFrameFormat::ColorSpace_Undefined);
+}
+
+void tst_QVideoFrameFormat::construct_data()
+{
+ QTest::addColumn<QSize>("frameSize");
+ QTest::addColumn<QVideoFrameFormat::PixelFormat>("pixelFormat");
+ QTest::addColumn<bool>("valid");
+
+ QTest::newRow("32x32 rgb32 no handle")
+ << QSize(32, 32)
+ << QVideoFrameFormat::Format_XRGB8888
+ << true;
+
+ QTest::newRow("32x32 invalid no handle")
+ << QSize(32, 32)
+ << QVideoFrameFormat::Format_Invalid
+ << false;
+
+ QTest::newRow("invalid size, rgb32 no handle")
+ << QSize()
+ << QVideoFrameFormat::Format_XRGB8888
+ << false;
+
+ QTest::newRow("0x0 rgb32 no handle")
+ << QSize(0,0)
+ << QVideoFrameFormat::Format_XRGB8888
+ << true;
+}
+
+void tst_QVideoFrameFormat::construct()
+{
+ QFETCH(QSize, frameSize);
+ QFETCH(QVideoFrameFormat::PixelFormat, pixelFormat);
+ QFETCH(bool, valid);
+
+ QRect viewport(QPoint(0, 0), frameSize);
+
+ QVideoFrameFormat format(frameSize, pixelFormat);
+
+ QCOMPARE(format.pixelFormat(), pixelFormat);
+ QCOMPARE(format.frameSize(), frameSize);
+ QCOMPARE(format.frameWidth(), frameSize.width());
+ QCOMPARE(format.frameHeight(), frameSize.height());
+ QCOMPARE(format.isValid(), valid);
+ QCOMPARE(format.viewport(), viewport);
+ QCOMPARE(format.scanLineDirection(), QVideoFrameFormat::TopToBottom);
+ QCOMPARE(format.streamFrameRate(), 0.0);
+ QCOMPARE(format.colorSpace(), QVideoFrameFormat::ColorSpace_Undefined);
+}
+
+void tst_QVideoFrameFormat::frameSize_data()
+{
+ QTest::addColumn<QSize>("initialSize");
+ QTest::addColumn<QSize>("newSize");
+
+ QTest::newRow("grow")
+ << QSize(64, 64)
+ << QSize(1024, 1024);
+ QTest::newRow("shrink")
+ << QSize(1024, 1024)
+ << QSize(64, 64);
+ QTest::newRow("unchanged")
+ << QSize(512, 512)
+ << QSize(512, 512);
+}
+
+void tst_QVideoFrameFormat::frameSize()
+{
+ QFETCH(QSize, initialSize);
+ QFETCH(QSize, newSize);
+
+ QVideoFrameFormat format(initialSize, QVideoFrameFormat::Format_XRGB8888);
+
+ format.setFrameSize(newSize);
+
+ QCOMPARE(format.frameSize(), newSize);
+ QCOMPARE(format.frameWidth(), newSize.width());
+ QCOMPARE(format.frameHeight(), newSize.height());
+}
+
+void tst_QVideoFrameFormat::planeCount_returnsNumberOfColorPlanesDictatedByPixelFormat_data() const {
+ QTest::addColumn<QVideoFrameFormat::PixelFormat>("pixelFormat");
+ QTest::addColumn<int>("colorPlanes"); // Number of planes as specified by QVideoFrameFormat::PixelFormat documentation
+
+ QTest::newRow("ARGB8888") << QVideoFrameFormat::Format_ARGB8888 << 1;
+ QTest::newRow("ARGB8888_Premultiplied") << QVideoFrameFormat::Format_ARGB8888_Premultiplied << 1;
+ QTest::newRow("XRGB8888") << QVideoFrameFormat::Format_XRGB8888 << 1;
+ QTest::newRow("BGRA8888") << QVideoFrameFormat::Format_BGRA8888 << 1;
+ QTest::newRow("BGRA8888_Premultiplied") << QVideoFrameFormat::Format_BGRA8888_Premultiplied << 1;
+ QTest::newRow("BGRX8888") << QVideoFrameFormat::Format_BGRX8888 << 1;
+ QTest::newRow("ABGR8888") << QVideoFrameFormat::Format_ABGR8888 << 1;
+ QTest::newRow("XBGR8888") << QVideoFrameFormat::Format_XBGR8888 << 1;
+ QTest::newRow("RGBA8888") << QVideoFrameFormat::Format_RGBA8888 << 1;
+ QTest::newRow("RGBX8888") << QVideoFrameFormat::Format_RGBX8888 << 1;
+
+ QTest::newRow("AUYVY") << QVideoFrameFormat::Format_AYUV << 1;
+ QTest::newRow("AYUV_Premultiplied") << QVideoFrameFormat::Format_AYUV_Premultiplied << 1;
+ QTest::newRow("YUV420P") << QVideoFrameFormat::Format_YUV420P << 3;
+ QTest::newRow("YUV422P") << QVideoFrameFormat::Format_YUV422P << 3;
+ QTest::newRow("YV12") << QVideoFrameFormat::Format_YV12 << 3;
+
+ QTest::newRow("UYVY") << QVideoFrameFormat::Format_UYVY << 1;
+ QTest::newRow("YUYV") << QVideoFrameFormat::Format_YUYV << 1;
+ QTest::newRow("NV12") << QVideoFrameFormat::Format_NV12 << 2;
+ QTest::newRow("NV21") << QVideoFrameFormat::Format_NV21 << 2;
+
+ QTest::newRow("IMC1") << QVideoFrameFormat::Format_IMC1 << 3;
+ QTest::newRow("IMC2") << QVideoFrameFormat::Format_IMC2 << 2;
+ QTest::newRow("IMC3") << QVideoFrameFormat::Format_IMC3 << 3;
+ QTest::newRow("IMC4") << QVideoFrameFormat::Format_IMC4 << 2;
+
+ QTest::newRow("Y8") << QVideoFrameFormat::Format_Y8 << 1;
+ QTest::newRow("Y16") << QVideoFrameFormat::Format_Y16 << 1;
+
+ QTest::newRow("P010") << QVideoFrameFormat::Format_P010 << 2;
+ QTest::newRow("P016") << QVideoFrameFormat::Format_P016 << 2;
+
+ QTest::newRow("SamplerExternalOES") << QVideoFrameFormat::Format_SamplerExternalOES << 1;
+ QTest::newRow("Jpeg") << QVideoFrameFormat::Format_Jpeg << 1;
+ QTest::newRow("SamplerRect") << QVideoFrameFormat::Format_SamplerRect << 1;
+
+ QTest::newRow("YUV420P10") << QVideoFrameFormat::Format_YUV420P10 << 3;
+}
+
+void tst_QVideoFrameFormat::planeCount_returnsNumberOfColorPlanesDictatedByPixelFormat() const {
+ QFETCH(QVideoFrameFormat::PixelFormat, pixelFormat);
+ QFETCH(int, colorPlanes);
+
+ const QVideoFrameFormat frameFormat = QVideoFrameFormat({}, pixelFormat);
+
+ QCOMPARE_EQ(frameFormat.planeCount(), colorPlanes);
+}
+
+void tst_QVideoFrameFormat::viewport_data()
+{
+ QTest::addColumn<QSize>("initialSize");
+ QTest::addColumn<QRect>("viewport");
+ QTest::addColumn<QSize>("newSize");
+ QTest::addColumn<QRect>("expectedViewport");
+
+ QTest::newRow("grow reset")
+ << QSize(64, 64)
+ << QRect(8, 8, 48, 48)
+ << QSize(1024, 1024)
+ << QRect(0, 0, 1024, 1024);
+ QTest::newRow("shrink reset")
+ << QSize(1024, 1024)
+ << QRect(8, 8, 1008, 1008)
+ << QSize(64, 64)
+ << QRect(0, 0, 64, 64);
+ QTest::newRow("unchanged reset")
+ << QSize(512, 512)
+ << QRect(8, 8, 496, 496)
+ << QSize(512, 512)
+ << QRect(0, 0, 512, 512);
+}
+
+void tst_QVideoFrameFormat::viewport()
+{
+ QFETCH(QSize, initialSize);
+ QFETCH(QRect, viewport);
+ QFETCH(QSize, newSize);
+ QFETCH(QRect, expectedViewport);
+
+ QRect initialViewport(QPoint(0, 0), initialSize);
+
+ QVideoFrameFormat format(initialSize, QVideoFrameFormat::Format_XRGB8888);
+
+ format.setViewport(viewport);
+
+ QCOMPARE(format.viewport(), viewport);
+
+ format.setFrameSize(newSize);
+
+ QCOMPARE(format.viewport(), expectedViewport);
+}
+
+void tst_QVideoFrameFormat::scanLineDirection_data()
+{
+ QTest::addColumn<QVideoFrameFormat::Direction>("direction");
+ QTest::addColumn<QString>("stringized");
+
+ ADD_ENUM_TEST(TopToBottom);
+ ADD_ENUM_TEST(BottomToTop);
+}
+
+void tst_QVideoFrameFormat::scanLineDirection()
+{
+ QFETCH(QVideoFrameFormat::Direction, direction);
+ QFETCH(QString, stringized);
+
+ QVideoFrameFormat format(QSize(16, 16), QVideoFrameFormat::Format_XRGB8888);
+
+ format.setScanLineDirection(direction);
+
+ QCOMPARE(format.scanLineDirection(), direction);
+
+ QTest::ignoreMessage(QtDebugMsg, stringized.toLatin1().constData());
+ qDebug() << direction;
+}
+
+void tst_QVideoFrameFormat::colorSpaceEnum_data()
+{
+ QTest::addColumn<QVideoFrameFormat::ColorSpace>("colorspace");
+ QTest::addColumn<QString>("stringized");
+
+ ADD_ENUM_TEST(ColorSpace_BT601);
+ ADD_ENUM_TEST(ColorSpace_BT709);
+ ADD_ENUM_TEST(ColorSpace_BT2020);
+ ADD_ENUM_TEST(ColorSpace_AdobeRgb);
+ ADD_ENUM_TEST(ColorSpace_Undefined);
+}
+
+/* Test case for Enum ColorSpace */
+void tst_QVideoFrameFormat::colorSpaceEnum()
+{
+ QFETCH(QVideoFrameFormat::ColorSpace, colorspace);
+ QFETCH(QString, stringized);
+
+ QVideoFrameFormat format(QSize(64, 64), QVideoFrameFormat::Format_XRGB8888);
+ format.setColorSpace(colorspace);
+
+ QCOMPARE(format.colorSpace(), colorspace);
+
+ QTest::ignoreMessage(QtDebugMsg, stringized.toLatin1().constData());
+ qDebug() << colorspace;
+}
+
+
+void tst_QVideoFrameFormat::frameRate_data()
+{
+ QTest::addColumn<qreal>("frameRate");
+
+ QTest::newRow("null")
+ << qreal(0.0);
+ QTest::newRow("1/1")
+ << qreal(1.0);
+ QTest::newRow("24/1")
+ << qreal(24.0);
+ QTest::newRow("15/2")
+ << qreal(7.5);
+}
+
+void tst_QVideoFrameFormat::frameRate()
+{
+ QFETCH(qreal, frameRate);
+
+ QVideoFrameFormat format(QSize(64, 64), QVideoFrameFormat::Format_XRGB8888);
+
+ format.setStreamFrameRate(frameRate);
+
+ QCOMPARE(format.streamFrameRate(), frameRate);
+}
+
+void tst_QVideoFrameFormat::compare()
+{
+ QVideoFrameFormat format1(
+ QSize(16, 16), QVideoFrameFormat::Format_XRGB8888);
+ QVideoFrameFormat format2(
+ QSize(16, 16), QVideoFrameFormat::Format_XRGB8888);
+ QVideoFrameFormat format3(
+ QSize(32, 32), QVideoFrameFormat::Format_AYUV);
+ QVideoFrameFormat format4(
+ QSize(16, 16), QVideoFrameFormat::Format_XBGR8888);
+
+ QCOMPARE(format1 == format2, true);
+ QCOMPARE(format1 != format2, false);
+ QCOMPARE(format1 == format3, false);
+ QCOMPARE(format1 != format3, true);
+ QCOMPARE(format1 == format4, false);
+ QCOMPARE(format1 != format4, true);
+
+ format2.setFrameSize(1024, 768);
+
+ // Not equal, frame size differs.
+ QCOMPARE(format1 == format2, false);
+ QCOMPARE(format1 != format2, true);
+
+ format1.setFrameSize(1024, 768);
+
+ // Equal.
+ QCOMPARE(format1 == format2, true);
+ QCOMPARE(format1 != format2, false);
+
+ format1.setViewport(QRect(0, 0, 800, 600));
+ format2.setViewport(QRect(112, 84, 800, 600));
+
+ // Not equal, viewports differ.
+ QCOMPARE(format1 == format2, false);
+ QCOMPARE(format1 != format2, true);
+
+ format1.setViewport(QRect(112, 84, 800, 600));
+
+ // Equal.
+ QCOMPARE(format1 == format2, true);
+ QCOMPARE(format1 != format2, false);
+
+ format2.setScanLineDirection(QVideoFrameFormat::BottomToTop);
+
+ // Not equal scan line direction differs.
+ QCOMPARE(format1 == format2, false);
+ QCOMPARE(format1 != format2, true);
+
+ format1.setScanLineDirection(QVideoFrameFormat::BottomToTop);
+
+ // Equal.
+ QCOMPARE(format1 == format2, true);
+ QCOMPARE(format1 != format2, false);
+
+ format1.setStreamFrameRate(7.5);
+
+ // Not equal frame rate differs.
+ QCOMPARE(format1 == format2, false);
+ QCOMPARE(format1 != format2, true);
+
+ format2.setStreamFrameRate(qreal(7.50001));
+
+ // Equal.
+ QCOMPARE(format1 == format2, true);
+ QCOMPARE(format1 != format2, false);
+
+ format2.setColorSpace(QVideoFrameFormat::ColorSpace_BT601);
+
+ // Not equal yuv color space differs.
+ QCOMPARE(format1 == format2, false);
+ QCOMPARE(format1 != format2, true);
+
+ format1.setColorSpace(QVideoFrameFormat::ColorSpace_BT601);
+
+ // Equal.
+ QCOMPARE(format1 == format2, true);
+ QCOMPARE(format1 != format2, false);
+}
+
+
+void tst_QVideoFrameFormat::copy()
+{
+ QVideoFrameFormat original(
+ QSize(1024, 768), QVideoFrameFormat::Format_ARGB8888);
+ original.setScanLineDirection(QVideoFrameFormat::BottomToTop);
+
+ QVideoFrameFormat copy(original);
+
+ QCOMPARE(copy.pixelFormat(), QVideoFrameFormat::Format_ARGB8888);
+ QCOMPARE(copy.frameSize(), QSize(1024, 768));
+ QCOMPARE(copy.scanLineDirection(), QVideoFrameFormat::BottomToTop);
+
+ QCOMPARE(original == copy, true);
+ QCOMPARE(original != copy, false);
+
+ copy.setScanLineDirection(QVideoFrameFormat::TopToBottom);
+
+ QCOMPARE(copy.scanLineDirection(), QVideoFrameFormat::TopToBottom);
+
+ QCOMPARE(original.scanLineDirection(), QVideoFrameFormat::BottomToTop);
+
+ QCOMPARE(original == copy, false);
+ QCOMPARE(original != copy, true);
+}
+
+void tst_QVideoFrameFormat::assign()
+{
+ QVideoFrameFormat copy(
+ QSize(64, 64), QVideoFrameFormat::Format_AYUV);
+
+ QVideoFrameFormat original(
+ QSize(1024, 768), QVideoFrameFormat::Format_ARGB8888);
+ original.setScanLineDirection(QVideoFrameFormat::BottomToTop);
+
+ copy = original;
+
+ QCOMPARE(copy.pixelFormat(), QVideoFrameFormat::Format_ARGB8888);
+ QCOMPARE(copy.frameSize(), QSize(1024, 768));
+ QCOMPARE(copy.scanLineDirection(), QVideoFrameFormat::BottomToTop);
+
+ QCOMPARE(original == copy, true);
+ QCOMPARE(original != copy, false);
+
+ copy.setScanLineDirection(QVideoFrameFormat::TopToBottom);
+
+ QCOMPARE(copy.scanLineDirection(), QVideoFrameFormat::TopToBottom);
+
+ QCOMPARE(original.scanLineDirection(), QVideoFrameFormat::BottomToTop);
+
+ QCOMPARE(original == copy, false);
+ QCOMPARE(original != copy, true);
+}
+
+/* Test case for api isValid */
+void tst_QVideoFrameFormat::isValid()
+{
+ /* When both pixel format and framesize is not valid */
+ QVideoFrameFormat format;
+ QVERIFY(!format.isValid());
+
+ /* When framesize is valid and pixel format is not valid */
+ format.setFrameSize(64,64);
+ QVERIFY(format.frameSize() == QSize(64,64));
+ QVERIFY(!format.pixelFormat());
+ QVERIFY(!format.isValid());
+
+ /* When both the pixel format and framesize is valid. */
+ QVideoFrameFormat format1(QSize(32, 32), QVideoFrameFormat::Format_AYUV);
+ QVERIFY(format1.isValid());
+
+ /* When pixel format is valid and frame size is not valid */
+ format1.setFrameSize(-1,-1);
+ QVERIFY(!format1.frameSize().isValid());
+ QVERIFY(!format1.isValid());
+}
+
+/* Test case for copy constructor with all the parameters. */
+void tst_QVideoFrameFormat::copyAllParameters()
+{
+ /* Create the instance and set all the parameters. */
+ QVideoFrameFormat original(
+ QSize(1024, 768), QVideoFrameFormat::Format_ARGB8888);
+
+ original.setScanLineDirection(QVideoFrameFormat::BottomToTop);
+ original.setViewport(QRect(0, 0, 1024, 1024));
+ original.setStreamFrameRate(qreal(15.0));
+ original.setColorSpace(QVideoFrameFormat::ColorSpace_BT709);
+
+ /* Copy the original instance to copy and verify if both the instances
+ have the same parameters. */
+ QVideoFrameFormat copy(original);
+
+ QCOMPARE(copy.pixelFormat(), QVideoFrameFormat::Format_ARGB8888);
+ QCOMPARE(copy.frameSize(), QSize(1024, 768));
+ QCOMPARE(copy.scanLineDirection(), QVideoFrameFormat::BottomToTop);
+ QCOMPARE(copy.viewport(), QRect(0, 0, 1024, 1024));
+ QCOMPARE(copy.streamFrameRate(), qreal(15.0));
+ QCOMPARE(copy.colorSpace(), QVideoFrameFormat::ColorSpace_BT709);
+
+ /* Verify if both the instances are eqaul */
+ QCOMPARE(original == copy, true);
+ QCOMPARE(original != copy, false);
+}
+
+/* Test case for copy constructor with all the parameters. */
+void tst_QVideoFrameFormat::assignAllParameters()
+{
+ /* Create the instance and set all the parameters. */
+ QVideoFrameFormat copy(
+ QSize(64, 64), QVideoFrameFormat::Format_AYUV);
+ copy.setScanLineDirection(QVideoFrameFormat::TopToBottom);
+ copy.setViewport(QRect(0, 0, 640, 320));
+ copy.setStreamFrameRate(qreal(7.5));
+ copy.setColorSpace(QVideoFrameFormat::ColorSpace_BT601);
+
+ /* Create the instance and set all the parameters. */
+ QVideoFrameFormat original(
+ QSize(1024, 768), QVideoFrameFormat::Format_ARGB8888);
+ original.setScanLineDirection(QVideoFrameFormat::BottomToTop);
+ original.setViewport(QRect(0, 0, 1024, 1024));
+ original.setStreamFrameRate(qreal(15.0));
+ original.setColorSpace(QVideoFrameFormat::ColorSpace_BT709);
+
+ /* Assign the original instance to copy and verify if both the instancess
+ have the same parameters. */
+ copy = original;
+
+ QCOMPARE(copy.pixelFormat(), QVideoFrameFormat::Format_ARGB8888);
+ QCOMPARE(copy.frameSize(), QSize(1024, 768));
+ QCOMPARE(copy.scanLineDirection(), QVideoFrameFormat::BottomToTop);
+ QCOMPARE(copy.viewport(), QRect(0, 0, 1024, 1024));
+ QCOMPARE(copy.streamFrameRate(), qreal(15.0));
+ QCOMPARE(copy.colorSpace(), QVideoFrameFormat::ColorSpace_BT709);
+
+ /* Verify if both the instances are eqaul */
+ QCOMPARE(original == copy, true);
+ QCOMPARE(original != copy, false);
+}
+
+QTEST_MAIN(tst_QVideoFrameFormat)
+
+
+
+#include "tst_qvideoframeformat.moc"
diff --git a/tests/auto/unit/multimedia/qvideotexturehelper/CMakeLists.txt b/tests/auto/unit/multimedia/qvideotexturehelper/CMakeLists.txt
new file mode 100644
index 000000000..a47b46d5b
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideotexturehelper/CMakeLists.txt
@@ -0,0 +1,10 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+qt_internal_add_test(tst_qvideotexturehelper
+ SOURCES
+ tst_qvideotexturehelper.cpp
+ LIBRARIES
+ Qt::Gui
+ Qt::MultimediaPrivate
+)
diff --git a/tests/auto/unit/multimedia/qvideotexturehelper/tst_qvideotexturehelper.cpp b/tests/auto/unit/multimedia/qvideotexturehelper/tst_qvideotexturehelper.cpp
new file mode 100644
index 000000000..aa166af54
--- /dev/null
+++ b/tests/auto/unit/multimedia/qvideotexturehelper/tst_qvideotexturehelper.cpp
@@ -0,0 +1,260 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QtCore/qbytearray.h>
+#include <QtTest/qtest.h>
+
+#include <private/qvideotexturehelper_p.h>
+#include <qvideoframe.h>
+
+#include "qvideoframeformat.h"
+
+QT_USE_NAMESPACE
+
+struct ColorSpaceCoeff
+{
+ float a;
+ float b;
+ float c;
+};
+
+// Coefficients used in ITU-R BT.709-6 Table 3 - Signal format
+constexpr ColorSpaceCoeff BT709Coefficients = {
+ 0.2126f, 0.7152f, 0.0722f // E_g' = 0.2126 * E_R' + 0.7152 * E_G' + 0.0722 * E_B'
+ //
+ // Note that the other coefficients can be derived from a and c
+ // to re-normalize the values, see ITU-R BT.601-7, section 2.5.2
+ //
+ // E_CB' = (E_B' - E_g') / 1.8556 -> 1.8556 == (1-0.0722) * 2
+ // E_CR' = (E_R' - E_g') / 1.5748 -> 1.5748 == (1-0.2126) * 2
+};
+
+// Coefficients used in ITU-R BT.2020-2 Table 4 - Signal format
+constexpr ColorSpaceCoeff BT2020Coefficients = {
+ 0.2627f, 0.6780f, 0.0593f // Y_c' = (0.2627 R + 0.6780 G + 0.05938 B)'
+ // C_B' = (B' - Y') / 1.8814 -> 1.8814 == 2*(1-0.0593)
+ // C_R' = (R' - Y') / 1.4746 -> 1.4746 == 2*(1-0.2627)
+};
+
+struct ColorSpaceEntry
+{
+ QVideoFrameFormat::ColorSpace colorSpace;
+ QVideoFrameFormat::ColorRange colorRange;
+ ColorSpaceCoeff coefficients;
+};
+
+// clang-format off
+const std::vector<ColorSpaceEntry> colorSpaces = {
+ {
+ QVideoFrameFormat::ColorSpace_BT709,
+ QVideoFrameFormat::ColorRange_Video,
+ BT709Coefficients
+ },
+ {
+ QVideoFrameFormat::ColorSpace_BT709,
+ QVideoFrameFormat::ColorRange_Full,
+ BT709Coefficients
+ },
+ {
+ QVideoFrameFormat::ColorSpace_BT2020,
+ QVideoFrameFormat::ColorRange_Video,
+ BT2020Coefficients
+ },
+ {
+ QVideoFrameFormat::ColorSpace_BT2020,
+ QVideoFrameFormat::ColorRange_Full,
+ BT2020Coefficients
+ }
+};
+
+ColorSpaceCoeff getColorSpaceCoef(QVideoFrameFormat::ColorSpace colorSpace,
+ QVideoFrameFormat::ColorRange range)
+{
+ const auto it = std::find_if(colorSpaces.begin(), colorSpaces.end(),
+ [&](const ColorSpaceEntry &p) {
+ return p.colorSpace == colorSpace && p.colorRange == range;
+ });
+
+ if (it != colorSpaces.end())
+ return it->coefficients;
+
+ Q_ASSERT(false);
+
+ return {};
+}
+
+QMatrix4x4 yuv2rgb(QVideoFrameFormat::ColorSpace colorSpace, QVideoFrameFormat::ColorRange range)
+{
+ constexpr float max8bit = static_cast<float>(255);
+ constexpr float uvOffset = -128.0f/max8bit; // Really -0.5, but carried over from fixed point
+
+ QMatrix4x4 normalizeYUV;
+
+ if (range == QVideoFrameFormat::ColorRange_Video) {
+ // YUV signal is assumed to be in limited range 8 bit representation,
+ // where Y is in range [16..235] and U and V are in range [16..240].
+ // Shaders use floats in [0..1], so we scale the values accordingly.
+ constexpr float yRange = (235 - 16) / max8bit;
+ constexpr float yOffset = -16 / max8bit;
+ constexpr float uvRange = (240 - 16) / max8bit;
+
+ // Second, stretch limited range YUV signals to full range
+ normalizeYUV.scale(1/yRange, 1/uvRange, 1/uvRange);
+
+ // First, pull limited range signals down so that they start on 0
+ normalizeYUV.translate(yOffset, uvOffset, uvOffset);
+ } else {
+ normalizeYUV.translate(0.0f, uvOffset, uvOffset);
+ }
+
+ const auto [a, b, c] = getColorSpaceCoef(colorSpace, range);
+
+ // Re-normalization coefficients that restores the color difference
+ // signals to (-0.5..0.5)
+ const auto d = 2 * (1.0f - c);
+ const auto e = 2 * (1.0f - a);
+
+ // Color matrix from ITU-R BT.709-6 Table 3 - Signal Format
+ // Same as ITU-R BT.2020-2 Table 4 - Signal format
+ const QMatrix4x4 rgb2yuv {
+ a, b, c, 0.0f, // Item 3.2: E_g' = a * E_R' + b * E_G' + c * E_B'
+ -a/d, -b/d, (1-c)/d, 0.0f, // Item 3.3: E_CB' = (E_B' - E_g')/d
+ (1-a)/e, -b/e, -c/e, 0.0f, // Item 3.3: E_CR' = (E_R' - E_g')/e
+ 0.0f, 0.0f, 0.0f, 1.0f
+ };
+
+ const QMatrix4x4 yuv2rgb = rgb2yuv.inverted();
+
+ // Read backwards:
+ // 1. Offset and scale YUV signal to be in range [0..1]
+ // 3. Convert to RGB in range [0..1]
+ return yuv2rgb * normalizeYUV;
+}
+
+// clang-format on
+
+bool fuzzyCompareWithTolerance(const QMatrix4x4 &computed, const QMatrix4x4 &baseline,
+ float tolerance)
+{
+ const float *computedData = computed.data();
+ const float *baselineData = baseline.data();
+ for (int i = 0; i < 16; ++i) {
+ const float c = computedData[i];
+ const float b = baselineData[i];
+
+ bool difference = false;
+ if (qFuzzyIsNull(c) && qFuzzyIsNull(b))
+ continue;
+
+ difference = 2 * (std::abs(c - b) / (c + b)) > tolerance;
+
+ if (difference) {
+ qDebug() << "Mismatch at index" << i << c << "vs" << b;
+ qDebug() << "Computed:";
+ qDebug() << computed;
+ qDebug() << "Baseline:";
+ qDebug() << baseline;
+
+ return false;
+ }
+ }
+ return true;
+}
+
+bool fuzzyCompareWithTolerance(const QVector3D &computed, const QVector3D &baseline,
+ float tolerance)
+{
+ auto fuzzyCompare = [](float c, float b, float tolerance) {
+ if (std::abs(c) < tolerance && std::abs(b) < tolerance)
+ return true;
+
+ return 2 * std::abs(c - b) / (c + b) < tolerance;
+ };
+
+ const bool equal = fuzzyCompare(computed.x(), baseline.x(), tolerance)
+ && fuzzyCompare(computed.y(), baseline.y(), tolerance)
+ && fuzzyCompare(computed.z(), baseline.z(), tolerance);
+
+ if (!equal) {
+ qDebug() << "Vectors are different. Computed:";
+ qDebug() << computed;
+ qDebug() << "Baseline:";
+ qDebug() << baseline;
+ }
+
+ return equal;
+}
+
+QMatrix4x4 getColorMatrix(const QByteArray &uniformDataBytes)
+{
+ const auto uniformData =
+ reinterpret_cast<const QVideoTextureHelper::UniformData *>(uniformDataBytes.data());
+ const auto colorMatrixData = reinterpret_cast<const float *>(uniformData->colorMatrix);
+
+ return QMatrix4x4{ colorMatrixData }.transposed();
+};
+
+class tst_qvideotexturehelper : public QObject
+{
+ Q_OBJECT
+public:
+private slots:
+ void updateUniformData_populatesYUV2RGBColorMatrix_data()
+ {
+ QTest::addColumn<QVideoFrameFormat::ColorSpace>("colorSpace");
+ QTest::addColumn<QVideoFrameFormat::ColorRange>("colorRange");
+
+ QTest::addRow("BT709_full")
+ << QVideoFrameFormat::ColorSpace_BT709 << QVideoFrameFormat::ColorRange_Full;
+
+ QTest::addRow("BT709_video")
+ << QVideoFrameFormat::ColorSpace_BT709 << QVideoFrameFormat::ColorRange_Video;
+
+ QTest::addRow("BT2020_full")
+ << QVideoFrameFormat::ColorSpace_BT2020 << QVideoFrameFormat::ColorRange_Full;
+
+ QTest::addRow("BT2020_video")
+ << QVideoFrameFormat::ColorSpace_BT2020 << QVideoFrameFormat::ColorRange_Video;
+ }
+
+ void updateUniformData_populatesYUV2RGBColorMatrix()
+ {
+ QFETCH(const QVideoFrameFormat::ColorSpace, colorSpace);
+ QFETCH(const QVideoFrameFormat::ColorRange, colorRange);
+
+ // Arrange
+ QVideoFrameFormat format{ {}, QVideoFrameFormat::Format_NV12 };
+ format.setColorSpace(colorSpace);
+ format.setColorRange(colorRange);
+
+ const QMatrix4x4 expected = yuv2rgb(colorSpace, colorRange);
+
+ // Act
+ QByteArray data;
+ QVideoTextureHelper::updateUniformData(&data, format, {}, {}, 0.0);
+ const QMatrix4x4 actual = getColorMatrix(data);
+
+ // Assert
+ QVERIFY(fuzzyCompareWithTolerance(actual, expected, 1e-3f));
+
+ { // Sanity check: Color matrix maps white to white
+ constexpr QVector3D expectedWhiteRgb{ 1.0f, 1.0f, 1.0f };
+ const QVector3D whiteYuv = expected.inverted().map(expectedWhiteRgb);
+
+ const QVector3D actualWhiteRgb = actual.map(whiteYuv);
+ QVERIFY(fuzzyCompareWithTolerance(actualWhiteRgb, expectedWhiteRgb, 5e-4f));
+ }
+
+ { // Sanity check: Color matrix maps black to black
+ constexpr QVector3D expectedBlackRgb{ 0.0f, 0.0f, 0.0f };
+ const QVector3D blackYuv = expected.inverted().map(expectedBlackRgb);
+
+ const QVector3D actualBlackRgb = actual.map(blackYuv);
+ QVERIFY(fuzzyCompareWithTolerance(actualBlackRgb, expectedBlackRgb, 5e-4f));
+ }
+ }
+};
+
+QTEST_MAIN(tst_qvideotexturehelper)
+
+#include "tst_qvideotexturehelper.moc"
diff --git a/tests/auto/unit/multimedia/qwavedecoder/CMakeLists.txt b/tests/auto/unit/multimedia/qwavedecoder/CMakeLists.txt
new file mode 100644
index 000000000..4567e95ac
--- /dev/null
+++ b/tests/auto/unit/multimedia/qwavedecoder/CMakeLists.txt
@@ -0,0 +1,24 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+# Generated from qwavedecoder.pro.
+
+#####################################################################
+## tst_qwavedecoder Test:
+#####################################################################
+
+# Collect test data
+file(GLOB_RECURSE test_data_glob
+ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
+ data/*)
+list(APPEND test_data ${test_data_glob})
+
+qt_internal_add_test(tst_qwavedecoder
+ SOURCES
+ tst_qwavedecoder.cpp
+ LIBRARIES
+ Qt::Gui
+ Qt::MultimediaPrivate
+ Qt::Network
+ TESTDATA ${test_data}
+)
diff --git a/tests/auto/unit/qwavedecoder/data/corrupt_datadesc_1_16_8000.le.wav b/tests/auto/unit/multimedia/qwavedecoder/data/corrupt_datadesc_1_16_8000.le.wav
index b6eac4d70..b6eac4d70 100644
--- a/tests/auto/unit/qwavedecoder/data/corrupt_datadesc_1_16_8000.le.wav
+++ b/tests/auto/unit/multimedia/qwavedecoder/data/corrupt_datadesc_1_16_8000.le.wav
Binary files differ
diff --git a/tests/auto/unit/qwavedecoder/data/corrupt_fmtdesc_1_16_8000.le.wav b/tests/auto/unit/multimedia/qwavedecoder/data/corrupt_fmtdesc_1_16_8000.le.wav
index 2f0da1370..2f0da1370 100644
--- a/tests/auto/unit/qwavedecoder/data/corrupt_fmtdesc_1_16_8000.le.wav
+++ b/tests/auto/unit/multimedia/qwavedecoder/data/corrupt_fmtdesc_1_16_8000.le.wav
Binary files differ
diff --git a/tests/auto/unit/qwavedecoder/data/corrupt_fmtstring_1_16_8000.le.wav b/tests/auto/unit/multimedia/qwavedecoder/data/corrupt_fmtstring_1_16_8000.le.wav
index b14a53c9e..b14a53c9e 100644
--- a/tests/auto/unit/qwavedecoder/data/corrupt_fmtstring_1_16_8000.le.wav
+++ b/tests/auto/unit/multimedia/qwavedecoder/data/corrupt_fmtstring_1_16_8000.le.wav
Binary files differ
diff --git a/tests/auto/unit/qwavedecoder/data/empty.wav b/tests/auto/unit/multimedia/qwavedecoder/data/empty.wav
index e69de29bb..e69de29bb 100644
--- a/tests/auto/unit/qwavedecoder/data/empty.wav
+++ b/tests/auto/unit/multimedia/qwavedecoder/data/empty.wav
diff --git a/tests/auto/unit/multimedia/qwavedecoder/data/gendata.sh b/tests/auto/unit/multimedia/qwavedecoder/data/gendata.sh
new file mode 100755
index 000000000..99a04129b
--- /dev/null
+++ b/tests/auto/unit/multimedia/qwavedecoder/data/gendata.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+# Copyright (C) 2016 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+# Generate some simple test data. Uses "sox".
+
+endian=""
+endian_extn=""
+
+for channel in 1 2; do
+ if [ $channel -eq 1 ]; then
+ endian="little"
+ endian_extn="le"
+ fi
+
+ if [ $channel -eq 2 ]; then
+ endian="big"
+ endian_extn="be"
+ fi
+ for samplebits in 8 16 32; do
+ for samplerate in 44100 8000; do
+ if [ $samplebits -ne 8 ]; then
+ sox -n --endian "${endian}" -c ${channel} -b ${samplebits} -r ${samplerate} isawav_${channel}_${samplebits}_${samplerate}_${endian_extn}.wav synth 0.25 sine 300-3300
+ else
+ sox -n -c ${channel} -b ${samplebits} -r ${samplerate} isawav_${channel}_${samplebits}_${samplerate}.wav synth 0.25 sine 300-3300
+ fi
+ done
+ done
+done
+
diff --git a/tests/auto/unit/qwavedecoder/data/isawav_1_16_44100_le.wav b/tests/auto/unit/multimedia/qwavedecoder/data/isawav_1_16_44100_le.wav
index 88b1a8379..88b1a8379 100644
--- a/tests/auto/unit/qwavedecoder/data/isawav_1_16_44100_le.wav
+++ b/tests/auto/unit/multimedia/qwavedecoder/data/isawav_1_16_44100_le.wav
Binary files differ
diff --git a/tests/auto/unit/qwavedecoder/data/isawav_1_16_44100_le_2.wav b/tests/auto/unit/multimedia/qwavedecoder/data/isawav_1_16_44100_le_2.wav
index 087e68e82..087e68e82 100644
--- a/tests/auto/unit/qwavedecoder/data/isawav_1_16_44100_le_2.wav
+++ b/tests/auto/unit/multimedia/qwavedecoder/data/isawav_1_16_44100_le_2.wav
Binary files differ
diff --git a/tests/auto/unit/qwavedecoder/data/isawav_1_16_8000_le.wav b/tests/auto/unit/multimedia/qwavedecoder/data/isawav_1_16_8000_le.wav
index 83a405907..83a405907 100644
--- a/tests/auto/unit/qwavedecoder/data/isawav_1_16_8000_le.wav
+++ b/tests/auto/unit/multimedia/qwavedecoder/data/isawav_1_16_8000_le.wav
Binary files differ
diff --git a/tests/auto/unit/qwavedecoder/data/isawav_1_32_44100_le.wav b/tests/auto/unit/multimedia/qwavedecoder/data/isawav_1_32_44100_le.wav
index 9c437b155..9c437b155 100644
--- a/tests/auto/unit/qwavedecoder/data/isawav_1_32_44100_le.wav
+++ b/tests/auto/unit/multimedia/qwavedecoder/data/isawav_1_32_44100_le.wav
Binary files differ
diff --git a/tests/auto/unit/qwavedecoder/data/isawav_1_32_8000_le.wav b/tests/auto/unit/multimedia/qwavedecoder/data/isawav_1_32_8000_le.wav
index f90a8bc35..f90a8bc35 100644
--- a/tests/auto/unit/qwavedecoder/data/isawav_1_32_8000_le.wav
+++ b/tests/auto/unit/multimedia/qwavedecoder/data/isawav_1_32_8000_le.wav
Binary files differ
diff --git a/tests/auto/unit/qwavedecoder/data/isawav_1_8_44100.wav b/tests/auto/unit/multimedia/qwavedecoder/data/isawav_1_8_44100.wav
index 7d10829ea..7d10829ea 100644
--- a/tests/auto/unit/qwavedecoder/data/isawav_1_8_44100.wav
+++ b/tests/auto/unit/multimedia/qwavedecoder/data/isawav_1_8_44100.wav
Binary files differ
diff --git a/tests/auto/unit/qwavedecoder/data/isawav_1_8_8000.wav b/tests/auto/unit/multimedia/qwavedecoder/data/isawav_1_8_8000.wav
index 76c08e89e..76c08e89e 100644
--- a/tests/auto/unit/qwavedecoder/data/isawav_1_8_8000.wav
+++ b/tests/auto/unit/multimedia/qwavedecoder/data/isawav_1_8_8000.wav
Binary files differ
diff --git a/tests/auto/unit/multimedia/qwavedecoder/data/isawav_1_8_8000_even_bext.wav b/tests/auto/unit/multimedia/qwavedecoder/data/isawav_1_8_8000_even_bext.wav
new file mode 100644
index 000000000..531b0ee58
--- /dev/null
+++ b/tests/auto/unit/multimedia/qwavedecoder/data/isawav_1_8_8000_even_bext.wav
Binary files differ
diff --git a/tests/auto/unit/multimedia/qwavedecoder/data/isawav_1_8_8000_odd_bext.wav b/tests/auto/unit/multimedia/qwavedecoder/data/isawav_1_8_8000_odd_bext.wav
new file mode 100644
index 000000000..467be6312
--- /dev/null
+++ b/tests/auto/unit/multimedia/qwavedecoder/data/isawav_1_8_8000_odd_bext.wav
Binary files differ
diff --git a/tests/auto/unit/qwavedecoder/data/isawav_2_16_44100_be.wav b/tests/auto/unit/multimedia/qwavedecoder/data/isawav_2_16_44100_be.wav
index ca0cd425a..ca0cd425a 100644
--- a/tests/auto/unit/qwavedecoder/data/isawav_2_16_44100_be.wav
+++ b/tests/auto/unit/multimedia/qwavedecoder/data/isawav_2_16_44100_be.wav
Binary files differ
diff --git a/tests/auto/unit/qwavedecoder/data/isawav_2_16_8000_be.wav b/tests/auto/unit/multimedia/qwavedecoder/data/isawav_2_16_8000_be.wav
index 3a684590b..3a684590b 100644
--- a/tests/auto/unit/qwavedecoder/data/isawav_2_16_8000_be.wav
+++ b/tests/auto/unit/multimedia/qwavedecoder/data/isawav_2_16_8000_be.wav
Binary files differ
diff --git a/tests/auto/unit/qwavedecoder/data/isawav_2_32_44100_be.wav b/tests/auto/unit/multimedia/qwavedecoder/data/isawav_2_32_44100_be.wav
index f1aaf2906..f1aaf2906 100644
--- a/tests/auto/unit/qwavedecoder/data/isawav_2_32_44100_be.wav
+++ b/tests/auto/unit/multimedia/qwavedecoder/data/isawav_2_32_44100_be.wav
Binary files differ
diff --git a/tests/auto/unit/qwavedecoder/data/isawav_2_32_8000_be.wav b/tests/auto/unit/multimedia/qwavedecoder/data/isawav_2_32_8000_be.wav
index c10c20872..c10c20872 100644
--- a/tests/auto/unit/qwavedecoder/data/isawav_2_32_8000_be.wav
+++ b/tests/auto/unit/multimedia/qwavedecoder/data/isawav_2_32_8000_be.wav
Binary files differ
diff --git a/tests/auto/unit/qwavedecoder/data/isawav_2_8_44100.wav b/tests/auto/unit/multimedia/qwavedecoder/data/isawav_2_8_44100.wav
index befd02baf..befd02baf 100644
--- a/tests/auto/unit/qwavedecoder/data/isawav_2_8_44100.wav
+++ b/tests/auto/unit/multimedia/qwavedecoder/data/isawav_2_8_44100.wav
Binary files differ
diff --git a/tests/auto/unit/qwavedecoder/data/isawav_2_8_8000.wav b/tests/auto/unit/multimedia/qwavedecoder/data/isawav_2_8_8000.wav
index ce8b0d06a..ce8b0d06a 100644
--- a/tests/auto/unit/qwavedecoder/data/isawav_2_8_8000.wav
+++ b/tests/auto/unit/multimedia/qwavedecoder/data/isawav_2_8_8000.wav
Binary files differ
diff --git a/tests/auto/unit/qwavedecoder/data/nosampledata.wav b/tests/auto/unit/multimedia/qwavedecoder/data/nosampledata.wav
index 8dbde9545..8dbde9545 100644
--- a/tests/auto/unit/qwavedecoder/data/nosampledata.wav
+++ b/tests/auto/unit/multimedia/qwavedecoder/data/nosampledata.wav
Binary files differ
diff --git a/tests/auto/unit/qwavedecoder/data/notawav.wav b/tests/auto/unit/multimedia/qwavedecoder/data/notawav.wav
index 36a20ea05..36a20ea05 100644
--- a/tests/auto/unit/qwavedecoder/data/notawav.wav
+++ b/tests/auto/unit/multimedia/qwavedecoder/data/notawav.wav
diff --git a/tests/auto/unit/qwavedecoder/data/onebyte.wav b/tests/auto/unit/multimedia/qwavedecoder/data/onebyte.wav
index d00491fd7..d00491fd7 100644
--- a/tests/auto/unit/qwavedecoder/data/onebyte.wav
+++ b/tests/auto/unit/multimedia/qwavedecoder/data/onebyte.wav
diff --git a/tests/auto/unit/qwavedecoder/tst_qwavedecoder.cpp b/tests/auto/unit/multimedia/qwavedecoder/tst_qwavedecoder.cpp
index 274450602..079f98075 100644
--- a/tests/auto/unit/qwavedecoder/tst_qwavedecoder.cpp
+++ b/tests/auto/unit/multimedia/qwavedecoder/tst_qwavedecoder.cpp
@@ -1,35 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//TESTED_COMPONENT=src/multimedia
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtTest/QtTest>
-#include <private/qwavedecoder_p.h>
+#include <qwavedecoder.h>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
@@ -67,8 +40,6 @@ private slots:
void readPerByte();
};
-Q_DECLARE_METATYPE(tst_QWaveDecoder::Corruption)
-
void tst_QWaveDecoder::init()
{
}
@@ -87,7 +58,7 @@ void tst_QWaveDecoder::cleanupTestCase()
static QString testFilePath(const char *filename)
{
- QString path = QString("data/%1").arg(filename);
+ QString path = QStringLiteral("data/%1").arg(filename);
return QFINDTESTDATA(path);
}
@@ -98,33 +69,35 @@ void tst_QWaveDecoder::file_data()
QTest::addColumn<int>("channels");
QTest::addColumn<int>("samplesize");
QTest::addColumn<int>("samplerate");
- QTest::addColumn<QAudioFormat::Endian>("byteorder");
-
- QTest::newRow("File is empty") << testFilePath("empty.wav") << tst_QWaveDecoder::NotAWav << -1 << -1 << -1 << QAudioFormat::LittleEndian;
- QTest::newRow("File is one byte") << testFilePath("onebyte.wav") << tst_QWaveDecoder::NotAWav << -1 << -1 << -1 << QAudioFormat::LittleEndian;
- QTest::newRow("File is not a wav(text)") << testFilePath("notawav.wav") << tst_QWaveDecoder::NotAWav << -1 << -1 << -1 << QAudioFormat::LittleEndian;
- QTest::newRow("Wav file has no sample data") << testFilePath("nosampledata.wav") << tst_QWaveDecoder::NoSampleData << -1 << -1 << -1 << QAudioFormat::LittleEndian;
- QTest::newRow("corrupt fmt chunk descriptor") << testFilePath("corrupt_fmtdesc_1_16_8000.le.wav") << tst_QWaveDecoder::FormatDescriptor << -1 << -1 << -1 << QAudioFormat::LittleEndian;
- QTest::newRow("corrupt fmt string") << testFilePath("corrupt_fmtstring_1_16_8000.le.wav") << tst_QWaveDecoder::FormatString << -1 << -1 << -1 << QAudioFormat::LittleEndian;
- QTest::newRow("corrupt data chunk descriptor") << testFilePath("corrupt_datadesc_1_16_8000.le.wav") << tst_QWaveDecoder::DataDescriptor << -1 << -1 << -1 << QAudioFormat::LittleEndian;
-
- QTest::newRow("File isawav_1_8_8000.wav") << testFilePath("isawav_1_8_8000.wav") << tst_QWaveDecoder::None << 1 << 8 << 8000 << QAudioFormat::LittleEndian;
- QTest::newRow("File isawav_1_8_44100.wav") << testFilePath("isawav_1_8_44100.wav") << tst_QWaveDecoder::None << 1 << 8 << 44100 << QAudioFormat::LittleEndian;
- QTest::newRow("File isawav_2_8_8000.wav") << testFilePath("isawav_2_8_8000.wav") << tst_QWaveDecoder::None << 2 << 8 << 8000 << QAudioFormat::LittleEndian;
- QTest::newRow("File isawav_2_8_44100.wav") << testFilePath("isawav_2_8_44100.wav") << tst_QWaveDecoder::None << 2 << 8 << 44100 << QAudioFormat::LittleEndian;
-
- QTest::newRow("File isawav_1_16_8000_le.wav") << testFilePath("isawav_1_16_8000_le.wav") << tst_QWaveDecoder::None << 1 << 16 << 8000 << QAudioFormat::LittleEndian;
- QTest::newRow("File isawav_1_16_44100_le.wav") << testFilePath("isawav_1_16_44100_le.wav") << tst_QWaveDecoder::None << 1 << 16 << 44100 << QAudioFormat::LittleEndian;
- QTest::newRow("File isawav_2_16_8000_be.wav") << testFilePath("isawav_2_16_8000_be.wav") << tst_QWaveDecoder::None << 2 << 16 << 8000 << QAudioFormat::BigEndian;
- QTest::newRow("File isawav_2_16_44100_be.wav") << testFilePath("isawav_2_16_44100_be.wav") << tst_QWaveDecoder::None << 2 << 16 << 44100 << QAudioFormat::BigEndian;
- // The next file has extra data in the wave header.
- QTest::newRow("File isawav_1_16_44100_le_2.wav") << testFilePath("isawav_1_16_44100_le_2.wav") << tst_QWaveDecoder::None << 1 << 16 << 44100 << QAudioFormat::LittleEndian;
+ QTest::newRow("File is empty") << testFilePath("empty.wav") << tst_QWaveDecoder::NotAWav << -1 << -1 << -1;
+ QTest::newRow("File is one byte") << testFilePath("onebyte.wav") << tst_QWaveDecoder::NotAWav << -1 << -1 << -1;
+ QTest::newRow("File is not a wav(text)") << testFilePath("notawav.wav") << tst_QWaveDecoder::NotAWav << -1 << -1 << -1;
+ QTest::newRow("Wav file has no sample data") << testFilePath("nosampledata.wav") << tst_QWaveDecoder::NoSampleData << -1 << -1 << -1;
+ QTest::newRow("corrupt fmt chunk descriptor") << testFilePath("corrupt_fmtdesc_1_16_8000.le.wav") << tst_QWaveDecoder::FormatDescriptor << -1 << -1 << -1;
+ QTest::newRow("corrupt fmt string") << testFilePath("corrupt_fmtstring_1_16_8000.le.wav") << tst_QWaveDecoder::FormatString << -1 << -1 << -1;
+ QTest::newRow("corrupt data chunk descriptor") << testFilePath("corrupt_datadesc_1_16_8000.le.wav") << tst_QWaveDecoder::DataDescriptor << -1 << -1 << -1;
+
+ QTest::newRow("File isawav_1_8_8000.wav") << testFilePath("isawav_1_8_8000.wav") << tst_QWaveDecoder::None << 1 << 8 << 8000;
+ QTest::newRow("File isawav_1_8_44100.wav") << testFilePath("isawav_1_8_44100.wav") << tst_QWaveDecoder::None << 1 << 8 << 44100;
+ QTest::newRow("File isawav_2_8_8000.wav") << testFilePath("isawav_2_8_8000.wav") << tst_QWaveDecoder::None << 2 << 8 << 8000;
+ QTest::newRow("File isawav_2_8_44100.wav") << testFilePath("isawav_2_8_44100.wav") << tst_QWaveDecoder::None << 2 << 8 << 44100;
+
+ QTest::newRow("File isawav_1_16_8000_le.wav") << testFilePath("isawav_1_16_8000_le.wav") << tst_QWaveDecoder::None << 1 << 16 << 8000;
+ QTest::newRow("File isawav_1_16_44100_le.wav") << testFilePath("isawav_1_16_44100_le.wav") << tst_QWaveDecoder::None << 1 << 16 << 44100;
+ QTest::newRow("File isawav_2_16_8000_be.wav") << testFilePath("isawav_2_16_8000_be.wav") << tst_QWaveDecoder::None << 2 << 16 << 8000;
+ QTest::newRow("File isawav_2_16_44100_be.wav") << testFilePath("isawav_2_16_44100_be.wav") << tst_QWaveDecoder::None << 2 << 16 << 44100;
+ // The next file has extra data in the wave header.
+ QTest::newRow("File isawav_1_16_44100_le_2.wav") << testFilePath("isawav_1_16_44100_le_2.wav") << tst_QWaveDecoder::None << 1 << 16 << 44100;
+ // The next file has embedded bext chunk with odd payload (QTBUG-122193)
+ QTest::newRow("File isawav_1_8_8000_odd_bext.wav") << testFilePath("isawav_1_8_8000_odd_bext.wav") << tst_QWaveDecoder::None << 1 << 8 << 8000;
+ // The next file has embedded bext chunk with even payload
+ QTest::newRow("File isawav_1_8_8000_even_bext.wav") << testFilePath("isawav_1_8_8000_even_bext.wav") << tst_QWaveDecoder::None << 1 << 8 << 8000;
// 32 bit waves are not supported
- QTest::newRow("File isawav_1_32_8000_le.wav") << testFilePath("isawav_1_32_8000_le.wav") << tst_QWaveDecoder::FormatDescriptor << 1 << 32 << 8000 << QAudioFormat::LittleEndian;
- QTest::newRow("File isawav_1_32_44100_le.wav") << testFilePath("isawav_1_32_44100_le.wav") << tst_QWaveDecoder::FormatDescriptor << 1 << 32 << 44100 << QAudioFormat::LittleEndian;
- QTest::newRow("File isawav_2_32_8000_be.wav") << testFilePath("isawav_2_32_8000_be.wav") << tst_QWaveDecoder::FormatDescriptor << 2 << 32 << 8000 << QAudioFormat::BigEndian;
- QTest::newRow("File isawav_2_32_44100_be.wav") << testFilePath("isawav_2_32_44100_be.wav") << tst_QWaveDecoder::FormatDescriptor << 2 << 32 << 44100 << QAudioFormat::BigEndian;
+ QTest::newRow("File isawav_1_32_8000_le.wav") << testFilePath("isawav_1_32_8000_le.wav") << tst_QWaveDecoder::FormatDescriptor << 1 << 32 << 8000;
+ QTest::newRow("File isawav_1_32_44100_le.wav") << testFilePath("isawav_1_32_44100_le.wav") << tst_QWaveDecoder::FormatDescriptor << 1 << 32 << 44100;
+ QTest::newRow("File isawav_2_32_8000_be.wav") << testFilePath("isawav_2_32_8000_be.wav") << tst_QWaveDecoder::FormatDescriptor << 2 << 32 << 8000;
+ QTest::newRow("File isawav_2_32_44100_be.wav") << testFilePath("isawav_2_32_44100_be.wav") << tst_QWaveDecoder::FormatDescriptor << 2 << 32 << 44100;
}
void tst_QWaveDecoder::file()
@@ -134,7 +107,6 @@ void tst_QWaveDecoder::file()
QFETCH(int, channels);
QFETCH(int, samplesize);
QFETCH(int, samplerate);
- QFETCH(QAudioFormat::Endian, byteorder);
QFile stream;
stream.setFileName(file);
@@ -143,8 +115,10 @@ void tst_QWaveDecoder::file()
QVERIFY(stream.isOpen());
QWaveDecoder waveDecoder(&stream);
- QSignalSpy validFormatSpy(&waveDecoder, SIGNAL(formatKnown()));
- QSignalSpy parsingErrorSpy(&waveDecoder, SIGNAL(parsingError()));
+ QSignalSpy validFormatSpy(&waveDecoder, &QWaveDecoder::formatKnown);
+ QSignalSpy parsingErrorSpy(&waveDecoder, &QWaveDecoder::parsingError);
+
+ QVERIFY(waveDecoder.open(QIODeviceBase::ReadOnly));
if (corruption == NotAWav) {
QSKIP("Not all failures detected correctly yet");
@@ -176,11 +150,8 @@ void tst_QWaveDecoder::file()
QAudioFormat format = waveDecoder.audioFormat();
QVERIFY(format.isValid());
QVERIFY(format.channelCount() == channels);
- QVERIFY(format.sampleSize() == samplesize);
+ QCOMPARE(format.bytesPerSample() * 8, samplesize);
QVERIFY(format.sampleRate() == samplerate);
- if (format.sampleSize() != 8) {
- QVERIFY(format.byteOrder() == byteorder);
- }
}
stream.close();
@@ -193,7 +164,6 @@ void tst_QWaveDecoder::http()
QFETCH(int, channels);
QFETCH(int, samplesize);
QFETCH(int, samplerate);
- QFETCH(QAudioFormat::Endian, byteorder);
QFile stream;
stream.setFileName(file);
@@ -206,8 +176,10 @@ void tst_QWaveDecoder::http()
QNetworkReply *reply = nam.get(QNetworkRequest(QUrl::fromLocalFile(file)));
QWaveDecoder waveDecoder(reply);
- QSignalSpy validFormatSpy(&waveDecoder, SIGNAL(formatKnown()));
- QSignalSpy parsingErrorSpy(&waveDecoder, SIGNAL(parsingError()));
+ QSignalSpy validFormatSpy(&waveDecoder, &QWaveDecoder::formatKnown);
+ QSignalSpy parsingErrorSpy(&waveDecoder, &QWaveDecoder::parsingError);
+
+ QVERIFY(waveDecoder.open(QIODeviceBase::ReadOnly));
if (corruption == NotAWav) {
QSKIP("Not all failures detected correctly yet");
@@ -239,11 +211,8 @@ void tst_QWaveDecoder::http()
QAudioFormat format = waveDecoder.audioFormat();
QVERIFY(format.isValid());
QVERIFY(format.channelCount() == channels);
- QVERIFY(format.sampleSize() == samplesize);
+ QCOMPARE(format.bytesPerSample() * 8, samplesize);
QVERIFY(format.sampleRate() == samplerate);
- if (format.sampleSize() != 8) {
- QVERIFY(format.byteOrder() == byteorder);
- }
}
delete reply;
@@ -258,7 +227,9 @@ void tst_QWaveDecoder::readAllAtOnce()
QVERIFY(stream.isOpen());
QWaveDecoder waveDecoder(&stream);
- QSignalSpy validFormatSpy(&waveDecoder, SIGNAL(formatKnown()));
+ QSignalSpy validFormatSpy(&waveDecoder, &QWaveDecoder::formatKnown);
+
+ QVERIFY(waveDecoder.open(QIODeviceBase::ReadOnly));
QTRY_COMPARE(validFormatSpy.count(), 1);
QVERIFY(waveDecoder.size() > 0);
@@ -284,7 +255,9 @@ void tst_QWaveDecoder::readPerByte()
QVERIFY(stream.isOpen());
QWaveDecoder waveDecoder(&stream);
- QSignalSpy validFormatSpy(&waveDecoder, SIGNAL(formatKnown()));
+ QSignalSpy validFormatSpy(&waveDecoder, &QWaveDecoder::formatKnown);
+
+ QVERIFY(waveDecoder.open(QIODeviceBase::ReadOnly));
QTRY_COMPARE(validFormatSpy.count(), 1);
QVERIFY(waveDecoder.size() > 0);
diff --git a/tests/auto/unit/multimediaqml.pro b/tests/auto/unit/multimediaqml.pro
deleted file mode 100644
index e8cdcb67e..000000000
--- a/tests/auto/unit/multimediaqml.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-
-TEMPLATE = subdirs
-SUBDIRS += \
- qdeclarativemultimediaglobal \
- qdeclarativeaudio \
- qdeclarativecamera
-
-disabled {
- SUBDIRS += \
- qdeclarativevideo
-}
-
diff --git a/tests/auto/unit/multimediawidgets.pro b/tests/auto/unit/multimediawidgets.pro
deleted file mode 100644
index 1bcfc6c2e..000000000
--- a/tests/auto/unit/multimediawidgets.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-
-TEMPLATE = subdirs
-SUBDIRS += \
- qcameraviewfinder \
- qcamerawidgets \
- qmediaplayerwidgets \
-
-# Tests depending on private interfaces should only be built if
-# these interfaces are exported.
-qtConfig(private_tests) {
- SUBDIRS += \
- qgraphicsvideoitem \
- qpaintervideosurface \
- qvideowidget
-}
-
diff --git a/tests/auto/unit/multimediawidgets/CMakeLists.txt b/tests/auto/unit/multimediawidgets/CMakeLists.txt
new file mode 100644
index 000000000..87adc0190
--- /dev/null
+++ b/tests/auto/unit/multimediawidgets/CMakeLists.txt
@@ -0,0 +1,13 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+# Generated from multimediawidgets.pro.
+
+add_subdirectory(qcamerawidgets)
+add_subdirectory(qgraphicsvideoitem)
+add_subdirectory(qmediaplayerwidgets)
+add_subdirectory(qvideowidget)
+if(QT_FEATURE_private_tests)
+# add_subdirectory(qgraphicsvideoitem)
+# add_subdirectory(qvideowidget)
+endif()
diff --git a/tests/auto/unit/multimediawidgets/qcamerawidgets/CMakeLists.txt b/tests/auto/unit/multimediawidgets/qcamerawidgets/CMakeLists.txt
new file mode 100644
index 000000000..486f34690
--- /dev/null
+++ b/tests/auto/unit/multimediawidgets/qcamerawidgets/CMakeLists.txt
@@ -0,0 +1,22 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+# Generated from qcamerawidgets.pro.
+
+#####################################################################
+## tst_qcamerawidgets Test:
+#####################################################################
+
+qt_internal_add_test(tst_qcamerawidgets
+ SOURCES
+ tst_qcamerawidgets.cpp
+ INCLUDE_DIRECTORIES
+ ../../mockbackend
+ LIBRARIES
+ # Remove: L${CMAKE_CURRENT_SOURCE_DIR}
+ Qt::Gui
+ Qt::MultimediaPrivate
+ Qt::MultimediaWidgetsPrivate
+ Qt::Widgets
+ MockMultimediaPlugin
+)
diff --git a/tests/auto/unit/multimediawidgets/qcamerawidgets/tst_qcamerawidgets.cpp b/tests/auto/unit/multimediawidgets/qcamerawidgets/tst_qcamerawidgets.cpp
new file mode 100644
index 000000000..6c31a4b66
--- /dev/null
+++ b/tests/auto/unit/multimediawidgets/qcamerawidgets/tst_qcamerawidgets.cpp
@@ -0,0 +1,114 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QtTest/QtTest>
+#include <QDebug>
+
+#include <private/qplatformcamera_p.h>
+#include <private/qplatformimagecapture_p.h>
+#include <qmediacapturesession.h>
+#include <qcamera.h>
+#include <qimagecapture.h>
+#include <qgraphicsvideoitem.h>
+#include <qobject.h>
+#include <qvideowidget.h>
+#include <qvideosink.h>
+
+#include "qmockmediacapturesession.h"
+#include "qmockintegration.h"
+
+QT_USE_NAMESPACE
+
+Q_ENABLE_MOCK_MULTIMEDIA_PLUGIN
+
+class tst_QCameraWidgets: public QObject
+{
+ Q_OBJECT
+
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+
+private slots:
+ void testCameraEncodingProperyChange();
+ void testSetVideoOutput();
+};
+
+void tst_QCameraWidgets::initTestCase()
+{
+}
+
+
+void tst_QCameraWidgets::cleanupTestCase()
+{
+}
+
+void tst_QCameraWidgets::testCameraEncodingProperyChange()
+{
+ QMediaCaptureSession session;
+ QCamera camera;
+ QImageCapture imageCapture;
+ session.setCamera(&camera);
+ session.setImageCapture(&imageCapture);
+
+ QSignalSpy activeChangedSignal(&camera, &QCamera::activeChanged);
+
+ camera.start();
+ QCOMPARE(camera.isActive(), true);
+
+ QCOMPARE(activeChangedSignal.size(), 1);
+}
+
+void tst_QCameraWidgets::testSetVideoOutput()
+{
+ QVideoWidget widget;
+ QGraphicsVideoItem item;
+ QVideoSink surface;
+ QMediaCaptureSession session;
+
+ session.setVideoOutput(&widget);
+ QVERIFY(session.videoSink() == widget.videoSink());
+ QVERIFY(session.videoOutput() == &widget);
+
+ session.setVideoOutput(&item);
+ QVERIFY(session.videoSink() == item.videoSink());
+ QVERIFY(session.videoOutput() == &item);
+
+ session.setVideoOutput(nullptr);
+ QVERIFY(session.videoSink() == nullptr);
+ QVERIFY(session.videoOutput() == nullptr);
+
+ session.setVideoOutput(&widget);
+ QVERIFY(session.videoSink() == widget.videoSink());
+ QVERIFY(session.videoOutput() == &widget);
+
+ session.setVideoOutput(nullptr);
+ QVERIFY(session.videoOutput() == nullptr);
+
+ session.setVideoOutput(&surface);
+ QVERIFY(session.videoSink() == &surface);
+ QVERIFY(session.videoOutput() == &surface);
+
+ session.setVideoSink(nullptr);
+ QVERIFY(session.videoSink() == nullptr);
+ QVERIFY(session.videoOutput() == nullptr);
+
+ session.setVideoOutput(&surface);
+ QVERIFY(session.videoSink() == &surface);
+ QVERIFY(session.videoOutput() == &surface);
+
+ session.setVideoSink(&surface);
+ QVERIFY(session.videoSink() == &surface);
+ QVERIFY(session.videoOutput() == nullptr);
+
+ session.setVideoOutput(&widget);
+ QVERIFY(session.videoSink() == widget.videoSink());
+ QVERIFY(session.videoOutput() == &widget);
+
+ session.setVideoOutput(&surface);
+ QVERIFY(session.videoOutput() == &surface);
+}
+
+QTEST_MAIN(tst_QCameraWidgets)
+
+#include "tst_qcamerawidgets.moc"
diff --git a/tests/auto/unit/multimediawidgets/qgraphicsvideoitem/CMakeLists.txt b/tests/auto/unit/multimediawidgets/qgraphicsvideoitem/CMakeLists.txt
new file mode 100644
index 000000000..599042725
--- /dev/null
+++ b/tests/auto/unit/multimediawidgets/qgraphicsvideoitem/CMakeLists.txt
@@ -0,0 +1,21 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+# Generated from qgraphicsvideoitem.pro.
+
+#####################################################################
+## tst_qgraphicsvideoitem Test:
+#####################################################################
+
+qt_internal_add_test(tst_qgraphicsvideoitem
+ SOURCES
+ tst_qgraphicsvideoitem.cpp
+ INCLUDE_DIRECTORIES
+ ../../mockbackend
+ LIBRARIES
+ Qt::Gui
+ Qt::MultimediaPrivate
+ Qt::MultimediaWidgetsPrivate
+ Qt::Widgets
+ MockMultimediaPlugin
+)
diff --git a/tests/auto/unit/multimediawidgets/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp b/tests/auto/unit/multimediawidgets/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp
new file mode 100644
index 000000000..0cda11de1
--- /dev/null
+++ b/tests/auto/unit/multimediawidgets/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp
@@ -0,0 +1,389 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <qtmultimediaglobal.h>
+#include "qgraphicsvideoitem.h"
+#include <QtTest/QtTest>
+
+#include <qvideosink.h>
+#include <qvideoframeformat.h>
+#include <qvideoframe.h>
+#include <qmediaplayer.h>
+
+#include <QtWidgets/qapplication.h>
+#include <QtWidgets/qgraphicsscene.h>
+#include <QtWidgets/qgraphicsview.h>
+
+#include <qmockintegration.h>
+
+QT_USE_NAMESPACE
+
+Q_ENABLE_MOCK_MULTIMEDIA_PLUGIN
+
+class tst_QGraphicsVideoItem : public QObject
+{
+ Q_OBJECT
+public slots:
+ void initTestCase();
+
+private slots:
+ void nullObject();
+ void playerDestroyed();
+
+ void show();
+
+ void aspectRatioMode();
+ void offset();
+ void size();
+ void nativeSize_data();
+ void nativeSize();
+
+ void boundingRect_data();
+ void boundingRect();
+
+ void paint();
+};
+
+class QtTestGraphicsVideoItem : public QGraphicsVideoItem
+{
+public:
+ QtTestGraphicsVideoItem(QGraphicsItem *parent = nullptr)
+ : QGraphicsVideoItem(parent)
+ {
+ }
+
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override
+ {
+ ++m_paintCount;
+
+ QTestEventLoop::instance().exitLoop();
+
+ QGraphicsVideoItem::paint(painter, option, widget);
+ }
+
+ bool waitForPaint(int secs)
+ {
+ const int paintCount = m_paintCount;
+
+ QTestEventLoop::instance().enterLoop(secs);
+
+ return m_paintCount != paintCount;
+ }
+
+ [[nodiscard]] int paintCount() const
+ {
+ return m_paintCount;
+ }
+
+private:
+ int m_paintCount = 0;
+};
+
+void tst_QGraphicsVideoItem::initTestCase()
+{
+}
+
+void tst_QGraphicsVideoItem::nullObject()
+{
+ QGraphicsVideoItem item(nullptr);
+
+ QVERIFY(item.boundingRect().isEmpty());
+}
+
+void tst_QGraphicsVideoItem::playerDestroyed()
+{
+ QGraphicsVideoItem item;
+ {
+ QMediaPlayer player;
+ player.setVideoOutput(&item);
+ }
+
+ QVERIFY(item.boundingRect().isEmpty());
+}
+
+void tst_QGraphicsVideoItem::show()
+{
+ auto *item = new QtTestGraphicsVideoItem;
+ QMediaPlayer player;
+ player.setVideoOutput(item);
+
+ // Graphics items are visible by default
+ item->hide();
+ item->show();
+
+ QGraphicsScene graphicsScene;
+ graphicsScene.addItem(item);
+ QGraphicsView graphicsView(&graphicsScene);
+ graphicsView.show();
+
+ QVERIFY(item->paintCount() || item->waitForPaint(1));
+
+ QVERIFY(item->boundingRect().isEmpty());
+
+ // ### Ensure we get a correct bounding rect
+// QVideoFrameFormat format(QSize(320,240),QVideoFrameFormat::Format_RGB32);
+// QVERIFY(object.testService->rendererControl->surface()->start(format));
+
+// QCoreApplication::processEvents();
+// QVERIFY(!item->boundingRect().isEmpty());
+}
+
+void tst_QGraphicsVideoItem::aspectRatioMode()
+{
+ QGraphicsVideoItem item;
+
+ QCOMPARE(item.aspectRatioMode(), Qt::KeepAspectRatio);
+
+ item.setAspectRatioMode(Qt::IgnoreAspectRatio);
+ QCOMPARE(item.aspectRatioMode(), Qt::IgnoreAspectRatio);
+
+ item.setAspectRatioMode(Qt::KeepAspectRatioByExpanding);
+ QCOMPARE(item.aspectRatioMode(), Qt::KeepAspectRatioByExpanding);
+
+ item.setAspectRatioMode(Qt::KeepAspectRatio);
+ QCOMPARE(item.aspectRatioMode(), Qt::KeepAspectRatio);
+}
+
+void tst_QGraphicsVideoItem::offset()
+{
+ QGraphicsVideoItem item;
+
+ QCOMPARE(item.offset(), QPointF(0, 0));
+
+ item.setOffset(QPointF(-32.4, 43.0));
+ QCOMPARE(item.offset(), QPointF(-32.4, 43.0));
+
+ item.setOffset(QPointF(1, 1));
+ QCOMPARE(item.offset(), QPointF(1, 1));
+
+ item.setOffset(QPointF(12, -30.4));
+ QCOMPARE(item.offset(), QPointF(12, -30.4));
+
+ item.setOffset(QPointF(-90.4, -75));
+ QCOMPARE(item.offset(), QPointF(-90.4, -75));
+}
+
+void tst_QGraphicsVideoItem::size()
+{
+ QGraphicsVideoItem item;
+
+ QCOMPARE(item.size(), QSizeF(320, 240));
+
+ item.setSize(QSizeF(542.5, 436.3));
+ QCOMPARE(item.size(), QSizeF(542.5, 436.3));
+
+ item.setSize(QSizeF(-43, 12));
+ QCOMPARE(item.size(), QSizeF(0, 0));
+
+ item.setSize(QSizeF(54, -9));
+ QCOMPARE(item.size(), QSizeF(0, 0));
+
+ item.setSize(QSizeF(-90, -65));
+ QCOMPARE(item.size(), QSizeF(0, 0));
+
+ item.setSize(QSizeF(1000, 1000));
+ QCOMPARE(item.size(), QSizeF(1000, 1000));
+}
+
+void tst_QGraphicsVideoItem::nativeSize_data()
+{
+ QTest::addColumn<QSize>("frameSize");
+ QTest::addColumn<QRect>("viewport");
+ QTest::addColumn<QSizeF>("nativeSize");
+
+ QTest::newRow("640x480")
+ << QSize(640, 480)
+ << QRect(0, 0, 640, 480)
+ << QSizeF(640, 480);
+
+ QTest::newRow("800x600, (80,60, 640x480) viewport")
+ << QSize(800, 600)
+ << QRect(80, 60, 640, 480)
+ << QSizeF(640, 480);
+}
+
+void tst_QGraphicsVideoItem::nativeSize()
+{
+ QFETCH(QSize, frameSize);
+ QFETCH(QRect, viewport);
+ QFETCH(QSizeF, nativeSize);
+
+ QtTestGraphicsVideoItem item;
+ QMediaPlayer player;
+ player.setVideoOutput(&item);
+
+ QCOMPARE(item.nativeSize(), QSizeF());
+
+ QSignalSpy spy(&item, &QGraphicsVideoItem::nativeSizeChanged);
+
+ QVideoFrameFormat format(frameSize, QVideoFrameFormat::Format_ARGB8888);
+ format.setViewport(viewport);
+ QVideoFrame frame(format);
+ item.videoSink()->setVideoFrame(frame);
+
+ QCoreApplication::processEvents();
+ QCOMPARE(item.nativeSize(), nativeSize);
+ QCOMPARE(spy.size(), 1);
+ QCOMPARE(spy.last().first().toSizeF(), nativeSize);
+}
+
+void tst_QGraphicsVideoItem::boundingRect_data()
+{
+ QTest::addColumn<QSize>("frameSize");
+ QTest::addColumn<QPointF>("offset");
+ QTest::addColumn<QSizeF>("size");
+ QTest::addColumn<Qt::AspectRatioMode>("aspectRatioMode");
+ QTest::addColumn<QRectF>("expectedRect");
+
+
+ QTest::newRow("640x480: (0,0 640x480), Keep")
+ << QSize(640, 480)
+ << QPointF(0, 0)
+ << QSizeF(640, 480)
+ << Qt::KeepAspectRatio
+ << QRectF(0, 0, 640, 480);
+
+ QTest::newRow("800x600, (0,0, 640x480), Keep")
+ << QSize(800, 600)
+ << QPointF(0, 0)
+ << QSizeF(640, 480)
+ << Qt::KeepAspectRatio
+ << QRectF(0, 0, 640, 480);
+
+ QTest::newRow("800x600, (0,0, 640x480), KeepByExpanding")
+ << QSize(800, 600)
+ << QPointF(0, 0)
+ << QSizeF(640, 480)
+ << Qt::KeepAspectRatioByExpanding
+ << QRectF(0, 0, 640, 480);
+
+ QTest::newRow("800x600, (0,0, 640x480), Ignore")
+ << QSize(800, 600)
+ << QPointF(0, 0)
+ << QSizeF(640, 480)
+ << Qt::IgnoreAspectRatio
+ << QRectF(0, 0, 640, 480);
+
+ QTest::newRow("800x600, (100,100, 640x480), Keep")
+ << QSize(800, 600)
+ << QPointF(100, 100)
+ << QSizeF(640, 480)
+ << Qt::KeepAspectRatio
+ << QRectF(100, 100, 640, 480);
+
+ QTest::newRow("800x600, (100,-100, 640x480), KeepByExpanding")
+ << QSize(800, 600)
+ << QPointF(100, -100)
+ << QSizeF(640, 480)
+ << Qt::KeepAspectRatioByExpanding
+ << QRectF(100, -100, 640, 480);
+
+ QTest::newRow("800x600, (-100,-100, 640x480), Ignore")
+ << QSize(800, 600)
+ << QPointF(-100, -100)
+ << QSizeF(640, 480)
+ << Qt::IgnoreAspectRatio
+ << QRectF(-100, -100, 640, 480);
+
+ QTest::newRow("800x600, (0,0, 1920x1024), Keep")
+ << QSize(800, 600)
+ << QPointF(0, 0)
+ << QSizeF(1920, 1024)
+ << Qt::KeepAspectRatio
+ << QRectF(832.0 / 3, 0, 4096.0 / 3, 1024);
+
+ QTest::newRow("800x600, (0,0, 1920x1024), KeepByExpanding")
+ << QSize(800, 600)
+ << QPointF(0, 0)
+ << QSizeF(1920, 1024)
+ << Qt::KeepAspectRatioByExpanding
+ << QRectF(0, 0, 1920, 1024);
+
+ QTest::newRow("800x600, (0,0, 1920x1024), Ignore")
+ << QSize(800, 600)
+ << QPointF(0, 0)
+ << QSizeF(1920, 1024)
+ << Qt::IgnoreAspectRatio
+ << QRectF(0, 0, 1920, 1024);
+
+ QTest::newRow("800x600, (100,100, 1920x1024), Keep")
+ << QSize(800, 600)
+ << QPointF(100, 100)
+ << QSizeF(1920, 1024)
+ << Qt::KeepAspectRatio
+ << QRectF(100 + 832.0 / 3, 100, 4096.0 / 3, 1024);
+
+ QTest::newRow("800x600, (100,-100, 1920x1024), KeepByExpanding")
+ << QSize(800, 600)
+ << QPointF(100, -100)
+ << QSizeF(1920, 1024)
+ << Qt::KeepAspectRatioByExpanding
+ << QRectF(100, -100, 1920, 1024);
+
+ QTest::newRow("800x600, (-100,-100, 1920x1024), Ignore")
+ << QSize(800, 600)
+ << QPointF(-100, -100)
+ << QSizeF(1920, 1024)
+ << Qt::IgnoreAspectRatio
+ << QRectF(-100, -100, 1920, 1024);
+}
+
+void tst_QGraphicsVideoItem::boundingRect()
+{
+ QFETCH(QSize, frameSize);
+ QFETCH(QPointF, offset);
+ QFETCH(QSizeF, size);
+ QFETCH(Qt::AspectRatioMode, aspectRatioMode);
+ QFETCH(QRectF, expectedRect);
+
+ QtTestGraphicsVideoItem item;
+ QMediaPlayer player;
+ player.setVideoOutput(&item);
+
+ item.setOffset(offset);
+ item.setSize(size);
+ item.setAspectRatioMode(aspectRatioMode);
+
+ QVideoFrameFormat format(frameSize, QVideoFrameFormat::Format_ARGB8888);
+ QVideoFrame frame(format);
+ item.videoSink()->setVideoFrame(frame);
+
+ QCoreApplication::processEvents();
+ QCOMPARE(item.boundingRect(), expectedRect);
+}
+
+static const uchar rgb32ImageData[] =
+{
+ 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00,
+ 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00
+};
+
+void tst_QGraphicsVideoItem::paint()
+{
+ auto *item = new QtTestGraphicsVideoItem;
+ QMediaPlayer player;
+ player.setVideoOutput(item);
+
+ QGraphicsScene graphicsScene;
+ graphicsScene.addItem(item);
+ QGraphicsView graphicsView(&graphicsScene);
+ graphicsView.show();
+ QVERIFY(item->paintCount() || item->waitForPaint(1));
+
+ auto *sink = item->videoSink();
+ Q_ASSERT(sink);
+
+ QVideoFrameFormat format(QSize(2, 2), QVideoFrameFormat::Format_XRGB8888);
+ QVideoFrame frame(format);
+ frame.map(QtVideo::MapMode::WriteOnly);
+ memcpy(frame.bits(0), rgb32ImageData, frame.mappedBytes(0));
+ frame.unmap();
+
+ sink->setVideoFrame(frame);
+
+ QVERIFY(item->waitForPaint(1));
+}
+
+QTEST_MAIN(tst_QGraphicsVideoItem)
+
+#include "tst_qgraphicsvideoitem.moc"
diff --git a/tests/auto/unit/multimediawidgets/qmediaplayerwidgets/CMakeLists.txt b/tests/auto/unit/multimediawidgets/qmediaplayerwidgets/CMakeLists.txt
new file mode 100644
index 000000000..7c54e67b9
--- /dev/null
+++ b/tests/auto/unit/multimediawidgets/qmediaplayerwidgets/CMakeLists.txt
@@ -0,0 +1,23 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+# Generated from qmediaplayerwidgets.pro.
+
+#####################################################################
+## tst_qmediaplayerwidgets Test:
+#####################################################################
+
+qt_internal_add_test(tst_qmediaplayerwidgets
+ SOURCES
+ tst_qmediaplayerwidgets.cpp
+ INCLUDE_DIRECTORIES
+ ../../mockbackend
+ LIBRARIES
+ # Remove: L${CMAKE_CURRENT_SOURCE_DIR}
+ Qt::Gui
+ Qt::MultimediaPrivate
+ Qt::MultimediaWidgetsPrivate
+ Qt::Network
+ Qt::Widgets
+ MockMultimediaPlugin
+)
diff --git a/tests/auto/unit/multimediawidgets/qmediaplayerwidgets/tst_qmediaplayerwidgets.cpp b/tests/auto/unit/multimediawidgets/qmediaplayerwidgets/tst_qmediaplayerwidgets.cpp
new file mode 100644
index 000000000..e0f23d477
--- /dev/null
+++ b/tests/auto/unit/multimediawidgets/qmediaplayerwidgets/tst_qmediaplayerwidgets.cpp
@@ -0,0 +1,107 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QtTest/QtTest>
+#include <QtCore/qdebug.h>
+#include <QtCore/qbuffer.h>
+
+#include <qgraphicsvideoitem.h>
+#include <qvideosink.h>
+#include <qmediaplayer.h>
+#include <private/qplatformmediaplayer_p.h>
+
+#include "qvideosink.h"
+#include "qmockintegration.h"
+
+QT_USE_NAMESPACE
+
+Q_ENABLE_MOCK_MULTIMEDIA_PLUGIN
+
+class tst_QMediaPlayerWidgets: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void testSetVideoOutput();
+ void testSetVideoOutputNoService();
+ void testSetVideoOutputNoControl();
+};
+
+void tst_QMediaPlayerWidgets::testSetVideoOutput()
+{
+ QVideoWidget widget;
+ QGraphicsVideoItem item;
+ QVideoSink surface;
+
+ QMediaPlayer player;
+
+ player.setVideoOutput(&widget);
+// QVERIFY(widget.mediaSource() == &player);
+
+ player.setVideoOutput(&item);
+// QVERIFY(widget.mediaSource() == nullptr);
+// QVERIFY(item.mediaSource() == &player);
+
+ player.setVideoOutput(reinterpret_cast<QVideoWidget *>(0));
+// QVERIFY(item.mediaSource() == nullptr);
+
+ player.setVideoOutput(&widget);
+// QVERIFY(widget.mediaSource() == &player);
+
+ player.setVideoOutput(reinterpret_cast<QGraphicsVideoItem *>(0));
+// QVERIFY(widget.mediaSource() == nullptr);
+
+ player.setVideoOutput(&surface);
+// QVERIFY(mockService->rendererControl->surface() == &surface);
+
+ player.setVideoOutput(reinterpret_cast<QVideoSink *>(0));
+// QVERIFY(mockService->rendererControl->surface() == nullptr);
+
+ player.setVideoOutput(&surface);
+// QVERIFY(mockService->rendererControl->surface() == &surface);
+
+ player.setVideoOutput(&widget);
+// QVERIFY(mockService->rendererControl->surface() == nullptr);
+// QVERIFY(widget.mediaSource() == &player);
+
+ player.setVideoOutput(&surface);
+// QVERIFY(mockService->rendererControl->surface() == &surface);
+// QVERIFY(widget.mediaSource() == nullptr);
+}
+
+
+void tst_QMediaPlayerWidgets::testSetVideoOutputNoService()
+{
+ QVideoWidget widget;
+ QGraphicsVideoItem item;
+ QVideoSink surface;
+
+ QMockIntegration::instance()->setFlags(QMockIntegration::NoPlayerInterface);
+ QMediaPlayer player;
+ QMockIntegration::instance()->setFlags({});
+
+ player.setVideoOutput(&widget);
+
+ player.setVideoOutput(&item);
+
+ player.setVideoOutput(&surface);
+ // Nothing we can verify here other than it doesn't assert.
+}
+
+void tst_QMediaPlayerWidgets::testSetVideoOutputNoControl()
+{
+ QVideoWidget widget;
+ QGraphicsVideoItem item;
+ QVideoSink surface;
+
+ QMediaPlayer player;
+
+ player.setVideoOutput(&widget);
+
+ player.setVideoOutput(&item);
+
+ player.setVideoOutput(&surface);
+}
+
+QTEST_MAIN(tst_QMediaPlayerWidgets)
+#include "tst_qmediaplayerwidgets.moc"
diff --git a/tests/auto/unit/multimediawidgets/qvideowidget/BLACKLIST b/tests/auto/unit/multimediawidgets/qvideowidget/BLACKLIST
new file mode 100644
index 000000000..2ce9e48fa
--- /dev/null
+++ b/tests/auto/unit/multimediawidgets/qvideowidget/BLACKLIST
@@ -0,0 +1,3 @@
+# QTBUG-110453
+[fullScreen]
+android
diff --git a/tests/auto/unit/multimediawidgets/qvideowidget/CMakeLists.txt b/tests/auto/unit/multimediawidgets/qvideowidget/CMakeLists.txt
new file mode 100644
index 000000000..b179b0b3b
--- /dev/null
+++ b/tests/auto/unit/multimediawidgets/qvideowidget/CMakeLists.txt
@@ -0,0 +1,21 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+# Generated from qvideowidget.pro.
+
+#####################################################################
+## tst_qvideowidget Test:
+#####################################################################
+
+qt_internal_add_test(tst_qvideowidget
+ SOURCES
+ tst_qvideowidget.cpp
+ INCLUDE_DIRECTORIES
+ ../../mockbackend
+ LIBRARIES
+ Qt::Gui
+ Qt::MultimediaPrivate
+ Qt::MultimediaWidgetsPrivate
+ Qt::Widgets
+ MockMultimediaPlugin
+)
diff --git a/tests/auto/unit/multimediawidgets/qvideowidget/tst_qvideowidget.cpp b/tests/auto/unit/multimediawidgets/qvideowidget/tst_qvideowidget.cpp
new file mode 100644
index 000000000..b999020a4
--- /dev/null
+++ b/tests/auto/unit/multimediawidgets/qvideowidget/tst_qvideowidget.cpp
@@ -0,0 +1,269 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <qtmultimediaglobal.h>
+#include <QtTest/QtTest>
+
+#include "qvideowidget.h"
+#include "qvideosink.h"
+#include "qmediaplayer.h"
+
+#include <qvideoframeformat.h>
+#include <qvideoframe.h>
+
+#include <QtWidgets/qapplication.h>
+
+#include <qmockintegration.h>
+#include <qmockvideosink.h>
+
+QT_USE_NAMESPACE
+
+Q_ENABLE_MOCK_MULTIMEDIA_PLUGIN
+
+class tst_QVideoWidget : public QObject
+{
+ Q_OBJECT
+public slots:
+ void initTestCase();
+
+private slots:
+ void nullObject();
+
+ void show();
+ void fullScreen();
+ void aspectRatio();
+ void sizeHint_data();
+ void sizeHint();
+#if 0
+ void brightness_data() { color_data(); }
+ void brightness();
+ void contrast_data() { color_data(); }
+ void contrast();
+ void hue_data() { color_data(); }
+ void hue();
+ void saturation_data() { color_data(); }
+ void saturation();
+#endif
+
+ void paint();
+
+private:
+// void color_data();
+};
+
+class QtTestVideoWidget : public QVideoWidget
+{
+public:
+ QtTestVideoWidget(QWidget *parent = nullptr)
+ : QVideoWidget(parent)
+ {
+ resize(320, 240);
+ }
+};
+
+void tst_QVideoWidget::initTestCase()
+{
+#ifdef Q_OS_MACOS
+ if (qEnvironmentVariable("QTEST_ENVIRONMENT").toLower() == "ci")
+ QSKIP("SKIP on macOS CI since metal is not supported, otherwise it often crashes. To be "
+ "fixed.");
+#endif
+}
+
+void tst_QVideoWidget::nullObject()
+{
+ QtTestVideoWidget widget;
+
+ widget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+
+ widget.setFullScreen(true);
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+ QCOMPARE(widget.isFullScreen(), true);
+
+ widget.setAspectRatioMode(Qt::IgnoreAspectRatio);
+ QCOMPARE(widget.aspectRatioMode(), Qt::IgnoreAspectRatio);
+}
+
+
+
+void tst_QVideoWidget::show()
+{
+ QtTestVideoWidget widget;
+
+ widget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+
+ widget.resize(640, 480);
+ QCOMPARE(widget.size(), QSize(640, 480));
+
+ widget.move(10, 10);
+ QCOMPARE(widget.size(), QSize(640, 480));
+
+ widget.hide();
+}
+
+void tst_QVideoWidget::aspectRatio()
+{
+ QtTestVideoWidget widget;
+ QMediaPlayer player;
+ player.setVideoOutput(&widget);
+
+ // Test the aspect ratio defaults to keeping the aspect ratio.
+ QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio);
+
+ // Test the control has been informed of the aspect ratio change, post show.
+ widget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+ QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio);
+
+ // Test an aspect ratio change is enforced immediately while visible.
+ widget.setAspectRatioMode(Qt::IgnoreAspectRatio);
+ QCOMPARE(widget.aspectRatioMode(), Qt::IgnoreAspectRatio);
+
+ // Test an aspect ratio set while not visible is respected.
+ widget.hide();
+ widget.setAspectRatioMode(Qt::KeepAspectRatio);
+ QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio);
+ widget.show();
+ QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio);
+}
+
+void tst_QVideoWidget::sizeHint_data()
+{
+#ifdef Q_OS_MAC
+ QSKIP("QTBUG-26481 - Crashes on Mac");
+#endif
+
+ QTest::addColumn<QSize>("frameSize");
+ QTest::addColumn<QRect>("viewport");
+ QTest::addColumn<QSize>("expectedSize");
+
+ QTest::newRow("640x480")
+ << QSize(640, 480)
+ << QRect(0, 0, 640, 480)
+ << QSize(640, 480);
+
+// QTest::newRow("800x600, (80,60, 640x480) viewport")
+// << QSize(800, 600)
+// << QRect(80, 60, 640, 480)
+// << QSize(640, 480);
+}
+
+void tst_QVideoWidget::sizeHint()
+{
+#ifdef Q_OS_MAC
+ QSKIP("QTBUG-26481 - Crashes on Mac");
+#endif
+
+ QFETCH(QSize, frameSize);
+// QFETCH(QRect, viewport);
+ QFETCH(QSize, expectedSize);
+
+ QtTestVideoWidget widget;
+ QMediaPlayer player;
+
+ player.setVideoOutput(&widget);
+ auto mockSink = QMockIntegration::instance()->lastVideoSink();
+
+ widget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+ mockSink->setNativeSize(frameSize);
+
+ QCOMPARE(widget.sizeHint(), expectedSize);
+}
+
+
+void tst_QVideoWidget::fullScreen()
+{
+ QtTestVideoWidget widget;
+ QMediaPlayer player;
+ player.setVideoOutput(&widget);
+ widget.showNormal();
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+
+ Qt::WindowFlags windowFlags = widget.windowFlags();
+
+ QSignalSpy spy(&widget, &QVideoWidget::fullScreenChanged);
+
+ // Test showing full screen with setFullScreen(true).
+ widget.setFullScreen(true);
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+ QCOMPARE(widget.isFullScreen(), true);
+ QCOMPARE(spy.size(), 1);
+ QCOMPARE(spy.value(0).value(0).toBool(), true);
+
+ // Test returning to normal with setFullScreen(false).
+ widget.setFullScreen(false);
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+ QCOMPARE(widget.isFullScreen(), false);
+ QCOMPARE(spy.size(), 2);
+ QCOMPARE(spy.value(1).value(0).toBool(), false);
+ QCOMPARE(widget.windowFlags(), windowFlags);
+
+ // Test showing full screen with showFullScreen().
+ widget.showFullScreen();
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+ QCOMPARE(widget.isFullScreen(), true);
+ QCOMPARE(spy.size(), 3);
+ QCOMPARE(spy.value(2).value(0).toBool(), true);
+
+ // Test returning to normal with showNormal().
+ widget.showNormal();
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+ QCOMPARE(widget.isFullScreen(), false);
+ QCOMPARE(spy.size(), 4);
+ QCOMPARE(spy.value(3).value(0).toBool(), false);
+ QCOMPARE(widget.windowFlags(), windowFlags);
+
+ // Test setFullScreen(false) and showNormal() do nothing when isFullScreen() == false.
+ widget.setFullScreen(false);
+ QCOMPARE(widget.isFullScreen(), false);
+ QCOMPARE(spy.size(), 4);
+ widget.showNormal();
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+ QCOMPARE(widget.isFullScreen(), false);
+ QCOMPARE(spy.size(), 4);
+
+ // Test setFullScreen(true) and showFullScreen() do nothing when isFullScreen() == true.
+ widget.showFullScreen();
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+ widget.setFullScreen(true);
+ QCOMPARE(widget.isFullScreen(), true);
+ QCOMPARE(spy.size(), 5);
+ widget.showFullScreen();
+ QCOMPARE(widget.isFullScreen(), true);
+ QCOMPARE(spy.size(), 5);
+}
+
+static const uchar rgb32ImageData[] =
+{
+ 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00,
+ 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00
+};
+
+void tst_QVideoWidget::paint()
+{
+ QtTestVideoWidget widget;
+ QMediaPlayer player;
+ player.setVideoOutput(&widget);
+ widget.resize(640,480);
+ widget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+
+ QVideoFrameFormat format(QSize(2, 2), QVideoFrameFormat::Format_XRGB8888);
+ QVideoFrame frame(format);
+ QVERIFY(frame.map(QtVideo::MapMode::ReadWrite));
+ uchar *data = frame.bits(0);
+ memcpy(data, rgb32ImageData, sizeof(rgb32ImageData));
+ frame.unmap();
+
+ auto *sink = widget.videoSink();
+ emit sink->setVideoFrame(frame);
+
+ QCoreApplication::processEvents(QEventLoop::AllEvents);
+}
+
+QTEST_MAIN(tst_QVideoWidget)
+
+#include "tst_qvideowidget.moc"
diff --git a/tests/auto/unit/qabstractvideobuffer/qabstractvideobuffer.pro b/tests/auto/unit/qabstractvideobuffer/qabstractvideobuffer.pro
deleted file mode 100644
index f97ea41c3..000000000
--- a/tests/auto/unit/qabstractvideobuffer/qabstractvideobuffer.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qabstractvideobuffer
-
-QT += core multimedia-private testlib
-
-SOURCES += tst_qabstractvideobuffer.cpp
-
diff --git a/tests/auto/unit/qabstractvideobuffer/tst_qabstractvideobuffer.cpp b/tests/auto/unit/qabstractvideobuffer/tst_qabstractvideobuffer.cpp
deleted file mode 100644
index 98dfd97b2..000000000
--- a/tests/auto/unit/qabstractvideobuffer/tst_qabstractvideobuffer.cpp
+++ /dev/null
@@ -1,165 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//TESTED_COMPONENT=src/multimedia
-
-#include <QtTest/QtTest>
-
-#include <qabstractvideobuffer.h>
-
-// Adds an enum, and the stringized version
-#define ADD_ENUM_TEST(x) \
- QTest::newRow(#x) \
- << QAbstractVideoBuffer::x \
- << QString(QLatin1String(#x));
-
-class tst_QAbstractVideoBuffer : public QObject
-{
- Q_OBJECT
-public:
- tst_QAbstractVideoBuffer();
- ~tst_QAbstractVideoBuffer();
-
-public slots:
- void initTestCase();
- void cleanupTestCase();
- void init();
- void cleanup();
-
-private slots:
- void handleType_data();
- void handleType();
- void handle();
- void mapMode();
- void mapModeDebug_data();
- void mapModeDebug();
-};
-
-class QtTestVideoBuffer : public QAbstractVideoBuffer
-{
-public:
- QtTestVideoBuffer(QAbstractVideoBuffer::HandleType type) : QAbstractVideoBuffer(type) {}
-
- MapMode mapMode() const { return QAbstractVideoBuffer::ReadWrite; }
-
- uchar *map(MapMode, int *, int *) { return 0; }
- void unmap() {}
-};
-
-tst_QAbstractVideoBuffer::tst_QAbstractVideoBuffer()
-{
-}
-
-tst_QAbstractVideoBuffer::~tst_QAbstractVideoBuffer()
-{
-}
-
-void tst_QAbstractVideoBuffer::initTestCase()
-{
-}
-
-void tst_QAbstractVideoBuffer::cleanupTestCase()
-{
-}
-
-void tst_QAbstractVideoBuffer::init()
-{
-}
-
-void tst_QAbstractVideoBuffer::cleanup()
-{
-}
-
-void tst_QAbstractVideoBuffer::handleType_data()
-{
- QTest::addColumn<QAbstractVideoBuffer::HandleType>("type");
- QTest::addColumn<QString>("stringized");
-
- ADD_ENUM_TEST(NoHandle);
- ADD_ENUM_TEST(GLTextureHandle);
- ADD_ENUM_TEST(XvShmImageHandle);
- ADD_ENUM_TEST(QPixmapHandle);
- ADD_ENUM_TEST(CoreImageHandle);
-
- // User handles are different
-
- QTest::newRow("user1")
- << QAbstractVideoBuffer::UserHandle << QString::fromLatin1("UserHandle(1000)");
- QTest::newRow("user2")
- << QAbstractVideoBuffer::HandleType(QAbstractVideoBuffer::UserHandle + 1) << QString::fromLatin1("UserHandle(1001)");
-}
-
-void tst_QAbstractVideoBuffer::handleType()
-{
- QFETCH(QAbstractVideoBuffer::HandleType, type);
- QFETCH(QString, stringized);
-
- QtTestVideoBuffer buffer(type);
-
- QCOMPARE(buffer.handleType(), type);
-
- QTest::ignoreMessage(QtDebugMsg, stringized.toLatin1().constData());
- qDebug() << type;
-}
-
-void tst_QAbstractVideoBuffer::handle()
-{
- QtTestVideoBuffer buffer(QAbstractVideoBuffer::NoHandle);
-
- QVERIFY(buffer.handle().isNull());
-}
-
-void tst_QAbstractVideoBuffer::mapMode()
-{
- QtTestVideoBuffer maptest(QAbstractVideoBuffer::NoHandle);
- QVERIFY2(maptest.mapMode() == QAbstractVideoBuffer::ReadWrite, "ReadWrite Failed");
-}
-
-void tst_QAbstractVideoBuffer::mapModeDebug_data()
-{
- QTest::addColumn<QAbstractVideoBuffer::MapMode>("mapMode");
- QTest::addColumn<QString>("stringized");
-
- ADD_ENUM_TEST(NotMapped);
- ADD_ENUM_TEST(ReadOnly);
- ADD_ENUM_TEST(WriteOnly);
- ADD_ENUM_TEST(ReadWrite);
-}
-
-void tst_QAbstractVideoBuffer::mapModeDebug()
-{
- QFETCH(QAbstractVideoBuffer::MapMode, mapMode);
- QFETCH(QString, stringized);
-
- QTest::ignoreMessage(QtDebugMsg, stringized.toLatin1().constData());
- qDebug() << mapMode;
-}
-
-QTEST_MAIN(tst_QAbstractVideoBuffer)
-
-#include "tst_qabstractvideobuffer.moc"
diff --git a/tests/auto/unit/qabstractvideosurface/qabstractvideosurface.pro b/tests/auto/unit/qabstractvideosurface/qabstractvideosurface.pro
deleted file mode 100644
index 1f2e47d59..000000000
--- a/tests/auto/unit/qabstractvideosurface/qabstractvideosurface.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qabstractvideosurface
-
-QT += core multimedia-private testlib
-
-SOURCES += tst_qabstractvideosurface.cpp
-
diff --git a/tests/auto/unit/qabstractvideosurface/tst_qabstractvideosurface.cpp b/tests/auto/unit/qabstractvideosurface/tst_qabstractvideosurface.cpp
deleted file mode 100644
index b18dba5f7..000000000
--- a/tests/auto/unit/qabstractvideosurface/tst_qabstractvideosurface.cpp
+++ /dev/null
@@ -1,396 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//TESTED_COMPONENT=src/multimedia
-
-#include <QtTest/QtTest>
-
-#include <qabstractvideosurface.h>
-#include <qvideosurfaceformat.h>
-
-class tst_QAbstractVideoSurface : public QObject
-{
- Q_OBJECT
-public:
- tst_QAbstractVideoSurface();
- ~tst_QAbstractVideoSurface();
-
-public slots:
- void initTestCase();
- void cleanupTestCase();
- void init();
- void cleanup();
-
-private slots:
- void setError();
- void isFormatSupported_data();
- void isFormatSupported();
- void nearestFormat_data();
- void nearestFormat();
- void start_data();
- void start();
- void nativeResolution();
- void supportedFormatsChanged();
-};
-
-using SupportedFormatMap = QMultiMap<QAbstractVideoBuffer::HandleType, QVideoFrame::PixelFormat>;
-
-Q_DECLARE_METATYPE(SupportedFormatMap)
-
-class QtTestVideoSurface : public QAbstractVideoSurface
-{
- Q_OBJECT
-public:
- explicit QtTestVideoSurface(QObject *parent = 0) : QAbstractVideoSurface(parent) {}
- explicit QtTestVideoSurface(SupportedFormatMap formats, QObject *parent = 0)
- : QAbstractVideoSurface(parent), supportedFormats(formats) {}
-
- QList<QVideoFrame::PixelFormat> supportedPixelFormats(
- QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const
- {
- return supportedFormats.values(handleType);
- }
-
- bool present(const QVideoFrame &) { return false; }
-
- using QAbstractVideoSurface::setError;
-
- /* adding protected setNativeResolution*/
- using QAbstractVideoSurface::setNativeResolution;
-
- /* fun to generate supportedFormatsChanged signal */
- QList<QVideoFrame::PixelFormat> supportedPixelFormatsChange(QList<QVideoFrame::PixelFormat> formats)
- {
- supportedFormats.insert(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_RGB32);
- QList<QVideoFrame::PixelFormat> supportedFormats = supportedPixelFormats();
- if (supportedFormats.count() != formats.count()) {
- emit supportedFormatsChanged();
- }
- return supportedFormats;
- }
-
-private:
- SupportedFormatMap supportedFormats;
-};
-
-tst_QAbstractVideoSurface::tst_QAbstractVideoSurface()
-{
-}
-
-tst_QAbstractVideoSurface::~tst_QAbstractVideoSurface()
-{
-}
-
-void tst_QAbstractVideoSurface::initTestCase()
-{
-}
-
-void tst_QAbstractVideoSurface::cleanupTestCase()
-{
-}
-
-void tst_QAbstractVideoSurface::init()
-{
-}
-
-void tst_QAbstractVideoSurface::cleanup()
-{
-}
-
-void tst_QAbstractVideoSurface::setError()
-{
- qRegisterMetaType<QAbstractVideoSurface::Error>();
-
- QtTestVideoSurface surface;
-
- QCOMPARE(surface.error(), QAbstractVideoSurface::NoError);
- QTest::ignoreMessage(QtDebugMsg, "NoError");
- qDebug() << QAbstractVideoSurface::NoError;
-
- surface.setError(QAbstractVideoSurface::StoppedError);
- QCOMPARE(surface.error(), QAbstractVideoSurface::StoppedError);
- QTest::ignoreMessage(QtDebugMsg, "StoppedError");
- qDebug() << QAbstractVideoSurface::StoppedError;
-
- surface.setError(QAbstractVideoSurface::ResourceError);
- QCOMPARE(surface.error(), QAbstractVideoSurface::ResourceError);
- QTest::ignoreMessage(QtDebugMsg, "ResourceError");
- qDebug() << QAbstractVideoSurface::ResourceError;
-
- surface.setError(QAbstractVideoSurface::NoError);
- QCOMPARE(surface.error(), QAbstractVideoSurface::NoError);
- QTest::ignoreMessage(QtDebugMsg, "NoError");
- qDebug() << QAbstractVideoSurface::NoError;
-
- surface.setError(QAbstractVideoSurface::UnsupportedFormatError);
- QCOMPARE(surface.error(), QAbstractVideoSurface::UnsupportedFormatError);
- QTest::ignoreMessage(QtDebugMsg, "UnsupportedFormatError");
- qDebug() << QAbstractVideoSurface::UnsupportedFormatError;
-
- surface.setError(QAbstractVideoSurface::IncorrectFormatError);
- QCOMPARE(surface.error(), QAbstractVideoSurface::IncorrectFormatError);
- QTest::ignoreMessage(QtDebugMsg, "IncorrectFormatError");
- qDebug() << QAbstractVideoSurface::IncorrectFormatError;
-}
-
-void tst_QAbstractVideoSurface::isFormatSupported_data()
-{
- QTest::addColumn<SupportedFormatMap>("supportedFormats");
- QTest::addColumn<QVideoSurfaceFormat>("format");
- QTest::addColumn<bool>("supported");
-
- SupportedFormatMap formats;
-
- QTest::newRow("no formats: rgb32")
- << formats
- << QVideoSurfaceFormat(QSize(800, 600), QVideoFrame::Format_RGB32)
- << false;
- QTest::newRow("no formats: yv12")
- << formats
- << QVideoSurfaceFormat(QSize(800, 600), QVideoFrame::Format_YV12)
- << false;
- QTest::newRow("no formats: rgb32 gl")
- << formats
- << QVideoSurfaceFormat(
- QSize(800, 600),
- QVideoFrame::Format_RGB32,
- QAbstractVideoBuffer::GLTextureHandle)
- << false;
- QTest::newRow("no formats: rgb24 gl")
- << formats
- << QVideoSurfaceFormat(
- QSize(800, 600),
- QVideoFrame::Format_RGB24,
- QAbstractVideoBuffer::GLTextureHandle)
- << false;
-
- formats.insert(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_RGB32);
- formats.insert(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_RGB24);
- formats.insert(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_YUV444);
- formats.insert(QAbstractVideoBuffer::GLTextureHandle, QVideoFrame::Format_RGB32);
-
- QTest::newRow("supported: rgb32")
- << formats
- << QVideoSurfaceFormat(QSize(800, 600), QVideoFrame::Format_RGB32)
- << true;
- QTest::newRow("supported: rgb24")
- << formats
- << QVideoSurfaceFormat(QSize(800, 600), QVideoFrame::Format_RGB24)
- << true;
- QTest::newRow("unsupported: yv12")
- << formats
- << QVideoSurfaceFormat(QSize(800, 600), QVideoFrame::Format_YV12)
- << false;
- QTest::newRow("supported: rgb32 gl")
- << formats
- << QVideoSurfaceFormat(
- QSize(800, 600),
- QVideoFrame::Format_RGB32,
- QAbstractVideoBuffer::GLTextureHandle)
- << true;
- QTest::newRow("unsupported: rgb24 gl")
- << formats
- << QVideoSurfaceFormat(
- QSize(800, 600),
- QVideoFrame::Format_RGB24,
- QAbstractVideoBuffer::GLTextureHandle)
- << false;
- QTest::newRow("unsupported: yv12 gl")
- << formats
- << QVideoSurfaceFormat(
- QSize(800, 600),
- QVideoFrame::Format_YV12,
- QAbstractVideoBuffer::GLTextureHandle)
- << false;
-
- formats.insert(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_YV12);
- formats.insert(QAbstractVideoBuffer::GLTextureHandle, QVideoFrame::Format_RGB24);
-
- QTest::newRow("supported: yv12")
- << formats
- << QVideoSurfaceFormat(QSize(800, 600), QVideoFrame::Format_YV12)
- << true;
- QTest::newRow("supported: rgb24 gl")
- << formats
- << QVideoSurfaceFormat(
- QSize(800, 600),
- QVideoFrame::Format_RGB24,
- QAbstractVideoBuffer::GLTextureHandle)
- << true;
-}
-
-void tst_QAbstractVideoSurface::isFormatSupported()
-{
- QFETCH(SupportedFormatMap, supportedFormats);
- QFETCH(QVideoSurfaceFormat, format);
- QFETCH(bool, supported);
-
- QtTestVideoSurface surface(supportedFormats);
-
- QCOMPARE(surface.isFormatSupported(format), supported);
-}
-
-void tst_QAbstractVideoSurface::nearestFormat_data()
-{
- isFormatSupported_data();
-}
-
-void tst_QAbstractVideoSurface::nearestFormat()
-{
- QFETCH(SupportedFormatMap, supportedFormats);
- QFETCH(QVideoSurfaceFormat, format);
- QFETCH(bool, supported);
-
- QtTestVideoSurface surface(supportedFormats);
-
- QCOMPARE(surface.nearestFormat(format) == format, supported);
-}
-
-void tst_QAbstractVideoSurface::start_data()
-{
- QTest::addColumn<QVideoSurfaceFormat>("format");
-
- QTest::newRow("rgb32") << QVideoSurfaceFormat(
- QSize(800, 600),
- QVideoFrame::Format_RGB32);
- QTest::newRow("yv12") << QVideoSurfaceFormat(
- QSize(800, 600),
- QVideoFrame::Format_YV12);
- QTest::newRow("rgb32 gl") << QVideoSurfaceFormat(
- QSize(800, 600),
- QVideoFrame::Format_RGB32,
- QAbstractVideoBuffer::GLTextureHandle);
-}
-
-void tst_QAbstractVideoSurface::start()
-{
- QFETCH(QVideoSurfaceFormat, format);
-
- QtTestVideoSurface surface;
- surface.setError(QAbstractVideoSurface::ResourceError);
-
- QSignalSpy formatSpy(&surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)));
- QSignalSpy activeSpy(&surface, SIGNAL(activeChanged(bool)));
-
- QVERIFY(!surface.isActive());
- QCOMPARE(surface.surfaceFormat(), QVideoSurfaceFormat());
-
- QVERIFY(surface.start(format));
-
- QVERIFY(surface.isActive());
- QCOMPARE(surface.surfaceFormat(), format);
-
- QCOMPARE(formatSpy.count(), 1);
- QCOMPARE(qvariant_cast<QVideoSurfaceFormat>(formatSpy.last().at(0)), format);
-
- QCOMPARE(activeSpy.count(), 1);
- QCOMPARE(activeSpy.last().at(0).toBool(), true);
-
- // Starting twice won't change active
- // XXX should this also not emit surfaceFormatChanged?
- QVERIFY(surface.start(format));
- QCOMPARE(activeSpy.count(), 1);
- QVERIFY(surface.isActive());
-
- // error() is reset on a successful start.
- QCOMPARE(surface.error(), QAbstractVideoSurface::NoError);
-
- surface.stop();
-
- QVERIFY(!surface.isActive());
- QCOMPARE(surface.surfaceFormat(), QVideoSurfaceFormat());
-
- QCOMPARE(formatSpy.count(), 3);
- QCOMPARE(qvariant_cast<QVideoSurfaceFormat>(formatSpy.last().at(0)), QVideoSurfaceFormat());
-
- QCOMPARE(activeSpy.count(), 2);
- QCOMPARE(activeSpy.last().at(0).toBool(), false);
-
- // Stopping a stopped surface shouldn't hurt
- surface.stop();
-
- QVERIFY(!surface.isActive());
- QCOMPARE(surface.surfaceFormat(), QVideoSurfaceFormat());
-
- QCOMPARE(formatSpy.count(), 3);
- QCOMPARE(qvariant_cast<QVideoSurfaceFormat>(formatSpy.last().at(0)), QVideoSurfaceFormat());
-
- QCOMPARE(activeSpy.count(), 2);
- QCOMPARE(activeSpy.last().at(0).toBool(), false);
-}
-
-// Test nativeResolution property
-void tst_QAbstractVideoSurface::nativeResolution()
-{
- QtTestVideoSurface surface;
- QSignalSpy spy(&surface, SIGNAL(nativeResolutionChanged(QSize)));
- QSize size1 = surface.nativeResolution();
- QVERIFY(size1.width() == -1);
- QVERIFY(size1.height() == -1);
- QVERIFY(spy.count() == 0);
-
- QSize res(100,150);
- surface.setNativeResolution(res);
- QVERIFY(spy.count() == 1);
-
- QSize size2 = qvariant_cast<QSize>(spy.at(0).at(0));
- QVERIFY(size2.width() == 100);
- QVERIFY(size2.height() == 150);
-
- // Setting again should not emit
- surface.setNativeResolution(res);
- QVERIFY(spy.count() == 1);
-
- size2 = qvariant_cast<QSize>(spy.at(0).at(0));
- QVERIFY(size2.width() == 100);
- QVERIFY(size2.height() == 150);
-
- spy.clear();
-}
-
-// QAbstractVideoSurface's supported Formats Changed Signal
-void tst_QAbstractVideoSurface::supportedFormatsChanged()
-{
- SupportedFormatMap formatMap;
- formatMap.insert(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_RGB24);
- QtTestVideoSurface surface(formatMap);
- QSignalSpy spy(&surface, SIGNAL(supportedFormatsChanged()));
- QList<QVideoFrame::PixelFormat> formats = surface.supportedPixelFormats();
- QVERIFY(formats.count() == 1);
- QVERIFY(spy.count() == 0);
-
- // user defined implementation for generation of supportedFormatsChanged signal
- QList<QVideoFrame::PixelFormat> newFormats = surface.supportedPixelFormatsChange(formats);
- QVERIFY(newFormats.count() == (formats.count() + 1));
- QVERIFY(spy.count() == 1);
- spy.clear();
-}
-
-QTEST_MAIN(tst_QAbstractVideoSurface)
-
-#include "tst_qabstractvideosurface.moc"
diff --git a/tests/auto/unit/qaudiobuffer/qaudiobuffer.pro b/tests/auto/unit/qaudiobuffer/qaudiobuffer.pro
deleted file mode 100644
index 8f8f54ac3..000000000
--- a/tests/auto/unit/qaudiobuffer/qaudiobuffer.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-QT += multimedia testlib
-QT -= gui
-
-TARGET = tst_qaudiobuffer
-CONFIG += testcase
-CONFIG -= app_bundle
-
-TEMPLATE = app
-
-SOURCES += tst_qaudiobuffer.cpp
diff --git a/tests/auto/unit/qaudiobuffer/tst_qaudiobuffer.cpp b/tests/auto/unit/qaudiobuffer/tst_qaudiobuffer.cpp
deleted file mode 100644
index 1b01ca501..000000000
--- a/tests/auto/unit/qaudiobuffer/tst_qaudiobuffer.cpp
+++ /dev/null
@@ -1,397 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore/QString>
-#include <QtTest/QtTest>
-
-#include <qaudiobuffer.h>
-
-class tst_QAudioBuffer : public QObject
-{
- Q_OBJECT
-
-public:
- tst_QAudioBuffer();
- ~tst_QAudioBuffer();
-
-private Q_SLOTS:
- void ctors();
- void assign();
- void constData() const;
- void data_const() const;
- void data();
- void durations();
- void durations_data();
- void stereoSample();
-
-private:
- QAudioFormat mFormat;
- QAudioBuffer *mNull;
- QAudioBuffer *mEmpty;
- QAudioBuffer *mFromArray;
-};
-
-tst_QAudioBuffer::tst_QAudioBuffer()
-{
- // Initialize some common buffers
- mFormat.setChannelCount(2);
- mFormat.setSampleSize(16);
- mFormat.setSampleType(QAudioFormat::UnSignedInt);
- mFormat.setSampleRate(10000);
- mFormat.setCodec("audio/pcm");
-
- QByteArray b(4000, char(0x80));
- mNull = new QAudioBuffer;
- mEmpty = new QAudioBuffer(500, mFormat); // 500 stereo frames of 16 bits -> 2KB
- mFromArray = new QAudioBuffer(b, mFormat);
-}
-
-
-tst_QAudioBuffer::~tst_QAudioBuffer()
-{
- delete mNull;
- delete mEmpty;
- delete mFromArray;
-}
-
-void tst_QAudioBuffer::ctors()
-{
- // Null buffer
- QVERIFY(!mNull->isValid());
- QVERIFY(mNull->constData() == 0);
- QVERIFY(mNull->data() == 0);
- QVERIFY(((const QAudioBuffer*)mNull)->data() == 0);
- QCOMPARE(mNull->duration(), 0LL);
- QCOMPARE(mNull->byteCount(), 0);
- QCOMPARE(mNull->sampleCount(), 0);
- QCOMPARE(mNull->frameCount(), 0);
- QCOMPARE(mNull->startTime(), -1LL);
-
- // Empty buffer
- QVERIFY(mEmpty->isValid());
- QVERIFY(mEmpty->constData() != 0);
- QVERIFY(mEmpty->data() != 0);
- QVERIFY(((const QAudioBuffer*)mEmpty)->data() != 0);
- QCOMPARE(mEmpty->sampleCount(), 1000);
- QCOMPARE(mEmpty->frameCount(), 500);
- QCOMPARE(mEmpty->duration(), 50000LL);
- QCOMPARE(mEmpty->byteCount(), 2000);
- QCOMPARE(mEmpty->startTime(), -1LL);
-
- // bytearray buffer
- QVERIFY(mFromArray->isValid());
- QVERIFY(mFromArray->constData() != 0);
- QVERIFY(mFromArray->data() != 0);
- QVERIFY(((const QAudioBuffer*)mFromArray)->data() != 0);
- /// 4000 bytes at 10KHz, 2ch, 16bit = 40kBps -> 0.1s
- QCOMPARE(mFromArray->duration(), 100000LL);
- QCOMPARE(mFromArray->byteCount(), 4000);
- QCOMPARE(mFromArray->sampleCount(), 2000);
- QCOMPARE(mFromArray->frameCount(), 1000);
- QCOMPARE(mFromArray->startTime(), -1LL);
-
-
- // Now some invalid buffers
- QAudioBuffer badFormat(1000, QAudioFormat());
- QVERIFY(!badFormat.isValid());
- QVERIFY(badFormat.constData() == 0);
- QVERIFY(badFormat.data() == 0);
- QVERIFY(((const QAudioBuffer*)&badFormat)->data() == 0);
- QCOMPARE(badFormat.duration(), 0LL);
- QCOMPARE(badFormat.byteCount(), 0);
- QCOMPARE(badFormat.sampleCount(), 0);
- QCOMPARE(badFormat.frameCount(), 0);
- QCOMPARE(badFormat.startTime(), -1LL);
-
- QAudioBuffer badArray(QByteArray(), mFormat);
- QVERIFY(!badArray.isValid());
- QVERIFY(badArray.constData() == 0);
- QVERIFY(badArray.data() == 0);
- QVERIFY(((const QAudioBuffer*)&badArray)->data() == 0);
- QCOMPARE(badArray.duration(), 0LL);
- QCOMPARE(badArray.byteCount(), 0);
- QCOMPARE(badArray.sampleCount(), 0);
- QCOMPARE(badArray.frameCount(), 0);
- QCOMPARE(badArray.startTime(), -1LL);
-
- QAudioBuffer badBoth = QAudioBuffer(QByteArray(), QAudioFormat());
- QVERIFY(!badBoth.isValid());
- QVERIFY(badBoth.constData() == 0);
- QVERIFY(badBoth.data() == 0);
- QVERIFY(((const QAudioBuffer*)&badBoth)->data() == 0);
- QCOMPARE(badBoth.duration(), 0LL);
- QCOMPARE(badBoth.byteCount(), 0);
- QCOMPARE(badBoth.sampleCount(), 0);
- QCOMPARE(badBoth.frameCount(), 0);
- QCOMPARE(badBoth.startTime(), -1LL);
-}
-
-void tst_QAudioBuffer::assign()
-{
- // TODO Needs strong behaviour definition
-}
-
-void tst_QAudioBuffer::constData() const
-{
- const void *data = mEmpty->constData();
- QVERIFY(data != 0);
-
- const unsigned int *idata = reinterpret_cast<const unsigned int*>(data);
- QCOMPARE(*idata, 0U);
-
- const QAudioBuffer::S8U *sdata = mEmpty->constData<QAudioBuffer::S8U>();
- QVERIFY(sdata);
- QCOMPARE(sdata->left, (unsigned char)0);
- QCOMPARE(sdata->right, (unsigned char)0);
-
- // The bytearray one should be 0x80
- data = mFromArray->constData();
- QVERIFY(data != 0);
-
- idata = reinterpret_cast<const unsigned int *>(data);
- QEXPECT_FAIL("", "Unsigned 16bits are cleared to 0x8080 currently", Continue);
- QCOMPARE(*idata, 0x80008000);
-
- sdata = mFromArray->constData<QAudioBuffer::S8U>();
- QCOMPARE(sdata->left, (unsigned char)0x80);
- QCOMPARE(sdata->right, (unsigned char)0x80);
-}
-
-void tst_QAudioBuffer::data_const() const
-{
- const void *data = ((const QAudioBuffer*)mEmpty)->data();
- QVERIFY(data != 0);
-
- const unsigned int *idata = reinterpret_cast<const unsigned int*>(data);
- QCOMPARE(*idata, 0U);
-
- const QAudioBuffer::S8U *sdata = ((const QAudioBuffer*)mEmpty)->constData<QAudioBuffer::S8U>();
- QVERIFY(sdata);
- QCOMPARE(sdata->left, (unsigned char)0);
- QCOMPARE(sdata->right, (unsigned char)0);
-
- // The bytearray one should be 0x80
- data = ((const QAudioBuffer*)mFromArray)->data();
- QVERIFY(data != 0);
-
- idata = reinterpret_cast<const unsigned int *>(data);
- QEXPECT_FAIL("", "Unsigned 16bits are cleared to 0x8080 currently", Continue);
- QCOMPARE(*idata, 0x80008000);
-
- sdata = ((const QAudioBuffer*)mFromArray)->constData<QAudioBuffer::S8U>();
- QCOMPARE(sdata->left, (unsigned char)0x80);
- QCOMPARE(sdata->right, (unsigned char)0x80);
-}
-
-void tst_QAudioBuffer::data()
-{
- void *data = mEmpty->data();
- QVERIFY(data != 0);
-
- unsigned int *idata = reinterpret_cast<unsigned int*>(data);
- QCOMPARE(*idata, 0U);
-
- QAudioBuffer::S8U *sdata = mEmpty->data<QAudioBuffer::S8U>();
- QVERIFY(sdata);
- QCOMPARE(sdata->left, (unsigned char)0);
- QCOMPARE(sdata->right, (unsigned char)0);
-
- // The bytearray one should be 0x80
- data = mFromArray->data();
- QVERIFY(data != 0);
-
- idata = reinterpret_cast<unsigned int *>(data);
- QEXPECT_FAIL("", "Unsigned 16bits are cleared to 0x8080 currently", Continue);
- QCOMPARE(*idata, 0x80008000);
-
- sdata = mFromArray->data<QAudioBuffer::S8U>();
- QCOMPARE(sdata->left, (unsigned char)0x80);
- QCOMPARE(sdata->right, (unsigned char)0x80);
-}
-
-void tst_QAudioBuffer::durations()
-{
- QFETCH(int, channelCount);
- QFETCH(int, sampleSize);
- QFETCH(int, frameCount);
- int sampleCount = frameCount * channelCount;
- QFETCH(QAudioFormat::SampleType, sampleType);
- QFETCH(int, sampleRate);
- QFETCH(qint64, duration);
- QFETCH(int, byteCount);
-
- QAudioFormat f;
- f.setChannelCount(channelCount);
- f.setSampleType(sampleType);
- f.setSampleSize(sampleSize);
- f.setSampleRate(sampleRate);
- f.setCodec("audio/pcm");
-
- QAudioBuffer b(frameCount, f);
-
- QCOMPARE(b.frameCount(), frameCount);
- QCOMPARE(b.sampleCount(), sampleCount);
- QCOMPARE(b.duration(), duration);
- QCOMPARE(b.byteCount(), byteCount);
-}
-
-void tst_QAudioBuffer::durations_data()
-{
- QTest::addColumn<int>("channelCount");
- QTest::addColumn<int>("sampleSize");
- QTest::addColumn<int>("frameCount");
- QTest::addColumn<QAudioFormat::SampleType>("sampleType");
- QTest::addColumn<int>("sampleRate");
- QTest::addColumn<qint64>("duration");
- QTest::addColumn<int>("byteCount");
- QTest::newRow("M8_1000_8K") << 1 << 8 << 1000 << QAudioFormat::UnSignedInt << 8000 << 125000LL << 1000;
- QTest::newRow("M8_2000_8K") << 1 << 8 << 2000 << QAudioFormat::UnSignedInt << 8000 << 250000LL << 2000;
- QTest::newRow("M8_1000_4K") << 1 << 8 << 1000 << QAudioFormat::UnSignedInt << 4000 << 250000LL << 1000;
-
- QTest::newRow("S8_1000_8K") << 2 << 8 << 500 << QAudioFormat::UnSignedInt << 8000 << 62500LL << 1000;
-
- QTest::newRow("SF_1000_8K") << 2 << 32 << 500 << QAudioFormat::Float << 8000 << 62500LL << 4000;
-
- QTest::newRow("4x128_1000_16K") << 4 << 128 << 250 << QAudioFormat::SignedInt << 16000 << 15625LL << 16000;
-}
-
-void tst_QAudioBuffer::stereoSample()
-{
- // Uninitialized (should default to zero level for type)
- QAudioBuffer::S8U s8u;
- QAudioBuffer::S8S s8s;
- QAudioBuffer::S16U s16u;
- QAudioBuffer::S16S s16s;
- QAudioBuffer::S32F s32f;
-
- QCOMPARE(s8u.left, (unsigned char) 0x80);
- QCOMPARE(s8u.right, (unsigned char) 0x80);
- QCOMPARE(s8u.average(), (unsigned char) 0x80);
-
- QCOMPARE(s8s.left, (signed char) 0x00);
- QCOMPARE(s8s.right, (signed char) 0x00);
- QCOMPARE(s8s.average(), (signed char) 0x0);
-
- QCOMPARE(s16u.left, (unsigned short) 0x8000);
- QCOMPARE(s16u.right, (unsigned short) 0x8000);
- QCOMPARE(s16u.average(), (unsigned short) 0x8000);
-
- QCOMPARE(s16s.left, (signed short) 0x0);
- QCOMPARE(s16s.right, (signed short) 0x0);
- QCOMPARE(s16s.average(), (signed short) 0x0);
-
- QCOMPARE(s32f.left, 0.0f);
- QCOMPARE(s32f.right, 0.0f);
- QCOMPARE(s32f.average(), 0.0f);
-
- // Initialized
- QAudioBuffer::S8U s8u2(34, 145);
- QAudioBuffer::S8S s8s2(23, -89);
- QAudioBuffer::S16U s16u2(500, 45000);
- QAudioBuffer::S16S s16s2(-10000, 346);
- QAudioBuffer::S32F s32f2(500.7f, -123.1f);
-
- QCOMPARE(s8u2.left, (unsigned char) 34);
- QCOMPARE(s8u2.right, (unsigned char) 145);
- QCOMPARE(s8u2.average(), (unsigned char) 89);
-
- QCOMPARE(s8s2.left, (signed char) 23);
- QCOMPARE(s8s2.right,(signed char) -89);
- QCOMPARE(s8s2.average(), (signed char) -33);
-
- QCOMPARE(s16u2.left, (unsigned short) 500);
- QCOMPARE(s16u2.right, (unsigned short) 45000);
- QCOMPARE(s16u2.average(), (unsigned short) 22750);
-
- QCOMPARE(s16s2.left, (signed short) -10000);
- QCOMPARE(s16s2.right, (signed short) 346);
- QCOMPARE(s16s2.average(), (signed short) (-5000 + 173));
-
- QCOMPARE(s32f2.left, 500.7f);
- QCOMPARE(s32f2.right, -123.1f);
- QCOMPARE(s32f2.average(), (500.7f - 123.1f)/2);
-
- // Assigned
- s8u = s8u2;
- s8s = s8s2;
- s16u = s16u2;
- s16s = s16s2;
- s32f = s32f2;
-
- QCOMPARE(s8u.left, (unsigned char) 34);
- QCOMPARE(s8u.right, (unsigned char) 145);
- QCOMPARE(s8u.average(), (unsigned char) 89);
-
- QCOMPARE(s8s.left, (signed char) 23);
- QCOMPARE(s8s.right, (signed char) -89);
- QCOMPARE(s8s.average(), (signed char) -33);
-
- QCOMPARE(s16u.left, (unsigned short) 500);
- QCOMPARE(s16u.right, (unsigned short) 45000);
- QCOMPARE(s16u.average(), (unsigned short) 22750);
-
- QCOMPARE(s16s.left, (signed short) -10000);
- QCOMPARE(s16s.right, (signed short) 346);
- QCOMPARE(s16s.average(), (signed short) (-5000 + 173));
-
- QCOMPARE(s32f.left, 500.7f);
- QCOMPARE(s32f.right, -123.1f);
- QCOMPARE(s32f.average(), (500.7f - 123.1f)/2);
-
- // Cleared
- s8u.clear();
- s8s.clear();
- s16u.clear();
- s16s.clear();
- s32f.clear();
-
- QCOMPARE(s8u.left, (unsigned char) 0x80);
- QCOMPARE(s8u.right, (unsigned char) 0x80);
- QCOMPARE(s8u.average(), (unsigned char) 0x80);
-
- QCOMPARE(s8s.left, (signed char) 0x00);
- QCOMPARE(s8s.right, (signed char) 0x00);
- QCOMPARE(s8s.average(), (signed char) 0x0);
-
- QCOMPARE(s16u.left, (unsigned short) 0x8000);
- QCOMPARE(s16u.right, (unsigned short) 0x8000);
- QCOMPARE(s16u.average(), (unsigned short) 0x8000);
-
- QCOMPARE(s16s.left, (signed short) 0x0);
- QCOMPARE(s16s.right, (signed short) 0x0);
- QCOMPARE(s16s.average(), (signed short) 0x0);
-
- QCOMPARE(s32f.left, 0.0f);
- QCOMPARE(s32f.right, 0.0f);
- QCOMPARE(s32f.average(), 0.0f);
-}
-
-
-QTEST_APPLESS_MAIN(tst_QAudioBuffer);
-
-#include "tst_qaudiobuffer.moc"
diff --git a/tests/auto/unit/qaudiodecoder/qaudiodecoder.pro b/tests/auto/unit/qaudiodecoder/qaudiodecoder.pro
deleted file mode 100644
index 4534fb4fe..000000000
--- a/tests/auto/unit/qaudiodecoder/qaudiodecoder.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-QT += multimedia multimedia-private testlib gui
-
-TARGET = tst_qaudiodecoder
-
-CONFIG += testcase
-
-TEMPLATE = app
-
-INCLUDEPATH += \
- ../../../../src/multimedia/audio
-
-include (../qmultimedia_common/mock.pri)
-include (../qmultimedia_common/mockdecoder.pri)
-
-SOURCES += tst_qaudiodecoder.cpp
diff --git a/tests/auto/unit/qaudiodecoder/tst_qaudiodecoder.cpp b/tests/auto/unit/qaudiodecoder/tst_qaudiodecoder.cpp
deleted file mode 100644
index cfcbc5f3f..000000000
--- a/tests/auto/unit/qaudiodecoder/tst_qaudiodecoder.cpp
+++ /dev/null
@@ -1,413 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#include <QtCore/QString>
-#include <QtTest/QtTest>
-
-#include "qaudiodecoder.h"
-#include "mockaudiodecoderservice.h"
-#include "mockmediaserviceprovider.h"
-
-class tst_QAudioDecoder : public QObject
-{
- Q_OBJECT
-
-public:
- tst_QAudioDecoder();
-
-private Q_SLOTS:
- void init();
- void ctors();
- void read();
- void stop();
- void format();
- void source();
- void readAll();
- void nullControl();
- void nullService();
-
-private:
- MockAudioDecoderService *mockAudioDecoderService;
- MockMediaServiceProvider *mockProvider;
-};
-
-tst_QAudioDecoder::tst_QAudioDecoder()
-{
-}
-
-void tst_QAudioDecoder::init()
-{
- mockAudioDecoderService = new MockAudioDecoderService(this);
- mockProvider = new MockMediaServiceProvider(mockAudioDecoderService);
-
- QMediaServiceProvider::setDefaultServiceProvider(mockProvider);
-}
-
-void tst_QAudioDecoder::ctors()
-{
- QAudioDecoder d;
- QVERIFY(d.state() == QAudioDecoder::StoppedState);
- QVERIFY(d.bufferAvailable() == false);
- QCOMPARE(d.sourceFilename(), QString(""));
-
- d.setSourceFilename("");
- QVERIFY(d.state() == QAudioDecoder::StoppedState);
- QVERIFY(d.bufferAvailable() == false);
- QCOMPARE(d.sourceFilename(), QString(""));
-}
-
-void tst_QAudioDecoder::read()
-{
- QAudioDecoder d;
- QVERIFY(d.state() == QAudioDecoder::StoppedState);
- QVERIFY(d.bufferAvailable() == false);
-
- QSignalSpy readySpy(&d, SIGNAL(bufferReady()));
- QSignalSpy bufferChangedSpy(&d, SIGNAL(bufferAvailableChanged(bool)));
- QSignalSpy errorSpy(&d, SIGNAL(error(QAudioDecoder::Error)));
-
- // Starting with empty source == error
- d.start();
-
- QVERIFY(d.state() == QAudioDecoder::StoppedState);
- QVERIFY(d.bufferAvailable() == false);
-
- QCOMPARE(readySpy.count(), 0);
- QCOMPARE(bufferChangedSpy.count(), 0);
- QCOMPARE(errorSpy.count(), 1);
-
- // Set the source to something
- d.setSourceFilename("Blah");
- QCOMPARE(d.sourceFilename(), QString("Blah"));
-
- readySpy.clear();
- errorSpy.clear();
- bufferChangedSpy.clear();
-
- d.start();
- QCOMPARE(d.state(), QAudioDecoder::DecodingState);
- QCOMPARE(d.bufferAvailable(), false); // not yet
-
- // Try to read
- QAudioBuffer b = d.read();
- QVERIFY(!b.isValid());
-
- // Read again with no parameter
- b = d.read();
- QVERIFY(!b.isValid());
-
- // Wait a while
- QTRY_VERIFY(d.bufferAvailable());
-
- QVERIFY(d.bufferAvailable());
-
- b = d.read();
- QVERIFY(b.format().isValid());
- QVERIFY(b.isValid());
- QVERIFY(b.format().channelCount() == 1);
- QVERIFY(b.sampleCount() == 4);
-
- QVERIFY(readySpy.count() >= 1);
- QVERIFY(errorSpy.count() == 0);
-
- if (d.bufferAvailable()) {
- QVERIFY(bufferChangedSpy.count() == 1);
- } else {
- QVERIFY(bufferChangedSpy.count() == 2);
- }
-}
-
-void tst_QAudioDecoder::stop()
-{
- QAudioDecoder d;
- QVERIFY(d.state() == QAudioDecoder::StoppedState);
- QVERIFY(d.bufferAvailable() == false);
-
- QSignalSpy readySpy(&d, SIGNAL(bufferReady()));
- QSignalSpy bufferChangedSpy(&d, SIGNAL(bufferAvailableChanged(bool)));
- QSignalSpy errorSpy(&d, SIGNAL(error(QAudioDecoder::Error)));
-
- // Starting with empty source == error
- d.start();
-
- QVERIFY(d.state() == QAudioDecoder::StoppedState);
- QVERIFY(d.bufferAvailable() == false);
-
- QCOMPARE(readySpy.count(), 0);
- QCOMPARE(bufferChangedSpy.count(), 0);
- QCOMPARE(errorSpy.count(), 1);
-
- // Set the source to something
- d.setSourceFilename("Blah");
- QCOMPARE(d.sourceFilename(), QString("Blah"));
-
- readySpy.clear();
- errorSpy.clear();
- bufferChangedSpy.clear();
-
- d.start();
- QCOMPARE(d.state(), QAudioDecoder::DecodingState);
- QCOMPARE(d.bufferAvailable(), false); // not yet
-
- // Try to read
- QAudioBuffer b = d.read();
- QVERIFY(!b.isValid());
-
- // Read again with no parameter
- b = d.read();
- QVERIFY(!b.isValid());
-
- // Wait a while
- QTRY_VERIFY(d.bufferAvailable());
-
- QVERIFY(d.bufferAvailable());
-
- // Now stop
- d.stop();
-
- QVERIFY(d.state() == QAudioDecoder::StoppedState);
- QVERIFY(d.bufferAvailable() == false);
-}
-
-void tst_QAudioDecoder::format()
-{
- QAudioDecoder d;
- QVERIFY(d.state() == QAudioDecoder::StoppedState);
- QVERIFY(d.bufferAvailable() == false);
-
- QSignalSpy readySpy(&d, SIGNAL(bufferReady()));
- QSignalSpy bufferChangedSpy(&d, SIGNAL(bufferAvailableChanged(bool)));
- QSignalSpy errorSpy(&d, SIGNAL(error(QAudioDecoder::Error)));
-
- // Set the source to something
- d.setSourceFilename("Blah");
- QCOMPARE(d.sourceFilename(), QString("Blah"));
-
- readySpy.clear();
- errorSpy.clear();
- bufferChangedSpy.clear();
-
- d.start();
- QCOMPARE(d.state(), QAudioDecoder::DecodingState);
- QCOMPARE(d.bufferAvailable(), false); // not yet
-
- // Try to read
- QAudioBuffer b = d.read();
- QVERIFY(!b.isValid());
-
- // Read again with no parameter
- b = d.read();
- QVERIFY(!b.isValid());
-
- // Wait a while
- QTRY_VERIFY(d.bufferAvailable());
-
- b = d.read();
- QVERIFY(d.audioFormat() == b.format());
-
- // Setting format while decoding is forbidden
- QAudioFormat f(d.audioFormat());
- f.setChannelCount(2);
-
- d.setAudioFormat(f);
- QVERIFY(d.audioFormat() != f);
- QVERIFY(d.audioFormat() == b.format());
-
- // Now stop, and set something specific
- d.stop();
- d.setAudioFormat(f);
- QVERIFY(d.audioFormat() == f);
-
- // Decode again
- d.start();
- QTRY_VERIFY(d.bufferAvailable());
-
- b = d.read();
- QVERIFY(d.audioFormat() == f);
- QVERIFY(b.format() == f);
-}
-
-void tst_QAudioDecoder::source()
-{
- QAudioDecoder d;
-
- QVERIFY(d.sourceFilename().isEmpty());
- QVERIFY(d.sourceDevice() == 0);
-
- QFile f;
- d.setSourceDevice(&f);
- QVERIFY(d.sourceFilename().isEmpty());
- QVERIFY(d.sourceDevice() == &f);
-
- d.setSourceFilename("Foo");
- QVERIFY(d.sourceFilename() == QString("Foo"));
- QVERIFY(d.sourceDevice() == 0);
-
- d.setSourceDevice(0);
- QVERIFY(d.sourceFilename().isEmpty());
- QVERIFY(d.sourceDevice() == 0);
-
- d.setSourceFilename("Foo");
- QVERIFY(d.sourceFilename() == QString("Foo"));
- QVERIFY(d.sourceDevice() == 0);
-
- d.setSourceFilename(QString());
- QVERIFY(d.sourceFilename() == QString());
- QVERIFY(d.sourceDevice() == 0);
-}
-
-void tst_QAudioDecoder::readAll()
-{
- QAudioDecoder d;
- d.setSourceFilename("Foo");
- QVERIFY(d.state() == QAudioDecoder::StoppedState);
-
- QSignalSpy durationSpy(&d, SIGNAL(durationChanged(qint64)));
- QSignalSpy positionSpy(&d, SIGNAL(positionChanged(qint64)));
- QSignalSpy stateSpy(&d, SIGNAL(stateChanged(QAudioDecoder::State)));
- QSignalSpy finishedSpy(&d, SIGNAL(finished()));
- QSignalSpy bufferAvailableSpy(&d, SIGNAL(bufferAvailableChanged(bool)));
- d.start();
- int i = 0;
- forever {
- QVERIFY(d.state() == QAudioDecoder::DecodingState);
- QCOMPARE(stateSpy.count(), 1);
- QCOMPARE(durationSpy.count(), 1);
- QVERIFY(finishedSpy.isEmpty());
- QTRY_VERIFY(bufferAvailableSpy.count() >= 1);
- if (d.bufferAvailable()) {
- QAudioBuffer b = d.read();
- QVERIFY(b.isValid());
- QCOMPARE(b.startTime() / 1000, d.position());
- QVERIFY(!positionSpy.isEmpty());
- QList<QVariant> arguments = positionSpy.takeLast();
- QCOMPARE(arguments.at(0).toLongLong(), b.startTime() / 1000);
-
- i++;
- if (i == MOCK_DECODER_MAX_BUFFERS) {
- QCOMPARE(finishedSpy.count(), 1);
- QCOMPARE(stateSpy.count(), 2);
- QVERIFY(d.state() == QAudioDecoder::StoppedState);
- QList<QVariant> arguments = stateSpy.takeLast();
- QVERIFY(arguments.at(0).toInt() == (int)QAudioDecoder::StoppedState);
- QVERIFY(!d.bufferAvailable());
- QVERIFY(!bufferAvailableSpy.isEmpty());
- arguments = bufferAvailableSpy.takeLast();
- QVERIFY(arguments.at(0).toBool() == false);
- break;
- }
- } else
- QTest::qWait(30);
- }
-}
-
-void tst_QAudioDecoder::nullControl()
-{
- mockAudioDecoderService->setControlNull();
- QAudioDecoder d;
-
- QVERIFY(d.error() == QAudioDecoder::ServiceMissingError);
- QVERIFY(!d.errorString().isEmpty());
-
- QVERIFY(d.hasSupport("MIME") == QMultimedia::MaybeSupported);
-
- QVERIFY(d.state() == QAudioDecoder::StoppedState);
-
- QVERIFY(d.sourceFilename().isEmpty());
- d.setSourceFilename("test");
- QVERIFY(d.sourceFilename().isEmpty());
-
- QFile f;
- QVERIFY(d.sourceDevice() == 0);
- d.setSourceDevice(&f);
- QVERIFY(d.sourceDevice() == 0);
-
- QAudioFormat format;
- format.setChannelCount(2);
- QVERIFY(!d.audioFormat().isValid());
- d.setAudioFormat(format);
- QVERIFY(!d.audioFormat().isValid());
-
- QVERIFY(!d.read().isValid());
- QVERIFY(!d.bufferAvailable());
-
- QVERIFY(d.position() == -1);
- QVERIFY(d.duration() == -1);
-
- d.start();
- QVERIFY(d.error() == QAudioDecoder::ServiceMissingError);
- QVERIFY(!d.errorString().isEmpty());
- QVERIFY(d.state() == QAudioDecoder::StoppedState);
- d.stop();
-}
-
-
-void tst_QAudioDecoder::nullService()
-{
- mockProvider->service = 0;
- QAudioDecoder d;
-
- QVERIFY(d.error() == QAudioDecoder::ServiceMissingError);
- QVERIFY(!d.errorString().isEmpty());
-
- QVERIFY(d.hasSupport("MIME") == QMultimedia::MaybeSupported);
-
- QVERIFY(d.state() == QAudioDecoder::StoppedState);
-
- QVERIFY(d.sourceFilename().isEmpty());
- d.setSourceFilename("test");
- QVERIFY(d.sourceFilename().isEmpty());
-
- QFile f;
- QVERIFY(d.sourceDevice() == 0);
- d.setSourceDevice(&f);
- QVERIFY(d.sourceDevice() == 0);
-
- QAudioFormat format;
- format.setChannelCount(2);
- QVERIFY(!d.audioFormat().isValid());
- d.setAudioFormat(format);
- QVERIFY(!d.audioFormat().isValid());
-
- QVERIFY(!d.read().isValid());
- QVERIFY(!d.bufferAvailable());
-
- QVERIFY(d.position() == -1);
- QVERIFY(d.duration() == -1);
-
- d.start();
- QVERIFY(d.error() == QAudioDecoder::ServiceMissingError);
- QVERIFY(!d.errorString().isEmpty());
- QVERIFY(d.state() == QAudioDecoder::StoppedState);
- d.stop();
-}
-
-QTEST_MAIN(tst_QAudioDecoder)
-
-#include "tst_qaudiodecoder.moc"
diff --git a/tests/auto/unit/qaudioformat/qaudioformat.pro b/tests/auto/unit/qaudioformat/qaudioformat.pro
deleted file mode 100644
index 408200a85..000000000
--- a/tests/auto/unit/qaudioformat/qaudioformat.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qaudioformat
-
-QT += core multimedia-private testlib
-
-SOURCES += tst_qaudioformat.cpp
-
diff --git a/tests/auto/unit/qaudionamespace/qaudionamespace.pro b/tests/auto/unit/qaudionamespace/qaudionamespace.pro
deleted file mode 100644
index cfe502dc6..000000000
--- a/tests/auto/unit/qaudionamespace/qaudionamespace.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qaudionamespace
-
-QT += core multimedia-private testlib
-
-SOURCES += tst_qaudionamespace.cpp
-
diff --git a/tests/auto/unit/qaudioprobe/qaudioprobe.pro b/tests/auto/unit/qaudioprobe/qaudioprobe.pro
deleted file mode 100644
index a83769cc7..000000000
--- a/tests/auto/unit/qaudioprobe/qaudioprobe.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qaudioprobe
-
-QT += multimedia-private testlib
-
-SOURCES += tst_qaudioprobe.cpp
-
-include (../qmultimedia_common/mock.pri)
-include (../qmultimedia_common/mockrecorder.pri)
-
diff --git a/tests/auto/unit/qaudioprobe/tst_qaudioprobe.cpp b/tests/auto/unit/qaudioprobe/tst_qaudioprobe.cpp
deleted file mode 100644
index 3bab32129..000000000
--- a/tests/auto/unit/qaudioprobe/tst_qaudioprobe.cpp
+++ /dev/null
@@ -1,183 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QDebug>
-
-#include <qaudioprobe.h>
-#include <qaudiorecorder.h>
-
-//TESTED_COMPONENT=src/multimedia
-
-#include "mockmediaserviceprovider.h"
-#include "mockmediarecorderservice.h"
-#include "mockmediaobject.h"
-
-QT_USE_NAMESPACE
-
-class tst_QAudioProbe: public QObject
-{
- Q_OBJECT
-
-public slots:
- void init();
- void cleanup();
-
-private slots:
- void testNullService();
- void testNullControl();
- void testRecorder();
- void testRecorderDeleteRecorder();
- void testRecorderDeleteProbe();
- void testMediaObject();
-
-private:
- QAudioRecorder *recorder;
- MockMediaRecorderControl *mockMediaRecorderControl;
- MockMediaRecorderService *mockMediaRecorderService;
- MockMediaServiceProvider *mockProvider;
-};
-
-void tst_QAudioProbe::init()
-{
- mockMediaRecorderControl = new MockMediaRecorderControl(this);
- mockMediaRecorderService = new MockMediaRecorderService(this, mockMediaRecorderControl);
- mockProvider = new MockMediaServiceProvider(mockMediaRecorderService);
- mockProvider->deleteServiceOnRelease = true;
- recorder = 0;
-
- QMediaServiceProvider::setDefaultServiceProvider(mockProvider);
-}
-
-void tst_QAudioProbe::cleanup()
-{
- delete recorder;
- delete mockProvider;
- delete mockMediaRecorderControl;
- mockMediaRecorderControl = 0;
- mockMediaRecorderService = 0;
- mockProvider = 0;
- recorder = 0;
-}
-
-void tst_QAudioProbe::testNullService()
-{
- mockProvider->service = 0;
- recorder = new QAudioRecorder;
-
- QVERIFY(!recorder->isAvailable());
- QCOMPARE(recorder->availability(), QMultimedia::ServiceMissing);
-
- QAudioProbe probe;
- QVERIFY(!probe.isActive());
- QVERIFY(!probe.setSource(recorder));
- QVERIFY(!probe.isActive());
- delete recorder;
- recorder = 0;
- QVERIFY(!probe.isActive());
-}
-
-
-void tst_QAudioProbe::testNullControl()
-{
- mockMediaRecorderService->hasControls = false;
- recorder = new QAudioRecorder;
-
- QVERIFY(!recorder->isAvailable());
- QCOMPARE(recorder->availability(), QMultimedia::ServiceMissing);
-
- QAudioProbe probe;
- QVERIFY(!probe.isActive());
- QVERIFY(!probe.setSource(recorder));
- QVERIFY(!probe.isActive());
- delete recorder;
- recorder = 0;
- QVERIFY(!probe.isActive());
-}
-
-void tst_QAudioProbe::testRecorder()
-{
- recorder = new QAudioRecorder;
- QVERIFY(recorder->isAvailable());
-
- QAudioProbe probe;
- QVERIFY(!probe.isActive());
- QVERIFY(probe.setSource(recorder));
- QVERIFY(probe.isActive());
- probe.setSource((QMediaRecorder*)0);
- QVERIFY(!probe.isActive());
-}
-
-void tst_QAudioProbe::testRecorderDeleteRecorder()
-{
- recorder = new QAudioRecorder;
- QVERIFY(recorder->isAvailable());
-
- QAudioProbe probe;
- QVERIFY(!probe.isActive());
- QVERIFY(probe.setSource(recorder));
- QVERIFY(probe.isActive());
-
- delete recorder;
- recorder = 0;
- QVERIFY(!probe.isActive());
- probe.setSource((QMediaRecorder*)0);
- QVERIFY(!probe.isActive());
-}
-
-void tst_QAudioProbe::testRecorderDeleteProbe()
-{
- recorder = new QAudioRecorder;
- QVERIFY(recorder->isAvailable());
-
- QAudioProbe *probe = new QAudioProbe;
- QVERIFY(!probe->isActive());
- QVERIFY(probe->setSource(recorder));
- QVERIFY(probe->isActive());
-
- delete probe;
- QVERIFY(recorder->isAvailable());
-}
-
-void tst_QAudioProbe::testMediaObject()
-{
- QMediaObject *object = new MockMediaObject(0, mockMediaRecorderService);
- QVERIFY(object->isAvailable());
-
- QAudioProbe probe;
- QVERIFY(!probe.isActive());
- QVERIFY(probe.setSource(object));
- QVERIFY(probe.isActive());
- probe.setSource((QMediaObject*)0);
- QVERIFY(!probe.isActive());
- delete object;
-}
-
-QTEST_GUILESS_MAIN(tst_QAudioProbe)
-
-#include "tst_qaudioprobe.moc"
diff --git a/tests/auto/unit/qaudiorecorder/qaudiorecorder.pro b/tests/auto/unit/qaudiorecorder/qaudiorecorder.pro
deleted file mode 100644
index a40fba233..000000000
--- a/tests/auto/unit/qaudiorecorder/qaudiorecorder.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qaudiorecorder
-
-QT += multimedia-private testlib
-
-SOURCES += tst_qaudiorecorder.cpp
-
-include (../qmultimedia_common/mock.pri)
-include (../qmultimedia_common/mockrecorder.pri)
-
diff --git a/tests/auto/unit/qaudiorecorder/tst_qaudiorecorder.cpp b/tests/auto/unit/qaudiorecorder/tst_qaudiorecorder.cpp
deleted file mode 100644
index 5691c8f44..000000000
--- a/tests/auto/unit/qaudiorecorder/tst_qaudiorecorder.cpp
+++ /dev/null
@@ -1,180 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QDebug>
-
-#include <qaudioformat.h>
-
-#include <qaudiorecorder.h>
-#include <qaudioencodersettingscontrol.h>
-#include <qmediarecordercontrol.h>
-#include <qaudioinputselectorcontrol.h>
-#include <qaudiodeviceinfo.h>
-#include <qaudioinput.h>
-#include <qmediaobject.h>
-
-//TESTED_COMPONENT=src/multimedia
-
-#include "mockmediaserviceprovider.h"
-#include "mockmediarecorderservice.h"
-
-QT_USE_NAMESPACE
-
-class tst_QAudioRecorder: public QObject
-{
- Q_OBJECT
-
-public slots:
- void init();
- void cleanup();
-
-private slots:
- void testNullService();
- void testNullControl();
- void testAudioSource();
- void testDevices();
- void testAvailability();
- void testAvailableAudioInputChangedSignal();
-
-private:
- QAudioRecorder *audiosource;
- MockMediaRecorderService *mockMediaRecorderService;
- MockMediaServiceProvider *mockProvider;
-};
-
-void tst_QAudioRecorder::init()
-{
- mockMediaRecorderService = new MockMediaRecorderService(this, new MockMediaRecorderControl(this));
- mockProvider = new MockMediaServiceProvider(mockMediaRecorderService);
- audiosource = 0;
-
- QMediaServiceProvider::setDefaultServiceProvider(mockProvider);
-}
-
-void tst_QAudioRecorder::cleanup()
-{
- delete mockMediaRecorderService;
- delete mockProvider;
- delete audiosource;
- mockMediaRecorderService = 0;
- mockProvider = 0;
- audiosource = 0;
-}
-
-void tst_QAudioRecorder::testNullService()
-{
- mockProvider->service = 0;
- QAudioRecorder source;
-
- QVERIFY(!source.isAvailable());
- QCOMPARE(source.availability(), QMultimedia::ServiceMissing);
-
- QCOMPARE(source.audioInputs().size(), 0);
- QCOMPARE(source.defaultAudioInput(), QString());
- QCOMPARE(source.audioInput(), QString());
-}
-
-
-void tst_QAudioRecorder::testNullControl()
-{
- mockMediaRecorderService->hasControls = false;
- QAudioRecorder source;
-
- QVERIFY(!source.isAvailable());
- QCOMPARE(source.availability(), QMultimedia::ServiceMissing);
-
- QCOMPARE(source.audioInputs().size(), 0);
- QCOMPARE(source.defaultAudioInput(), QString());
- QCOMPARE(source.audioInput(), QString());
-
- QCOMPARE(source.audioInputDescription("blah"), QString());
-
- QSignalSpy deviceNameSpy(&source, SIGNAL(audioInputChanged(QString)));
-
- source.setAudioInput("blah");
- QCOMPARE(deviceNameSpy.count(), 0);
-}
-
-void tst_QAudioRecorder::testAudioSource()
-{
- audiosource = new QAudioRecorder;
-
- QCOMPARE(audiosource->mediaObject()->service(),(QMediaService *) mockMediaRecorderService);
-}
-
-void tst_QAudioRecorder::testDevices()
-{
- audiosource = new QAudioRecorder;
- QList<QString> devices = audiosource->audioInputs();
- QVERIFY(devices.size() > 0);
- QVERIFY(devices.at(0).compare("device1") == 0);
- QVERIFY(audiosource->audioInputDescription("device1").compare("dev1 comment") == 0);
- QVERIFY(audiosource->defaultAudioInput() == "device1");
- QVERIFY(audiosource->isAvailable() == true);
-
- QSignalSpy checkSignal(audiosource, SIGNAL(audioInputChanged(QString)));
- audiosource->setAudioInput("device2");
- QVERIFY(audiosource->audioInput().compare("device2") == 0);
- QVERIFY(checkSignal.count() == 1);
- QVERIFY(audiosource->isAvailable() == true);
-}
-
-void tst_QAudioRecorder::testAvailability()
-{
- QAudioRecorder source;
-
- QVERIFY(source.isAvailable());
- QCOMPARE(source.availability(), QMultimedia::Available);
-}
-
-void tst_QAudioRecorder::testAvailableAudioInputChangedSignal()
-{
- // The availabilityChangedSignal is implemented in QAudioRecorder. SO using it to test the signal.
- audiosource = new QAudioRecorder;
-
- /* Spy the signal availableInputsChanged and audioInputchanged */
- QSignalSpy changed(mockMediaRecorderService->mockAudioInputSelector, SIGNAL(availableInputsChanged()));
- QSignalSpy audioInputchange(audiosource, SIGNAL(availableAudioInputsChanged()));
-
- /* Add the end points and verify if the available end point changed signal is emitted. */
- QMetaObject::invokeMethod(mockMediaRecorderService->mockAudioInputSelector, "addInputs");
- QVERIFY(changed.count() == 1);
- QVERIFY(audioInputchange.count() == 1);
-
- /* Now try removes */
- changed.clear();
- audioInputchange.clear();
- QMetaObject::invokeMethod(mockMediaRecorderService->mockAudioInputSelector, "removeInputs");
- QVERIFY(changed.count() == 1);
- QVERIFY(audioInputchange.count() == 1);
-}
-
-QTEST_GUILESS_MAIN(tst_QAudioRecorder)
-
-#include "tst_qaudiorecorder.moc"
diff --git a/tests/auto/unit/qcamera/qcamera.pro b/tests/auto/unit/qcamera/qcamera.pro
deleted file mode 100644
index baca79829..000000000
--- a/tests/auto/unit/qcamera/qcamera.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qcamera
-
-QT += multimedia-private testlib
-
-include (../qmultimedia_common/mock.pri)
-include (../qmultimedia_common/mockcamera.pri)
-
-SOURCES += tst_qcamera.cpp
diff --git a/tests/auto/unit/qcamera/tst_qcamera.cpp b/tests/auto/unit/qcamera/tst_qcamera.cpp
deleted file mode 100644
index 643b552f9..000000000
--- a/tests/auto/unit/qcamera/tst_qcamera.cpp
+++ /dev/null
@@ -1,2523 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//TESTED_COMPONENT=src/multimedia
-
-#include <QtTest/QtTest>
-#include <QDebug>
-
-#include <qabstractvideosurface.h>
-#include <qcameracontrol.h>
-#include <qcameralockscontrol.h>
-#include <qcameraexposurecontrol.h>
-#include <qcameraflashcontrol.h>
-#include <qcamerafocuscontrol.h>
-#include <qcameraimagecapturecontrol.h>
-#include <qimageencodercontrol.h>
-#include <qcameraimageprocessingcontrol.h>
-#include <qcameracapturebufferformatcontrol.h>
-#include <qcameracapturedestinationcontrol.h>
-#include <qmediaservice.h>
-#include <qcamera.h>
-#include <qcamerainfo.h>
-#include <qcameraimagecapture.h>
-#include <qvideorenderercontrol.h>
-
-#include "mockcameraservice.h"
-
-#include "mockmediaserviceprovider.h"
-#include "mockvideosurface.h"
-#include "mockvideorenderercontrol.h"
-#include "mockvideowindowcontrol.h"
-
-QT_USE_NAMESPACE
-
-
-class tst_QCamera: public QObject
-{
- Q_OBJECT
-
-public slots:
- void initTestCase();
- void init();
- void cleanup();
-
-private slots:
- void testSimpleCamera();
- void testSimpleCameraWhiteBalance();
- void testSimpleCameraExposure();
- void testSimpleCameraFocus();
- void testSimpleCameraCapture();
- void testSimpleCameraLock();
- void testSimpleCaptureDestination();
- void testSimpleCaptureFormat();
-
- void testCameraWhiteBalance();
- void testCameraExposure();
- void testCameraFocus();
- void testCameraCapture();
- void testCameraCaptureMetadata();
- void testImageSettings();
- void testViewfinderSettings();
- void testViewfinderSettingsChange();
- void testSupportedViewfinderSettings_data();
- void testSupportedViewfinderSettings();
- void testSupportedViewfinderResolutions_data();
- void testSupportedViewfinderResolutions();
- void testSupportedViewfinderFrameRateRanges_data();
- void testSupportedViewfinderFrameRateRanges();
- void testSupportedViewfinderPixelFormats_data();
- void testSupportedViewfinderPixelFormats();
- void testCameraLock();
- void testCameraLockCancel();
- void testCameraEncodingProperyChange();
- void testCaptureDestination();
- void testCaptureFormat();
-
- void testConstructor();
- void testCaptureMode();
- void testIsCaptureModeSupported();
- void testRequestedLocks();
- void testSupportedLocks();
- void testQCameraIsAvailable();
- void testQCameraIsNotAvailable();
- void testSearchAndLockWithLockTypes();
- void testSetCaptureMode();
- void testUnlockWithType();
- void testCaptureModeChangedSignal();
- void testLockStatusChangedWithTypesSignal();
- void testErrorSignal();
- void testError();
- void testErrorString();
- void testStatus();
- void testLockType();
- void testLockChangeReason();
-
-
- // Test cases to for QCameraFocus
- void testCameraFocusIsAvailable();
- void testFocusModes();
- void testOpticalAndDigitalZoomChanged();
- void testMaxOpticalZoomChangedSignal();
- void testMaxDigitalZoomChangedSignal();
- void testfocusZonesChangedSignal();
-
- // Test cases for QCameraControl class.
- void testCameraControl();
- void testCaptureModeChanged_signal();
- void testEnumsOfQCameraControl();
-
- // Test case for QCameraImageProcessing class
- void testContrast();
- void testDenoisingLevel();
- void testIsAvailable();
- void testSaturation();
- void testSharpeningLevel();
- void testEnumOfQCameraImageProcessing();
-
- void testSetVideoOutput();
- void testSetVideoOutputNoService();
- void testSetVideoOutputNoControl();
- void testSetVideoOutputDestruction();
-
- void testEnumDebug();
-
- // constructor for QCameraImageProceesing
- void testImageProcessingControl();
-
- // Signals test cases for QCameraExposure
- void testSignalApertureChanged();
- void testSignalExposureCompensationChanged();
- void testSignalIsoSensitivityChanged();
- void testSignalShutterSpeedChanged();
- void testSignalFlashReady();
-
- // test constructor
- void testExposureControlConstructor();
-
-private:
- MockSimpleCameraService *mockSimpleCameraService;
- MockCameraService *mockCameraService;
- MockMediaServiceProvider *provider;
-};
-
-Q_DECLARE_METATYPE(QCamera::FrameRateRange)
-
-void tst_QCamera::initTestCase()
-{
- qRegisterMetaType<QCamera::FrameRateRange>("FrameRateRange");
-}
-
-void tst_QCamera::init()
-{
- provider = new MockMediaServiceProvider;
- mockSimpleCameraService = new MockSimpleCameraService;
- mockCameraService = new MockCameraService;
-
- provider->service = mockCameraService;
- QMediaServiceProvider::setDefaultServiceProvider(provider);
-}
-
-void tst_QCamera::cleanup()
-{
- delete provider;
- delete mockCameraService;
- delete mockSimpleCameraService;
-}
-
-void tst_QCamera::testSimpleCamera()
-{
- provider->service = mockSimpleCameraService;
- QCamera camera;
- QCOMPARE(camera.service(), (QMediaService*)mockSimpleCameraService);
-
- QCOMPARE(camera.state(), QCamera::UnloadedState);
- camera.start();
- QCOMPARE(camera.state(), QCamera::ActiveState);
- camera.stop();
- QCOMPARE(camera.state(), QCamera::LoadedState);
- camera.unload();
- QCOMPARE(camera.state(), QCamera::UnloadedState);
- camera.load();
- QCOMPARE(camera.state(), QCamera::LoadedState);
-}
-
-void tst_QCamera::testSimpleCameraWhiteBalance()
-{
- provider->service = mockSimpleCameraService;
- QCamera camera;
-
- //only WhiteBalanceAuto is supported
- QVERIFY(!camera.imageProcessing()->isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceAuto));
- QVERIFY(!camera.imageProcessing()->isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceCloudy));
- QCOMPARE(camera.imageProcessing()->whiteBalanceMode(), QCameraImageProcessing::WhiteBalanceAuto);
- camera.imageProcessing()->setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceCloudy);
- QCOMPARE(camera.imageProcessing()->whiteBalanceMode(), QCameraImageProcessing::WhiteBalanceAuto);
- QCOMPARE(camera.imageProcessing()->manualWhiteBalance()+1.0, 1.0);
- camera.imageProcessing()->setManualWhiteBalance(5000);
- QCOMPARE(camera.imageProcessing()->manualWhiteBalance()+1.0, 1.0);
-}
-
-void tst_QCamera::testSimpleCameraExposure()
-{
- provider->service = mockSimpleCameraService;
- QCamera camera;
- QCameraExposure *cameraExposure = camera.exposure();
- QVERIFY(cameraExposure != 0);
-
- QVERIFY(!cameraExposure->isExposureModeSupported(QCameraExposure::ExposureAuto));
- QCOMPARE(cameraExposure->exposureMode(), QCameraExposure::ExposureAuto);
- cameraExposure->setExposureMode(QCameraExposure::ExposureManual);//should be ignored
- QCOMPARE(cameraExposure->exposureMode(), QCameraExposure::ExposureAuto);
-
- QVERIFY(!cameraExposure->isFlashModeSupported(QCameraExposure::FlashOff));
- QCOMPARE(cameraExposure->flashMode(), QCameraExposure::FlashOff);
- QCOMPARE(cameraExposure->isFlashReady(), false);
- cameraExposure->setFlashMode(QCameraExposure::FlashOn);
- QCOMPARE(cameraExposure->flashMode(), QCameraExposure::FlashOff);
-
- QVERIFY(!cameraExposure->isMeteringModeSupported(QCameraExposure::MeteringAverage));
- QVERIFY(!cameraExposure->isMeteringModeSupported(QCameraExposure::MeteringSpot));
- QVERIFY(!cameraExposure->isMeteringModeSupported(QCameraExposure::MeteringMatrix));
- QCOMPARE(cameraExposure->meteringMode(), QCameraExposure::MeteringMatrix);
- cameraExposure->setMeteringMode(QCameraExposure::MeteringSpot);
- QCOMPARE(cameraExposure->meteringMode(), QCameraExposure::MeteringMatrix);
-
- QCOMPARE(cameraExposure->spotMeteringPoint(), QPointF());
- cameraExposure->setSpotMeteringPoint(QPointF(0.5f, 0.5f));
- QCOMPARE(cameraExposure->spotMeteringPoint(), QPointF());
-
- QCOMPARE(cameraExposure->exposureCompensation(), 0.0);
- cameraExposure->setExposureCompensation(2.0);
- QCOMPARE(cameraExposure->exposureCompensation(), 0.0);
-
- QCOMPARE(cameraExposure->isoSensitivity(), -1);
- QVERIFY(cameraExposure->supportedIsoSensitivities().isEmpty());
- cameraExposure->setManualIsoSensitivity(100);
- QCOMPARE(cameraExposure->isoSensitivity(), -1);
- cameraExposure->setAutoIsoSensitivity();
- QCOMPARE(cameraExposure->isoSensitivity(), -1);
-
- QVERIFY(cameraExposure->aperture() < 0);
- QVERIFY(cameraExposure->supportedApertures().isEmpty());
- cameraExposure->setAutoAperture();
- QVERIFY(cameraExposure->aperture() < 0);
- cameraExposure->setManualAperture(5.6);
- QVERIFY(cameraExposure->aperture() < 0);
-
- QVERIFY(cameraExposure->shutterSpeed() < 0);
- QVERIFY(cameraExposure->supportedShutterSpeeds().isEmpty());
- cameraExposure->setAutoShutterSpeed();
- QVERIFY(cameraExposure->shutterSpeed() < 0);
- cameraExposure->setManualShutterSpeed(1/128.0);
- QVERIFY(cameraExposure->shutterSpeed() < 0);
-}
-
-void tst_QCamera::testSimpleCameraFocus()
-{
- provider->service = mockSimpleCameraService;
- QCamera camera;
-
- QCameraFocus *cameraFocus = camera.focus();
- QVERIFY(cameraFocus != 0);
-
- QVERIFY(!cameraFocus->isFocusModeSupported(QCameraFocus::AutoFocus));
- QVERIFY(!cameraFocus->isFocusModeSupported(QCameraFocus::ContinuousFocus));
- QVERIFY(!cameraFocus->isFocusModeSupported(QCameraFocus::InfinityFocus));
-
- QCOMPARE(cameraFocus->focusMode(), QCameraFocus::AutoFocus);
- QTest::ignoreMessage(QtWarningMsg, "Focus mode selection is not supported");
- cameraFocus->setFocusMode(QCameraFocus::ContinuousFocus);
- QCOMPARE(cameraFocus->focusMode(), QCameraFocus::AutoFocus);
-
- QCOMPARE(cameraFocus->maximumOpticalZoom(), 1.0);
- QCOMPARE(cameraFocus->maximumDigitalZoom(), 1.0);
- QCOMPARE(cameraFocus->opticalZoom(), 1.0);
- QCOMPARE(cameraFocus->digitalZoom(), 1.0);
-
- QTest::ignoreMessage(QtWarningMsg, "The camera doesn't support zooming.");
- cameraFocus->zoomTo(100.0, 100.0);
- QCOMPARE(cameraFocus->opticalZoom(), 1.0);
- QCOMPARE(cameraFocus->digitalZoom(), 1.0);
-
-
- QVERIFY(!cameraFocus->isFocusPointModeSupported(QCameraFocus::FocusPointAuto));
- QCOMPARE(cameraFocus->focusPointMode(), QCameraFocus::FocusPointAuto);
-
- QTest::ignoreMessage(QtWarningMsg, "Focus points mode selection is not supported");
- cameraFocus->setFocusPointMode( QCameraFocus::FocusPointCenter );
- QCOMPARE(cameraFocus->focusPointMode(), QCameraFocus::FocusPointAuto);
-
- QCOMPARE(cameraFocus->customFocusPoint(), QPointF(0.5, 0.5));
- QTest::ignoreMessage(QtWarningMsg, "Focus points selection is not supported");
- cameraFocus->setCustomFocusPoint(QPointF(1.0, 1.0));
- QCOMPARE(cameraFocus->customFocusPoint(), QPointF(0.5, 0.5));
-}
-
-void tst_QCamera::testSimpleCameraCapture()
-{
- provider->service = mockSimpleCameraService;
- QCamera camera;
- QCameraImageCapture imageCapture(&camera);
-
- QVERIFY(!imageCapture.isReadyForCapture());
- QVERIFY(!imageCapture.isAvailable());
-
- QCOMPARE(imageCapture.error(), QCameraImageCapture::NoError);
- QVERIFY(imageCapture.errorString().isEmpty());
-
- QSignalSpy errorSignal(&imageCapture, SIGNAL(error(int,QCameraImageCapture::Error,QString)));
- imageCapture.capture(QString::fromLatin1("/dev/null"));
- QCOMPARE(errorSignal.size(), 1);
- QCOMPARE(imageCapture.error(), QCameraImageCapture::NotSupportedFeatureError);
- QVERIFY(!imageCapture.errorString().isEmpty());
-}
-
-void tst_QCamera::testSimpleCameraLock()
-{
- provider->service = mockSimpleCameraService;
- QCamera camera;
- QCOMPARE(camera.lockStatus(), QCamera::Unlocked);
- QCOMPARE(camera.lockStatus(QCamera::LockExposure), QCamera::Unlocked);
- QCOMPARE(camera.lockStatus(QCamera::LockFocus), QCamera::Unlocked);
- QCOMPARE(camera.lockStatus(QCamera::LockWhiteBalance), QCamera::Unlocked);
-
- QSignalSpy lockedSignal(&camera, SIGNAL(locked()));
- QSignalSpy lockFailedSignal(&camera, SIGNAL(lockFailed()));
- QSignalSpy lockStatusChangedSignal(&camera, SIGNAL(lockStatusChanged(QCamera::LockStatus,QCamera::LockChangeReason)));
-
- camera.searchAndLock();
- QCOMPARE(camera.lockStatus(), QCamera::Unlocked);
- QCOMPARE(camera.lockStatus(QCamera::LockExposure), QCamera::Unlocked);
- QCOMPARE(camera.lockStatus(QCamera::LockFocus), QCamera::Unlocked);
- QCOMPARE(camera.lockStatus(QCamera::LockWhiteBalance), QCamera::Unlocked);
- QCOMPARE(lockedSignal.count(), 0);
- QCOMPARE(lockFailedSignal.count(), 0);
- QCOMPARE(lockStatusChangedSignal.count(), 0);
-
- lockedSignal.clear();
- lockFailedSignal.clear();
- lockStatusChangedSignal.clear();
-
- camera.unlock();
- QCOMPARE(camera.lockStatus(), QCamera::Unlocked);
- QCOMPARE(camera.lockStatus(QCamera::LockExposure), QCamera::Unlocked);
- QCOMPARE(camera.lockStatus(QCamera::LockFocus), QCamera::Unlocked);
- QCOMPARE(camera.lockStatus(QCamera::LockWhiteBalance), QCamera::Unlocked);
-
- QCOMPARE(lockedSignal.count(), 0);
- QCOMPARE(lockFailedSignal.count(), 0);
- QCOMPARE(lockStatusChangedSignal.count(), 0);
-}
-
-void tst_QCamera::testSimpleCaptureDestination()
-{
- provider->service = mockSimpleCameraService;
- QCamera camera;
- QCameraImageCapture imageCapture(&camera);
-
- QVERIFY(imageCapture.isCaptureDestinationSupported(QCameraImageCapture::CaptureToFile));
- QVERIFY(!imageCapture.isCaptureDestinationSupported(QCameraImageCapture::CaptureToBuffer));
- QVERIFY(!imageCapture.isCaptureDestinationSupported(
- QCameraImageCapture::CaptureToBuffer | QCameraImageCapture::CaptureToFile));
-
- QCOMPARE(imageCapture.captureDestination(), QCameraImageCapture::CaptureToFile);
- imageCapture.setCaptureDestination(QCameraImageCapture::CaptureToBuffer);
- QCOMPARE(imageCapture.captureDestination(), QCameraImageCapture::CaptureToFile);
-}
-
-void tst_QCamera::testSimpleCaptureFormat()
-{
- provider->service = mockSimpleCameraService;
- QCamera camera;
- QCameraImageCapture imageCapture(&camera);
-
- QCOMPARE(imageCapture.bufferFormat(), QVideoFrame::Format_Invalid);
- QVERIFY(imageCapture.supportedBufferFormats().isEmpty());
-
- imageCapture.setBufferFormat(QVideoFrame::Format_AdobeDng);
- QCOMPARE(imageCapture.bufferFormat(), QVideoFrame::Format_Invalid);
-}
-
-void tst_QCamera::testCaptureDestination()
-{
- QCamera camera;
- QCameraImageCapture imageCapture(&camera);
-
- QVERIFY(imageCapture.isCaptureDestinationSupported(QCameraImageCapture::CaptureToFile));
- QVERIFY(imageCapture.isCaptureDestinationSupported(QCameraImageCapture::CaptureToBuffer));
- QVERIFY(!imageCapture.isCaptureDestinationSupported(
- QCameraImageCapture::CaptureToBuffer | QCameraImageCapture::CaptureToFile));
-
- QSignalSpy destinationChangedSignal(&imageCapture, SIGNAL(captureDestinationChanged(QCameraImageCapture::CaptureDestinations)));
-
- QCOMPARE(imageCapture.captureDestination(), QCameraImageCapture::CaptureToFile);
- imageCapture.setCaptureDestination(QCameraImageCapture::CaptureToBuffer);
- QCOMPARE(imageCapture.captureDestination(), QCameraImageCapture::CaptureToBuffer);
- QCOMPARE(destinationChangedSignal.size(), 1);
- QCOMPARE(destinationChangedSignal.first().first().value<QCameraImageCapture::CaptureDestinations>(),
- QCameraImageCapture::CaptureToBuffer);
-
- //not supported combination
- imageCapture.setCaptureDestination(QCameraImageCapture::CaptureToBuffer | QCameraImageCapture::CaptureToFile);
- QCOMPARE(imageCapture.captureDestination(), QCameraImageCapture::CaptureToBuffer);
- QCOMPARE(destinationChangedSignal.size(), 1);
-}
-
-void tst_QCamera::testCaptureFormat()
-{
- QCamera camera;
- QCameraImageCapture imageCapture(&camera);
-
- QSignalSpy formatChangedSignal(&imageCapture, SIGNAL(bufferFormatChanged(QVideoFrame::PixelFormat)));
-
- QCOMPARE(imageCapture.bufferFormat(), QVideoFrame::Format_Jpeg);
- QCOMPARE(imageCapture.supportedBufferFormats().size(), 3);
-
- imageCapture.setBufferFormat(QVideoFrame::Format_AdobeDng);
- QCOMPARE(imageCapture.bufferFormat(), QVideoFrame::Format_AdobeDng);
-
- QCOMPARE(formatChangedSignal.size(), 1);
- QCOMPARE(formatChangedSignal.first().first().value<QVideoFrame::PixelFormat>(),
- QVideoFrame::Format_AdobeDng);
-
- imageCapture.setBufferFormat(QVideoFrame::Format_Y16);
- QCOMPARE(imageCapture.bufferFormat(), QVideoFrame::Format_AdobeDng);
-
- QCOMPARE(formatChangedSignal.size(), 1);
-}
-
-
-void tst_QCamera::testCameraCapture()
-{
- QCamera camera;
- QCameraImageCapture imageCapture(&camera);
-
- QVERIFY(!imageCapture.isReadyForCapture());
-
- QSignalSpy capturedSignal(&imageCapture, SIGNAL(imageCaptured(int,QImage)));
- QSignalSpy errorSignal(&imageCapture, SIGNAL(error(int,QCameraImageCapture::Error,QString)));
-
- imageCapture.capture(QString::fromLatin1("/dev/null"));
- QCOMPARE(capturedSignal.size(), 0);
- QCOMPARE(errorSignal.size(), 1);
- QCOMPARE(imageCapture.error(), QCameraImageCapture::NotReadyError);
-
- errorSignal.clear();
-
- camera.start();
- QVERIFY(imageCapture.isReadyForCapture());
- QCOMPARE(errorSignal.size(), 0);
-
- imageCapture.capture(QString::fromLatin1("/dev/null"));
-
- QTRY_COMPARE(capturedSignal.size(), 1);
- QCOMPARE(errorSignal.size(), 0);
- QCOMPARE(imageCapture.error(), QCameraImageCapture::NoError);
-}
-
-void tst_QCamera::testCameraCaptureMetadata()
-{
- QCamera camera;
- QCameraImageCapture imageCapture(&camera);
-
- QSignalSpy metadataSignal(&imageCapture, SIGNAL(imageMetadataAvailable(int,QString,QVariant)));
- QSignalSpy savedSignal(&imageCapture, SIGNAL(imageSaved(int,QString)));
-
- camera.start();
- int id = imageCapture.capture(QString::fromLatin1("/dev/null"));
-
- QTRY_COMPARE(savedSignal.size(), 1);
-
- QCOMPARE(metadataSignal.size(), 3);
-
- QVariantList metadata = metadataSignal[0];
- QCOMPARE(metadata[0].toInt(), id);
- QCOMPARE(metadata[1].toString(), QMediaMetaData::FocalLengthIn35mmFilm);
- QCOMPARE(metadata[2].value<QVariant>().toInt(), 50);
-
- metadata = metadataSignal[1];
- QCOMPARE(metadata[0].toInt(), id);
- QCOMPARE(metadata[1].toString(), QMediaMetaData::DateTimeOriginal);
- QDateTime captureTime = metadata[2].value<QVariant>().value<QDateTime>();
- const qint64 dt = captureTime.secsTo(QDateTime::currentDateTime());
- QVERIFY2(qAbs(dt) < 5, QByteArray::number(dt).constData()); // it should not take more than 5 seconds for signal to arrive here
-
- metadata = metadataSignal[2];
- QCOMPARE(metadata[0].toInt(), id);
- QCOMPARE(metadata[1].toString(), QLatin1String("Answer to the Ultimate Question of Life, the Universe, and Everything"));
- QCOMPARE(metadata[2].value<QVariant>().toInt(), 42);
-}
-
-
-void tst_QCamera::testCameraWhiteBalance()
-{
- QSet<QCameraImageProcessing::WhiteBalanceMode> whiteBalanceModes;
- whiteBalanceModes << QCameraImageProcessing::WhiteBalanceAuto;
- whiteBalanceModes << QCameraImageProcessing::WhiteBalanceFlash;
- whiteBalanceModes << QCameraImageProcessing::WhiteBalanceTungsten;
-
- MockCameraService service;
- service.mockImageProcessingControl->setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceFlash);
- service.mockImageProcessingControl->setSupportedWhiteBalanceModes(whiteBalanceModes);
- service.mockImageProcessingControl->setParameter(
- QCameraImageProcessingControl::ColorTemperature,
- QVariant(34));
-
- provider->service = &service;
-
- QCamera camera;
- QCameraImageProcessing *cameraImageProcessing = camera.imageProcessing();
-
- QCOMPARE(cameraImageProcessing->whiteBalanceMode(), QCameraImageProcessing::WhiteBalanceFlash);
- QVERIFY(camera.imageProcessing()->isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceAuto));
- QVERIFY(camera.imageProcessing()->isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceFlash));
- QVERIFY(camera.imageProcessing()->isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceTungsten));
- QVERIFY(!camera.imageProcessing()->isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceCloudy));
-
- cameraImageProcessing->setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceTungsten);
- QCOMPARE(cameraImageProcessing->whiteBalanceMode(), QCameraImageProcessing::WhiteBalanceTungsten);
-
- cameraImageProcessing->setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceManual);
- QCOMPARE(cameraImageProcessing->whiteBalanceMode(), QCameraImageProcessing::WhiteBalanceManual);
- QCOMPARE(cameraImageProcessing->manualWhiteBalance(), 34.0);
-
- cameraImageProcessing->setManualWhiteBalance(432.0);
- QCOMPARE(cameraImageProcessing->manualWhiteBalance(), 432.0);
-}
-
-void tst_QCamera::testCameraExposure()
-{
- QCamera camera;
-
- QCameraExposure *cameraExposure = camera.exposure();
- QVERIFY(cameraExposure != 0);
-
- QVERIFY(cameraExposure->isExposureModeSupported(QCameraExposure::ExposureAuto));
- QCOMPARE(cameraExposure->exposureMode(), QCameraExposure::ExposureAuto);
-
- // Test Cases For QCameraExposure
- QVERIFY(cameraExposure->isExposureModeSupported(QCameraExposure::ExposureManual));
- cameraExposure->setExposureMode(QCameraExposure::ExposureManual);
- QCOMPARE(cameraExposure->exposureMode(), QCameraExposure::ExposureManual);
-
- QVERIFY(cameraExposure->isExposureModeSupported(QCameraExposure::ExposureNight));
- cameraExposure->setExposureMode(QCameraExposure::ExposureNight);
- QCOMPARE(cameraExposure->exposureMode(), QCameraExposure::ExposureNight);
-
- QVERIFY(cameraExposure->isExposureModeSupported(QCameraExposure::ExposureBacklight));
- cameraExposure->setExposureMode(QCameraExposure::ExposureBacklight);
- QCOMPARE(cameraExposure->exposureMode(), QCameraExposure::ExposureBacklight);
-
-
- QVERIFY(cameraExposure->isExposureModeSupported(QCameraExposure::ExposureSpotlight ));
- cameraExposure->setExposureMode(QCameraExposure::ExposureSpotlight);
- QCOMPARE(cameraExposure->exposureMode(), QCameraExposure::ExposureSpotlight);
-
- QVERIFY(cameraExposure->isExposureModeSupported(QCameraExposure::ExposureSports ));
- cameraExposure->setExposureMode(QCameraExposure::ExposureSports);
- QCOMPARE(cameraExposure->exposureMode(), QCameraExposure::ExposureSports);
-
- QVERIFY(cameraExposure->isExposureModeSupported(QCameraExposure::ExposureSnow ));
- cameraExposure->setExposureMode(QCameraExposure::ExposureSnow);
- QCOMPARE(cameraExposure->exposureMode(), QCameraExposure::ExposureSnow);
-
- QVERIFY(cameraExposure->isExposureModeSupported(QCameraExposure::ExposureBeach ));
- cameraExposure->setExposureMode(QCameraExposure::ExposureBeach);
- QCOMPARE(cameraExposure->exposureMode(), QCameraExposure::ExposureBeach);
-
- QVERIFY(cameraExposure->isExposureModeSupported(QCameraExposure::ExposureLargeAperture ));
- cameraExposure->setExposureMode(QCameraExposure::ExposureLargeAperture);
- QCOMPARE(cameraExposure->exposureMode(), QCameraExposure::ExposureLargeAperture);
-
- QVERIFY(cameraExposure->isExposureModeSupported(QCameraExposure::ExposureSmallAperture ));
- cameraExposure->setExposureMode(QCameraExposure::ExposureSmallAperture);
- QCOMPARE(cameraExposure->exposureMode(), QCameraExposure::ExposureSmallAperture);
-
- QVERIFY(cameraExposure->isExposureModeSupported(QCameraExposure::ExposurePortrait ));
- cameraExposure->setExposureMode(QCameraExposure::ExposurePortrait);
- QCOMPARE(cameraExposure->exposureMode(), QCameraExposure::ExposurePortrait);
-
- QVERIFY(cameraExposure->isExposureModeSupported(QCameraExposure::ExposureModeVendor ));
- cameraExposure->setExposureMode(QCameraExposure::ExposureModeVendor);
- QCOMPARE(cameraExposure->exposureMode(), QCameraExposure::ExposureModeVendor);
-
-
- cameraExposure->setFlashMode(QCameraExposure::FlashAuto);
- QCOMPARE(cameraExposure->flashMode(), QCameraExposure::FlashAuto);
- QCOMPARE(cameraExposure->isFlashReady(), true);
- cameraExposure->setFlashMode(QCameraExposure::FlashRedEyeReduction);
- QCOMPARE(cameraExposure->flashMode(), QCameraExposure::FlashRedEyeReduction);
- cameraExposure->setFlashMode(QCameraExposure::FlashOn);
- QCOMPARE(cameraExposure->flashMode(), QCameraExposure::FlashOn);
- cameraExposure->setFlashMode(QCameraExposure::FlashFill);
- QCOMPARE(cameraExposure->flashMode(), QCameraExposure::FlashFill);
- cameraExposure->setFlashMode(QCameraExposure::FlashTorch);
- QCOMPARE(cameraExposure->flashMode(), QCameraExposure::FlashTorch);
- cameraExposure->setFlashMode(QCameraExposure::FlashSlowSyncFrontCurtain);
- QCOMPARE(cameraExposure->flashMode(), QCameraExposure::FlashSlowSyncFrontCurtain);
-
- QVERIFY(!cameraExposure->isMeteringModeSupported(QCameraExposure::MeteringAverage));
- QVERIFY(cameraExposure->isMeteringModeSupported(QCameraExposure::MeteringSpot));
- QVERIFY(cameraExposure->isMeteringModeSupported(QCameraExposure::MeteringMatrix));
-
- cameraExposure->setMeteringMode(QCameraExposure::MeteringMatrix);
- QCOMPARE(cameraExposure->meteringMode(), QCameraExposure::MeteringMatrix);
-
- //MeteringAverage is not supported, metering mode should not be changed
- cameraExposure->setMeteringMode(QCameraExposure::MeteringAverage);
- QCOMPARE(cameraExposure->meteringMode(), QCameraExposure::MeteringMatrix);
-
- cameraExposure->setMeteringMode(QCameraExposure::MeteringSpot);
- QCOMPARE(cameraExposure->meteringMode(), QCameraExposure::MeteringSpot);
-
- cameraExposure->setSpotMeteringPoint(QPointF(0.5f, 0.25f));
- QCOMPARE(cameraExposure->spotMeteringPoint(), QPointF(0.5f, 0.25f));
- cameraExposure->setSpotMeteringPoint(QPointF(0.25f, 56.3f));
- QCOMPARE(cameraExposure->spotMeteringPoint(), QPointF(0.5f, 0.25f));
- cameraExposure->setSpotMeteringPoint(QPointF(0, 0));
- QCOMPARE(cameraExposure->spotMeteringPoint(), QPointF(0, 0));
- cameraExposure->setSpotMeteringPoint(QPointF(1, 1));
- QCOMPARE(cameraExposure->spotMeteringPoint(), QPointF(1, 1));
-
- QCOMPARE(cameraExposure->exposureCompensation(), 0.0);
- cameraExposure->setExposureCompensation(2.0);
- QCOMPARE(cameraExposure->exposureCompensation(), 2.0);
-
- int minIso = cameraExposure->supportedIsoSensitivities().first();
- int maxIso = cameraExposure->supportedIsoSensitivities().last();
- QVERIFY(cameraExposure->isoSensitivity() > 0);
- QCOMPARE(cameraExposure->requestedIsoSensitivity(), -1);
- QVERIFY(minIso > 0);
- QVERIFY(maxIso > 0);
- cameraExposure->setManualIsoSensitivity(minIso);
- QCOMPARE(cameraExposure->isoSensitivity(), minIso);
- cameraExposure->setManualIsoSensitivity(maxIso*10);
- QCOMPARE(cameraExposure->isoSensitivity(), maxIso);
- QCOMPARE(cameraExposure->requestedIsoSensitivity(), maxIso*10);
-
- cameraExposure->setManualIsoSensitivity(-10);
- QCOMPARE(cameraExposure->isoSensitivity(), minIso);
- QCOMPARE(cameraExposure->requestedIsoSensitivity(), -10);
- cameraExposure->setAutoIsoSensitivity();
- QCOMPARE(cameraExposure->isoSensitivity(), 100);
- QCOMPARE(cameraExposure->requestedIsoSensitivity(), -1);
-
- QCOMPARE(cameraExposure->requestedAperture(), -1.0);
- qreal minAperture = cameraExposure->supportedApertures().first();
- qreal maxAperture = cameraExposure->supportedApertures().last();
- QVERIFY(minAperture > 0);
- QVERIFY(maxAperture > 0);
- QVERIFY(cameraExposure->aperture() >= minAperture);
- QVERIFY(cameraExposure->aperture() <= maxAperture);
-
- cameraExposure->setAutoAperture();
- QVERIFY(cameraExposure->aperture() >= minAperture);
- QVERIFY(cameraExposure->aperture() <= maxAperture);
- QCOMPARE(cameraExposure->requestedAperture(), -1.0);
-
- cameraExposure->setManualAperture(0);
- QCOMPARE(cameraExposure->aperture(), minAperture);
- QCOMPARE(cameraExposure->requestedAperture()+1.0, 1.0);
-
- cameraExposure->setManualAperture(10000);
- QCOMPARE(cameraExposure->aperture(), maxAperture);
- QCOMPARE(cameraExposure->requestedAperture(), 10000.0);
-
- cameraExposure->setAutoAperture();
- QCOMPARE(cameraExposure->requestedAperture(), -1.0);
-
- QCOMPARE(cameraExposure->requestedShutterSpeed(), -1.0);
- qreal minShutterSpeed = cameraExposure->supportedShutterSpeeds().first();
- qreal maxShutterSpeed = cameraExposure->supportedShutterSpeeds().last();
- QVERIFY(minShutterSpeed > 0);
- QVERIFY(maxShutterSpeed > 0);
- QVERIFY(cameraExposure->shutterSpeed() >= minShutterSpeed);
- QVERIFY(cameraExposure->shutterSpeed() <= maxShutterSpeed);
-
- cameraExposure->setAutoShutterSpeed();
- QVERIFY(cameraExposure->shutterSpeed() >= minShutterSpeed);
- QVERIFY(cameraExposure->shutterSpeed() <= maxShutterSpeed);
- QCOMPARE(cameraExposure->requestedShutterSpeed(), -1.0);
-
- cameraExposure->setManualShutterSpeed(0);
- QCOMPARE(cameraExposure->shutterSpeed(), minShutterSpeed);
- QCOMPARE(cameraExposure->requestedShutterSpeed()+1.0, 1.0);
-
- cameraExposure->setManualShutterSpeed(10000);
- QCOMPARE(cameraExposure->shutterSpeed(), maxShutterSpeed);
- QCOMPARE(cameraExposure->requestedShutterSpeed(), 10000.0);
-
- cameraExposure->setAutoShutterSpeed();
- QCOMPARE(cameraExposure->requestedShutterSpeed(), -1.0);
-}
-
-void tst_QCamera::testCameraFocus()
-{
- QCamera camera;
-
- QCameraFocus *cameraFocus = camera.focus();
- QVERIFY(cameraFocus != 0);
-
- QVERIFY(cameraFocus->isFocusModeSupported(QCameraFocus::AutoFocus));
- QVERIFY(cameraFocus->isFocusModeSupported(QCameraFocus::ContinuousFocus));
- QVERIFY(!cameraFocus->isFocusModeSupported(QCameraFocus::InfinityFocus));
-
- QCOMPARE(cameraFocus->focusMode(), QCameraFocus::AutoFocus);
- cameraFocus->setFocusMode(QCameraFocus::ManualFocus);
- QCOMPARE(cameraFocus->focusMode(), QCameraFocus::AutoFocus);
- cameraFocus->setFocusMode(QCameraFocus::ContinuousFocus);
- QCOMPARE(cameraFocus->focusMode(), QCameraFocus::ContinuousFocus);
-
- QVERIFY(cameraFocus->maximumOpticalZoom() >= 1.0);
- QVERIFY(cameraFocus->maximumDigitalZoom() >= 1.0);
- QCOMPARE(cameraFocus->opticalZoom(), 1.0);
- QCOMPARE(cameraFocus->digitalZoom(), 1.0);
- cameraFocus->zoomTo(0.5, 1.0);
- QCOMPARE(cameraFocus->opticalZoom(), 1.0);
- QCOMPARE(cameraFocus->digitalZoom(), 1.0);
- cameraFocus->zoomTo(2.0, 0.5);
- QCOMPARE(cameraFocus->opticalZoom(), 2.0);
- QCOMPARE(cameraFocus->digitalZoom(), 1.0);
- cameraFocus->zoomTo(2.0, 2.5);
- QCOMPARE(cameraFocus->opticalZoom(), 2.0);
- QCOMPARE(cameraFocus->digitalZoom(), 2.5);
- cameraFocus->zoomTo(2000000.0, 1000000.0);
- QVERIFY(qFuzzyCompare(cameraFocus->opticalZoom(), cameraFocus->maximumOpticalZoom()));
- QVERIFY(qFuzzyCompare(cameraFocus->digitalZoom(), cameraFocus->maximumDigitalZoom()));
-
- QVERIFY(cameraFocus->isFocusPointModeSupported(QCameraFocus::FocusPointAuto));
- QVERIFY(cameraFocus->isFocusPointModeSupported(QCameraFocus::FocusPointCenter));
- QVERIFY(cameraFocus->isFocusPointModeSupported(QCameraFocus::FocusPointCustom));
- QCOMPARE(cameraFocus->focusPointMode(), QCameraFocus::FocusPointAuto);
-
- cameraFocus->setFocusPointMode( QCameraFocus::FocusPointCenter );
- QCOMPARE(cameraFocus->focusPointMode(), QCameraFocus::FocusPointCenter);
-
- cameraFocus->setFocusPointMode( QCameraFocus::FocusPointFaceDetection );
- QCOMPARE(cameraFocus->focusPointMode(), QCameraFocus::FocusPointCenter);
-
- QCOMPARE(cameraFocus->customFocusPoint(), QPointF(0.5, 0.5));
- cameraFocus->setCustomFocusPoint(QPointF(1.0, 1.0));
- QCOMPARE(cameraFocus->customFocusPoint(), QPointF(1.0, 1.0));
-}
-
-void tst_QCamera::testImageSettings()
-{
- QImageEncoderSettings settings;
- QVERIFY(settings.isNull());
- QVERIFY(settings == QImageEncoderSettings());
-
- QCOMPARE(settings.codec(), QString());
- settings.setCodec(QLatin1String("codecName"));
- QCOMPARE(settings.codec(), QLatin1String("codecName"));
- QVERIFY(!settings.isNull());
- QVERIFY(settings != QImageEncoderSettings());
-
- settings = QImageEncoderSettings();
- QCOMPARE(settings.quality(), QMultimedia::NormalQuality);
- settings.setQuality(QMultimedia::HighQuality);
- QCOMPARE(settings.quality(), QMultimedia::HighQuality);
- QVERIFY(!settings.isNull());
-
- settings = QImageEncoderSettings();
- QCOMPARE(settings.resolution(), QSize());
- settings.setResolution(QSize(320,240));
- QCOMPARE(settings.resolution(), QSize(320,240));
- settings.setResolution(800,600);
- QCOMPARE(settings.resolution(), QSize(800,600));
- QVERIFY(!settings.isNull());
-
- settings = QImageEncoderSettings();
- settings.setEncodingOption(QLatin1String("encoderOption"), QVariant(1));
- QCOMPARE(settings.encodingOption(QLatin1String("encoderOption")), QVariant(1));
- QVariantMap options;
- options.insert(QLatin1String("encoderOption"), QVariant(1));
- QCOMPARE(settings.encodingOptions(), options);
- options.insert(QLatin1String("encoderOption2"), QVariant(2));
- options.remove(QLatin1String("encoderOption"));
- settings.setEncodingOptions(options);
- QCOMPARE(settings.encodingOption(QLatin1String("encoderOption")), QVariant());
- QCOMPARE(settings.encodingOption(QLatin1String("encoderOption2")), QVariant(2));
- QVERIFY(!settings.isNull());
- QVERIFY(settings != QImageEncoderSettings());
-
- settings = QImageEncoderSettings();
- QVERIFY(settings.isNull());
- QCOMPARE(settings.codec(), QString());
- QCOMPARE(settings.quality(), QMultimedia::NormalQuality);
- QCOMPARE(settings.resolution(), QSize());
- QVERIFY(settings.encodingOptions().isEmpty());
-
- {
- QImageEncoderSettings settings1;
- QImageEncoderSettings settings2;
- QCOMPARE(settings2, settings1);
-
- settings2 = settings1;
- QCOMPARE(settings2, settings1);
- QVERIFY(settings2.isNull());
-
- settings1.setQuality(QMultimedia::HighQuality);
-
- QVERIFY(settings2.isNull());
- QVERIFY(!settings1.isNull());
- QVERIFY(settings1 != settings2);
- }
-
- {
- QImageEncoderSettings settings1;
- QImageEncoderSettings settings2(settings1);
- QCOMPARE(settings2, settings1);
-
- settings2 = settings1;
- QCOMPARE(settings2, settings1);
- QVERIFY(settings2.isNull());
-
- settings1.setQuality(QMultimedia::HighQuality);
-
- QVERIFY(settings2.isNull());
- QVERIFY(!settings1.isNull());
- QVERIFY(settings1 != settings2);
- }
-
- QImageEncoderSettings settings1;
- QImageEncoderSettings settings2;
-
- settings1 = QImageEncoderSettings();
- settings1.setResolution(800,600);
- settings2 = QImageEncoderSettings();
- settings2.setResolution(QSize(800,600));
- QVERIFY(settings1 == settings2);
- settings2.setResolution(QSize(400,300));
- QVERIFY(settings1 != settings2);
-
- settings1 = QImageEncoderSettings();
- settings1.setCodec("codec1");
- settings2 = QImageEncoderSettings();
- settings2.setCodec("codec1");
- QVERIFY(settings1 == settings2);
- settings2.setCodec("codec2");
- QVERIFY(settings1 != settings2);
-
- settings1 = QImageEncoderSettings();
- settings1.setQuality(QMultimedia::NormalQuality);
- settings2 = QImageEncoderSettings();
- settings2.setQuality(QMultimedia::NormalQuality);
- QVERIFY(settings1 == settings2);
- settings2.setQuality(QMultimedia::LowQuality);
- QVERIFY(settings1 != settings2);
-
- settings1 = QImageEncoderSettings();
- settings1.setEncodingOption(QLatin1String("encoderOption"), QVariant(1));
- settings2 = QImageEncoderSettings();
- settings2.setEncodingOption(QLatin1String("encoderOption"), QVariant(1));
- QVERIFY(settings1 == settings2);
- settings2.setEncodingOption(QLatin1String("encoderOption"), QVariant(2));
- QVERIFY(settings1 != settings2);
-}
-
-void tst_QCamera::testViewfinderSettings()
-{
- QCameraViewfinderSettings settings;
- QVERIFY(settings.isNull());
- QVERIFY(settings == QCameraViewfinderSettings());
-
- QCOMPARE(settings.resolution(), QSize());
- settings.setResolution(QSize(640, 480));
- QCOMPARE(settings.resolution(), QSize(640, 480));
- settings.setResolution(1280, 720);
- QCOMPARE(settings.resolution(), QSize(1280, 720));
- QVERIFY(!settings.isNull());
- QVERIFY(settings != QCameraViewfinderSettings());
-
- settings = QCameraViewfinderSettings();
- QVERIFY(qFuzzyIsNull(settings.minimumFrameRate()));
- settings.setMinimumFrameRate(10.0);
- QVERIFY(qFuzzyCompare(settings.minimumFrameRate(), 10.0));
- QVERIFY(qFuzzyIsNull(settings.maximumFrameRate()));
- settings.setMaximumFrameRate(20.0);
- QVERIFY(qFuzzyCompare(settings.maximumFrameRate(), 20.0));
- QVERIFY(!settings.isNull());
-
- settings = QCameraViewfinderSettings();
- QCOMPARE(settings.pixelFormat(), QVideoFrame::Format_Invalid);
- settings.setPixelFormat(QVideoFrame::Format_RGB32);
- QCOMPARE(settings.pixelFormat(), QVideoFrame::Format_RGB32);
- QVERIFY(!settings.isNull());
-
- settings = QCameraViewfinderSettings();
- QCOMPARE(settings.pixelAspectRatio(), QSize());
- settings.setPixelAspectRatio(QSize(2, 1));
- QCOMPARE(settings.pixelAspectRatio(), QSize(2, 1));
- settings.setPixelAspectRatio(3, 2);
- QCOMPARE(settings.pixelAspectRatio(), QSize(3, 2));
- QVERIFY(!settings.isNull());
-
- settings = QCameraViewfinderSettings();
-
- {
- QCameraViewfinderSettings settings1;
- QCameraViewfinderSettings settings2;
- QCOMPARE(settings2, settings1);
-
- settings2 = settings1;
- QCOMPARE(settings2, settings1);
- QVERIFY(settings2.isNull());
-
- settings1.setResolution(800, 600);
-
- QVERIFY(settings2.isNull());
- QVERIFY(!settings1.isNull());
- QVERIFY(settings1 != settings2);
- }
-
- {
- QCameraViewfinderSettings settings1;
- QCameraViewfinderSettings settings2(settings1);
- QCOMPARE(settings2, settings1);
-
- settings2 = settings1;
- QCOMPARE(settings2, settings1);
- QVERIFY(settings2.isNull());
-
- settings1.setResolution(800, 600);
-
- QVERIFY(settings2.isNull());
- QVERIFY(!settings1.isNull());
- QVERIFY(settings1 != settings2);
- }
-
- QCameraViewfinderSettings settings1;
- QCameraViewfinderSettings settings2;
-
- settings1 = QCameraViewfinderSettings();
- settings1.setResolution(800,600);
- settings2 = QCameraViewfinderSettings();
- settings2.setResolution(QSize(800,600));
- QVERIFY(settings1 == settings2);
- settings2.setResolution(QSize(400,300));
- QVERIFY(settings1 != settings2);
-
- settings1 = QCameraViewfinderSettings();
- settings1.setMinimumFrameRate(10.0);
- settings2 = QCameraViewfinderSettings();
- settings2.setMinimumFrameRate(10.0);
- QVERIFY(settings1 == settings2);
- settings2.setMinimumFrameRate(15.0);
- QVERIFY(settings1 != settings2);
-
- settings1 = QCameraViewfinderSettings();
- settings1.setMaximumFrameRate(30.0);
- settings2 = QCameraViewfinderSettings();
- settings2.setMaximumFrameRate(30.0);
- QVERIFY(settings1 == settings2);
- settings2.setMaximumFrameRate(15.0);
- QVERIFY(settings1 != settings2);
-
- settings1 = QCameraViewfinderSettings();
- settings1.setPixelFormat(QVideoFrame::Format_YV12);
- settings2 = QCameraViewfinderSettings();
- settings2.setPixelFormat(QVideoFrame::Format_YV12);
- QVERIFY(settings1 == settings2);
- settings2.setPixelFormat(QVideoFrame::Format_NV21);
- QVERIFY(settings1 != settings2);
-
- settings1 = QCameraViewfinderSettings();
- settings1.setPixelAspectRatio(2,1);
- settings2 = QCameraViewfinderSettings();
- settings2.setPixelAspectRatio(QSize(2,1));
- QVERIFY(settings1 == settings2);
- settings2.setPixelAspectRatio(QSize(1,2));
- QVERIFY(settings1 != settings2);
-}
-
-void tst_QCamera::testViewfinderSettingsChange()
-{
- QCamera camera;
-
- QSignalSpy stateChangedSignal(&camera, SIGNAL(stateChanged(QCamera::State)));
- QSignalSpy statusChangedSignal(&camera, SIGNAL(statusChanged(QCamera::Status)));
-
- camera.start();
- QCOMPARE(camera.state(), QCamera::ActiveState);
- QCOMPARE(camera.status(), QCamera::ActiveStatus);
-
- QCOMPARE(stateChangedSignal.count(), 1);
- QCOMPARE(statusChangedSignal.count(), 1);
- stateChangedSignal.clear();
- statusChangedSignal.clear();
-
- //the settings change should trigger camera stop/start
- camera.setViewfinderSettings(QCameraViewfinderSettings());
- QCOMPARE(camera.state(), QCamera::ActiveState);
- QCOMPARE(camera.status(), QCamera::LoadedStatus);
-
- QCOMPARE(stateChangedSignal.count(), 0);
- QCOMPARE(statusChangedSignal.count(), 1);
- stateChangedSignal.clear();
- statusChangedSignal.clear();
-
- QCOMPARE(camera.state(), QCamera::ActiveState);
- QTRY_COMPARE(camera.status(), QCamera::ActiveStatus);
-
- QCOMPARE(stateChangedSignal.count(), 0);
- QCOMPARE(statusChangedSignal.count(), 1);
- stateChangedSignal.clear();
- statusChangedSignal.clear();
-
- //the settings change should trigger camera stop/start only once
- camera.setViewfinderSettings(QCameraViewfinderSettings());
- camera.setViewfinderSettings(QCameraViewfinderSettings());
-
- QCOMPARE(camera.state(), QCamera::ActiveState);
- QCOMPARE(camera.status(), QCamera::LoadedStatus);
-
- QCOMPARE(stateChangedSignal.count(), 0);
- QCOMPARE(statusChangedSignal.count(), 1);
- stateChangedSignal.clear();
- statusChangedSignal.clear();
-
- QCOMPARE(camera.state(), QCamera::ActiveState);
- QTRY_COMPARE(camera.status(), QCamera::ActiveStatus);
-
- QCOMPARE(stateChangedSignal.count(), 0);
- QCOMPARE(statusChangedSignal.count(), 1);
-}
-
-class ViewfinderSettingsBuilder
-{
-public:
- ViewfinderSettingsBuilder &setResolution(int width, int height) {
- m_settings.setResolution(width, height);
- return *this;
- }
-
- ViewfinderSettingsBuilder &setMinimumFrameRate(qreal r) {
- m_settings.setMinimumFrameRate(r);
- return *this;
- }
-
- ViewfinderSettingsBuilder &setMaximumFrameRate(qreal r) {
- m_settings.setMaximumFrameRate(r);
- return *this;
- }
-
- ViewfinderSettingsBuilder &setPixelFormat(QVideoFrame::PixelFormat f) {
- m_settings.setPixelFormat(f);
- return *this;
- }
-
- ViewfinderSettingsBuilder &setPixelAspectRatio(int h, int v) {
- m_settings.setPixelAspectRatio(h, v);
- return *this;
- }
-
- QCameraViewfinderSettings build() {
- QCameraViewfinderSettings s = m_settings;
- m_settings = QCameraViewfinderSettings();
- return s;
- }
-
-private:
- QCameraViewfinderSettings m_settings;
-};
-
-void tst_QCamera::testSupportedViewfinderSettings_data()
-{
- // see mockcameraviewfindersettingscontrol.h for expected values
-
- ViewfinderSettingsBuilder builder;
-
- QTest::addColumn<QCameraViewfinderSettings>("settings");
- QTest::addColumn< QList<int> >("expectedSupportedSettings");
-
- QTest::newRow("all supported settings") << QCameraViewfinderSettings()
- << (QList<int>() << 0 << 1 << 2 << 3 << 4 << 5);
-
- QTest::newRow("invalid resolution") << builder.setResolution(452472, 44453).build()
- << QList<int>();
-
- QTest::newRow("resolution (1)") << builder.setResolution(640, 480).build()
- << (QList<int>() << 0);
-
- QTest::newRow("resolution (2)") << builder.setResolution(1280, 720).build()
- << (QList<int>() << 1 << 3 << 4);
-
- QTest::newRow("invalid minimum frame rate") << builder.setMinimumFrameRate(2).build()
- << QList<int>();
-
- QTest::newRow("minimum frame rate (1)") << builder.setMinimumFrameRate(5).build()
- << (QList<int>() << 2);
-
- QTest::newRow("minimum frame rate (2)") << builder.setMinimumFrameRate(10).build()
- << (QList<int>() << 1 << 3);
-
- QTest::newRow("minimum frame rate (3)") << builder.setMinimumFrameRate(30).build()
- << (QList<int>() << 0 << 4 << 5);
-
- QTest::newRow("invalid maximum frame rate") << builder.setMaximumFrameRate(2).build()
- << QList<int>();
-
- QTest::newRow("maximum frame rate (1)") << builder.setMaximumFrameRate(10).build()
- << (QList<int>() << 1 << 2 << 3);
-
- QTest::newRow("maximum frame rate (2)") << builder.setMaximumFrameRate(30).build()
- << (QList<int>() << 0 << 4 << 5);
-
- QTest::newRow("invalid pixel format") << builder.setPixelFormat(QVideoFrame::Format_CameraRaw).build()
- << QList<int>();
-
- QTest::newRow("pixel format (1)") << builder.setPixelFormat(QVideoFrame::Format_BGR32).build()
- << (QList<int>() << 2);
-
- QTest::newRow("pixel format (2)") << builder.setPixelFormat(QVideoFrame::Format_YV12).build()
- << (QList<int>() << 3 << 4);
-
- QTest::newRow("pixel format (3)") << builder.setPixelFormat(QVideoFrame::Format_NV12).build()
- << (QList<int>() << 0 << 1 << 5);
-
- QTest::newRow("invalid pixel aspect ratio") << builder.setPixelAspectRatio(5, 3).build()
- << QList<int>();
-
- QTest::newRow("pixel aspect ratio (1)") << builder.setPixelAspectRatio(2, 1).build()
- << (QList<int>() << 2);
-
- QTest::newRow("pixel aspect ratio (2)") << builder.setPixelAspectRatio(1, 1).build()
- << (QList<int>() << 0 << 1 << 3 << 4 << 5);
-
- QTest::newRow("invalid multi settings") << builder.setResolution(640, 480)
- .setMinimumFrameRate(10)
- .setMaximumFrameRate(10)
- .build()
- << QList<int>();
-
- QTest::newRow("multi settings (1)") << builder.setResolution(640, 480)
- .setMinimumFrameRate(30)
- .setMaximumFrameRate(30)
- .build()
- << (QList<int>() << 0);
-
- QTest::newRow("multi settings (2)") << builder.setResolution(1280, 720)
- .setMinimumFrameRate(10)
- .setMaximumFrameRate(10)
- .build()
- << (QList<int>() << 1 << 3);
-
- QTest::newRow("multi settings (3)") << builder.setPixelFormat(QVideoFrame::Format_NV12)
- .setMinimumFrameRate(30)
- .build()
- << (QList<int>() << 0 << 5);
-
- QTest::newRow("multi settings (4)") << builder.setPixelAspectRatio(1, 1)
- .setMaximumFrameRate(10)
- .build()
- << (QList<int>() << 1 << 3);
-}
-
-void tst_QCamera::testSupportedViewfinderSettings()
-{
- QFETCH(QCameraViewfinderSettings, settings);
- QFETCH(QList<int>, expectedSupportedSettings);
-
- QList<QCameraViewfinderSettings> actualSupportedSettings = QCamera().supportedViewfinderSettings(settings);
- QCOMPARE(actualSupportedSettings.size(), expectedSupportedSettings.size());
- for (int i = 0; i < expectedSupportedSettings.size(); ++i) {
- QCameraViewfinderSettings expectedSettings = mockCameraService->mockViewfinderSettingsControl->supportedSettings.at(expectedSupportedSettings.at(i));
- QCOMPARE(actualSupportedSettings.at(i), expectedSettings);
- }
-}
-
-void tst_QCamera::testSupportedViewfinderResolutions_data()
-{
- // see mockcameraviewfindersettingscontrol.h for expected values
-
- typedef QList<QSize> SizeList;
- ViewfinderSettingsBuilder builder;
-
- QTest::addColumn<QCameraViewfinderSettings>("settings");
- QTest::addColumn<SizeList>("expectedResolutions");
-
- QTest::newRow("empty settings") << QCameraViewfinderSettings()
- << (SizeList() << QSize(320, 240)
- << QSize(640, 480)
- << QSize(1280, 720)
- << QSize(1920, 1080));
-
- QTest::newRow("invalid minimum frame rate") << builder.setMinimumFrameRate(2).build()
- << SizeList();
-
- QTest::newRow("minimum frame rate (1)") << builder.setMinimumFrameRate(5).build()
- << (SizeList() << QSize(1920, 1080));
-
- QTest::newRow("minimum frame rate (2)") << builder.setMinimumFrameRate(10).build()
- << (SizeList() << QSize(1280, 720));
-
- QTest::newRow("minimum frame rate (3)") << builder.setMinimumFrameRate(30).build()
- << (SizeList() << QSize(320, 240)
- << QSize(640, 480)
- << QSize(1280, 720));
-
- QTest::newRow("invalid maximum frame rate") << builder.setMaximumFrameRate(2).build()
- << SizeList();
-
- QTest::newRow("maximum frame rate") << builder.setMaximumFrameRate(10).build()
- << (SizeList() << QSize(1280, 720)
- << QSize(1920, 1080));
-
- QTest::newRow("invalid pixel format") << builder.setPixelFormat(QVideoFrame::Format_CameraRaw).build()
- << SizeList();
-
- QTest::newRow("pixel format (1)") << builder.setPixelFormat(QVideoFrame::Format_BGR32).build()
- << (SizeList() << QSize(1920, 1080));
-
- QTest::newRow("pixel format (2)") << builder.setPixelFormat(QVideoFrame::Format_YV12).build()
- << (SizeList() << QSize(1280, 720));
-
- QTest::newRow("pixel format (3)") << builder.setPixelFormat(QVideoFrame::Format_NV12).build()
- << (SizeList() << QSize(320, 240)
- << QSize(640, 480)
- << QSize(1280, 720));
-
- QTest::newRow("invalid pixel aspect ratio") << builder.setPixelAspectRatio(7, 2).build()
- << SizeList();
-
- QTest::newRow("pixel aspect ratio (1") << builder.setPixelAspectRatio(2, 1).build()
- << (SizeList() << QSize(1920, 1080));
-
- QTest::newRow("pixel aspect ratio (2") << builder.setPixelAspectRatio(1, 1).build()
- << (SizeList() << QSize(320, 240)
- << QSize(640, 480)
- << QSize(1280, 720));
-
- QTest::newRow("invalid multi settings (1)") << builder.setMinimumFrameRate(2)
- .setMaximumFrameRate(3)
- .build()
- << SizeList();
-
- QTest::newRow("invalid multi settings (2)") << builder.setMinimumFrameRate(5)
- .setMaximumFrameRate(11)
- .build()
- << SizeList();
-
- QTest::newRow("multi settings (1)") << builder.setMinimumFrameRate(10)
- .setMaximumFrameRate(10)
- .build()
- << (SizeList() << QSize(1280, 720));
-
- QTest::newRow("multi settings (2)") << builder.setMinimumFrameRate(30)
- .setMaximumFrameRate(30)
- .build()
- << (SizeList() << QSize(320, 240)
- << QSize(640, 480)
- << QSize(1280, 720));
-
- QTest::newRow("multi settings (3)") << builder.setPixelFormat(QVideoFrame::Format_NV12)
- .setMinimumFrameRate(30)
- .build()
- << (SizeList() << QSize(320, 240)
- << QSize(640, 480));
-
- QTest::newRow("multi settings (4)") << builder.setPixelAspectRatio(1, 1)
- .setMaximumFrameRate(10)
- .build()
- << (SizeList() << QSize(1280, 720));
-}
-
-void tst_QCamera::testSupportedViewfinderResolutions()
-{
- QFETCH(QCameraViewfinderSettings, settings);
- QFETCH(QList<QSize>, expectedResolutions);
-
- QList<QSize> actualResolutions = QCamera().supportedViewfinderResolutions(settings);
- QCOMPARE(actualResolutions.size(), expectedResolutions.size());
- for (int i = 0; i < actualResolutions.size(); ++i)
- QCOMPARE(actualResolutions.at(i), expectedResolutions.at(i));
-}
-
-void tst_QCamera::testSupportedViewfinderFrameRateRanges_data()
-{
- // see mockcameraviewfindersettingscontrol.h for expected values
-
- typedef QList<QCamera::FrameRateRange> RangeList;
- ViewfinderSettingsBuilder builder;
-
- QTest::addColumn<QCameraViewfinderSettings>("settings");
- QTest::addColumn<RangeList>("expectedFrameRateRanges");
-
- QTest::newRow("empty settings") << QCameraViewfinderSettings()
- << (RangeList() << QCamera::FrameRateRange(5, 10)
- << QCamera::FrameRateRange(10, 10)
- << QCamera::FrameRateRange(30, 30));
-
- QTest::newRow("invalid resolution") << builder.setResolution(452472, 444534).build()
- << RangeList();
-
- QTest::newRow("resolution (1)") << builder.setResolution(320, 240).build()
- << (RangeList() << QCamera::FrameRateRange(30, 30));
-
- QTest::newRow("resolution (2)") << builder.setResolution(1280, 720).build()
- << (RangeList() << QCamera::FrameRateRange(10, 10)
- << QCamera::FrameRateRange(30, 30));
-
- QTest::newRow("resolution (3)") << builder.setResolution(1920, 1080).build()
- << (RangeList() << QCamera::FrameRateRange(5, 10));
-
- QTest::newRow("invalid minimum frame rate") << builder.setMinimumFrameRate(2).build()
- << RangeList();
-
- QTest::newRow("minimum frame rate (1)") << builder.setMinimumFrameRate(5).build()
- << (RangeList() << QCamera::FrameRateRange(5, 10));
-
- QTest::newRow("minimum frame rate (2)") << builder.setMinimumFrameRate(10).build()
- << (RangeList() << QCamera::FrameRateRange(10, 10));
-
- QTest::newRow("invalid maximum frame rate") << builder.setMaximumFrameRate(2).build()
- << RangeList();
-
- QTest::newRow("maximum frame rate (1)") << builder.setMaximumFrameRate(10).build()
- << (RangeList() << QCamera::FrameRateRange(5, 10)
- << QCamera::FrameRateRange(10, 10));
-
- QTest::newRow("maximum frame rate (2)") << builder.setMaximumFrameRate(30).build()
- << (RangeList() << QCamera::FrameRateRange(30, 30));
-
- QTest::newRow("invalid pixel format") << builder.setPixelFormat(QVideoFrame::Format_IMC1).build()
- << RangeList();
-
- QTest::newRow("pixel format (1)") << builder.setPixelFormat(QVideoFrame::Format_BGR32).build()
- << (RangeList() << QCamera::FrameRateRange(5, 10));
-
- QTest::newRow("pixel format (2)") << builder.setPixelFormat(QVideoFrame::Format_NV12).build()
- << (RangeList() << QCamera::FrameRateRange(10, 10)
- << QCamera::FrameRateRange(30, 30));
-
- QTest::newRow("invalid pixel aspect ratio") << builder.setPixelAspectRatio(2, 3).build()
- << RangeList();
-
- QTest::newRow("pixel aspect ratio (1)") << builder.setPixelAspectRatio(2, 1).build()
- << (RangeList() << QCamera::FrameRateRange(5, 10));
-
- QTest::newRow("pixel aspect ratio (2)") << builder.setPixelAspectRatio(1, 1).build()
- << (RangeList() << QCamera::FrameRateRange(10, 10)
- << QCamera::FrameRateRange(30, 30));
-}
-
-void tst_QCamera::testSupportedViewfinderFrameRateRanges()
-{
- QFETCH(QCameraViewfinderSettings, settings);
- QFETCH(QList<QCamera::FrameRateRange>, expectedFrameRateRanges);
-
- QList<QCamera::FrameRateRange> actualFrameRateRanges = QCamera().supportedViewfinderFrameRateRanges(settings);
- QCOMPARE(actualFrameRateRanges.size(), expectedFrameRateRanges.size());
- for (int i = 0; i < actualFrameRateRanges.size(); ++i)
- QCOMPARE(actualFrameRateRanges.at(i), expectedFrameRateRanges.at(i));
-}
-
-void tst_QCamera::testSupportedViewfinderPixelFormats_data()
-{
- // see mockcameraviewfindersettingscontrol.h for expected values
-
- typedef QList<QVideoFrame::PixelFormat> FormatList;
- ViewfinderSettingsBuilder builder;
-
- QTest::addColumn<QCameraViewfinderSettings>("settings");
- QTest::addColumn<FormatList>("expectedPixelFormats");
-
- QTest::newRow("empty settings") << QCameraViewfinderSettings()
- << (FormatList() << QVideoFrame::Format_NV12
- << QVideoFrame::Format_BGR32
- << QVideoFrame::Format_YV12);
-
- QTest::newRow("invalid resolution") << builder.setResolution(452472, 444534).build()
- << FormatList();
-
- QTest::newRow("resolution (1)") << builder.setResolution(640, 480).build()
- << (FormatList() << QVideoFrame::Format_NV12);
-
- QTest::newRow("resolution (2)") << builder.setResolution(1280, 720).build()
- << (FormatList() << QVideoFrame::Format_NV12
- << QVideoFrame::Format_YV12);
-
- QTest::newRow("invalid minimum frame rate") << builder.setMinimumFrameRate(2).build()
- << FormatList();
-
- QTest::newRow("minimum frame rate (1)") << builder.setMinimumFrameRate(5).build()
- << (FormatList() << QVideoFrame::Format_BGR32);
-
- QTest::newRow("minimum frame rate (2)") << builder.setMinimumFrameRate(10).build()
- << (FormatList() << QVideoFrame::Format_NV12
- << QVideoFrame::Format_YV12);
-
- QTest::newRow("invalid maximum frame rate") << builder.setMaximumFrameRate(2).build()
- << FormatList();
-
- QTest::newRow("maximum frame rate (1)") << builder.setMaximumFrameRate(10).build()
- << (FormatList() << QVideoFrame::Format_NV12
- << QVideoFrame::Format_BGR32
- << QVideoFrame::Format_YV12);
-
- QTest::newRow("maximum frame rate (2)") << builder.setMinimumFrameRate(30).build()
- << (FormatList() << QVideoFrame::Format_NV12
- << QVideoFrame::Format_YV12);
-
- QTest::newRow("invalid pixel aspect ratio") << builder.setPixelAspectRatio(2, 3).build()
- << FormatList();
-
- QTest::newRow("pixel aspect ratio (1)") << builder.setPixelAspectRatio(2, 1).build()
- << (FormatList() << QVideoFrame::Format_BGR32);
-
- QTest::newRow("pixel aspect ratio (2)") << builder.setPixelAspectRatio(1, 1).build()
- << (FormatList() << QVideoFrame::Format_NV12
- << QVideoFrame::Format_YV12);
-}
-
-void tst_QCamera::testSupportedViewfinderPixelFormats()
-{
- QFETCH(QCameraViewfinderSettings, settings);
- QFETCH(QList<QVideoFrame::PixelFormat>, expectedPixelFormats);
-
- QList<QVideoFrame::PixelFormat> actualPixelFormats = QCamera().supportedViewfinderPixelFormats(settings);
- QCOMPARE(actualPixelFormats.size(), expectedPixelFormats.size());
- for (int i = 0; i < actualPixelFormats.size(); ++i)
- QCOMPARE(actualPixelFormats.at(i), expectedPixelFormats.at(i));
-}
-
-void tst_QCamera::testCameraLock()
-{
- QCamera camera;
-
- camera.focus()->setFocusMode(QCameraFocus::AutoFocus);
-
- QCOMPARE(camera.lockStatus(), QCamera::Unlocked);
-
- QSignalSpy lockedSignal(&camera, SIGNAL(locked()));
- QSignalSpy lockFailedSignal(&camera, SIGNAL(lockFailed()));
- QSignalSpy lockStatusChangedSignal(&camera, SIGNAL(lockStatusChanged(QCamera::LockStatus,QCamera::LockChangeReason)));
-
- camera.searchAndLock();
- QCOMPARE(camera.lockStatus(), QCamera::Searching);
- QCOMPARE(lockedSignal.count(), 0);
- QCOMPARE(lockFailedSignal.count(), 0);
- QCOMPARE(lockStatusChangedSignal.count(), 1);
-
- lockedSignal.clear();
- lockFailedSignal.clear();
- lockStatusChangedSignal.clear();
-
- QTRY_COMPARE(camera.lockStatus(), QCamera::Locked);
- QCOMPARE(lockedSignal.count(), 1);
- QCOMPARE(lockFailedSignal.count(), 0);
- QCOMPARE(lockStatusChangedSignal.count(), 1);
-
- lockedSignal.clear();
- lockFailedSignal.clear();
- lockStatusChangedSignal.clear();
-
- camera.searchAndLock();
- QCOMPARE(camera.lockStatus(), QCamera::Searching);
- QCOMPARE(lockedSignal.count(), 0);
- QCOMPARE(lockFailedSignal.count(), 0);
- QCOMPARE(lockStatusChangedSignal.count(), 1);
-
- lockedSignal.clear();
- lockFailedSignal.clear();
- lockStatusChangedSignal.clear();
-
- camera.unlock();
- QCOMPARE(camera.lockStatus(), QCamera::Unlocked);
- QCOMPARE(lockedSignal.count(), 0);
- QCOMPARE(lockFailedSignal.count(), 0);
- QCOMPARE(lockStatusChangedSignal.count(), 1);
-}
-
-void tst_QCamera::testCameraLockCancel()
-{
- MockCameraService service;
- provider->service = &service;
- QCamera camera;
-
- camera.focus()->setFocusMode(QCameraFocus::AutoFocus);
-
- QCOMPARE(camera.lockStatus(), QCamera::Unlocked);
-
- QSignalSpy lockedSignal(&camera, SIGNAL(locked()));
- QSignalSpy lockFailedSignal(&camera, SIGNAL(lockFailed()));
- QSignalSpy lockStatusChangedSignal(&camera, SIGNAL(lockStatusChanged(QCamera::LockStatus,QCamera::LockChangeReason)));
- camera.searchAndLock();
- QCOMPARE(camera.lockStatus(), QCamera::Searching);
- QCOMPARE(lockedSignal.count(), 0);
- QCOMPARE(lockFailedSignal.count(), 0);
- QCOMPARE(lockStatusChangedSignal.count(), 1);
-
- lockedSignal.clear();
- lockFailedSignal.clear();
- lockStatusChangedSignal.clear();
-
- camera.unlock();
- QCOMPARE(camera.lockStatus(), QCamera::Unlocked);
- QCOMPARE(lockedSignal.count(), 0);
- QCOMPARE(lockFailedSignal.count(), 0);
- QCOMPARE(lockStatusChangedSignal.count(), 1);
-}
-
-void tst_QCamera::testCameraEncodingProperyChange()
-{
- QCamera camera;
- QCameraImageCapture imageCapture(&camera);
-
- QSignalSpy stateChangedSignal(&camera, SIGNAL(stateChanged(QCamera::State)));
- QSignalSpy statusChangedSignal(&camera, SIGNAL(statusChanged(QCamera::Status)));
-
- camera.start();
- QCOMPARE(camera.state(), QCamera::ActiveState);
- QCOMPARE(camera.status(), QCamera::ActiveStatus);
-
- QCOMPARE(stateChangedSignal.count(), 1);
- QCOMPARE(statusChangedSignal.count(), 1);
- stateChangedSignal.clear();
- statusChangedSignal.clear();
-
-
- camera.setCaptureMode(QCamera::CaptureVideo);
- QCOMPARE(camera.state(), QCamera::ActiveState);
- QCOMPARE(camera.status(), QCamera::LoadedStatus);
-
- QCOMPARE(stateChangedSignal.count(), 0);
- QCOMPARE(statusChangedSignal.count(), 1);
- stateChangedSignal.clear();
- statusChangedSignal.clear();
-
- QCOMPARE(camera.state(), QCamera::ActiveState);
- QTRY_COMPARE(camera.status(), QCamera::ActiveStatus);
-
- QCOMPARE(stateChangedSignal.count(), 0);
- QCOMPARE(statusChangedSignal.count(), 1);
- stateChangedSignal.clear();
- statusChangedSignal.clear();
-
- //backens should not be stopped since the capture mode is Video
- imageCapture.setEncodingSettings(QImageEncoderSettings());
- QCOMPARE(stateChangedSignal.count(), 0);
- QCOMPARE(statusChangedSignal.count(), 0);
-
- camera.setCaptureMode(QCamera::CaptureStillImage);
-
- QCOMPARE(camera.state(), QCamera::ActiveState);
- QTRY_COMPARE(camera.status(), QCamera::ActiveStatus);
-
- stateChangedSignal.clear();
- statusChangedSignal.clear();
-
- //the settings change should trigger camera stop/start
- imageCapture.setEncodingSettings(QImageEncoderSettings());
- QCOMPARE(camera.state(), QCamera::ActiveState);
- QCOMPARE(camera.status(), QCamera::LoadedStatus);
-
- QCOMPARE(stateChangedSignal.count(), 0);
- QCOMPARE(statusChangedSignal.count(), 1);
- stateChangedSignal.clear();
- statusChangedSignal.clear();
-
- QCOMPARE(camera.state(), QCamera::ActiveState);
- QTRY_COMPARE(camera.status(), QCamera::ActiveStatus);
-
- QCOMPARE(stateChangedSignal.count(), 0);
- QCOMPARE(statusChangedSignal.count(), 1);
- stateChangedSignal.clear();
- statusChangedSignal.clear();
-
- //the settings change should trigger camera stop/start only once
- camera.setCaptureMode(QCamera::CaptureVideo);
- camera.setCaptureMode(QCamera::CaptureStillImage);
- imageCapture.setEncodingSettings(QImageEncoderSettings());
- imageCapture.setEncodingSettings(QImageEncoderSettings());
-
- QCOMPARE(camera.state(), QCamera::ActiveState);
- QCOMPARE(camera.status(), QCamera::LoadedStatus);
-
- QCOMPARE(stateChangedSignal.count(), 0);
- QCOMPARE(statusChangedSignal.count(), 1);
- stateChangedSignal.clear();
- statusChangedSignal.clear();
-
- QCOMPARE(camera.state(), QCamera::ActiveState);
- QTRY_COMPARE(camera.status(), QCamera::ActiveStatus);
-
- QCOMPARE(stateChangedSignal.count(), 0);
- QCOMPARE(statusChangedSignal.count(), 1);
-}
-
-void tst_QCamera::testSetVideoOutput()
-{
- MockVideoSurface surface;
- QCamera camera;
-
- camera.setViewfinder(reinterpret_cast<QVideoWidget *>(0));
-
- camera.setViewfinder(reinterpret_cast<QGraphicsVideoItem *>(0));
-
- QCOMPARE(mockCameraService->rendererRef, 0);
-
- camera.setViewfinder(&surface);
- QVERIFY(mockCameraService->rendererControl->surface() == &surface);
- QCOMPARE(mockCameraService->rendererRef, 1);
-
- camera.setViewfinder(reinterpret_cast<QAbstractVideoSurface *>(0));
- QVERIFY(mockCameraService->rendererControl->surface() == 0);
-
- //rendererControl is released
- QCOMPARE(mockCameraService->rendererRef, 0);
-
- camera.setViewfinder(&surface);
- QVERIFY(mockCameraService->rendererControl->surface() == &surface);
- QCOMPARE(mockCameraService->rendererRef, 1);
-
- camera.setViewfinder(reinterpret_cast<QVideoWidget *>(0));
- QVERIFY(mockCameraService->rendererControl->surface() == 0);
- //rendererControl is released
- QCOMPARE(mockCameraService->rendererRef, 0);
-
- camera.setViewfinder(&surface);
- QVERIFY(mockCameraService->rendererControl->surface() == &surface);
- QCOMPARE(mockCameraService->rendererRef, 1);
-}
-
-
-void tst_QCamera::testSetVideoOutputNoService()
-{
- MockVideoSurface surface;
-
- provider->service = 0;
- QCamera camera;
-
- camera.setViewfinder(&surface);
- // Nothing we can verify here other than it doesn't assert.
-}
-
-void tst_QCamera::testSetVideoOutputNoControl()
-{
- MockVideoSurface surface;
-
- MockCameraService service;
- service.rendererRef = 1;
- provider->service = &service;
-
- QCamera camera;
-
- camera.setViewfinder(&surface);
- QVERIFY(service.rendererControl->surface() == 0);
-}
-
-void tst_QCamera::testSetVideoOutputDestruction()
-{
- MockVideoSurface surface;
- MockCameraService service;
- provider->service = &service;
-
- {
- QCamera camera;
- camera.setViewfinder(&surface);
- QVERIFY(service.rendererControl->surface() == &surface);
- QCOMPARE(service.rendererRef, 1);
- }
- QVERIFY(service.rendererControl->surface() == 0);
- QCOMPARE(service.rendererRef, 0);
-}
-
-void tst_QCamera::testEnumDebug()
-{
- QTest::ignoreMessage(QtDebugMsg, "QCamera::ActiveState");
- qDebug() << QCamera::ActiveState;
- QTest::ignoreMessage(QtDebugMsg, "QCamera::ActiveStatus");
- qDebug() << QCamera::ActiveStatus;
- QTest::ignoreMessage(QtDebugMsg, "QCamera::CaptureVideo");
- qDebug() << QCamera::CaptureVideo;
- QTest::ignoreMessage(QtDebugMsg, "QCamera::CameraError");
- qDebug() << QCamera::CameraError;
- QTest::ignoreMessage(QtDebugMsg, "QCamera::Unlocked");
- qDebug() << QCamera::Unlocked;
- QTest::ignoreMessage(QtDebugMsg, "QCamera::LockAcquired");
- qDebug() << QCamera::LockAcquired;
- QTest::ignoreMessage(QtDebugMsg, "QCamera::NoLock");
- qDebug() << QCamera::NoLock;
- QTest::ignoreMessage(QtDebugMsg, "QCamera::LockExposure");
- qDebug() << QCamera::LockExposure;
- QTest::ignoreMessage(QtDebugMsg, "QCamera::FrontFace ");
- qDebug() << QCamera::FrontFace;
-}
-
-void tst_QCamera::testCameraControl()
-{
- MockCameraControl *m_cameraControl=new MockCameraControl(this);
- QVERIFY(m_cameraControl != NULL);
-}
-
-void tst_QCamera::testConstructor()
-{
- // Service doesn't implement QVideoDeviceSelectorControl
- provider->service = mockSimpleCameraService;
-
- {
- QCamera camera;
- QCOMPARE(camera.availability(), QMultimedia::Available);
- QCOMPARE(camera.error(), QCamera::NoError);
- }
-
- {
- // Requesting a camera at a specific position from a service which doesn't implement
- // the QVideoDeviceSelectorControl should result in loading the default camera
- QCamera camera(QCamera::FrontFace);
- QCOMPARE(camera.availability(), QMultimedia::Available);
- QCOMPARE(camera.error(), QCamera::NoError);
- }
-
- // Service implements QVideoDeviceSelectorControl
- provider->service = mockCameraService;
-
- {
- QCamera camera;
- QCOMPARE(camera.availability(), QMultimedia::Available);
- QCOMPARE(camera.error(), QCamera::NoError);
- QCOMPARE(mockCameraService->mockVideoDeviceSelectorControl->selectedDevice(), 1); // default is 1
- }
-
- {
- QCamera camera(QCameraInfo::defaultCamera());
- QCOMPARE(camera.availability(), QMultimedia::Available);
- QCOMPARE(camera.error(), QCamera::NoError);
- QCOMPARE(mockCameraService->mockVideoDeviceSelectorControl->selectedDevice(), 1);
- QCOMPARE(QCameraInfo(camera), QCameraInfo::defaultCamera());
- }
-
- {
- QCameraInfo cameraInfo = QCameraInfo::availableCameras().at(0);
- QCamera camera(cameraInfo);
- QCOMPARE(camera.availability(), QMultimedia::Available);
- QCOMPARE(camera.error(), QCamera::NoError);
- QCOMPARE(mockCameraService->mockVideoDeviceSelectorControl->selectedDevice(), 0);
- QCOMPARE(QCameraInfo(camera), cameraInfo);
- }
-
- {
- // Requesting a camera at a position which is not available should result in
- // loading the default camera
- QCamera camera(QCamera::FrontFace);
- QCOMPARE(camera.availability(), QMultimedia::Available);
- QCOMPARE(camera.error(), QCamera::NoError);
- QCOMPARE(mockCameraService->mockVideoDeviceSelectorControl->selectedDevice(), 1);
- }
-
- {
- QCamera camera(QCamera::BackFace);
- QCOMPARE(camera.availability(), QMultimedia::Available);
- QCOMPARE(camera.error(), QCamera::NoError);
- QCOMPARE(mockCameraService->mockVideoDeviceSelectorControl->selectedDevice(), 0);
- }
-
- {
- // Should load the default camera when UnspecifiedPosition is requested
- QCamera camera(QCamera::UnspecifiedPosition);
- QCOMPARE(camera.availability(), QMultimedia::Available);
- QCOMPARE(camera.error(), QCamera::NoError);
- QCOMPARE(mockCameraService->mockVideoDeviceSelectorControl->selectedDevice(), 1);
- }
-}
-
-/* captureModeChanged Signal test case. */
-void tst_QCamera::testCaptureModeChanged_signal()
-{
- MockCameraControl *m_cameraControl= new MockCameraControl(this);
- QSignalSpy spy(m_cameraControl, SIGNAL(captureModeChanged(QCamera::CaptureModes)));
- QVERIFY(spy.size() == 0);
-
- m_cameraControl->setCaptureMode(QCamera::CaptureVideo);
- QVERIFY(spy.size() == 1);
-
- m_cameraControl->setCaptureMode(QCamera::CaptureStillImage);
- QVERIFY(spy.size() == 2);
-}
-
-/* Test case for captureMode */
-void tst_QCamera::testCaptureMode()
-{
- QCamera camera;
- QVERIFY(camera.captureMode() == QCamera::CaptureStillImage);
-
- camera.setCaptureMode(QCamera::CaptureVideo);
- QVERIFY(camera.captureMode() == QCamera::CaptureVideo);
-}
-
-/* Test case for isCaptureModeSupported */
-void tst_QCamera::testIsCaptureModeSupported()
-{
- QCamera camera;
- QVERIFY(camera.isCaptureModeSupported(QCamera::CaptureStillImage) == true);
- QVERIFY(camera.isCaptureModeSupported(QCamera::CaptureVideo) == true);
-}
-
-/* Test case for requestedLocks. LockType is stored in OR combination so all
- types of combinations are verified here.*/
-void tst_QCamera::testRequestedLocks()
-{
- QCamera camera;
-
- QCOMPARE(camera.requestedLocks(),QCamera::NoLock);
-
- camera.searchAndLock(QCamera::LockExposure);
- QCOMPARE(camera.requestedLocks(),QCamera::LockExposure);
-
- camera.unlock();
- camera.searchAndLock(QCamera::LockFocus);
- QCOMPARE(camera.requestedLocks(),QCamera::LockFocus );
-
- camera.unlock();
- camera.searchAndLock(QCamera::LockWhiteBalance);
- QCOMPARE(camera.requestedLocks(),QCamera::NoLock);
-
- camera.unlock();
- camera.searchAndLock(QCamera::LockExposure |QCamera::LockFocus );
- QCOMPARE(camera.requestedLocks(),QCamera::LockExposure |QCamera::LockFocus );
- camera.searchAndLock(QCamera::LockWhiteBalance);
- QCOMPARE(camera.requestedLocks(),QCamera::LockExposure |QCamera::LockFocus);
- camera.unlock(QCamera::LockExposure);
- QCOMPARE(camera.requestedLocks(),QCamera::LockFocus);
- camera.unlock(QCamera::LockFocus);
- camera.searchAndLock(QCamera::LockExposure |QCamera::LockWhiteBalance );
- QCOMPARE(camera.requestedLocks(),QCamera::LockExposure);
-}
-
-/* Test case for supportedLocks() */
-void tst_QCamera::testSupportedLocks()
-{
- QCamera camera;
-
- QCOMPARE(camera.supportedLocks(),QCamera::LockExposure | QCamera::LockFocus);
-}
-
-/* Test case for isAvailable */
-void tst_QCamera::testQCameraIsAvailable()
-{
- QCamera camera;
- QVERIFY(camera.isAvailable());
- QVERIFY(camera.availability() == QMultimedia::Available);
-}
-
-void tst_QCamera::testQCameraIsNotAvailable()
-{
- provider->service = 0;
- QCamera camera("random");
-
- QCOMPARE(camera.error(), QCamera::ServiceMissingError);
- QVERIFY(!camera.isAvailable());
- QCOMPARE(camera.availability(), QMultimedia::ServiceMissing);
-}
-
-/* Test case for searchAndLock ( QCamera::LockTypes locks ) */
-void tst_QCamera::testSearchAndLockWithLockTypes()
-{
- QCamera camera;
-
- QCOMPARE(camera.lockStatus(), QCamera::Unlocked);
-
- /* Spy the signals */
- QSignalSpy lockedSignal(&camera, SIGNAL(locked()));
- QSignalSpy lockFailedSignal(&camera, SIGNAL(lockFailed()));
- QSignalSpy lockStatusChangedSignal(&camera, SIGNAL(lockStatusChanged(QCamera::LockStatus,QCamera::LockChangeReason)));
- QSignalSpy lockStatusChangedSignalWithType(&camera, SIGNAL(lockStatusChanged(QCamera::LockType,QCamera::LockStatus,QCamera::LockChangeReason)));
-
- /* search and lock the camera with QCamera::LockExposure and verify if the signal is emitted correctly */
- camera.searchAndLock(QCamera::LockExposure);
- QCOMPARE(camera.lockStatus(), QCamera::Locked);
- QCOMPARE(lockedSignal.count(), 1);
- QCOMPARE(lockFailedSignal.count(), 0);
- QCOMPARE(lockStatusChangedSignal.count(), 1);
- QCOMPARE(lockStatusChangedSignalWithType.count(), 1);
-}
-
-/* Test case for setCaptureMode() */
-void tst_QCamera::testSetCaptureMode()
-{
- QCamera camera;
-
- /* Set the capture mode and verify if it set correctly */
- camera.setCaptureMode(QCamera::CaptureVideo);
- QVERIFY(camera.captureMode() == QCamera::CaptureVideo);
-
- camera.setCaptureMode(QCamera::CaptureStillImage);
- QVERIFY(camera.captureMode() == QCamera::CaptureStillImage);
-}
-
-/* Test case for unlock (QCamera::LockTypes) */
-void tst_QCamera::testUnlockWithType()
-{
- QCamera camera;
-
- QCOMPARE(camera.lockStatus(), QCamera::Unlocked);
-
- /* Spy the signal */
- QSignalSpy lockedSignal(&camera, SIGNAL(locked()));
- QSignalSpy lockFailedSignal(&camera, SIGNAL(lockFailed()));
- QSignalSpy lockStatusChangedSignal(&camera, SIGNAL(lockStatusChanged(QCamera::LockStatus,QCamera::LockChangeReason)));
- QSignalSpy lockStatusChangedSignalWithType(&camera, SIGNAL(lockStatusChanged(QCamera::LockType,QCamera::LockStatus,QCamera::LockChangeReason)));
-
- /* lock the camera with QCamera::LockExposure and Verify if the signal is emitted correctly */
- camera.searchAndLock(QCamera::LockExposure);
- QCOMPARE(camera.lockStatus(), QCamera::Locked);
- QCOMPARE(lockedSignal.count(), 1);
- QCOMPARE(lockFailedSignal.count(), 0);
- QCOMPARE(lockStatusChangedSignal.count(), 1);
- QCOMPARE(lockStatusChangedSignalWithType.count(), 1);
-
- /* Clear the signal */
- lockedSignal.clear();
- lockFailedSignal.clear();
- lockStatusChangedSignal.clear();
- lockStatusChangedSignalWithType.clear();
-
- /* Unlock the camera and verify if the signal is emitted correctly */
- camera.unlock(QCamera::LockExposure);
- QCOMPARE(camera.lockStatus(), QCamera::Unlocked);
- QCOMPARE(lockedSignal.count(), 0);
- QCOMPARE(lockFailedSignal.count(), 0);
- QCOMPARE(lockStatusChangedSignal.count(), 1);
- QCOMPARE(lockStatusChangedSignalWithType.count(), 1);
- QCamera::LockType lockType = qvariant_cast<QCamera::LockType >(lockStatusChangedSignalWithType.at(0).at(0));
- QCamera::LockStatus lockStatus = qvariant_cast<QCamera::LockStatus >(lockStatusChangedSignalWithType.at(0).at(1));
- QVERIFY(lockType == QCamera::LockExposure);
- QVERIFY(lockStatus == QCamera::Unlocked);
-
- lockedSignal.clear();
- lockFailedSignal.clear();
- lockStatusChangedSignal.clear();
- lockStatusChangedSignalWithType.clear();
-
- /* Lock the camera with QCamera::LockFocus */
- camera.searchAndLock(QCamera::LockFocus);
- lockedSignal.clear();
- lockFailedSignal.clear();
- lockStatusChangedSignal.clear();
- lockStatusChangedSignalWithType.clear();
-
- /* Unlock the camera and Verify if the signal is emitted correctly */
- camera.unlock(QCamera::LockFocus);
- QCOMPARE(camera.lockStatus(), QCamera::Unlocked);
- QCOMPARE(lockedSignal.count(), 0);
- QCOMPARE(lockFailedSignal.count(), 0);
- QCOMPARE(lockStatusChangedSignal.count(), 1);
- QCOMPARE(lockStatusChangedSignalWithType.count(), 1);
- lockType = qvariant_cast<QCamera::LockType >(lockStatusChangedSignalWithType.at(0).at(0));
- lockStatus = qvariant_cast<QCamera::LockStatus >(lockStatusChangedSignalWithType.at(0).at(1));
- QVERIFY(lockType == QCamera::LockFocus);
- QVERIFY(lockStatus == QCamera::Unlocked);
-}
-
-/* Test case for signal captureModeChanged(QCamera::CaptureModes) */
-void tst_QCamera::testCaptureModeChangedSignal()
-{
- QCamera camera;
- QVERIFY(camera.captureMode() == QCamera::CaptureStillImage);
-
- qRegisterMetaType<QCamera::CaptureModes>("QCamera::CaptureModes");
-
- /* Spy the signal */
- QSignalSpy lockCaptureModeChangedSignal(&camera, SIGNAL(captureModeChanged(QCamera::CaptureModes)));
-
- /* set the capture mode and Verify if the signal is emitted */
- camera.setCaptureMode(QCamera::CaptureVideo);
- QVERIFY(camera.captureMode() == QCamera::CaptureVideo);
- QCOMPARE(lockCaptureModeChangedSignal.count(), 1);
- QCamera::CaptureModes lockCaptureMode = qvariant_cast<QCamera::CaptureModes >(lockCaptureModeChangedSignal.at(0).at(0));
- QVERIFY(lockCaptureMode == QCamera::CaptureVideo);
-}
-
-/* Test case for signal lockStatusChanged(QCamera::LockType,QCamera::LockStatus, QCamera::LockChangeReason) */
-void tst_QCamera::testLockStatusChangedWithTypesSignal()
-{
- QCamera camera;
-
- QCOMPARE(camera.lockStatus(), QCamera::Unlocked);
-
- /* Spy the signal lockStatusChanged(QCamera::LockType,QCamera::LockStatus, QCamera::LockChangeReason) */
- QSignalSpy lockStatusChangedSignalWithType(&camera, SIGNAL(lockStatusChanged(QCamera::LockType,QCamera::LockStatus,QCamera::LockChangeReason)));
-
- /* Lock the camera with type QCamera::LockExposure */
- camera.searchAndLock(QCamera::LockExposure);
-
- /* Verify if the signal is emitted and lock status is set correclty */
- QCOMPARE(camera.lockStatus(), QCamera::Locked);
- QCOMPARE(lockStatusChangedSignalWithType.count(), 1);
- QCamera::LockType lockType = qvariant_cast<QCamera::LockType >(lockStatusChangedSignalWithType.at(0).at(0));
- QCamera::LockStatus lockStatus = qvariant_cast<QCamera::LockStatus >(lockStatusChangedSignalWithType.at(0).at(1));
- QVERIFY(lockType == QCamera::LockExposure);
- QVERIFY(lockStatus == QCamera::Locked);
-
- lockStatusChangedSignalWithType.clear();
-
- /* Unlock the camera */
- camera.unlock();
-
- /* Verify if the signal is emitted and lock status is set correclty */
- QCOMPARE(camera.lockStatus(), QCamera::Unlocked);
- QCOMPARE(lockStatusChangedSignalWithType.count(), 1);
- lockType = qvariant_cast<QCamera::LockType >(lockStatusChangedSignalWithType.at(0).at(0));
- lockStatus = qvariant_cast<QCamera::LockStatus >(lockStatusChangedSignalWithType.at(0).at(1));
- QVERIFY(lockType == QCamera::LockExposure);
- QVERIFY(lockStatus == QCamera::Unlocked);
-}
-
-/* Test case for verifying if error signal generated correctly */
-void tst_QCamera::testErrorSignal()
-{
- MockCameraService service;
- provider->service = &service;
-
- QCamera camera;
-
- QSignalSpy spyError(&camera, SIGNAL(errorOccurred(QCamera::Error)));
-
- /* Set the QCameraControl error and verify if the signal is emitted correctly in QCamera */
- service.mockControl->setError(QCamera::CameraError,QString("Camera Error"));
-
- QVERIFY(spyError.count() == 1);
- QCamera::Error err = qvariant_cast<QCamera::Error >(spyError.at(0).at(0));
- QVERIFY(err == QCamera::CameraError);
-
- spyError.clear();
-
- /* Set the QCameraControl error and verify if the signal is emitted correctly in QCamera */
- service.mockControl->setError(QCamera::InvalidRequestError,QString("InvalidRequestError Error"));
- QVERIFY(spyError.count() == 1);
- err = qvariant_cast<QCamera::Error >(spyError.at(0).at(0));
- QVERIFY(err == QCamera::InvalidRequestError);
-
- spyError.clear();
-
- /* Set the QCameraControl error and verify if the signal is emitted correctly in QCamera */
- service.mockControl->setError(QCamera::NotSupportedFeatureError,QString("NotSupportedFeatureError Error"));
- QVERIFY(spyError.count() == 1);
- err = qvariant_cast<QCamera::Error >(spyError.at(0).at(0));
- QVERIFY(err == QCamera::NotSupportedFeatureError);
-
-}
-
-/* Test case for verifying the QCamera error */
-void tst_QCamera::testError()
-{
- MockCameraService service;
- provider->service = &service;
-
- QCamera camera;
-
- /* Set the QCameraControl error and verify if it is set correctly in QCamera */
- service.mockControl->setError(QCamera::CameraError,QString("Camera Error"));
- QVERIFY(camera.error() == QCamera::CameraError);
-
- /* Set the QCameraControl error and verify if it is set correctly in QCamera */
- service.mockControl->setError(QCamera::InvalidRequestError,QString("InvalidRequestError Error"));
- QVERIFY(camera.error() == QCamera::InvalidRequestError);
-
- /* Set the QCameraControl error and verify if it is set correctly in QCamera */
- service.mockControl->setError(QCamera::NotSupportedFeatureError,QString("NotSupportedFeatureError Error"));
- QVERIFY(camera.error() == QCamera::NotSupportedFeatureError);
-
-}
-
-/* Test the error strings for QCamera class */
-void tst_QCamera::testErrorString()
-{
- MockCameraService service;
- provider->service = &service;
-
- QCamera camera;
-
- /* Set the QCameraControl error and verify if it is set correctly in QCamera */
- service.mockControl->setError(QCamera::CameraError,QString("Camera Error"));
- QVERIFY(camera.errorString() == QString("Camera Error"));
-
- /* Set the QCameraControl error and verify if it is set correctly in QCamera */
- service.mockControl->setError(QCamera::InvalidRequestError,QString("InvalidRequestError Error"));
- QVERIFY(camera.errorString() == QString("InvalidRequestError Error"));
-
- /* Set the QCameraControl error and verify if it is set correctly in QCamera */
- service.mockControl->setError(QCamera::NotSupportedFeatureError,QString("NotSupportedFeatureError Error"));
- QVERIFY(camera.errorString() == QString("NotSupportedFeatureError Error"));
-}
-
-/* Test case for verifying Status of QCamera. */
-void tst_QCamera::testStatus()
-{
- MockCameraService service;
- provider->service = &service;
-
- QCamera camera;
-
- /* Set the QCameraControl status and verify if it is set correctly in QCamera */
- service.mockControl->setStatus(QCamera::StartingStatus);
- QVERIFY(camera.status() == QCamera::StartingStatus);
-
- /* Set the QCameraControl status and verify if it is set correctly in QCamera */
- service.mockControl->setStatus(QCamera::StandbyStatus);
- QVERIFY(camera.status() == QCamera::StandbyStatus);
-
- /* Set the QCameraControl status and verify if it is set correctly in QCamera */
- service.mockControl->setStatus(QCamera::LoadingStatus);
- QVERIFY(camera.status() == QCamera::LoadingStatus);
-
- /* Set the QCameraControl status and verify if it is set correctly in QCamera */
- service.mockControl->setStatus(QCamera::UnavailableStatus);
- QVERIFY(camera.status() == QCamera::UnavailableStatus);
-}
-
-/* Test case for verifying default locktype QCamera::NoLock */
-void tst_QCamera::testLockType()
-{
- QCamera camera;
-
- QCOMPARE(camera.requestedLocks(),QCamera::NoLock);
-}
-
-/* Test case for QCamera::LockChangeReason with QCamera::LockAcquired */
-void tst_QCamera::testLockChangeReason()
-{
- MockCameraService service;
- provider->service = &service;
-
- QCamera camera;
-
- QSignalSpy lockStatusChangedSignalWithType(&camera, SIGNAL(lockStatusChanged(QCamera::LockType,QCamera::LockStatus,QCamera::LockChangeReason)));
-
- /* Set the lockChangeReason */
- service.mockLocksControl->setLockChangeReason(QCamera::LockAcquired);
-
- /* Verify if lockChangeReson is eqaul toQCamera::LockAcquired */
- QCOMPARE(lockStatusChangedSignalWithType.count(), 1);
- QCamera::LockChangeReason LockChangeReason = qvariant_cast<QCamera::LockChangeReason >(lockStatusChangedSignalWithType.at(0).at(2));
- QVERIFY(LockChangeReason == QCamera::LockAcquired);
-
-}
-
-/* All the enums test case for QCameraControl class*/
-void tst_QCamera::testEnumsOfQCameraControl()
-{
- MockCameraControl *m_cameraControl = new MockCameraControl(this);
- bool result;
-
- // In still mode, can't change much
- QVERIFY(m_cameraControl->captureMode() == QCamera::CaptureStillImage);
- result = m_cameraControl->canChangeProperty(MockCameraControl::CaptureMode, QCamera::ActiveStatus);
- QVERIFY(!result);
- result = m_cameraControl->canChangeProperty(MockCameraControl::ImageEncodingSettings, QCamera::ActiveStatus);
- QVERIFY(!result);
- result = m_cameraControl->canChangeProperty(MockCameraControl::VideoEncodingSettings, QCamera::ActiveStatus);
- QVERIFY(result);
- result = m_cameraControl->canChangeProperty(MockCameraControl::Viewfinder, QCamera::ActiveStatus);
- QVERIFY(!result);
-
- // In video mode can change image encoding settings
- m_cameraControl->setCaptureMode(QCamera::CaptureVideo);
- result = m_cameraControl->canChangeProperty(MockCameraControl::ImageEncodingSettings, QCamera::ActiveStatus);
- QVERIFY(result);
- result = m_cameraControl->canChangeProperty(MockCameraControl::VideoEncodingSettings, QCamera::ActiveStatus);
- QVERIFY(result);
- result = m_cameraControl->canChangeProperty(MockCameraControl::Viewfinder, QCamera::ActiveStatus);
- QVERIFY(!result);
-
- // Flip the allow everything bit
- m_cameraControl->m_propertyChangesSupported = true;
- result = m_cameraControl->canChangeProperty(MockCameraControl::CaptureMode, QCamera::ActiveStatus);
- QVERIFY(result);
- result = m_cameraControl->canChangeProperty(MockCameraControl::ImageEncodingSettings, QCamera::ActiveStatus);
- QVERIFY(result);
- result = m_cameraControl->canChangeProperty(MockCameraControl::VideoEncodingSettings, QCamera::ActiveStatus);
- QVERIFY(result);
- result = m_cameraControl->canChangeProperty(MockCameraControl::Viewfinder, QCamera::ActiveStatus);
- QVERIFY(result);
-}
-
-// Test case for QCameraImageProcessing class
-void tst_QCamera::testContrast()
-{
- QCamera camera;
- QCameraImageProcessing *cameraImageProcessing = camera.imageProcessing();
- QVERIFY(cameraImageProcessing->contrast() ==0);
-
- cameraImageProcessing->setContrast(0.123);
- QCOMPARE(cameraImageProcessing->contrast(), 0.123);
-
- cameraImageProcessing->setContrast(4.56);
- QCOMPARE(cameraImageProcessing->contrast(), 4.56);
-}
-
-void tst_QCamera::testDenoisingLevel()
-{
- QCamera camera;
- QCameraImageProcessing *cameraImageProcessing = camera.imageProcessing();
-
- QCOMPARE(cameraImageProcessing->denoisingLevel()+1 , 1.0);
-
- cameraImageProcessing->setDenoisingLevel(-0.3);
- QCOMPARE(cameraImageProcessing->denoisingLevel() , -0.3);
-
- cameraImageProcessing->setDenoisingLevel(0.3);
- QCOMPARE(cameraImageProcessing->denoisingLevel() , 0.3);
-}
-
-void tst_QCamera::testIsAvailable()
-{
- QCamera camera;
- QCameraImageProcessing *cameraImageProcessing = camera.imageProcessing();
- QVERIFY(cameraImageProcessing->isAvailable() == true);
-}
-
-void tst_QCamera::testSaturation()
-{
- QCamera camera;
- QCameraImageProcessing *cameraImageProcessing = camera.imageProcessing();
- QCOMPARE(cameraImageProcessing->saturation()+1.0, 1.0);
-
- cameraImageProcessing->setSaturation(0.5);
- QCOMPARE(cameraImageProcessing->saturation(), 0.5);
-
- cameraImageProcessing->setSaturation(-0.5);
- QCOMPARE(cameraImageProcessing->saturation(), -0.5);
-}
-
-void tst_QCamera::testSharpeningLevel()
-{
- QCamera camera;
-
- QCameraImageProcessing *cameraImageProcessing = camera.imageProcessing();
-
- QCOMPARE(cameraImageProcessing->sharpeningLevel()+1 , 1.0);
-
- cameraImageProcessing->setSharpeningLevel(-0.3);
- QCOMPARE(cameraImageProcessing->sharpeningLevel() , -0.3);
-
- cameraImageProcessing->setSharpeningLevel(0.3);
- QCOMPARE(cameraImageProcessing->sharpeningLevel() , 0.3);
-}
-
-void tst_QCamera::testEnumOfQCameraImageProcessing()
-{
- QSet<QCameraImageProcessing::WhiteBalanceMode> whiteBalanceModes;
- whiteBalanceModes << QCameraImageProcessing::WhiteBalanceManual;
- whiteBalanceModes << QCameraImageProcessing::WhiteBalanceAuto;
- whiteBalanceModes << QCameraImageProcessing::WhiteBalanceSunlight;
- whiteBalanceModes << QCameraImageProcessing::WhiteBalanceCloudy;
- whiteBalanceModes << QCameraImageProcessing::WhiteBalanceShade;
- whiteBalanceModes << QCameraImageProcessing::WhiteBalanceTungsten;
- whiteBalanceModes << QCameraImageProcessing::WhiteBalanceFluorescent;
- whiteBalanceModes << QCameraImageProcessing::WhiteBalanceFlash;
- whiteBalanceModes << QCameraImageProcessing::WhiteBalanceSunset;
- whiteBalanceModes << QCameraImageProcessing::WhiteBalanceVendor;
-
- MockCameraService service;
- service.mockImageProcessingControl->setSupportedWhiteBalanceModes(whiteBalanceModes);
-
- service.mockImageProcessingControl->setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceManual);
- QVERIFY(service.mockImageProcessingControl->isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceManual));
- QVERIFY(service.mockImageProcessingControl->whiteBalanceMode() == QCameraImageProcessing::WhiteBalanceManual);
-
- service.mockImageProcessingControl->setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceAuto);
- QVERIFY(service.mockImageProcessingControl->isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceAuto));
- QVERIFY(service.mockImageProcessingControl->whiteBalanceMode() == QCameraImageProcessing::WhiteBalanceAuto);
-
- service.mockImageProcessingControl->setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceSunlight);
- QVERIFY(service.mockImageProcessingControl->isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceSunlight));
- QVERIFY(service.mockImageProcessingControl->whiteBalanceMode() == QCameraImageProcessing::WhiteBalanceSunlight);
-
- service.mockImageProcessingControl->setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceCloudy);
- QVERIFY(service.mockImageProcessingControl->isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceCloudy));
- QVERIFY(service.mockImageProcessingControl->whiteBalanceMode() == QCameraImageProcessing::WhiteBalanceCloudy);
-
- service.mockImageProcessingControl->setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceShade);
- QVERIFY(service.mockImageProcessingControl->isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceShade));
- QVERIFY(service.mockImageProcessingControl->whiteBalanceMode() == QCameraImageProcessing::WhiteBalanceShade);
-
- service.mockImageProcessingControl->setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceTungsten);
- QVERIFY(service.mockImageProcessingControl->isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceTungsten));
- QVERIFY(service.mockImageProcessingControl->whiteBalanceMode() == QCameraImageProcessing::WhiteBalanceTungsten);
-
- service.mockImageProcessingControl->setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceFluorescent);
- QVERIFY(service.mockImageProcessingControl->isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceFluorescent));
- QVERIFY(service.mockImageProcessingControl->whiteBalanceMode() == QCameraImageProcessing::WhiteBalanceFluorescent);
-
- service.mockImageProcessingControl->setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceFlash);
- QVERIFY(service.mockImageProcessingControl->isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceFlash));
- QVERIFY(service.mockImageProcessingControl->whiteBalanceMode() == QCameraImageProcessing::WhiteBalanceFlash);
-
- service.mockImageProcessingControl->setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceSunset);
- QVERIFY(service.mockImageProcessingControl->isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceSunset));
- QVERIFY(service.mockImageProcessingControl->whiteBalanceMode() == QCameraImageProcessing::WhiteBalanceSunset);
-
- service.mockImageProcessingControl->setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceVendor);
- QVERIFY(service.mockImageProcessingControl->isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceVendor));
- QVERIFY(service.mockImageProcessingControl->whiteBalanceMode() == QCameraImageProcessing::WhiteBalanceVendor);
-}
-
-//Added test cases for QCameraFocus
-void tst_QCamera::testCameraFocusIsAvailable()
-{
- QCamera camera;
-
- QCameraFocus *cameraFocus = camera.focus();
- QVERIFY(cameraFocus != 0);
- QVERIFY(cameraFocus->isAvailable());
-}
-
-//Added this code to cover QCameraFocus::HyperfocalFocus and QCameraFocus::MacroFocus
-//As the HyperfocalFocus and MacroFocus are not supported we can not set the focus mode to these Focus Modes
-void tst_QCamera::testFocusModes()
-{
- QCamera camera;
-
- QCameraFocus *cameraFocus = camera.focus();
- QVERIFY(cameraFocus != 0);
- QVERIFY(!cameraFocus->isFocusModeSupported(QCameraFocus::HyperfocalFocus));
- QVERIFY(!cameraFocus->isFocusModeSupported(QCameraFocus::MacroFocus));
- QCOMPARE(cameraFocus->focusMode(), QCameraFocus::AutoFocus);
- cameraFocus->setFocusMode(QCameraFocus::HyperfocalFocus);
- QVERIFY(cameraFocus->focusMode()!= QCameraFocus::HyperfocalFocus);
- QCOMPARE(cameraFocus->focusMode(), QCameraFocus::AutoFocus);
- cameraFocus->setFocusMode(QCameraFocus::MacroFocus);
- QVERIFY(cameraFocus->focusMode()!= QCameraFocus::MacroFocus);
- QCOMPARE(cameraFocus->focusMode(), QCameraFocus::AutoFocus);
-}
-
-void tst_QCamera::testOpticalAndDigitalZoomChanged()
-{
- QCamera camera;
-
- QCameraFocus *cameraFocus = camera.focus();
- QVERIFY(cameraFocus != 0);
- QSignalSpy spy1(cameraFocus,SIGNAL(digitalZoomChanged(qreal)));
- QSignalSpy spy2(cameraFocus,SIGNAL(opticalZoomChanged(qreal)));
- QVERIFY(spy1.count() == 0);
- QVERIFY(spy2.count() == 0);
- cameraFocus->zoomTo(2.0,3.0);
- QVERIFY(spy1.count() == 1);
- QVERIFY(spy2.count() == 1);
-}
-
-void tst_QCamera::testMaxDigitalZoomChangedSignal()
-{
- QCamera camera;
-
- QCameraFocus *cameraFocus = camera.focus();
- QVERIFY(cameraFocus != 0);
- QSignalSpy spy(cameraFocus,SIGNAL(maximumDigitalZoomChanged(qreal)));
- QVERIFY(spy.count() == 0);
- cameraFocus->zoomTo(5.0,6.0);
- QVERIFY(spy.count() == 1);
-}
-
-void tst_QCamera::testMaxOpticalZoomChangedSignal()
-{
- QCamera camera;
-
- QCameraFocus *cameraFocus = camera.focus();
- QVERIFY(cameraFocus != 0);
- QSignalSpy spy(cameraFocus,SIGNAL(maximumOpticalZoomChanged(qreal)));
- QVERIFY(spy.count() == 0);
- cameraFocus->zoomTo(5.0,6.0);
- QVERIFY(spy.count() == 1);
-}
-
-void tst_QCamera::testfocusZonesChangedSignal()
-{
- QCamera camera;
-
- QCameraFocus *cameraFocus = camera.focus();
- QVERIFY(cameraFocus != 0);
-
- QSignalSpy spy(cameraFocus,SIGNAL(focusZonesChanged()));
- cameraFocus->setCustomFocusPoint(QPointF(0.1, 0.1));
- QVERIFY(spy.count() == 1);
-}
-
-// test constructor for abstract class of ImageProcessingControl
-void tst_QCamera :: testImageProcessingControl()
-{
- QObject parent;
- MockImageProcessingControl processCtrl(&parent);
-}
-
-void tst_QCamera::testSignalApertureChanged()
-{
- QCamera camera;
-
- QCameraExposure *cameraExposure = camera.exposure(); //create camera expose instance
- QVERIFY(cameraExposure != 0);
-
- QSignalSpy spyApertureChanged(cameraExposure , SIGNAL(apertureChanged(qreal)));
- QSignalSpy spyApertureRangeChanged(cameraExposure , SIGNAL(apertureRangeChanged()));
-
-
- QVERIFY(spyApertureChanged.count() ==0);
- cameraExposure->setManualAperture(10.0);//set the ManualAperture to 10.0
-
- QTest::qWait(100);
- QVERIFY(spyApertureChanged.count() ==1);
- QVERIFY(spyApertureRangeChanged.count() ==1);
-}
-
-void tst_QCamera::testSignalExposureCompensationChanged()
-{
- QCamera camera;
-
- QCameraExposure *cameraExposure = camera.exposure(); //create camera expose instance
- QVERIFY(cameraExposure != 0);
-
- QSignalSpy spyExposureCompensationChanged(cameraExposure , SIGNAL(exposureCompensationChanged(qreal)));
-
- QVERIFY(spyExposureCompensationChanged.count() ==0);
-
- QVERIFY(cameraExposure->exposureCompensation() != 800);
- cameraExposure->setExposureCompensation(2.0);
-
- QTest::qWait(100);
-
- QVERIFY(cameraExposure->exposureCompensation() == 2.0);
-
- QCOMPARE(spyExposureCompensationChanged.count(),1);
-
- // Setting the same should not result in a signal
- cameraExposure->setExposureCompensation(2.0);
- QTest::qWait(100);
-
- QVERIFY(cameraExposure->exposureCompensation() == 2.0);
- QCOMPARE(spyExposureCompensationChanged.count(),1);
-}
-
-void tst_QCamera::testSignalIsoSensitivityChanged()
-{
- QCamera camera;
-
- QCameraExposure *cameraExposure = camera.exposure(); //create camera expose instance
- QVERIFY(cameraExposure != 0);
-
- QSignalSpy spyisoSensitivityChanged(cameraExposure , SIGNAL(isoSensitivityChanged(int)));
-
- QVERIFY(spyisoSensitivityChanged.count() ==0);
-
- cameraExposure->setManualIsoSensitivity(800); //set the manualiso sentivity to 800
- QTest::qWait(100);
- QVERIFY(spyisoSensitivityChanged.count() ==1);
-
-}
-void tst_QCamera::testSignalShutterSpeedChanged()
-{
- QCamera camera;
-
- QCameraExposure *cameraExposure = camera.exposure(); //create camera expose instance
- QVERIFY(cameraExposure != 0);
-
- QSignalSpy spySignalShutterSpeedChanged(cameraExposure , SIGNAL(shutterSpeedChanged(qreal)));
- QSignalSpy spySignalShutterSpeedRangeChanged(cameraExposure , SIGNAL(shutterSpeedRangeChanged()));
-
- QVERIFY(spySignalShutterSpeedChanged.count() ==0);
-
- cameraExposure->setManualShutterSpeed(2.0);//set the ManualShutterSpeed to 2.0
- QTest::qWait(100);
-
- QVERIFY(spySignalShutterSpeedChanged.count() ==1);
- QVERIFY(spySignalShutterSpeedRangeChanged.count() ==1);
-}
-
-void tst_QCamera::testSignalFlashReady()
-{
- QCamera camera;
-
- QCameraExposure *cameraExposure = camera.exposure(); //create camera expose instance
- QVERIFY(cameraExposure != 0);
-
-
- QSignalSpy spyflashReady(cameraExposure,SIGNAL(flashReady(bool)));
-
- QVERIFY(spyflashReady.count() ==0);
-
- QVERIFY(cameraExposure->flashMode() ==QCameraExposure::FlashAuto);
-
- cameraExposure->setFlashMode(QCameraExposure::FlashOff);//set theFlashMode to QCameraExposure::FlashOff
-
- QVERIFY(cameraExposure->flashMode() ==QCameraExposure::FlashOff);
-
- QVERIFY(spyflashReady.count() ==1);
-}
-
-// test constructor
-void tst_QCamera::testExposureControlConstructor()
-{
- // To check changes in abstract classes's pure virtual functions
- MockCameraExposureControl obj;
-}
-
-QTEST_MAIN(tst_QCamera)
-
-#include "tst_qcamera.moc"
diff --git a/tests/auto/unit/qcameraimagecapture/qcameraimagecapture.pro b/tests/auto/unit/qcameraimagecapture/qcameraimagecapture.pro
deleted file mode 100644
index ae92c2d04..000000000
--- a/tests/auto/unit/qcameraimagecapture/qcameraimagecapture.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qcameraimagecapture
-
-QT += multimedia-private testlib
-
-SOURCES += \
- tst_qcameraimagecapture.cpp
-
-include (../qmultimedia_common/mock.pri)
-include (../qmultimedia_common/mockcamera.pri)
diff --git a/tests/auto/unit/qcameraimagecapture/tst_qcameraimagecapture.cpp b/tests/auto/unit/qcameraimagecapture/tst_qcameraimagecapture.cpp
deleted file mode 100644
index c45c2e629..000000000
--- a/tests/auto/unit/qcameraimagecapture/tst_qcameraimagecapture.cpp
+++ /dev/null
@@ -1,422 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/****************************************************************************
-Author : Vijay/Avinash
-
-Reviewer Name Date Coverage ( Full / Test Case IDs ).
----------------------------------------------------------------------------
- Initial review of test cases.
-****************************************************************************/
-
-//TESTED_COMPONENT=src/multimedia
-
-#include <QtTest/QtTest>
-#include <QDebug>
-
-#include <qcameracontrol.h>
-#include <qcameralockscontrol.h>
-#include <qcameraexposurecontrol.h>
-#include <qcameraflashcontrol.h>
-#include <qcamerafocuscontrol.h>
-#include <qcameraimagecapturecontrol.h>
-#include <qimageencodercontrol.h>
-#include <qcameraimageprocessingcontrol.h>
-#include <qmediaservice.h>
-#include <qcamera.h>
-#include <qcameraimagecapture.h>
-
-#include "mockcameraservice.h"
-#include "mockmediaserviceprovider.h"
-
-QT_USE_NAMESPACE
-
-class NullService: public QMediaService
-{
- Q_OBJECT
-
-public:
- NullService(): QMediaService(0)
- {
-
- }
-
- ~NullService()
- {
-
- }
-
- QMediaControl* requestControl(const char *iid)
- {
- Q_UNUSED(iid);
- return 0;
- }
-
- void releaseControl(QMediaControl*) {}
-
-};
-
-class tst_QCameraImageCapture: public QObject
-{
- Q_OBJECT
-
-public slots:
- void initTestCase();
- void init();
- void cleanup();
- void cleanupTestCase();
-
-private slots:
- void constructor();
- void mediaObject();
- void deleteMediaObject();
- void isReadyForCapture();
- void capture();
- void cancelCapture();
- void encodingSettings();
- void errors();
- void error();
- void imageCaptured();
- void imageExposed();
- void imageSaved();
- void readyForCaptureChanged();
- void supportedResolutions();
- void imageCodecDescription();
- void supportedImageCodecs();
- void cameraImageCaptureControl();
-
-private:
- MockCameraService *mockcameraservice;
- MockMediaServiceProvider *provider;
-};
-
-void tst_QCameraImageCapture::initTestCase()
-{
- provider = new MockMediaServiceProvider;
- QMediaServiceProvider::setDefaultServiceProvider(provider);
-}
-
-void tst_QCameraImageCapture::init()
-{
- mockcameraservice = new MockCameraService;
- provider->service = mockcameraservice;
-}
-
-void tst_QCameraImageCapture::cleanup()
-{
- delete mockcameraservice;
- mockcameraservice = 0;
-}
-
-void tst_QCameraImageCapture::cleanupTestCase()
-{
- delete provider;
-}
-
-//MaemoAPI-1823:test QCameraImageCapture Constructor
-void tst_QCameraImageCapture::constructor()
-{
- QCamera camera;
- QCameraImageCapture imageCapture(&camera);
- QVERIFY(imageCapture.isAvailable() == true);
-}
-
-//MaemoAPI-1824:test mediaObject
-void tst_QCameraImageCapture::mediaObject()
-{
- NullService mymockcameraservice ;
- provider->service = &mymockcameraservice;
- QCamera camera;
- QCameraImageCapture imageCapture(&camera);
- QVERIFY(imageCapture.mediaObject() == NULL);
-
- provider->service = mockcameraservice;
- QCamera camera1;
- QCameraImageCapture imageCapture1(&camera1);
- QMediaObject *medobj1 = imageCapture1.mediaObject();
- QCOMPARE(medobj1, &camera1);
-}
-
-void tst_QCameraImageCapture::deleteMediaObject()
-{
- provider->service = new MockCameraService;
-
- QCamera *camera = new QCamera;
- QCameraImageCapture *capture = new QCameraImageCapture(camera);
-
- QVERIFY(capture->mediaObject() == camera);
- QVERIFY(capture->isAvailable());
-
- delete camera;
- delete provider->service;
-
- //capture should detach from camera
- QVERIFY(capture->mediaObject() == 0);
- QVERIFY(!capture->isAvailable());
-
- capture->capture();
- delete capture;
-}
-
-//MaemoAPI-1825:test isReadyForCapture
-void tst_QCameraImageCapture::isReadyForCapture()
-{
- QCamera camera;
- QCameraImageCapture imageCapture(&camera);
- QVERIFY(imageCapture.isAvailable() == true);
- QVERIFY(imageCapture.isReadyForCapture() == false);
- camera.start();
- imageCapture.capture();
- QTRY_VERIFY(imageCapture.isReadyForCapture());
- camera.stop();
-}
-
-//MaemoAPI-1826:test capture
-void tst_QCameraImageCapture::capture()
-{
- QCamera camera;
- QCameraImageCapture imageCapture(&camera);
- QVERIFY(imageCapture.isAvailable() == true);
- QVERIFY(imageCapture.isReadyForCapture() == false);
- QVERIFY(imageCapture.capture() == -1);
- camera.start();
- QVERIFY(imageCapture.isReadyForCapture() == true);
- QTest::qWait(300);
- QVERIFY(imageCapture.capture() != -1);
- camera.stop();
-}
-
-//MaemoAPI-1827:test cancelCapture
-void tst_QCameraImageCapture::cancelCapture()
-{
- QCamera camera;
- QCameraImageCapture imageCapture(&camera);
- QSignalSpy spy(&imageCapture, SIGNAL(imageCaptured(int,QImage)));
- QSignalSpy spy1(&imageCapture, SIGNAL(imageSaved(int,QString)));
- QVERIFY(imageCapture.isAvailable() == true);
- QVERIFY(imageCapture.isReadyForCapture() == false);
- camera.start();
- imageCapture.capture();
- QTRY_VERIFY(imageCapture.isReadyForCapture());
- QVERIFY(spy.count() == 1 && spy1.count() == 1);
- spy.clear();
- spy1.clear();
- camera.stop();
-
- QVERIFY(imageCapture.isReadyForCapture() == false);
- camera.start();
- imageCapture.capture();
- imageCapture.cancelCapture();
- QTRY_VERIFY(imageCapture.isReadyForCapture());
- QVERIFY(spy.count() == 0 && spy1.count() == 0);
- camera.stop();
-}
-
-//MaemoAPI-1828:test encodingSettings
-//MaemoAPI-1829:test set encodingSettings
-void tst_QCameraImageCapture::encodingSettings()
-{
- QCamera camera;
- QCameraImageCapture imageCapture(&camera);
- QVERIFY(imageCapture.isAvailable() == true);
- QVERIFY(imageCapture.encodingSettings() == QImageEncoderSettings());
- QImageEncoderSettings settings;
- settings.setCodec("JPEG");
- settings.setQuality(QMultimedia::NormalQuality);
- imageCapture.setEncodingSettings(settings);
- QVERIFY(!imageCapture.encodingSettings().isNull());
- QVERIFY(imageCapture.encodingSettings().codec() == "JPEG");
- QVERIFY(imageCapture.encodingSettings().quality() == QMultimedia::NormalQuality);
-}
-
-//MaemoAPI-1838:test supportedImageCodecs
-void tst_QCameraImageCapture::supportedImageCodecs()
-{
- QCamera camera;
- QCameraImageCapture imageCapture(&camera);
- QVERIFY(imageCapture.isAvailable() == true);
- QVERIFY(!imageCapture.supportedImageCodecs().isEmpty());
-}
-
-//MaemoAPI-1836:test supportedResolutions
-void tst_QCameraImageCapture::supportedResolutions()
-{
- QCamera camera;
- QCameraImageCapture imageCapture(&camera);
- QVERIFY(imageCapture.isAvailable() == true);
- QVERIFY(imageCapture.supportedResolutions().count() == 2);
- QImageEncoderSettings settings1;
- settings1.setCodec("PNG");;
- settings1.setResolution(320, 240);
- int result = imageCapture.supportedResolutions(settings1).count();
- QVERIFY(result == 1);
-}
-
-//MaemoAPI-1837:test imageCodecDescription
-void tst_QCameraImageCapture::imageCodecDescription()
-{
- QCamera camera;
- QCameraImageCapture imageCapture(&camera);
- QVERIFY(imageCapture.isAvailable() == true);
- QVERIFY(imageCapture.imageCodecDescription(" ").isNull());
- QVERIFY(imageCapture.imageCodecDescription("PNG").isNull() == false);
-}
-
-//MaemoAPI-1830:test errors
-void tst_QCameraImageCapture::errors()
-{
- MockSimpleCameraService mockSimpleCameraService ;
- provider->service = &mockSimpleCameraService;
-
- QCamera camera1;
- QCameraImageCapture imageCapture1(&camera1);
- QVERIFY(imageCapture1.isAvailable() == false);
- imageCapture1.capture(QString::fromLatin1("/dev/null"));
- QVERIFY(imageCapture1.error() == QCameraImageCapture::NotSupportedFeatureError);
- QVERIFY2(!imageCapture1.errorString().isEmpty(), "Device does not support images capture");
- QVERIFY(imageCapture1.availability() == QMultimedia::ServiceMissing);
-
- provider->service = mockcameraservice;
-
- QCamera camera;
- QCameraImageCapture imageCapture(&camera);
- QVERIFY(imageCapture.isAvailable() == true);
- QVERIFY(imageCapture.error() == QCameraImageCapture::NoError);
- QVERIFY(imageCapture.errorString().isEmpty());
- QVERIFY(imageCapture.availability() == QMultimedia::Available);
-
- imageCapture.capture();
- QVERIFY(imageCapture.error() == QCameraImageCapture::NotReadyError);
- QVERIFY2(!imageCapture.errorString().isEmpty(), "Could not capture in stopped state");
- QVERIFY(imageCapture.availability() == QMultimedia::Available);
-}
-
-//MaemoAPI-1831:test error
-void tst_QCameraImageCapture::error()
-{
- QCamera camera;
- QCameraImageCapture imageCapture(&camera);
- QSignalSpy spy(&imageCapture, SIGNAL(error(int,QCameraImageCapture::Error,QString)));
- imageCapture.capture();
- QTest::qWait(30);
- QVERIFY(spy.count() == 1);
- QVERIFY(qvariant_cast<int>(spy.at(0).at(0)) == -1);
- QVERIFY(qvariant_cast<QCameraImageCapture::Error>(spy.at(0).at(1)) == QCameraImageCapture::NotReadyError);
- QVERIFY(qvariant_cast<QString>(spy.at(0).at(2)) == "Could not capture in stopped state");
- spy.clear();
-}
-
-//MaemoAPI-1832:test imageCaptured
-void tst_QCameraImageCapture::imageCaptured()
-{
- QCamera camera;
- QCameraImageCapture imageCapture(&camera);
- QSignalSpy spy(&imageCapture, SIGNAL(imageCaptured(int,QImage)));
- QVERIFY(imageCapture.isAvailable() == true);
- QVERIFY(imageCapture.isReadyForCapture() == false);
- camera.start();
- imageCapture.capture();
- QTRY_VERIFY(imageCapture.isReadyForCapture());
-
- QVERIFY(spy.count() == 1);
- QVERIFY(qvariant_cast<int>(spy.at(0).at(0)) > 0);
- QImage image = qvariant_cast<QImage>(spy.at(0).at(1));
- QVERIFY(image.isNull() == true);
- spy.clear();
- camera.stop();
-}
-
-//MaemoAPI-1833:test imageExposed
-void tst_QCameraImageCapture::imageExposed()
-{
- QCamera camera;
- QCameraImageCapture imageCapture(&camera);
- QSignalSpy spy(&imageCapture, SIGNAL(imageExposed(int)));
- QVERIFY(imageCapture.isAvailable() == true);
- QVERIFY(imageCapture.isReadyForCapture() == false);
- camera.start();
- imageCapture.capture();
- QTRY_VERIFY(imageCapture.isReadyForCapture());
-
- QVERIFY(spy.count() == 1);
- QVERIFY(qvariant_cast<int>(spy.at(0).at(0)) > 0);
- spy.clear();
- camera.stop();
-}
-
-//MaemoAPI-1834:test imageSaved
-void tst_QCameraImageCapture::imageSaved()
-{
- QCamera camera;
- QCameraImageCapture imageCapture(&camera);
- QSignalSpy spy(&imageCapture, SIGNAL(imageSaved(int,QString)));
- QVERIFY(imageCapture.isAvailable() == true);
- QVERIFY(imageCapture.isReadyForCapture() == false);
- camera.start();
- imageCapture.capture(QString::fromLatin1("/usr/share"));
- QTRY_VERIFY(imageCapture.isReadyForCapture());
-
- QVERIFY(spy.count() == 1);
- QVERIFY(qvariant_cast<int>(spy.at(0).at(0)) > 0);
- QVERIFY(qvariant_cast<QString>(spy.at(0).at(1)) == "/usr/share");
- spy.clear();
- camera.stop();
-}
-
-//MaemoAPI-1835:test readyForCaptureChanged
-void tst_QCameraImageCapture::readyForCaptureChanged()
-{
- QCamera camera;
- QCameraImageCapture imageCapture(&camera);
- QSignalSpy spy(&imageCapture, SIGNAL(readyForCaptureChanged(bool)));
- QVERIFY(imageCapture.isReadyForCapture() == false);
- imageCapture.capture();
- QTest::qWait(100);
- QVERIFY(spy.count() == 0);
- QVERIFY2(!imageCapture.errorString().isEmpty(),"Could not capture in stopped state" );
- camera.start();
- QTest::qWait(100);
- imageCapture.capture();
- QTest::qWait(100);
- QVERIFY(spy.count() == 2);
- QVERIFY(spy.at(0).at(0).toBool() == false);
- QVERIFY(spy.at(1).at(0).toBool() == true);
- camera.stop();
- spy.clear();
-}
-
-//MaemoAPI-1853:test cameraImageCapture control constructor
-void tst_QCameraImageCapture::cameraImageCaptureControl()
-{
- MockCameraControl ctrl;
- MockCaptureControl capctrl(&ctrl);
-}
-
-QTEST_MAIN(tst_QCameraImageCapture)
-
-#include "tst_qcameraimagecapture.moc"
diff --git a/tests/auto/unit/qcamerainfo/qcamerainfo.pro b/tests/auto/unit/qcamerainfo/qcamerainfo.pro
deleted file mode 100644
index 42d8e714e..000000000
--- a/tests/auto/unit/qcamerainfo/qcamerainfo.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qcamerainfo
-
-QT += multimedia-private testlib
-
-include (../qmultimedia_common/mock.pri)
-include (../qmultimedia_common/mockcamera.pri)
-
-SOURCES += tst_qcamerainfo.cpp
diff --git a/tests/auto/unit/qcamerainfo/tst_qcamerainfo.cpp b/tests/auto/unit/qcamerainfo/tst_qcamerainfo.cpp
deleted file mode 100644
index 233a46e0f..000000000
--- a/tests/auto/unit/qcamerainfo/tst_qcamerainfo.cpp
+++ /dev/null
@@ -1,204 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QDebug>
-
-#include <qcamera.h>
-#include <qcamerainfo.h>
-
-#include "mockcameraservice.h"
-#include "mockmediaserviceprovider.h"
-
-QT_USE_NAMESPACE
-
-class tst_QCameraInfo: public QObject
-{
- Q_OBJECT
-
-public slots:
- void initTestCase();
- void init();
- void cleanup();
-
-private slots:
- void constructor();
- void defaultCamera();
- void availableCameras();
- void equality_operators();
-
-private:
- MockSimpleCameraService *mockSimpleCameraService;
- MockCameraService *mockCameraService;
- MockMediaServiceProvider *provider;
-};
-
-void tst_QCameraInfo::initTestCase()
-{
-}
-
-void tst_QCameraInfo::init()
-{
- provider = new MockMediaServiceProvider;
- mockSimpleCameraService = new MockSimpleCameraService;
- mockCameraService = new MockCameraService;
-
- provider->service = mockCameraService;
- QMediaServiceProvider::setDefaultServiceProvider(provider);
-}
-
-void tst_QCameraInfo::cleanup()
-{
- delete provider;
- delete mockCameraService;
- delete mockSimpleCameraService;
-}
-
-void tst_QCameraInfo::constructor()
-{
- // Service doesn't implement QVideoDeviceSelectorControl
- // QCameraInfo should not be valid in this case
- provider->service = mockSimpleCameraService;
-
- {
- QCamera camera;
- QCameraInfo info(camera);
- QVERIFY(info.isNull());
- QVERIFY(info.deviceName().isEmpty());
- QVERIFY(info.description().isEmpty());
- QCOMPARE(info.position(), QCamera::UnspecifiedPosition);
- QCOMPARE(info.orientation(), 0);
- }
-
- // Service implements QVideoDeviceSelectorControl
- provider->service = mockCameraService;
-
- {
- // default camera
- QCamera camera;
- QCameraInfo info(camera);
- QVERIFY(!info.isNull());
- QCOMPARE(info.deviceName(), QStringLiteral("othercamera"));
- QCOMPARE(info.description(), QStringLiteral("othercamera desc"));
- QCOMPARE(info.position(), QCamera::UnspecifiedPosition);
- QCOMPARE(info.orientation(), 0);
- }
-
- QCamera camera("backcamera");
- QCameraInfo info(camera);
- QVERIFY(!info.isNull());
- QCOMPARE(info.deviceName(), QStringLiteral("backcamera"));
- QCOMPARE(info.description(), QStringLiteral("backcamera desc"));
- QCOMPARE(info.position(), QCamera::BackFace);
- QCOMPARE(info.orientation(), 90);
-
- QCameraInfo info2(info);
- QVERIFY(!info2.isNull());
- QCOMPARE(info2.deviceName(), QStringLiteral("backcamera"));
- QCOMPARE(info2.description(), QStringLiteral("backcamera desc"));
- QCOMPARE(info2.position(), QCamera::BackFace);
- QCOMPARE(info2.orientation(), 90);
-}
-
-void tst_QCameraInfo::defaultCamera()
-{
- provider->service = mockCameraService;
-
- QCameraInfo info = QCameraInfo::defaultCamera();
-
- QVERIFY(!info.isNull());
- QCOMPARE(info.deviceName(), QStringLiteral("othercamera"));
- QCOMPARE(info.description(), QStringLiteral("othercamera desc"));
- QCOMPARE(info.position(), QCamera::UnspecifiedPosition);
- QCOMPARE(info.orientation(), 0);
-
- QCamera camera(info);
- QCOMPARE(QCameraInfo(camera), info);
-}
-
-void tst_QCameraInfo::availableCameras()
-{
- provider->service = mockCameraService;
-
- QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
- QCOMPARE(cameras.count(), 2);
-
- QCameraInfo info = cameras.at(0);
- QVERIFY(!info.isNull());
- QCOMPARE(info.deviceName(), QStringLiteral("backcamera"));
- QCOMPARE(info.description(), QStringLiteral("backcamera desc"));
- QCOMPARE(info.position(), QCamera::BackFace);
- QCOMPARE(info.orientation(), 90);
-
- info = cameras.at(1);
- QVERIFY(!info.isNull());
- QCOMPARE(info.deviceName(), QStringLiteral("othercamera"));
- QCOMPARE(info.description(), QStringLiteral("othercamera desc"));
- QCOMPARE(info.position(), QCamera::UnspecifiedPosition);
- QCOMPARE(info.orientation(), 0);
-
- cameras = QCameraInfo::availableCameras(QCamera::BackFace);
- QCOMPARE(cameras.count(), 1);
- info = cameras.at(0);
- QVERIFY(!info.isNull());
- QCOMPARE(info.deviceName(), QStringLiteral("backcamera"));
- QCOMPARE(info.description(), QStringLiteral("backcamera desc"));
- QCOMPARE(info.position(), QCamera::BackFace);
- QCOMPARE(info.orientation(), 90);
-
- cameras = QCameraInfo::availableCameras(QCamera::FrontFace);
- QCOMPARE(cameras.count(), 0);
-}
-
-void tst_QCameraInfo::equality_operators()
-{
- provider->service = mockCameraService;
-
- QCameraInfo defaultCamera = QCameraInfo::defaultCamera();
- QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
-
- QVERIFY(defaultCamera == cameras.at(1));
- QVERIFY(defaultCamera != cameras.at(0));
- QVERIFY(cameras.at(0) != cameras.at(1));
-
- {
- QCamera camera(defaultCamera);
- QVERIFY(QCameraInfo(camera) == defaultCamera);
- QVERIFY(QCameraInfo(camera) == cameras.at(1));
- }
-
- {
- QCamera camera(cameras.at(0));
- QVERIFY(QCameraInfo(camera) == cameras.at(0));
- }
-}
-
-
-QTEST_MAIN(tst_QCameraInfo)
-
-#include "tst_qcamerainfo.moc"
diff --git a/tests/auto/unit/qcameraviewfinder/qcameraviewfinder.pro b/tests/auto/unit/qcameraviewfinder/qcameraviewfinder.pro
deleted file mode 100644
index f9016febe..000000000
--- a/tests/auto/unit/qcameraviewfinder/qcameraviewfinder.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qcameraviewfinder
-
-QT += multimedia-private multimediawidgets-private testlib
-
-include (../qmultimedia_common/mock.pri)
-include (../qmultimedia_common/mockcamera.pri)
-
-SOURCES += tst_qcameraviewfinder.cpp
-QT+=widgets
diff --git a/tests/auto/unit/qcameraviewfinder/tst_qcameraviewfinder.cpp b/tests/auto/unit/qcameraviewfinder/tst_qcameraviewfinder.cpp
deleted file mode 100644
index 69f1b9780..000000000
--- a/tests/auto/unit/qcameraviewfinder/tst_qcameraviewfinder.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-
-#include <QtTest/QtTest>
-#include <QDebug>
-
-#include "qcameraviewfinder.h"
-#include "qcamera.h"
-#include "qmediaobject.h"
-
-#include "mockcameraservice.h"
-#include "mockmediaserviceprovider.h"
-
-class tst_QCameraViewFinder : public QObject
-{
- Q_OBJECT
-public slots:
- void initTestCase();
- void cleanupTestCase();
-
-private slots:
- void testConstructor();
- void testMediaObject();
-
-private:
- MockCameraService *mockcameraservice;
- MockMediaServiceProvider *provider;
- QCamera *camera;
- QCameraViewfinder *viewFinder;
-};
-
-void tst_QCameraViewFinder::initTestCase()
-{
- provider = new MockMediaServiceProvider;
- mockcameraservice = new MockCameraService;
- provider->service = mockcameraservice;
- QMediaServiceProvider::setDefaultServiceProvider(provider);
-
- camera = new QCamera;
- viewFinder = new QCameraViewfinder();
-}
-
-void tst_QCameraViewFinder::cleanupTestCase()
-{
- delete mockcameraservice;
- delete provider;
-}
-
-void tst_QCameraViewFinder::testConstructor()
-{
- /* Verify whether the object is created or not */
- QVERIFY(viewFinder != NULL);
- QCOMPARE(viewFinder->isVisible(),false);
- QCOMPARE(viewFinder->isEnabled(),true);
- viewFinder->show();
-}
-
-void tst_QCameraViewFinder::testMediaObject()
-{
- QVERIFY(viewFinder != NULL);
- viewFinder->show();
- /* Sets the QVideoWidget based camera viewfinder.*/
- camera->setViewfinder(viewFinder);
- QCOMPARE(viewFinder->isVisible(),true);
-
- /* Return the currently attached media object.*/
- QMediaObject *media = viewFinder->mediaObject();
-
- /* Verifying the object */
- QCOMPARE(media, camera);
-}
-
-QTEST_MAIN(tst_QCameraViewFinder)
-#include "tst_qcameraviewfinder.moc"
diff --git a/tests/auto/unit/qcamerawidgets/qcamerawidgets.pro b/tests/auto/unit/qcamerawidgets/qcamerawidgets.pro
deleted file mode 100644
index c87144e94..000000000
--- a/tests/auto/unit/qcamerawidgets/qcamerawidgets.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qcamerawidgets
-
-QT += multimedia-private multimediawidgets-private testlib
-
-include (../qmultimedia_common/mock.pri)
-include (../qmultimedia_common/mockcamera.pri)
-
-SOURCES += tst_qcamerawidgets.cpp
-
-QT+=widgets
diff --git a/tests/auto/unit/qcamerawidgets/tst_qcamerawidgets.cpp b/tests/auto/unit/qcamerawidgets/tst_qcamerawidgets.cpp
deleted file mode 100644
index 648c6a408..000000000
--- a/tests/auto/unit/qcamerawidgets/tst_qcamerawidgets.cpp
+++ /dev/null
@@ -1,304 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//TESTED_COMPONENT=src/multimedia
-
-#include <QtTest/QtTest>
-#include <QDebug>
-
-#include <qabstractvideosurface.h>
-#include <qcameracontrol.h>
-#include <qcameralockscontrol.h>
-#include <qcameraexposurecontrol.h>
-#include <qcameraflashcontrol.h>
-#include <qcamerafocuscontrol.h>
-#include <qcameraimagecapturecontrol.h>
-#include <qimageencodercontrol.h>
-#include <qcameraimageprocessingcontrol.h>
-#include <qcameracapturebufferformatcontrol.h>
-#include <qcameracapturedestinationcontrol.h>
-#include <qmediaservice.h>
-#include <qcamera.h>
-#include <qcameraimagecapture.h>
-#include <qgraphicsvideoitem.h>
-#include <qvideorenderercontrol.h>
-#include <qvideowidget.h>
-#include <qvideowindowcontrol.h>
-
-#include "mockcameraservice.h"
-
-#include "mockmediaserviceprovider.h"
-#include "mockvideosurface.h"
-#include "mockvideorenderercontrol.h"
-#include "mockvideowindowcontrol.h"
-
-QT_USE_NAMESPACE
-
-
-class tst_QCameraWidgets: public QObject
-{
- Q_OBJECT
-
-public slots:
- void initTestCase();
- void init();
- void cleanup();
- void cleanupTestCase();
-
-private slots:
- void testCameraEncodingProperyChange();
- void testSetVideoOutput();
- void testSetVideoOutputNoService();
- void testSetVideoOutputNoControl();
-
-private:
- MockCameraService *mockCameraService;
- MockMediaServiceProvider *provider;
-};
-
-void tst_QCameraWidgets::initTestCase()
-{
- provider = new MockMediaServiceProvider;
- QMediaServiceProvider::setDefaultServiceProvider(provider);
-}
-
-void tst_QCameraWidgets::init()
-{
- mockCameraService = new MockCameraService;
- provider->service = mockCameraService;
-}
-
-void tst_QCameraWidgets::cleanup()
-{
- delete mockCameraService;
- provider->service = 0;
-}
-
-
-void tst_QCameraWidgets::cleanupTestCase()
-{
- delete provider;
-}
-
-void tst_QCameraWidgets::testCameraEncodingProperyChange()
-{
- QCamera camera;
- QCameraImageCapture imageCapture(&camera);
-
- QSignalSpy stateChangedSignal(&camera, SIGNAL(stateChanged(QCamera::State)));
- QSignalSpy statusChangedSignal(&camera, SIGNAL(statusChanged(QCamera::Status)));
-
- camera.start();
- QCOMPARE(camera.state(), QCamera::ActiveState);
- QCOMPARE(camera.status(), QCamera::ActiveStatus);
-
- QCOMPARE(stateChangedSignal.count(), 1);
- QCOMPARE(statusChangedSignal.count(), 1);
- stateChangedSignal.clear();
- statusChangedSignal.clear();
-
-
- camera.setCaptureMode(QCamera::CaptureVideo);
- QCOMPARE(camera.state(), QCamera::ActiveState);
- QCOMPARE(camera.status(), QCamera::LoadedStatus);
-
- QCOMPARE(stateChangedSignal.count(), 0);
- QCOMPARE(statusChangedSignal.count(), 1);
- stateChangedSignal.clear();
- statusChangedSignal.clear();
-
- QCOMPARE(camera.state(), QCamera::ActiveState);
- QTRY_COMPARE(camera.status(), QCamera::ActiveStatus);
-
- QCOMPARE(stateChangedSignal.count(), 0);
- QCOMPARE(statusChangedSignal.count(), 1);
- stateChangedSignal.clear();
- statusChangedSignal.clear();
-
- //backens should not be stopped since the capture mode is Video
- imageCapture.setEncodingSettings(QImageEncoderSettings());
- QCOMPARE(stateChangedSignal.count(), 0);
- QCOMPARE(statusChangedSignal.count(), 0);
-
- camera.setCaptureMode(QCamera::CaptureStillImage);
- QTRY_COMPARE(camera.status(), QCamera::ActiveStatus);
- stateChangedSignal.clear();
- statusChangedSignal.clear();
-
- //the settings change should trigger camera stop/start
- imageCapture.setEncodingSettings(QImageEncoderSettings());
- QCOMPARE(camera.state(), QCamera::ActiveState);
- QCOMPARE(camera.status(), QCamera::LoadedStatus);
-
- QCOMPARE(stateChangedSignal.count(), 0);
- QCOMPARE(statusChangedSignal.count(), 1);
- stateChangedSignal.clear();
- statusChangedSignal.clear();
-
- QCOMPARE(camera.state(), QCamera::ActiveState);
- QTRY_COMPARE(camera.status(), QCamera::ActiveStatus);
-
- QCOMPARE(stateChangedSignal.count(), 0);
- QCOMPARE(statusChangedSignal.count(), 1);
- stateChangedSignal.clear();
- statusChangedSignal.clear();
-
- //the settings change should trigger camera stop/start only once
- camera.setCaptureMode(QCamera::CaptureVideo);
- camera.setCaptureMode(QCamera::CaptureStillImage);
- imageCapture.setEncodingSettings(QImageEncoderSettings());
- imageCapture.setEncodingSettings(QImageEncoderSettings());
-
- QCOMPARE(camera.state(), QCamera::ActiveState);
- QCOMPARE(camera.status(), QCamera::LoadedStatus);
-
- QCOMPARE(stateChangedSignal.count(), 0);
- QCOMPARE(statusChangedSignal.count(), 1);
- stateChangedSignal.clear();
- statusChangedSignal.clear();
-
- QCOMPARE(camera.state(), QCamera::ActiveState);
- QTRY_COMPARE(camera.status(), QCamera::ActiveStatus);
-
- QCOMPARE(stateChangedSignal.count(), 0);
- QCOMPARE(statusChangedSignal.count(), 1);
- stateChangedSignal.clear();
- statusChangedSignal.clear();
-
- //setting the viewfinder should also trigger backend to be restarted:
- camera.setViewfinder(new QGraphicsVideoItem());
- QCOMPARE(camera.state(), QCamera::ActiveState);
- QCOMPARE(camera.status(), QCamera::LoadedStatus);
-
- QCOMPARE(stateChangedSignal.count(), 0);
- QCOMPARE(statusChangedSignal.count(), 1);
-
- QTRY_COMPARE(camera.status(), QCamera::ActiveStatus);
-
- mockCameraService->mockControl->m_propertyChangesSupported = true;
- //the changes to encoding settings,
- //capture mode and encoding parameters should not trigger service restart
- stateChangedSignal.clear();
- statusChangedSignal.clear();
-
- camera.setCaptureMode(QCamera::CaptureVideo);
- camera.setCaptureMode(QCamera::CaptureStillImage);
- imageCapture.setEncodingSettings(QImageEncoderSettings());
- imageCapture.setEncodingSettings(QImageEncoderSettings());
- camera.setViewfinder(new QGraphicsVideoItem());
-
- QCOMPARE(stateChangedSignal.count(), 0);
- QCOMPARE(statusChangedSignal.count(), 0);
-}
-
-void tst_QCameraWidgets::testSetVideoOutput()
-{
- QVideoWidget widget;
- QGraphicsVideoItem item;
- MockVideoSurface surface;
- QCamera camera;
-
- camera.setViewfinder(&widget);
- qDebug() << widget.mediaObject();
- QVERIFY(widget.mediaObject() == &camera);
-
- camera.setViewfinder(&item);
- QVERIFY(widget.mediaObject() == 0);
- QVERIFY(item.mediaObject() == &camera);
-
- camera.setViewfinder(reinterpret_cast<QVideoWidget *>(0));
- QVERIFY(item.mediaObject() == 0);
-
- camera.setViewfinder(&widget);
- QVERIFY(widget.mediaObject() == &camera);
-
- camera.setViewfinder(reinterpret_cast<QGraphicsVideoItem *>(0));
- QVERIFY(widget.mediaObject() == 0);
-
- camera.setViewfinder(&surface);
- QVERIFY(mockCameraService->rendererControl->surface() == &surface);
-
- camera.setViewfinder(reinterpret_cast<QAbstractVideoSurface *>(0));
- QVERIFY(mockCameraService->rendererControl->surface() == 0);
-
- camera.setViewfinder(&surface);
- QVERIFY(mockCameraService->rendererControl->surface() == &surface);
-
- camera.setViewfinder(&widget);
- QVERIFY(mockCameraService->rendererControl->surface() == 0);
- QVERIFY(widget.mediaObject() == &camera);
-
- camera.setViewfinder(&surface);
- QVERIFY(mockCameraService->rendererControl->surface() == &surface);
- QVERIFY(widget.mediaObject() == 0);
-}
-
-
-void tst_QCameraWidgets::testSetVideoOutputNoService()
-{
- QVideoWidget widget;
- QGraphicsVideoItem item;
- MockVideoSurface surface;
-
- provider->service = 0;
- QCamera camera;
-
- camera.setViewfinder(&widget);
- QVERIFY(widget.mediaObject() == 0);
-
- camera.setViewfinder(&item);
- QVERIFY(item.mediaObject() == 0);
-
- camera.setViewfinder(&surface);
- // Nothing we can verify here other than it doesn't assert.
-}
-
-void tst_QCameraWidgets::testSetVideoOutputNoControl()
-{
- QVideoWidget widget;
- QGraphicsVideoItem item;
- MockVideoSurface surface;
-
- mockCameraService->rendererRef = 1;
- mockCameraService->windowRef = 1;
-
- QCamera camera;
-
- camera.setViewfinder(&widget);
- QVERIFY(widget.mediaObject() == 0);
-
- camera.setViewfinder(&item);
- QVERIFY(item.mediaObject() == 0);
-
- camera.setViewfinder(&surface);
- QVERIFY(mockCameraService->rendererControl->surface() == 0);
-}
-
-QTEST_MAIN(tst_QCameraWidgets)
-
-#include "tst_qcamerawidgets.moc"
diff --git a/tests/auto/unit/qdeclarativeaudio/qdeclarativeaudio.pro b/tests/auto/unit/qdeclarativeaudio/qdeclarativeaudio.pro
deleted file mode 100644
index 6d8b3c215..000000000
--- a/tests/auto/unit/qdeclarativeaudio/qdeclarativeaudio.pro
+++ /dev/null
@@ -1,20 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeaudio
-
-QT += multimedia-private qml testlib qtmultimediaquicktools-private
-
-HEADERS += \
- ../../../../src/imports/multimedia/qdeclarativeaudio_p.h \
- ../../../../src/imports/multimedia/qdeclarativeplaylist_p.h \
- ../../../../src/imports/multimedia/qdeclarativemediametadata_p.h
-
-SOURCES += \
- tst_qdeclarativeaudio.cpp \
- ../../../../src/imports/multimedia/qdeclarativeplaylist.cpp \
- ../../../../src/imports/multimedia/qdeclarativeaudio.cpp
-
-INCLUDEPATH += ../../../../src/imports/multimedia
-
-include (../qmultimedia_common/mock.pri)
-include (../qmultimedia_common/mockplayer.pri)
-
diff --git a/tests/auto/unit/qdeclarativeaudio/tst_qdeclarativeaudio.cpp b/tests/auto/unit/qdeclarativeaudio/tst_qdeclarativeaudio.cpp
deleted file mode 100644
index adcd9cc38..000000000
--- a/tests/auto/unit/qdeclarativeaudio/tst_qdeclarativeaudio.cpp
+++ /dev/null
@@ -1,1257 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//TESTED_COMPONENT=plugins/declarative/multimedia
-
-#include <QtTest/QtTest>
-
-#include "qdeclarativeaudio_p.h"
-#include "qdeclarativemediametadata_p.h"
-
-#include "mockmediaserviceprovider.h"
-#include "mockmediaplayerservice.h"
-
-#include <QtMultimedia/qmediametadata.h>
-#include <qmediaplayercontrol.h>
-#include <qmediaservice.h>
-#include <private/qmediaserviceprovider_p.h>
-#include <private/qdeclarativevideooutput_p.h>
-#include <qmetadatareadercontrol.h>
-#include <QAbstractVideoSurface>
-
-#include <QtGui/qguiapplication.h>
-#include <QtQml/qqmlengine.h>
-#include <QtQml/qqmlcomponent.h>
-
-class tst_QDeclarativeAudio : public QObject
-{
- Q_OBJECT
-public slots:
- void initTestCase();
-
-private slots:
- void nullPlayerControl();
- void nullMetaDataControl();
- void nullService();
-
- void source();
- void autoLoad();
- void playing();
- void paused();
- void duration();
- void position();
- void volume();
- void muted();
- void bufferProgress();
- void seekable();
- void playbackRate();
- void status();
- void metaData_data();
- void metaData();
- void error();
- void loops();
- void audioRole();
- void customAudioRole();
- void videoOutput();
-
-private:
- void enumerator(const QMetaObject *object, const char *name, QMetaEnum *result);
- QMetaEnum enumerator(const QMetaObject *object, const char *name);
- void keyToValue(const QMetaEnum &enumeration, const char *key, int *result);
- int keyToValue(const QMetaEnum &enumeration, const char *key);
-};
-
-Q_DECLARE_METATYPE(QDeclarativeAudio::Error);
-Q_DECLARE_METATYPE(QDeclarativeAudio::AudioRole);
-
-class QtTestMediaPlayerControl : public QMediaPlayerControl
-{
- Q_OBJECT
-public:
- QtTestMediaPlayerControl(QObject *parent = 0)
- : QMediaPlayerControl(parent)
- , m_state(QMediaPlayer::StoppedState)
- , m_mediaStatus(QMediaPlayer::NoMedia)
- , m_duration(0)
- , m_position(0)
- , m_playbackRate(1.0)
- , m_volume(100)
- , m_bufferStatus(0)
- , m_muted(false)
- , m_audioAvailable(false)
- , m_videoAvailable(false)
- , m_seekable(false)
- {
- }
-
- QMediaPlayer::State state() const { return m_state; }
- void updateState(QMediaPlayer::State state) { emit stateChanged(m_state = state); }
-
- QMediaPlayer::MediaStatus mediaStatus() const { return m_mediaStatus; }
- void updateMediaStatus(QMediaPlayer::MediaStatus status) {
- emit mediaStatusChanged(m_mediaStatus = status); }
- void updateMediaStatus(QMediaPlayer::MediaStatus status, QMediaPlayer::State state)
- {
- m_mediaStatus = status;
- m_state = state;
-
- emit mediaStatusChanged(m_mediaStatus);
- emit stateChanged(m_state);
- }
-
- qint64 duration() const { return m_duration; }
- void setDuration(qint64 duration) { emit durationChanged(m_duration = duration); }
-
- qint64 position() const { return m_position; }
- void setPosition(qint64 position) { emit positionChanged(m_position = position); }
-
- int volume() const { return m_volume; }
- void setVolume(int volume) { emit volumeChanged(m_volume = volume); }
-
- bool isMuted() const { return m_muted; }
- void setMuted(bool muted) { emit mutedChanged(m_muted = muted); }
-
- int bufferStatus() const { return m_bufferStatus; }
- void setBufferStatus(int status) { emit bufferStatusChanged(m_bufferStatus = status); }
-
- bool isAudioAvailable() const { return m_audioAvailable; }
- void setAudioAvailable(bool available) {
- emit audioAvailableChanged(m_audioAvailable = available); }
- bool isVideoAvailable() const { return m_videoAvailable; }
- void setVideoAvailable(bool available) {
- emit videoAvailableChanged(m_videoAvailable = available); }
-
- bool isSeekable() const { return m_seekable; }
- void setSeekable(bool seekable) { emit seekableChanged(m_seekable = seekable); }
-
- QMediaTimeRange availablePlaybackRanges() const { return QMediaTimeRange(); }
-
- qreal playbackRate() const { return m_playbackRate; }
- void setPlaybackRate(qreal rate) { emit playbackRateChanged(m_playbackRate = rate); }
-
- QMediaContent media() const { return m_media; }
- const QIODevice *mediaStream() const { return 0; }
- void setMedia(const QMediaContent &media, QIODevice *)
- {
- m_media = media;
-
- m_mediaStatus = m_media.isNull()
- ? QMediaPlayer::NoMedia
- : QMediaPlayer::LoadingMedia;
-
- emit mediaChanged(m_media);
- emit mediaStatusChanged(m_mediaStatus);
- }
-
- void play()
- {
- m_state = QMediaPlayer::PlayingState;
- if (m_mediaStatus == QMediaPlayer::EndOfMedia)
- updateMediaStatus(QMediaPlayer::LoadedMedia);
- emit stateChanged(m_state);
- }
- void pause() { emit stateChanged(m_state = QMediaPlayer::PausedState); }
- void stop() { emit stateChanged(m_state = QMediaPlayer::StoppedState); }
-
- void emitError(QMediaPlayer::Error err, const QString &errorString) {
- emit error(err, errorString); }
-
-private:
- QMediaPlayer::State m_state;
- QMediaPlayer::MediaStatus m_mediaStatus;
- qint64 m_duration;
- qint64 m_position;
- qreal m_playbackRate;
- int m_volume;
- int m_bufferStatus;
- bool m_muted;
- bool m_audioAvailable;
- bool m_videoAvailable;
- bool m_seekable;
- QMediaContent m_media;
-};
-
-class QtTestMetaDataControl : public QMetaDataReaderControl
-{
- Q_OBJECT
-public:
- QtTestMetaDataControl(QObject *parent = 0)
- : QMetaDataReaderControl(parent)
- {
- }
-
- bool isMetaDataAvailable() const { return true; }
-
- QVariant metaData(const QString &key) const { return m_metaData.value(key); }
- void setMetaData(const QString &key, const QVariant &value) {
- m_metaData.insert(key, value); emit metaDataChanged(); }
-
- QStringList availableMetaData() const { return m_metaData.keys(); }
-
-private:
- QMap<QString, QVariant> m_metaData;
-};
-
-class QtTestMediaService : public QMediaService
-{
- Q_OBJECT
-public:
- QtTestMediaService(
- QtTestMediaPlayerControl *playerControl,
- QtTestMetaDataControl *metaDataControl,
- QObject *parent)
- : QMediaService(parent)
- , playerControl(playerControl)
- , metaDataControl(metaDataControl)
- {
- }
-
- QMediaControl *requestControl(const char *name)
- {
- if (qstrcmp(name, QMediaPlayerControl_iid) == 0)
- return playerControl;
- else if (qstrcmp(name, QMetaDataReaderControl_iid) == 0)
- return metaDataControl;
- else
- return 0;
- }
-
- void releaseControl(QMediaControl *) {}
-
- QtTestMediaPlayerControl *playerControl;
- QtTestMetaDataControl *metaDataControl;
-};
-
-class QtTestMediaServiceProvider : public QMediaServiceProvider
-{
- Q_OBJECT
-public:
- QtTestMediaServiceProvider()
- : service(new QtTestMediaService(
- new QtTestMediaPlayerControl(this), new QtTestMetaDataControl(this), this))
- {
- setDefaultServiceProvider(this);
- }
-
- QtTestMediaServiceProvider(QtTestMediaService *service)
- : service(service)
- {
- setDefaultServiceProvider(this);
- }
-
- QtTestMediaServiceProvider(
- QtTestMediaPlayerControl *playerControl, QtTestMetaDataControl *metaDataControl)
- : service(new QtTestMediaService(playerControl, metaDataControl, this))
- {
- setDefaultServiceProvider(this);
- }
-
- ~QtTestMediaServiceProvider()
- {
- setDefaultServiceProvider(0);
- }
-
- QMediaService *requestService(
- const QByteArray &type,
- const QMediaServiceProviderHint & = QMediaServiceProviderHint())
- {
- requestedService = type;
-
- return service;
- }
-
- void releaseService(QMediaService *) {}
-
- inline QtTestMediaPlayerControl *playerControl() { return service->playerControl; }
- inline QtTestMetaDataControl *metaDataControl() { return service->metaDataControl; }
-
- QtTestMediaService *service;
- QByteArray requestedService;
-};
-
-void tst_QDeclarativeAudio::initTestCase()
-{
- qRegisterMetaType<QDeclarativeAudio::Error>();
- qRegisterMetaType<QDeclarativeAudio::AudioRole>();
-}
-
-void tst_QDeclarativeAudio::nullPlayerControl()
-{
- QtTestMetaDataControl metaDataControl;
- QtTestMediaServiceProvider provider(0, &metaDataControl);
-
- QDeclarativeAudio audio;
- audio.classBegin();
-
- QCOMPARE(audio.source(), QUrl());
- audio.setSource(QUrl("http://example.com"));
- QCOMPARE(audio.source(), QUrl("http://example.com"));
-
- QCOMPARE(audio.playbackState(), audio.StoppedState);
- audio.play();
- QCOMPARE(audio.playbackState(), audio.StoppedState);
- audio.pause();
- QCOMPARE(audio.playbackState(), audio.StoppedState);
-
- QCOMPARE(audio.duration(), 0);
-
- QCOMPARE(audio.position(), 0);
- audio.seek(10000);
- QCOMPARE(audio.position(), 10000);
-
- QCOMPARE(audio.volume(), qreal(1.0));
- audio.setVolume(0.5);
- QCOMPARE(audio.volume(), qreal(0.5));
-
- QCOMPARE(audio.isMuted(), false);
- audio.setMuted(true);
- QCOMPARE(audio.isMuted(), true);
-
- QCOMPARE(audio.bufferProgress(), qreal(0));
-
- QCOMPARE(audio.isSeekable(), false);
-
- QCOMPARE(audio.playbackRate(), qreal(1.0));
-
- QCOMPARE(audio.status(), QDeclarativeAudio::NoMedia);
-
- QCOMPARE(audio.error(), QDeclarativeAudio::ServiceMissing);
-}
-
-void tst_QDeclarativeAudio::nullMetaDataControl()
-{
- QtTestMediaPlayerControl playerControl;
- QtTestMediaServiceProvider provider(&playerControl, 0);
-
- QDeclarativeAudio audio;
- audio.classBegin();
- audio.componentComplete();
-
- QVERIFY(audio.metaData());
-}
-
-void tst_QDeclarativeAudio::nullService()
-{
- QtTestMediaServiceProvider provider(0);
-
- QDeclarativeAudio audio;
- audio.classBegin();
-
- QCOMPARE(audio.source(), QUrl());
- audio.setSource(QUrl("http://example.com"));
- QCOMPARE(audio.source(), QUrl("http://example.com"));
-
- QCOMPARE(audio.playbackState(), audio.StoppedState);
- audio.play();
- QCOMPARE(audio.playbackState(), audio.StoppedState);
- audio.pause();
- QCOMPARE(audio.playbackState(), audio.StoppedState);
-
- QCOMPARE(audio.duration(), 0);
-
- QCOMPARE(audio.position(), 0);
- audio.seek(10000);
- QCOMPARE(audio.position(), 10000);
-
- QCOMPARE(audio.volume(), qreal(1.0));
- audio.setVolume(0.5);
- QCOMPARE(audio.volume(), qreal(0.5));
-
- QCOMPARE(audio.isMuted(), false);
- audio.setMuted(true);
- QCOMPARE(audio.isMuted(), true);
-
- QCOMPARE(audio.bufferProgress(), qreal(0));
-
- QCOMPARE(audio.isSeekable(), false);
-
- QCOMPARE(audio.playbackRate(), qreal(1.0));
-
- QCOMPARE(audio.status(), QDeclarativeAudio::NoMedia);
-
- QCOMPARE(audio.error(), QDeclarativeAudio::ServiceMissing);
-
- QVERIFY(audio.metaData());
-}
-
-void tst_QDeclarativeAudio::source()
-{
- const QUrl url1("http://example.com");
- const QUrl url2("file:///local/path");
- const QUrl url3;
-
- QtTestMediaServiceProvider provider;
- QDeclarativeAudio audio;
- audio.classBegin();
- audio.componentComplete();
-
- QSignalSpy spy(&audio, SIGNAL(sourceChanged()));
-
- audio.setSource(url1);
- QCOMPARE(audio.source(), url1);
- QCOMPARE(provider.playerControl()->media().request().url(), url1);
- QCOMPARE(spy.count(), 1);
-
- audio.setSource(url2);
- QCOMPARE(audio.source(), url2);
- QCOMPARE(provider.playerControl()->media().request().url(), url2);
- QCOMPARE(spy.count(), 2);
-
- audio.setSource(url3);
- QCOMPARE(audio.source(), url3);
- QCOMPARE(provider.playerControl()->media().request().url(), url3);
- QCOMPARE(spy.count(), 3);
-}
-
-void tst_QDeclarativeAudio::autoLoad()
-{
- QtTestMediaServiceProvider provider;
- QDeclarativeAudio audio;
- audio.classBegin();
- audio.componentComplete();
-
- QSignalSpy spy(&audio, SIGNAL(autoLoadChanged()));
-
- QCOMPARE(audio.isAutoLoad(), true);
-
- audio.setAutoLoad(false);
- QCOMPARE(audio.isAutoLoad(), false);
- QCOMPARE(spy.count(), 1);
-
- audio.setSource(QUrl("http://example.com"));
- QCOMPARE(audio.source(), QUrl("http://example.com"));
- audio.play();
- QCOMPARE(audio.playbackState(), audio.PlayingState);
- audio.stop();
-
- audio.setAutoLoad(true);
- audio.setSource(QUrl("http://example.com"));
- audio.pause();
- QCOMPARE(spy.count(), 2);
- QCOMPARE(audio.playbackState(), audio.PausedState);
-}
-
-void tst_QDeclarativeAudio::playing()
-{
- QtTestMediaServiceProvider provider;
- QDeclarativeAudio audio;
- audio.classBegin();
-
- QSignalSpy stateChangedSpy(&audio, SIGNAL(playbackStateChanged()));
- QSignalSpy playingSpy(&audio, SIGNAL(playing()));
- QSignalSpy stoppedSpy(&audio, SIGNAL(stopped()));
-
- int stateChanged = 0;
- int playing = 0;
- int stopped = 0;
-
- audio.componentComplete();
- audio.setSource(QUrl("http://example.com"));
-
- QCOMPARE(audio.playbackState(), audio.StoppedState);
-
- // play() when stopped.
- audio.play();
- QCOMPARE(audio.playbackState(), audio.PlayingState);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(stateChangedSpy.count(), ++stateChanged);
- QCOMPARE(playingSpy.count(), ++playing);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // stop() when playing.
- audio.stop();
- QCOMPARE(audio.playbackState(), audio.StoppedState);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(stateChangedSpy.count(), ++stateChanged);
- QCOMPARE(playingSpy.count(), playing);
- QCOMPARE(stoppedSpy.count(), ++stopped);
-
- // stop() when stopped.
- audio.stop();
- QCOMPARE(audio.playbackState(), audio.StoppedState);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(stateChangedSpy.count(), stateChanged);
- QCOMPARE(playingSpy.count(), playing);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- audio.play();
- QCOMPARE(audio.playbackState(), audio.PlayingState);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(stateChangedSpy.count(), ++stateChanged);
- QCOMPARE(playingSpy.count(), ++playing);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // play() when playing.
- audio.play();
- QCOMPARE(audio.playbackState(), audio.PlayingState);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(stateChangedSpy.count(), stateChanged);
- QCOMPARE(playingSpy.count(), playing);
- QCOMPARE(stoppedSpy.count(), stopped);
-}
-
-void tst_QDeclarativeAudio::paused()
-{
- QtTestMediaServiceProvider provider;
- QDeclarativeAudio audio;
- audio.classBegin();
-
- QSignalSpy stateChangedSpy(&audio, SIGNAL(playbackStateChanged()));
- QSignalSpy pausedSpy(&audio, SIGNAL(paused()));
- int stateChanged = 0;
- int pausedCount = 0;
-
- audio.componentComplete();
- audio.setSource(QUrl("http://example.com"));
-
- QCOMPARE(audio.playbackState(), audio.StoppedState);
-
- // play() when stopped.
- audio.play();
- QCOMPARE(audio.playbackState(), audio.PlayingState);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(stateChangedSpy.count(), ++stateChanged);
- QCOMPARE(pausedSpy.count(), pausedCount);
-
- // pause() when playing.
- audio.pause();
- QCOMPARE(audio.playbackState(), audio.PausedState);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(stateChangedSpy.count(), ++stateChanged);
- QCOMPARE(pausedSpy.count(), ++pausedCount);
-
- // pause() when paused.
- audio.pause();
- QCOMPARE(audio.playbackState(), audio.PausedState);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(stateChangedSpy.count(), stateChanged);
- QCOMPARE(pausedSpy.count(), pausedCount);
-
- // stop() when paused.
- audio.stop();
- QCOMPARE(audio.playbackState(), audio.StoppedState);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(stateChangedSpy.count(), ++stateChanged);
- QCOMPARE(pausedSpy.count(), pausedCount);
-
- // pause() when stopped.
- audio.pause();
- QCOMPARE(audio.playbackState(), audio.PausedState);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(stateChangedSpy.count(), ++stateChanged);
- QCOMPARE(pausedSpy.count(), ++pausedCount);
-
- // play() when paused.
- audio.play();
- QCOMPARE(audio.playbackState(), audio.PlayingState);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(stateChangedSpy.count(), ++stateChanged);
- QCOMPARE(pausedSpy.count(), pausedCount);
-}
-
-void tst_QDeclarativeAudio::duration()
-{
- QtTestMediaServiceProvider provider;
- QDeclarativeAudio audio;
- audio.classBegin();
- audio.componentComplete();
-
- QSignalSpy spy(&audio, SIGNAL(durationChanged()));
-
- QCOMPARE(audio.duration(), 0);
-
- provider.playerControl()->setDuration(4040);
- QCOMPARE(audio.duration(), 4040);
- QCOMPARE(spy.count(), 1);
-
- provider.playerControl()->setDuration(-129);
- QCOMPARE(audio.duration(), -129);
- QCOMPARE(spy.count(), 2);
-
- provider.playerControl()->setDuration(0);
- QCOMPARE(audio.duration(), 0);
- QCOMPARE(spy.count(), 3);
-
- // Unnecessary duration changed signals aren't filtered.
- provider.playerControl()->setDuration(0);
- QCOMPARE(audio.duration(), 0);
- QCOMPARE(spy.count(), 4);
-}
-
-void tst_QDeclarativeAudio::position()
-{
- QtTestMediaServiceProvider provider;
- QDeclarativeAudio audio;
- audio.classBegin();
- audio.componentComplete();
-
- QSignalSpy spy(&audio, SIGNAL(positionChanged()));
-
- QCOMPARE(audio.position(), 0);
-
- // QDeclarativeAudio won't bound set positions to the duration. A media service may though.
- QCOMPARE(audio.duration(), 0);
-
- audio.seek(450);
- QCOMPARE(audio.position(), 450);
- QCOMPARE(provider.playerControl()->position(), qint64(450));
- QCOMPARE(spy.count(), 1);
-
- audio.seek(-5403);
- QCOMPARE(audio.position(), 0);
- QCOMPARE(provider.playerControl()->position(), qint64(0));
- QCOMPARE(spy.count(), 2);
-
- audio.seek(-5403);
- QCOMPARE(audio.position(), 0);
- QCOMPARE(provider.playerControl()->position(), qint64(0));
- QCOMPARE(spy.count(), 2);
-
- // Check the signal change signal is emitted if the change originates from the media service.
- provider.playerControl()->setPosition(450);
- QCOMPARE(audio.position(), 450);
- QCOMPARE(spy.count(), 3);
-
- connect(&audio, SIGNAL(positionChanged()), &QTestEventLoop::instance(), SLOT(exitLoop()));
-
- provider.playerControl()->updateState(QMediaPlayer::PlayingState);
- QTestEventLoop::instance().enterLoop(2);
- QVERIFY(spy.count() > 3 && spy.count() < 6); // 4 or 5
-
- provider.playerControl()->updateState(QMediaPlayer::PausedState);
- QTestEventLoop::instance().enterLoop(1);
- QVERIFY(spy.count() < 6);
-}
-
-void tst_QDeclarativeAudio::volume()
-{
- QtTestMediaServiceProvider provider;
- QDeclarativeAudio audio;
- audio.classBegin();
- audio.componentComplete();
-
- QSignalSpy spy(&audio, SIGNAL(volumeChanged()));
-
- QCOMPARE(audio.volume(), qreal(1.0));
-
- audio.setVolume(0.7);
- QCOMPARE(audio.volume(), qreal(0.7));
- QCOMPARE(provider.playerControl()->volume(), 70);
- QCOMPARE(spy.count(), 1);
-
- audio.setVolume(0.7);
- QCOMPARE(audio.volume(), qreal(0.7));
- QCOMPARE(provider.playerControl()->volume(), 70);
- QCOMPARE(spy.count(), 1);
-
- provider.playerControl()->setVolume(30);
- QCOMPARE(audio.volume(), qreal(0.3));
- QCOMPARE(spy.count(), 2);
-}
-
-void tst_QDeclarativeAudio::muted()
-{
- QtTestMediaServiceProvider provider;
- QDeclarativeAudio audio;
- audio.classBegin();
- audio.componentComplete();
-
- QSignalSpy spy(&audio, SIGNAL(mutedChanged()));
-
- QCOMPARE(audio.isMuted(), false);
-
- audio.setMuted(true);
- QCOMPARE(audio.isMuted(), true);
- QCOMPARE(provider.playerControl()->isMuted(), true);
- QCOMPARE(spy.count(), 1);
-
- provider.playerControl()->setMuted(false);
- QCOMPARE(audio.isMuted(), false);
- QCOMPARE(spy.count(), 2);
-
- audio.setMuted(false);
- QCOMPARE(audio.isMuted(), false);
- QCOMPARE(provider.playerControl()->isMuted(), false);
- QCOMPARE(spy.count(), 2);
-}
-
-void tst_QDeclarativeAudio::bufferProgress()
-{
- QtTestMediaServiceProvider provider;
- QDeclarativeAudio audio;
- audio.classBegin();
- audio.componentComplete();
-
- QSignalSpy spy(&audio, SIGNAL(bufferProgressChanged()));
-
- QCOMPARE(audio.bufferProgress(), qreal(0.0));
-
- provider.playerControl()->setBufferStatus(20);
- QCOMPARE(audio.bufferProgress(), qreal(0.2));
- QCOMPARE(spy.count(), 1);
-
- provider.playerControl()->setBufferStatus(20);
- QCOMPARE(audio.bufferProgress(), qreal(0.2));
- QCOMPARE(spy.count(), 2);
-
- provider.playerControl()->setBufferStatus(40);
- QCOMPARE(audio.bufferProgress(), qreal(0.4));
- QCOMPARE(spy.count(), 3);
-
- connect(&audio, SIGNAL(positionChanged()), &QTestEventLoop::instance(), SLOT(exitLoop()));
-
- provider.playerControl()->updateMediaStatus(
- QMediaPlayer::BufferingMedia, QMediaPlayer::PlayingState);
- QTestEventLoop::instance().enterLoop(2);
- QVERIFY(spy.count() > 3 && spy.count() < 6); // 4 or 5
-
- provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferedMedia);
- QTestEventLoop::instance().enterLoop(1);
- QVERIFY(spy.count() < 6);
-}
-
-void tst_QDeclarativeAudio::seekable()
-{
- QtTestMediaServiceProvider provider;
- QDeclarativeAudio audio;
- audio.classBegin();
- audio.componentComplete();
-
- QSignalSpy spy(&audio, SIGNAL(seekableChanged()));
-
- QCOMPARE(audio.isSeekable(), false);
-
- provider.playerControl()->setSeekable(true);
- QCOMPARE(audio.isSeekable(), true);
- QCOMPARE(spy.count(), 1);
-
- provider.playerControl()->setSeekable(true);
- QCOMPARE(audio.isSeekable(), true);
- QCOMPARE(spy.count(), 2);
-
- provider.playerControl()->setSeekable(false);
- QCOMPARE(audio.isSeekable(), false);
- QCOMPARE(spy.count(), 3);
-}
-
-void tst_QDeclarativeAudio::playbackRate()
-{
- QtTestMediaServiceProvider provider;
- QDeclarativeAudio audio;
- audio.classBegin();
- audio.componentComplete();
-
- QSignalSpy spy(&audio, SIGNAL(playbackRateChanged()));
-
- QCOMPARE(audio.playbackRate(), qreal(1.0));
-
- audio.setPlaybackRate(0.5);
- QCOMPARE(audio.playbackRate(), qreal(0.5));
- QCOMPARE(provider.playerControl()->playbackRate(), qreal(0.5));
- QCOMPARE(spy.count(), 1);
-
- provider.playerControl()->setPlaybackRate(2.0);
- QCOMPARE(provider.playerControl()->playbackRate(), qreal(2.0));
- QCOMPARE(spy.count(), 2);
-
- audio.setPlaybackRate(2.0);
- QCOMPARE(audio.playbackRate(), qreal(2.0));
- QCOMPARE(provider.playerControl()->playbackRate(), qreal(2.0));
- QCOMPARE(spy.count(), 2);
-}
-
-void tst_QDeclarativeAudio::status()
-{
- QtTestMediaServiceProvider provider;
- QDeclarativeAudio audio;
- audio.classBegin();
- audio.componentComplete();
-
- QSignalSpy statusChangedSpy(&audio, SIGNAL(statusChanged()));
-
- QCOMPARE(audio.status(), QDeclarativeAudio::NoMedia);
-
- // Set media, start loading.
- provider.playerControl()->updateMediaStatus(QMediaPlayer::LoadingMedia);
- QCOMPARE(audio.status(), QDeclarativeAudio::Loading);
- QCOMPARE(statusChangedSpy.count(), 1);
-
- // Finish loading.
- provider.playerControl()->updateMediaStatus(QMediaPlayer::LoadedMedia);
- QCOMPARE(audio.status(), QDeclarativeAudio::Loaded);
- QCOMPARE(statusChangedSpy.count(), 2);
-
- // Play, start buffering.
- provider.playerControl()->updateMediaStatus(
- QMediaPlayer::StalledMedia, QMediaPlayer::PlayingState);
- QCOMPARE(audio.status(), QDeclarativeAudio::Stalled);
- QCOMPARE(statusChangedSpy.count(), 3);
-
- // Enough data buffered to proceed.
- provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferingMedia);
- QCOMPARE(audio.status(), QDeclarativeAudio::Buffering);
- QCOMPARE(statusChangedSpy.count(), 4);
-
- // Errant second buffering status changed.
- provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferingMedia);
- QCOMPARE(audio.status(), QDeclarativeAudio::Buffering);
- QCOMPARE(statusChangedSpy.count(), 4);
-
- // Buffer full.
- provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferedMedia);
- QCOMPARE(audio.status(), QDeclarativeAudio::Buffered);
- QCOMPARE(statusChangedSpy.count(), 5);
-
- // Buffer getting low.
- provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferingMedia);
- QCOMPARE(audio.status(), QDeclarativeAudio::Buffering);
- QCOMPARE(statusChangedSpy.count(), 6);
-
- // Buffer full.
- provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferedMedia);
- QCOMPARE(audio.status(), QDeclarativeAudio::Buffered);
- QCOMPARE(statusChangedSpy.count(), 7);
-
- // Finished.
- provider.playerControl()->updateMediaStatus(
- QMediaPlayer::EndOfMedia, QMediaPlayer::StoppedState);
- QCOMPARE(audio.status(), QDeclarativeAudio::EndOfMedia);
- QCOMPARE(statusChangedSpy.count(), 8);
-}
-
-void tst_QDeclarativeAudio::metaData_data()
-{
- QTest::addColumn<QByteArray>("propertyName");
- QTest::addColumn<QString>("propertyKey");
- QTest::addColumn<QVariant>("value");
-
- QTest::newRow("title")
- << QByteArray("title")
- << QMediaMetaData::Title
- << QVariant(QString::fromLatin1("This is a title"));
-
- QTest::newRow("genre")
- << QByteArray("genre")
- << QMediaMetaData::Genre
- << QVariant(QString::fromLatin1("rock"));
-
- QTest::newRow("trackNumber")
- << QByteArray("trackNumber")
- << QMediaMetaData::TrackNumber
- << QVariant(8);
-}
-
-void tst_QDeclarativeAudio::metaData()
-{
- QFETCH(QByteArray, propertyName);
- QFETCH(QString, propertyKey);
- QFETCH(QVariant, value);
-
- QtTestMediaServiceProvider provider;
- QDeclarativeAudio audio;
- audio.classBegin();
- audio.componentComplete();
-
- QSignalSpy spy(audio.metaData(), SIGNAL(metaDataChanged()));
-
- const int index = audio.metaData()->metaObject()->indexOfProperty(propertyName.constData());
- QVERIFY(index != -1);
-
- QMetaProperty property = audio.metaData()->metaObject()->property(index);
- QCOMPARE(property.read(&audio), QVariant());
-
- property.write(audio.metaData(), value);
- QCOMPARE(property.read(audio.metaData()), QVariant());
- QCOMPARE(provider.metaDataControl()->metaData(propertyKey), QVariant());
- QCOMPARE(spy.count(), 0);
-
- provider.metaDataControl()->setMetaData(propertyKey, value);
- QCOMPARE(property.read(audio.metaData()), value);
- QCOMPARE(spy.count(), 1);
-}
-
-void tst_QDeclarativeAudio::error()
-{
- const QString errorString = QLatin1String("Failed to open device.");
-
- QtTestMediaServiceProvider provider;
- QDeclarativeAudio audio;
- audio.classBegin();
- audio.componentComplete();
-
- QSignalSpy errorSpy(&audio, SIGNAL(error(QDeclarativeAudio::Error,QString)));
- QSignalSpy errorChangedSpy(&audio, SIGNAL(errorChanged()));
-
- QCOMPARE(audio.error(), QDeclarativeAudio::NoError);
- QCOMPARE(audio.errorString(), QString());
-
- provider.playerControl()->emitError(QMediaPlayer::ResourceError, errorString);
-
- QCOMPARE(audio.error(), QDeclarativeAudio::ResourceError);
- QCOMPARE(audio.errorString(), errorString);
- QCOMPARE(errorSpy.count(), 1);
- QCOMPARE(errorChangedSpy.count(), 1);
-
- // Changing the source resets the error properties.
- audio.setSource(QUrl("http://example.com"));
- QCOMPARE(audio.error(), QDeclarativeAudio::NoError);
- QCOMPARE(audio.errorString(), QString());
- QCOMPARE(errorSpy.count(), 1);
- QCOMPARE(errorChangedSpy.count(), 2);
-
- // But isn't noisy.
- audio.setSource(QUrl("file:///file/path"));
- QCOMPARE(audio.error(), QDeclarativeAudio::NoError);
- QCOMPARE(audio.errorString(), QString());
- QCOMPARE(errorSpy.count(), 1);
- QCOMPARE(errorChangedSpy.count(), 2);
-}
-
-void tst_QDeclarativeAudio::loops()
-{
- QtTestMediaServiceProvider provider;
- QDeclarativeAudio audio;
-
- QSignalSpy loopsChangedSpy(&audio, SIGNAL(loopCountChanged()));
- QSignalSpy stateChangedSpy(&audio, SIGNAL(playbackStateChanged()));
- QSignalSpy stoppedSpy(&audio, SIGNAL(stopped()));
-
- int stateChanged = 0;
- int loopsChanged = 0;
- int stoppedCount = 0;
-
- audio.classBegin();
- audio.componentComplete();
-
- QCOMPARE(audio.playbackState(), audio.StoppedState);
-
- //setLoopCount(3) when stopped.
- audio.setLoopCount(3);
- QCOMPARE(audio.loopCount(), 3);
- QCOMPARE(loopsChangedSpy.count(), ++loopsChanged);
-
- //play till end
- audio.play();
- QCOMPARE(audio.playbackState(), audio.PlayingState);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(stateChangedSpy.count(), ++stateChanged);
- QCOMPARE(stoppedSpy.count(), stoppedCount);
-
- // play() when playing.
- audio.play();
- QCOMPARE(audio.playbackState(), audio.PlayingState);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(stateChangedSpy.count(), stateChanged);
- QCOMPARE(stoppedSpy.count(), stoppedCount);
-
- provider.playerControl()->updateMediaStatus(QMediaPlayer::EndOfMedia, QMediaPlayer::StoppedState);
- QCOMPARE(audio.playbackState(), audio.PlayingState);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(stateChangedSpy.count(), stateChanged);
- QCOMPARE(stoppedSpy.count(), stoppedCount);
-
- //play to end
- provider.playerControl()->updateMediaStatus(QMediaPlayer::EndOfMedia, QMediaPlayer::StoppedState);
- QCOMPARE(stoppedSpy.count(), stoppedCount);
- //play to end
- provider.playerControl()->updateMediaStatus(QMediaPlayer::EndOfMedia, QMediaPlayer::StoppedState);
- QCOMPARE(audio.playbackState(), audio.StoppedState);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(stateChangedSpy.count(), ++stateChanged);
- QCOMPARE(stoppedSpy.count(), ++stoppedCount);
-
- // stop when playing
- audio.play();
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(stateChangedSpy.count(), ++stateChanged);
- QCOMPARE(stoppedSpy.count(), stoppedCount);
- provider.playerControl()->updateMediaStatus(QMediaPlayer::EndOfMedia, QMediaPlayer::StoppedState);
- audio.stop();
- QCOMPARE(audio.playbackState(), audio.StoppedState);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(stateChangedSpy.count(), ++stateChanged);
- QCOMPARE(stoppedSpy.count(), ++stoppedCount);
-
- //play() with infinite loop
- audio.setLoopCount(-1);
- QCOMPARE(audio.loopCount(), -1);
- QCOMPARE(loopsChangedSpy.count(), ++loopsChanged);
- audio.play();
- QCOMPARE(audio.playbackState(), audio.PlayingState);
- QCOMPARE(stateChangedSpy.count(), ++stateChanged);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- provider.playerControl()->updateMediaStatus(QMediaPlayer::EndOfMedia, QMediaPlayer::StoppedState);
- QCOMPARE(audio.playbackState(), audio.PlayingState);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(stateChangedSpy.count(), stateChanged);
-
- // stop() when playing in infinite loop.
- audio.stop();
- QCOMPARE(audio.playbackState(), audio.StoppedState);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(stateChangedSpy.count(), ++stateChanged);
- QCOMPARE(stoppedSpy.count(), ++stoppedCount);
-
- qDebug() << "Testing version 5";
-}
-
-void tst_QDeclarativeAudio::audioRole()
-{
- MockMediaPlayerService mockService;
- MockMediaServiceProvider mockProvider(&mockService);
- QMediaServiceProvider::setDefaultServiceProvider(&mockProvider);
-
- QQmlEngine engine;
- QQmlComponent component(&engine);
- component.setData("import QtQuick 2.0 \n import QtMultimedia 5.6 \n Audio { }", QUrl());
-
- {
- mockService.setHasAudioRole(false);
- QDeclarativeAudio *audio = static_cast<QDeclarativeAudio*>(component.create());
-
- QCOMPARE(audio->audioRole(), QDeclarativeAudio::UnknownRole);
- QVERIFY(audio->supportedAudioRoles().isArray());
- QVERIFY(audio->supportedAudioRoles().toVariant().toList().isEmpty());
-
- QSignalSpy spy(audio, SIGNAL(audioRoleChanged()));
- audio->setAudioRole(QDeclarativeAudio::MusicRole);
- QCOMPARE(audio->audioRole(), QDeclarativeAudio::UnknownRole);
- QCOMPARE(spy.count(), 0);
- }
-
- {
- mockService.reset();
- mockService.setHasAudioRole(true);
- QDeclarativeAudio *audio = static_cast<QDeclarativeAudio*>(component.create());
- QSignalSpy spy(audio, SIGNAL(audioRoleChanged()));
-
- QCOMPARE(audio->audioRole(), QDeclarativeAudio::UnknownRole);
- QVERIFY(audio->supportedAudioRoles().isArray());
- QVERIFY(!audio->supportedAudioRoles().toVariant().toList().isEmpty());
-
- audio->setAudioRole(QDeclarativeAudio::MusicRole);
- QCOMPARE(audio->audioRole(), QDeclarativeAudio::MusicRole);
- QCOMPARE(mockService.mockAudioRoleControl->audioRole(), QAudio::MusicRole);
- QCOMPARE(spy.count(), 1);
- }
-}
-
-void tst_QDeclarativeAudio::customAudioRole()
-{
- MockMediaPlayerService mockService;
- MockMediaServiceProvider mockProvider(&mockService);
- QMediaServiceProvider::setDefaultServiceProvider(&mockProvider);
-
- QQmlEngine engine;
- QQmlComponent component(&engine);
- component.setData("import QtQuick 2.0 \n import QtMultimedia 5.11 \n Audio { }", QUrl());
-
- {
- mockService.setHasCustomAudioRole(false);
- QObject *audio = component.create();
- QVERIFY(audio);
-
- QMetaEnum audioRoleEnum = enumerator(audio->metaObject(), "AudioRole");
- int AudioRole_UnknownRoleValue = keyToValue(audioRoleEnum, "UnknownRole");
- QVERIFY(!QTest::currentTestFailed());
-
- QVERIFY(audio->property("customAudioRole").toString().isEmpty());
-
- QSignalSpy spyRole(audio, SIGNAL(audioRoleChanged()));
- QSignalSpy spyCustomRole(audio, SIGNAL(customAudioRoleChanged()));
- audio->setProperty("customAudioRole", QStringLiteral("customRole"));
- QCOMPARE(audio->property("audioRole").toInt(), AudioRole_UnknownRoleValue);
- QVERIFY(audio->property("customAudioRole").toString().isEmpty());
- QCOMPARE(spyRole.count(), 0);
- QCOMPARE(spyCustomRole.count(), 0);
- }
-
- {
- mockService.reset();
- mockService.setHasAudioRole(false);
-
- QObject *audio = component.create();
- QVERIFY(audio);
-
- QMetaEnum audioRoleEnum = enumerator(audio->metaObject(), "AudioRole");
- int AudioRole_UnknownRoleValue = keyToValue(audioRoleEnum, "UnknownRole");
- QVERIFY(!QTest::currentTestFailed());
-
- QVERIFY(audio->property("customAudioRole").toString().isEmpty());
-
- QSignalSpy spyRole(audio, SIGNAL(audioRoleChanged()));
- QSignalSpy spyCustomRole(audio, SIGNAL(customAudioRoleChanged()));
- audio->setProperty("customAudioRole", QStringLiteral("customRole"));
- QCOMPARE(audio->property("audioRole").toInt(), AudioRole_UnknownRoleValue);
- QVERIFY(audio->property("customAudioRole").toString().isEmpty());
- QCOMPARE(spyRole.count(), 0);
- QCOMPARE(spyCustomRole.count(), 0);
- }
-
- {
- mockService.reset();
-
- QObject *audio = component.create();
- QVERIFY(audio);
-
- QMetaEnum audioRoleEnum = enumerator(audio->metaObject(), "AudioRole");
- int AudioRole_UnknownRoleValue = keyToValue(audioRoleEnum, "UnknownRole");
- int AudioRole_CustomRoleValue = keyToValue(audioRoleEnum, "CustomRole");
- int AudioRole_MusicRoleValue = keyToValue(audioRoleEnum, "MusicRole");
- QVERIFY(!QTest::currentTestFailed());
-
- QSignalSpy spyRole(audio, SIGNAL(audioRoleChanged()));
- QSignalSpy spyCustomRole(audio, SIGNAL(customAudioRoleChanged()));
-
- QCOMPARE(audio->property("audioRole").toInt(), AudioRole_UnknownRoleValue);
- QVERIFY(audio->property("customAudioRole").toString().isEmpty());
-
- QString customRole(QStringLiteral("customRole"));
- audio->setProperty("customAudioRole", customRole);
- QCOMPARE(audio->property("audioRole").toInt(), AudioRole_CustomRoleValue);
- QCOMPARE(audio->property("customAudioRole").toString(), customRole);
- QCOMPARE(mockService.mockAudioRoleControl->audioRole(), QAudio::CustomRole);
- QCOMPARE(mockService.mockCustomAudioRoleControl->customAudioRole(), customRole);
- QCOMPARE(spyRole.count(), 1);
- QCOMPARE(spyCustomRole.count(), 1);
-
- spyRole.clear();
- spyCustomRole.clear();
-
- QString customRole2(QStringLiteral("customRole2"));
- audio->setProperty("customAudioRole", customRole2);
- QCOMPARE(audio->property("customAudioRole").toString(), customRole2);
- QCOMPARE(mockService.mockCustomAudioRoleControl->customAudioRole(), customRole2);
- QCOMPARE(spyRole.count(), 0);
- QCOMPARE(spyCustomRole.count(), 1);
-
- spyRole.clear();
- spyCustomRole.clear();
-
- audio->setProperty("audioRole", AudioRole_MusicRoleValue);
- QCOMPARE(audio->property("audioRole").toInt(), AudioRole_MusicRoleValue);
- QVERIFY(audio->property("customAudioRole").toString().isEmpty());
- QCOMPARE(mockService.mockAudioRoleControl->audioRole(), QAudio::MusicRole);
- QVERIFY(mockService.mockCustomAudioRoleControl->customAudioRole().isEmpty());
- QCOMPARE(spyRole.count(), 1);
- QCOMPARE(spyCustomRole.count(), 1);
-
- spyRole.clear();
- spyCustomRole.clear();
-
- audio->setProperty("audioRole", AudioRole_CustomRoleValue);
- QCOMPARE(audio->property("audioRole").toInt(), AudioRole_CustomRoleValue);
- QVERIFY(audio->property("customAudioRole").toString().isEmpty());
- QCOMPARE(mockService.mockAudioRoleControl->audioRole(), QAudio::CustomRole);
- QVERIFY(mockService.mockCustomAudioRoleControl->customAudioRole().isEmpty());
- QCOMPARE(spyRole.count(), 1);
- QCOMPARE(spyCustomRole.count(), 0);
- }
-}
-
-void tst_QDeclarativeAudio::enumerator(const QMetaObject *object,
- const char *name,
- QMetaEnum *result)
-{
- int index = object->indexOfEnumerator(name);
- QVERIFY(index >= 0);
- *result = object->enumerator(index);
-}
-
-QMetaEnum tst_QDeclarativeAudio::enumerator(const QMetaObject *object, const char *name)
-{
- QMetaEnum result;
- enumerator(object, name, &result);
- return result;
-}
-
-void tst_QDeclarativeAudio::keyToValue(const QMetaEnum &enumeration, const char *key, int *result)
-{
- bool ok = false;
- *result = enumeration.keyToValue(key, &ok);
- QVERIFY(ok);
-}
-
-int tst_QDeclarativeAudio::keyToValue(const QMetaEnum &enumeration, const char *key)
-{
- int result;
- keyToValue(enumeration, key, &result);
- return result;
-}
-
-struct Surface : QAbstractVideoSurface
-{
- Surface(QObject *parent = nullptr) : QAbstractVideoSurface(parent) { }
- QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType) const override
- {
- return QList<QVideoFrame::PixelFormat>() << QVideoFrame::Format_RGB32;
- }
-
- bool present(const QVideoFrame &) override { return true; }
-};
-
-void tst_QDeclarativeAudio::videoOutput()
-{
- QtTestMediaPlayerControl playerControl;
- QtTestMediaServiceProvider provider(&playerControl, 0);
-
- QDeclarativeAudio audio;
- QSignalSpy spy(&audio, &QDeclarativeAudio::videoOutputChanged);
-
- audio.classBegin();
- audio.componentComplete();
-
- QVERIFY(audio.videoOutput().isNull());
-
- QVariant surface;
- surface.setValue(new Surface(this));
- audio.setVideoOutput(surface);
- QCOMPARE(audio.videoOutput(), surface);
- QCOMPARE(spy.count(), 1);
-
- QQmlEngine engine;
- QJSValue jsArray = engine.newArray(5);
- jsArray.setProperty(0, engine.newQObject(new Surface(this)));
- jsArray.setProperty(1, engine.newQObject(new Surface(this)));
- QDeclarativeVideoOutput output;
- jsArray.setProperty(2, engine.newQObject(&output));
- jsArray.setProperty(3, 123);
- jsArray.setProperty(4, QLatin1String("ignore this"));
-
- QVariant surfaces;
- surfaces.setValue(jsArray);
- audio.setVideoOutput(surfaces);
-
- auto arr = audio.videoOutput().value<QJSValue>();
- QVERIFY(arr.equals(jsArray));
- QCOMPARE(spy.count(), 2);
-}
-
-QTEST_MAIN(tst_QDeclarativeAudio)
-
-#include "tst_qdeclarativeaudio.moc"
diff --git a/tests/auto/unit/qdeclarativecamera/qdeclarativecamera.pro b/tests/auto/unit/qdeclarativecamera/qdeclarativecamera.pro
deleted file mode 100644
index 4e58f2293..000000000
--- a/tests/auto/unit/qdeclarativecamera/qdeclarativecamera.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-TARGET = tst_qdeclarativecamera
-CONFIG += warn_on qmltestcase
-
-QT += multimedia-private
-
-include (../qmultimedia_common/mock.pri)
-include (../qmultimedia_common/mockcamera.pri)
-
-SOURCES += \
- tst_qdeclarativecamera.cpp
-
-
-OTHER_FILES += \
- tst_qdeclarativecamera.qml
diff --git a/tests/auto/unit/qdeclarativecamera/tst_qdeclarativecamera.cpp b/tests/auto/unit/qdeclarativecamera/tst_qdeclarativecamera.cpp
deleted file mode 100644
index 2406e5be8..000000000
--- a/tests/auto/unit/qdeclarativecamera/tst_qdeclarativecamera.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtQuickTest/quicktest.h>
-
-#include "mockcameraservice.h"
-#include "mockmediaserviceprovider.h"
-
-int main(int argc, char **argv)
-{
- MockMediaServiceProvider provider;
- MockCameraService mockCameraService;
- provider.service = &mockCameraService;
- QMediaServiceProvider::setDefaultServiceProvider(&provider);
-
- return quick_test_main(argc, argv, "QDeclarativeCamera", QUICK_TEST_SOURCE_DIR);
-}
diff --git a/tests/auto/unit/qdeclarativecamera/tst_qdeclarativecamera.qml b/tests/auto/unit/qdeclarativecamera/tst_qdeclarativecamera.qml
deleted file mode 100644
index 20cee5d2f..000000000
--- a/tests/auto/unit/qdeclarativecamera/tst_qdeclarativecamera.qml
+++ /dev/null
@@ -1,296 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtTest 1.0
-import QtMultimedia 5.4
-
-TestCase {
-
- Component {
- id: cameraComponent
- Camera { }
- }
-
- Loader {
- id: cameraLoader
- }
-
- SignalSpy {
- id: deviceIdSpy
- target: cameraLoader.item
- signalName: "deviceIdChanged"
- }
-
- function test_deviceId() {
- deviceIdSpy.clear();
- cameraLoader.sourceComponent = cameraComponent;
- var camera = cameraLoader.item;
-
- // default camera
- compare(camera.deviceId, "othercamera", "deviceId");
- compare(camera.displayName, "othercamera desc", "displayName");
- compare(camera.position, Camera.UnspecifiedPosition, "position");
- compare(camera.orientation, 0, "orientation");
-
- // setting an invalid camera ID should leave the item unchanged
- camera.deviceId = "invalidcamera";
- compare(camera.deviceId, "othercamera");
- compare(deviceIdSpy.count, 0);
- compare(camera.displayName, "othercamera desc", "displayName");
- compare(camera.position, Camera.UnspecifiedPosition, "position");
- compare(camera.orientation, 0, "orientation");
-
- // change to another valid camera
- camera.deviceId = "backcamera";
- compare(camera.deviceId, "backcamera");
- compare(deviceIdSpy.count, 1);
- compare(camera.displayName, "backcamera desc", "displayName");
- compare(camera.position, Camera.BackFace, "position");
- compare(camera.orientation, 90, "orientation");
-
- // setting an empty device ID should load the default camera
- camera.deviceId = "";
- compare(camera.deviceId, "othercamera", "deviceId");
- compare(deviceIdSpy.count, 2);
-
- cameraLoader.sourceComponent = undefined;
- }
-
- function test_position() {
- deviceIdSpy.clear();
- cameraLoader.sourceComponent = cameraComponent;
- var camera = cameraLoader.item;
-
- // default camera
- compare(camera.position, Camera.UnspecifiedPosition, "position");
- compare(camera.deviceId, "othercamera", "deviceId");
-
- // setting an unavailable camera position should leave the item unchanged
- camera.position = Camera.FrontFace;
- compare(camera.position, Camera.UnspecifiedPosition, "position");
- compare(camera.deviceId, "othercamera", "deviceId");
- compare(deviceIdSpy.count, 0);
-
- // change to an available position
- camera.position = Camera.BackFace;
- compare(camera.position, Camera.BackFace, "position");
- compare(camera.deviceId, "backcamera", "deviceId");
- compare(deviceIdSpy.count, 1);
-
- // setting UnspecifiedPosition should load the default camera
- camera.position = Camera.UnspecifiedPosition;
- compare(camera.position, Camera.UnspecifiedPosition, "position");
- compare(camera.deviceId, "othercamera", "deviceId");
- compare(deviceIdSpy.count, 2);
-
- cameraLoader.sourceComponent = undefined;
- }
-
- SignalSpy {
- id: cameraStateSpy
- target: cameraLoader.item
- signalName: "cameraStateChanged"
- }
-
- function test_cameraState() {
- deviceIdSpy.clear();
- cameraStateSpy.clear();
- cameraLoader.sourceComponent = cameraComponent;
- var camera = cameraLoader.item;
-
- // camera should be in ActiveState by default
- compare(camera.cameraState, Camera.ActiveState, "cameraState");
- compare(camera.deviceId, "othercamera", "deviceId");
-
- // Changing the camera device should unload the previous camera and apply the current state
- // to the new camera
- camera.deviceId = "backcamera";
- compare(camera.deviceId, "backcamera", "deviceId");
- compare(camera.cameraState, Camera.ActiveState, "cameraState");
- compare(cameraStateSpy.count, 2);
- compare(cameraStateSpy.signalArguments[0][0], Camera.UnloadedState);
- compare(cameraStateSpy.signalArguments[1][0], Camera.ActiveState);
-
- cameraLoader.sourceComponent = undefined;
- }
-
- function test_supportedViewfinderResolutions_data() {
- // see mockcameraviewfindersettingscontrol.h for expected values
-
- return [
- {
- tag: "all",
- minimumFrameRate: 0, maximumFrameRate: 0,
- expectedResolutions: [
- { width: 320, height: 240 },
- { width: 640, height: 480 },
- { width: 1280, height: 720 },
- { width: 1920, height: 1080 }
- ]
- },
- {
- tag: "invalid minimumFrameRate",
- minimumFrameRate: 2, maximumFrameRate: 0,
- expectedResolutions: [ ]
- },
- {
- tag: "minimumFrameRate=5",
- minimumFrameRate: 5, maximumFrameRate: 0,
- expectedResolutions: [
- { width: 1920, height: 1080 }
- ]
- },
- {
- tag: "minimumFrameRate=10",
- minimumFrameRate: 10, maximumFrameRate: 0,
- expectedResolutions: [
- { width: 1280, height: 720 }
- ]
- },
- {
- tag: "minimumFrameRate=30",
- minimumFrameRate: 30, maximumFrameRate: 0,
- expectedResolutions: [
- { width: 320, height: 240 },
- { width: 640, height: 480 },
- { width: 1280, height: 720 }
- ]
- },
- {
- tag: "invalid maximumFrameRate",
- minimumFrameRate: 0, maximumFrameRate: 2,
- expectedResolutions: [ ]
- },
- {
- tag: "maximumFrameRate=10",
- minimumFrameRate: 0, maximumFrameRate: 10,
- expectedResolutions: [
- { width: 1280, height: 720 },
- { width: 1920, height: 1080 }
- ]
- },
- {
- tag: "minimumFrameRate=10, maximumFrameRate=10",
- minimumFrameRate: 10, maximumFrameRate: 10,
- expectedResolutions: [
- { width: 1280, height: 720 }
- ]
- },
- {
- tag: "minimumFrameRate=30, maximumFrameRate=30",
- minimumFrameRate: 30, maximumFrameRate: 30,
- expectedResolutions: [
- { width: 320, height: 240 },
- { width: 640, height: 480 },
- { width: 1280, height: 720 }
- ]
- }
- ]
- }
-
- function test_supportedViewfinderResolutions(data) {
- cameraLoader.sourceComponent = cameraComponent;
- var camera = cameraLoader.item;
-
- var actualResolutions = camera.supportedViewfinderResolutions(data.minimumFrameRate, data.maximumFrameRate);
- compare(actualResolutions.length, data.expectedResolutions.length);
- for (var i = 0; i < actualResolutions.length; ++i) {
- compare(actualResolutions[i].width, data.expectedResolutions[i].width);
- compare(actualResolutions[i].height, data.expectedResolutions[i].height);
- }
-
- cameraLoader.sourceComponent = undefined;
- }
-
- function test_supportedViewfinderFrameRateRanges_data() {
- // see mockcameraviewfindersettingscontrol.h for expected values
- return [
- {
- tag: "all",
- expectedFrameRateRanges: [
- { minimumFrameRate: 5, maximumFrameRate: 10 },
- { minimumFrameRate: 10, maximumFrameRate: 10 },
- { minimumFrameRate: 30, maximumFrameRate: 30 }
- ]
- },
- {
- tag: "invalid",
- resolution: { width: 452472, height: 444534 },
- expectedFrameRateRanges: [ ]
- },
- {
- tag: "320, 240",
- resolution: { width: 320, height: 240 },
- expectedFrameRateRanges: [
- { minimumFrameRate: 30, maximumFrameRate: 30 }
- ]
- },
- {
- tag: "1280, 720",
- resolution: { width: 1280, height: 720 },
- expectedFrameRateRanges: [
- { minimumFrameRate: 10, maximumFrameRate: 10 },
- { minimumFrameRate: 30, maximumFrameRate: 30 }
- ]
- },
- {
- tag: "1920, 1080",
- resolution: { width: 1920, height: 1080 },
- expectedFrameRateRanges: [
- { minimumFrameRate: 5, maximumFrameRate: 10 }
- ]
- }
- ]
- }
-
- function test_supportedViewfinderFrameRateRanges(data) {
- cameraLoader.sourceComponent = cameraComponent;
- var camera = cameraLoader.item;
-
- // Pass the resolution as an object
- var actualFrameRateRanges = camera.supportedViewfinderFrameRateRanges(data.resolution);
- compare(actualFrameRateRanges.length, data.expectedFrameRateRanges.length);
- for (var i = 0; i < actualFrameRateRanges.length; ++i) {
- compare(actualFrameRateRanges[i].minimumFrameRate, data.expectedFrameRateRanges[i].minimumFrameRate);
- compare(actualFrameRateRanges[i].maximumFrameRate, data.expectedFrameRateRanges[i].maximumFrameRate);
- }
-
- // Pass the resolution as a size
- if (typeof data.resolution !== 'undefined') {
- actualFrameRateRanges = camera.supportedViewfinderFrameRateRanges(Qt.size(data.resolution.width, data.resolution.height));
- compare(actualFrameRateRanges.length, data.expectedFrameRateRanges.length);
- for (i = 0; i < actualFrameRateRanges.length; ++i) {
- compare(actualFrameRateRanges[i].minimumFrameRate, data.expectedFrameRateRanges[i].minimumFrameRate);
- compare(actualFrameRateRanges[i].maximumFrameRate, data.expectedFrameRateRanges[i].maximumFrameRate);
- }
- }
-
- cameraLoader.sourceComponent = undefined;
- }
-}
diff --git a/tests/auto/unit/qdeclarativemultimediaglobal/qdeclarativemultimediaglobal.pro b/tests/auto/unit/qdeclarativemultimediaglobal/qdeclarativemultimediaglobal.pro
deleted file mode 100644
index f806b054b..000000000
--- a/tests/auto/unit/qdeclarativemultimediaglobal/qdeclarativemultimediaglobal.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-TARGET = tst_qdeclarativemultimediaglobal
-CONFIG += warn_on qmltestcase
-
-QT += multimedia-private
-
-include (../qmultimedia_common/mock.pri)
-include (../qmultimedia_common/mockcamera.pri)
-
-SOURCES += \
- tst_qdeclarativemultimediaglobal.cpp
-
-
-OTHER_FILES += \
- tst_qdeclarativemultimediaglobal.qml
diff --git a/tests/auto/unit/qdeclarativemultimediaglobal/tst_qdeclarativemultimediaglobal.cpp b/tests/auto/unit/qdeclarativemultimediaglobal/tst_qdeclarativemultimediaglobal.cpp
deleted file mode 100644
index d78eb0076..000000000
--- a/tests/auto/unit/qdeclarativemultimediaglobal/tst_qdeclarativemultimediaglobal.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtQuickTest/quicktest.h>
-
-#include "mockcameraservice.h"
-#include "mockmediaserviceprovider.h"
-
-int main(int argc, char **argv)
-{
- MockMediaServiceProvider provider;
- MockCameraService mockCameraService;
- provider.service = &mockCameraService;
- QMediaServiceProvider::setDefaultServiceProvider(&provider);
-
- return quick_test_main(argc, argv, "QDeclarativeMultimediaGlobal", QUICK_TEST_SOURCE_DIR);
-}
diff --git a/tests/auto/unit/qdeclarativemultimediaglobal/tst_qdeclarativemultimediaglobal.qml b/tests/auto/unit/qdeclarativemultimediaglobal/tst_qdeclarativemultimediaglobal.qml
deleted file mode 100644
index e44c68a29..000000000
--- a/tests/auto/unit/qdeclarativemultimediaglobal/tst_qdeclarativemultimediaglobal.qml
+++ /dev/null
@@ -1,180 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtTest 1.0
-import QtMultimedia 5.4
-
-TestCase {
-
- function test_0_globalObject() {
- verify(typeof QtMultimedia !== 'undefined');
- }
-
- function test_1_defaultCamera() {
- verify(typeof QtMultimedia.defaultCamera !== 'undefined');
-
- var camera = QtMultimedia.defaultCamera;
- compare(camera.deviceId, "othercamera", "deviceId");
- compare(camera.displayName, "othercamera desc", "displayName");
- compare(camera.position, Camera.UnspecifiedPosition, "position");
- compare(camera.orientation, 0, "orientation");
- }
-
- function test_2_availableCameras() {
- verify(typeof QtMultimedia.availableCameras !== 'undefined');
- compare(QtMultimedia.availableCameras.length, 2);
-
- var camera = QtMultimedia.availableCameras[0];
- compare(camera.deviceId, "backcamera", "deviceId");
- compare(camera.displayName, "backcamera desc", "displayName");
- compare(camera.position, Camera.BackFace, "position");
- compare(camera.orientation, 90, "orientation");
-
- camera = QtMultimedia.availableCameras[1];
- compare(camera.deviceId, "othercamera", "deviceId");
- compare(camera.displayName, "othercamera desc", "displayName");
- compare(camera.position, Camera.UnspecifiedPosition, "position");
- compare(camera.orientation, 0, "orientation");
- }
-
- function test_convertVolume_data() {
- return [
- { tag: "-1.0 from linear to linear", input: -1, from: QtMultimedia.LinearVolumeScale, to: QtMultimedia.LinearVolumeScale, expectedOutput: 0 },
- { tag: "0.0 from linear to linear", input: 0, from: QtMultimedia.LinearVolumeScale, to: QtMultimedia.LinearVolumeScale, expectedOutput: 0 },
- { tag: "0.5 from linear to linear", input: 0.5, from: QtMultimedia.LinearVolumeScale, to: QtMultimedia.LinearVolumeScale, expectedOutput: 0.5 },
- { tag: "1.0 from linear to linear", input: 1.0, from: QtMultimedia.LinearVolumeScale, to: QtMultimedia.LinearVolumeScale, expectedOutput: 1.0 },
-
- { tag: "-1.0 from linear to cubic", input: -1, from: QtMultimedia.LinearVolumeScale, to: QtMultimedia.CubicVolumeScale, expectedOutput: 0 },
- { tag: "0.0 from linear to cubic", input: 0, from: QtMultimedia.LinearVolumeScale, to: QtMultimedia.CubicVolumeScale, expectedOutput: 0 },
- { tag: "0.33 from linear to cubic", input: 0.33, from: QtMultimedia.LinearVolumeScale, to: QtMultimedia.CubicVolumeScale, expectedOutput: 0.69 },
- { tag: "0.5 from linear to cubic", input: 0.5, from: QtMultimedia.LinearVolumeScale, to: QtMultimedia.CubicVolumeScale, expectedOutput: 0.79 },
- { tag: "0.72 from linear to cubic", input: 0.72, from: QtMultimedia.LinearVolumeScale, to: QtMultimedia.CubicVolumeScale, expectedOutput: 0.89 },
- { tag: "1.0 from linear to cubic", input: 1.0, from: QtMultimedia.LinearVolumeScale, to: QtMultimedia.CubicVolumeScale, expectedOutput: 1.0 },
-
- { tag: "-1.0 from linear to logarithmic", input: -1, from: QtMultimedia.LinearVolumeScale, to: QtMultimedia.LogarithmicVolumeScale, expectedOutput: 0 },
- { tag: "0.0 from linear to logarithmic", input: 0, from: QtMultimedia.LinearVolumeScale, to: QtMultimedia.LogarithmicVolumeScale, expectedOutput: 0 },
- { tag: "0.33 from linear to logarithmic", input: 0.33, from: QtMultimedia.LinearVolumeScale, to: QtMultimedia.LogarithmicVolumeScale, expectedOutput: 0.78 },
- { tag: "0.5 from linear to logarithmic", input: 0.5, from: QtMultimedia.LinearVolumeScale, to: QtMultimedia.LogarithmicVolumeScale, expectedOutput: 0.9 },
- { tag: "0.72 from linear to logarithmic", input: 0.72, from: QtMultimedia.LinearVolumeScale, to: QtMultimedia.LogarithmicVolumeScale, expectedOutput: 0.96 },
- { tag: "1.0 from linear to logarithmic", input: 1.0, from: QtMultimedia.LinearVolumeScale, to: QtMultimedia.LogarithmicVolumeScale, expectedOutput: 1.0 },
-
- { tag: "-1.0 from linear to decibel", input: -1, from: QtMultimedia.LinearVolumeScale, to: QtMultimedia.DecibelVolumeScale, expectedOutput: -200 },
- { tag: "0.0 from linear to decibel", input: 0, from: QtMultimedia.LinearVolumeScale, to: QtMultimedia.DecibelVolumeScale, expectedOutput: -200 },
- { tag: "0.33 from linear to decibel", input: 0.33, from: QtMultimedia.LinearVolumeScale, to: QtMultimedia.DecibelVolumeScale, expectedOutput: -9.63 },
- { tag: "0.5 from linear to decibel", input: 0.5, from: QtMultimedia.LinearVolumeScale, to: QtMultimedia.DecibelVolumeScale, expectedOutput: -6.02 },
- { tag: "0.72 from linear to decibel", input: 0.72, from: QtMultimedia.LinearVolumeScale, to: QtMultimedia.DecibelVolumeScale, expectedOutput: -2.85 },
- { tag: "1.0 from linear to decibel", input: 1.0, from: QtMultimedia.LinearVolumeScale, to: QtMultimedia.DecibelVolumeScale, expectedOutput: 0 },
-
- { tag: "-1.0 from cubic to linear", input: -1, from: QtMultimedia.CubicVolumeScale, to: QtMultimedia.LinearVolumeScale, expectedOutput: 0 },
- { tag: "0.0 from cubic to linear", input: 0, from: QtMultimedia.CubicVolumeScale, to: QtMultimedia.LinearVolumeScale, expectedOutput: 0 },
- { tag: "0.33 from cubic to linear", input: 0.33, from: QtMultimedia.CubicVolumeScale, to: QtMultimedia.LinearVolumeScale, expectedOutput: 0.04 },
- { tag: "0.5 from cubic to linear", input: 0.5, from: QtMultimedia.CubicVolumeScale, to: QtMultimedia.LinearVolumeScale, expectedOutput: 0.13 },
- { tag: "0.72 from cubic to linear", input: 0.72, from: QtMultimedia.CubicVolumeScale, to: QtMultimedia.LinearVolumeScale, expectedOutput: 0.37 },
- { tag: "1.0 from cubic to linear", input: 1.0, from: QtMultimedia.CubicVolumeScale, to: QtMultimedia.LinearVolumeScale, expectedOutput: 1 },
-
- { tag: "-1.0 from cubic to cubic", input: -1, from: QtMultimedia.CubicVolumeScale, to: QtMultimedia.CubicVolumeScale, expectedOutput: 0 },
- { tag: "0.0 from cubic to cubic", input: 0, from: QtMultimedia.CubicVolumeScale, to: QtMultimedia.CubicVolumeScale, expectedOutput: 0 },
- { tag: "0.5 from cubic to cubic", input: 0.5, from: QtMultimedia.CubicVolumeScale, to: QtMultimedia.CubicVolumeScale, expectedOutput: 0.5 },
- { tag: "1.0 from cubic to cubic", input: 1.0, from: QtMultimedia.CubicVolumeScale, to: QtMultimedia.CubicVolumeScale, expectedOutput: 1.0 },
-
- { tag: "-1.0 from cubic to logarithmic", input: -1, from: QtMultimedia.CubicVolumeScale, to: QtMultimedia.LogarithmicVolumeScale, expectedOutput: 0 },
- { tag: "0.0 from cubic to logarithmic", input: 0, from: QtMultimedia.CubicVolumeScale, to: QtMultimedia.LogarithmicVolumeScale, expectedOutput: 0 },
- { tag: "0.33 from cubic to logarithmic", input: 0.33, from: QtMultimedia.CubicVolumeScale, to: QtMultimedia.LogarithmicVolumeScale, expectedOutput: 0.15 },
- { tag: "0.5 from cubic to logarithmic", input: 0.5, from: QtMultimedia.CubicVolumeScale, to: QtMultimedia.LogarithmicVolumeScale, expectedOutput: 0.44 },
- { tag: "0.72 from cubic to logarithmic", input: 0.72, from: QtMultimedia.CubicVolumeScale, to: QtMultimedia.LogarithmicVolumeScale, expectedOutput: 0.82 },
- { tag: "1.0 from cubic to logarithmic", input: 1.0, from: QtMultimedia.CubicVolumeScale, to: QtMultimedia.LogarithmicVolumeScale, expectedOutput: 1 },
-
- { tag: "-1.0 from cubic to decibel", input: -1, from: QtMultimedia.CubicVolumeScale, to: QtMultimedia.DecibelVolumeScale, expectedOutput: -200 },
- { tag: "0.0 from cubic to decibel", input: 0, from: QtMultimedia.CubicVolumeScale, to: QtMultimedia.DecibelVolumeScale, expectedOutput: -200 },
- { tag: "0.33 from cubic to decibel", input: 0.33, from: QtMultimedia.CubicVolumeScale, to: QtMultimedia.DecibelVolumeScale, expectedOutput: -28.89 },
- { tag: "0.5 from cubic to decibel", input: 0.5, from: QtMultimedia.CubicVolumeScale, to: QtMultimedia.DecibelVolumeScale, expectedOutput: -18.06 },
- { tag: "0.72 from cubic to decibel", input: 0.72, from: QtMultimedia.CubicVolumeScale, to: QtMultimedia.DecibelVolumeScale, expectedOutput: -8.56 },
- { tag: "1.0 from cubic to decibel", input: 1.0, from: QtMultimedia.CubicVolumeScale, to: QtMultimedia.DecibelVolumeScale, expectedOutput: 0 },
-
- { tag: "-1.0 from logarithmic to linear", input: -1, from: QtMultimedia.LogarithmicVolumeScale, to: QtMultimedia.LinearVolumeScale, expectedOutput: 0 },
- { tag: "0.0 from logarithmic to linear", input: 0, from: QtMultimedia.LogarithmicVolumeScale, to: QtMultimedia.LinearVolumeScale, expectedOutput: 0 },
- { tag: "0.33 from logarithmic to linear", input: 0.33, from: QtMultimedia.LogarithmicVolumeScale, to: QtMultimedia.LinearVolumeScale, expectedOutput: 0.09 },
- { tag: "0.5 from logarithmic to linear", input: 0.5, from: QtMultimedia.LogarithmicVolumeScale, to: QtMultimedia.LinearVolumeScale, expectedOutput: 0.15 },
- { tag: "0.72 from logarithmic to linear", input: 0.72, from: QtMultimedia.LogarithmicVolumeScale, to: QtMultimedia.LinearVolumeScale, expectedOutput: 0.28 },
- { tag: "1.0 from logarithmic to linear", input: 1.0, from: QtMultimedia.LogarithmicVolumeScale, to: QtMultimedia.LinearVolumeScale, expectedOutput: 1.0 },
-
- { tag: "-1.0 from logarithmic to cubic", input: -1, from: QtMultimedia.LogarithmicVolumeScale, to: QtMultimedia.CubicVolumeScale, expectedOutput: 0 },
- { tag: "0.0 from logarithmic to cubic", input: 0, from: QtMultimedia.LogarithmicVolumeScale, to: QtMultimedia.CubicVolumeScale, expectedOutput: 0 },
- { tag: "0.33 from logarithmic to cubic", input: 0.33, from: QtMultimedia.LogarithmicVolumeScale, to: QtMultimedia.CubicVolumeScale, expectedOutput: 0.44 },
- { tag: "0.5 from logarithmic to cubic", input: 0.5, from: QtMultimedia.LogarithmicVolumeScale, to: QtMultimedia.CubicVolumeScale, expectedOutput: 0.53 },
- { tag: "0.72 from logarithmic to cubic", input: 0.72, from: QtMultimedia.LogarithmicVolumeScale, to: QtMultimedia.CubicVolumeScale, expectedOutput: 0.65 },
- { tag: "1.0 from logarithmic to cubic", input: 1.0, from: QtMultimedia.LogarithmicVolumeScale, to: QtMultimedia.CubicVolumeScale, expectedOutput: 1.0 },
-
- { tag: "-1.0 from logarithmic to logarithmic", input: -1, from: QtMultimedia.LogarithmicVolumeScale, to: QtMultimedia.LogarithmicVolumeScale, expectedOutput: 0 },
- { tag: "0.0 from logarithmic to logarithmic", input: 0, from: QtMultimedia.LogarithmicVolumeScale, to: QtMultimedia.LogarithmicVolumeScale, expectedOutput: 0 },
- { tag: "0.5 from logarithmic to logarithmic", input: 0.5, from: QtMultimedia.LogarithmicVolumeScale, to: QtMultimedia.LogarithmicVolumeScale, expectedOutput: 0.5 },
- { tag: "1.0 from logarithmic to logarithmic", input: 1.0, from: QtMultimedia.LogarithmicVolumeScale, to: QtMultimedia.LogarithmicVolumeScale, expectedOutput: 1.0 },
-
- { tag: "-1.0 from logarithmic to decibel", input: -1, from: QtMultimedia.LogarithmicVolumeScale, to: QtMultimedia.DecibelVolumeScale, expectedOutput: -200 },
- { tag: "0.0 from logarithmic to decibel", input: 0, from: QtMultimedia.LogarithmicVolumeScale, to: QtMultimedia.DecibelVolumeScale, expectedOutput: -200 },
- { tag: "0.33 from logarithmic to decibel", input: 0.33, from: QtMultimedia.LogarithmicVolumeScale, to: QtMultimedia.DecibelVolumeScale, expectedOutput: -21.21 },
- { tag: "0.5 from logarithmic to decibel", input: 0.5, from: QtMultimedia.LogarithmicVolumeScale, to: QtMultimedia.DecibelVolumeScale, expectedOutput: -16.45 },
- { tag: "0.72 from logarithmic to decibel", input: 0.72, from: QtMultimedia.LogarithmicVolumeScale, to: QtMultimedia.DecibelVolumeScale, expectedOutput: -11.17 },
- { tag: "1.0 from logarithmic to decibel", input: 1.0, from: QtMultimedia.LogarithmicVolumeScale, to: QtMultimedia.DecibelVolumeScale, expectedOutput: 0 },
-
- { tag: "-1000 from decibel to linear", input: -1000, from: QtMultimedia.DecibelVolumeScale, to: QtMultimedia.LinearVolumeScale, expectedOutput: 0 },
- { tag: "-200 from decibel to linear", input: -200, from: QtMultimedia.DecibelVolumeScale, to: QtMultimedia.LinearVolumeScale, expectedOutput: 0 },
- { tag: "-40 from decibel to linear", input: -40, from: QtMultimedia.DecibelVolumeScale, to: QtMultimedia.LinearVolumeScale, expectedOutput: 0.01 },
- { tag: "-10 from decibel to linear", input: -10, from: QtMultimedia.DecibelVolumeScale, to: QtMultimedia.LinearVolumeScale, expectedOutput: 0.32 },
- { tag: "-5 from decibel to linear", input: -5, from: QtMultimedia.DecibelVolumeScale, to: QtMultimedia.LinearVolumeScale, expectedOutput: 0.56 },
- { tag: "0 from decibel to linear", input: 0, from: QtMultimedia.DecibelVolumeScale, to: QtMultimedia.LinearVolumeScale, expectedOutput: 1 },
-
- { tag: "-1000 from decibel to cubic", input: -1000, from: QtMultimedia.DecibelVolumeScale, to: QtMultimedia.CubicVolumeScale, expectedOutput: 0 },
- { tag: "-200 from decibel to cubic", input: -200, from: QtMultimedia.DecibelVolumeScale, to: QtMultimedia.CubicVolumeScale, expectedOutput: 0 },
- { tag: "-40 from decibel to cubic", input: -40, from: QtMultimedia.DecibelVolumeScale, to: QtMultimedia.CubicVolumeScale, expectedOutput: 0.22 },
- { tag: "-10 from decibel to cubic", input: -10, from: QtMultimedia.DecibelVolumeScale, to: QtMultimedia.CubicVolumeScale, expectedOutput: 0.68 },
- { tag: "-5 from decibel to cubic", input: -5, from: QtMultimedia.DecibelVolumeScale, to: QtMultimedia.CubicVolumeScale, expectedOutput: 0.83 },
- { tag: "0 from decibel to cubic", input: 0, from: QtMultimedia.DecibelVolumeScale, to: QtMultimedia.CubicVolumeScale, expectedOutput: 1 },
-
- { tag: "-1000 from decibel to logarithmic", input: -1000, from: QtMultimedia.DecibelVolumeScale, to: QtMultimedia.LogarithmicVolumeScale, expectedOutput: 0 },
- { tag: "-200 from decibel to logarithmic", input: -200, from: QtMultimedia.DecibelVolumeScale, to: QtMultimedia.LogarithmicVolumeScale, expectedOutput: 0 },
- { tag: "-40 from decibel to logarithmic", input: -40, from: QtMultimedia.DecibelVolumeScale, to: QtMultimedia.LogarithmicVolumeScale, expectedOutput: 0.05 },
- { tag: "-10 from decibel to logarithmic", input: -10, from: QtMultimedia.DecibelVolumeScale, to: QtMultimedia.LogarithmicVolumeScale, expectedOutput: 0.77 },
- { tag: "-5 from decibel to logarithmic", input: -5, from: QtMultimedia.DecibelVolumeScale, to: QtMultimedia.LogarithmicVolumeScale, expectedOutput: 0.92 },
- { tag: "0 from decibel to logarithmic", input: 0, from: QtMultimedia.DecibelVolumeScale, to: QtMultimedia.LogarithmicVolumeScale, expectedOutput: 1 },
-
- { tag: "-1000 from decibel to decibel", input: -1000, from: QtMultimedia.DecibelVolumeScale, to: QtMultimedia.DecibelVolumeScale, expectedOutput: -1000 },
- { tag: "-200 from decibel to decibel", input: -200, from: QtMultimedia.DecibelVolumeScale, to: QtMultimedia.DecibelVolumeScale, expectedOutput: -200 },
- { tag: "-30 from decibel to decibel", input: -30, from: QtMultimedia.DecibelVolumeScale, to: QtMultimedia.DecibelVolumeScale, expectedOutput: -30 },
- { tag: "0 from decibel to decibel", input: 0, from: QtMultimedia.DecibelVolumeScale, to: QtMultimedia.DecibelVolumeScale, expectedOutput: 0 },
- ]
- }
-
- function test_convertVolume(data) {
- fuzzyCompare(QtMultimedia.convertVolume(data.input, data.from, data.to),
- data.expectedOutput,
- 0.01);
- }
-
-}
diff --git a/tests/auto/unit/qdeclarativevideo/qdeclarativevideo.pro b/tests/auto/unit/qdeclarativevideo/qdeclarativevideo.pro
deleted file mode 100644
index 239485509..000000000
--- a/tests/auto/unit/qdeclarativevideo/qdeclarativevideo.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativevideo
-
-QT += multimedia-private qml testlib
-
-HEADERS += \
- ../../../../src/imports/multimedia/qdeclarativevideo_p.h \
- ../../../../src/imports/multimedia/qdeclarativemediabase_p.h \
- ../../../../src/imports/multimedia/qdeclarativemediametadata_p.h
-
-SOURCES += \
- tst_qdeclarativevideo.cpp \
- ../../../../src/imports/multimedia/qdeclarativevideo.cpp \
- ../../../../src/imports/multimedia/qdeclarativemediabase.cpp
-
-INCLUDEPATH += ../../../../src/imports/multimedia
-QT+=widgets
-DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/unit/qdeclarativevideo/tst_qdeclarativevideo.cpp b/tests/auto/unit/qdeclarativevideo/tst_qdeclarativevideo.cpp
deleted file mode 100644
index e90f58388..000000000
--- a/tests/auto/unit/qdeclarativevideo/tst_qdeclarativevideo.cpp
+++ /dev/null
@@ -1,978 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//TESTED_COMPONENT=plugins/declarative/multimedia
-
-#include <QtTest/QtTest>
-
-#include "qdeclarativevideo_p.h"
-
-
-#include <qabstractvideosurface.h>
-#include <qgraphicsvideoitem.h>
-#include <qmediaplayercontrol.h>
-#include <qmediaservice.h>
-#include <qmediaserviceprovider.h>
-#include <qvideorenderercontrol.h>
-#include <qvideowindowcontrol.h>
-#include <qvideosurfaceformat.h>
-
-#include <QtWidgets/qapplication.h>
-#include <QtGui/qpainter.h>
-
-class tst_QDeclarativeVideo : public QObject
-{
- Q_OBJECT
-public slots:
- void initTestCase();
-
-private slots:
- void nullPlayerControl();
- void nullService();
-
- void playing();
- void paused();
- void error();
-
- void hasAudio();
- void hasVideo();
- void fillMode();
- void geometry();
-};
-
-Q_DECLARE_METATYPE(QDeclarativeVideo::Error);
-
-class QtTestMediaPlayerControl : public QMediaPlayerControl
-{
- Q_OBJECT
-public:
- QtTestMediaPlayerControl(QObject *parent = 0)
- : QMediaPlayerControl(parent)
- , m_state(QMediaPlayer::StoppedState)
- , m_mediaStatus(QMediaPlayer::NoMedia)
- , m_duration(0)
- , m_position(0)
- , m_playbackRate(1.0)
- , m_volume(50)
- , m_bufferStatus(0)
- , m_muted(false)
- , m_audioAvailable(false)
- , m_videoAvailable(false)
- , m_seekable(false)
- {
- }
-
- QMediaPlayer::State state() const { return m_state; }
- void updateState(QMediaPlayer::State state) { emit stateChanged(m_state = state); }
-
- QMediaPlayer::MediaStatus mediaStatus() const { return m_mediaStatus; }
- void updateMediaStatus(QMediaPlayer::MediaStatus status) {
- emit mediaStatusChanged(m_mediaStatus = status); }
- void updateMediaStatus(QMediaPlayer::MediaStatus status, QMediaPlayer::State state)
- {
- m_mediaStatus = status;
- m_state = state;
-
- emit mediaStatusChanged(m_mediaStatus);
- emit stateChanged(m_state);
- }
-
- qint64 duration() const { return m_duration; }
- void setDuration(qint64 duration) { emit durationChanged(m_duration = duration); }
-
- qint64 position() const { return m_position; }
- void setPosition(qint64 position) { emit positionChanged(m_position = position); }
-
- int volume() const { return m_volume; }
- void setVolume(int volume) { emit volumeChanged(m_volume = volume); }
-
- bool isMuted() const { return m_muted; }
- void setMuted(bool muted) { emit mutedChanged(m_muted = muted); }
-
- int bufferStatus() const { return m_bufferStatus; }
- void setBufferStatus(int status) { emit bufferStatusChanged(m_bufferStatus = status); }
-
- bool isAudioAvailable() const { return m_audioAvailable; }
- void setAudioAvailable(bool available) {
- emit audioAvailableChanged(m_audioAvailable = available); }
- bool isVideoAvailable() const { return m_videoAvailable; }
- void setVideoAvailable(bool available) {
- emit videoAvailableChanged(m_videoAvailable = available); }
-
- bool isSeekable() const { return m_seekable; }
- void setSeekable(bool seekable) { emit seekableChanged(m_seekable = seekable); }
-
- QMediaTimeRange availablePlaybackRanges() const { return QMediaTimeRange(); }
-
- qreal playbackRate() const { return m_playbackRate; }
- void setPlaybackRate(qreal rate) { emit playbackRateChanged(m_playbackRate = rate); }
-
- QMediaContent media() const { return m_media; }
- const QIODevice *mediaStream() const { return 0; }
- void setMedia(const QMediaContent &media, QIODevice *)
- {
- m_media = media;
-
- m_mediaStatus = m_media.isNull()
- ? QMediaPlayer::NoMedia
- : QMediaPlayer::LoadingMedia;
-
- emit mediaChanged(m_media);
- emit mediaStatusChanged(m_mediaStatus);
- }
-
- void play() { emit stateChanged(m_state = QMediaPlayer::PlayingState); }
- void pause() { emit stateChanged(m_state = QMediaPlayer::PausedState); }
- void stop() { emit stateChanged(m_state = QMediaPlayer::StoppedState); }
-
- void emitError(QMediaPlayer::Error err, const QString &errorString) {
- emit error(err, errorString); }
-
-private:
- QMediaPlayer::State m_state;
- QMediaPlayer::MediaStatus m_mediaStatus;
- qint64 m_duration;
- qint64 m_position;
- qreal m_playbackRate;
- int m_volume;
- int m_bufferStatus;
- bool m_muted;
- bool m_audioAvailable;
- bool m_videoAvailable;
- bool m_seekable;
- QMediaContent m_media;
-};
-
-class QtTestRendererControl : public QVideoRendererControl
-{
-public:
- QtTestRendererControl(QObject *parent ) : QVideoRendererControl(parent), m_surface(0) {}
-
- QAbstractVideoSurface *surface() const { return m_surface; }
- void setSurface(QAbstractVideoSurface *surface) { m_surface = surface; }
-
-private:
- QAbstractVideoSurface *m_surface;
-};
-
-class QtTestWindowControl : public QVideoWindowControl
-{
-public:
- QtTestWindowControl(QObject *parent)
- : QVideoWindowControl(parent)
- , m_winId(0)
- , m_repaintCount(0)
- , m_brightness(0)
- , m_contrast(0)
- , m_saturation(0)
- , m_aspectRatioMode(Qt::KeepAspectRatio)
- , m_fullScreen(0)
- {
- }
-
- WId winId() const { return m_winId; }
- void setWinId(WId id) { m_winId = id; }
-
- QRect displayRect() const { return m_displayRect; }
- void setDisplayRect(const QRect &rect) { m_displayRect = rect; }
-
- bool isFullScreen() const { return m_fullScreen; }
- void setFullScreen(bool fullScreen) { emit fullScreenChanged(m_fullScreen = fullScreen); }
-
- int repaintCount() const { return m_repaintCount; }
- void setRepaintCount(int count) { m_repaintCount = count; }
- void repaint() { ++m_repaintCount; }
-
- QSize nativeSize() const { return m_nativeSize; }
- void setNativeSize(const QSize &size) { m_nativeSize = size; emit nativeSizeChanged(); }
-
- Qt::AspectRatioMode aspectRatioMode() const { return m_aspectRatioMode; }
- void setAspectRatioMode(Qt::AspectRatioMode mode) { m_aspectRatioMode = mode; }
-
- int brightness() const { return m_brightness; }
- void setBrightness(int brightness) { emit brightnessChanged(m_brightness = brightness); }
-
- int contrast() const { return m_contrast; }
- void setContrast(int contrast) { emit contrastChanged(m_contrast = contrast); }
-
- int hue() const { return m_hue; }
- void setHue(int hue) { emit hueChanged(m_hue = hue); }
-
- int saturation() const { return m_saturation; }
- void setSaturation(int saturation) { emit saturationChanged(m_saturation = saturation); }
-
-private:
- WId m_winId;
- int m_repaintCount;
- int m_brightness;
- int m_contrast;
- int m_hue;
- int m_saturation;
- Qt::AspectRatioMode m_aspectRatioMode;
- QRect m_displayRect;
- QSize m_nativeSize;
- bool m_fullScreen;
-};
-
-class QtTestMediaService : public QMediaService
-{
- Q_OBJECT
-public:
- QtTestMediaService(
- QtTestMediaPlayerControl *playerControl,
- QtTestRendererControl *rendererControl,
- QtTestWindowControl *windowControl,
- QObject *parent)
- : QMediaService(parent)
- , playerControl(playerControl)
- , rendererControl(rendererControl)
- , windowControl(windowControl)
- {
- }
-
- QMediaControl *requestControl(const char *name)
- {
- if (qstrcmp(name, QMediaPlayerControl_iid) == 0)
- return playerControl;
- else if (qstrcmp(name, QVideoRendererControl_iid) == 0)
- return rendererControl;
- else if (qstrcmp(name, QVideoWindowControl_iid) == 0)
- return windowControl;
- else
- return 0;
- }
-
- void releaseControl(QMediaControl *) {}
-
- QtTestMediaPlayerControl *playerControl;
- QtTestRendererControl *rendererControl;
- QtTestWindowControl *windowControl;
-};
-
-class QtTestMediaServiceProvider : public QMediaServiceProvider
-{
- Q_OBJECT
-public:
- QtTestMediaServiceProvider()
- : service(
- new QtTestMediaService(
- new QtTestMediaPlayerControl(this),
- new QtTestRendererControl(this),
- new QtTestWindowControl(this),
- this))
- {
- setDefaultServiceProvider(this);
- }
-
- QtTestMediaServiceProvider(QtTestMediaService *service)
- : service(service)
- {
- setDefaultServiceProvider(this);
- }
-
- QtTestMediaServiceProvider(
- QtTestMediaPlayerControl *playerControl,
- QtTestRendererControl *rendererControl,
- QtTestWindowControl *windowControl)
- : service(new QtTestMediaService(playerControl, rendererControl, windowControl, this))
- {
- setDefaultServiceProvider(this);
- }
-
- ~QtTestMediaServiceProvider()
- {
- setDefaultServiceProvider(0);
- }
-
- QMediaService *requestService(
- const QByteArray &type,
- const QMediaServiceProviderHint & = QMediaServiceProviderHint())
- {
- requestedService = type;
-
- return service;
- }
-
- void releaseService(QMediaService *) {}
-
- inline QtTestMediaPlayerControl *playerControl() { return service->playerControl; }
- inline QtTestRendererControl *rendererControl() { return service->rendererControl; }
-
- QtTestMediaService *service;
- QByteArray requestedService;
-};
-
-
-void tst_QDeclarativeVideo::initTestCase()
-{
- qRegisterMetaType<QDeclarativeVideo::Error>();
-}
-
-void tst_QDeclarativeVideo::nullPlayerControl()
-{
- QtTestMediaServiceProvider provider(0, 0, 0);
-
- QDeclarativeVideo video;
- video.classBegin();
-
- QCOMPARE(video.source(), QUrl());
- video.setSource(QUrl("http://example.com"));
- QCOMPARE(video.source(), QUrl("http://example.com"));
-
- QCOMPARE(video.isPlaying(), false);
- video.setPlaying(true);
- QCOMPARE(video.isPlaying(), true);
- video.setPlaying(false);
- video.play();
- QCOMPARE(video.isPlaying(), false);
-
- QCOMPARE(video.isPaused(), false);
- video.pause();
- QCOMPARE(video.isPaused(), false);
- video.setPaused(true);
- QCOMPARE(video.isPaused(), true);
-
- QCOMPARE(video.duration(), 0);
-
- QCOMPARE(video.position(), 0);
- video.setPosition(10000);
- QCOMPARE(video.position(), 10000);
-
- QCOMPARE(video.volume(), qreal(1.0));
- video.setVolume(0.5);
- QCOMPARE(video.volume(), qreal(0.5));
-
- QCOMPARE(video.isMuted(), false);
- video.setMuted(true);
- QCOMPARE(video.isMuted(), true);
-
- QCOMPARE(video.bufferProgress(), qreal(0));
-
- QCOMPARE(video.isSeekable(), false);
-
- QCOMPARE(video.playbackRate(), qreal(1.0));
-
- QCOMPARE(video.hasAudio(), false);
- QCOMPARE(video.hasVideo(), false);
-
- QCOMPARE(video.status(), QDeclarativeVideo::NoMedia);
-
- QCOMPARE(video.error(), QDeclarativeVideo::ServiceMissing);
-}
-
-void tst_QDeclarativeVideo::nullService()
-{
- QtTestMediaServiceProvider provider(0);
-
- QDeclarativeVideo video;
- video.classBegin();
-
- QCOMPARE(video.source(), QUrl());
- video.setSource(QUrl("http://example.com"));
- QCOMPARE(video.source(), QUrl("http://example.com"));
-
- QCOMPARE(video.isPlaying(), false);
- video.setPlaying(true);
- QCOMPARE(video.isPlaying(), true);
- video.setPlaying(false);
- video.play();
- QCOMPARE(video.isPlaying(), false);
-
- QCOMPARE(video.isPaused(), false);
- video.pause();
- QCOMPARE(video.isPaused(), false);
- video.setPaused(true);
- QCOMPARE(video.isPaused(), true);
-
- QCOMPARE(video.duration(), 0);
-
- QCOMPARE(video.position(), 0);
- video.setPosition(10000);
- QCOMPARE(video.position(), 10000);
-
- QCOMPARE(video.volume(), qreal(1.0));
- video.setVolume(0.5);
- QCOMPARE(video.volume(), qreal(0.5));
-
- QCOMPARE(video.isMuted(), false);
- video.setMuted(true);
- QCOMPARE(video.isMuted(), true);
-
- QCOMPARE(video.bufferProgress(), qreal(0));
-
- QCOMPARE(video.isSeekable(), false);
-
- QCOMPARE(video.playbackRate(), qreal(1.0));
-
- QCOMPARE(video.hasAudio(), false);
- QCOMPARE(video.hasVideo(), false);
-
- QCOMPARE(video.status(), QDeclarativeVideo::NoMedia);
-
- QCOMPARE(video.error(), QDeclarativeVideo::ServiceMissing);
-
- QCOMPARE(video.metaObject()->indexOfProperty("title"), -1);
- QCOMPARE(video.metaObject()->indexOfProperty("genre"), -1);
- QCOMPARE(video.metaObject()->indexOfProperty("description"), -1);
-}
-
-void tst_QDeclarativeVideo::playing()
-{
- QtTestMediaServiceProvider provider;
- QDeclarativeVideo video;
- video.classBegin();
- video.componentComplete();
- video.setSource(QUrl("http://example.com"));
-
- QSignalSpy playingChangedSpy(&video, SIGNAL(playingChanged()));
- QSignalSpy startedSpy(&video, SIGNAL(started()));
- QSignalSpy stoppedSpy(&video, SIGNAL(stopped()));
-
- int playingChanged = 0;
- int started = 0;
- int stopped = 0;
-
- QCOMPARE(video.isPlaying(), false);
-
- // setPlaying(true) when stopped.
- video.setPlaying(true);
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(false) when playing.
- video.setPlaying(false);
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(stoppedSpy.count(), ++stopped);
-
- // play() when stopped.
- video.play();
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // stop() when playing.
- video.stop();
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(stoppedSpy.count(), ++stopped);
-
- // stop() when stopped.
- video.stop();
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(false) when stopped.
- video.setPlaying(false);
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- video.setPlaying(true);
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(true) when playing.
- video.setPlaying(true);
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // play() when playing.
- video.play();
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(stoppedSpy.count(), stopped);
-}
-
-void tst_QDeclarativeVideo::paused()
-{
- QtTestMediaServiceProvider provider;
- QDeclarativeVideo video;
- video.classBegin();
- video.componentComplete();
- video.setSource(QUrl("http://example.com"));
-
- QSignalSpy playingChangedSpy(&video, SIGNAL(playingChanged()));
- QSignalSpy pausedChangedSpy(&video, SIGNAL(pausedChanged()));
- QSignalSpy startedSpy(&video, SIGNAL(started()));
- QSignalSpy pausedSpy(&video, SIGNAL(paused()));
- QSignalSpy resumedSpy(&video, SIGNAL(resumed()));
- QSignalSpy stoppedSpy(&video, SIGNAL(stopped()));
-
- int playingChanged = 0;
- int pausedChanged = 0;
- int started = 0;
- int paused = 0;
- int resumed = 0;
- int stopped = 0;
-
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(video.isPaused(), false);
-
- // setPlaying(true) when stopped.
- video.setPlaying(true);
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(true) when playing.
- video.setPaused(true);
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), ++paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(true) when paused.
- video.setPaused(true);
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // pause() when paused.
- video.pause();
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(false) when paused.
- video.setPaused(false);
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), ++resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(false) when playing.
- video.setPaused(false);
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // pause() when playing.
- video.pause();
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), ++paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(false) when paused.
- video.setPlaying(false);
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), ++stopped);
-
- // setPaused(true) when stopped and paused.
- video.setPaused(true);
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(false) when stopped and paused.
- video.setPaused(false);
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(video.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(true) when stopped.
- video.setPaused(true);
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(true) when stopped and paused.
- video.setPlaying(true);
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(pausedSpy.count(), ++paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // play() when paused.
- video.play();
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), ++resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(true) when playing.
- video.setPaused(true);
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), ++paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // stop() when paused.
- video.stop();
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(video.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), ++stopped);
-
- // setPaused(true) when stopped.
- video.setPaused(true);
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // stop() when stopped and paused.
- video.stop();
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(video.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // pause() when stopped.
- video.pause();
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(pausedSpy.count(), ++paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(false) when paused.
- video.setPlaying(false);
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), ++stopped);
-
- // pause() when stopped and paused.
- video.pause();
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(pausedSpy.count(), ++paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(false) when paused.
- video.setPlaying(false);
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), ++stopped);
-
- // play() when stopped and paused.
- video.play();
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-}
-
-void tst_QDeclarativeVideo::error()
-{
- const QString errorString = QLatin1String("Failed to open device.");
-
- QtTestMediaServiceProvider provider;
- QDeclarativeVideo video;
- video.classBegin();
- video.componentComplete();
-
- QSignalSpy errorSpy(&video, SIGNAL(error(QDeclarativeVideo::Error,QString)));
- QSignalSpy errorChangedSpy(&video, SIGNAL(errorChanged()));
-
- QCOMPARE(video.error(), QDeclarativeVideo::NoError);
- QCOMPARE(video.errorString(), QString());
-
- provider.playerControl()->emitError(QMediaPlayer::ResourceError, errorString);
-
- QCOMPARE(video.error(), QDeclarativeVideo::ResourceError);
- QCOMPARE(video.errorString(), errorString);
- QCOMPARE(errorSpy.count(), 1);
- QCOMPARE(errorChangedSpy.count(), 1);
-
- // Changing the source resets the error properties.
- video.setSource(QUrl("http://example.com"));
- QCOMPARE(video.error(), QDeclarativeVideo::NoError);
- QCOMPARE(video.errorString(), QString());
- QCOMPARE(errorSpy.count(), 1);
- QCOMPARE(errorChangedSpy.count(), 2);
-
- // But isn't noisy.
- video.setSource(QUrl("file:///file/path"));
- QCOMPARE(video.error(), QDeclarativeVideo::NoError);
- QCOMPARE(video.errorString(), QString());
- QCOMPARE(errorSpy.count(), 1);
- QCOMPARE(errorChangedSpy.count(), 2);
-}
-
-
-void tst_QDeclarativeVideo::hasAudio()
-{
- QtTestMediaServiceProvider provider;
- QDeclarativeVideo video;
- video.classBegin();
- video.componentComplete();
-
- QSignalSpy spy(&video, SIGNAL(hasAudioChanged()));
-
- QCOMPARE(video.hasAudio(), false);
-
- provider.playerControl()->setAudioAvailable(true);
- QCOMPARE(video.hasAudio(), true);
- QCOMPARE(spy.count(), 1);
-
- provider.playerControl()->setAudioAvailable(true);
- QCOMPARE(video.hasAudio(), true);
- QCOMPARE(spy.count(), 2);
-
- provider.playerControl()->setAudioAvailable(false);
- QCOMPARE(video.hasAudio(), false);
- QCOMPARE(spy.count(), 3);
-}
-
-void tst_QDeclarativeVideo::hasVideo()
-{
- QtTestMediaServiceProvider provider;
- QDeclarativeVideo video;
- video.classBegin();
- video.componentComplete();
-
- QSignalSpy spy(&video, SIGNAL(hasVideoChanged()));
-
- QCOMPARE(video.hasVideo(), false);
-
- provider.playerControl()->setVideoAvailable(true);
- QCOMPARE(video.hasVideo(), true);
- QCOMPARE(spy.count(), 1);
-
- provider.playerControl()->setVideoAvailable(true);
- QCOMPARE(video.hasVideo(), true);
- QCOMPARE(spy.count(), 2);
-
- provider.playerControl()->setVideoAvailable(false);
- QCOMPARE(video.hasVideo(), false);
- QCOMPARE(spy.count(), 3);
-}
-
-void tst_QDeclarativeVideo::fillMode()
-{
- QtTestMediaServiceProvider provider;
- QDeclarativeVideo video;
- video.classBegin();
- video.componentComplete();
-
- QList<QGraphicsItem *> children = video.childItems();
- QCOMPARE(children.count(), 1);
- QGraphicsVideoItem *videoItem = qgraphicsitem_cast<QGraphicsVideoItem *>(children.first());
- QVERIFY(videoItem != 0);
-
- QCOMPARE(video.fillMode(), QDeclarativeVideo::PreserveAspectFit);
-
- video.setFillMode(QDeclarativeVideo::PreserveAspectCrop);
- QCOMPARE(video.fillMode(), QDeclarativeVideo::PreserveAspectCrop);
- QCOMPARE(videoItem->aspectRatioMode(), Qt::KeepAspectRatioByExpanding);
-
- video.setFillMode(QDeclarativeVideo::Stretch);
- QCOMPARE(video.fillMode(), QDeclarativeVideo::Stretch);
- QCOMPARE(videoItem->aspectRatioMode(), Qt::IgnoreAspectRatio);
-
- video.setFillMode(QDeclarativeVideo::PreserveAspectFit);
- QCOMPARE(video.fillMode(), QDeclarativeVideo::PreserveAspectFit);
- QCOMPARE(videoItem->aspectRatioMode(), Qt::KeepAspectRatio);
-}
-
-void tst_QDeclarativeVideo::geometry()
-{
- QtTestMediaServiceProvider provider;
- QDeclarativeVideo video;
- video.classBegin();
- video.componentComplete();
-
- QList<QGraphicsItem *> children = video.childItems();
- QCOMPARE(children.count(), 1);
- QGraphicsVideoItem *videoItem = qgraphicsitem_cast<QGraphicsVideoItem *>(children.first());
- QVERIFY(videoItem != 0);
-
- { // Surface setup is deferred until after the first paint.
- QImage image(320, 240, QImage::Format_RGB32);
- QPainter painter(&image);
-
- videoItem->paint(&painter, 0);
- }
-
- QAbstractVideoSurface *surface = provider.rendererControl()->surface();
-
- //video item can use overlay, QAbstractVideoSurface is not used than.
- if (surface) {
- QVideoSurfaceFormat format(QSize(640, 480), QVideoFrame::Format_RGB32);
-
- QVERIFY(surface->start(format));
- QCoreApplication::processEvents();
-
- QCOMPARE(video.implicitWidth(), qreal(640));
- QCOMPARE(video.implicitHeight(), qreal(480));
- }
-
- video.setWidth(560);
- video.setHeight(328);
-
- QCOMPARE(videoItem->size().width(), qreal(560));
- QCOMPARE(videoItem->size().height(), qreal(328));
-}
-
-QTEST_MAIN(tst_QDeclarativeVideo)
-
-#include "tst_qdeclarativevideo.moc"
diff --git a/tests/auto/unit/qgraphicsvideoitem/qgraphicsvideoitem.pro b/tests/auto/unit/qgraphicsvideoitem/qgraphicsvideoitem.pro
deleted file mode 100644
index 27d0ff9a4..000000000
--- a/tests/auto/unit/qgraphicsvideoitem/qgraphicsvideoitem.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qgraphicsvideoitem
-
-QT += multimedia-private multimediawidgets-private testlib
-
-SOURCES += tst_qgraphicsvideoitem.cpp
-
-QT+=widgets
diff --git a/tests/auto/unit/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp b/tests/auto/unit/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp
deleted file mode 100644
index 41805f49a..000000000
--- a/tests/auto/unit/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp
+++ /dev/null
@@ -1,705 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//TESTED_COMPONENT=src/multimedia
-
-#include <qtmultimediaglobal.h>
-#include "qgraphicsvideoitem.h"
-#include <QtTest/QtTest>
-#include "qmediaobject.h"
-#include "qmediaservice.h"
-#include <private/qpaintervideosurface_p.h>
-#include "qvideorenderercontrol.h"
-
-#include <qabstractvideosurface.h>
-#include <qvideosurfaceformat.h>
-
-#include <QtWidgets/qapplication.h>
-#include <QtWidgets/qgraphicsscene.h>
-#include <QtWidgets/qgraphicsview.h>
-
-QT_USE_NAMESPACE
-class tst_QGraphicsVideoItem : public QObject
-{
- Q_OBJECT
-public slots:
- void initTestCase();
-
-private slots:
- void nullObject();
- void nullService();
- void noOutputs();
- void serviceDestroyed();
- void mediaObjectDestroyed();
- void setMediaObject();
-
- void show();
-
- void aspectRatioMode();
- void offset();
- void size();
- void nativeSize_data();
- void nativeSize();
-
- void boundingRect_data();
- void boundingRect();
-
- void paint();
- void paintSurface();
-};
-
-Q_DECLARE_METATYPE(const uchar *)
-Q_DECLARE_METATYPE(Qt::AspectRatioMode)
-
-class QtTestRendererControl : public QVideoRendererControl
-{
-public:
- QtTestRendererControl()
- : m_surface(0)
- {
- }
-
- QAbstractVideoSurface *surface() const { return m_surface; }
- void setSurface(QAbstractVideoSurface *surface) { m_surface = surface; }
-
-private:
- QAbstractVideoSurface *m_surface;
-};
-
-class QtTestVideoService : public QMediaService
-{
- Q_OBJECT
-public:
- QtTestVideoService(
- QtTestRendererControl *renderer)
- : QMediaService(0)
- , rendererRef(0)
- , rendererControl(renderer)
- {
- }
-
- ~QtTestVideoService()
- {
- delete rendererControl;
- }
-
- QMediaControl *requestControl(const char *name)
- {
- if (qstrcmp(name, QVideoRendererControl_iid) == 0 && rendererControl) {
- rendererRef += 1;
-
- return rendererControl;
- } else {
- return 0;
- }
- }
-
- void releaseControl(QMediaControl *control)
- {
- Q_ASSERT(control);
-
- if (control == rendererControl) {
- rendererRef -= 1;
-
- if (rendererRef == 0)
- rendererControl->setSurface(0);
- }
- }
-
- int rendererRef;
- QtTestRendererControl *rendererControl;
-};
-
-class QtTestVideoObject : public QMediaObject
-{
- Q_OBJECT
-public:
- QtTestVideoObject(QtTestRendererControl *renderer)
- : QMediaObject(0, new QtTestVideoService(renderer))
- {
- testService = qobject_cast<QtTestVideoService*>(service());
- }
-
- QtTestVideoObject(QtTestVideoService *service):
- QMediaObject(0, service),
- testService(service)
- {
- }
-
- ~QtTestVideoObject()
- {
- delete testService;
- }
-
- QtTestVideoService *testService;
-};
-
-class QtTestGraphicsVideoItem : public QGraphicsVideoItem
-{
-public:
- QtTestGraphicsVideoItem(QGraphicsItem *parent = 0)
- : QGraphicsVideoItem(parent)
- , m_paintCount(0)
- {
- }
-
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
- {
- ++m_paintCount;
-
- QTestEventLoop::instance().exitLoop();
-
- QGraphicsVideoItem::paint(painter, option, widget);
- }
-
- bool waitForPaint(int secs)
- {
- const int paintCount = m_paintCount;
-
- QTestEventLoop::instance().enterLoop(secs);
-
- return m_paintCount != paintCount;
- }
-
- int paintCount() const
- {
- return m_paintCount;
- }
-
-private:
- int m_paintCount;
-};
-
-void tst_QGraphicsVideoItem::initTestCase()
-{
- qRegisterMetaType<Qt::AspectRatioMode>();
-}
-
-void tst_QGraphicsVideoItem::nullObject()
-{
- QGraphicsVideoItem item(0);
-
- QVERIFY(item.boundingRect().isEmpty());
-}
-
-void tst_QGraphicsVideoItem::nullService()
-{
- QtTestVideoService *service = 0;
-
- QtTestVideoObject object(service);
-
- QtTestGraphicsVideoItem *item = new QtTestGraphicsVideoItem;
- object.bind(item);
-
- QVERIFY(item->boundingRect().isEmpty());
-
- item->hide();
- item->show();
-
- QGraphicsScene graphicsScene;
- graphicsScene.addItem(item);
- QGraphicsView graphicsView(&graphicsScene);
- graphicsView.show();
-}
-
-void tst_QGraphicsVideoItem::noOutputs()
-{
- QtTestRendererControl *control = 0;
- QtTestVideoObject object(control);
-
- QtTestGraphicsVideoItem *item = new QtTestGraphicsVideoItem;
- object.bind(item);
-
- QVERIFY(item->boundingRect().isEmpty());
-
- item->hide();
- item->show();
-
- QGraphicsScene graphicsScene;
- graphicsScene.addItem(item);
- QGraphicsView graphicsView(&graphicsScene);
- graphicsView.show();
-}
-
-void tst_QGraphicsVideoItem::serviceDestroyed()
-{
- QtTestVideoObject object(new QtTestRendererControl);
-
- QGraphicsVideoItem item;
- object.bind(&item);
-
- QCOMPARE(object.testService->rendererRef, 1);
-
- QtTestVideoService *service = object.testService;
- object.testService = 0;
-
- delete service;
-
- QCOMPARE(item.mediaObject(), static_cast<QMediaObject *>(&object));
- QVERIFY(item.boundingRect().isEmpty());
-}
-
-void tst_QGraphicsVideoItem::mediaObjectDestroyed()
-{
- QtTestVideoObject *object = new QtTestVideoObject(new QtTestRendererControl);
-
- QGraphicsVideoItem item;
- object->bind(&item);
-
- QCOMPARE(object->testService->rendererRef, 1);
-
- delete object;
- object = 0;
-
- QCOMPARE(item.mediaObject(), static_cast<QMediaObject *>(object));
- QVERIFY(item.boundingRect().isEmpty());
-}
-
-void tst_QGraphicsVideoItem::setMediaObject()
-{
- QMediaObject *nullObject = 0;
- QtTestVideoObject object(new QtTestRendererControl);
-
- QGraphicsVideoItem item;
-
- QCOMPARE(item.mediaObject(), nullObject);
- QCOMPARE(object.testService->rendererRef, 0);
-
- object.bind(&item);
- QCOMPARE(item.mediaObject(), static_cast<QMediaObject *>(&object));
- QCOMPARE(object.testService->rendererRef, 1);
- QVERIFY(object.testService->rendererControl->surface() == 0);
-
- { // Surface setup is deferred until after the first paint.
- QImage image(320, 240, QImage::Format_RGB32);
- QPainter painter(&image);
-
- item.paint(&painter, 0);
- }
- QVERIFY(object.testService->rendererControl->surface() != 0);
-
- object.unbind(&item);
- QCOMPARE(item.mediaObject(), nullObject);
-
- QCOMPARE(object.testService->rendererRef, 0);
- QVERIFY(object.testService->rendererControl->surface() == 0);
-
- item.setVisible(false);
-
- object.bind(&item);
- QCOMPARE(item.mediaObject(), static_cast<QMediaObject *>(&object));
- QCOMPARE(object.testService->rendererRef, 1);
- QVERIFY(object.testService->rendererControl->surface() != 0);
-}
-
-void tst_QGraphicsVideoItem::show()
-{
- QtTestVideoObject object(new QtTestRendererControl);
- QtTestGraphicsVideoItem *item = new QtTestGraphicsVideoItem;
- object.bind(item);
-
- // Graphics items are visible by default
- QCOMPARE(object.testService->rendererRef, 1);
- QVERIFY(object.testService->rendererControl->surface() == 0);
-
- item->hide();
- QCOMPARE(object.testService->rendererRef, 1);
-
- item->show();
- QCOMPARE(object.testService->rendererRef, 1);
- QVERIFY(object.testService->rendererControl->surface() == 0);
-
- QGraphicsScene graphicsScene;
- graphicsScene.addItem(item);
- QGraphicsView graphicsView(&graphicsScene);
- graphicsView.show();
-
- QVERIFY(item->paintCount() || item->waitForPaint(1));
- QVERIFY(object.testService->rendererControl->surface() != 0);
-
- QVERIFY(item->boundingRect().isEmpty());
-
- QVideoSurfaceFormat format(QSize(320,240),QVideoFrame::Format_RGB32);
- QVERIFY(object.testService->rendererControl->surface()->start(format));
-
- QCoreApplication::processEvents();
- QVERIFY(!item->boundingRect().isEmpty());
-}
-
-void tst_QGraphicsVideoItem::aspectRatioMode()
-{
- QGraphicsVideoItem item;
-
- QCOMPARE(item.aspectRatioMode(), Qt::KeepAspectRatio);
-
- item.setAspectRatioMode(Qt::IgnoreAspectRatio);
- QCOMPARE(item.aspectRatioMode(), Qt::IgnoreAspectRatio);
-
- item.setAspectRatioMode(Qt::KeepAspectRatioByExpanding);
- QCOMPARE(item.aspectRatioMode(), Qt::KeepAspectRatioByExpanding);
-
- item.setAspectRatioMode(Qt::KeepAspectRatio);
- QCOMPARE(item.aspectRatioMode(), Qt::KeepAspectRatio);
-}
-
-void tst_QGraphicsVideoItem::offset()
-{
- QGraphicsVideoItem item;
-
- QCOMPARE(item.offset(), QPointF(0, 0));
-
- item.setOffset(QPointF(-32.4, 43.0));
- QCOMPARE(item.offset(), QPointF(-32.4, 43.0));
-
- item.setOffset(QPointF(1, 1));
- QCOMPARE(item.offset(), QPointF(1, 1));
-
- item.setOffset(QPointF(12, -30.4));
- QCOMPARE(item.offset(), QPointF(12, -30.4));
-
- item.setOffset(QPointF(-90.4, -75));
- QCOMPARE(item.offset(), QPointF(-90.4, -75));
-}
-
-void tst_QGraphicsVideoItem::size()
-{
- QGraphicsVideoItem item;
-
- QCOMPARE(item.size(), QSizeF(320, 240));
-
- item.setSize(QSizeF(542.5, 436.3));
- QCOMPARE(item.size(), QSizeF(542.5, 436.3));
-
- item.setSize(QSizeF(-43, 12));
- QCOMPARE(item.size(), QSizeF(0, 0));
-
- item.setSize(QSizeF(54, -9));
- QCOMPARE(item.size(), QSizeF(0, 0));
-
- item.setSize(QSizeF(-90, -65));
- QCOMPARE(item.size(), QSizeF(0, 0));
-
- item.setSize(QSizeF(1000, 1000));
- QCOMPARE(item.size(), QSizeF(1000, 1000));
-}
-
-void tst_QGraphicsVideoItem::nativeSize_data()
-{
- QTest::addColumn<QSize>("frameSize");
- QTest::addColumn<QRect>("viewport");
- QTest::addColumn<QSize>("pixelAspectRatio");
- QTest::addColumn<QSizeF>("nativeSize");
-
- QTest::newRow("640x480")
- << QSize(640, 480)
- << QRect(0, 0, 640, 480)
- << QSize(1, 1)
- << QSizeF(640, 480);
-
- QTest::newRow("800x600, (80,60, 640x480) viewport")
- << QSize(800, 600)
- << QRect(80, 60, 640, 480)
- << QSize(1, 1)
- << QSizeF(640, 480);
-
- QTest::newRow("800x600, (80,60, 640x480) viewport, 4:3")
- << QSize(800, 600)
- << QRect(80, 60, 640, 480)
- << QSize(4, 3)
- << QSizeF(853, 480);
-}
-
-void tst_QGraphicsVideoItem::nativeSize()
-{
- QFETCH(QSize, frameSize);
- QFETCH(QRect, viewport);
- QFETCH(QSize, pixelAspectRatio);
- QFETCH(QSizeF, nativeSize);
-
- QtTestVideoObject object(new QtTestRendererControl);
- QGraphicsVideoItem item;
- object.bind(&item);
-
- QCOMPARE(item.nativeSize(), QSizeF());
-
- QSignalSpy spy(&item, SIGNAL(nativeSizeChanged(QSizeF)));
-
- QVideoSurfaceFormat format(frameSize, QVideoFrame::Format_ARGB32);
- format.setViewport(viewport);
- format.setPixelAspectRatio(pixelAspectRatio);
-
- { // Surface setup is deferred until after the first paint.
- QImage image(320, 240, QImage::Format_RGB32);
- QPainter painter(&image);
-
- item.paint(&painter, 0);
- }
- QVERIFY(object.testService->rendererControl->surface() != 0);
- QVERIFY(object.testService->rendererControl->surface()->start(format));
-
- QCoreApplication::processEvents();
- QCOMPARE(item.nativeSize(), nativeSize);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.last().first().toSizeF(), nativeSize);
-
- object.testService->rendererControl->surface()->stop();
-
- QCoreApplication::processEvents();
- QVERIFY(item.nativeSize().isEmpty());
- QCOMPARE(spy.count(), 2);
- QVERIFY(spy.last().first().toSizeF().isEmpty());
-}
-
-void tst_QGraphicsVideoItem::boundingRect_data()
-{
- QTest::addColumn<QSize>("frameSize");
- QTest::addColumn<QPointF>("offset");
- QTest::addColumn<QSizeF>("size");
- QTest::addColumn<Qt::AspectRatioMode>("aspectRatioMode");
- QTest::addColumn<QRectF>("expectedRect");
-
-
- QTest::newRow("640x480: (0,0 640x480), Keep")
- << QSize(640, 480)
- << QPointF(0, 0)
- << QSizeF(640, 480)
- << Qt::KeepAspectRatio
- << QRectF(0, 0, 640, 480);
-
- QTest::newRow("800x600, (0,0, 640x480), Keep")
- << QSize(800, 600)
- << QPointF(0, 0)
- << QSizeF(640, 480)
- << Qt::KeepAspectRatio
- << QRectF(0, 0, 640, 480);
-
- QTest::newRow("800x600, (0,0, 640x480), KeepByExpanding")
- << QSize(800, 600)
- << QPointF(0, 0)
- << QSizeF(640, 480)
- << Qt::KeepAspectRatioByExpanding
- << QRectF(0, 0, 640, 480);
-
- QTest::newRow("800x600, (0,0, 640x480), Ignore")
- << QSize(800, 600)
- << QPointF(0, 0)
- << QSizeF(640, 480)
- << Qt::IgnoreAspectRatio
- << QRectF(0, 0, 640, 480);
-
- QTest::newRow("800x600, (100,100, 640x480), Keep")
- << QSize(800, 600)
- << QPointF(100, 100)
- << QSizeF(640, 480)
- << Qt::KeepAspectRatio
- << QRectF(100, 100, 640, 480);
-
- QTest::newRow("800x600, (100,-100, 640x480), KeepByExpanding")
- << QSize(800, 600)
- << QPointF(100, -100)
- << QSizeF(640, 480)
- << Qt::KeepAspectRatioByExpanding
- << QRectF(100, -100, 640, 480);
-
- QTest::newRow("800x600, (-100,-100, 640x480), Ignore")
- << QSize(800, 600)
- << QPointF(-100, -100)
- << QSizeF(640, 480)
- << Qt::IgnoreAspectRatio
- << QRectF(-100, -100, 640, 480);
-
- QTest::newRow("800x600, (0,0, 1920x1024), Keep")
- << QSize(800, 600)
- << QPointF(0, 0)
- << QSizeF(1920, 1024)
- << Qt::KeepAspectRatio
- << QRectF(832.0 / 3, 0, 4096.0 / 3, 1024);
-
- QTest::newRow("800x600, (0,0, 1920x1024), KeepByExpanding")
- << QSize(800, 600)
- << QPointF(0, 0)
- << QSizeF(1920, 1024)
- << Qt::KeepAspectRatioByExpanding
- << QRectF(0, 0, 1920, 1024);
-
- QTest::newRow("800x600, (0,0, 1920x1024), Ignore")
- << QSize(800, 600)
- << QPointF(0, 0)
- << QSizeF(1920, 1024)
- << Qt::IgnoreAspectRatio
- << QRectF(0, 0, 1920, 1024);
-
- QTest::newRow("800x600, (100,100, 1920x1024), Keep")
- << QSize(800, 600)
- << QPointF(100, 100)
- << QSizeF(1920, 1024)
- << Qt::KeepAspectRatio
- << QRectF(100 + 832.0 / 3, 100, 4096.0 / 3, 1024);
-
- QTest::newRow("800x600, (100,-100, 1920x1024), KeepByExpanding")
- << QSize(800, 600)
- << QPointF(100, -100)
- << QSizeF(1920, 1024)
- << Qt::KeepAspectRatioByExpanding
- << QRectF(100, -100, 1920, 1024);
-
- QTest::newRow("800x600, (-100,-100, 1920x1024), Ignore")
- << QSize(800, 600)
- << QPointF(-100, -100)
- << QSizeF(1920, 1024)
- << Qt::IgnoreAspectRatio
- << QRectF(-100, -100, 1920, 1024);
-}
-
-void tst_QGraphicsVideoItem::boundingRect()
-{
- QFETCH(QSize, frameSize);
- QFETCH(QPointF, offset);
- QFETCH(QSizeF, size);
- QFETCH(Qt::AspectRatioMode, aspectRatioMode);
- QFETCH(QRectF, expectedRect);
-
- QtTestVideoObject object(new QtTestRendererControl);
- QGraphicsVideoItem item;
- object.bind(&item);
-
- item.setOffset(offset);
- item.setSize(size);
- item.setAspectRatioMode(aspectRatioMode);
-
- QVideoSurfaceFormat format(frameSize, QVideoFrame::Format_ARGB32);
-
- { // Surface setup is deferred until after the first paint.
- QImage image(320, 240, QImage::Format_RGB32);
- QPainter painter(&image);
-
- item.paint(&painter, 0);
- }
- QVERIFY(object.testService->rendererControl->surface() != 0);
- QVERIFY(object.testService->rendererControl->surface()->start(format));
-
- QCoreApplication::processEvents();
- QCOMPARE(item.boundingRect(), expectedRect);
-}
-
-static const uchar rgb32ImageData[] =
-{
- 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00,
- 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00
-};
-
-void tst_QGraphicsVideoItem::paint()
-{
- QtTestVideoObject object(new QtTestRendererControl);
- QtTestGraphicsVideoItem *item = new QtTestGraphicsVideoItem;
- object.bind(item);
-
- QGraphicsScene graphicsScene;
- graphicsScene.addItem(item);
- QGraphicsView graphicsView(&graphicsScene);
- graphicsView.show();
- QVERIFY(item->waitForPaint(1));
-
- QPainterVideoSurface *surface = qobject_cast<QPainterVideoSurface *>(
- object.testService->rendererControl->surface());
- if (!surface)
- QSKIP("QGraphicsVideoItem is not QPainterVideoSurface based");
-
- QVideoSurfaceFormat format(QSize(2, 2), QVideoFrame::Format_RGB32);
-
- QVERIFY(surface->start(format));
- QCOMPARE(surface->isActive(), true);
- QCOMPARE(surface->isReady(), true);
-
- QVERIFY(item->waitForPaint(1));
-
- QCOMPARE(surface->isActive(), true);
- QCOMPARE(surface->isReady(), true);
-
- QVideoFrame frame(sizeof(rgb32ImageData), QSize(2, 2), 8, QVideoFrame::Format_RGB32);
-
- frame.map(QAbstractVideoBuffer::WriteOnly);
- memcpy(frame.bits(), rgb32ImageData, frame.mappedBytes());
- frame.unmap();
-
- QVERIFY(surface->present(frame));
- QCOMPARE(surface->isActive(), true);
- QCOMPARE(surface->isReady(), false);
-
- QVERIFY(item->waitForPaint(1));
-
- QCOMPARE(surface->isActive(), true);
- QCOMPARE(surface->isReady(), true);
-}
-
-void tst_QGraphicsVideoItem::paintSurface()
-{
- QtTestGraphicsVideoItem *item = new QtTestGraphicsVideoItem;
- QVERIFY(item->videoSurface());
-
- QGraphicsScene graphicsScene;
- graphicsScene.addItem(item);
- QGraphicsView graphicsView(&graphicsScene);
- graphicsView.show();
- QVERIFY(item->waitForPaint(1));
-
- QPainterVideoSurface *surface = qobject_cast<QPainterVideoSurface *>(
- item->videoSurface());
- if (!surface)
- QSKIP("QGraphicsVideoItem is not QPainterVideoSurface based");
-
- QVideoSurfaceFormat format(QSize(2, 2), QVideoFrame::Format_RGB32);
-
- QVERIFY(surface->start(format));
- QCOMPARE(surface->isActive(), true);
- QCOMPARE(surface->isReady(), true);
-
- QVERIFY(item->waitForPaint(1));
-
- QCOMPARE(surface->isActive(), true);
- QCOMPARE(surface->isReady(), true);
-
- QVideoFrame frame(sizeof(rgb32ImageData), QSize(2, 2), 8, QVideoFrame::Format_RGB32);
-
- frame.map(QAbstractVideoBuffer::WriteOnly);
- memcpy(frame.bits(), rgb32ImageData, frame.mappedBytes());
- frame.unmap();
-
- QVERIFY(surface->present(frame));
- QCOMPARE(surface->isActive(), true);
- QCOMPARE(surface->isReady(), false);
-
- QVERIFY(item->waitForPaint(1));
-
- QCOMPARE(surface->isActive(), true);
- QCOMPARE(surface->isReady(), true);
-}
-
-QTEST_MAIN(tst_QGraphicsVideoItem)
-
-#include "tst_qgraphicsvideoitem.moc"
diff --git a/tests/auto/unit/qmediabindableinterface/qmediabindableinterface.pro b/tests/auto/unit/qmediabindableinterface/qmediabindableinterface.pro
deleted file mode 100644
index 98dd0eca7..000000000
--- a/tests/auto/unit/qmediabindableinterface/qmediabindableinterface.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qmediabindableinterface
-
-QT += multimedia-private testlib
-
-SOURCES += \
- tst_qmediabindableinterface.cpp
-
-include (../qmultimedia_common/mock.pri)
-include (../qmultimedia_common/mockrecorder.pri)
diff --git a/tests/auto/unit/qmediabindableinterface/tst_qmediabindableinterface.cpp b/tests/auto/unit/qmediabindableinterface/tst_qmediabindableinterface.cpp
deleted file mode 100644
index a7123cfe0..000000000
--- a/tests/auto/unit/qmediabindableinterface/tst_qmediabindableinterface.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//TESTED_COMPONENT=src/multimedia
-
-#include <QtTest/QtTest>
-#include <qmediaobject.h>
-#include <qmediacontrol.h>
-#include <qmediaservice.h>
-#include <qmediarecordercontrol.h>
-#include <qmediarecorder.h>
-#include <qmetadatawritercontrol.h>
-#include <qaudioinputselectorcontrol.h>
-#include <qaudioencodersettingscontrol.h>
-#include <qmediacontainercontrol.h>
-#include <qvideoencodersettingscontrol.h>
-#include <qaudioformat.h>
-
-#include "mockmediacontainercontrol.h"
-#include "mockmetadatawritercontrol.h"
-#include "mockmediarecordercontrol.h"
-#include "mockmediaobject.h"
-
-QT_USE_NAMESPACE
-
-class TestBindableService : public QMediaService
-{
- Q_OBJECT
-public:
- TestBindableService(QObject *parent, QMediaControl *control):
- QMediaService(parent),
- mockControl(control),
- hasControls(true)
- {
- mockContainerControl = new MockMediaContainerControl(parent); //Creating the object for Media
- mockMetaDataControl = new MockMetaDataWriterControl(parent); //Creating the object for MetaData
- }
-
- QMediaControl* requestControl(const char *name)
- {
- if (hasControls && qstrcmp(name,QMediaRecorderControl_iid) == 0)
- return mockControl;
- if (hasControls && qstrcmp(name,QMediaContainerControl_iid) == 0)
- return mockContainerControl;
- if (hasControls && qstrcmp(name, QMetaDataWriterControl_iid) == 0)
- return mockMetaDataControl;
-
- return 0;
- }
-
- void releaseControl(QMediaControl*) {}
- //Initialising the objects for the media
- QMediaControl *mockControl;
- QMediaContainerControl *mockContainerControl;
- MockMetaDataWriterControl *mockMetaDataControl;
- bool hasControls;
-};
-
-class tst_QMediaBindableInterface:public QObject
-{
- Q_OBJECT
-private slots:
- void init()
- {
-
- }
-
- void cleanup()
- {
-
- }
-
- void testMediaObject() //Verifying the mediaobject api
- {
- MockMediaRecorderControl recorderControl(0);
- TestBindableService service(0, &recorderControl);
- service.mockMetaDataControl->populateMetaData();
- MockMediaObject object(0, &service);
- QMediaRecorder recorder(&object);
- QMediaObject *obj = recorder.mediaObject();
- QVERIFY(obj != NULL);
- QVERIFY(obj->isAvailable());
- }
-
- void testDestructor() //Invoking the destructor
- {
- MockMediaRecorderControl recorderControl(0);
- TestBindableService service(0, &recorderControl);
- service.mockMetaDataControl->populateMetaData();
- MockMediaObject object(0, &service);
- QMediaRecorder *recorder = new QMediaRecorder(&object);
- QVERIFY(recorder->isAvailable());
- delete recorder;
- recorder = NULL;
- }
-};
-
-QTEST_MAIN(tst_QMediaBindableInterface)
-#include "tst_qmediabindableinterface.moc"
diff --git a/tests/auto/unit/qmediacontainercontrol/qmediacontainercontrol.pro b/tests/auto/unit/qmediacontainercontrol/qmediacontainercontrol.pro
deleted file mode 100644
index e13aab7c9..000000000
--- a/tests/auto/unit/qmediacontainercontrol/qmediacontainercontrol.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qmediacontainercontrol
-
-QT += multimedia-private testlib
-
-SOURCES += tst_qmediacontainercontrol.cpp
-
-include (../qmultimedia_common/mockcontainer.pri)
-
diff --git a/tests/auto/unit/qmediacontainercontrol/tst_qmediacontainercontrol.cpp b/tests/auto/unit/qmediacontainercontrol/tst_qmediacontainercontrol.cpp
deleted file mode 100644
index e3992a759..000000000
--- a/tests/auto/unit/qmediacontainercontrol/tst_qmediacontainercontrol.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//TESTED_COMPONENT=src/multimedia
-
-#include <QtTest/QtTest>
-#include "qmediacontainercontrol.h"
-#include "qmediarecorder.h"
-
-#include "../qmultimedia_common/mockmediacontainercontrol.h"
-
-//MaemoAPI-
-class tst_QMediaContainerControl :public QObject
-{
- Q_OBJECT
-
-private slots:
- //to test the constructor
- void tst_mediacontainercontrol()
- {
-
- QObject obj;
- MockMediaContainerControl control(&obj);
- QStringList strlist=control.supportedContainers();
- QStringList strlist1;
- strlist1 << "wav" << "mp3" << "mov";
- QVERIFY(strlist[0]==strlist1[0]); //checking with "wav" mime type
- QVERIFY(strlist[1]==strlist1[1]); //checking with "mp3" mime type
- QVERIFY(strlist[2]==strlist1[2]); //checking with "mov" mime type
-
- control.setContainerFormat("wav");
- const QString str("wav");
- QVERIFY2(control.containerFormat() == str,"Failed");
-
- const QString str1("WAV format");
- QVERIFY2(control.containerDescription("wav") == str1,"FAILED");
- }
-};
-
-QTEST_MAIN(tst_QMediaContainerControl);
-#include "tst_qmediacontainercontrol.moc"
diff --git a/tests/auto/unit/qmediacontent/qmediacontent.pro b/tests/auto/unit/qmediacontent/qmediacontent.pro
deleted file mode 100644
index d3ae1f7a5..000000000
--- a/tests/auto/unit/qmediacontent/qmediacontent.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qmediacontent
-
-QT += multimedia-private network testlib
-
-SOURCES += tst_qmediacontent.cpp
diff --git a/tests/auto/unit/qmediacontent/tst_qmediacontent.cpp b/tests/auto/unit/qmediacontent/tst_qmediacontent.cpp
deleted file mode 100644
index 53fae3224..000000000
--- a/tests/auto/unit/qmediacontent/tst_qmediacontent.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtNetwork/qnetworkrequest.h>
-
-#include <qmediacontent.h>
-#include <qmediaplaylist.h>
-
-//TESTED_COMPONENT=src/multimedia
-
-QT_USE_NAMESPACE
-class tst_QMediaContent : public QObject
-{
- Q_OBJECT
-
-private slots:
- void testNull();
- void testUrlCtor();
- void testRequestCtor();
- void testCopy();
- void testAssignment();
- void testEquality();
- void testPlaylist();
-};
-
-void tst_QMediaContent::testNull()
-{
- QMediaContent media;
-
- QCOMPARE(media.isNull(), true);
- QCOMPARE(media.request().url(), QUrl());
-}
-
-void tst_QMediaContent::testUrlCtor()
-{
- QMediaContent media(QUrl("http://example.com/movie.mov"));
- QCOMPARE(media.request().url(), QUrl("http://example.com/movie.mov"));
-}
-
-void tst_QMediaContent::testRequestCtor()
-{
- QNetworkRequest request(QUrl("http://example.com/movie.mov"));
- request.setAttribute(QNetworkRequest::User, QVariant(1234));
-
- QMediaContent media(request);
- QCOMPARE(media.request().url(), QUrl("http://example.com/movie.mov"));
- QCOMPARE(media.request(), request);
-}
-
-void tst_QMediaContent::testCopy()
-{
- QMediaContent media1(QUrl("http://example.com/movie.mov"));
- QMediaContent media2(media1);
-
- QVERIFY(media1 == media2);
-}
-
-void tst_QMediaContent::testAssignment()
-{
- QMediaContent media1(QUrl("http://example.com/movie.mov"));
- QMediaContent media2;
- QMediaContent media3;
-
- media2 = media1;
- QVERIFY(media2 == media1);
-
- media2 = media3;
- QVERIFY(media2 == media3);
-}
-
-void tst_QMediaContent::testEquality()
-{
- QMediaContent media1;
- QMediaContent media2;
- QMediaContent media3(QUrl("http://example.com/movie.mov"));
- QMediaContent media4(QUrl("http://example.com/movie.mov"));
- QMediaContent media5(QUrl("file:///some/where/over/the/rainbow.mp3"));
-
- // null == null
- QCOMPARE(media1 == media2, true);
- QCOMPARE(media1 != media2, false);
-
- // null != something
- QCOMPARE(media1 == media3, false);
- QCOMPARE(media1 != media3, true);
-
- // equiv
- QCOMPARE(media3 == media4, true);
- QCOMPARE(media3 != media4, false);
-
- // not equiv
- QCOMPARE(media4 == media5, false);
- QCOMPARE(media4 != media5, true);
-}
-
-void tst_QMediaContent::testPlaylist()
-{
- QMediaContent media(QUrl("http://example.com/movie.mov"));
- QVERIFY(media.request().url().isValid());
- QVERIFY(!media.playlist());
-
- {
- QPointer<QMediaPlaylist> playlist(new QMediaPlaylist);
- media = QMediaContent(playlist.data(), QUrl("http://example.com/sample.m3u"), true);
- QVERIFY(media.request().url().isValid());
- QCOMPARE(media.playlist(), playlist.data());
- media = QMediaContent();
- // Make sure playlist is destroyed by QMediaContent
- QTRY_VERIFY(!playlist);
- }
-
- {
- QMediaPlaylist *playlist = new QMediaPlaylist;
- media = QMediaContent(playlist, QUrl("http://example.com/sample.m3u"), true);
- // Delete playlist outside QMediaContent
- delete playlist;
- QVERIFY(!media.playlist());
- media = QMediaContent();
- }
-
- {
- QPointer<QMediaPlaylist> playlist(new QMediaPlaylist);
- media = QMediaContent(playlist.data(), QUrl(), false);
- QVERIFY(!media.request().url().isValid());
- QCOMPARE(media.playlist(), playlist.data());
- media = QMediaContent();
- QVERIFY(playlist);
- delete playlist.data();
- }
-}
-
-QTEST_MAIN(tst_QMediaContent)
-
-#include "tst_qmediacontent.moc"
diff --git a/tests/auto/unit/qmediaobject/qmediaobject.pro b/tests/auto/unit/qmediaobject/qmediaobject.pro
deleted file mode 100644
index 26c9f1223..000000000
--- a/tests/auto/unit/qmediaobject/qmediaobject.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qmediaobject
-QT += multimedia-private testlib
-
-include (../qmultimedia_common/mockrecorder.pri)
-include (../qmultimedia_common/mock.pri)
-
-SOURCES += tst_qmediaobject.cpp
diff --git a/tests/auto/unit/qmediaobject/tst_qmediaobject.cpp b/tests/auto/unit/qmediaobject/tst_qmediaobject.cpp
deleted file mode 100644
index f1d5cc327..000000000
--- a/tests/auto/unit/qmediaobject/tst_qmediaobject.cpp
+++ /dev/null
@@ -1,502 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//TESTED_COMPONENT=src/multimedia
-
-#include <QtTest/QtTest>
-
-#include <QtCore/qtimer.h>
-
-#include <QtMultimedia/qmediametadata.h>
-#include <qmediaobject.h>
-#include <qmediaservice.h>
-#include <qmetadatareadercontrol.h>
-#include <qaudioinputselectorcontrol.h>
-
-#include "mockmediarecorderservice.h"
-#include "mockmediaserviceprovider.h"
-#include "mockmetadatareadercontrol.h"
-#include "mockavailabilitycontrol.h"
-
-class QtTestMediaObjectService : public QMediaService
-{
- Q_OBJECT
-public:
- QtTestMediaObjectService(QObject *parent = 0, MockAvailabilityControl *availability = 0)
- : QMediaService(parent)
- , availabilityControl(availability)
- , metaDataRef(0)
- , hasMetaData(true)
- {
- }
-
- QMediaControl *requestControl(const char *iid)
- {
- if (hasMetaData && qstrcmp(iid, QMetaDataReaderControl_iid) == 0)
- return &metaData;
- else if (qstrcmp(iid, QMediaAvailabilityControl_iid) == 0)
- return availabilityControl;
- else
- return 0;
- }
-
- void releaseControl(QMediaControl *)
- {
- }
-
- MockMetaDataReaderControl metaData;
- MockAvailabilityControl *availabilityControl;
- int metaDataRef;
- bool hasMetaData;
-};
-
-QT_USE_NAMESPACE
-
-class tst_QMediaObject : public QObject
-{
- Q_OBJECT
-
-private slots:
- void propertyWatch();
- void notifySignals_data();
- void notifySignals();
- void notifyInterval_data();
- void notifyInterval();
-
- void nullMetaDataControl();
- void isMetaDataAvailable();
- void metaDataChanged();
- void metaData_data();
- void metaData();
- void availability();
-
- void service();
-
-private:
- void setupNotifyTests();
-};
-
-class QtTestMediaObject : public QMediaObject
-{
- Q_OBJECT
- Q_PROPERTY(int a READ a WRITE setA NOTIFY aChanged)
- Q_PROPERTY(int b READ b WRITE setB NOTIFY bChanged)
- Q_PROPERTY(int c READ c WRITE setC NOTIFY cChanged)
- Q_PROPERTY(int d READ d WRITE setD)
-public:
- QtTestMediaObject(QMediaService *service = 0): QMediaObject(0, service), m_a(0), m_b(0), m_c(0), m_d(0) {}
-
- using QMediaObject::addPropertyWatch;
- using QMediaObject::removePropertyWatch;
-
- int a() const { return m_a; }
- void setA(int a) { m_a = a; }
-
- int b() const { return m_b; }
- void setB(int b) { m_b = b; }
-
- int c() const { return m_c; }
- void setC(int c) { m_c = c; }
-
- int d() const { return m_d; }
- void setD(int d) { m_d = d; }
-
-Q_SIGNALS:
- void aChanged(int a);
- void bChanged(int b);
- void cChanged(int c);
-
-private:
- int m_a;
- int m_b;
- int m_c;
- int m_d;
-};
-
-void tst_QMediaObject::propertyWatch()
-{
- QtTestMediaObject object;
- object.setNotifyInterval(0);
-
- QEventLoop loop;
- connect(&object, SIGNAL(aChanged(int)), &QTestEventLoop::instance(), SLOT(exitLoop()));
- connect(&object, SIGNAL(bChanged(int)), &QTestEventLoop::instance(), SLOT(exitLoop()));
- connect(&object, SIGNAL(cChanged(int)), &QTestEventLoop::instance(), SLOT(exitLoop()));
-
- QSignalSpy aSpy(&object, SIGNAL(aChanged(int)));
- QSignalSpy bSpy(&object, SIGNAL(bChanged(int)));
- QSignalSpy cSpy(&object, SIGNAL(cChanged(int)));
-
- QTestEventLoop::instance().enterLoop(1);
-
- QCOMPARE(aSpy.count(), 0);
- QCOMPARE(bSpy.count(), 0);
- QCOMPARE(cSpy.count(), 0);
-
- int aCount = 0;
- int bCount = 0;
- int cCount = 0;
-
- object.addPropertyWatch("a");
-
- QTestEventLoop::instance().enterLoop(1);
-
- QVERIFY(aSpy.count() > aCount);
- QCOMPARE(bSpy.count(), 0);
- QCOMPARE(cSpy.count(), 0);
- QCOMPARE(aSpy.last().value(0).toInt(), 0);
-
- aCount = aSpy.count();
-
- object.setA(54);
- object.setB(342);
- object.setC(233);
-
- QTestEventLoop::instance().enterLoop(1);
-
- QVERIFY(aSpy.count() > aCount);
- QCOMPARE(bSpy.count(), 0);
- QCOMPARE(cSpy.count(), 0);
- QCOMPARE(aSpy.last().value(0).toInt(), 54);
-
- aCount = aSpy.count();
-
- object.addPropertyWatch("b");
- object.addPropertyWatch("d");
- object.removePropertyWatch("e");
- object.setA(43);
- object.setB(235);
- object.setC(90);
-
- QTestEventLoop::instance().enterLoop(1);
-
- QVERIFY(aSpy.count() > aCount);
- QVERIFY(bSpy.count() > bCount);
- QCOMPARE(cSpy.count(), 0);
- QCOMPARE(aSpy.last().value(0).toInt(), 43);
- QCOMPARE(bSpy.last().value(0).toInt(), 235);
-
- aCount = aSpy.count();
- bCount = bSpy.count();
-
- object.removePropertyWatch("a");
- object.addPropertyWatch("c");
- object.addPropertyWatch("e");
-
- QTestEventLoop::instance().enterLoop(1);
-
- QCOMPARE(aSpy.count(), aCount);
- QVERIFY(bSpy.count() > bCount);
- QVERIFY(cSpy.count() > cCount);
- QCOMPARE(bSpy.last().value(0).toInt(), 235);
- QCOMPARE(cSpy.last().value(0).toInt(), 90);
-
- bCount = bSpy.count();
- cCount = cSpy.count();
-
- object.setA(435);
- object.setC(9845);
-
- QTestEventLoop::instance().enterLoop(1);
-
- QCOMPARE(aSpy.count(), aCount);
- QVERIFY(bSpy.count() > bCount);
- QVERIFY(cSpy.count() > cCount);
- QCOMPARE(bSpy.last().value(0).toInt(), 235);
- QCOMPARE(cSpy.last().value(0).toInt(), 9845);
-
- bCount = bSpy.count();
- cCount = cSpy.count();
-
- object.setA(8432);
- object.setB(324);
- object.setC(443);
- object.removePropertyWatch("c");
- object.removePropertyWatch("d");
-
- QTestEventLoop::instance().enterLoop(1);
-
- QCOMPARE(aSpy.count(), aCount);
- QVERIFY(bSpy.count() > bCount);
- QCOMPARE(cSpy.count(), cCount);
- QCOMPARE(bSpy.last().value(0).toInt(), 324);
- QCOMPARE(cSpy.last().value(0).toInt(), 9845);
-
- bCount = bSpy.count();
-
- object.removePropertyWatch("b");
-
- QTestEventLoop::instance().enterLoop(1);
-
- QCOMPARE(aSpy.count(), aCount);
- QCOMPARE(bSpy.count(), bCount);
- QCOMPARE(cSpy.count(), cCount);
-}
-
-void tst_QMediaObject::setupNotifyTests()
-{
- QTest::addColumn<int>("interval");
- QTest::addColumn<int>("count");
-
- QTest::newRow("single 750ms")
- << 750
- << 1;
- QTest::newRow("single 600ms")
- << 600
- << 1;
- QTest::newRow("x3 300ms")
- << 300
- << 3;
- QTest::newRow("x5 180ms")
- << 180
- << 5;
-}
-
-void tst_QMediaObject::notifySignals_data()
-{
- setupNotifyTests();
-}
-
-void tst_QMediaObject::notifySignals()
-{
- QFETCH(int, interval);
- QFETCH(int, count);
-
- QtTestMediaObject object;
- QSignalSpy spy(&object, SIGNAL(aChanged(int)));
-
- object.setNotifyInterval(interval);
- object.addPropertyWatch("a");
-
- QElapsedTimer timer;
- timer.start();
-
- QTRY_COMPARE(spy.count(), count);
-}
-
-void tst_QMediaObject::notifyInterval_data()
-{
- setupNotifyTests();
-}
-
-void tst_QMediaObject::notifyInterval()
-{
- QFETCH(int, interval);
-
- QtTestMediaObject object;
- QSignalSpy spy(&object, SIGNAL(notifyIntervalChanged(int)));
-
- object.setNotifyInterval(interval);
- QCOMPARE(object.notifyInterval(), interval);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.last().value(0).toInt(), interval);
-
- object.setNotifyInterval(interval);
- QCOMPARE(object.notifyInterval(), interval);
- QCOMPARE(spy.count(), 1);
-}
-
-void tst_QMediaObject::nullMetaDataControl()
-{
- const QString titleKey(QLatin1String("Title"));
- const QString title(QLatin1String("Host of Seraphim"));
-
- QtTestMediaObjectService service;
- service.hasMetaData = false;
-
- QtTestMediaObject object(&service);
-
- QSignalSpy spy(&object, SIGNAL(metaDataChanged()));
-
- QCOMPARE(object.isMetaDataAvailable(), false);
-
- QCOMPARE(object.metaData(QMediaMetaData::Title).toString(), QString());
- QCOMPARE(object.availableMetaData(), QStringList());
- QCOMPARE(spy.count(), 0);
-}
-
-void tst_QMediaObject::isMetaDataAvailable()
-{
- QtTestMediaObjectService service;
- service.metaData.setMetaDataAvailable(false);
-
- QtTestMediaObject object(&service);
- QCOMPARE(object.isMetaDataAvailable(), false);
-
- QSignalSpy spy(&object, SIGNAL(metaDataAvailableChanged(bool)));
- service.metaData.setMetaDataAvailable(true);
-
- QCOMPARE(object.isMetaDataAvailable(), true);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.at(0).at(0).toBool(), true);
-
- service.metaData.setMetaDataAvailable(false);
-
- QCOMPARE(object.isMetaDataAvailable(), false);
- QCOMPARE(spy.count(), 2);
- QCOMPARE(spy.at(1).at(0).toBool(), false);
-}
-
-void tst_QMediaObject::metaDataChanged()
-{
- QtTestMediaObjectService service;
- QtTestMediaObject object(&service);
-
- QSignalSpy changedSpy(&object, SIGNAL(metaDataChanged()));
- QSignalSpy changedWithValueSpy(&object, SIGNAL(metaDataChanged(QString,QVariant)));
-
- service.metaData.setMetaData("key", "Value");
- QCOMPARE(changedSpy.count(), 1);
- QCOMPARE(changedWithValueSpy.count(), 1);
- QCOMPARE(changedWithValueSpy.last()[0], QVariant("key"));
- QCOMPARE(changedWithValueSpy.last()[1].value<QVariant>(), QVariant("Value"));
-
- service.metaData.setMetaData("key", "Value");
- QCOMPARE(changedSpy.count(), 1);
- QCOMPARE(changedWithValueSpy.count(), 1);
-
- service.metaData.setMetaData("key2", "Value");
- QCOMPARE(changedSpy.count(), 2);
- QCOMPARE(changedWithValueSpy.count(), 2);
- QCOMPARE(changedWithValueSpy.last()[0], QVariant("key2"));
- QCOMPARE(changedWithValueSpy.last()[1].value<QVariant>(), QVariant("Value"));
-}
-
-void tst_QMediaObject::metaData_data()
-{
- QTest::addColumn<QString>("artist");
- QTest::addColumn<QString>("title");
- QTest::addColumn<QString>("genre");
-
- QTest::newRow("")
- << QString::fromLatin1("Dead Can Dance")
- << QString::fromLatin1("Host of Seraphim")
- << QString::fromLatin1("Awesome");
-}
-
-void tst_QMediaObject::metaData()
-{
- QFETCH(QString, artist);
- QFETCH(QString, title);
- QFETCH(QString, genre);
-
- QtTestMediaObjectService service;
- service.metaData.populateMetaData();
-
- QtTestMediaObject object(&service);
- QVERIFY(object.availableMetaData().isEmpty());
-
- service.metaData.m_data.insert(QMediaMetaData::AlbumArtist, artist);
- service.metaData.m_data.insert(QMediaMetaData::Title, title);
- service.metaData.m_data.insert(QMediaMetaData::Genre, genre);
-
- QCOMPARE(object.metaData(QMediaMetaData::AlbumArtist).toString(), artist);
- QCOMPARE(object.metaData(QMediaMetaData::Title).toString(), title);
-
- QStringList metaDataKeys = object.availableMetaData();
- QCOMPARE(metaDataKeys.size(), 3);
- QVERIFY(metaDataKeys.contains(QMediaMetaData::AlbumArtist));
- QVERIFY(metaDataKeys.contains(QMediaMetaData::Title));
- QVERIFY(metaDataKeys.contains(QMediaMetaData::Genre));
-}
-
-void tst_QMediaObject::availability()
-{
- {
- QtTestMediaObject nullObject(0);
- QCOMPARE(nullObject.isAvailable(), false);
- QCOMPARE(nullObject.availability(), QMultimedia::ServiceMissing);
- }
-
- {
- QtTestMediaObjectService service;
- QtTestMediaObject object(&service);
- QCOMPARE(object.isAvailable(), true);
- QCOMPARE(object.availability(), QMultimedia::Available);
- }
-
- {
- MockAvailabilityControl available(QMultimedia::Available);
- QtTestMediaObjectService service(0, &available);
- QtTestMediaObject object(&service);
- QSignalSpy availabilitySpy(&object, SIGNAL(availabilityChanged(bool)));
- QSignalSpy availabilityStatusSpy(&object, SIGNAL(availabilityChanged(QMultimedia::AvailabilityStatus)));
-
- QCOMPARE(object.isAvailable(), true);
- QCOMPARE(object.availability(), QMultimedia::Available);
-
- available.setAvailability(QMultimedia::Busy);
- QCOMPARE(object.isAvailable(), false);
- QCOMPARE(object.availability(), QMultimedia::Busy);
- QCOMPARE(availabilitySpy.count(), 1);
- QCOMPARE(availabilityStatusSpy.count(), 1);
-
- available.setAvailability(QMultimedia::Available);
- QCOMPARE(object.isAvailable(), true);
- QCOMPARE(object.availability(), QMultimedia::Available);
- QCOMPARE(availabilitySpy.count(), 2);
- QCOMPARE(availabilityStatusSpy.count(), 2);
- }
-
- {
- MockAvailabilityControl available(QMultimedia::Busy);
- QtTestMediaObjectService service(0, &available);
- QtTestMediaObject object(&service);
- QSignalSpy availabilitySpy(&object, SIGNAL(availabilityChanged(bool)));
- QSignalSpy availabilityStatusSpy(&object, SIGNAL(availabilityChanged(QMultimedia::AvailabilityStatus)));
-
- QCOMPARE(object.isAvailable(), false);
- QCOMPARE(object.availability(), QMultimedia::Busy);
-
- available.setAvailability(QMultimedia::Available);
- QCOMPARE(object.isAvailable(), true);
- QCOMPARE(object.availability(), QMultimedia::Available);
- QCOMPARE(availabilitySpy.count(), 1);
- QCOMPARE(availabilityStatusSpy.count(), 1);
- }
-}
-
- void tst_QMediaObject::service()
- {
- // Create the mediaobject with service.
- QtTestMediaObjectService service;
- QtTestMediaObject mediaObject1(&service);
-
- // Get service and Compare if it equal to the service passed as an argument in mediaObject1.
- QMediaService *service1 = mediaObject1.service();
- QVERIFY(service1 != NULL);
- QCOMPARE(service1,&service);
-
- // Create the mediaobject with empty service and verify that service() returns NULL.
- QtTestMediaObject mediaObject2;
- QMediaService *service2 = mediaObject2.service();
- QVERIFY(service2 == NULL);
-}
-
-QTEST_GUILESS_MAIN(tst_QMediaObject)
-#include "tst_qmediaobject.moc"
diff --git a/tests/auto/unit/qmediaplayer/qmediaplayer.pro b/tests/auto/unit/qmediaplayer/qmediaplayer.pro
deleted file mode 100644
index 7279239e0..000000000
--- a/tests/auto/unit/qmediaplayer/qmediaplayer.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qmediaplayer
-QT += network multimedia-private testlib
-SOURCES += tst_qmediaplayer.cpp
-RESOURCES += testdata.qrc
-
-include (../qmultimedia_common/mock.pri)
-include (../qmultimedia_common/mockplayer.pri)
diff --git a/tests/auto/unit/qmediaplayer/testdata.qrc b/tests/auto/unit/qmediaplayer/testdata.qrc
deleted file mode 100644
index 1afc630dd..000000000
--- a/tests/auto/unit/qmediaplayer/testdata.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource prefix="/">
- <file>testdata/nokia-tune.mp3</file>
-</qresource>
-</RCC>
diff --git a/tests/auto/unit/qmediaplayer/tst_qmediaplayer.cpp b/tests/auto/unit/qmediaplayer/tst_qmediaplayer.cpp
deleted file mode 100644
index ed2a9dd42..000000000
--- a/tests/auto/unit/qmediaplayer/tst_qmediaplayer.cpp
+++ /dev/null
@@ -1,1399 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//TESTED_COMPONENT=src/multimedia
-
-#include <QtTest/QtTest>
-
-#include <QtCore/qdebug.h>
-#include <QtCore/qbuffer.h>
-
-#include <qabstractvideosurface.h>
-#include <qmediaplayer.h>
-#include <qmediaplayercontrol.h>
-#include <qmediaplaylist.h>
-#include <qmediaservice.h>
-#include <qmediastreamscontrol.h>
-#include <qvideorenderercontrol.h>
-
-#include "mockmediaserviceprovider.h"
-#include "mockmediaplayerservice.h"
-#include "mockvideosurface.h"
-
-QT_USE_NAMESPACE
-
-class AutoConnection
-{
-public:
- AutoConnection(QObject *sender, const char *signal, QObject *receiver, const char *method)
- : sender(sender), signal(signal), receiver(receiver), method(method)
- {
- QObject::connect(sender, signal, receiver, method);
- }
-
- ~AutoConnection()
- {
- QObject::disconnect(sender, signal, receiver, method);
- }
-
-private:
- QObject *sender;
- const char *signal;
- QObject *receiver;
- const char *method;
-};
-
-class tst_QMediaPlayer: public QObject
-{
- Q_OBJECT
-
-public slots:
- void initTestCase();
- void cleanupTestCase();
- void init();
- void cleanup();
-
-private slots:
- void testNullService_data();
- void testNullService();
- void testValid();
- void testMedia_data();
- void testMedia();
- void testDuration_data();
- void testDuration();
- void testPosition_data();
- void testPosition();
- void testVolume_data();
- void testVolume();
- void testMuted_data();
- void testMuted();
- void testIsAvailable();
- void testVideoAvailable_data();
- void testVideoAvailable();
- void testBufferStatus_data();
- void testBufferStatus();
- void testSeekable_data();
- void testSeekable();
- void testPlaybackRate_data();
- void testPlaybackRate();
- void testError_data();
- void testError();
- void testErrorString_data();
- void testErrorString();
- void testService();
- void testPlay_data();
- void testPlay();
- void testPause_data();
- void testPause();
- void testStop_data();
- void testStop();
- void testMediaStatus_data();
- void testMediaStatus();
- void testPlaylist();
- void testSetVideoOutput();
- void testSetVideoOutputNoService();
- void testSetVideoOutputNoControl();
- void testSetVideoOutputDestruction();
- void testPositionPropertyWatch();
- void debugEnums();
- void testPlayerFlags();
- void testDestructor();
- void testSupportedMimeTypes();
- void testQrc_data();
- void testQrc();
- void testAudioRole();
- void testCustomAudioRole();
-
-private:
- void setupCommonTestData();
-
- MockMediaServiceProvider *mockProvider;
- MockMediaPlayerService *mockService;
- QMediaPlayer *player;
-};
-
-void tst_QMediaPlayer::setupCommonTestData()
-{
- QTest::addColumn<bool>("valid");
- QTest::addColumn<QMediaPlayer::State>("state");
- QTest::addColumn<QMediaPlayer::MediaStatus>("status");
- QTest::addColumn<QMediaContent>("mediaContent");
- QTest::addColumn<qint64>("duration");
- QTest::addColumn<qint64>("position");
- QTest::addColumn<bool>("seekable");
- QTest::addColumn<int>("volume");
- QTest::addColumn<bool>("muted");
- QTest::addColumn<bool>("videoAvailable");
- QTest::addColumn<int>("bufferStatus");
- QTest::addColumn<qreal>("playbackRate");
- QTest::addColumn<QMediaPlayer::Error>("error");
- QTest::addColumn<QString>("errorString");
-
- QTest::newRow("invalid") << false << QMediaPlayer::StoppedState << QMediaPlayer::UnknownMediaStatus <<
- QMediaContent() << qint64(0) << qint64(0) << false << 0 << false << false << 0 <<
- qreal(0) << QMediaPlayer::NoError << QString();
- QTest::newRow("valid+null") << true << QMediaPlayer::StoppedState << QMediaPlayer::UnknownMediaStatus <<
- QMediaContent() << qint64(0) << qint64(0) << false << 0 << false << false << 50 <<
- qreal(0) << QMediaPlayer::NoError << QString();
- QTest::newRow("valid+content+stopped") << true << QMediaPlayer::StoppedState << QMediaPlayer::UnknownMediaStatus <<
- QMediaContent(QUrl("file:///some.mp3")) << qint64(0) << qint64(0) << false << 50 << false << false << 0 <<
- qreal(1) << QMediaPlayer::NoError << QString();
- QTest::newRow("valid+content+playing") << true << QMediaPlayer::PlayingState << QMediaPlayer::LoadedMedia <<
- QMediaContent(QUrl("file:///some.mp3")) << qint64(10000) << qint64(10) << true << 50 << true << false << 0 <<
- qreal(1) << QMediaPlayer::NoError << QString();
- QTest::newRow("valid+content+paused") << true << QMediaPlayer::PausedState << QMediaPlayer::LoadedMedia <<
- QMediaContent(QUrl("file:///some.mp3")) << qint64(10000) << qint64(10) << true << 50 << true << false << 0 <<
- qreal(1) << QMediaPlayer::NoError << QString();
- QTest::newRow("valud+streaming") << true << QMediaPlayer::PlayingState << QMediaPlayer::LoadedMedia <<
- QMediaContent(QUrl("http://example.com/stream")) << qint64(10000) << qint64(10000) << false << 50 << false << true << 0 <<
- qreal(1) << QMediaPlayer::NoError << QString();
- QTest::newRow("valid+error") << true << QMediaPlayer::StoppedState << QMediaPlayer::UnknownMediaStatus <<
- QMediaContent(QUrl("http://example.com/stream")) << qint64(0) << qint64(0) << false << 50 << false << false << 0 <<
- qreal(0) << QMediaPlayer::ResourceError << QString("Resource unavailable");
-}
-
-void tst_QMediaPlayer::initTestCase()
-{
- qRegisterMetaType<QMediaPlayer::State>("QMediaPlayer::State");
- qRegisterMetaType<QMediaPlayer::Error>("QMediaPlayer::Error");
- qRegisterMetaType<QMediaPlayer::MediaStatus>("QMediaPlayer::MediaStatus");
- qRegisterMetaType<QMediaContent>("QMediaContent");
-}
-
-void tst_QMediaPlayer::cleanupTestCase()
-{
-}
-
-void tst_QMediaPlayer::init()
-{
- mockService = new MockMediaPlayerService;
- mockProvider = new MockMediaServiceProvider(mockService);
- QMediaServiceProvider::setDefaultServiceProvider(mockProvider);
-
- player = new QMediaPlayer;
-}
-
-void tst_QMediaPlayer::cleanup()
-{
- delete player;
- delete mockProvider;
- delete mockService;
-}
-
-void tst_QMediaPlayer::testNullService_data()
-{
- setupCommonTestData();
-}
-
-void tst_QMediaPlayer::testNullService()
-{
- mockProvider->service = 0;
- QMediaPlayer player;
-
- const QIODevice *nullDevice = 0;
-
- QCOMPARE(player.media(), QMediaContent());
- QCOMPARE(player.mediaStream(), nullDevice);
- QCOMPARE(player.state(), QMediaPlayer::StoppedState);
- QCOMPARE(player.mediaStatus(), QMediaPlayer::UnknownMediaStatus);
- QCOMPARE(player.duration(), qint64(-1));
- QCOMPARE(player.position(), qint64(0));
- QCOMPARE(player.volume(), 0);
- QCOMPARE(player.isMuted(), false);
- QCOMPARE(player.isVideoAvailable(), false);
- QCOMPARE(player.bufferStatus(), 0);
- QCOMPARE(player.isSeekable(), false);
- QCOMPARE(player.playbackRate(), qreal(0));
- QCOMPARE(player.error(), QMediaPlayer::ServiceMissingError);
- QCOMPARE(player.isAvailable(), false);
- QCOMPARE(player.availability(), QMultimedia::ServiceMissing);
-
- {
- QFETCH(QMediaContent, mediaContent);
-
- QSignalSpy spy(&player, SIGNAL(currentMediaChanged(QMediaContent)));
- QFile file;
-
- player.setMedia(mediaContent, &file);
- QCOMPARE(player.currentMedia(), QMediaContent());
- QCOMPARE(player.media(), mediaContent);
- QCOMPARE(player.mediaStream(), nullDevice);
- QCOMPARE(spy.count(), 0);
- } {
- QSignalSpy stateSpy(&player, SIGNAL(stateChanged(QMediaPlayer::State)));
- QSignalSpy statusSpy(&player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)));
-
- player.play();
- QCOMPARE(player.state(), QMediaPlayer::StoppedState);
- QCOMPARE(player.mediaStatus(), QMediaPlayer::UnknownMediaStatus);
- QCOMPARE(stateSpy.count(), 0);
- QCOMPARE(statusSpy.count(), 0);
-
- player.pause();
- QCOMPARE(player.state(), QMediaPlayer::StoppedState);
- QCOMPARE(player.mediaStatus(), QMediaPlayer::UnknownMediaStatus);
- QCOMPARE(stateSpy.count(), 0);
- QCOMPARE(statusSpy.count(), 0);
-
- player.stop();
- QCOMPARE(player.state(), QMediaPlayer::StoppedState);
- QCOMPARE(player.mediaStatus(), QMediaPlayer::UnknownMediaStatus);
- QCOMPARE(stateSpy.count(), 0);
- QCOMPARE(statusSpy.count(), 0);
- } {
- QFETCH(int, volume);
- QFETCH(bool, muted);
-
- QSignalSpy volumeSpy(&player, SIGNAL(volumeChanged(int)));
- QSignalSpy mutingSpy(&player, SIGNAL(mutedChanged(bool)));
-
- player.setVolume(volume);
- QCOMPARE(player.volume(), 0);
- QCOMPARE(volumeSpy.count(), 0);
-
- player.setMuted(muted);
- QCOMPARE(player.isMuted(), false);
- QCOMPARE(mutingSpy.count(), 0);
- } {
- QFETCH(qint64, position);
-
- QSignalSpy spy(&player, SIGNAL(positionChanged(qint64)));
-
- player.setPosition(position);
- QCOMPARE(player.position(), qint64(0));
- QCOMPARE(spy.count(), 0);
- } {
- QFETCH(qreal, playbackRate);
-
- QSignalSpy spy(&player, SIGNAL(playbackRateChanged(qreal)));
-
- player.setPlaybackRate(playbackRate);
- QCOMPARE(player.playbackRate(), qreal(0));
- QCOMPARE(spy.count(), 0);
- } {
- QMediaPlaylist playlist;
- player.setPlaylist(&playlist);
-
- QSignalSpy mediaSpy(&player, SIGNAL(mediaChanged(QMediaContent)));
- QSignalSpy statusSpy(&player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)));
-
- playlist.addMedia(QUrl("http://example.com/stream"));
- playlist.addMedia(QUrl("file:///some.mp3"));
-
- playlist.setCurrentIndex(0);
- QCOMPARE(playlist.currentIndex(), 0);
- QCOMPARE(player.currentMedia(), QMediaContent());
- QCOMPARE(player.media().playlist(), &playlist);
- QCOMPARE(mediaSpy.count(), 0);
- QCOMPARE(statusSpy.count(), 0);
-
- playlist.next();
- QCOMPARE(playlist.currentIndex(), 1);
- QCOMPARE(player.currentMedia(), QMediaContent());
- QCOMPARE(player.media().playlist(), &playlist);
- QCOMPARE(mediaSpy.count(), 0);
- QCOMPARE(statusSpy.count(), 0);
- }
-}
-
-void tst_QMediaPlayer::testValid()
-{
- /*
- QFETCH(bool, valid);
-
- mockService->setIsValid(valid);
- QCOMPARE(player->isValid(), valid);
- */
-}
-
-void tst_QMediaPlayer::testMedia_data()
-{
- setupCommonTestData();
-}
-
-void tst_QMediaPlayer::testMedia()
-{
- QFETCH(QMediaContent, mediaContent);
-
- mockService->setMedia(mediaContent);
- QCOMPARE(player->currentMedia(), mediaContent);
-
- QBuffer stream;
- player->setMedia(mediaContent, &stream);
- QCOMPARE(player->currentMedia(), mediaContent);
- QCOMPARE((QBuffer*)player->mediaStream(), &stream);
-}
-
-void tst_QMediaPlayer::testDuration_data()
-{
- setupCommonTestData();
-}
-
-void tst_QMediaPlayer::testDuration()
-{
- QFETCH(qint64, duration);
-
- mockService->setDuration(duration);
- QVERIFY(player->duration() == duration);
-}
-
-void tst_QMediaPlayer::testPosition_data()
-{
- setupCommonTestData();
-}
-
-void tst_QMediaPlayer::testPosition()
-{
- QFETCH(bool, valid);
- QFETCH(bool, seekable);
- QFETCH(qint64, position);
- QFETCH(qint64, duration);
-
- mockService->setIsValid(valid);
- mockService->setSeekable(seekable);
- mockService->setPosition(position);
- mockService->setDuration(duration);
- QVERIFY(player->isSeekable() == seekable);
- QVERIFY(player->position() == position);
- QVERIFY(player->duration() == duration);
-
- if (seekable) {
- { QSignalSpy spy(player, SIGNAL(positionChanged(qint64)));
- player->setPosition(position);
- QCOMPARE(player->position(), position);
- QCOMPARE(spy.count(), 0); }
-
- mockService->setPosition(position);
- { QSignalSpy spy(player, SIGNAL(positionChanged(qint64)));
- player->setPosition(0);
- QCOMPARE(player->position(), qint64(0));
- QCOMPARE(spy.count(), position == 0 ? 0 : 1); }
-
- mockService->setPosition(position);
- { QSignalSpy spy(player, SIGNAL(positionChanged(qint64)));
- player->setPosition(duration);
- QCOMPARE(player->position(), duration);
- QCOMPARE(spy.count(), position == duration ? 0 : 1); }
-
- mockService->setPosition(position);
- { QSignalSpy spy(player, SIGNAL(positionChanged(qint64)));
- player->setPosition(-1);
- QCOMPARE(player->position(), qint64(0));
- QCOMPARE(spy.count(), position == 0 ? 0 : 1); }
-
- }
- else {
- QSignalSpy spy(player, SIGNAL(positionChanged(qint64)));
- player->setPosition(position);
-
- QCOMPARE(player->position(), position);
- QCOMPARE(spy.count(), 0);
- }
-}
-
-void tst_QMediaPlayer::testVolume_data()
-{
- setupCommonTestData();
-}
-
-void tst_QMediaPlayer::testVolume()
-{
- QFETCH(bool, valid);
- QFETCH(int, volume);
-
- mockService->setVolume(volume);
- QVERIFY(player->volume() == volume);
-
- if (valid) {
- { QSignalSpy spy(player, SIGNAL(volumeChanged(int)));
- player->setVolume(10);
- QCOMPARE(player->volume(), 10);
- QCOMPARE(spy.count(), 1); }
-
- { QSignalSpy spy(player, SIGNAL(volumeChanged(int)));
- player->setVolume(-1000);
- QCOMPARE(player->volume(), 0);
- QCOMPARE(spy.count(), 1); }
-
- { QSignalSpy spy(player, SIGNAL(volumeChanged(int)));
- player->setVolume(100);
- QCOMPARE(player->volume(), 100);
- QCOMPARE(spy.count(), 1); }
-
- { QSignalSpy spy(player, SIGNAL(volumeChanged(int)));
- player->setVolume(1000);
- QCOMPARE(player->volume(), 100);
- QCOMPARE(spy.count(), 0); }
- }
-}
-
-void tst_QMediaPlayer::testMuted_data()
-{
- setupCommonTestData();
-}
-
-void tst_QMediaPlayer::testMuted()
-{
- QFETCH(bool, valid);
- QFETCH(bool, muted);
- QFETCH(int, volume);
-
- if (valid) {
- mockService->setMuted(muted);
- mockService->setVolume(volume);
- QVERIFY(player->isMuted() == muted);
-
- QSignalSpy spy(player, SIGNAL(mutedChanged(bool)));
- player->setMuted(!muted);
- QCOMPARE(player->isMuted(), !muted);
- QCOMPARE(player->volume(), volume);
- QCOMPARE(spy.count(), 1);
- }
-}
-
-void tst_QMediaPlayer::testVideoAvailable_data()
-{
- setupCommonTestData();
-}
-
-void tst_QMediaPlayer::testVideoAvailable()
-{
- QFETCH(bool, videoAvailable);
-
- mockService->setVideoAvailable(videoAvailable);
- QVERIFY(player->isVideoAvailable() == videoAvailable);
-}
-
-void tst_QMediaPlayer::testBufferStatus_data()
-{
- setupCommonTestData();
-}
-
-void tst_QMediaPlayer::testBufferStatus()
-{
- QFETCH(int, bufferStatus);
-
- mockService->setBufferStatus(bufferStatus);
- QVERIFY(player->bufferStatus() == bufferStatus);
-}
-
-void tst_QMediaPlayer::testSeekable_data()
-{
- setupCommonTestData();
-}
-
-void tst_QMediaPlayer::testSeekable()
-{
- QFETCH(bool, seekable);
-
- mockService->setSeekable(seekable);
- QVERIFY(player->isSeekable() == seekable);
-}
-
-void tst_QMediaPlayer::testPlaybackRate_data()
-{
- setupCommonTestData();
-}
-
-void tst_QMediaPlayer::testPlaybackRate()
-{
- QFETCH(bool, valid);
- QFETCH(qreal, playbackRate);
-
- if (valid) {
- mockService->setPlaybackRate(playbackRate);
- QVERIFY(player->playbackRate() == playbackRate);
-
- QSignalSpy spy(player, SIGNAL(playbackRateChanged(qreal)));
- player->setPlaybackRate(playbackRate + 0.5f);
- QCOMPARE(player->playbackRate(), playbackRate + 0.5f);
- QCOMPARE(spy.count(), 1);
- }
-}
-
-void tst_QMediaPlayer::testError_data()
-{
- setupCommonTestData();
-}
-
-void tst_QMediaPlayer::testError()
-{
- QFETCH(QMediaPlayer::Error, error);
-
- mockService->setError(error);
- QVERIFY(player->error() == error);
-}
-
-void tst_QMediaPlayer::testErrorString_data()
-{
- setupCommonTestData();
-}
-
-void tst_QMediaPlayer::testErrorString()
-{
- QFETCH(QString, errorString);
-
- mockService->setErrorString(errorString);
- QVERIFY(player->errorString() == errorString);
-}
-
-void tst_QMediaPlayer::testIsAvailable()
-{
- QCOMPARE(player->isAvailable(), true);
- QCOMPARE(player->availability(), QMultimedia::Available);
-}
-
-void tst_QMediaPlayer::testService()
-{
- /*
- QFETCH(bool, valid);
-
- mockService->setIsValid(valid);
-
- if (valid)
- QVERIFY(player->service() != 0);
- else
- QVERIFY(player->service() == 0);
- */
-}
-
-void tst_QMediaPlayer::testPlay_data()
-{
- setupCommonTestData();
-}
-
-void tst_QMediaPlayer::testPlay()
-{
- QFETCH(bool, valid);
- QFETCH(QMediaContent, mediaContent);
- QFETCH(QMediaPlayer::State, state);
-
- mockService->setIsValid(valid);
- mockService->setState(state);
- mockService->setMedia(mediaContent);
- QVERIFY(player->state() == state);
- QVERIFY(player->currentMedia() == mediaContent);
-
- QSignalSpy spy(player, SIGNAL(stateChanged(QMediaPlayer::State)));
-
- player->play();
-
- if (!valid || mediaContent.isNull()) {
- QCOMPARE(player->state(), QMediaPlayer::StoppedState);
- QCOMPARE(spy.count(), 0);
- }
- else {
- QCOMPARE(player->state(), QMediaPlayer::PlayingState);
- QCOMPARE(spy.count(), state == QMediaPlayer::PlayingState ? 0 : 1);
- }
-}
-
-void tst_QMediaPlayer::testPause_data()
-{
- setupCommonTestData();
-}
-
-void tst_QMediaPlayer::testPause()
-{
- QFETCH(bool, valid);
- QFETCH(QMediaContent, mediaContent);
- QFETCH(QMediaPlayer::State, state);
-
- mockService->setIsValid(valid);
- mockService->setState(state);
- mockService->setMedia(mediaContent);
- QVERIFY(player->state() == state);
- QVERIFY(player->currentMedia() == mediaContent);
-
- QSignalSpy spy(player, SIGNAL(stateChanged(QMediaPlayer::State)));
-
- player->pause();
-
- if (!valid || mediaContent.isNull()) {
- QCOMPARE(player->state(), QMediaPlayer::StoppedState);
- QCOMPARE(spy.count(), 0);
- }
- else {
- QCOMPARE(player->state(), QMediaPlayer::PausedState);
- QCOMPARE(spy.count(), state == QMediaPlayer::PausedState ? 0 : 1);
- }
-}
-
-void tst_QMediaPlayer::testStop_data()
-{
- setupCommonTestData();
-}
-
-void tst_QMediaPlayer::testStop()
-{
- QFETCH(QMediaContent, mediaContent);
- QFETCH(QMediaPlayer::State, state);
-
- mockService->setState(state);
- mockService->setMedia(mediaContent);
- QVERIFY(player->state() == state);
- QVERIFY(player->currentMedia() == mediaContent);
-
- QSignalSpy spy(player, SIGNAL(stateChanged(QMediaPlayer::State)));
-
- player->stop();
-
- if (mediaContent.isNull() || state == QMediaPlayer::StoppedState) {
- QCOMPARE(player->state(), QMediaPlayer::StoppedState);
- QCOMPARE(spy.count(), 0);
- }
- else {
- QCOMPARE(player->state(), QMediaPlayer::StoppedState);
- QCOMPARE(spy.count(), 1);
- }
-}
-
-void tst_QMediaPlayer::testMediaStatus_data()
-{
- setupCommonTestData();
-}
-
-void tst_QMediaPlayer::testMediaStatus()
-{
- QFETCH(int, bufferStatus);
- int bufferSignals = 0;
-
- player->setNotifyInterval(10);
-
- mockService->setMediaStatus(QMediaPlayer::NoMedia);
- mockService->setBufferStatus(bufferStatus);
-
- AutoConnection connection(
- player, SIGNAL(bufferStatusChanged(int)),
- &QTestEventLoop::instance(), SLOT(exitLoop()));
-
- QSignalSpy statusSpy(player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)));
- QSignalSpy bufferSpy(player, SIGNAL(bufferStatusChanged(int)));
-
- QCOMPARE(player->mediaStatus(), QMediaPlayer::NoMedia);
-
- mockService->setMediaStatus(QMediaPlayer::LoadingMedia);
- QCOMPARE(player->mediaStatus(), QMediaPlayer::LoadingMedia);
- QCOMPARE(statusSpy.count(), 1);
-
- QCOMPARE(qvariant_cast<QMediaPlayer::MediaStatus>(statusSpy.last().value(0)),
- QMediaPlayer::LoadingMedia);
-
- mockService->setMediaStatus(QMediaPlayer::LoadedMedia);
- QCOMPARE(player->mediaStatus(), QMediaPlayer::LoadedMedia);
- QCOMPARE(statusSpy.count(), 2);
-
- QCOMPARE(qvariant_cast<QMediaPlayer::MediaStatus>(statusSpy.last().value(0)),
- QMediaPlayer::LoadedMedia);
-
- // Verify the bufferStatusChanged() signal isn't being emitted.
- QTestEventLoop::instance().enterLoop(1);
- QCOMPARE(bufferSpy.count(), 0);
-
- mockService->setMediaStatus(QMediaPlayer::StalledMedia);
- QCOMPARE(player->mediaStatus(), QMediaPlayer::StalledMedia);
- QCOMPARE(statusSpy.count(), 3);
-
- QCOMPARE(qvariant_cast<QMediaPlayer::MediaStatus>(statusSpy.last().value(0)),
- QMediaPlayer::StalledMedia);
-
- // Verify the bufferStatusChanged() signal is being emitted.
- QTestEventLoop::instance().enterLoop(1);
- QVERIFY(bufferSpy.count() > bufferSignals);
- QCOMPARE(bufferSpy.last().value(0).toInt(), bufferStatus);
- bufferSignals = bufferSpy.count();
-
- mockService->setMediaStatus(QMediaPlayer::BufferingMedia);
- QCOMPARE(player->mediaStatus(), QMediaPlayer::BufferingMedia);
- QCOMPARE(statusSpy.count(), 4);
-
- QCOMPARE(qvariant_cast<QMediaPlayer::MediaStatus>(statusSpy.last().value(0)),
- QMediaPlayer::BufferingMedia);
-
- // Verify the bufferStatusChanged() signal is being emitted.
- QTestEventLoop::instance().enterLoop(1);
- QVERIFY(bufferSpy.count() > bufferSignals);
- QCOMPARE(bufferSpy.last().value(0).toInt(), bufferStatus);
- bufferSignals = bufferSpy.count();
-
- mockService->setMediaStatus(QMediaPlayer::BufferedMedia);
- QCOMPARE(player->mediaStatus(), QMediaPlayer::BufferedMedia);
- QCOMPARE(statusSpy.count(), 5);
-
- QCOMPARE(qvariant_cast<QMediaPlayer::MediaStatus>(statusSpy.last().value(0)),
- QMediaPlayer::BufferedMedia);
-
- // Verify the bufferStatusChanged() signal isn't being emitted.
- QTestEventLoop::instance().enterLoop(1);
- QCOMPARE(bufferSpy.count(), bufferSignals);
-
- mockService->setMediaStatus(QMediaPlayer::EndOfMedia);
- QCOMPARE(player->mediaStatus(), QMediaPlayer::EndOfMedia);
- QCOMPARE(statusSpy.count(), 6);
-
- QCOMPARE(qvariant_cast<QMediaPlayer::MediaStatus>(statusSpy.last().value(0)),
- QMediaPlayer::EndOfMedia);
-}
-
-void tst_QMediaPlayer::testPlaylist()
-{
- QMediaContent content0(QUrl(QLatin1String("test://audio/song1.mp3")));
- QMediaContent content1(QUrl(QLatin1String("test://audio/song2.mp3")));
- QMediaContent content2(QUrl(QLatin1String("test://video/movie1.mp4")));
- QMediaContent content3(QUrl(QLatin1String("test://video/movie2.mp4")));
- QMediaContent content4(QUrl(QLatin1String("test://image/photo.jpg")));
-
- mockService->setIsValid(true);
- mockService->setState(QMediaPlayer::StoppedState, QMediaPlayer::NoMedia);
-
- QMediaPlaylist *playlist = new QMediaPlaylist;
- player->setPlaylist(playlist);
- QCOMPARE(player->media().playlist(), playlist);
-
- QSignalSpy stateSpy(player, SIGNAL(stateChanged(QMediaPlayer::State)));
- QSignalSpy mediaSpy(player, SIGNAL(currentMediaChanged(QMediaContent)));
-
- // Test the player does nothing with an empty playlist attached.
- player->play();
- QCOMPARE(player->state(), QMediaPlayer::StoppedState);
- QCOMPARE(player->currentMedia(), QMediaContent());
- QCOMPARE(stateSpy.count(), 0);
- QCOMPARE(mediaSpy.count(), 0);
-
- playlist->addMedia(content0);
- playlist->addMedia(content1);
- playlist->addMedia(content2);
- playlist->addMedia(content3);
-
- // Test changing the playlist position, changes the current media, but not the playing state.
- playlist->setCurrentIndex(1);
- QCOMPARE(player->currentMedia(), content1);
- QCOMPARE(player->state(), QMediaPlayer::StoppedState);
- QCOMPARE(stateSpy.count(), 0);
- QCOMPARE(mediaSpy.count(), 1);
-
- // Test playing starts with the current media.
- player->play();
- QCOMPARE(player->currentMedia(), content1);
- QCOMPARE(player->state(), QMediaPlayer::PlayingState);
- QCOMPARE(stateSpy.count(), 1);
- QCOMPARE(mediaSpy.count(), 1);
-
- // Test pausing doesn't change the current media.
- player->pause();
- QCOMPARE(player->currentMedia(), content1);
- QCOMPARE(player->state(), QMediaPlayer::PausedState);
- QCOMPARE(stateSpy.count(), 2);
- QCOMPARE(mediaSpy.count(), 1);
-
- // Test stopping doesn't change the current media.
- player->stop();
- QCOMPARE(player->currentMedia(), content1);
- QCOMPARE(player->state(), QMediaPlayer::StoppedState);
- QCOMPARE(stateSpy.count(), 3);
- QCOMPARE(mediaSpy.count(), 1);
-
- // Test when the player service reaches the end of the current media, the player moves onto
- // the next item without stopping.
- player->play();
- QCOMPARE(player->currentMedia(), content1);
- QCOMPARE(player->state(), QMediaPlayer::PlayingState);
- QCOMPARE(stateSpy.count(), 4);
- QCOMPARE(mediaSpy.count(), 1);
-
- mockService->setState(QMediaPlayer::StoppedState, QMediaPlayer::EndOfMedia);
- QCOMPARE(player->currentMedia(), content2);
- QCOMPARE(player->state(), QMediaPlayer::PlayingState);
- QCOMPARE(stateSpy.count(), 4);
- QCOMPARE(mediaSpy.count(), 2);
-
- // Test skipping the current media doesn't change the state.
- playlist->next();
- QCOMPARE(player->currentMedia(), content3);
- QCOMPARE(player->state(), QMediaPlayer::PlayingState);
- QCOMPARE(stateSpy.count(), 4);
- QCOMPARE(mediaSpy.count(), 3);
-
- // Test changing the current media while paused doesn't change the state.
- player->pause();
- mockService->setMediaStatus(QMediaPlayer::BufferedMedia);
- QCOMPARE(player->currentMedia(), content3);
- QCOMPARE(player->state(), QMediaPlayer::PausedState);
- QCOMPARE(stateSpy.count(), 5);
- QCOMPARE(mediaSpy.count(), 3);
-
- playlist->previous();
- QCOMPARE(player->currentMedia(), content2);
- QCOMPARE(player->state(), QMediaPlayer::PausedState);
- QCOMPARE(stateSpy.count(), 5);
- QCOMPARE(mediaSpy.count(), 4);
-
- // Test changing the current media while stopped doesn't change the state.
- player->stop();
- mockService->setMediaStatus(QMediaPlayer::LoadedMedia);
- QCOMPARE(player->currentMedia(), content2);
- QCOMPARE(player->state(), QMediaPlayer::StoppedState);
- QCOMPARE(stateSpy.count(), 6);
- QCOMPARE(mediaSpy.count(), 4);
-
- playlist->next();
- QCOMPARE(player->currentMedia(), content3);
- QCOMPARE(player->state(), QMediaPlayer::StoppedState);
- QCOMPARE(stateSpy.count(), 6);
- QCOMPARE(mediaSpy.count(), 5);
-
- // Test the player is stopped and the current media cleared when it reaches the end of the last
- // item in the playlist.
- player->play();
- QCOMPARE(player->currentMedia(), content3);
- QCOMPARE(player->state(), QMediaPlayer::PlayingState);
- QCOMPARE(stateSpy.count(), 7);
- QCOMPARE(mediaSpy.count(), 5);
-
- // Double up the signals to ensure some noise doesn't destabalize things.
- mockService->setState(QMediaPlayer::StoppedState, QMediaPlayer::EndOfMedia);
- mockService->setState(QMediaPlayer::StoppedState, QMediaPlayer::EndOfMedia);
- QCOMPARE(player->currentMedia(), QMediaContent());
- QCOMPARE(player->state(), QMediaPlayer::StoppedState);
- QCOMPARE(stateSpy.count(), 8);
- QCOMPARE(mediaSpy.count(), 6);
-
- // Test starts playing from the start of the playlist if there is no current media selected.
- player->play();
- QCOMPARE(player->currentMedia(), content0);
- QCOMPARE(player->state(), QMediaPlayer::PlayingState);
- QCOMPARE(stateSpy.count(), 9);
- // one notification is for playlist and another is for the first media in the playlist
- QCOMPARE(mediaSpy.count(), 8);
-
- // Test deleting the playlist stops the player and clears the media it set.
- delete playlist;
- QCOMPARE(player->currentMedia(), QMediaContent());
- QCOMPARE(player->state(), QMediaPlayer::StoppedState);
- QCOMPARE(stateSpy.count(), 10);
- QCOMPARE(mediaSpy.count(), 9);
-
- // Test the player works as normal with the playlist removed.
- player->play();
- QCOMPARE(player->currentMedia(), QMediaContent());
- QCOMPARE(player->state(), QMediaPlayer::StoppedState);
- QCOMPARE(stateSpy.count(), 10);
- QCOMPARE(mediaSpy.count(), 9);
-
- player->setMedia(content1);
- player->play();
-
- QCOMPARE(player->currentMedia(), content1);
- QCOMPARE(player->state(), QMediaPlayer::PlayingState);
- QCOMPARE(stateSpy.count(), 11);
- QCOMPARE(mediaSpy.count(), 10);
-
- // Test the player can bind to playlist again
- playlist = new QMediaPlaylist;
- player->setPlaylist(playlist);
-
- QCOMPARE(player->currentMedia(), QMediaContent());
- QCOMPARE(player->state(), QMediaPlayer::StoppedState);
-
- playlist->addMedia(content0);
- playlist->addMedia(content1);
- playlist->addMedia(content2);
- playlist->addMedia(content3);
-
- playlist->setCurrentIndex(1);
- QCOMPARE(player->currentMedia(), content1);
- QCOMPARE(player->state(), QMediaPlayer::StoppedState);
-
- // Test attaching the new playlist,
- // player should detach the current one
- QMediaPlaylist *playlist2 = new QMediaPlaylist;
- playlist2->addMedia(content1);
- playlist2->addMedia(content2);
- playlist2->addMedia(content3);
- playlist2->setCurrentIndex(2);
-
- player->play();
- player->setPlaylist(playlist2);
- QCOMPARE(player->currentMedia(), playlist2->currentMedia());
- QCOMPARE(player->state(), QMediaPlayer::StoppedState);
-
- playlist2->setCurrentIndex(1);
- QCOMPARE(player->currentMedia(), playlist2->currentMedia());
-
- {
- QMediaPlaylist playlist;
- playlist.addMedia(content1);
- playlist.addMedia(content2);
- playlist.addMedia(content3);
- playlist.setCurrentIndex(1);
-
- // playlist resets to the first item
- player->setPlaylist(&playlist);
- QCOMPARE(player->playlist(), &playlist);
- QCOMPARE(player->currentMedia(), content1);
- } //playlist should be detached now
-
- QVERIFY(player->playlist() == 0);
- QCOMPARE(player->currentMedia(), QMediaContent());
-
- // Test when the player service encounters an invalid media, the player moves onto
- // the next item without stopping
- {
- QSignalSpy ss(player, SIGNAL(stateChanged(QMediaPlayer::State)));
- QSignalSpy ms(player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)));
-
- // playlist index is set to 0 when it is loaded into media player
- player->setPlaylist(playlist);
- player->play();
- QCOMPARE(ss.count(), 1);
- QCOMPARE(ms.count(), 1);
- QCOMPARE(qvariant_cast<QMediaPlayer::MediaStatus>(ms.last().value(0)), QMediaPlayer::LoadingMedia);
- ms.clear();
-
- mockService->setState(QMediaPlayer::StoppedState, QMediaPlayer::InvalidMedia);
- QCOMPARE(player->state(), QMediaPlayer::PlayingState);
- QCOMPARE(player->mediaStatus(), QMediaPlayer::LoadingMedia);
- QCOMPARE(ss.count(), 1);
- QCOMPARE(ms.count(), 2);
- QCOMPARE(qvariant_cast<QMediaPlayer::MediaStatus>(ms.at(0).value(0)), QMediaPlayer::InvalidMedia);
- QCOMPARE(qvariant_cast<QMediaPlayer::MediaStatus>(ms.at(1).value(0)), QMediaPlayer::LoadingMedia);
-
- // NOTE: status should begin transitioning through to BufferedMedia.
- QCOMPARE(player->currentMedia(), content1);
- }
-
- delete playlist;
- delete playlist2;
-}
-
-void tst_QMediaPlayer::testPlayerFlags()
-{
- MockMediaServiceProvider provider(0, true);
- QMediaPlayer::Flag flags = QMediaPlayer::LowLatency;
-
- QMediaServiceProviderHint::Feature feature;
-
- if (flags & QMediaPlayer::LowLatency)
- {
- /* if the flag is low latency set the low latency play back for the service provider */
- feature = QMediaServiceProviderHint::LowLatencyPlayback;
- const QByteArray service(Q_MEDIASERVICE_MEDIAPLAYER);
- const QMediaServiceProviderHint providerHint(feature);
- /* request service for the service provider */
- provider.requestService(service,providerHint);
-
- /* Constructs a SupportedFeatures media service provider hint. */
- QMediaServiceProviderHint servicepro(feature);
-
- /* compare the flag value */
- QVERIFY(servicepro.features() == QMediaServiceProviderHint::LowLatencyPlayback);
- }
-
- /* The player is expected to play QIODevice based streams.
- If passed to QMediaPlayer constructor,
- the service supporting streams playback will be chosen. */
- flags = QMediaPlayer::StreamPlayback;
- /* Construct a QMediaPlayer that uses the playback service from provider,
- parented to parent and with flags.*/
-
- if (flags & QMediaPlayer::StreamPlayback)
- {
- /* if the flag is stream play back set the stream play back for the service provider */
- feature = QMediaServiceProviderHint::StreamPlayback;
- const QByteArray service(Q_MEDIASERVICE_MEDIAPLAYER);
- const QMediaServiceProviderHint providerHint(feature);
-
- /* request service for the service provider */
- provider.requestService(service,providerHint);
-
- /* Constructs a SupportedFeatures media service provider hint. */
- QMediaServiceProviderHint servicepro(feature);
-
- /* compare the flag value */
- QVERIFY(servicepro.features() == QMediaServiceProviderHint::StreamPlayback);
- }
-}
-
-void tst_QMediaPlayer::testDestructor()
-{
- //don't use the same service as tst_QMediaPlayer::player
- mockProvider->service = new MockMediaPlayerService;
- mockProvider->deleteServiceOnRelease = true;
-
- /* create an object for player */
- QMediaPlayer *victim = new QMediaPlayer;
-
- /* check whether the object is created */
- QVERIFY(victim);
-
- /* delete the instance (a crash is a failure :) */
- delete victim;
-
- //service is released
- QVERIFY(mockProvider->service == 0);
-
- mockProvider->deleteServiceOnRelease = false;
-}
-
-void tst_QMediaPlayer::testSetVideoOutput()
-{
- MockVideoSurface surface;
-
- player->setVideoOutput(reinterpret_cast<QVideoWidget *>(0));
- player->setVideoOutput(reinterpret_cast<QGraphicsVideoItem *>(0));
-
- QCOMPARE(mockService->rendererRef, 0);
-
- player->setVideoOutput(&surface);
- QVERIFY(mockService->rendererControl->surface() == &surface);
- QCOMPARE(mockService->rendererRef, 1);
-
- player->setVideoOutput(reinterpret_cast<QAbstractVideoSurface *>(0));
- QVERIFY(mockService->rendererControl->surface() == 0);
-
- //rendererControl is released
- QCOMPARE(mockService->rendererRef, 0);
-
- player->setVideoOutput(&surface);
- QVERIFY(mockService->rendererControl->surface() == &surface);
- QCOMPARE(mockService->rendererRef, 1);
-
- player->setVideoOutput(reinterpret_cast<QVideoWidget *>(0));
- QVERIFY(mockService->rendererControl->surface() == 0);
- //rendererControl is released
- QCOMPARE(mockService->rendererRef, 0);
-
- player->setVideoOutput(&surface);
- QVERIFY(mockService->rendererControl->surface() == &surface);
- QCOMPARE(mockService->rendererRef, 1);
-}
-
-
-void tst_QMediaPlayer::testSetVideoOutputNoService()
-{
- MockVideoSurface surface;
-
- MockMediaServiceProvider provider(0, true);
- QMediaServiceProvider::setDefaultServiceProvider(&provider);
- QMediaPlayer player;
-
- player.setVideoOutput(&surface);
- // Nothing we can verify here other than it doesn't assert.
-}
-
-void tst_QMediaPlayer::testSetVideoOutputNoControl()
-{
- MockVideoSurface surface;
-
- MockMediaPlayerService service;
- service.rendererRef = 1;
-
- MockMediaServiceProvider provider(&service);
- QMediaServiceProvider::setDefaultServiceProvider(&provider);
- QMediaPlayer player;
-
- player.setVideoOutput(&surface);
- QVERIFY(service.rendererControl->surface() == 0);
-}
-
-void tst_QMediaPlayer::testSetVideoOutputDestruction()
-{
- MockVideoSurface surface;
- {
- QMediaPlayer player;
- player.setVideoOutput(&surface);
- QVERIFY(mockService->rendererControl->surface() == &surface);
- QCOMPARE(mockService->rendererRef, 1);
- }
- QVERIFY(mockService->rendererControl->surface() == 0);
- QCOMPARE(mockService->rendererRef, 0);
-}
-
-void tst_QMediaPlayer::testPositionPropertyWatch()
-{
- QMediaContent content0(QUrl(QLatin1String("test://audio/song1.mp3")));
- QMediaContent content1(QUrl(QLatin1String("test://audio/song2.mp3")));
-
- mockService->setIsValid(true);
- mockService->setState(QMediaPlayer::StoppedState, QMediaPlayer::NoMedia);
-
- QMediaPlaylist *playlist = new QMediaPlaylist;
-
- playlist->addMedia(content0);
- playlist->addMedia(content1);
-
- player->setPlaylist(playlist);
- player->setNotifyInterval(5);
-
- player->play();
- QSignalSpy positionSpy(player, SIGNAL(positionChanged(qint64)));
- playlist->next();
- QCOMPARE(player->state(), QMediaPlayer::PlayingState);
- QTRY_VERIFY(positionSpy.count() > 0);
-
- playlist->next();
- QCOMPARE(player->state(), QMediaPlayer::StoppedState);
-
- positionSpy.clear();
- QTRY_COMPARE(positionSpy.count(), 0);
-
- delete playlist;
-}
-
-void tst_QMediaPlayer::debugEnums()
-{
- QTest::ignoreMessage(QtDebugMsg, "QMediaPlayer::PlayingState");
- qDebug() << QMediaPlayer::PlayingState;
- QTest::ignoreMessage(QtDebugMsg, "QMediaPlayer::NoMedia");
- qDebug() << QMediaPlayer::NoMedia;
- QTest::ignoreMessage(QtDebugMsg, "QMediaPlayer::NetworkError");
- qDebug() << QMediaPlayer::NetworkError;
-}
-
-void tst_QMediaPlayer::testSupportedMimeTypes()
-{
- QStringList mimeList = QMediaPlayer::supportedMimeTypes(QMediaPlayer::LowLatency);
-
- // This is empty on some platforms, and not on others, so can't test something here at the moment.
-}
-
-void tst_QMediaPlayer::testQrc_data()
-{
- QTest::addColumn<QMediaContent>("mediaContent");
- QTest::addColumn<QMediaPlayer::MediaStatus>("status");
- QTest::addColumn<QMediaPlayer::Error>("error");
- QTest::addColumn<int>("errorCount");
- QTest::addColumn<bool>("hasStreamFeature");
- QTest::addColumn<QString>("backendMediaContentScheme");
- QTest::addColumn<bool>("backendHasStream");
-
- QTest::newRow("invalid") << QMediaContent(QUrl(QLatin1String("qrc:/invalid.mp3")))
- << QMediaPlayer::InvalidMedia
- << QMediaPlayer::ResourceError
- << 1 // error count
- << false // No StreamPlayback support
- << QString() // backend should not have got any media (empty URL scheme)
- << false; // backend should not have got any stream
-
- QTest::newRow("valid+nostream") << QMediaContent(QUrl(QLatin1String("qrc:/testdata/nokia-tune.mp3")))
- << QMediaPlayer::LoadingMedia
- << QMediaPlayer::NoError
- << 0 // error count
- << false // No StreamPlayback support
- << QStringLiteral("file") // backend should have a got a temporary file
- << false; // backend should not have got any stream
-
- QTest::newRow("valid+stream") << QMediaContent(QUrl(QLatin1String("qrc:/testdata/nokia-tune.mp3")))
- << QMediaPlayer::LoadingMedia
- << QMediaPlayer::NoError
- << 0 // error count
- << true // StreamPlayback support
- << QStringLiteral("qrc")
- << true; // backend should have got a stream (QFile opened from the resource)
-}
-
-void tst_QMediaPlayer::testQrc()
-{
- QFETCH(QMediaContent, mediaContent);
- QFETCH(QMediaPlayer::MediaStatus, status);
- QFETCH(QMediaPlayer::Error, error);
- QFETCH(int, errorCount);
- QFETCH(bool, hasStreamFeature);
- QFETCH(QString, backendMediaContentScheme);
- QFETCH(bool, backendHasStream);
-
- if (hasStreamFeature)
- mockProvider->setSupportedFeatures(QMediaServiceProviderHint::StreamPlayback);
-
- QMediaPlayer player;
-
- mockService->setState(QMediaPlayer::PlayingState, QMediaPlayer::NoMedia);
-
- QSignalSpy mediaSpy(&player, SIGNAL(currentMediaChanged(QMediaContent)));
- QSignalSpy statusSpy(&player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)));
- QSignalSpy errorSpy(&player, SIGNAL(error(QMediaPlayer::Error)));
-
- player.setMedia(mediaContent);
-
- QTRY_COMPARE(player.mediaStatus(), status);
- QCOMPARE(statusSpy.count(), 1);
- QCOMPARE(qvariant_cast<QMediaPlayer::MediaStatus>(statusSpy.last().value(0)), status);
-
- QCOMPARE(player.media(), mediaContent);
- QCOMPARE(player.currentMedia(), mediaContent);
- QCOMPARE(mediaSpy.count(), 1);
- QCOMPARE(qvariant_cast<QMediaContent>(mediaSpy.last().value(0)), mediaContent);
-
- QCOMPARE(player.error(), error);
- QCOMPARE(errorSpy.count(), errorCount);
- if (errorCount > 0) {
- QCOMPARE(qvariant_cast<QMediaPlayer::Error>(errorSpy.last().value(0)), error);
- QVERIFY(!player.errorString().isEmpty());
- }
-
- // Check the media actually passed to the backend
- QCOMPARE(mockService->mockControl->media().request().url().scheme(), backendMediaContentScheme);
- QCOMPARE(bool(mockService->mockControl->mediaStream()), backendHasStream);
-}
-
-void tst_QMediaPlayer::testAudioRole()
-{
- {
- mockService->setHasAudioRole(false);
- QMediaPlayer player;
-
- QCOMPARE(player.audioRole(), QAudio::UnknownRole);
- QVERIFY(player.supportedAudioRoles().isEmpty());
-
- QSignalSpy spy(&player, SIGNAL(audioRoleChanged(QAudio::Role)));
- player.setAudioRole(QAudio::MusicRole);
- QCOMPARE(player.audioRole(), QAudio::UnknownRole);
- QCOMPARE(spy.count(), 0);
- }
-
- {
- mockService->reset();
- mockService->setHasAudioRole(true);
- QMediaPlayer player;
- QSignalSpy spy(&player, SIGNAL(audioRoleChanged(QAudio::Role)));
-
- QCOMPARE(player.audioRole(), QAudio::UnknownRole);
- QVERIFY(!player.supportedAudioRoles().isEmpty());
-
- player.setAudioRole(QAudio::MusicRole);
- QCOMPARE(player.audioRole(), QAudio::MusicRole);
- QCOMPARE(mockService->mockAudioRoleControl->audioRole(), QAudio::MusicRole);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(qvariant_cast<QAudio::Role>(spy.last().value(0)), QAudio::MusicRole);
-
- spy.clear();
-
- player.setProperty("audioRole", QVariant::fromValue(QAudio::AlarmRole));
- QCOMPARE(qvariant_cast<QAudio::Role>(player.property("audioRole")), QAudio::AlarmRole);
- QCOMPARE(mockService->mockAudioRoleControl->audioRole(), QAudio::AlarmRole);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(qvariant_cast<QAudio::Role>(spy.last().value(0)), QAudio::AlarmRole);
- }
-}
-
-void tst_QMediaPlayer::testCustomAudioRole()
-{
- {
- mockService->setHasCustomAudioRole(false);
- QMediaPlayer player;
-
- QVERIFY(player.customAudioRole().isEmpty());
- QVERIFY(player.supportedCustomAudioRoles().isEmpty());
-
- QSignalSpy spyRole(&player, SIGNAL(audioRoleChanged(QAudio::Role)));
- QSignalSpy spyCustomRole(&player, SIGNAL(customAudioRoleChanged(const QString &)));
- player.setCustomAudioRole(QStringLiteral("customRole"));
- QCOMPARE(player.audioRole(), QAudio::UnknownRole);
- QVERIFY(player.customAudioRole().isEmpty());
- QCOMPARE(spyRole.count(), 0);
- QCOMPARE(spyCustomRole.count(), 0);
- }
-
- {
- mockService->reset();
- mockService->setHasAudioRole(false);
- QMediaPlayer player;
-
- QVERIFY(player.customAudioRole().isEmpty());
- QVERIFY(player.supportedCustomAudioRoles().isEmpty());
-
- QSignalSpy spyRole(&player, SIGNAL(audioRoleChanged(QAudio::Role)));
- QSignalSpy spyCustomRole(&player, SIGNAL(customAudioRoleChanged(const QString &)));
- player.setCustomAudioRole(QStringLiteral("customRole"));
- QCOMPARE(player.audioRole(), QAudio::UnknownRole);
- QVERIFY(player.customAudioRole().isEmpty());
- QCOMPARE(spyRole.count(), 0);
- QCOMPARE(spyCustomRole.count(), 0);
- }
-
- {
- mockService->reset();
- QMediaPlayer player;
- QSignalSpy spyRole(&player, SIGNAL(audioRoleChanged(QAudio::Role)));
- QSignalSpy spyCustomRole(&player, SIGNAL(customAudioRoleChanged(const QString &)));
-
- QCOMPARE(player.audioRole(), QAudio::UnknownRole);
- QVERIFY(player.customAudioRole().isEmpty());
- QVERIFY(!player.supportedCustomAudioRoles().isEmpty());
-
- QString customRole(QStringLiteral("customRole"));
- player.setCustomAudioRole(customRole);
- QCOMPARE(player.audioRole(), QAudio::CustomRole);
- QCOMPARE(player.customAudioRole(), customRole);
- QCOMPARE(mockService->mockAudioRoleControl->audioRole(), QAudio::CustomRole);
- QCOMPARE(mockService->mockCustomAudioRoleControl->customAudioRole(), customRole);
- QCOMPARE(spyRole.count(), 1);
- QCOMPARE(qvariant_cast<QAudio::Role>(spyRole.last().value(0)), QAudio::CustomRole);
- QCOMPARE(spyCustomRole.count(), 1);
- QCOMPARE(qvariant_cast<QString>(spyCustomRole.last().value(0)), customRole);
-
- spyRole.clear();
- spyCustomRole.clear();
-
- QString customRole2(QStringLiteral("customRole2"));
- player.setProperty("customAudioRole", QVariant::fromValue(customRole2));
- QCOMPARE(qvariant_cast<QString>(player.property("customAudioRole")), customRole2);
- QCOMPARE(mockService->mockCustomAudioRoleControl->customAudioRole(), customRole2);
- QCOMPARE(spyRole.count(), 0);
- QCOMPARE(spyCustomRole.count(), 1);
- QCOMPARE(qvariant_cast<QString>(spyCustomRole.last().value(0)), customRole2);
-
- spyRole.clear();
- spyCustomRole.clear();
-
- player.setAudioRole(QAudio::MusicRole);
- QCOMPARE(player.audioRole(), QAudio::MusicRole);
- QVERIFY(player.customAudioRole().isEmpty());
- QCOMPARE(mockService->mockAudioRoleControl->audioRole(), QAudio::MusicRole);
- QVERIFY(mockService->mockCustomAudioRoleControl->customAudioRole().isEmpty());
- QCOMPARE(spyRole.count(), 1);
- QCOMPARE(qvariant_cast<QAudio::Role>(spyRole.last().value(0)), QAudio::MusicRole);
- QCOMPARE(spyCustomRole.count(), 1);
- QVERIFY(qvariant_cast<QString>(spyCustomRole.last().value(0)).isEmpty());
-
- spyRole.clear();
- spyCustomRole.clear();
-
- player.setAudioRole(QAudio::CustomRole);
- QCOMPARE(player.audioRole(), QAudio::CustomRole);
- QVERIFY(player.customAudioRole().isEmpty());
- QCOMPARE(mockService->mockAudioRoleControl->audioRole(), QAudio::CustomRole);
- QVERIFY(mockService->mockCustomAudioRoleControl->customAudioRole().isEmpty());
- QCOMPARE(spyRole.count(), 1);
- QCOMPARE(qvariant_cast<QAudio::Role>(spyRole.last().value(0)), QAudio::CustomRole);
- QCOMPARE(spyCustomRole.count(), 0);
- }
-}
-
-QTEST_GUILESS_MAIN(tst_QMediaPlayer)
-#include "tst_qmediaplayer.moc"
diff --git a/tests/auto/unit/qmediaplayerwidgets/qmediaplayerwidgets.pro b/tests/auto/unit/qmediaplayerwidgets/qmediaplayerwidgets.pro
deleted file mode 100644
index 60c4f25f4..000000000
--- a/tests/auto/unit/qmediaplayerwidgets/qmediaplayerwidgets.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qmediaplayerwidgets
-QT += network multimedia-private multimediawidgets-private testlib widgets
-SOURCES += tst_qmediaplayerwidgets.cpp
-
-include (../qmultimedia_common/mock.pri)
-include (../qmultimedia_common/mockplayer.pri)
diff --git a/tests/auto/unit/qmediaplayerwidgets/tst_qmediaplayerwidgets.cpp b/tests/auto/unit/qmediaplayerwidgets/tst_qmediaplayerwidgets.cpp
deleted file mode 100644
index 1e6a714fb..000000000
--- a/tests/auto/unit/qmediaplayerwidgets/tst_qmediaplayerwidgets.cpp
+++ /dev/null
@@ -1,174 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//TESTED_COMPONENT=src/multimedia
-
-#include <QtTest/QtTest>
-#include <QtCore/qdebug.h>
-#include <QtCore/qbuffer.h>
-
-#include <qgraphicsvideoitem.h>
-#include <qabstractvideosurface.h>
-#include <qmediaplayer.h>
-#include <qmediaplayercontrol.h>
-
-#include "mockmediaserviceprovider.h"
-#include "mockmediaplayerservice.h"
-#include "mockvideosurface.h"
-
-QT_USE_NAMESPACE
-
-class tst_QMediaPlayerWidgets: public QObject
-{
- Q_OBJECT
-
-public slots:
- void initTestCase();
- void cleanupTestCase();
- void init();
- void cleanup();
-
-private slots:
- void testSetVideoOutput();
- void testSetVideoOutputNoService();
- void testSetVideoOutputNoControl();
-
-private:
- MockMediaServiceProvider *provider;
- MockMediaPlayerService *mockService;
-};
-
-void tst_QMediaPlayerWidgets::initTestCase()
-{
- provider = new MockMediaServiceProvider;
- QMediaServiceProvider::setDefaultServiceProvider(provider);
-}
-
-void tst_QMediaPlayerWidgets::cleanupTestCase()
-{
- delete provider;
-}
-
-void tst_QMediaPlayerWidgets::init()
-{
- mockService = new MockMediaPlayerService;
- provider->service = mockService;
-}
-
-void tst_QMediaPlayerWidgets::cleanup()
-{
-}
-
-void tst_QMediaPlayerWidgets::testSetVideoOutput()
-{
- QVideoWidget widget;
- QGraphicsVideoItem item;
- MockVideoSurface surface;
-
- QMediaPlayer player;
-
- player.setVideoOutput(&widget);
- QVERIFY(widget.mediaObject() == &player);
-
- player.setVideoOutput(&item);
- QVERIFY(widget.mediaObject() == 0);
- QVERIFY(item.mediaObject() == &player);
-
- player.setVideoOutput(reinterpret_cast<QVideoWidget *>(0));
- QVERIFY(item.mediaObject() == 0);
-
- player.setVideoOutput(&widget);
- QVERIFY(widget.mediaObject() == &player);
-
- player.setVideoOutput(reinterpret_cast<QGraphicsVideoItem *>(0));
- QVERIFY(widget.mediaObject() == 0);
-
- player.setVideoOutput(&surface);
- QVERIFY(mockService->rendererControl->surface() == &surface);
-
- player.setVideoOutput(reinterpret_cast<QAbstractVideoSurface *>(0));
- QVERIFY(mockService->rendererControl->surface() == 0);
-
- player.setVideoOutput(&surface);
- QVERIFY(mockService->rendererControl->surface() == &surface);
-
- player.setVideoOutput(&widget);
- QVERIFY(mockService->rendererControl->surface() == 0);
- QVERIFY(widget.mediaObject() == &player);
-
- player.setVideoOutput(&surface);
- QVERIFY(mockService->rendererControl->surface() == &surface);
- QVERIFY(widget.mediaObject() == 0);
-}
-
-
-void tst_QMediaPlayerWidgets::testSetVideoOutputNoService()
-{
- QVideoWidget widget;
- QGraphicsVideoItem item;
- MockVideoSurface surface;
-
- provider->service = 0;
- QMediaPlayer player;
-
- player.setVideoOutput(&widget);
- QVERIFY(widget.mediaObject() == 0);
-
- player.setVideoOutput(&item);
- QVERIFY(item.mediaObject() == 0);
-
- player.setVideoOutput(&surface);
- // Nothing we can verify here other than it doesn't assert.
-}
-
-void tst_QMediaPlayerWidgets::testSetVideoOutputNoControl()
-{
- QVideoWidget widget;
- QGraphicsVideoItem item;
- MockVideoSurface surface;
-
- MockMediaPlayerService service;
- service.rendererRef = 1;
- service.windowRef = 1;
-
- provider->service = &service;
-
- QMediaPlayer player;
-
- player.setVideoOutput(&widget);
- QVERIFY(widget.mediaObject() == 0);
-
- player.setVideoOutput(&item);
- QVERIFY(item.mediaObject() == 0);
-
- player.setVideoOutput(&surface);
- QVERIFY(service.rendererControl->surface() == 0);
-}
-
-QTEST_MAIN(tst_QMediaPlayerWidgets)
-#include "tst_qmediaplayerwidgets.moc"
diff --git a/tests/auto/unit/qmediaplaylist/qmediaplaylist.pro b/tests/auto/unit/qmediaplaylist/qmediaplaylist.pro
deleted file mode 100644
index 78a9ea7e8..000000000
--- a/tests/auto/unit/qmediaplaylist/qmediaplaylist.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qmediaplaylist
-
-include (../qmultimedia_common/mockplaylist.pri)
-
-QT += multimedia-private testlib
-
-SOURCES += \
- tst_qmediaplaylist.cpp
-
-INCLUDEPATH += ../../../../src/plugins/m3u
-
-TESTDATA += testdata/*
diff --git a/tests/auto/unit/qmediaplaylistnavigator/qmediaplaylistnavigator.pro b/tests/auto/unit/qmediaplaylistnavigator/qmediaplaylistnavigator.pro
deleted file mode 100644
index 042e6ac4c..000000000
--- a/tests/auto/unit/qmediaplaylistnavigator/qmediaplaylistnavigator.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qmediaplaylistnavigator
-
-QT += multimedia-private testlib
-
-SOURCES += tst_qmediaplaylistnavigator.cpp
-
diff --git a/tests/auto/unit/qmediaplaylistnavigator/tst_qmediaplaylistnavigator.cpp b/tests/auto/unit/qmediaplaylistnavigator/tst_qmediaplaylistnavigator.cpp
deleted file mode 100644
index ad7ec7179..000000000
--- a/tests/auto/unit/qmediaplaylistnavigator/tst_qmediaplaylistnavigator.cpp
+++ /dev/null
@@ -1,509 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//TESTED_COMPONENT=src/multimedia
-
-#include <QtTest/QtTest>
-#include <QDebug>
-#include <private/qmedianetworkplaylistprovider_p.h>
-#include <private/qmediaplaylistnavigator_p.h>
-
-QT_USE_NAMESPACE
-class tst_QMediaPlaylistNavigator : public QObject
-{
- Q_OBJECT
-public slots:
- void init();
- void cleanup();
-
-private slots:
- void construction();
- void setPlaylist();
- void linearPlayback();
- void loopPlayback();
- void currentItemOnce();
- void currentItemInLoop();
- void randomPlayback();
-
- void testItemAt();
- void testNextIndex();
- void testPreviousIndex();
- void testCurrentIndexChangedSignal();
- void testPlaybackModeChangedSignal();
- void testSurroundingItemsChangedSignal();
- void testActivatedSignal();
-};
-
-void tst_QMediaPlaylistNavigator::init()
-{
- qRegisterMetaType<QMediaPlaylist::PlaybackMode>("QMediaPlaylist::PlaybackMode");
- qRegisterMetaType<QMediaContent>("QMediaContent");
-}
-
-void tst_QMediaPlaylistNavigator::cleanup()
-{
-}
-
-void tst_QMediaPlaylistNavigator::construction()
-{
- QMediaNetworkPlaylistProvider playlist;
- QCOMPARE(playlist.mediaCount(), 0);
-
- QMediaPlaylistNavigator navigator(&playlist);
- QVERIFY(navigator.currentItem().isNull());
- QCOMPARE(navigator.currentIndex(), -1);
-}
-
-void tst_QMediaPlaylistNavigator::setPlaylist()
-{
- QMediaPlaylistNavigator navigator(0);
- QVERIFY(navigator.playlist() != 0);
- QCOMPARE(navigator.playlist()->mediaCount(), 0);
- QCOMPARE(navigator.playlist()->media(0), QMediaContent());
- QVERIFY(navigator.playlist()->isReadOnly() );
-
- QMediaNetworkPlaylistProvider playlist;
- QCOMPARE(playlist.mediaCount(), 0);
-
- navigator.setPlaylist(&playlist);
- QCOMPARE(navigator.playlist(), (QMediaPlaylistProvider*)&playlist);
- QCOMPARE(navigator.playlist()->mediaCount(), 0);
- QVERIFY(!navigator.playlist()->isReadOnly() );
-}
-
-void tst_QMediaPlaylistNavigator::linearPlayback()
-{
- QMediaNetworkPlaylistProvider playlist;
- QMediaPlaylistNavigator navigator(&playlist);
-
- navigator.setPlaybackMode(QMediaPlaylist::Sequential);
- navigator.jump(0);
- QVERIFY(navigator.currentItem().isNull());
- QCOMPARE(navigator.currentIndex(), -1);
-
- QMediaContent content1(QUrl(QLatin1String("file:///1")));
- playlist.addMedia(content1);
- navigator.jump(0);
- QVERIFY(!navigator.currentItem().isNull());
-
- QCOMPARE(navigator.currentIndex(), 0);
- QCOMPARE(navigator.currentItem(), content1);
- QCOMPARE(navigator.nextItem(), QMediaContent());
- QCOMPARE(navigator.nextItem(2), QMediaContent());
- QCOMPARE(navigator.previousItem(), QMediaContent());
- QCOMPARE(navigator.previousItem(2), QMediaContent());
-
- QMediaContent content2(QUrl(QLatin1String("file:///2")));
- playlist.addMedia(content2);
- QCOMPARE(navigator.currentIndex(), 0);
- QCOMPARE(navigator.currentItem(), content1);
- QCOMPARE(navigator.nextItem(), content2);
- QCOMPARE(navigator.nextItem(2), QMediaContent());
- QCOMPARE(navigator.previousItem(), QMediaContent());
- QCOMPARE(navigator.previousItem(2), QMediaContent());
-
- navigator.jump(1);
- QCOMPARE(navigator.currentIndex(), 1);
- QCOMPARE(navigator.currentItem(), content2);
- QCOMPARE(navigator.nextItem(), QMediaContent());
- QCOMPARE(navigator.nextItem(2), QMediaContent());
- QCOMPARE(navigator.previousItem(), content1);
- QCOMPARE(navigator.previousItem(2), QMediaContent());
-
- navigator.jump(0);
- navigator.next();
- QCOMPARE(navigator.currentIndex(), 1);
- navigator.next();
- QCOMPARE(navigator.currentIndex(), -1);
- navigator.next();//jump to the first item
- QCOMPARE(navigator.currentIndex(), 0);
-
- navigator.previous();
- QCOMPARE(navigator.currentIndex(), -1);
- navigator.previous();//jump to the last item
- QCOMPARE(navigator.currentIndex(), 1);
-}
-
-void tst_QMediaPlaylistNavigator::loopPlayback()
-{
- QMediaNetworkPlaylistProvider playlist;
- QMediaPlaylistNavigator navigator(&playlist);
-
- navigator.setPlaybackMode(QMediaPlaylist::Loop);
- navigator.jump(0);
- QVERIFY(navigator.currentItem().isNull());
- QCOMPARE(navigator.currentIndex(), -1);
-
- QMediaContent content1(QUrl(QLatin1String("file:///1")));
- playlist.addMedia(content1);
- navigator.jump(0);
- QVERIFY(!navigator.currentItem().isNull());
-
- QCOMPARE(navigator.currentIndex(), 0);
- QCOMPARE(navigator.currentItem(), content1);
- QCOMPARE(navigator.nextItem(), content1);
- QCOMPARE(navigator.nextItem(2), content1);
- QCOMPARE(navigator.previousItem(), content1);
- QCOMPARE(navigator.previousItem(2), content1);
-
- QMediaContent content2(QUrl(QLatin1String("file:///2")));
- playlist.addMedia(content2);
- QCOMPARE(navigator.currentIndex(), 0);
- QCOMPARE(navigator.currentItem(), content1);
- QCOMPARE(navigator.nextItem(), content2);
- QCOMPARE(navigator.nextItem(2), content1); //loop over end of the list
- QCOMPARE(navigator.previousItem(), content2);
- QCOMPARE(navigator.previousItem(2), content1);
-
- navigator.jump(1);
- QCOMPARE(navigator.currentIndex(), 1);
- QCOMPARE(navigator.currentItem(), content2);
- QCOMPARE(navigator.nextItem(), content1);
- QCOMPARE(navigator.nextItem(2), content2);
- QCOMPARE(navigator.previousItem(), content1);
- QCOMPARE(navigator.previousItem(2), content2);
-
- navigator.jump(0);
- navigator.next();
- QCOMPARE(navigator.currentIndex(), 1);
- navigator.next();
- QCOMPARE(navigator.currentIndex(), 0);
- navigator.previous();
- QCOMPARE(navigator.currentIndex(), 1);
- navigator.previous();
- QCOMPARE(navigator.currentIndex(), 0);
-}
-
-void tst_QMediaPlaylistNavigator::currentItemOnce()
-{
- QMediaNetworkPlaylistProvider playlist;
- QMediaPlaylistNavigator navigator(&playlist);
-
- navigator.setPlaybackMode(QMediaPlaylist::CurrentItemOnce);
-
- QCOMPARE(navigator.playbackMode(), QMediaPlaylist::CurrentItemOnce);
- QCOMPARE(navigator.currentIndex(), -1);
-
- playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///1"))));
- playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///2"))));
- playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///3"))));
-
- QCOMPARE(navigator.currentIndex(), -1);
- navigator.next();
- QCOMPARE(navigator.currentIndex(), -1);
-
- navigator.jump(1);
- QCOMPARE(navigator.currentIndex(), 1);
- navigator.next();
- QCOMPARE(navigator.currentIndex(), -1);
- navigator.next();
- QCOMPARE(navigator.currentIndex(), -1);
- navigator.previous();
- QCOMPARE(navigator.currentIndex(), -1);
- navigator.jump(1);
- navigator.previous();
- QCOMPARE(navigator.currentIndex(), -1);
-}
-
-void tst_QMediaPlaylistNavigator::currentItemInLoop()
-{
- QMediaNetworkPlaylistProvider playlist;
- QMediaPlaylistNavigator navigator(&playlist);
-
- navigator.setPlaybackMode(QMediaPlaylist::CurrentItemInLoop);
-
- QCOMPARE(navigator.playbackMode(), QMediaPlaylist::CurrentItemInLoop);
- QCOMPARE(navigator.currentIndex(), -1);
-
- playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///1"))));
- playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///2"))));
- playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///3"))));
-
- QCOMPARE(navigator.currentIndex(), -1);
- navigator.next();
- QCOMPARE(navigator.currentIndex(), -1);
- navigator.jump(1);
- navigator.next();
- QCOMPARE(navigator.currentIndex(), 1);
- navigator.next();
- QCOMPARE(navigator.currentIndex(), 1);
- navigator.previous();
- QCOMPARE(navigator.currentIndex(), 1);
- navigator.previous();
- QCOMPARE(navigator.currentIndex(), 1);
-}
-
-void tst_QMediaPlaylistNavigator::randomPlayback()
-{
- QMediaNetworkPlaylistProvider playlist;
- QMediaPlaylistNavigator navigator(&playlist);
-
- navigator.setPlaybackMode(QMediaPlaylist::Random);
-
- QCOMPARE(navigator.playbackMode(), QMediaPlaylist::Random);
- QCOMPARE(navigator.currentIndex(), -1);
-
- playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///1"))));
- playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///2"))));
- playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///3"))));
-
- playlist.shuffle();
-
- QCOMPARE(navigator.currentIndex(), -1);
- navigator.next();
- int pos1 = navigator.currentIndex();
- navigator.next();
- int pos2 = navigator.currentIndex();
- navigator.next();
- int pos3 = navigator.currentIndex();
-
- QVERIFY(pos1 != -1);
- QVERIFY(pos2 != -1);
- QVERIFY(pos3 != -1);
-
- navigator.previous();
- QCOMPARE(navigator.currentIndex(), pos2);
- navigator.next();
- QCOMPARE(navigator.currentIndex(), pos3);
- navigator.next();
- int pos4 = navigator.currentIndex();
- navigator.previous();
- QCOMPARE(navigator.currentIndex(), pos3);
- navigator.previous();
- QCOMPARE(navigator.currentIndex(), pos2);
- navigator.previous();
- QCOMPARE(navigator.currentIndex(), pos1);
- navigator.previous();
- int pos0 = navigator.currentIndex();
- QVERIFY(pos0 != -1);
- navigator.next();
- navigator.next();
- navigator.next();
- navigator.next();
- QCOMPARE(navigator.currentIndex(), pos4);
-
-}
-
-void tst_QMediaPlaylistNavigator::testItemAt()
-{
- QMediaNetworkPlaylistProvider playlist;
- QMediaPlaylistNavigator navigator(&playlist);
- navigator.setPlaybackMode(QMediaPlaylist::Random);
- QCOMPARE(navigator.playbackMode(), QMediaPlaylist::Random);
- QCOMPARE(navigator.currentIndex(), -1);
-
- //Adding the media to the playlist
- QMediaContent content = QMediaContent(QUrl(QLatin1String("file:///1")));
- playlist.addMedia(content);
-
- //Currently it is not pointing to any index , Returns Null mediacontent
- QCOMPARE(navigator.currentIndex(), -1);
- QCOMPARE(navigator.itemAt(navigator.currentIndex()),QMediaContent());
- navigator.next();
-
- //Points to the added media
- int pos1 = navigator.currentIndex();
- QCOMPARE(content,navigator.itemAt(pos1));
-}
-
-void tst_QMediaPlaylistNavigator::testNextIndex()
-{
- QMediaNetworkPlaylistProvider playlist;
- QMediaPlaylistNavigator navigator(&playlist);
- navigator.setPlaybackMode(QMediaPlaylist::Random);
- QCOMPARE(navigator.playbackMode(), QMediaPlaylist::Random);
- QCOMPARE(navigator.currentIndex(), -1);
-
- //Adding the media to the playlist
- playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///1"))));
- playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///2"))));
- playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///3"))));
-
- playlist.shuffle();
-
- //Currently it is not pointing to any index
- QCOMPARE(navigator.currentIndex(), -1);
- navigator.next();
- int pos1 = navigator.currentIndex();
- //Pointing to the next index
- navigator.next();
- int pos2 = navigator.currentIndex();
- navigator.next();
- int pos3 = navigator.currentIndex();
-
- //Pointing to the previous index
- navigator.previous();
- QCOMPARE(navigator.nextIndex(1), pos3);
- navigator.previous();
- QCOMPARE(navigator.nextIndex(1), pos2);
- QCOMPARE(navigator.nextIndex(2), pos3);
- navigator.previous();
- QCOMPARE(navigator.nextIndex(1), pos1);
-}
-
-void tst_QMediaPlaylistNavigator::testPreviousIndex()
-{
- QMediaNetworkPlaylistProvider playlist;
- QMediaPlaylistNavigator navigator(&playlist);
- navigator.setPlaybackMode(QMediaPlaylist::Random);
- QCOMPARE(navigator.playbackMode(), QMediaPlaylist::Random);
- QCOMPARE(navigator.currentIndex(), -1);
-
- //Adding the media to the playlist
- playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///1"))));
- playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///2"))));
- playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///3"))));
- playlist.shuffle();
-
- //Currently it is not pointing to any index
- QCOMPARE(navigator.currentIndex(), -1);
-
- //pointing to next index
- navigator.next();
- int pos1 = navigator.currentIndex();
- navigator.next();
- int pos2 = navigator.currentIndex();
- navigator.next();
- int pos3 = navigator.currentIndex();
- QCOMPARE(navigator.previousIndex(1), pos2);
- QCOMPARE(navigator.previousIndex(2), pos1);
- navigator.next();
- QCOMPARE(navigator.previousIndex(1), pos3);
-}
-
-void tst_QMediaPlaylistNavigator::testCurrentIndexChangedSignal()
-{
- QMediaNetworkPlaylistProvider playlist;
- QMediaPlaylistNavigator navigator(&playlist);
- QCOMPARE(navigator.playbackMode(), QMediaPlaylist::Sequential);
- QCOMPARE(navigator.currentIndex(), -1);
-
- //Creating a QSignalSpy object for currentIndexChanged() signal
- QSignalSpy spy(&navigator,SIGNAL(currentIndexChanged(int)));
- QVERIFY(spy.count() == 0);
-
- //Adding the media to the playlist
- playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///1"))));
- playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///2"))));
- playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///3"))));
-
- //Currently it is not pointing to any index
- QCOMPARE(navigator.currentIndex(), -1);
- navigator.next();
- QVERIFY(spy.count() == 1);
- int pos1 = navigator.currentIndex();
- //Pointing to the next index
- navigator.next();
- QVERIFY(navigator.previousIndex(1) == pos1);
- QVERIFY(spy.count() == 2);
-}
-
-void tst_QMediaPlaylistNavigator::testPlaybackModeChangedSignal()
-{
- QMediaNetworkPlaylistProvider playlist;
- QMediaPlaylistNavigator navigator(&playlist);
- navigator.setPlaybackMode(QMediaPlaylist::Random);
- QCOMPARE(navigator.playbackMode(), QMediaPlaylist::Random);
- QCOMPARE(navigator.currentIndex(), -1);
-
- //Creating a QSignalSpy object for currentIndexChanged() signal
- QSignalSpy spy(&navigator,SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode)));
- QVERIFY(spy.count() == 0);
-
- //Adding the media to the playlist
- playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///1"))));
-
- //set the play back mode to sequential
- navigator.setPlaybackMode(QMediaPlaylist::Sequential);
- QCOMPARE(navigator.playbackMode(), QMediaPlaylist::Sequential);
- QVERIFY(spy.count() == 1);
-
- //set the play back mode to loop
- navigator.setPlaybackMode(QMediaPlaylist::Loop);
- QCOMPARE(navigator.playbackMode(), QMediaPlaylist::Loop);
- QVERIFY(spy.count() == 2);
-}
-
-void tst_QMediaPlaylistNavigator::testSurroundingItemsChangedSignal()
-{
- QMediaNetworkPlaylistProvider playlist;
- QMediaPlaylistNavigator navigator(&playlist);
- navigator.setPlaybackMode(QMediaPlaylist::Random);
- QCOMPARE(navigator.playbackMode(), QMediaPlaylist::Random);
- QCOMPARE(navigator.currentIndex(), -1);
-
- //Creating a QSignalSpy object for surroundingItemsChanged()signal
- QSignalSpy spy(&navigator,SIGNAL(surroundingItemsChanged()));
- QVERIFY(spy.count() == 0);
-
- //Adding the media to the playlist
- playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///1"))));
- QVERIFY(spy.count() == 1);
-
- //set the play back mode to sequential
- navigator.setPlaybackMode(QMediaPlaylist::Sequential);
- QCOMPARE(navigator.playbackMode(), QMediaPlaylist::Sequential);
- QVERIFY(spy.count() == 2);
-
- //Point to the next index
- navigator.next();
- QVERIFY(spy.count() == 3);
-}
-
-void tst_QMediaPlaylistNavigator::testActivatedSignal()
-{
- QMediaNetworkPlaylistProvider playlist;
- QMediaPlaylistNavigator navigator(&playlist);
- navigator.setPlaybackMode(QMediaPlaylist::Random);
- QCOMPARE(navigator.playbackMode(), QMediaPlaylist::Random);
- QCOMPARE(navigator.currentIndex(), -1);
-
- //Creating a QSignalSpy object for surroundingItemsChanged()signal
- QSignalSpy spy(&navigator,SIGNAL(activated(QMediaContent)));
- QVERIFY(spy.count() == 0);
-
- //Adding the media to the playlist
- playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///1"))));
- playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///2"))));
- playlist.shuffle();
-
- //Point to the next index
- navigator.next();
- QVERIFY(spy.count() == 1);
-
- //Jump to 0th item
- navigator.jump(0);
- QVERIFY(spy.count() == 2);
-
- //move to previous item
- navigator.previous();
- QVERIFY(spy.count() == 3);
-}
-
-QTEST_MAIN(tst_QMediaPlaylistNavigator)
-#include "tst_qmediaplaylistnavigator.moc"
diff --git a/tests/auto/unit/qmediapluginloader/qmediapluginloader.pro b/tests/auto/unit/qmediapluginloader/qmediapluginloader.pro
deleted file mode 100644
index 90b02ac59..000000000
--- a/tests/auto/unit/qmediapluginloader/qmediapluginloader.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qmediapluginloader
-
-QT += multimedia-private testlib
-
-SOURCES += tst_qmediapluginloader.cpp
diff --git a/tests/auto/unit/qmediapluginloader/tst_qmediapluginloader.cpp b/tests/auto/unit/qmediapluginloader/tst_qmediapluginloader.cpp
deleted file mode 100644
index ce1b2b9d0..000000000
--- a/tests/auto/unit/qmediapluginloader/tst_qmediapluginloader.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//TESTED_COMPONENT=src/multimedia
-
-#include <private/qmediapluginloader_p.h>
-#include <qmediaserviceproviderplugin.h>
-
-#include <QtTest/QtTest>
-#include <QDebug>
-
-QT_USE_NAMESPACE
-
-class tst_QMediaPluginLoader : public QObject
-{
- Q_OBJECT
-
-public slots:
- void initTestCase();
- void cleanupTestCase();
-
-private slots:
- void testInstance();
- void testInstances();
- void testInvalidKey();
-
-private:
- QMediaPluginLoader *loader;
-};
-
-void tst_QMediaPluginLoader::initTestCase()
-{
- loader = new QMediaPluginLoader(QMediaServiceProviderFactoryInterface_iid,
- QLatin1String("mediaservice"),
- Qt::CaseInsensitive);
-}
-
-void tst_QMediaPluginLoader::cleanupTestCase()
-{
- delete loader;
-}
-
-void tst_QMediaPluginLoader::testInstance()
-{
- const QStringList keys = loader->keys();
-
- if (keys.isEmpty()) // Test is invalidated, skip.
- QSKIP("No plug-ins available");
-
- for (const QString &key : keys)
- QVERIFY(loader->instance(key) != 0);
-}
-
-void tst_QMediaPluginLoader::testInstances()
-{
- const QStringList keys = loader->keys();
-
- if (keys.isEmpty()) // Test is invalidated, skip.
- QSKIP("No plug-ins available");
-
- for (const QString &key : keys)
- QVERIFY(loader->instances(key).size() > 0);
-}
-
-// Last so as to not interfere with the other tests if there is a failure.
-void tst_QMediaPluginLoader::testInvalidKey()
-{
- const QString key(QLatin1String("invalid-key"));
-
- // This test assumes there is no 'invalid-key' in the key list, verify that.
- if (loader->keys().contains(key))
- QSKIP("a plug-in includes the invalid key");
-
- QVERIFY(loader->instance(key) == 0);
-
- // Test looking up the key hasn't inserted it into the list. See QMap::operator[].
- QVERIFY(!loader->keys().contains(key));
-
- QVERIFY(loader->instances(key).isEmpty());
- QVERIFY(!loader->keys().contains(key));
-}
-
-QTEST_MAIN(tst_QMediaPluginLoader)
-
-#include "tst_qmediapluginloader.moc"
diff --git a/tests/auto/unit/qmediarecorder/qmediarecorder.pro b/tests/auto/unit/qmediarecorder/qmediarecorder.pro
deleted file mode 100644
index 7103ea157..000000000
--- a/tests/auto/unit/qmediarecorder/qmediarecorder.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qmediarecorder
-QT += multimedia-private testlib
-SOURCES += tst_qmediarecorder.cpp
-
-include (../qmultimedia_common/mock.pri)
-include (../qmultimedia_common/mockrecorder.pri)
diff --git a/tests/auto/unit/qmediarecorder/tst_qmediarecorder.cpp b/tests/auto/unit/qmediarecorder/tst_qmediarecorder.cpp
deleted file mode 100644
index 944207dfe..000000000
--- a/tests/auto/unit/qmediarecorder/tst_qmediarecorder.cpp
+++ /dev/null
@@ -1,1497 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//TESTED_COMPONENT=src/multimedia
-
-#include <QtTest/QtTest>
-#include <QDebug>
-#include <QtMultimedia/qmediametadata.h>
-#include <qmediaobject.h>
-#include <qmediacontrol.h>
-#include <qmediaservice.h>
-#include <qmediarecordercontrol.h>
-#include <qmediarecorder.h>
-#include <qmetadatawritercontrol.h>
-#include <qaudioinputselectorcontrol.h>
-#include <qaudioencodersettingscontrol.h>
-#include <qmediacontainercontrol.h>
-#include <qvideoencodersettingscontrol.h>
-#include <qaudioformat.h>
-
-#include "mockmediarecorderservice.h"
-#include "mockmediaobject.h"
-
-QT_USE_NAMESPACE
-
-class tst_QMediaRecorder: public QObject
-{
- Q_OBJECT
-
-public slots:
- void initTestCase();
- void cleanupTestCase();
-
-private slots:
- void testNullService();
- void testNullControls();
- void testDeleteMediaObject();
- void testError();
- void testSink();
- void testRecord();
- void testMute();
- void testVolume();
- void testAudioDeviceControl();
- void testAudioEncodeControl();
- void testMediaFormatsControl();
- void testVideoEncodeControl();
- void testEncodingSettings();
- void testAudioSettings();
- void testVideoSettings();
- void testSettingsApplied();
-
- void nullMetaDataControl();
- void isMetaDataAvailable();
- void isWritable();
- void metaDataChanged();
- void metaData_data();
- void metaData();
- void setMetaData_data();
- void setMetaData();
-
- void testAudioSettingsCopyConstructor();
- void testAudioSettingsOperatorNotEqual();
- void testAudioSettingsOperatorEqual();
- void testAudioSettingsOperatorAssign();
- void testAudioSettingsDestructor();
-
- void testAvailabilityStatus();
- void testIsAvailable();
- void testMediaObject();
- void testEnum();
-
- void testVideoSettingsQuality();
- void testVideoSettingsEncodingMode();
- void testVideoSettingsCopyConstructor();
- void testVideoSettingsOperatorAssignment();
- void testVideoSettingsOperatorNotEqual();
- void testVideoSettingsOperatorComparison();
- void testVideoSettingsDestructor();
-
-private:
- QAudioEncoderSettingsControl* encode;
- QAudioInputSelectorControl* audio;
- MockMediaObject *object;
- MockMediaRecorderService*service;
- MockMediaRecorderControl *mock;
- QMediaRecorder *capture;
- QVideoEncoderSettingsControl* videoEncode;
-};
-
-void tst_QMediaRecorder::initTestCase()
-{
- qRegisterMetaType<QMediaRecorder::State>("QMediaRecorder::State");
- qRegisterMetaType<QMediaRecorder::Error>("QMediaRecorder::Error");
-
- mock = new MockMediaRecorderControl(this);
- service = new MockMediaRecorderService(this, mock);
- object = new MockMediaObject(this, service);
- capture = new QMediaRecorder(object);
-
- audio = qobject_cast<QAudioInputSelectorControl*>(service->requestControl(QAudioInputSelectorControl_iid));
- encode = qobject_cast<QAudioEncoderSettingsControl*>(service->requestControl(QAudioEncoderSettingsControl_iid));
- videoEncode = qobject_cast<QVideoEncoderSettingsControl*>(service->requestControl(QVideoEncoderSettingsControl_iid));
-}
-
-void tst_QMediaRecorder::cleanupTestCase()
-{
- delete capture;
- delete object;
- delete service;
- delete mock;
-}
-
-void tst_QMediaRecorder::testNullService()
-{
- const QString id(QLatin1String("application/x-format"));
-
- MockMediaObject object(0, 0);
- QMediaRecorder recorder(&object);
-
- QCOMPARE(recorder.outputLocation(), QUrl());
- QCOMPARE(recorder.state(), QMediaRecorder::StoppedState);
- QCOMPARE(recorder.error(), QMediaRecorder::NoError);
- QCOMPARE(recorder.duration(), qint64(0));
- QCOMPARE(recorder.supportedContainers(), QStringList());
- QCOMPARE(recorder.containerDescription(id), QString());
- QCOMPARE(recorder.supportedAudioCodecs(), QStringList());
- QCOMPARE(recorder.audioCodecDescription(id), QString());
- QCOMPARE(recorder.supportedAudioSampleRates(), QList<int>());
- QCOMPARE(recorder.supportedVideoCodecs(), QStringList());
- QCOMPARE(recorder.videoCodecDescription(id), QString());
- bool continuous = true;
- QCOMPARE(recorder.supportedResolutions(QVideoEncoderSettings(), &continuous), QList<QSize>());
- QCOMPARE(continuous, false);
- continuous = true;
- QCOMPARE(recorder.supportedFrameRates(QVideoEncoderSettings(), &continuous), QList<qreal>());
- QCOMPARE(continuous, false);
- QCOMPARE(recorder.audioSettings(), QAudioEncoderSettings());
- QCOMPARE(recorder.videoSettings(), QVideoEncoderSettings());
- QCOMPARE(recorder.containerFormat(), QString());
- QVERIFY(!recorder.isMuted());
- recorder.setMuted(true);
- QVERIFY(!recorder.isMuted());
-}
-
-void tst_QMediaRecorder::testNullControls()
-{
- const QString id(QLatin1String("application/x-format"));
-
- MockMediaRecorderService service(0, 0);
- service.hasControls = false;
- MockMediaObject object(0, &service);
- QMediaRecorder recorder(&object);
-
- QCOMPARE(recorder.outputLocation(), QUrl());
- QCOMPARE(recorder.state(), QMediaRecorder::StoppedState);
- QCOMPARE(recorder.error(), QMediaRecorder::NoError);
- QCOMPARE(recorder.duration(), qint64(0));
- QCOMPARE(recorder.supportedContainers(), QStringList());
- QCOMPARE(recorder.containerDescription(id), QString());
- QCOMPARE(recorder.supportedAudioCodecs(), QStringList());
- QCOMPARE(recorder.audioCodecDescription(id), QString());
- QCOMPARE(recorder.supportedAudioSampleRates(), QList<int>());
- QCOMPARE(recorder.supportedVideoCodecs(), QStringList());
- QCOMPARE(recorder.videoCodecDescription(id), QString());
- bool continuous = true;
- QCOMPARE(recorder.supportedResolutions(QVideoEncoderSettings(), &continuous), QList<QSize>());
- QCOMPARE(continuous, false);
- continuous = true;
- QCOMPARE(recorder.supportedFrameRates(QVideoEncoderSettings(), &continuous), QList<qreal>());
- QCOMPARE(continuous, false);
- QCOMPARE(recorder.audioSettings(), QAudioEncoderSettings());
- QCOMPARE(recorder.videoSettings(), QVideoEncoderSettings());
- QCOMPARE(recorder.containerFormat(), QString());
-
- recorder.setOutputLocation(QUrl("file://test/save/file.mp4"));
- QCOMPARE(recorder.outputLocation(), QUrl());
- QCOMPARE(recorder.actualLocation(), QUrl());
-
- QAudioEncoderSettings audio;
- audio.setCodec(id);
- audio.setQuality(QMultimedia::LowQuality);
-
- QVideoEncoderSettings video;
- video.setCodec(id);
- video.setResolution(640, 480);
-
- recorder.setEncodingSettings(audio, video, id);
-
- QCOMPARE(recorder.audioSettings(), QAudioEncoderSettings());
- QCOMPARE(recorder.videoSettings(), QVideoEncoderSettings());
- QCOMPARE(recorder.containerFormat(), QString());
-
- QSignalSpy spy(&recorder, SIGNAL(stateChanged(QMediaRecorder::State)));
-
- recorder.record();
- QCOMPARE(recorder.state(), QMediaRecorder::StoppedState);
- QCOMPARE(recorder.error(), QMediaRecorder::NoError);
- QCOMPARE(spy.count(), 0);
-
- recorder.pause();
- QCOMPARE(recorder.state(), QMediaRecorder::StoppedState);
- QCOMPARE(recorder.error(), QMediaRecorder::NoError);
- QCOMPARE(spy.count(), 0);
-
- recorder.stop();
- QCOMPARE(recorder.state(), QMediaRecorder::StoppedState);
- QCOMPARE(recorder.error(), QMediaRecorder::NoError);
- QCOMPARE(spy.count(), 0);
-}
-
-void tst_QMediaRecorder::testDeleteMediaObject()
-{
- MockMediaRecorderControl *mock = new MockMediaRecorderControl(this);
- MockMediaRecorderService *service = new MockMediaRecorderService(this, mock);
- MockMediaObject *object = new MockMediaObject(this, service);
- QMediaRecorder *capture = new QMediaRecorder(object);
-
- QVERIFY(capture->mediaObject() == object);
- QVERIFY(capture->isAvailable());
-
- delete object;
- delete service;
- delete mock;
-
- QVERIFY(capture->mediaObject() == 0);
- QVERIFY(!capture->isAvailable());
-
- delete capture;
-}
-
-void tst_QMediaRecorder::testError()
-{
- const QString errorString(QLatin1String("format error"));
-
- QSignalSpy spy(capture, SIGNAL(error(QMediaRecorder::Error)));
-
- QCOMPARE(capture->error(), QMediaRecorder::NoError);
- QCOMPARE(capture->errorString(), QString());
-
- mock->error(QMediaRecorder::FormatError, errorString);
- QCOMPARE(capture->error(), QMediaRecorder::FormatError);
- QCOMPARE(capture->errorString(), errorString);
- QCOMPARE(spy.count(), 1);
-
- QCOMPARE(spy.last()[0].value<QMediaRecorder::Error>(), QMediaRecorder::FormatError);
-}
-
-void tst_QMediaRecorder::testSink()
-{
- capture->setOutputLocation(QUrl("test.tmp"));
- QUrl s = capture->outputLocation();
- QCOMPARE(s.toString(), QString("test.tmp"));
- QCOMPARE(capture->actualLocation(), QUrl());
-
- //the actual location is available after record
- capture->record();
- QCOMPARE(capture->actualLocation().toString(), QString("test.tmp"));
- capture->stop();
- QCOMPARE(capture->actualLocation().toString(), QString("test.tmp"));
-
- //setOutputLocation resets the actual location
- capture->setOutputLocation(QUrl());
- QCOMPARE(capture->actualLocation(), QUrl());
-
- capture->record();
- QCOMPARE(capture->actualLocation(), QUrl::fromLocalFile("default_name.mp4"));
- capture->stop();
- QCOMPARE(capture->actualLocation(), QUrl::fromLocalFile("default_name.mp4"));
-}
-
-void tst_QMediaRecorder::testRecord()
-{
- QSignalSpy stateSignal(capture,SIGNAL(stateChanged(QMediaRecorder::State)));
- QSignalSpy statusSignal(capture,SIGNAL(statusChanged(QMediaRecorder::Status)));
- QSignalSpy progressSignal(capture, SIGNAL(durationChanged(qint64)));
- capture->record();
- QCOMPARE(capture->state(), QMediaRecorder::RecordingState);
- QCOMPARE(capture->error(), QMediaRecorder::NoError);
- QCOMPARE(capture->errorString(), QString());
-
- QCOMPARE(stateSignal.count(), 1);
- QCOMPARE(stateSignal.last()[0].value<QMediaRecorder::State>(), QMediaRecorder::RecordingState);
-
- QTestEventLoop::instance().enterLoop(1);
-
- QCOMPARE(capture->status(), QMediaRecorder::RecordingStatus);
- QVERIFY(!statusSignal.isEmpty());
- QCOMPARE(statusSignal.last()[0].value<QMediaRecorder::Status>(), QMediaRecorder::RecordingStatus);
- statusSignal.clear();
-
- QVERIFY(progressSignal.count() > 0);
-
- capture->pause();
-
- QCOMPARE(capture->state(), QMediaRecorder::PausedState);
-
- QCOMPARE(stateSignal.count(), 2);
-
- QTestEventLoop::instance().enterLoop(1);
- QCOMPARE(capture->status(), QMediaRecorder::PausedStatus);
- QVERIFY(!statusSignal.isEmpty());
- QCOMPARE(statusSignal.last()[0].value<QMediaRecorder::Status>(), QMediaRecorder::PausedStatus);
- statusSignal.clear();
-
- capture->stop();
-
- QCOMPARE(capture->state(), QMediaRecorder::StoppedState);
- QCOMPARE(stateSignal.count(), 3);
-
- QTestEventLoop::instance().enterLoop(1);
- QCOMPARE(capture->status(), QMediaRecorder::LoadedStatus);
- QVERIFY(!statusSignal.isEmpty());
- QCOMPARE(statusSignal.last()[0].value<QMediaRecorder::Status>(), QMediaRecorder::LoadedStatus);
- statusSignal.clear();
-
- mock->stop();
- QCOMPARE(stateSignal.count(), 3);
-}
-
-void tst_QMediaRecorder::testMute()
-{
- QSignalSpy mutedChanged(capture, SIGNAL(mutedChanged(bool)));
- QVERIFY(!capture->isMuted());
- capture->setMuted(true);
-
- QCOMPARE(mutedChanged.size(), 1);
- QCOMPARE(mutedChanged[0][0].toBool(), true);
- QVERIFY(capture->isMuted());
-
- capture->setMuted(false);
-
- QCOMPARE(mutedChanged.size(), 2);
- QCOMPARE(mutedChanged[1][0].toBool(), false);
- QVERIFY(!capture->isMuted());
-
- capture->setMuted(false);
- QCOMPARE(mutedChanged.size(), 2);
-}
-
-void tst_QMediaRecorder::testVolume()
-{
- QSignalSpy volumeChanged(capture, SIGNAL(volumeChanged(qreal)));
- QCOMPARE(capture->volume(), 1.0);
- capture->setVolume(2.0);
-
- QCOMPARE(volumeChanged.size(), 1);
- QCOMPARE(volumeChanged[0][0].toReal(), 2.0);
- QCOMPARE(capture->volume(), 2.0);
-
- capture->setVolume(1.0);
-
- QCOMPARE(volumeChanged.size(), 2);
- QCOMPARE(volumeChanged[1][0].toReal(), 1.0);
- QCOMPARE(capture->volume(), 1.0);
-
- capture->setVolume(1.0);
- QCOMPARE(volumeChanged.size(), 2);
-}
-
-void tst_QMediaRecorder::testAudioDeviceControl()
-{
- QSignalSpy readSignal(audio,SIGNAL(activeInputChanged(QString)));
- QVERIFY(audio->availableInputs().size() == 3);
- QVERIFY(audio->defaultInput().compare("device1") == 0);
- audio->setActiveInput("device2");
- QTestEventLoop::instance().enterLoop(1);
- QVERIFY(audio->activeInput().compare("device2") == 0);
- QVERIFY(readSignal.count() == 1);
- QVERIFY(audio->inputDescription("device2").compare("dev2 comment") == 0);
-}
-
-void tst_QMediaRecorder::testAudioEncodeControl()
-{
- QStringList codecs = capture->supportedAudioCodecs();
- QVERIFY(codecs.count() == 2);
- QVERIFY(capture->audioCodecDescription("audio/pcm") == "Pulse Code Modulation");
- QList<int> rates;
- rates << 8000 << 11025 << 22050 << 44100;
- QCOMPARE(capture->supportedAudioSampleRates(), rates);
-}
-
-void tst_QMediaRecorder::testMediaFormatsControl()
-{
- QCOMPARE(capture->supportedContainers(), QStringList() << "wav" << "mp3" << "mov");
-
- QCOMPARE(capture->containerDescription("wav"), QString("WAV format"));
- QCOMPARE(capture->containerDescription("mp3"), QString("MP3 format"));
- QCOMPARE(capture->containerDescription("ogg"), QString());
-}
-
-void tst_QMediaRecorder::testVideoEncodeControl()
-{
- bool continuous = false;
- QList<QSize> sizes = capture->supportedResolutions(QVideoEncoderSettings(), &continuous);
- QCOMPARE(sizes.count(), 2);
- QCOMPARE(continuous, true);
-
- QList<qreal> rates = capture->supportedFrameRates(QVideoEncoderSettings(), &continuous);
- QCOMPARE(rates.count(), 3);
- QCOMPARE(continuous, false);
-
- QStringList vCodecs = capture->supportedVideoCodecs();
- QVERIFY(vCodecs.count() == 2);
- QCOMPARE(capture->videoCodecDescription("video/3gpp"), QString("video/3gpp"));
-}
-
-void tst_QMediaRecorder::testEncodingSettings()
-{
- QAudioEncoderSettings audioSettings = capture->audioSettings();
- QCOMPARE(audioSettings.codec(), QString("audio/pcm"));
- QCOMPARE(audioSettings.bitRate(), 128*1024);
- QCOMPARE(audioSettings.sampleRate(), 8000);
- QCOMPARE(audioSettings.quality(), QMultimedia::NormalQuality);
- QCOMPARE(audioSettings.channelCount(), -1);
-
- QCOMPARE(audioSettings.encodingMode(), QMultimedia::ConstantQualityEncoding);
-
- QVideoEncoderSettings videoSettings = capture->videoSettings();
- QCOMPARE(videoSettings.codec(), QString());
- QCOMPARE(videoSettings.bitRate(), -1);
- QCOMPARE(videoSettings.resolution(), QSize());
- QCOMPARE(videoSettings.frameRate(), 0.0);
- QCOMPARE(videoSettings.quality(), QMultimedia::NormalQuality);
- QCOMPARE(videoSettings.encodingMode(), QMultimedia::ConstantQualityEncoding);
-
- QString format = capture->containerFormat();
- QCOMPARE(format, QString());
-
- audioSettings.setCodec("audio/mpeg");
- audioSettings.setSampleRate(44100);
- audioSettings.setBitRate(256*1024);
- audioSettings.setQuality(QMultimedia::HighQuality);
- audioSettings.setEncodingMode(QMultimedia::AverageBitRateEncoding);
-
- videoSettings.setCodec("video/3gpp");
- videoSettings.setBitRate(800);
- videoSettings.setFrameRate(24*1024);
- videoSettings.setResolution(QSize(800,600));
- videoSettings.setQuality(QMultimedia::HighQuality);
- audioSettings.setEncodingMode(QMultimedia::TwoPassEncoding);
-
- format = QString("mov");
-
- capture->setAudioSettings(audioSettings);
- capture->setVideoSettings(videoSettings);
- capture->setContainerFormat(format);
-
- QCOMPARE(capture->audioSettings(), audioSettings);
- QCOMPARE(capture->videoSettings(), videoSettings);
- QCOMPARE(capture->containerFormat(), format);
-}
-
-void tst_QMediaRecorder::testAudioSettings()
-{
- QAudioEncoderSettings settings;
- QVERIFY(settings.isNull());
- QVERIFY(settings == QAudioEncoderSettings());
-
- QCOMPARE(settings.codec(), QString());
- settings.setCodec(QLatin1String("codecName"));
- QCOMPARE(settings.codec(), QLatin1String("codecName"));
- QVERIFY(!settings.isNull());
- QVERIFY(settings != QAudioEncoderSettings());
-
- settings = QAudioEncoderSettings();
- QCOMPARE(settings.bitRate(), -1);
- settings.setBitRate(128000);
- QCOMPARE(settings.bitRate(), 128000);
- QVERIFY(!settings.isNull());
-
- settings = QAudioEncoderSettings();
- QCOMPARE(settings.quality(), QMultimedia::NormalQuality);
- settings.setQuality(QMultimedia::HighQuality);
- QCOMPARE(settings.quality(), QMultimedia::HighQuality);
- QVERIFY(!settings.isNull());
-
- settings = QAudioEncoderSettings();
- QCOMPARE(settings.sampleRate(), -1);
- settings.setSampleRate(44100);
- QCOMPARE(settings.sampleRate(), 44100);
- QVERIFY(!settings.isNull());
-
- settings = QAudioEncoderSettings();
- QCOMPARE(settings.channelCount(), -1);
- settings.setChannelCount(2);
- QCOMPARE(settings.channelCount(), 2);
- QVERIFY(!settings.isNull());
-
- settings = QAudioEncoderSettings();
- settings.setEncodingOption(QLatin1String("encoderOption"), QVariant(1));
- QCOMPARE(settings.encodingOption(QLatin1String("encoderOption")), QVariant(1));
- QVariantMap options;
- options.insert(QLatin1String("encoderOption"), QVariant(1));
- QCOMPARE(settings.encodingOptions(), options);
- options.insert(QLatin1String("encoderOption2"), QVariant(2));
- options.remove(QLatin1String("encoderOption"));
- settings.setEncodingOptions(options);
- QCOMPARE(settings.encodingOption(QLatin1String("encoderOption")), QVariant());
- QCOMPARE(settings.encodingOption(QLatin1String("encoderOption2")), QVariant(2));
- QVERIFY(!settings.isNull());
- QVERIFY(settings != QAudioEncoderSettings());
-
- settings = QAudioEncoderSettings();
- QVERIFY(settings.isNull());
- QCOMPARE(settings.codec(), QString());
- QCOMPARE(settings.bitRate(), -1);
- QCOMPARE(settings.quality(), QMultimedia::NormalQuality);
- QCOMPARE(settings.sampleRate(), -1);
- QVERIFY(settings.encodingOptions().isEmpty());
-
- {
- QAudioEncoderSettings settings1;
- QAudioEncoderSettings settings2;
- QCOMPARE(settings2, settings1);
-
- settings2 = settings1;
- QCOMPARE(settings2, settings1);
- QVERIFY(settings2.isNull());
-
- settings1.setQuality(QMultimedia::HighQuality);
-
- QVERIFY(settings2.isNull());
- QVERIFY(!settings1.isNull());
- QVERIFY(settings1 != settings2);
- }
-
- {
- QAudioEncoderSettings settings1;
- QAudioEncoderSettings settings2(settings1);
- QCOMPARE(settings2, settings1);
-
- settings2 = settings1;
- QCOMPARE(settings2, settings1);
- QVERIFY(settings2.isNull());
-
- settings1.setQuality(QMultimedia::HighQuality);
-
- QVERIFY(settings2.isNull());
- QVERIFY(!settings1.isNull());
- QVERIFY(settings1 != settings2);
- }
-
- QAudioEncoderSettings settings1;
- settings1.setBitRate(1);
- QAudioEncoderSettings settings2;
- settings2.setBitRate(1);
- QVERIFY(settings1 == settings2);
- settings2.setBitRate(2);
- QVERIFY(settings1 != settings2);
-
- settings1 = QAudioEncoderSettings();
- settings1.setChannelCount(1);
- settings2 = QAudioEncoderSettings();
- settings2.setChannelCount(1);
- QVERIFY(settings1 == settings2);
- settings2.setChannelCount(2);
- QVERIFY(settings1 != settings2);
-
- settings1 = QAudioEncoderSettings();
- settings1.setCodec("codec1");
- settings2 = QAudioEncoderSettings();
- settings2.setCodec("codec1");
- QVERIFY(settings1 == settings2);
- settings2.setCodec("codec2");
- QVERIFY(settings1 != settings2);
-
- settings1 = QAudioEncoderSettings();
- settings1.setEncodingMode(QMultimedia::ConstantBitRateEncoding);
- settings2 = QAudioEncoderSettings();
- settings2.setEncodingMode(QMultimedia::ConstantBitRateEncoding);
- QVERIFY(settings1 == settings2);
- settings2.setEncodingMode(QMultimedia::TwoPassEncoding);
- QVERIFY(settings1 != settings2);
-
- settings1 = QAudioEncoderSettings();
- settings1.setQuality(QMultimedia::NormalQuality);
- settings2 = QAudioEncoderSettings();
- settings2.setQuality(QMultimedia::NormalQuality);
- QVERIFY(settings1 == settings2);
- settings2.setQuality(QMultimedia::LowQuality);
- QVERIFY(settings1 != settings2);
-
- settings1 = QAudioEncoderSettings();
- settings1.setSampleRate(1);
- settings2 = QAudioEncoderSettings();
- settings2.setSampleRate(1);
- QVERIFY(settings1 == settings2);
- settings2.setSampleRate(2);
- QVERIFY(settings1 != settings2);
-
- settings1 = QAudioEncoderSettings();
- settings1.setEncodingOption(QLatin1String("encoderOption"), QVariant(1));
- settings2 = QAudioEncoderSettings();
- settings2.setEncodingOption(QLatin1String("encoderOption"), QVariant(1));
- QVERIFY(settings1 == settings2);
- settings2.setEncodingOption(QLatin1String("encoderOption"), QVariant(2));
- QVERIFY(settings1 != settings2);
-}
-
-void tst_QMediaRecorder::testVideoSettings()
-{
- QVideoEncoderSettings settings;
- QVERIFY(settings.isNull());
- QVERIFY(settings == QVideoEncoderSettings());
-
- QCOMPARE(settings.codec(), QString());
- settings.setCodec(QLatin1String("codecName"));
- QCOMPARE(settings.codec(), QLatin1String("codecName"));
- QVERIFY(!settings.isNull());
- QVERIFY(settings != QVideoEncoderSettings());
-
- settings = QVideoEncoderSettings();
- QCOMPARE(settings.bitRate(), -1);
- settings.setBitRate(128000);
- QCOMPARE(settings.bitRate(), 128000);
- QVERIFY(!settings.isNull());
-
- settings = QVideoEncoderSettings();
- QCOMPARE(settings.quality(), QMultimedia::NormalQuality);
- settings.setQuality(QMultimedia::HighQuality);
- QCOMPARE(settings.quality(), QMultimedia::HighQuality);
- QVERIFY(!settings.isNull());
-
- settings = QVideoEncoderSettings();
- QCOMPARE(settings.frameRate(), qreal());
- settings.setFrameRate(30000.0/10001);
- QVERIFY(qFuzzyCompare(settings.frameRate(), qreal(30000.0/10001)));
- settings.setFrameRate(24.0);
- QVERIFY(qFuzzyCompare(settings.frameRate(), qreal(24.0)));
- QVERIFY(!settings.isNull());
-
- settings = QVideoEncoderSettings();
- QCOMPARE(settings.resolution(), QSize());
- settings.setResolution(QSize(320,240));
- QCOMPARE(settings.resolution(), QSize(320,240));
- settings.setResolution(800,600);
- QCOMPARE(settings.resolution(), QSize(800,600));
- QVERIFY(!settings.isNull());
-
- settings = QVideoEncoderSettings();
- settings.setEncodingOption(QLatin1String("encoderOption"), QVariant(1));
- QCOMPARE(settings.encodingOption(QLatin1String("encoderOption")), QVariant(1));
- QVariantMap options;
- options.insert(QLatin1String("encoderOption"), QVariant(1));
- QCOMPARE(settings.encodingOptions(), options);
- options.insert(QLatin1String("encoderOption2"), QVariant(2));
- options.remove(QLatin1String("encoderOption"));
- settings.setEncodingOptions(options);
- QCOMPARE(settings.encodingOption(QLatin1String("encoderOption")), QVariant());
- QCOMPARE(settings.encodingOption(QLatin1String("encoderOption2")), QVariant(2));
- QVERIFY(!settings.isNull());
- QVERIFY(settings != QVideoEncoderSettings());
-
- settings = QVideoEncoderSettings();
- QVERIFY(settings.isNull());
- QCOMPARE(settings.codec(), QString());
- QCOMPARE(settings.bitRate(), -1);
- QCOMPARE(settings.quality(), QMultimedia::NormalQuality);
- QCOMPARE(settings.frameRate(), qreal());
- QCOMPARE(settings.resolution(), QSize());
- QVERIFY(settings.encodingOptions().isEmpty());
-
- {
- QVideoEncoderSettings settings1;
- QVideoEncoderSettings settings2;
- QCOMPARE(settings2, settings1);
-
- settings2 = settings1;
- QCOMPARE(settings2, settings1);
- QVERIFY(settings2.isNull());
-
- settings1.setQuality(QMultimedia::HighQuality);
-
- QVERIFY(settings2.isNull());
- QVERIFY(!settings1.isNull());
- QVERIFY(settings1 != settings2);
- }
-
- {
- QVideoEncoderSettings settings1;
- QVideoEncoderSettings settings2(settings1);
- QCOMPARE(settings2, settings1);
-
- settings2 = settings1;
- QCOMPARE(settings2, settings1);
- QVERIFY(settings2.isNull());
-
- settings1.setQuality(QMultimedia::HighQuality);
-
- QVERIFY(settings2.isNull());
- QVERIFY(!settings1.isNull());
- QVERIFY(settings1 != settings2);
- }
-
- QVideoEncoderSettings settings1;
- settings1.setBitRate(1);
- QVideoEncoderSettings settings2;
- settings2.setBitRate(1);
- QVERIFY(settings1 == settings2);
- settings2.setBitRate(2);
- QVERIFY(settings1 != settings2);
-
- settings1 = QVideoEncoderSettings();
- settings1.setResolution(800,600);
- settings2 = QVideoEncoderSettings();
- settings2.setResolution(QSize(800,600));
- QVERIFY(settings1 == settings2);
- settings2.setResolution(QSize(400,300));
- QVERIFY(settings1 != settings2);
-
- settings1 = QVideoEncoderSettings();
- settings1.setCodec("codec1");
- settings2 = QVideoEncoderSettings();
- settings2.setCodec("codec1");
- QVERIFY(settings1 == settings2);
- settings2.setCodec("codec2");
- QVERIFY(settings1 != settings2);
-
- settings1 = QVideoEncoderSettings();
- settings1.setEncodingMode(QMultimedia::ConstantBitRateEncoding);
- settings2 = QVideoEncoderSettings();
- settings2.setEncodingMode(QMultimedia::ConstantBitRateEncoding);
- QVERIFY(settings1 == settings2);
- settings2.setEncodingMode(QMultimedia::TwoPassEncoding);
- QVERIFY(settings1 != settings2);
-
- settings1 = QVideoEncoderSettings();
- settings1.setQuality(QMultimedia::NormalQuality);
- settings2 = QVideoEncoderSettings();
- settings2.setQuality(QMultimedia::NormalQuality);
- QVERIFY(settings1 == settings2);
- settings2.setQuality(QMultimedia::LowQuality);
- QVERIFY(settings1 != settings2);
-
- settings1 = QVideoEncoderSettings();
- settings1.setFrameRate(1);
- settings2 = QVideoEncoderSettings();
- settings2.setFrameRate(1);
- QVERIFY(settings1 == settings2);
- settings2.setFrameRate(2);
- QVERIFY(settings1 != settings2);
-
- settings1 = QVideoEncoderSettings();
- settings1.setEncodingOption(QLatin1String("encoderOption"), QVariant(1));
- settings2 = QVideoEncoderSettings();
- settings2.setEncodingOption(QLatin1String("encoderOption"), QVariant(1));
- QVERIFY(settings1 == settings2);
- settings2.setEncodingOption(QLatin1String("encoderOption"), QVariant(2));
- QVERIFY(settings1 != settings2);
-}
-
-void tst_QMediaRecorder::testSettingsApplied()
-{
- MockMediaRecorderControl recorderControl(0);
- MockMediaRecorderService service(0, &recorderControl);
- MockMediaObject object(0, &service);
-
- //if the media recorder is not configured after construction
- //the settings are applied in the next event loop
- QMediaRecorder recorder(&object);
- QCOMPARE(recorderControl.m_settingAppliedCount, 0);
- QTRY_COMPARE(recorderControl.m_settingAppliedCount, 1);
-
- QVideoEncoderSettings videoSettings;
- videoSettings.setResolution(640,480);
- recorder.setVideoSettings(videoSettings);
-
- QAudioEncoderSettings audioSettings;
- audioSettings.setQuality(QMultimedia::HighQuality);
- recorder.setAudioSettings(audioSettings);
-
- recorder.setContainerFormat("mkv");
-
- QCOMPARE(recorderControl.m_settingAppliedCount, 1);
- QTRY_COMPARE(recorderControl.m_settingAppliedCount, 2);
-
- //encoder settings are applied before recording if changed
- audioSettings.setQuality(QMultimedia::VeryHighQuality);
- recorder.setAudioSettings(audioSettings);
-
- QCOMPARE(recorderControl.m_settingAppliedCount, 2);
- recorder.record();
- QCOMPARE(recorderControl.m_settingAppliedCount, 3);
-
- recorder.stop();
-
- //applySettings is not called if setting has not changes
- recorder.record();
- QCOMPARE(recorderControl.m_settingAppliedCount, 3);
-}
-
-void tst_QMediaRecorder::nullMetaDataControl()
-{
- const QString titleKey(QLatin1String("Title"));
- const QString title(QLatin1String("Host of Seraphim"));
-
- MockMediaRecorderControl recorderControl(0);
- MockMediaRecorderService service(0, &recorderControl);
- service.hasControls = false;
- MockMediaObject object(0, &service);
-
- QMediaRecorder recorder(&object);
-
- QSignalSpy spy(&recorder, SIGNAL(metaDataChanged()));
-
- QCOMPARE(recorder.isMetaDataAvailable(), false);
- QCOMPARE(recorder.isMetaDataWritable(), false);
-
- recorder.setMetaData(QMediaMetaData::Title, title);
-
- QCOMPARE(recorder.metaData(QMediaMetaData::Title).toString(), QString());
- QCOMPARE(recorder.availableMetaData(), QStringList());
- QCOMPARE(spy.count(), 0);
-}
-
-void tst_QMediaRecorder::isMetaDataAvailable()
-{
- MockMediaRecorderControl recorderControl(0);
- MockMediaRecorderService service(0, &recorderControl);
- service.mockMetaDataControl->setMetaDataAvailable(false);
- MockMediaObject object(0, &service);
-
- QMediaRecorder recorder(&object);
- QCOMPARE(recorder.isMetaDataAvailable(), false);
-
- QSignalSpy spy(&recorder, SIGNAL(metaDataAvailableChanged(bool)));
- service.mockMetaDataControl->setMetaDataAvailable(true);
-
- QCOMPARE(recorder.isMetaDataAvailable(), true);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.at(0).at(0).toBool(), true);
-
- service.mockMetaDataControl->setMetaDataAvailable(false);
-
- QCOMPARE(recorder.isMetaDataAvailable(), false);
- QCOMPARE(spy.count(), 2);
- QCOMPARE(spy.at(1).at(0).toBool(), false);
-}
-
-void tst_QMediaRecorder::isWritable()
-{
- MockMediaRecorderControl recorderControl(0);
- MockMediaRecorderService service(0, &recorderControl);
- service.mockMetaDataControl->setWritable(false);
-
- MockMediaObject object(0, &service);
-
- QMediaRecorder recorder(&object);
-
- QSignalSpy spy(&recorder, SIGNAL(metaDataWritableChanged(bool)));
-
- QCOMPARE(recorder.isMetaDataWritable(), false);
-
- service.mockMetaDataControl->setWritable(true);
-
- QCOMPARE(recorder.isMetaDataWritable(), true);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.at(0).at(0).toBool(), true);
-
- service.mockMetaDataControl->setWritable(false);
-
- QCOMPARE(recorder.isMetaDataWritable(), false);
- QCOMPARE(spy.count(), 2);
- QCOMPARE(spy.at(1).at(0).toBool(), false);
-}
-
-void tst_QMediaRecorder::metaDataChanged()
-{
- MockMediaRecorderControl recorderControl(0);
- MockMediaRecorderService service(0, &recorderControl);
- MockMediaObject object(0, &service);
-
- QMediaRecorder recorder(&object);
-
- QSignalSpy changedSpy(&recorder, SIGNAL(metaDataChanged()));
- QSignalSpy changedWithValueSpy(&recorder, SIGNAL(metaDataChanged(QString,QVariant)));
-
- service.mockMetaDataControl->setMetaData("key", "Value");
- QCOMPARE(changedSpy.count(), 1);
- QCOMPARE(changedWithValueSpy.count(), 1);
- QCOMPARE(changedWithValueSpy.last()[0], QVariant("key"));
- QCOMPARE(changedWithValueSpy.last()[1].value<QVariant>(), QVariant("Value"));
-
- service.mockMetaDataControl->setMetaData("key", "Value");
- QCOMPARE(changedSpy.count(), 1);
- QCOMPARE(changedWithValueSpy.count(), 1);
-
- service.mockMetaDataControl->setMetaData("key2", "Value");
- QCOMPARE(changedSpy.count(), 2);
- QCOMPARE(changedWithValueSpy.count(), 2);
- QCOMPARE(changedWithValueSpy.last()[0], QVariant("key2"));
- QCOMPARE(changedWithValueSpy.last()[1].value<QVariant>(), QVariant("Value"));
-}
-
-void tst_QMediaRecorder::metaData_data()
-{
- QTest::addColumn<QString>("artist");
- QTest::addColumn<QString>("title");
- QTest::addColumn<QString>("genre");
- QTest::addColumn<QString>("custom");
-
- QTest::newRow("")
- << QString::fromLatin1("Dead Can Dance")
- << QString::fromLatin1("Host of Seraphim")
- << QString::fromLatin1("Awesome")
- << QString::fromLatin1("Something else");
-}
-
-void tst_QMediaRecorder::metaData()
-{
- QFETCH(QString, artist);
- QFETCH(QString, title);
- QFETCH(QString, genre);
- QFETCH(QString, custom);
-
- MockMediaRecorderControl recorderControl(0);
- MockMediaRecorderService service(0, &recorderControl);
- service.mockMetaDataControl->populateMetaData();
-
- MockMediaObject object(0, &service);
-
- QMediaRecorder recorder(&object);
- QVERIFY(object.availableMetaData().isEmpty());
-
- service.mockMetaDataControl->m_data.insert(QMediaMetaData::AlbumArtist, artist);
- service.mockMetaDataControl->m_data.insert(QMediaMetaData::Title, title);
- service.mockMetaDataControl->m_data.insert(QMediaMetaData::Genre, genre);
- service.mockMetaDataControl->m_data.insert(QLatin1String("CustomEntry"), custom );
-
- QCOMPARE(recorder.metaData(QMediaMetaData::AlbumArtist).toString(), artist);
- QCOMPARE(recorder.metaData(QMediaMetaData::Title).toString(), title);
-
- QStringList metaDataKeys = recorder.availableMetaData();
- QCOMPARE(metaDataKeys.size(), 4);
- QVERIFY(metaDataKeys.contains(QMediaMetaData::AlbumArtist));
- QVERIFY(metaDataKeys.contains(QMediaMetaData::Title));
- QVERIFY(metaDataKeys.contains(QMediaMetaData::Genre));
- QVERIFY(metaDataKeys.contains(QLatin1String("CustomEntry")));
-}
-
-void tst_QMediaRecorder::setMetaData_data()
-{
- QTest::addColumn<QString>("title");
-
- QTest::newRow("")
- << QString::fromLatin1("In the Kingdom of the Blind the One eyed are Kings");
-}
-
-void tst_QMediaRecorder::setMetaData()
-{
- QFETCH(QString, title);
-
- MockMediaRecorderControl recorderControl(0);
- MockMediaRecorderService service(0, &recorderControl);
- service.mockMetaDataControl->populateMetaData();
-
- MockMediaObject object(0, &service);
-
- QMediaRecorder recorder(&object);
-
- recorder.setMetaData(QMediaMetaData::Title, title);
- QCOMPARE(recorder.metaData(QMediaMetaData::Title).toString(), title);
- QCOMPARE(service.mockMetaDataControl->m_data.value(QMediaMetaData::Title).toString(), title);
-}
-
-void tst_QMediaRecorder::testAudioSettingsCopyConstructor()
-{
- /* create an object for AudioEncodersettings */
- QAudioEncoderSettings audiosettings;
- QVERIFY(audiosettings.isNull());
-
- /* setting the desired properties for the AudioEncoder */
- audiosettings.setBitRate(128*1000);
- audiosettings.setChannelCount(4);
- audiosettings.setCodec("audio/pcm");
- audiosettings.setEncodingMode(QMultimedia::ConstantBitRateEncoding);
- audiosettings.setQuality(QMultimedia::LowQuality);
- audiosettings.setSampleRate(44100);
-
- /* Copy constructor */
- QAudioEncoderSettings other(audiosettings);
- QVERIFY(!(other.isNull()));
-
- /* Verifying whether data is copied properly or not */
- QVERIFY(other.bitRate() == audiosettings.bitRate());
- QVERIFY(other.sampleRate() == audiosettings.sampleRate());
- QVERIFY(other.channelCount() == audiosettings.channelCount());
- QCOMPARE(other.codec(), audiosettings.codec());
- QVERIFY(other.encodingMode() == audiosettings.encodingMode());
- QVERIFY(other.quality() == audiosettings.quality());
-}
-
-void tst_QMediaRecorder::testAudioSettingsOperatorNotEqual()
-{
- /* create an object for AudioEncodersettings */
- QAudioEncoderSettings audiosettings1;
- QVERIFY(audiosettings1.isNull());
-
- QAudioEncoderSettings audiosettings2;
- QVERIFY(audiosettings2.isNull());
-
- /* setting the desired properties to for the AudioEncoder */
- audiosettings1.setBitRate(128*1000);
- audiosettings1.setChannelCount(4);
- audiosettings1.setCodec("audio/pcm");
- audiosettings1.setEncodingMode(QMultimedia::ConstantBitRateEncoding);
- audiosettings1.setQuality(QMultimedia::LowQuality);
- audiosettings1.setSampleRate(44100);
-
- /* setting the desired properties for the AudioEncoder */
- audiosettings2.setBitRate(128*1000);
- audiosettings2.setChannelCount(4);
- audiosettings2.setCodec("audio/pcm");
- audiosettings2.setEncodingMode(QMultimedia::ConstantBitRateEncoding);
- audiosettings2.setQuality(QMultimedia::LowQuality);
- audiosettings2.setSampleRate(44100);
-
- /* verify the both are equal or not */
- QVERIFY(!(audiosettings1 != audiosettings2));
-
- /* Modify the settings value for one object */
- audiosettings2.setBitRate(64*1000);
- audiosettings2.setEncodingMode(QMultimedia::ConstantQualityEncoding);
-
- /* verify the not equal opertor */
- QVERIFY(audiosettings1 != audiosettings2);
-
- QVERIFY(audiosettings2.bitRate() != audiosettings1.bitRate());
- QVERIFY(audiosettings2.encodingMode() != audiosettings1.encodingMode());
-}
-
-void tst_QMediaRecorder::testAudioSettingsOperatorEqual()
-{
- /* create an object for AudioEncodersettings */
- QAudioEncoderSettings audiosettings1;
- QVERIFY(audiosettings1.isNull());
-
- /* setting the desired properties to for the AudioEncoder */
- audiosettings1.setBitRate(128*1000);
- audiosettings1.setChannelCount(4);
- audiosettings1.setCodec("audio/pcm");
- audiosettings1.setEncodingMode(QMultimedia::ConstantBitRateEncoding);
- audiosettings1.setQuality(QMultimedia::LowQuality);
- audiosettings1.setSampleRate(44100);
-
- QAudioEncoderSettings audiosettings2;
- QVERIFY(audiosettings2.isNull());
-
- /* setting the desired properties for the AudioEncoder */
- audiosettings2.setBitRate(128*1000);
- audiosettings2.setChannelCount(4);
- audiosettings2.setCodec("audio/pcm");
- audiosettings2.setEncodingMode(QMultimedia::ConstantBitRateEncoding);
- audiosettings2.setQuality(QMultimedia::LowQuality);
- audiosettings2.setSampleRate(44100);
-
- /* verify both the values are same or not */
- QVERIFY(audiosettings1 == audiosettings2);
- audiosettings2.setChannelCount(2);
- QVERIFY(audiosettings1 != audiosettings2);
-}
-
-void tst_QMediaRecorder::testAudioSettingsOperatorAssign()
-{
-
- /* create an object for AudioEncodersettings */
- QAudioEncoderSettings audiosettings1;
- QVERIFY(audiosettings1.isNull());
-
- /* setting the desired properties for the AudioEncoder */
- audiosettings1.setBitRate(128*1000);
- audiosettings1.setChannelCount(4);
- audiosettings1.setCodec("audio/pcm");
- audiosettings1.setEncodingMode(QMultimedia::ConstantBitRateEncoding);
- audiosettings1.setQuality(QMultimedia::LowQuality);
- audiosettings1.setSampleRate(44100);
-
- QAudioEncoderSettings audiosettings2;
- audiosettings2 = audiosettings1;
- /* Verifying whether data is copied properly or not */
- QVERIFY(audiosettings2.bitRate() == audiosettings1.bitRate());
- QVERIFY(audiosettings2.sampleRate() == audiosettings1.sampleRate());
- QVERIFY(audiosettings2.channelCount() == audiosettings1.channelCount());
- QCOMPARE(audiosettings2.codec(), audiosettings1.codec());
- QVERIFY(audiosettings2.encodingMode() == audiosettings1.encodingMode());
- QVERIFY(audiosettings2.quality() == audiosettings1.quality());
-}
-
-void tst_QMediaRecorder::testAudioSettingsDestructor()
-{
- /* Creating null object for the audioencodersettings */
- QAudioEncoderSettings * audiosettings = new QAudioEncoderSettings;
-
- /* Verifying the object is null or not */
- QVERIFY(audiosettings->isNull());
- /* delete the allocated memory */
- delete audiosettings;
-}
-
-/* availability() API test. */
-void tst_QMediaRecorder::testAvailabilityStatus()
-{
- {
- MockMediaRecorderService service(0, 0);
- MockMediaObject object(0, &service);
- QMediaRecorder recorder(&object);
- QCOMPARE(recorder.availability(), QMultimedia::ServiceMissing);
- QCOMPARE(recorder.isAvailable(), false);
- }
- {
- MockMediaRecorderControl recorderControl(0);
- MockMediaRecorderService service1(0, &recorderControl);
- service1.mockMetaDataControl->populateMetaData();
- MockMediaObject object1(0, &service1);
- QMediaRecorder recorder1(&object1);
- QCOMPARE(recorder1.availability(), QMultimedia::Available);
- QCOMPARE(recorder1.isAvailable(), true);
- }
- {
- MockMediaRecorderControl recorderControl(0);
- MockMediaRecorderService service1(0, &recorderControl, 0);
- service1.mockMetaDataControl->populateMetaData();
- MockMediaObject object1(0, &service1);
- QMediaRecorder recorder1(&object1);
-
- QCOMPARE(recorder1.availability(), QMultimedia::Available);
- QCOMPARE(recorder1.isAvailable(), true);
- }
- {
- MockMediaRecorderControl recorderControl(0);
- MockAvailabilityControl availability(QMultimedia::Available);
- MockMediaRecorderService service1(0, &recorderControl, &availability);
- service1.mockMetaDataControl->populateMetaData();
- MockMediaObject object1(0, &service1);
- QMediaRecorder recorder1(&object1);
-
- QSignalSpy spy(&object1, SIGNAL(availabilityChanged(QMultimedia::AvailabilityStatus)));
-
- QCOMPARE(recorder1.availability(), QMultimedia::Available);
- QCOMPARE(recorder1.isAvailable(), true);
-
- availability.setAvailability(QMultimedia::Busy);
- QCOMPARE(recorder1.availability(), QMultimedia::Busy);
- QCOMPARE(recorder1.isAvailable(), false);
- QCOMPARE(spy.count(), 1);
-
- availability.setAvailability(QMultimedia::Available);
- QCOMPARE(recorder1.availability(), QMultimedia::Available);
- QCOMPARE(recorder1.isAvailable(), true);
- QCOMPARE(spy.count(), 2);
- }
-}
-
-/* isAvailable() API test. */
-void tst_QMediaRecorder::testIsAvailable()
-{
- MockMediaRecorderService service(0, 0);
- MockMediaObject object(0, &service);
- QMediaRecorder recorder(&object);
- QCOMPARE(recorder.isAvailable(), false);
-
- MockMediaRecorderControl recorderControl(0);
- MockMediaRecorderService service1(0, &recorderControl);
- service1.mockMetaDataControl->populateMetaData();
- MockMediaObject object1(0, &service1);
- QMediaRecorder recorder1(&object1);
- QCOMPARE(recorder1.isAvailable(), true);
-}
-
-/* mediaObject() API test. */
-void tst_QMediaRecorder::testMediaObject()
-{
- MockMediaRecorderService service(0, 0);
- service.hasControls = false;
- MockMediaObject object(0, &service);
- QMediaRecorder recorder(&object);
-
- QMediaObject *medobj = recorder.mediaObject();
- QVERIFY(medobj == NULL);
-
- QMediaObject *medobj1 = capture->mediaObject();
- QVERIFY(medobj1 != NULL);
-}
-
-/* enum QMediaRecorder::ResourceError property test. */
-void tst_QMediaRecorder::testEnum()
-{
- const QString errorString(QLatin1String("resource error"));
-
- QSignalSpy spy(capture, SIGNAL(error(QMediaRecorder::Error)));
-
- QCOMPARE(capture->error(), QMediaRecorder::NoError);
- QCOMPARE(capture->errorString(), QString());
-
- mock->error(QMediaRecorder::ResourceError, errorString);
- QCOMPARE(capture->error(), QMediaRecorder::ResourceError);
- QCOMPARE(capture->errorString(), errorString);
- QCOMPARE(spy.count(), 1);
-
- QCOMPARE(spy.last()[0].value<QMediaRecorder::Error>(), QMediaRecorder::ResourceError);
-}
-
-/* Test the QVideoEncoderSettings quality API*/
-void tst_QMediaRecorder::testVideoSettingsQuality()
-{
- /* Create the instance*/
- QVideoEncoderSettings settings;
- QVERIFY(settings.isNull());
- QVERIFY(settings == QVideoEncoderSettings());
-
- /* Verify the default value is intialised correctly*/
- QCOMPARE(settings.quality(), QMultimedia::NormalQuality);
-
- /* Set all types of Quality parameter and Verify if it is set correctly*/
- settings.setQuality(QMultimedia::HighQuality);
- QCOMPARE(settings.quality(), QMultimedia::HighQuality);
- QVERIFY(!settings.isNull());
-
- settings.setQuality(QMultimedia::VeryLowQuality);
- QCOMPARE(settings.quality(), QMultimedia::VeryLowQuality);
-
- settings.setQuality(QMultimedia::LowQuality);
- QCOMPARE(settings.quality(), QMultimedia::LowQuality);
-
- settings.setQuality(QMultimedia::VeryHighQuality);
- QCOMPARE(settings.quality(), QMultimedia::VeryHighQuality);
-}
-
-/* Test QVideoEncoderSettings encodingMode */
-void tst_QMediaRecorder::testVideoSettingsEncodingMode()
-{
- /* Create the instance*/
- QVideoEncoderSettings settings;
- QVERIFY(settings.isNull());
- QVERIFY(settings == QVideoEncoderSettings());
-
- /* Verify the default values are initialised correctly*/
- QCOMPARE(settings.encodingMode(), QMultimedia::ConstantQualityEncoding);
- QVERIFY(settings.isNull());
-
- /* Set each type of encoding mode and Verify if it is set correctly*/
- settings.setEncodingMode(QMultimedia::ConstantBitRateEncoding);
- QCOMPARE(settings.encodingMode(),QMultimedia::ConstantBitRateEncoding);
- QVERIFY(!settings.isNull());
-
- settings.setEncodingMode(QMultimedia::AverageBitRateEncoding);
- QCOMPARE(settings.encodingMode(), QMultimedia::AverageBitRateEncoding);
-
- settings.setEncodingMode(QMultimedia::TwoPassEncoding);
- QCOMPARE(settings.encodingMode(), QMultimedia::TwoPassEncoding);
-}
-
-/* Test QVideoEncoderSettings copy constructor */
-void tst_QMediaRecorder::testVideoSettingsCopyConstructor()
-{
- /* Create the instance and initialise it*/
- QVideoEncoderSettings settings1;
- settings1.setCodec(QLatin1String("codecName"));
- settings1.setBitRate(128000);
- settings1.setQuality(QMultimedia::HighQuality);
- settings1.setEncodingMode(QMultimedia::ConstantBitRateEncoding);
- settings1.setFrameRate(30000.0/10001);
- settings1.setResolution(QSize(320,240));
-
- /* Create another instance with instance1 as argument*/
- QVideoEncoderSettings settings2(settings1);
-
- /* Verify if all the parameters are copied correctly*/
- QCOMPARE(settings2 != settings1, false);
- QCOMPARE(settings2.codec(), QLatin1String("codecName"));
- QCOMPARE(settings2.bitRate(), 128000);
- QCOMPARE(settings2.encodingMode(), QMultimedia::ConstantBitRateEncoding);
- QVERIFY(qFuzzyCompare(settings2.frameRate(), qreal(30000.0/10001)));
- QCOMPARE(settings2.resolution(), QSize(320,240));
- QCOMPARE(settings2.quality(), QMultimedia::HighQuality);
-
- /* Verify both the instances are equal*/
- QCOMPARE(settings2, settings1);
- QVERIFY(!settings2.isNull());
-}
-
-/* Test QVideoEncoderSettings Overloaded Operator assignment*/
-void tst_QMediaRecorder::testVideoSettingsOperatorAssignment()
-{
- /* Create two instances.*/
- QVideoEncoderSettings settings1;
- QVideoEncoderSettings settings2;
- QCOMPARE(settings2, settings1);
- QVERIFY(settings2.isNull());
-
- /* Initialize all the parameters */
- settings1.setCodec(QLatin1String("codecName"));
- settings1.setBitRate(128000);
- settings1.setEncodingMode(QMultimedia::ConstantBitRateEncoding);
- settings1.setFrameRate(30000.0/10001);
- settings1.setResolution(QSize(320,240));
- settings1.setQuality(QMultimedia::HighQuality);
- /* Assign one object to other*/
- settings2 = settings1;
-
- /* Verify all the parameters are copied correctly*/
- QCOMPARE(settings2, settings1);
- QCOMPARE(settings2.codec(), QLatin1String("codecName"));
- QCOMPARE(settings2.bitRate(), 128000);
- QCOMPARE(settings2.encodingMode(), QMultimedia::ConstantBitRateEncoding);
- QVERIFY(qFuzzyCompare(settings2.frameRate(), qreal(30000.0/10001)));
- QCOMPARE(settings2.resolution(), QSize(320,240));
- QCOMPARE(settings2.quality(), QMultimedia::HighQuality);
- QCOMPARE(settings2, settings1);
- QVERIFY(!settings2.isNull());
-}
-
-/* Test QVideoEncoderSettings Overloaded OperatorNotEqual*/
-void tst_QMediaRecorder::testVideoSettingsOperatorNotEqual()
-{
- /* Create the instance and set the bit rate and Verify objects with OperatorNotEqual*/
- QVideoEncoderSettings settings1;
- settings1.setBitRate(1);
- QVideoEncoderSettings settings2;
- settings2.setBitRate(1);
- /* OperatorNotEqual returns false when both objects are equal*/
- QCOMPARE(settings1 != settings2, false);
- settings2.setBitRate(2);
- /* OperatorNotEqual returns true when both objects are not equal*/
- QVERIFY(settings1 != settings2);
-
- /* Verify Resolution with not equal operator*/
- settings1 = QVideoEncoderSettings();
- settings1.setResolution(800,600);
- settings2 = QVideoEncoderSettings();
- settings2.setResolution(QSize(800,600));
- /* OperatorNotEqual returns false when both objects are equal*/
- QCOMPARE(settings1 != settings2, false);
- settings2.setResolution(QSize(400,300));
- /* OperatorNotEqual returns true when both objects are not equal*/
- QVERIFY(settings1 != settings2);
-
- /* Verify Codec with not equal operator*/
- settings1 = QVideoEncoderSettings();
- settings1.setCodec("codec1");
- settings2 = QVideoEncoderSettings();
- settings2.setCodec("codec1");
- /* OperatorNotEqual returns false when both objects are equal*/
- QCOMPARE(settings1 != settings2, false);
- settings2.setCodec("codec2");
- /* OperatorNotEqual returns true when both objects are not equal*/
- QVERIFY(settings1 != settings2);
-
- /* Verify EncodingMode with not equal operator*/
- settings1 = QVideoEncoderSettings();
- settings1.setEncodingMode(QMultimedia::ConstantBitRateEncoding);
- settings2 = QVideoEncoderSettings();
- settings2.setEncodingMode(QMultimedia::ConstantBitRateEncoding);
- /* OperatorNotEqual returns false when both objects are equal*/
- QCOMPARE(settings1 != settings2, false);
- settings2.setEncodingMode(QMultimedia::TwoPassEncoding);
- /* OperatorNotEqual returns true when both objects are not equal*/
- QVERIFY(settings1 != settings2);
-
- /* Verify Quality with not equal operator*/
- settings1 = QVideoEncoderSettings();
- settings1.setQuality(QMultimedia::NormalQuality);
- settings2 = QVideoEncoderSettings();
- settings2.setQuality(QMultimedia::NormalQuality);
- /* OperatorNotEqual returns false when both objects are equal*/
- QCOMPARE(settings1 != settings2, false);
- settings2.setQuality(QMultimedia::LowQuality);
- /* OperatorNotEqual returns true when both objects are not equal*/
- QVERIFY(settings1 != settings2);
-
- /* Verify FrameRate with not equal operator*/
- settings1 = QVideoEncoderSettings();
- settings1.setFrameRate(1);
- settings2 = QVideoEncoderSettings();
- settings2.setFrameRate(1);
- /* OperatorNotEqual returns false when both objects are equal*/
- QCOMPARE(settings1 != settings2, false);
- settings2.setFrameRate(2);
- /* OperatorNotEqual returns true when both objects are not equal*/
- QVERIFY(settings1 != settings2);
-}
-
-/* Test QVideoEncoderSettings Overloaded comparison operator*/
-void tst_QMediaRecorder::testVideoSettingsOperatorComparison()
-{
- /* Create the instance and set the bit rate and Verify objects with comparison operator*/
- QVideoEncoderSettings settings1;
- settings1.setBitRate(1);
- QVideoEncoderSettings settings2;
- settings2.setBitRate(1);
-
- /* Comparison operator returns true when both objects are equal*/
- QVERIFY(settings1 == settings2);
- settings2.setBitRate(2);
- /* Comparison operator returns false when both objects are not equal*/
- QCOMPARE(settings1 == settings2, false);
-
- /* Verify resolution with comparison operator*/
- settings1 = QVideoEncoderSettings();
- settings1.setResolution(800,600);
- settings2 = QVideoEncoderSettings();
- settings2.setResolution(QSize(800,600));
- /* Comparison operator returns true when both objects are equal*/
- QVERIFY(settings1 == settings2);
- settings2.setResolution(QSize(400,300));
- /* Comparison operator returns false when both objects are not equal*/
- QCOMPARE(settings1 == settings2, false);
-
- /* Verify Codec with comparison operator*/
- settings1 = QVideoEncoderSettings();
- settings1.setCodec("codec1");
- settings2 = QVideoEncoderSettings();
- settings2.setCodec("codec1");
- /* Comparison operator returns true when both objects are equal*/
- QVERIFY(settings1 == settings2);
- settings2.setCodec("codec2");
- /* Comparison operator returns false when both objects are not equal*/
- QCOMPARE(settings1 == settings2, false);
-
- /* Verify EncodingMode with comparison operator*/
- settings1 = QVideoEncoderSettings();
- settings1.setEncodingMode(QMultimedia::ConstantBitRateEncoding);
- settings2 = QVideoEncoderSettings();
- settings2.setEncodingMode(QMultimedia::ConstantBitRateEncoding);
- /* Comparison operator returns true when both objects are equal*/
- QVERIFY(settings1 == settings2);
- settings2.setEncodingMode(QMultimedia::TwoPassEncoding);
- /* Comparison operator returns false when both objects are not equal*/
- QCOMPARE(settings1 == settings2, false);
-
- /* Verify Quality with comparison operator*/
- settings1 = QVideoEncoderSettings();
- settings1.setQuality(QMultimedia::NormalQuality);
- settings2 = QVideoEncoderSettings();
- settings2.setQuality(QMultimedia::NormalQuality);
- /* Comparison operator returns true when both objects are equal*/
- QVERIFY(settings1 == settings2);
- settings2.setQuality(QMultimedia::LowQuality);
- /* Comparison operator returns false when both objects are not equal*/
- QCOMPARE(settings1 == settings2, false);
-
- /* Verify FrameRate with comparison operator*/
- settings1 = QVideoEncoderSettings();
- settings1.setFrameRate(1);
- settings2 = QVideoEncoderSettings();
- settings2.setFrameRate(1);
- /* Comparison operator returns true when both objects are equal*/
- QVERIFY(settings1 == settings2);
- settings2.setFrameRate(2);
- /* Comparison operator returns false when both objects are not equal*/
- QCOMPARE(settings1 == settings2, false);
-}
-
-/* Test the destuctor of the QVideoEncoderSettings*/
-void tst_QMediaRecorder::testVideoSettingsDestructor()
-{
- /* Create the instance on heap and verify if object deleted correctly*/
- QVideoEncoderSettings *settings1 = new QVideoEncoderSettings();
- QVERIFY(settings1 != NULL);
- QVERIFY(settings1->isNull());
- delete settings1;
-
- /* Create the instance on heap and initialise it and verify if object deleted correctly.*/
- QVideoEncoderSettings *settings2 = new QVideoEncoderSettings();
- QVERIFY(settings2 != NULL);
- settings2->setCodec(QString("codec"));
- QVERIFY(!settings2->isNull());
- delete settings2;
-}
-
-QTEST_GUILESS_MAIN(tst_QMediaRecorder)
-#include "tst_qmediarecorder.moc"
diff --git a/tests/auto/unit/qmediaservice/qmediaservice.pro b/tests/auto/unit/qmediaservice/qmediaservice.pro
deleted file mode 100644
index b95554807..000000000
--- a/tests/auto/unit/qmediaservice/qmediaservice.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qmediaservice
-
-QT += multimedia-private testlib
-
-SOURCES += tst_qmediaservice.cpp
diff --git a/tests/auto/unit/qmediaservice/tst_qmediaservice.cpp b/tests/auto/unit/qmediaservice/tst_qmediaservice.cpp
deleted file mode 100644
index fcc3933f3..000000000
--- a/tests/auto/unit/qmediaservice/tst_qmediaservice.cpp
+++ /dev/null
@@ -1,267 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//TESTED_COMPONENT=src/multimedia
-
-#include <QtTest/QtTest>
-
-#include <qvideodeviceselectorcontrol.h>
-#include <qmediacontrol.h>
-#include <qmediaservice.h>
-
-#include <QtCore/qcoreapplication.h>
-
-QT_BEGIN_NAMESPACE
-
-class QtTestMediaService;
-
-class QtTestMediaControlA : public QMediaControl
-{
- Q_OBJECT
-};
-
-#define QtTestMediaControlA_iid "com.nokia.QtTestMediaControlA"
-Q_MEDIA_DECLARE_CONTROL(QtTestMediaControlA, QtTestMediaControlA_iid)
-
-class QtTestMediaControlB : public QMediaControl
-{
- Q_OBJECT
-};
-
-#define QtTestMediaControlB_iid "com.nokia.QtTestMediaControlB"
-Q_MEDIA_DECLARE_CONTROL(QtTestMediaControlB, QtTestMediaControlB_iid)
-
-
-class QtTestMediaControlC : public QMediaControl
-{
- Q_OBJECT
-};
-
-#define QtTestMediaControlC_iid "com.nokia.QtTestMediaControlC"
-Q_MEDIA_DECLARE_CONTROL(QtTestMediaControlC, QtTestMediaControlA_iid) // Yes A.
-
-class QtTestMediaControlD : public QMediaControl
-{
- Q_OBJECT
-};
-
-#define QtTestMediaControlD_iid "com.nokia.QtTestMediaControlD"
-Q_MEDIA_DECLARE_CONTROL(QtTestMediaControlD, QtTestMediaControlD_iid)
-
-//unimplemented service
-#define QtTestMediaControlE_iid "com.nokia.QtTestMediaControlF"
-class QtTestMediaControlE : public QMediaControl
-{
- Q_OBJECT
-};
-
-/* implementation of child class by inheriting The QMediaService base class for media service implementations. */
-class QtTestMediaService : public QMediaService
-{
- Q_OBJECT
-public:
- int refA;
- int refB;
- int refC;
- QtTestMediaControlA controlA;
- QtTestMediaControlB controlB;
- QtTestMediaControlC controlC;
-
- //constructor
- QtTestMediaService(): QMediaService(0), refA(0), refB(0), refC(0)
- {
- }
-
- //requestControl() pure virtual function of QMediaService class.
- QMediaControl *requestControl(const char *name)
- {
- if (strcmp(name, QtTestMediaControlA_iid) == 0) {
- refA += 1;
-
- return &controlA;
- } else if (strcmp(name, QtTestMediaControlB_iid) == 0) {
- refB += 1;
-
- return &controlB;
- } else if (strcmp(name, QtTestMediaControlC_iid) == 0) {
- refA += 1;
-
- return &controlA;
- } else {
- return 0;
- }
- }
-
- //releaseControl() pure virtual function of QMediaService class.
- void releaseControl(QMediaControl *control)
- {
- if (control == &controlA)
- refA -= 1;
- else if (control == &controlB)
- refB -= 1;
- else if (control == &controlC)
- refC -= 1;
- }
-
- //requestControl() function of QMediaService class.
- using QMediaService::requestControl;
-};
-
-/* Test case implementation for QMediaService class which provides a common base class for media service implementations.*/
-class tst_QMediaService : public QObject
-{
- Q_OBJECT
-private slots:
- void tst_destructor();
- void tst_releaseControl();
- void tst_requestControl();
- void tst_requestControlTemplate();
-
- void initTestCase();
-
- void control_iid();
- void control();
-
-};
-
-/*MaemoAPI-1668 :destructor property test. */
-void tst_QMediaService::tst_destructor()
-{
- QtTestMediaService *service = new QtTestMediaService;
- delete service;
-}
-
-void tst_QMediaService::initTestCase()
-{
-}
-
-/*MaemoAPI-1669 :releaseControl() API property test. */
-void tst_QMediaService::tst_releaseControl()
-{
- //test class instance creation
- QtTestMediaService service;
-
- //Get a pointer to the media control implementing interface and verify.
- QMediaControl* controlA = service.requestControl(QtTestMediaControlA_iid);
- QCOMPARE(controlA, &service.controlA);
- service.releaseControl(controlA); //Controls must be returned to the service when no longer needed
- QVERIFY(service.refA == 0);
-
- //Get a pointer to the media control implementing interface and verify.
- QMediaControl* controlB = service.requestControl(QtTestMediaControlB_iid);
- QCOMPARE(controlB, &service.controlB);
- service.releaseControl(controlB); //Controls must be returned to the service when no longer needed
- QVERIFY(service.refB == 0);
-}
-
-/*MaemoAPI-1670 :requestControl() API property test. */
-void tst_QMediaService::tst_requestControl()
-{
- //test class instance creation
- QtTestMediaService service;
-
- //Get a pointer to the media control implementing interface and verify.
- QMediaControl* controlA = service.requestControl(QtTestMediaControlA_iid);
- QCOMPARE(controlA, &service.controlA);
- service.releaseControl(controlA); //Controls must be returned to the service when no longer needed
-
- //Get a pointer to the media control implementing interface and verify.
- QMediaControl* controlB = service.requestControl(QtTestMediaControlB_iid);
- QCOMPARE(controlB, &service.controlB);
- service.releaseControl(controlB); //Controls must be returned to the service when no longer needed
-
- //If the service does not implement the control, a null pointer is returned instead.
- QMediaControl* controlE = service.requestControl(QtTestMediaControlE_iid);
- QVERIFY(!controlE); //should return null pointer
- service.releaseControl(controlE); //Controls must be returned to the service when no longer needed
-
- //If the service is unavailable a null pointer is returned instead.
- QMediaControl* control = service.requestControl("");
- QVERIFY(!control); //should return null pointer
- service.releaseControl(control); //Controls must be returned to the service when no longer needed
-}
-
-/*MaemoAPI-1671 :requestControl() API property test. */
-void tst_QMediaService::tst_requestControlTemplate()
-{
- //test class instance creation
- QtTestMediaService service;
-
- //Get a pointer to the media control of type T implemented by a media service.
- QtTestMediaControlA *controlA = service.requestControl<QtTestMediaControlA *>();
- QCOMPARE(controlA, &service.controlA);
- service.releaseControl(controlA);
-
- //Get a pointer to the media control of type T implemented by a media service.
- QtTestMediaControlB *controlB = service.requestControl<QtTestMediaControlB *>();
- QCOMPARE(controlB, &service.controlB);
- service.releaseControl(controlB);
-
- QVERIFY(!service.requestControl<QtTestMediaControlC *>()); // Faulty implementation returns A.
- QCOMPARE(service.refA, 0); // Verify the control was released.
-
- QVERIFY(!service.requestControl<QtTestMediaControlD *>()); // No control of that type.
-}
-
-
-void tst_QMediaService::control_iid()
-{
- const char *nullString = 0;
-
- // Default implementation.
- QCOMPARE(qmediacontrol_iid<QtTestMediaControlE *>(), nullString);
-
- // Partial template.
- QVERIFY(qstrcmp(qmediacontrol_iid<QtTestMediaControlA *>(), QtTestMediaControlA_iid) == 0);
-}
-
-void tst_QMediaService::control()
-{
- QtTestMediaService service;
-
- QtTestMediaControlA *controlA = service.requestControl<QtTestMediaControlA *>();
- QCOMPARE(controlA, &service.controlA);
- service.releaseControl(controlA);
-
- QtTestMediaControlB *controlB = service.requestControl<QtTestMediaControlB *>();
- QCOMPARE(controlB, &service.controlB);
- service.releaseControl(controlB);
-
- QVERIFY(!service.requestControl<QtTestMediaControlC *>()); // Faulty implementation returns A, but is wrong class
- QCOMPARE(service.refA, 0); // Verify the control was released.
-
- QVERIFY(!service.requestControl<QtTestMediaControlD *>()); // No control of that type.
-}
-
-QT_END_NAMESPACE
-
-QT_USE_NAMESPACE
-
-QTEST_MAIN(tst_QMediaService)
-
-#include "tst_qmediaservice.moc"
diff --git a/tests/auto/unit/qmediaserviceprovider/mockservice.h b/tests/auto/unit/qmediaserviceprovider/mockservice.h
deleted file mode 100644
index 4bd7028e3..000000000
--- a/tests/auto/unit/qmediaserviceprovider/mockservice.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKSERVICE_H
-#define MOCKSERVICE_H
-
-#include <qmediaservice.h>
-
-class MockMediaService : public QMediaService
-{
- Q_OBJECT
-public:
- MockMediaService(const QString& name, QObject *parent = 0) : QMediaService(parent)
- { setObjectName(name); }
- ~MockMediaService() {}
-
- QMediaControl* requestControl(const char *) {return 0;}
- void releaseControl(QMediaControl *) {}
-};
-
-#endif // MOCKSERVICE_H
diff --git a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin1/mockserviceplugin1.cpp b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin1/mockserviceplugin1.cpp
deleted file mode 100644
index 3b8946b92..000000000
--- a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin1/mockserviceplugin1.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qmediaserviceproviderplugin.h>
-#include <qmediaservice.h>
-#include "../mockservice.h"
-
-class MockServicePlugin1 : public QMediaServiceProviderPlugin,
- public QMediaServiceSupportedFormatsInterface
-{
- Q_OBJECT
- Q_INTERFACES(QMediaServiceSupportedFormatsInterface)
- Q_PLUGIN_METADATA(IID "org.qt-project.qt.mediaserviceproviderfactory/5.0" FILE "mockserviceplugin1.json")
-public:
- QStringList keys() const
- {
- return QStringList() <<
- QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER);
- }
-
- QMediaService* create(QString const& key)
- {
- if (keys().contains(key))
- return new MockMediaService("MockServicePlugin1");
- else
- return 0;
- }
-
- void release(QMediaService *service)
- {
- delete service;
- }
-
- QMultimedia::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const
- {
- if (codecs.contains(QLatin1String("mpeg4")))
- return QMultimedia::NotSupported;
-
- if (mimeType == "audio/ogg") {
- return QMultimedia::ProbablySupported;
- }
-
- return QMultimedia::MaybeSupported;
- }
-
- QStringList supportedMimeTypes() const
- {
- return QStringList("audio/ogg");
- }
-};
-
-#include "mockserviceplugin1.moc"
-
diff --git a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin1/mockserviceplugin1.json b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin1/mockserviceplugin1.json
deleted file mode 100644
index 69ff56452..000000000
--- a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin1/mockserviceplugin1.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "Keys": ["mockserviceplugin1"],
- "Services": ["org.qt-project.qt.mediaplayer"]
-}
diff --git a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin1/mockserviceplugin1.pro b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin1/mockserviceplugin1.pro
deleted file mode 100644
index 813d102cb..000000000
--- a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin1/mockserviceplugin1.pro
+++ /dev/null
@@ -1,22 +0,0 @@
-QT += multimedia-private
-
-HEADERS += ../mockservice.h
-SOURCES += mockserviceplugin1.cpp
-OTHER_FILES += mockserviceplugin1.json
-
-DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
-
-PLUGIN_TYPE = mediaservice
-PLUGIN_CLASS_NAME = MockServicePlugin1
-load(qt_plugin)
-
-DESTDIR = ../$${PLUGIN_TYPE}
-win32:debug_and_release {
- CONFIG(debug, debug|release) {
- DESTDIR = ../debug/$${PLUGIN_TYPE}
- } else {
- DESTDIR = ../release/$${PLUGIN_TYPE}
- }
-}
-
-target.path = $$[QT_INSTALL_TESTS]/tst_qmediaserviceprovider/$${PLUGIN_TYPE}
diff --git a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin2/mockserviceplugin2.cpp b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin2/mockserviceplugin2.cpp
deleted file mode 100644
index b44c704f4..000000000
--- a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin2/mockserviceplugin2.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qmediaserviceproviderplugin.h>
-#include <qmediaservice.h>
-#include "../mockservice.h"
-
-class MockServicePlugin2 : public QMediaServiceProviderPlugin,
- public QMediaServiceSupportedFormatsInterface,
- public QMediaServiceFeaturesInterface
-{
- Q_OBJECT
- Q_INTERFACES(QMediaServiceSupportedFormatsInterface)
- Q_INTERFACES(QMediaServiceFeaturesInterface)
- Q_PLUGIN_METADATA(IID "org.qt-project.qt.mediaserviceproviderfactory/5.0" FILE "mockserviceplugin2.json")
-public:
- QStringList keys() const
- {
- return QStringList() << QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER);
- }
-
- QMediaService* create(QString const& key)
- {
- if (keys().contains(key))
- return new MockMediaService("MockServicePlugin2");
- else
- return 0;
- }
-
- void release(QMediaService *service)
- {
- delete service;
- }
-
- QMultimedia::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const
- {
- Q_UNUSED(codecs);
-
- if (mimeType == "audio/wav")
- return QMultimedia::PreferredService;
-
- return QMultimedia::NotSupported;
- }
-
- QStringList supportedMimeTypes() const
- {
- return QStringList("audio/wav");
- }
-
- QMediaServiceProviderHint::Features supportedFeatures(const QByteArray &service) const
- {
- QMediaServiceProviderHint::Features result;
- if (service == QByteArray(Q_MEDIASERVICE_MEDIAPLAYER))
- result |= QMediaServiceProviderHint::LowLatencyPlayback;
- return result;
- }
-};
-
-#include "mockserviceplugin2.moc"
-
diff --git a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin2/mockserviceplugin2.json b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin2/mockserviceplugin2.json
deleted file mode 100644
index 07f9cae7a..000000000
--- a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin2/mockserviceplugin2.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "Keys": ["mockserviceplugin2"],
- "Services": ["org.qt-project.qt.mediaplayer"]
-}
diff --git a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin2/mockserviceplugin2.pro b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin2/mockserviceplugin2.pro
deleted file mode 100644
index f2ac3291d..000000000
--- a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin2/mockserviceplugin2.pro
+++ /dev/null
@@ -1,22 +0,0 @@
-QT += multimedia-private
-
-HEADERS += ../mockservice.h
-SOURCES += mockserviceplugin2.cpp
-OTHER_FILES += mockserviceplugin2.json
-
-DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
-
-PLUGIN_TYPE = mediaservice
-PLUGIN_CLASS_NAME = MockServicePlugin2
-load(qt_plugin)
-
-DESTDIR = ../$${PLUGIN_TYPE}
-win32:debug_and_release {
- CONFIG(debug, debug|release) {
- DESTDIR = ../debug/$${PLUGIN_TYPE}
- } else {
- DESTDIR = ../release/$${PLUGIN_TYPE}
- }
-}
-
-target.path = $$[QT_INSTALL_TESTS]/tst_qmediaserviceprovider/$${PLUGIN_TYPE}
diff --git a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin3/mockserviceplugin3.cpp b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin3/mockserviceplugin3.cpp
deleted file mode 100644
index 2b50392b7..000000000
--- a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin3/mockserviceplugin3.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qmediaserviceproviderplugin.h>
-#include <qmediaservice.h>
-#include "../mockservice.h"
-
-class MockServicePlugin3 : public QMediaServiceProviderPlugin,
- public QMediaServiceSupportedDevicesInterface,
- public QMediaServiceDefaultDeviceInterface,
- public QMediaServiceCameraInfoInterface
-{
- Q_OBJECT
- Q_INTERFACES(QMediaServiceSupportedDevicesInterface)
- Q_INTERFACES(QMediaServiceDefaultDeviceInterface)
- Q_INTERFACES(QMediaServiceCameraInfoInterface)
- Q_PLUGIN_METADATA(IID "org.qt-project.qt.mediaserviceproviderfactory/5.0" FILE "mockserviceplugin3.json")
-public:
- QStringList keys() const
- {
- return QStringList() <<
- QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER) <<
- QLatin1String(Q_MEDIASERVICE_AUDIOSOURCE) <<
- QLatin1String(Q_MEDIASERVICE_CAMERA);
- }
-
- QMediaService* create(QString const& key)
- {
- if (keys().contains(key))
- return new MockMediaService("MockServicePlugin3");
- else
- return 0;
- }
-
- void release(QMediaService *service)
- {
- delete service;
- }
-
- QByteArray defaultDevice(const QByteArray &service) const
- {
- if (service == Q_MEDIASERVICE_AUDIOSOURCE)
- return "audiosource1";
-
- if (service == Q_MEDIASERVICE_CAMERA)
- return "frontcamera";
-
- return QByteArray();
- }
-
- QList<QByteArray> devices(const QByteArray &service) const
- {
- QList<QByteArray> res;
- if (service == Q_MEDIASERVICE_AUDIOSOURCE)
- res << "audiosource1" << "audiosource2";
-
- if (service == Q_MEDIASERVICE_CAMERA)
- res << "frontcamera";
-
- return res;
- }
-
- QString deviceDescription(const QByteArray &service, const QByteArray &device)
- {
- if (devices(service).contains(device))
- return QString(device)+" description";
- else
- return QString();
- }
-
- QCamera::Position cameraPosition(const QByteArray &device) const
- {
- if (device == "frontcamera")
- return QCamera::FrontFace;
-
- return QCamera::UnspecifiedPosition;
- }
-
- int cameraOrientation(const QByteArray &device) const
- {
- if (device == "frontcamera")
- return 270;
-
- return 0;
- }
-};
-
-#include "mockserviceplugin3.moc"
-
diff --git a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin3/mockserviceplugin3.json b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin3/mockserviceplugin3.json
deleted file mode 100644
index ab55b5d1d..000000000
--- a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin3/mockserviceplugin3.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "Keys": ["mockserviceplugin3"],
- "Services": ["org.qt-project.qt.mediaplayer", "org.qt-project.qt.audiosource", "org.qt-project.qt.camera"]
-}
diff --git a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin3/mockserviceplugin3.pro b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin3/mockserviceplugin3.pro
deleted file mode 100644
index 51f87d9da..000000000
--- a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin3/mockserviceplugin3.pro
+++ /dev/null
@@ -1,22 +0,0 @@
-QT += multimedia-private
-
-HEADERS += ../mockservice.h
-SOURCES += mockserviceplugin3.cpp
-OTHER_FILES += mockserviceplugin3.json
-
-DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
-
-PLUGIN_TYPE = mediaservice
-PLUGIN_CLASS_NAME = MockServicePlugin3
-load(qt_plugin)
-
-DESTDIR = ../$${PLUGIN_TYPE}
-win32:debug_and_release {
- CONFIG(debug, debug|release) {
- DESTDIR = ../debug/$${PLUGIN_TYPE}
- } else {
- DESTDIR = ../release/$${PLUGIN_TYPE}
- }
-}
-
-target.path = $$[QT_INSTALL_TESTS]/tst_qmediaserviceprovider/$${PLUGIN_TYPE}
diff --git a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin4/mockserviceplugin4.cpp b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin4/mockserviceplugin4.cpp
deleted file mode 100644
index 6a7725fee..000000000
--- a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin4/mockserviceplugin4.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qmediaserviceproviderplugin.h>
-#include <qmediaservice.h>
-#include "../mockservice.h"
-
-class MockServicePlugin4 : public QMediaServiceProviderPlugin,
- public QMediaServiceSupportedFormatsInterface,
- public QMediaServiceFeaturesInterface
-{
- Q_OBJECT
- Q_INTERFACES(QMediaServiceSupportedFormatsInterface)
- Q_INTERFACES(QMediaServiceFeaturesInterface)
- Q_PLUGIN_METADATA(IID "org.qt-project.qt.mediaserviceproviderfactory/5.0" FILE "mockserviceplugin4.json")
-public:
- QStringList keys() const
- {
- return QStringList() << QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER);
- }
-
- QMediaService* create(QString const& key)
- {
- if (keys().contains(key))
- return new MockMediaService("MockServicePlugin4");
- else
- return 0;
- }
-
- void release(QMediaService *service)
- {
- delete service;
- }
-
- QMultimedia::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const
- {
- if (codecs.contains(QLatin1String("jpeg2000")))
- return QMultimedia::NotSupported;
-
- if (supportedMimeTypes().contains(mimeType))
- return QMultimedia::ProbablySupported;
-
- return QMultimedia::MaybeSupported;
- }
-
- QStringList supportedMimeTypes() const
- {
- return QStringList() << "video/mp4" << "video/quicktime";
- }
-
- QMediaServiceProviderHint::Features supportedFeatures(const QByteArray &service) const
- {
- QMediaServiceProviderHint::Features result;
- if (service == QByteArray(Q_MEDIASERVICE_MEDIAPLAYER))
- result |= QMediaServiceProviderHint::StreamPlayback;
- return result;
- }
-};
-
-#include "mockserviceplugin4.moc"
-
diff --git a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin4/mockserviceplugin4.json b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin4/mockserviceplugin4.json
deleted file mode 100644
index d8b8bd7e9..000000000
--- a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin4/mockserviceplugin4.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "Keys": ["mockserviceplugin4"],
- "Services": ["org.qt-project.qt.mediaplayer"]
-}
diff --git a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin4/mockserviceplugin4.pro b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin4/mockserviceplugin4.pro
deleted file mode 100644
index c3834ab03..000000000
--- a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin4/mockserviceplugin4.pro
+++ /dev/null
@@ -1,22 +0,0 @@
-QT += multimedia-private
-
-HEADERS += ../mockservice.h
-SOURCES += mockserviceplugin4.cpp
-OTHER_FILES += mockserviceplugin4.json
-
-DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
-
-PLUGIN_TYPE = mediaservice
-PLUGIN_CLASS_NAME = MockServicePlugin4
-load(qt_plugin)
-
-DESTDIR = ../$${PLUGIN_TYPE}
-win32:debug_and_release {
- CONFIG(debug, debug|release) {
- DESTDIR = ../debug/$${PLUGIN_TYPE}
- } else {
- DESTDIR = ../release/$${PLUGIN_TYPE}
- }
-}
-
-target.path = $$[QT_INSTALL_TESTS]/tst_qmediaserviceprovider/$${PLUGIN_TYPE}
diff --git a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin5/mockserviceplugin5.cpp b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin5/mockserviceplugin5.cpp
deleted file mode 100644
index 5340a055d..000000000
--- a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin5/mockserviceplugin5.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qmediaserviceproviderplugin.h>
-#include <qmediaservice.h>
-#include "../mockservice.h"
-
-class MockServicePlugin5 : public QMediaServiceProviderPlugin,
- public QMediaServiceSupportedDevicesInterface,
- public QMediaServiceDefaultDeviceInterface,
- public QMediaServiceCameraInfoInterface
-{
- Q_OBJECT
- Q_INTERFACES(QMediaServiceSupportedDevicesInterface)
- Q_INTERFACES(QMediaServiceDefaultDeviceInterface)
- Q_INTERFACES(QMediaServiceCameraInfoInterface)
- Q_PLUGIN_METADATA(IID "org.qt-project.qt.mediaserviceproviderfactory/5.0" FILE "mockserviceplugin5.json")
-public:
- QStringList keys() const
- {
- return QStringList() << QLatin1String(Q_MEDIASERVICE_CAMERA);
- }
-
- QMediaService* create(QString const& key)
- {
- if (keys().contains(key))
- return new MockMediaService("MockServicePlugin5");
- else
- return 0;
- }
-
- void release(QMediaService *service)
- {
- delete service;
- }
-
- QByteArray defaultDevice(const QByteArray &service) const
- {
- if (service == Q_MEDIASERVICE_CAMERA)
- return "backcamera";
-
- return QByteArray();
- }
-
- QList<QByteArray> devices(const QByteArray &service) const
- {
- QList<QByteArray> res;
- if (service == Q_MEDIASERVICE_CAMERA)
- res << "backcamera" << "somecamera";
-
- return res;
- }
-
- QString deviceDescription(const QByteArray &service, const QByteArray &device)
- {
- if (devices(service).contains(device))
- return QString(device)+" description";
- else
- return QString();
- }
-
- QCamera::Position cameraPosition(const QByteArray &device) const
- {
- if (device == "backcamera")
- return QCamera::BackFace;
-
- return QCamera::UnspecifiedPosition;
- }
-
- int cameraOrientation(const QByteArray &device) const
- {
- if (device == "backcamera")
- return 90;
-
- return 0;
- }
-};
-
-#include "mockserviceplugin5.moc"
-
diff --git a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin5/mockserviceplugin5.json b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin5/mockserviceplugin5.json
deleted file mode 100644
index cc6f4816c..000000000
--- a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin5/mockserviceplugin5.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "Keys": ["mockserviceplugin5"],
- "Services": ["org.qt-project.qt.camera"]
-}
diff --git a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin5/mockserviceplugin5.pro b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin5/mockserviceplugin5.pro
deleted file mode 100644
index b273c6b15..000000000
--- a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin5/mockserviceplugin5.pro
+++ /dev/null
@@ -1,22 +0,0 @@
-QT += multimedia-private
-
-HEADERS += ../mockservice.h
-SOURCES += mockserviceplugin5.cpp
-OTHER_FILES += mockserviceplugin5.json
-
-DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
-
-PLUGIN_TYPE = mediaservice
-PLUGIN_CLASS_NAME = MockServicePlugin5
-load(qt_plugin)
-
-DESTDIR = ../$${PLUGIN_TYPE}
-win32:debug_and_release {
- CONFIG(debug, debug|release) {
- DESTDIR = ../debug/$${PLUGIN_TYPE}
- } else {
- DESTDIR = ../release/$${PLUGIN_TYPE}
- }
-}
-
-target.path = $$[QT_INSTALL_TESTS]/tst_qmediaserviceprovider/$${PLUGIN_TYPE}
diff --git a/tests/auto/unit/qmediaserviceprovider/qmediaserviceprovider.pro b/tests/auto/unit/qmediaserviceprovider/qmediaserviceprovider.pro
deleted file mode 100644
index cea19e212..000000000
--- a/tests/auto/unit/qmediaserviceprovider/qmediaserviceprovider.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-TEMPLATE = subdirs
-CONFIG += ORDERED
-
-SUBDIRS += \
- mockserviceplugin1 \
- mockserviceplugin2 \
- mockserviceplugin3 \
- mockserviceplugin4 \
- mockserviceplugin5 \
- test
-
-# no special install rule for subdir
-INSTALLS =
-
diff --git a/tests/auto/unit/qmediaserviceprovider/test/test.pro b/tests/auto/unit/qmediaserviceprovider/test/test.pro
deleted file mode 100644
index 94f7f259a..000000000
--- a/tests/auto/unit/qmediaserviceprovider/test/test.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-CONFIG += testcase
-TARGET = ../tst_qmediaserviceprovider
-
-QT += multimedia-private testlib
-
-SOURCES += ../tst_qmediaserviceprovider.cpp
-
-win32:debug_and_release {
- CONFIG(debug, debug|release) {
- TARGET = ../../debug/tst_qmediaserviceprovider
- } else {
- TARGET = ../../release/tst_qmediaserviceprovider
- }
-}
-
-mac: CONFIG -= app_bundle
-
diff --git a/tests/auto/unit/qmediaserviceprovider/tst_qmediaserviceprovider.cpp b/tests/auto/unit/qmediaserviceprovider/tst_qmediaserviceprovider.cpp
deleted file mode 100644
index e4bb719e6..000000000
--- a/tests/auto/unit/qmediaserviceprovider/tst_qmediaserviceprovider.cpp
+++ /dev/null
@@ -1,381 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//TESTED_COMPONENT=src/multimedia
-
-#include <QtTest/QtTest>
-#include <QDebug>
-#include <QStringList>
-
-#include <private/qmediaserviceprovider_p.h>
-#include <qmediaserviceproviderplugin.h>
-#include <private/qmediapluginloader_p.h>
-#include <qmediaobject.h>
-#include <qmediaservice.h>
-#include <qmediaplayer.h>
-#include <qaudiorecorder.h>
-#include <qcamera.h>
-#include <qcamerainfo.h>
-
-QT_USE_NAMESPACE
-
-class MockMediaServiceProvider : public QMediaServiceProvider
-{
- QMediaService* requestService(const QByteArray &type, const QMediaServiceProviderHint &)
- {
- Q_UNUSED(type);
- return 0;
- }
-
- void releaseService(QMediaService *service)
- {
- Q_UNUSED(service);
- }
-};
-
-
-class tst_QMediaServiceProvider : public QObject
-{
- Q_OBJECT
-
-public slots:
- void initTestCase();
-
-private slots:
- void testDefaultProviderAvailable();
- void testObtainService();
- void testHasSupport();
- void testSupportedMimeTypes();
- void testProviderHints();
- void testDefaultDevice();
- void testAvailableDevices();
- void testCameraInfo();
-
-private:
- QObjectList plugins;
-};
-
-void tst_QMediaServiceProvider::initTestCase()
-{
-// QMediaPluginLoader::setStaticPlugins(QLatin1String("mediaservice"), plugins);
-#if QT_CONFIG(library)
- QCoreApplication::setLibraryPaths(QStringList() << QCoreApplication::applicationDirPath());
-#endif
-}
-
-void tst_QMediaServiceProvider::testDefaultProviderAvailable()
-{
- // Must always be a default provider available
- QVERIFY(QMediaServiceProvider::defaultServiceProvider() != 0);
-}
-
-void tst_QMediaServiceProvider::testObtainService()
-{
- QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider();
-
- if (provider == 0)
- QSKIP("No default provider");
-
- QMediaService *service = 0;
-
- // Player
- service = provider->requestService(Q_MEDIASERVICE_MEDIAPLAYER);
- QVERIFY(service != 0);
- provider->releaseService(service);
-}
-
-void tst_QMediaServiceProvider::testHasSupport()
-{
- MockMediaServiceProvider mockProvider;
- QCOMPARE(mockProvider.hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "video/ogv", QStringList()),
- QMultimedia::MaybeSupported);
-
- QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider();
-
- if (provider == 0)
- QSKIP("No default provider");
-
- QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "video/ogv", QStringList()),
- QMultimedia::MaybeSupported);
-
- QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "audio/ogg", QStringList()),
- QMultimedia::ProbablySupported);
-
- //while the service returns PreferredService, provider should return ProbablySupported
- QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "audio/wav", QStringList()),
- QMultimedia::ProbablySupported);
-
- //even while all the plugins with "hasSupport" returned NotSupported,
- //MockServicePlugin3 has no "hasSupport" interface, so MaybeSupported
- QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "video/avi",
- QStringList() << "mpeg4"),
- QMultimedia::MaybeSupported);
-
- QCOMPARE(provider->hasSupport(QByteArray("non existing service"), "video/ogv", QStringList()),
- QMultimedia::NotSupported);
-
- QCOMPARE(QMediaPlayer::hasSupport("video/ogv"), QMultimedia::MaybeSupported);
- QCOMPARE(QMediaPlayer::hasSupport("audio/ogg"), QMultimedia::ProbablySupported);
- QCOMPARE(QMediaPlayer::hasSupport("audio/wav"), QMultimedia::ProbablySupported);
-
- //test low latency flag support
- QCOMPARE(QMediaPlayer::hasSupport("audio/wav", QStringList(), QMediaPlayer::LowLatency),
- QMultimedia::ProbablySupported);
- //plugin1 probably supports audio/ogg, it checked because it doesn't provide features iface
- QCOMPARE(QMediaPlayer::hasSupport("audio/ogg", QStringList(), QMediaPlayer::LowLatency),
- QMultimedia::ProbablySupported);
- //Plugin4 is not checked here, sine it's known not support low latency
- QCOMPARE(QMediaPlayer::hasSupport("video/quicktime", QStringList(), QMediaPlayer::LowLatency),
- QMultimedia::MaybeSupported);
-
- //test streaming flag support
- QCOMPARE(QMediaPlayer::hasSupport("video/quicktime", QStringList(), QMediaPlayer::StreamPlayback),
- QMultimedia::ProbablySupported);
- //Plugin2 is not checked here, sine it's known not support streaming
- QCOMPARE(QMediaPlayer::hasSupport("audio/wav", QStringList(), QMediaPlayer::StreamPlayback),
- QMultimedia::MaybeSupported);
-
- //ensure the correct media player plugin is chosen for mime type
- QMediaPlayer simplePlayer(0, QMediaPlayer::LowLatency);
- QCOMPARE(simplePlayer.service()->objectName(), QLatin1String("MockServicePlugin2"));
-
- QMediaPlayer mediaPlayer;
- QVERIFY(mediaPlayer.service()->objectName() != QLatin1String("MockServicePlugin2"));
-
- QMediaPlayer streamPlayer(0, QMediaPlayer::StreamPlayback);
- QCOMPARE(streamPlayer.service()->objectName(), QLatin1String("MockServicePlugin4"));
-}
-
-void tst_QMediaServiceProvider::testSupportedMimeTypes()
-{
- QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider();
-
- if (provider == 0)
- QSKIP("No default provider");
-
- QVERIFY(provider->supportedMimeTypes(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER)).contains("audio/ogg"));
- QVERIFY(!provider->supportedMimeTypes(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER)).contains("audio/mp3"));
-}
-
-void tst_QMediaServiceProvider::testProviderHints()
-{
- {
- QMediaServiceProviderHint hint;
- QVERIFY(hint.isNull());
- QCOMPARE(hint.type(), QMediaServiceProviderHint::Null);
- QVERIFY(hint.device().isEmpty());
- QCOMPARE(hint.cameraPosition(), QCamera::UnspecifiedPosition);
- QVERIFY(hint.mimeType().isEmpty());
- QVERIFY(hint.codecs().isEmpty());
- QCOMPARE(hint.features(), 0);
- }
-
- {
- QByteArray deviceName(QByteArray("testDevice"));
- QMediaServiceProviderHint hint(deviceName);
- QVERIFY(!hint.isNull());
- QCOMPARE(hint.type(), QMediaServiceProviderHint::Device);
- QCOMPARE(hint.device(), deviceName);
- QCOMPARE(hint.cameraPosition(), QCamera::UnspecifiedPosition);
- QVERIFY(hint.mimeType().isEmpty());
- QVERIFY(hint.codecs().isEmpty());
- QCOMPARE(hint.features(), 0);
- }
-
- {
- QMediaServiceProviderHint hint(QCamera::FrontFace);
- QVERIFY(!hint.isNull());
- QCOMPARE(hint.type(), QMediaServiceProviderHint::CameraPosition);
- QVERIFY(hint.device().isEmpty());
- QCOMPARE(hint.cameraPosition(), QCamera::FrontFace);
- QVERIFY(hint.mimeType().isEmpty());
- QVERIFY(hint.codecs().isEmpty());
- QCOMPARE(hint.features(), 0);
- }
-
- {
- QMediaServiceProviderHint hint(QMediaServiceProviderHint::LowLatencyPlayback);
- QVERIFY(!hint.isNull());
- QCOMPARE(hint.type(), QMediaServiceProviderHint::SupportedFeatures);
- QVERIFY(hint.device().isEmpty());
- QCOMPARE(hint.cameraPosition(), QCamera::UnspecifiedPosition);
- QVERIFY(hint.mimeType().isEmpty());
- QVERIFY(hint.codecs().isEmpty());
- QCOMPARE(hint.features(), QMediaServiceProviderHint::LowLatencyPlayback);
- }
-
- {
- QMediaServiceProviderHint hint(QMediaServiceProviderHint::RecordingSupport);
- QVERIFY(!hint.isNull());
- QCOMPARE(hint.type(), QMediaServiceProviderHint::SupportedFeatures);
- QVERIFY(hint.device().isEmpty());
- QCOMPARE(hint.cameraPosition(), QCamera::UnspecifiedPosition);
- QVERIFY(hint.mimeType().isEmpty());
- QVERIFY(hint.codecs().isEmpty());
- QCOMPARE(hint.features(), QMediaServiceProviderHint::RecordingSupport);
- }
-
- {
- QString mimeType(QLatin1String("video/ogg"));
- QStringList codecs;
- codecs << "theora" << "vorbis";
-
- QMediaServiceProviderHint hint(mimeType,codecs);
- QVERIFY(!hint.isNull());
- QCOMPARE(hint.type(), QMediaServiceProviderHint::ContentType);
- QVERIFY(hint.device().isEmpty());
- QCOMPARE(hint.cameraPosition(), QCamera::UnspecifiedPosition);
- QCOMPARE(hint.mimeType(), mimeType);
- QCOMPARE(hint.codecs(), codecs);
-
- QMediaServiceProviderHint hint2(hint);
-
- QVERIFY(!hint2.isNull());
- QCOMPARE(hint2.type(), QMediaServiceProviderHint::ContentType);
- QVERIFY(hint2.device().isEmpty());
- QCOMPARE(hint.cameraPosition(), QCamera::UnspecifiedPosition);
- QCOMPARE(hint2.mimeType(), mimeType);
- QCOMPARE(hint2.codecs(), codecs);
-
- QMediaServiceProviderHint hint3;
- QVERIFY(hint3.isNull());
- hint3 = hint;
- QVERIFY(!hint3.isNull());
- QCOMPARE(hint3.type(), QMediaServiceProviderHint::ContentType);
- QVERIFY(hint3.device().isEmpty());
- QCOMPARE(hint.cameraPosition(), QCamera::UnspecifiedPosition);
- QCOMPARE(hint3.mimeType(), mimeType);
- QCOMPARE(hint3.codecs(), codecs);
-
- QCOMPARE(hint, hint2);
- QCOMPARE(hint3, hint2);
-
- QMediaServiceProviderHint hint4(mimeType,codecs);
- QCOMPARE(hint, hint4);
-
- QMediaServiceProviderHint hint5(mimeType,QStringList());
- QVERIFY(hint != hint5);
- }
-}
-
-void tst_QMediaServiceProvider::testDefaultDevice()
-{
- QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider();
-
- if (provider == 0)
- QSKIP("No default provider");
-
- QCOMPARE(provider->defaultDevice(Q_MEDIASERVICE_AUDIOSOURCE), QByteArray("audiosource1"));
- QCOMPARE(provider->defaultDevice(Q_MEDIASERVICE_CAMERA), QByteArray("frontcamera"));
-}
-
-void tst_QMediaServiceProvider::testAvailableDevices()
-{
- QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider();
-
- if (provider == 0)
- QSKIP("No default provider");
-
- QList<QByteArray> devices = provider->devices(Q_MEDIASERVICE_AUDIOSOURCE);
- QCOMPARE(devices.count(), 2);
- QCOMPARE(devices.at(0), QByteArray("audiosource1"));
- QCOMPARE(devices.at(1), QByteArray("audiosource2"));
-
- devices = provider->devices(Q_MEDIASERVICE_CAMERA);
- QCOMPARE(devices.count(), 3);
- QCOMPARE(devices.at(0), QByteArray("frontcamera"));
- QCOMPARE(devices.at(1), QByteArray("backcamera"));
- QCOMPARE(devices.at(2), QByteArray("somecamera"));
-}
-
-void tst_QMediaServiceProvider::testCameraInfo()
-{
- QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider();
-
- if (provider == 0)
- QSKIP("No default provider");
-
- QCOMPARE(provider->cameraPosition("backcamera"), QCamera::BackFace);
- QCOMPARE(provider->cameraOrientation("backcamera"), 90);
- QCOMPARE(provider->cameraPosition("frontcamera"), QCamera::FrontFace);
- QCOMPARE(provider->cameraOrientation("frontcamera"), 270);
- QCOMPARE(provider->cameraPosition("somecamera"), QCamera::UnspecifiedPosition);
- QCOMPARE(provider->cameraOrientation("somecamera"), 0);
-
- {
- QCamera camera;
- QVERIFY(camera.service());
- QCOMPARE(camera.service()->objectName(), QLatin1String("MockServicePlugin3"));
- }
-
- {
- QCamera camera(QCameraInfo::defaultCamera());
- QVERIFY(camera.service());
- QCOMPARE(camera.service()->objectName(), QLatin1String("MockServicePlugin3"));
- }
-
- {
- QCamera camera(QCameraInfo::availableCameras().at(0));
- QVERIFY(camera.service());
- QCOMPARE(camera.service()->objectName(), QLatin1String("MockServicePlugin3"));
- }
-
- {
- QCamera camera(QCameraInfo::availableCameras().at(1));
- QVERIFY(camera.service());
- QCOMPARE(camera.service()->objectName(), QLatin1String("MockServicePlugin5"));
- }
-
- {
- QCamera camera(QCameraInfo::availableCameras().at(2));
- QVERIFY(camera.service());
- QCOMPARE(camera.service()->objectName(), QLatin1String("MockServicePlugin5"));
- }
-
- {
- QCamera camera(QCamera::FrontFace);
- QVERIFY(camera.service());
- QCOMPARE(camera.service()->objectName(), QLatin1String("MockServicePlugin3"));
- }
-
- {
- QCamera camera(QCamera::BackFace);
- QVERIFY(camera.service());
- QCOMPARE(camera.service()->objectName(), QLatin1String("MockServicePlugin5"));
- }
-
- {
- QCamera camera(QCamera::UnspecifiedPosition);
- QVERIFY(camera.service());
- QCOMPARE(camera.service()->objectName(), QLatin1String("MockServicePlugin3"));
- }
-}
-
-QTEST_MAIN(tst_QMediaServiceProvider)
-
-#include "tst_qmediaserviceprovider.moc"
diff --git a/tests/auto/unit/qmediatimerange/qmediatimerange.pro b/tests/auto/unit/qmediatimerange/qmediatimerange.pro
deleted file mode 100644
index c59c3d8df..000000000
--- a/tests/auto/unit/qmediatimerange/qmediatimerange.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qmediatimerange
-
-QT += multimedia-private testlib
-
-SOURCES += tst_qmediatimerange.cpp
-
diff --git a/tests/auto/unit/qmetadatareadercontrol/qmetadatareadercontrol.pro b/tests/auto/unit/qmetadatareadercontrol/qmetadatareadercontrol.pro
deleted file mode 100644
index 1ed2b3443..000000000
--- a/tests/auto/unit/qmetadatareadercontrol/qmetadatareadercontrol.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qmetadatareadercontrol
-
-QT += multimedia-private testlib
-
-SOURCES += tst_qmetadatareadercontrol.cpp
-
-include (../qmultimedia_common/mockcontainer.pri)
-
diff --git a/tests/auto/unit/qmetadatareadercontrol/tst_qmetadatareadercontrol.cpp b/tests/auto/unit/qmetadatareadercontrol/tst_qmetadatareadercontrol.cpp
deleted file mode 100644
index 381c34407..000000000
--- a/tests/auto/unit/qmetadatareadercontrol/tst_qmetadatareadercontrol.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QtCore/QString>
-#include <QtTest/QtTest>
-#include <QtCore/QCoreApplication>
-#include <QtMultimedia/qmediametadata.h>
-
-#include "mockmetadatareadercontrol.h"
-
-class tst_QMetaDataReaderControl : public QObject
-{
- Q_OBJECT
-
-private slots:
- // Test case for QMetaDataReaderControl
- void metaDataReaderControlConstructor();
- void metaDataReaderControlAvailableMetaData();
- void metaDataReaderControlIsMetaDataAvailable();
- void metaDataReaderControlMetaData();
- void metaDataReaderControlMetaDataAvailableChangedSignal();
- void metaDataReaderControlMetaDataChangedSignal();
-};
-
-QTEST_MAIN(tst_QMetaDataReaderControl);
-
-/* Test case for constructor. */
-void tst_QMetaDataReaderControl::metaDataReaderControlConstructor()
-{
- MockMetaDataReaderControl *metaData = new MockMetaDataReaderControl();
- QVERIFY(metaData !=NULL);
- delete metaData;
-}
-
-/* Test case for availableMetaData() */
-void tst_QMetaDataReaderControl::metaDataReaderControlAvailableMetaData()
-{
- MockMetaDataReaderControl *metaData = new MockMetaDataReaderControl();
- QVERIFY(metaData !=NULL);
- metaData->availableMetaData() ;
- delete metaData;
-}
-
-/* Test case for availableMetaData */
-void tst_QMetaDataReaderControl::metaDataReaderControlIsMetaDataAvailable ()
-{
- MockMetaDataReaderControl *metaData = new MockMetaDataReaderControl();
- QVERIFY(metaData !=NULL);
- metaData->availableMetaData();
- delete metaData;
-}
-
-/* Test case for metaData */
-void tst_QMetaDataReaderControl::metaDataReaderControlMetaData ()
-{
- MockMetaDataReaderControl *metaData = new MockMetaDataReaderControl();
- QVERIFY(metaData !=NULL);
- metaData->metaData(QMediaMetaData::Title);
- delete metaData;
-}
-
-/* Test case for signal metaDataAvailableChanged */
-void tst_QMetaDataReaderControl::metaDataReaderControlMetaDataAvailableChangedSignal ()
-{
- MockMetaDataReaderControl *metaData = new MockMetaDataReaderControl();
- QVERIFY(metaData !=NULL);
- QSignalSpy spy(metaData,SIGNAL(metaDataAvailableChanged(bool)));
- metaData->setMetaDataAvailable(true);
- QVERIFY(spy.count() == 1);
- delete metaData;
-}
-
- /* Test case for signal metaDataChanged */
-void tst_QMetaDataReaderControl::metaDataReaderControlMetaDataChangedSignal ()
-{
- MockMetaDataReaderControl *metaData = new MockMetaDataReaderControl();
- QVERIFY(metaData !=NULL);
- QSignalSpy spy(metaData,SIGNAL(metaDataChanged()));
- metaData->metaDataChanged();
- QVERIFY(spy.count () == 1);
- delete metaData;
-}
-
-#include "tst_qmetadatareadercontrol.moc"
-
-
diff --git a/tests/auto/unit/qmetadatawritercontrol/qmetadatawritercontrol.pro b/tests/auto/unit/qmetadatawritercontrol/qmetadatawritercontrol.pro
deleted file mode 100644
index db7e964ba..000000000
--- a/tests/auto/unit/qmetadatawritercontrol/qmetadatawritercontrol.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qmetadatawritercontrol
-
-QT += multimedia-private testlib
-
-SOURCES += tst_qmetadatawritercontrol.cpp
-
-include (../qmultimedia_common/mockcontainer.pri)
diff --git a/tests/auto/unit/qmetadatawritercontrol/tst_qmetadatawritercontrol.cpp b/tests/auto/unit/qmetadatawritercontrol/tst_qmetadatawritercontrol.cpp
deleted file mode 100644
index f8ceb694c..000000000
--- a/tests/auto/unit/qmetadatawritercontrol/tst_qmetadatawritercontrol.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QtCore/QString>
-#include <QtTest/QtTest>
-#include <QtCore/QCoreApplication>
-#include <QtMultimedia/qmediametadata.h>
-#include "qmetadatawritercontrol.h"
-
-#include "mockmetadatawritercontrol.h"
-
-class tst_QMetaDataWriterControl: public QObject
-{
- Q_OBJECT
-
-public slots:
- void initTestCase();
- void cleanupTestCase();
-
-private slots:
- void constructor();
-};
-
-void tst_QMetaDataWriterControl::initTestCase()
-{
-
-}
-
-void tst_QMetaDataWriterControl::cleanupTestCase()
-{
-
-}
-
-//MaemoAPI-1862:test constructor
-void tst_QMetaDataWriterControl::constructor()
-{
- QMetaDataWriterControl *mock = new MockMetaDataWriterControl();
- mock->availableMetaData();
- mock->isMetaDataAvailable();
- mock->isWritable();
- mock->metaData(QMediaMetaData::Title);
- mock->setMetaData(QMediaMetaData::Title, QVariant());
- ((MockMetaDataWriterControl*)mock)->setWritable();
- ((MockMetaDataWriterControl*)mock)->setMetaDataAvailable();
- delete mock;
-}
-
-QTEST_MAIN(tst_QMetaDataWriterControl);
-
-#include "tst_qmetadatawritercontrol.moc"
diff --git a/tests/auto/unit/qmultimedia_common/mock.pri b/tests/auto/unit/qmultimedia_common/mock.pri
deleted file mode 100644
index 94a17a615..000000000
--- a/tests/auto/unit/qmultimedia_common/mock.pri
+++ /dev/null
@@ -1,8 +0,0 @@
-INCLUDEPATH += $$PWD \
- ../../../../src/multimedia \
-
-HEADERS *= \
- ../qmultimedia_common/mockmediaserviceprovider.h \
- ../qmultimedia_common/mockmediaservice.h \
- ../qmultimedia_common/mockmediaobject.h \
- ../qmultimedia_common/mockavailabilitycontrol.h
diff --git a/tests/auto/unit/qmultimedia_common/mockaudiodecodercontrol.h b/tests/auto/unit/qmultimedia_common/mockaudiodecodercontrol.h
deleted file mode 100644
index 82eeedc15..000000000
--- a/tests/auto/unit/qmultimedia_common/mockaudiodecodercontrol.h
+++ /dev/null
@@ -1,206 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKAUDIODECODERCONTROL_H
-#define MOCKAUDIODECODERCONTROL_H
-
-#include "qmediacontrol.h"
-#include "qaudiodecodercontrol.h"
-
-#include <QtCore/qpair.h>
-
-#include "qaudiobuffer.h"
-#include <QTimer>
-#include <QIODevice>
-
-#define MOCK_DECODER_MAX_BUFFERS 10
-
-QT_BEGIN_NAMESPACE
-
-class MockAudioDecoderControl : public QAudioDecoderControl
-{
- Q_OBJECT
-
-public:
- MockAudioDecoderControl(QObject *parent = 0)
- : QAudioDecoderControl(parent)
- , mState(QAudioDecoder::StoppedState)
- , mDevice(0)
- , mPosition(-1)
- , mSerial(0)
- {
- mFormat.setChannelCount(1);
- mFormat.setSampleSize(8);
- mFormat.setSampleRate(1000);
- mFormat.setCodec("audio/x-raw");
- mFormat.setSampleType(QAudioFormat::UnSignedInt);
- }
-
- QAudioDecoder::State state() const
- {
- return mState;
- }
-
- QString sourceFilename() const
- {
- return mSource;
- }
-
- QAudioFormat audioFormat() const
- {
- return mFormat;
- }
-
- void setAudioFormat(const QAudioFormat &format)
- {
- if (mFormat != format) {
- mFormat = format;
- emit formatChanged(mFormat);
- }
- }
-
- void setSourceFilename(const QString &fileName)
- {
- mSource = fileName;
- mDevice = 0;
- stop();
- }
-
- QIODevice* sourceDevice() const
- {
- return mDevice;
- }
-
- void setSourceDevice(QIODevice *device)
- {
- mDevice = device;
- mSource.clear();
- stop();
- }
-
- // When decoding we decode to first buffer, then second buffer
- // we then stop until the first is read again and so on, for
- // 5 buffers
- void start()
- {
- if (mState == QAudioDecoder::StoppedState) {
- if (!mSource.isEmpty()) {
- mState = QAudioDecoder::DecodingState;
- emit stateChanged(mState);
- emit durationChanged(duration());
-
- QTimer::singleShot(50, this, SLOT(pretendDecode()));
- } else {
- emit error(QAudioDecoder::ResourceError, "No source set");
- }
- }
- }
-
- void stop()
- {
- if (mState != QAudioDecoder::StoppedState) {
- mState = QAudioDecoder::StoppedState;
- mSerial = 0;
- mPosition = 0;
- mBuffers.clear();
- emit stateChanged(mState);
- emit bufferAvailableChanged(false);
- }
- }
-
- QAudioBuffer read()
- {
- QAudioBuffer a;
- if (mBuffers.length() > 0) {
- a = mBuffers.takeFirst();
- mPosition = a.startTime() / 1000;
- emit positionChanged(mPosition);
-
- if (mBuffers.isEmpty())
- emit bufferAvailableChanged(false);
-
- if (mBuffers.isEmpty() && mSerial >= MOCK_DECODER_MAX_BUFFERS) {
- mState = QAudioDecoder::StoppedState;
- emit finished();
- emit stateChanged(mState);
- } else
- QTimer::singleShot(50, this, SLOT(pretendDecode()));
- }
-
- return a;
- }
-
- bool bufferAvailable() const
- {
- return mBuffers.length() > 0;
- }
-
- qint64 position() const
- {
- return mPosition;
- }
-
- qint64 duration() const
- {
- return (sizeof(mSerial) * MOCK_DECODER_MAX_BUFFERS * qint64(1000)) / (mFormat.sampleRate() * mFormat.channelCount());
- }
-
-private slots:
- void pretendDecode()
- {
- // Check if we've reached end of stream
- if (mSerial >= MOCK_DECODER_MAX_BUFFERS)
- return;
-
- // We just keep the length of mBuffers to 3 or less.
- if (mBuffers.length() < 3) {
- QByteArray b(sizeof(mSerial), 0);
- memcpy(b.data(), &mSerial, sizeof(mSerial));
- qint64 position = (sizeof(mSerial) * mSerial * qint64(1000000)) / (mFormat.sampleRate() * mFormat.channelCount());
- mSerial++;
- mBuffers.push_back(QAudioBuffer(b, mFormat, position));
- emit bufferReady();
- if (mBuffers.count() == 1)
- emit bufferAvailableChanged(true);
- }
- }
-
-public:
- QAudioDecoder::State mState;
- QString mSource;
- QIODevice *mDevice;
- QAudioFormat mFormat;
- qint64 mPosition;
-
- int mSerial;
- QList<QAudioBuffer> mBuffers;
-};
-
-QT_END_NAMESPACE
-
-#endif // QAUDIODECODERCONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockaudiodecoderservice.h b/tests/auto/unit/qmultimedia_common/mockaudiodecoderservice.h
deleted file mode 100644
index 11c1dff95..000000000
--- a/tests/auto/unit/qmultimedia_common/mockaudiodecoderservice.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKAUDIODECODERSERVICE_H
-#define MOCKAUDIODECODERSERVICE_H
-
-#include "qmediaservice.h"
-
-#include "mockaudiodecodercontrol.h"
-
-class MockAudioDecoderService : public QMediaService
-{
- Q_OBJECT
-
-public:
- MockAudioDecoderService(QObject *parent = 0)
- : QMediaService(parent)
- {
- mockControl = new MockAudioDecoderControl(this);
- validControl = mockControl;
- }
-
- ~MockAudioDecoderService()
- {
- delete mockControl;
- }
-
- QMediaControl* requestControl(const char *iid)
- {
- if (qstrcmp(iid, QAudioDecoderControl_iid) == 0)
- return mockControl;
- return 0;
- }
-
- void releaseControl(QMediaControl *control)
- {
- Q_UNUSED(control);
- }
-
- void setControlNull()
- {
- mockControl = 0;
- }
-
- void setControlValid()
- {
- mockControl = validControl;
- }
-
- MockAudioDecoderControl *mockControl;
- MockAudioDecoderControl *validControl;
-};
-
-
-
-#endif // MOCKAUDIODECODERSERVICE_H
diff --git a/tests/auto/unit/qmultimedia_common/mockaudioencodercontrol.h b/tests/auto/unit/qmultimedia_common/mockaudioencodercontrol.h
deleted file mode 100644
index 0b3de29e7..000000000
--- a/tests/auto/unit/qmultimedia_common/mockaudioencodercontrol.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKAUDIOENCODERCONTROL_H
-#define MOCKAUDIOENCODERCONTROL_H
-
-#include "qaudioencodersettingscontrol.h"
-
-class MockAudioEncoderControl : public QAudioEncoderSettingsControl
-{
- Q_OBJECT
-public:
- MockAudioEncoderControl(QObject *parent):
- QAudioEncoderSettingsControl(parent)
- {
- m_codecs << "audio/pcm" << "audio/mpeg";
- m_descriptions << "Pulse Code Modulation" << "mp3 format";
- m_audioSettings.setCodec("audio/pcm");
- m_audioSettings.setBitRate(128*1024);
- m_audioSettings.setSampleRate(8000);
- m_freqs << 8000 << 11025 << 22050 << 44100;
- }
-
- ~MockAudioEncoderControl() {}
-
- QAudioEncoderSettings audioSettings() const
- {
- return m_audioSettings;
- }
-
- void setAudioSettings(const QAudioEncoderSettings &settings)
- {
- m_audioSettings = settings;
- }
-
- QList<int> supportedChannelCounts(const QAudioEncoderSettings & = QAudioEncoderSettings()) const
- {
- QList<int> list; list << 1 << 2; return list;
- }
-
- QList<int> supportedSampleRates(const QAudioEncoderSettings & = QAudioEncoderSettings(), bool *continuous = 0) const
- {
- if (continuous)
- *continuous = false;
-
- return m_freqs;
- }
-
- QStringList supportedAudioCodecs() const
- {
- return m_codecs;
- }
-
- QString codecDescription(const QString &codecName) const
- {
- return m_descriptions.value(m_codecs.indexOf(codecName));
- }
-
-private:
- QAudioEncoderSettings m_audioSettings;
-
- QStringList m_codecs;
- QStringList m_descriptions;
-
- QList<int> m_freqs;
-
-};
-
-#endif // MOCKAUDIOENCODERCONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockaudioinputselector.h b/tests/auto/unit/qmultimedia_common/mockaudioinputselector.h
deleted file mode 100644
index 216fb54d3..000000000
--- a/tests/auto/unit/qmultimedia_common/mockaudioinputselector.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKAUDIOINPUTSELECTOR_H
-#define MOCKAUDIOINPUTSELECTOR_H
-
-#include "qaudioinputselectorcontrol.h"
-
-class MockAudioInputSelector : public QAudioInputSelectorControl
-{
- Q_OBJECT
-public:
- MockAudioInputSelector(QObject *parent):
- QAudioInputSelectorControl(parent)
- {
- m_names << "device1" << "device2" << "device3";
- m_descriptions << "dev1 comment" << "dev2 comment" << "dev3 comment";
- m_audioInput = "device1";
- emit availableInputsChanged();
- }
- ~MockAudioInputSelector() {}
-
- QList<QString> availableInputs() const
- {
- return m_names;
- }
-
- QString inputDescription(const QString& name) const
- {
- QString desc;
-
- for (int i = 0; i < m_names.count(); i++) {
- if (m_names.at(i).compare(name) == 0) {
- desc = m_descriptions.at(i);
- break;
- }
- }
- return desc;
- }
-
- QString defaultInput() const
- {
- return m_names.at(0);
- }
-
- QString activeInput() const
- {
- return m_audioInput;
- }
-
-public Q_SLOTS:
-
- void setActiveInput(const QString& name)
- {
- m_audioInput = name;
- emit activeInputChanged(name);
- }
-
- void addInputs()
- {
- m_names << "device4";
- emit availableInputsChanged();
- }
-
- void removeInputs()
- {
- m_names.clear();
- emit availableInputsChanged();
- }
-
-private:
- QString m_audioInput;
- QList<QString> m_names;
- QList<QString> m_descriptions;
-};
-
-
-
-#endif // MOCKAUDIOINPUTSELECTOR_H
diff --git a/tests/auto/unit/qmultimedia_common/mockaudioprobecontrol.h b/tests/auto/unit/qmultimedia_common/mockaudioprobecontrol.h
deleted file mode 100644
index bb5279db9..000000000
--- a/tests/auto/unit/qmultimedia_common/mockaudioprobecontrol.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKAUDIOPROBECONTROL_H
-#define MOCKAUDIOPROBECONTROL_H
-
-#include "qmediaaudioprobecontrol.h"
-
-class MockAudioProbeControl : public QMediaAudioProbeControl
-{
- Q_OBJECT
-public:
- MockAudioProbeControl(QObject *parent):
- QMediaAudioProbeControl(parent)
- {
- }
-
- ~MockAudioProbeControl() {}
-
-private:
-};
-
-#endif // MOCKAUDIOPROBECONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockaudiorolecontrol.h b/tests/auto/unit/qmultimedia_common/mockaudiorolecontrol.h
deleted file mode 100644
index 06e914ba1..000000000
--- a/tests/auto/unit/qmultimedia_common/mockaudiorolecontrol.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKAUDIOROLECONTROL_H
-#define MOCKAUDIOROLECONTROL_H
-
-#include <qaudiorolecontrol.h>
-
-class MockAudioRoleControl : public QAudioRoleControl
-{
- friend class MockMediaPlayerService;
-
-public:
- MockAudioRoleControl()
- : QAudioRoleControl()
- , m_audioRole(QAudio::UnknownRole)
- {
- }
-
- QAudio::Role audioRole() const
- {
- return m_audioRole;
- }
-
- void setAudioRole(QAudio::Role role)
- {
- if (role != m_audioRole)
- emit audioRoleChanged(m_audioRole = role);
- }
-
- QList<QAudio::Role> supportedAudioRoles() const
- {
- return QList<QAudio::Role>() << QAudio::MusicRole
- << QAudio::AlarmRole
- << QAudio::NotificationRole;
- }
-
- QAudio::Role m_audioRole;
-};
-
-#endif // MOCKAUDIOROLECONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockavailabilitycontrol.h b/tests/auto/unit/qmultimedia_common/mockavailabilitycontrol.h
deleted file mode 100644
index 11e89abb6..000000000
--- a/tests/auto/unit/qmultimedia_common/mockavailabilitycontrol.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#ifndef MOCKAVAILABILITYCONTROL_H
-#define MOCKAVAILABILITYCONTROL_H
-
-#include <qmediaavailabilitycontrol.h>
-
-class MockAvailabilityControl : public QMediaAvailabilityControl
-{
- Q_OBJECT
-
-public:
- MockAvailabilityControl(QMultimedia::AvailabilityStatus available)
- : m_availability(available)
- {
-
- }
-
- QMultimedia::AvailabilityStatus availability() const
- {
- return m_availability;
- }
-
- void setAvailability(QMultimedia::AvailabilityStatus availability)
- {
- if (m_availability != availability) {
- m_availability = availability;
- emit availabilityChanged(availability);
- }
- }
-
- QMultimedia::AvailabilityStatus m_availability;
-};
-
-#endif // MOCKAVAILABILITYCONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockcamera.pri b/tests/auto/unit/qmultimedia_common/mockcamera.pri
deleted file mode 100644
index f6f97de1e..000000000
--- a/tests/auto/unit/qmultimedia_common/mockcamera.pri
+++ /dev/null
@@ -1,26 +0,0 @@
-# Camera related mock backend files
-INCLUDEPATH += $$PWD \
- ../../../../src/multimedia \
- ../../../../src/multimedia/video \
- ../../../../src/multimedia/camera
-
-HEADERS *= \
- ../qmultimedia_common/mockcameraservice.h \
- ../qmultimedia_common/mockcameraflashcontrol.h \
- ../qmultimedia_common/mockcameralockscontrol.h \
- ../qmultimedia_common/mockcamerafocuscontrol.h \
- ../qmultimedia_common/mockcamerazoomcontrol.h \
- ../qmultimedia_common/mockcameraimageprocessingcontrol.h \
- ../qmultimedia_common/mockcameraimagecapturecontrol.h \
- ../qmultimedia_common/mockcameraexposurecontrol.h \
- ../qmultimedia_common/mockcameracapturedestinationcontrol.h \
- ../qmultimedia_common/mockcameracapturebuffercontrol.h \
- ../qmultimedia_common/mockimageencodercontrol.h \
- ../qmultimedia_common/mockcameracontrol.h \
- ../qmultimedia_common/mockvideodeviceselectorcontrol.h \
- ../qmultimedia_common/mockcamerainfocontrol.h \
- ../qmultimedia_common/mockcameraviewfindersettingscontrol.h
-
-
-include(mockvideo.pri)
-
diff --git a/tests/auto/unit/qmultimedia_common/mockcameracapturebuffercontrol.h b/tests/auto/unit/qmultimedia_common/mockcameracapturebuffercontrol.h
deleted file mode 100644
index 77a758285..000000000
--- a/tests/auto/unit/qmultimedia_common/mockcameracapturebuffercontrol.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKCAMERACAPTUREBUFFERCONTROL_H
-#define MOCKCAMERACAPTUREBUFFERCONTROL_H
-
-#include "qcameracapturebufferformatcontrol.h"
-
-class MockCaptureBufferFormatControl : public QCameraCaptureBufferFormatControl
-{
- Q_OBJECT
-public:
- MockCaptureBufferFormatControl(QObject *parent = 0):
- QCameraCaptureBufferFormatControl(parent),
- m_format(QVideoFrame::Format_Jpeg)
- {
- }
-
- QList<QVideoFrame::PixelFormat> supportedBufferFormats() const
- {
- return QList<QVideoFrame::PixelFormat>()
- << QVideoFrame::Format_Jpeg
- << QVideoFrame::Format_RGB32
- << QVideoFrame::Format_AdobeDng;
- }
-
- QVideoFrame::PixelFormat bufferFormat() const
- {
- return m_format;
- }
-
- void setBufferFormat(QVideoFrame::PixelFormat format)
- {
- if (format != m_format && supportedBufferFormats().contains(format)) {
- m_format = format;
- emit bufferFormatChanged(m_format);
- }
- }
-
-private:
- QVideoFrame::PixelFormat m_format;
-};
-
-
-#endif // MOCKCAMERACAPTUREBUFFERCONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockcameracapturedestinationcontrol.h b/tests/auto/unit/qmultimedia_common/mockcameracapturedestinationcontrol.h
deleted file mode 100644
index adec9ea81..000000000
--- a/tests/auto/unit/qmultimedia_common/mockcameracapturedestinationcontrol.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKCAMERACAPTUREDESTINATIONCONTROL_H
-#define MOCKCAMERACAPTUREDESTINATIONCONTROL_H
-
-#include <QtMultimedia/qcameracapturedestinationcontrol.h>
-
-class MockCaptureDestinationControl : public QCameraCaptureDestinationControl
-{
- Q_OBJECT
-public:
- MockCaptureDestinationControl(QObject *parent = 0):
- QCameraCaptureDestinationControl(parent),
- m_destination(QCameraImageCapture::CaptureToFile)
- {
- }
-
- bool isCaptureDestinationSupported(QCameraImageCapture::CaptureDestinations destination) const
- {
- return destination == QCameraImageCapture::CaptureToBuffer ||
- destination == QCameraImageCapture::CaptureToFile;
- }
-
- QCameraImageCapture::CaptureDestinations captureDestination() const
- {
- return m_destination;
- }
-
- void setCaptureDestination(QCameraImageCapture::CaptureDestinations destination)
- {
- if (isCaptureDestinationSupported(destination) && destination != m_destination) {
- m_destination = destination;
- emit captureDestinationChanged(m_destination);
- }
- }
-
-private:
- QCameraImageCapture::CaptureDestinations m_destination;
-};
-
-#endif // MOCKCAMERACAPTUREDESTINATIONCONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockcameracontrol.h b/tests/auto/unit/qmultimedia_common/mockcameracontrol.h
deleted file mode 100644
index 95e9be7b3..000000000
--- a/tests/auto/unit/qmultimedia_common/mockcameracontrol.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKCAMERACONTROL_H
-#define MOCKCAMERACONTROL_H
-
-#include "qcameracontrol.h"
-
-class MockCameraControl : public QCameraControl
-{
- friend class MockCaptureControl;
- Q_OBJECT
-public:
- MockCameraControl(QObject *parent = 0):
- QCameraControl(parent),
- m_state(QCamera::UnloadedState),
- m_captureMode(QCamera::CaptureStillImage),
- m_status(QCamera::UnloadedStatus),
- m_propertyChangesSupported(false)
- {
- }
-
- ~MockCameraControl() {}
-
- void start() { m_state = QCamera::ActiveState; }
- virtual void stop() { m_state = QCamera::UnloadedState; }
- QCamera::State state() const { return m_state; }
- void setState(QCamera::State state) {
- if (m_state != state) {
- m_state = state;
-
- switch (state) {
- case QCamera::UnloadedState:
- m_status = QCamera::UnloadedStatus;
- break;
- case QCamera::LoadedState:
- m_status = QCamera::LoadedStatus;
- break;
- case QCamera::ActiveState:
- m_status = QCamera::ActiveStatus;
- break;
- default:
- emit error(QCamera::NotSupportedFeatureError, "State not supported.");
- return;
- }
-
- emit stateChanged(m_state);
- emit statusChanged(m_status);
- }
- }
-
- QCamera::Status status() const { return m_status; }
-
- QCamera::CaptureModes captureMode() const { return m_captureMode; }
- void setCaptureMode(QCamera::CaptureModes mode)
- {
- if (m_captureMode != mode) {
- if (m_state == QCamera::ActiveState && !m_propertyChangesSupported)
- return;
- m_captureMode = mode;
- emit captureModeChanged(mode);
- }
- }
-
- bool isCaptureModeSupported(QCamera::CaptureModes mode) const
- {
- return mode == QCamera::CaptureStillImage || mode == QCamera::CaptureVideo;
- }
-
- QCamera::LockTypes supportedLocks() const
- {
- return QCamera::LockExposure | QCamera::LockFocus | QCamera::LockWhiteBalance;
- }
-
- bool canChangeProperty(PropertyChangeType changeType, QCamera::Status status) const
- {
- Q_UNUSED(status);
- if (changeType == QCameraControl::ImageEncodingSettings && m_captureMode == QCamera::CaptureVideo)
- return true;
- else if (changeType== QCameraControl::VideoEncodingSettings)
- return true;
- else
- return m_propertyChangesSupported;
- }
-
- /* helper method to emit the signal error */
- void setError(QCamera::Error err, QString errorString)
- {
- emit error(err, errorString);
- }
-
- /* helper method to emit the signal statusChaged */
- void setStatus(QCamera::Status newStatus)
- {
- m_status = newStatus;
- emit statusChanged(newStatus);
- }
-
- QCamera::State m_state;
- QCamera::CaptureModes m_captureMode;
- QCamera::Status m_status;
- bool m_propertyChangesSupported;
-};
-
-
-
-#endif // MOCKCAMERACONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockcameraexposurecontrol.h b/tests/auto/unit/qmultimedia_common/mockcameraexposurecontrol.h
deleted file mode 100644
index 1b2372cf5..000000000
--- a/tests/auto/unit/qmultimedia_common/mockcameraexposurecontrol.h
+++ /dev/null
@@ -1,280 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKCAMERAEXPOSURECONTROL_H
-#define MOCKCAMERAEXPOSURECONTROL_H
-
-#include "qcameraexposurecontrol.h"
-
-class MockCameraExposureControl : public QCameraExposureControl
-{
- Q_OBJECT
-public:
- MockCameraExposureControl(QObject *parent = 0):
- QCameraExposureControl(parent),
- m_aperture(2.8),
- m_shutterSpeed(0.01),
- m_isoSensitivity(100),
- m_meteringMode(QCameraExposure::MeteringMatrix),
- m_exposureCompensation(0),
- m_exposureMode(QCameraExposure::ExposureAuto),
- m_flashMode(QCameraExposure::FlashAuto),
- m_spot(0.5, 0.5)
- {
- m_isoRanges << 100 << 200 << 400 << 800;
- m_apertureRanges << 2.8 << 4.0 << 5.6 << 8.0 << 11.0 << 16.0;
- m_shutterRanges << 0.001 << 0.01 << 0.1 << 1.0;
- m_exposureRanges << -2.0 << 2.0;
-
- const QCameraExposure::ExposureMode exposureModes[] = {
- QCameraExposure::ExposureAuto,
- QCameraExposure::ExposureManual,
- QCameraExposure::ExposureBacklight,
- QCameraExposure::ExposureNight,
- QCameraExposure::ExposureSpotlight,
- QCameraExposure::ExposureSports,
- QCameraExposure::ExposureSnow,
- QCameraExposure:: ExposureLargeAperture,
- QCameraExposure::ExposureSmallAperture,
- QCameraExposure::ExposurePortrait,
- QCameraExposure::ExposureModeVendor,
- QCameraExposure::ExposureBeach,
- };
-
- for (QCameraExposure::ExposureMode mode : exposureModes)
- m_exposureModes << QVariant::fromValue<QCameraExposure::ExposureMode>(mode);
-
- m_meteringModes << QVariant::fromValue<QCameraExposure::MeteringMode>(QCameraExposure::MeteringMatrix)
- << QVariant::fromValue<QCameraExposure::MeteringMode>(QCameraExposure::MeteringSpot);
- }
-
- ~MockCameraExposureControl() {}
-
- bool isParameterSupported(ExposureParameter parameter) const
- {
- switch (parameter) {
- case QCameraExposureControl::ExposureMode:
- case QCameraExposureControl::MeteringMode:
- case QCameraExposureControl::ExposureCompensation:
- case QCameraExposureControl::ISO:
- case QCameraExposureControl::Aperture:
- case QCameraExposureControl::ShutterSpeed:
- case QCameraExposureControl::SpotMeteringPoint:
- return true;
- default:
- return false;
- }
- }
-
- QVariant requestedValue(ExposureParameter param) const
- {
- return m_requestedParameters.value(param);
- }
-
- QVariant actualValue(ExposureParameter param) const
- {
- switch (param) {
- case QCameraExposureControl::ExposureMode:
- return QVariant::fromValue<QCameraExposure::ExposureMode>(m_exposureMode);
- case QCameraExposureControl::MeteringMode:
- return QVariant::fromValue<QCameraExposure::MeteringMode>(m_meteringMode);
- case QCameraExposureControl::ExposureCompensation:
- return QVariant(m_exposureCompensation);
- case QCameraExposureControl::ISO:
- return QVariant(m_isoSensitivity);
- case QCameraExposureControl::Aperture:
- return QVariant(m_aperture);
- case QCameraExposureControl::ShutterSpeed:
- return QVariant(m_shutterSpeed);
- case QCameraExposureControl::SpotMeteringPoint:
- return QVariant(m_spot);
- default:
- return QVariant();
- }
- }
-
- QVariantList supportedParameterRange(ExposureParameter parameter, bool *continuous) const
- {
- *continuous = false;
-
- QVariantList res;
- switch (parameter) {
- case QCameraExposureControl::ExposureCompensation:
- *continuous = true;
- return m_exposureRanges;
- case QCameraExposureControl::ISO:
- return m_isoRanges;
- case QCameraExposureControl::Aperture:
- *continuous = true;
- return m_apertureRanges;
- case QCameraExposureControl::ShutterSpeed:
- *continuous = true;
- return m_shutterRanges;
- case QCameraExposureControl::ExposureMode:
- return m_exposureModes;
- case QCameraExposureControl::MeteringMode:
- return m_meteringModes;
- default:
- break;
- }
-
- return res;
- }
-
- // Added valueChanged and parameterRangeChanged signal
- bool setValue(ExposureParameter param, const QVariant& value)
- {
- if (!isParameterSupported(param))
- return false;
-
- if (m_requestedParameters.value(param) != value) {
- m_requestedParameters.insert(param, value);
- emit requestedValueChanged(param);
- }
-
- switch (param) {
- case QCameraExposureControl::ExposureMode:
- {
- QCameraExposure::ExposureMode mode = value.value<QCameraExposure::ExposureMode>();
- if (mode != m_exposureMode && m_exposureModes.contains(value)) {
- m_exposureMode = mode;
- emit actualValueChanged(param);
- }
- }
- break;
- case QCameraExposureControl::MeteringMode:
- {
- QCameraExposure::MeteringMode mode = value.value<QCameraExposure::MeteringMode>();
- if (mode != m_meteringMode && m_meteringModes.contains(value)) {
- m_meteringMode = mode;
- emit actualValueChanged(param);
- }
- }
- break;
- case QCameraExposureControl::ExposureCompensation:
- {
- m_res.clear();
- m_res << -4.0 << 4.0;
- qreal exposureCompensationlocal = qBound<qreal>(-2.0, value.toReal(), 2.0);
- if (actualValue(param).toReal() != exposureCompensationlocal) {
- m_exposureCompensation = exposureCompensationlocal;
- emit actualValueChanged(param);
- }
-
- if (m_exposureRanges.last().toReal() != m_res.last().toReal()) {
- m_exposureRanges.clear();
- m_exposureRanges = m_res;
- emit parameterRangeChanged(param);
- }
- }
- break;
- case QCameraExposureControl::ISO:
- {
- m_res.clear();
- m_res << 20 << 50;
- qreal exposureCompensationlocal = 100*qRound(qBound(100, value.toInt(), 800)/100.0);
- if (actualValue(param).toReal() != exposureCompensationlocal) {
- m_isoSensitivity = exposureCompensationlocal;
- emit actualValueChanged(param);
- }
-
- if (m_isoRanges.last().toInt() != m_res.last().toInt()) {
- m_isoRanges.clear();
- m_isoRanges = m_res;
- emit parameterRangeChanged(param);
- }
- }
- break;
- case QCameraExposureControl::Aperture:
- {
- m_res.clear();
- m_res << 12.0 << 18.0 << 20.0;
- qreal exposureCompensationlocal = qBound<qreal>(2.8, value.toReal(), 16.0);
- if (actualValue(param).toReal() != exposureCompensationlocal) {
- m_aperture = exposureCompensationlocal;
- emit actualValueChanged(param);
- }
-
- if (m_apertureRanges.last().toReal() != m_res.last().toReal()) {
- m_apertureRanges.clear();
- m_apertureRanges = m_res;
- emit parameterRangeChanged(param);
- }
- }
- break;
- case QCameraExposureControl::ShutterSpeed:
- {
- m_res.clear();
- m_res << 0.12 << 1.0 << 2.0;
- qreal exposureCompensationlocal = qBound<qreal>(0.001, value.toReal(), 1.0);
- if (actualValue(param).toReal() != exposureCompensationlocal) {
- m_shutterSpeed = exposureCompensationlocal;
- emit actualValueChanged(param);
- }
-
- if (m_shutterRanges.last().toReal() != m_res.last().toReal()) {
- m_shutterRanges.clear();
- m_shutterRanges = m_res;
- emit parameterRangeChanged(param);
- }
- }
- break;
-
- case QCameraExposureControl::SpotMeteringPoint:
- {
- static QRectF valid(0, 0, 1, 1);
- if (valid.contains(value.toPointF())) {
- m_spot = value.toPointF();
- emit actualValueChanged(param);
- return true;
- }
- return false;
- }
-
- default:
- return false;
- }
-
- return true;
- }
-
-private:
- qreal m_aperture;
- qreal m_shutterSpeed;
- int m_isoSensitivity;
- QCameraExposure::MeteringMode m_meteringMode;
- qreal m_exposureCompensation;
- QCameraExposure::ExposureMode m_exposureMode;
- QCameraExposure::FlashModes m_flashMode;
- QVariantList m_isoRanges,m_apertureRanges, m_shutterRanges, m_exposureRanges, m_res, m_exposureModes, m_meteringModes;
- QPointF m_spot;
-
- QMap<QCameraExposureControl::ExposureParameter, QVariant> m_requestedParameters;
-};
-
-#endif // MOCKCAMERAEXPOSURECONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockcameraflashcontrol.h b/tests/auto/unit/qmultimedia_common/mockcameraflashcontrol.h
deleted file mode 100644
index 96e2ebc52..000000000
--- a/tests/auto/unit/qmultimedia_common/mockcameraflashcontrol.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKCAMERAFLASHCONTROL_H
-#define MOCKCAMERAFLASHCONTROL_H
-
-#include "qcameraflashcontrol.h"
-
-class MockCameraFlashControl : public QCameraFlashControl
-{
- Q_OBJECT
-public:
- MockCameraFlashControl(QObject *parent = 0):
- QCameraFlashControl(parent),
- m_flashMode(QCameraExposure::FlashAuto)
- {
- }
-
- ~MockCameraFlashControl() {}
-
- QCameraExposure::FlashModes flashMode() const
- {
- return m_flashMode;
- }
-
- void setFlashMode(QCameraExposure::FlashModes mode)
- {
- if (isFlashModeSupported(mode)) {
- m_flashMode = mode;
- }
- emit flashReady(true);
- }
- //Setting the values for Flash mode
-
- bool isFlashModeSupported(QCameraExposure::FlashModes mode) const
- {
- return (mode & (QCameraExposure::FlashAuto | QCameraExposure::FlashOff | QCameraExposure::FlashOn |
- QCameraExposure::FlashFill |QCameraExposure::FlashTorch |QCameraExposure::FlashSlowSyncFrontCurtain |
- QCameraExposure::FlashRedEyeReduction));
- }
-
- bool isFlashReady() const
- {
- return true;
- }
-
-private:
- QCameraExposure::FlashModes m_flashMode;
-};
-
-#endif // MOCKCAMERAFLASHCONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockcamerafocuscontrol.h b/tests/auto/unit/qmultimedia_common/mockcamerafocuscontrol.h
deleted file mode 100644
index 579f70f20..000000000
--- a/tests/auto/unit/qmultimedia_common/mockcamerafocuscontrol.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKCAMERAFOCUSCONTROL_H
-#define MOCKCAMERAFOCUSCONTROL_H
-
-#include "qcamerafocuscontrol.h"
-#include "qcamerafocus.h"
-
-class MockCameraFocusControl : public QCameraFocusControl
-{
- Q_OBJECT
-public:
- MockCameraFocusControl(QObject *parent = 0):
- QCameraFocusControl(parent),
- m_focusMode(QCameraFocus::AutoFocus),
- m_focusPointMode(QCameraFocus::FocusPointAuto),
- m_focusPoint(0.5, 0.5)
- {
- m_zones << QCameraFocusZone(QRectF(0.45, 0.45, 0.1, 0.1));
- }
-
- ~MockCameraFocusControl() {}
-
- QCameraFocus::FocusModes focusMode() const
- {
- return m_focusMode;
- }
-
- void setFocusMode(QCameraFocus::FocusModes mode)
- {
- if (isFocusModeSupported(mode))
- m_focusMode = mode;
- }
-
- bool isFocusModeSupported(QCameraFocus::FocusModes mode) const
- {
- return mode == QCameraFocus::AutoFocus || mode == QCameraFocus::ContinuousFocus;
- }
-
- QCameraFocus::FocusPointMode focusPointMode() const
- {
- return m_focusPointMode;
- }
-
- void setFocusPointMode(QCameraFocus::FocusPointMode mode)
- {
- if (isFocusPointModeSupported(mode))
- m_focusPointMode = mode;
- }
-
- bool isFocusPointModeSupported(QCameraFocus::FocusPointMode mode) const
- {
- switch (mode) {
- case QCameraFocus::FocusPointAuto:
- case QCameraFocus::FocusPointCenter:
- case QCameraFocus::FocusPointCustom:
- return true;
- default:
- return false;
- }
- }
-
- QPointF customFocusPoint() const
- {
- return m_focusPoint;
- }
-
- void setCustomFocusPoint(const QPointF &point)
- {
- m_focusPoint = point;
- focusZonesChange(0.50, 0.50, 0.3, 0.3);
- }
-
- QCameraFocusZoneList focusZones() const
- {
- return m_zones;
- }
-
- // helper function to emit Focus Zones Changed signals
- void focusZonesChange(qreal left, qreal top, qreal width, qreal height)
- {
- QCameraFocusZone myZone(QRectF(left, top, width, height));
- if (m_zones.last().area() != myZone.area()) {
- m_zones.clear();
- m_zones << myZone;
- emit focusZonesChanged();
- }
- }
-
-private:
- QCameraFocus::FocusModes m_focusMode;
- QCameraFocus::FocusPointMode m_focusPointMode;
- QPointF m_focusPoint;
- // to emit focus zone changed signal
- QCameraFocusZoneList m_zones;
-};
-
-#endif // MOCKCAMERAFOCUSCONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockcameraimagecapturecontrol.h b/tests/auto/unit/qmultimedia_common/mockcameraimagecapturecontrol.h
deleted file mode 100644
index 6aa793a24..000000000
--- a/tests/auto/unit/qmultimedia_common/mockcameraimagecapturecontrol.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKCAMERACAPTURECONTROL_H
-#define MOCKCAMERACAPTURECONTROL_H
-
-#include <QDateTime>
-#include <QTimer>
-#include <QtMultimedia/qmediametadata.h>
-
-#include "qcameraimagecapturecontrol.h"
-#include "qcameracontrol.h"
-#include "mockcameracontrol.h"
-
-class MockCaptureControl : public QCameraImageCaptureControl
-{
- Q_OBJECT
-public:
- MockCaptureControl(MockCameraControl *cameraControl, QObject *parent = 0)
- : QCameraImageCaptureControl(parent), m_cameraControl(cameraControl), m_captureRequest(0), m_ready(true), m_captureCanceled(false)
- {
- }
-
- ~MockCaptureControl()
- {
- }
-
- QCameraImageCapture::DriveMode driveMode() const { return QCameraImageCapture::SingleImageCapture; }
- void setDriveMode(QCameraImageCapture::DriveMode) {}
-
- bool isReadyForCapture() const { return m_ready && m_cameraControl->state() == QCamera::ActiveState; }
-
- int capture(const QString &fileName)
- {
- if (isReadyForCapture()) {
- m_fileName = fileName;
- m_captureRequest++;
- emit readyForCaptureChanged(m_ready = false);
- QTimer::singleShot(5, this, SLOT(captured()));
- return m_captureRequest;
- } else {
- emit error(-1, QCameraImageCapture::NotReadyError,
- QLatin1String("Could not capture in stopped state"));
- }
-
- return -1;
- }
-
- void cancelCapture()
- {
- m_captureCanceled = true;
- }
-
-private Q_SLOTS:
- void captured()
- {
- if (!m_captureCanceled) {
- emit imageCaptured(m_captureRequest, QImage());
-
- emit imageMetadataAvailable(m_captureRequest,
- QMediaMetaData::FocalLengthIn35mmFilm,
- QVariant(50));
-
- emit imageMetadataAvailable(m_captureRequest,
- QMediaMetaData::DateTimeOriginal,
- QVariant(QDateTime::currentDateTime()));
-
- emit imageMetadataAvailable(m_captureRequest,
- QLatin1String("Answer to the Ultimate Question of Life, the Universe, and Everything"),
- QVariant(42));
- }
-
- if (!m_ready)
- {
- emit readyForCaptureChanged(m_ready = true);
- emit imageExposed(m_captureRequest);
- }
-
- if (!m_captureCanceled)
- emit imageSaved(m_captureRequest, m_fileName);
-
- m_captureCanceled = false;
- }
-
-private:
- MockCameraControl *m_cameraControl;
- QString m_fileName;
- int m_captureRequest;
- bool m_ready;
- bool m_captureCanceled;
-};
-
-#endif // MOCKCAMERACAPTURECONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockcameraimageprocessingcontrol.h b/tests/auto/unit/qmultimedia_common/mockcameraimageprocessingcontrol.h
deleted file mode 100644
index 6f315c69e..000000000
--- a/tests/auto/unit/qmultimedia_common/mockcameraimageprocessingcontrol.h
+++ /dev/null
@@ -1,150 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKCAMERAIMAGEPROCESSINGCONTROL_H
-#define MOCKCAMERAIMAGEPROCESSINGCONTROL_H
-
-#include "qcameraimageprocessingcontrol.h"
-
-class MockImageProcessingControl : public QCameraImageProcessingControl
-{
- Q_OBJECT
-public:
- MockImageProcessingControl(QObject *parent = 0)
- : QCameraImageProcessingControl(parent)
- {
- m_supportedWhiteBalance.insert(QCameraImageProcessing::WhiteBalanceAuto);
- }
-
- QCameraImageProcessing::WhiteBalanceMode whiteBalanceMode() const
- {
- return m_whiteBalanceMode;
- }
- void setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceMode mode)
- {
- m_whiteBalanceMode = mode;
- }
-
- bool isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceMode mode) const
- {
- return m_supportedWhiteBalance.contains(mode);
- }
-
- void setSupportedWhiteBalanceModes(QSet<QCameraImageProcessing::WhiteBalanceMode> modes)
- {
- m_supportedWhiteBalance = modes;
- }
-
- bool isParameterSupported(ProcessingParameter parameter) const
- {
- switch (parameter)
- {
- case ContrastAdjustment:
- case BrightnessAdjustment:
- case SharpeningAdjustment:
- case SaturationAdjustment:
- case DenoisingAdjustment:
- case ColorTemperature:
- case WhiteBalancePreset:
- return true;
- default :
- return false;
- }
- }
-
- bool isParameterValueSupported(ProcessingParameter parameter, const QVariant &value) const
- {
- if (parameter != WhiteBalancePreset)
- return false;
-
- return m_supportedWhiteBalance.contains(value.value<QCameraImageProcessing::WhiteBalanceMode>());
- }
-
- QVariant parameter(ProcessingParameter parameter) const
- {
- switch (parameter) {
- case ContrastAdjustment:
- return m_contrast;
- case SaturationAdjustment:
- return m_saturation;
- case BrightnessAdjustment:
- return m_brightness;
- case SharpeningAdjustment:
- return m_sharpeningLevel;
- case DenoisingAdjustment:
- return m_denoising;
- case ColorTemperature:
- return m_manualWhiteBalance;
- case WhiteBalancePreset:
- return QVariant::fromValue<QCameraImageProcessing::WhiteBalanceMode>(m_whiteBalanceMode);
- default:
- return QVariant();
- }
- }
- void setParameter(ProcessingParameter parameter, const QVariant &value)
- {
- switch (parameter) {
- case ContrastAdjustment:
- m_contrast = value;
- break;
- case SaturationAdjustment:
- m_saturation = value;
- break;
- case BrightnessAdjustment:
- m_brightness = value;
- break;
- case SharpeningAdjustment:
- m_sharpeningLevel = value;
- break;
- case DenoisingAdjustment:
- m_denoising = value;
- break;
- case ColorTemperature:
- m_manualWhiteBalance = value;
- break;
- case WhiteBalancePreset:
- m_whiteBalanceMode = value.value<QCameraImageProcessing::WhiteBalanceMode>();
- break;
- default:
- break;
- }
- }
-
-
-private:
- QCameraImageProcessing::WhiteBalanceMode m_whiteBalanceMode;
- QSet<QCameraImageProcessing::WhiteBalanceMode> m_supportedWhiteBalance;
- QVariant m_manualWhiteBalance;
- QVariant m_contrast;
- QVariant m_sharpeningLevel;
- QVariant m_saturation;
- QVariant m_brightness;
- QVariant m_denoising;
-};
-
-#endif // MOCKCAMERAIMAGEPROCESSINGCONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockcamerainfocontrol.h b/tests/auto/unit/qmultimedia_common/mockcamerainfocontrol.h
deleted file mode 100644
index 359bb7a5c..000000000
--- a/tests/auto/unit/qmultimedia_common/mockcamerainfocontrol.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKCAMERAINFOCONTROL_H
-#define MOCKCAMERAINFOCONTROL_H
-
-#include <qcamerainfocontrol.h>
-
-class MockCameraInfoControl : public QCameraInfoControl
-{
- Q_OBJECT
-public:
- MockCameraInfoControl(QObject *parent)
- : QCameraInfoControl(parent)
- {
- }
-
- ~MockCameraInfoControl() { }
-
- QCamera::Position cameraPosition(const QString &deviceName) const
- {
- return position(deviceName.toLatin1());
- }
-
- int cameraOrientation(const QString &deviceName) const
- {
- return orientation(deviceName.toLatin1());
- }
-
- static QCamera::Position position(const QByteArray &camera)
- {
- if (camera == "backcamera")
- return QCamera::BackFace;
- else
- return QCamera::UnspecifiedPosition;
- }
-
- static int orientation(const QByteArray &camera)
- {
- if (camera == "backcamera")
- return 90;
- else
- return 0;
- }
-};
-
-#endif // MOCKCAMERAINFOCONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockcameralockscontrol.h b/tests/auto/unit/qmultimedia_common/mockcameralockscontrol.h
deleted file mode 100644
index a520ad055..000000000
--- a/tests/auto/unit/qmultimedia_common/mockcameralockscontrol.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKCAMERALOCKCONTROL_H
-#define MOCKCAMERALOCKCONTROL_H
-
-#include <QTimer>
-#include "qcameralockscontrol.h"
-
-class MockCameraLocksControl : public QCameraLocksControl
-{
- Q_OBJECT
-public:
- MockCameraLocksControl(QObject *parent = 0):
- QCameraLocksControl(parent),
- m_focusLock(QCamera::Unlocked),
- m_exposureLock(QCamera::Unlocked)
- {
- }
-
- ~MockCameraLocksControl() {}
-
- QCamera::LockTypes supportedLocks() const
- {
- return QCamera::LockExposure | QCamera::LockFocus;
- }
-
- QCamera::LockStatus lockStatus(QCamera::LockType lock) const
- {
- switch (lock) {
- case QCamera::LockExposure:
- return m_exposureLock;
- case QCamera::LockFocus:
- return m_focusLock;
- default:
- return QCamera::Unlocked;
- }
- }
-
- void searchAndLock(QCamera::LockTypes locks)
- {
- if (locks & QCamera::LockExposure) {
- QCamera::LockStatus newStatus = locks & QCamera::LockFocus ? QCamera::Searching : QCamera::Locked;
-
- if (newStatus != m_exposureLock)
- emit lockStatusChanged(QCamera::LockExposure,
- m_exposureLock = newStatus,
- QCamera::UserRequest);
- }
-
- if (locks & QCamera::LockFocus) {
- emit lockStatusChanged(QCamera::LockFocus,
- m_focusLock = QCamera::Searching,
- QCamera::UserRequest);
-
- QTimer::singleShot(5, this, SLOT(focused()));
- }
- }
-
- void unlock(QCamera::LockTypes locks) {
- if (locks & QCamera::LockFocus && m_focusLock != QCamera::Unlocked) {
- emit lockStatusChanged(QCamera::LockFocus,
- m_focusLock = QCamera::Unlocked,
- QCamera::UserRequest);
- }
-
- if (locks & QCamera::LockExposure && m_exposureLock != QCamera::Unlocked) {
- emit lockStatusChanged(QCamera::LockExposure,
- m_exposureLock = QCamera::Unlocked,
- QCamera::UserRequest);
- }
- }
-
- /* helper method to emit the signal with LockChangeReason */
- void setLockChangeReason (QCamera::LockChangeReason lockChangeReason)
- {
- emit lockStatusChanged(QCamera::NoLock,
- QCamera::Unlocked,
- lockChangeReason);
-
- }
-
-private slots:
- void focused()
- {
- if (m_focusLock == QCamera::Searching) {
- emit lockStatusChanged(QCamera::LockFocus,
- m_focusLock = QCamera::Locked,
- QCamera::UserRequest);
- }
-
- if (m_exposureLock == QCamera::Searching) {
- emit lockStatusChanged(QCamera::LockExposure,
- m_exposureLock = QCamera::Locked,
- QCamera::UserRequest);
- }
- }
-
-
-private:
- QCamera::LockStatus m_focusLock;
- QCamera::LockStatus m_exposureLock;
-};
-
-
-#endif // MOCKCAMERALOCKCONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockcameraservice.h b/tests/auto/unit/qmultimedia_common/mockcameraservice.h
deleted file mode 100644
index d6612ddc3..000000000
--- a/tests/auto/unit/qmultimedia_common/mockcameraservice.h
+++ /dev/null
@@ -1,198 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKCAMERASERVICE_H
-#define MOCKCAMERASERVICE_H
-
-#include "qmediaservice.h"
-#include "../qmultimedia_common/mockcameraflashcontrol.h"
-#include "../qmultimedia_common/mockcameralockscontrol.h"
-#include "../qmultimedia_common/mockcamerafocuscontrol.h"
-#include "../qmultimedia_common/mockcamerazoomcontrol.h"
-#include "../qmultimedia_common/mockcameraimageprocessingcontrol.h"
-#include "../qmultimedia_common/mockcameraimagecapturecontrol.h"
-#include "../qmultimedia_common/mockcameraexposurecontrol.h"
-#include "../qmultimedia_common/mockcameracapturedestinationcontrol.h"
-#include "../qmultimedia_common/mockcameracapturebuffercontrol.h"
-#include "../qmultimedia_common/mockimageencodercontrol.h"
-#include "../qmultimedia_common/mockcameracontrol.h"
-#include "../qmultimedia_common/mockvideosurface.h"
-#include "../qmultimedia_common/mockvideorenderercontrol.h"
-#include "../qmultimedia_common/mockvideowindowcontrol.h"
-#include "../qmultimedia_common/mockvideodeviceselectorcontrol.h"
-#include "../qmultimedia_common/mockcamerainfocontrol.h"
-#include "../qmultimedia_common/mockcameraviewfindersettingscontrol.h"
-
-class MockSimpleCameraService : public QMediaService
-{
- Q_OBJECT
-
-public:
- MockSimpleCameraService(): QMediaService(0)
- {
- mockControl = new MockCameraControl(this);
- }
-
- ~MockSimpleCameraService()
- {
- }
-
- QMediaControl* requestControl(const char *iid)
- {
- if (qstrcmp(iid, QCameraControl_iid) == 0)
- return mockControl;
- return 0;
- }
-
- void releaseControl(QMediaControl*) {}
-
- MockCameraControl *mockControl;
-};
-
-
-class MockCameraService : public QMediaService
-{
- Q_OBJECT
-
-public:
- MockCameraService(): QMediaService(0)
- {
- mockControl = new MockCameraControl(this);
- mockLocksControl = new MockCameraLocksControl(this);
- mockExposureControl = new MockCameraExposureControl(this);
- mockFlashControl = new MockCameraFlashControl(this);
- mockFocusControl = new MockCameraFocusControl(this);
- mockZoomControl = new MockCameraZoomControl(this);
- mockCaptureControl = new MockCaptureControl(mockControl, this);
- mockCaptureBufferControl = new MockCaptureBufferFormatControl(this);
- mockCaptureDestinationControl = new MockCaptureDestinationControl(this);
- mockImageProcessingControl = new MockImageProcessingControl(this);
- mockImageEncoderControl = new MockImageEncoderControl(this);
- rendererControl = new MockVideoRendererControl(this);
- windowControl = new MockVideoWindowControl(this);
- mockVideoDeviceSelectorControl = new MockVideoDeviceSelectorControl(this);
- mockCameraInfoControl = new MockCameraInfoControl(this);
- mockViewfinderSettingsControl = new MockCameraViewfinderSettingsControl(this);
- rendererRef = 0;
- windowRef = 0;
- }
-
- ~MockCameraService()
- {
- }
-
- QMediaControl* requestControl(const char *iid)
- {
- if (qstrcmp(iid, QCameraControl_iid) == 0)
- return mockControl;
-
- if (qstrcmp(iid, QCameraLocksControl_iid) == 0)
- return mockLocksControl;
-
- if (qstrcmp(iid, QCameraExposureControl_iid) == 0)
- return mockExposureControl;
-
- if (qstrcmp(iid, QCameraFlashControl_iid) == 0)
- return mockFlashControl;
-
- if (qstrcmp(iid, QCameraFocusControl_iid) == 0)
- return mockFocusControl;
-
- if (qstrcmp(iid, QCameraZoomControl_iid) == 0)
- return mockZoomControl;
-
- if (qstrcmp(iid, QCameraImageCaptureControl_iid) == 0)
- return mockCaptureControl;
-
- if (qstrcmp(iid, QCameraCaptureBufferFormatControl_iid) == 0)
- return mockCaptureBufferControl;
-
- if (qstrcmp(iid, QCameraCaptureDestinationControl_iid) == 0)
- return mockCaptureDestinationControl;
-
- if (qstrcmp(iid, QCameraImageProcessingControl_iid) == 0)
- return mockImageProcessingControl;
-
- if (qstrcmp(iid, QImageEncoderControl_iid) == 0)
- return mockImageEncoderControl;
-
- if (qstrcmp(iid, QVideoDeviceSelectorControl_iid) == 0)
- return mockVideoDeviceSelectorControl;
-
- if (qstrcmp(iid, QCameraInfoControl_iid) == 0)
- return mockCameraInfoControl;
-
- if (qstrcmp(iid, QVideoRendererControl_iid) == 0) {
- if (rendererRef == 0) {
- rendererRef += 1;
- return rendererControl;
- }
- }
- if (qstrcmp(iid, QVideoWindowControl_iid) == 0) {
- if (windowRef == 0) {
- windowRef += 1;
- return windowControl;
- }
- }
-
- if (qstrcmp(iid, QCameraViewfinderSettingsControl2_iid) == 0) {
- return mockViewfinderSettingsControl;
- }
-
- return 0;
- }
-
- void releaseControl(QMediaControl *control)
- {
- if (control == rendererControl)
- rendererRef -= 1;
- if (control == windowControl)
- windowRef -= 1;
- }
-
- MockCameraControl *mockControl;
- MockCameraLocksControl *mockLocksControl;
- MockCaptureControl *mockCaptureControl;
- MockCaptureBufferFormatControl *mockCaptureBufferControl;
- MockCaptureDestinationControl *mockCaptureDestinationControl;
- MockCameraExposureControl *mockExposureControl;
- MockCameraFlashControl *mockFlashControl;
- MockCameraFocusControl *mockFocusControl;
- MockCameraZoomControl *mockZoomControl;
- MockImageProcessingControl *mockImageProcessingControl;
- MockImageEncoderControl *mockImageEncoderControl;
- MockVideoRendererControl *rendererControl;
- MockVideoWindowControl *windowControl;
- MockVideoDeviceSelectorControl *mockVideoDeviceSelectorControl;
- MockCameraInfoControl *mockCameraInfoControl;
- MockCameraViewfinderSettingsControl *mockViewfinderSettingsControl;
- int rendererRef;
- int windowRef;
-};
-
-#endif // MOCKCAMERASERVICE_H
diff --git a/tests/auto/unit/qmultimedia_common/mockcameraviewfindersettingscontrol.h b/tests/auto/unit/qmultimedia_common/mockcameraviewfindersettingscontrol.h
deleted file mode 100644
index 88b717ed1..000000000
--- a/tests/auto/unit/qmultimedia_common/mockcameraviewfindersettingscontrol.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKCAMERAVIEWFINDERSETTINGSCONTROL_H
-#define MOCKCAMERAVIEWFINDERSETTINGSCONTROL_H
-
-#include "qcameraviewfindersettingscontrol.h"
-
-class MockCameraViewfinderSettingsControl : public QCameraViewfinderSettingsControl2
-{
- Q_OBJECT
-public:
- MockCameraViewfinderSettingsControl(QObject *parent = 0):
- QCameraViewfinderSettingsControl2(parent)
- {
- QCameraViewfinderSettings s;
- s.setResolution(640, 480);
- s.setMinimumFrameRate(30);
- s.setMaximumFrameRate(30);
- s.setPixelFormat(QVideoFrame::Format_NV12);
- s.setPixelAspectRatio(1, 1);
- supportedSettings.append(s);
-
- s.setResolution(1280, 720);
- s.setMinimumFrameRate(10);
- s.setMaximumFrameRate(10);
- s.setPixelFormat(QVideoFrame::Format_NV12);
- s.setPixelAspectRatio(1, 1);
- supportedSettings.append(s);
-
- s.setResolution(1920, 1080);
- s.setMinimumFrameRate(5);
- s.setMaximumFrameRate(10);
- s.setPixelFormat(QVideoFrame::Format_BGR32);
- s.setPixelAspectRatio(2, 1);
- supportedSettings.append(s);
-
- s.setResolution(1280, 720);
- s.setMinimumFrameRate(10);
- s.setMaximumFrameRate(10);
- s.setPixelFormat(QVideoFrame::Format_YV12);
- s.setPixelAspectRatio(1, 1);
- supportedSettings.append(s);
-
- s.setResolution(1280, 720);
- s.setMinimumFrameRate(30);
- s.setMaximumFrameRate(30);
- s.setPixelFormat(QVideoFrame::Format_YV12);
- s.setPixelAspectRatio(1, 1);
- supportedSettings.append(s);
-
- s.setResolution(320, 240);
- s.setMinimumFrameRate(30);
- s.setMaximumFrameRate(30);
- s.setPixelFormat(QVideoFrame::Format_NV12);
- s.setPixelAspectRatio(1, 1);
- supportedSettings.append(s);
- }
-
- ~MockCameraViewfinderSettingsControl() {}
-
- QCameraViewfinderSettings viewfinderSettings() const
- {
- return settings;
- }
-
- void setViewfinderSettings(const QCameraViewfinderSettings &s)
- {
- settings = s;
- }
-
- QList<QCameraViewfinderSettings> supportedViewfinderSettings() const
- {
- return supportedSettings;
- }
-
- QCameraViewfinderSettings settings;
- QList<QCameraViewfinderSettings> supportedSettings;
-};
-
-#endif // MOCKCAMERAVIEWFINDERSETTINGSCONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockcamerazoomcontrol.h b/tests/auto/unit/qmultimedia_common/mockcamerazoomcontrol.h
deleted file mode 100644
index 9a56fd2cd..000000000
--- a/tests/auto/unit/qmultimedia_common/mockcamerazoomcontrol.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKCAMERAZOOMCONTROL_H
-#define MOCKCAMERAZOOMCONTROL_H
-
-#include "qcamerazoomcontrol.h"
-
-class MockCameraZoomControl : public QCameraZoomControl
-{
- Q_OBJECT
-public:
- MockCameraZoomControl(QObject *parent = 0):
- QCameraZoomControl(parent),
- m_opticalZoom(1.0),
- m_digitalZoom(1.0),
- m_maxOpticalZoom(3.0),
- m_maxDigitalZoom(4.0)
-
- {
- }
-
- ~MockCameraZoomControl() {}
-
- qreal maximumOpticalZoom() const
- {
- return m_maxOpticalZoom;
- }
-
- qreal maximumDigitalZoom() const
- {
- return m_maxDigitalZoom;
- }
-
- qreal currentOpticalZoom() const
- {
- return m_opticalZoom;
- }
-
- qreal currentDigitalZoom() const
- {
- return m_digitalZoom;
- }
-
- qreal requestedOpticalZoom() const
- {
- return m_opticalZoom;
- }
-
- qreal requestedDigitalZoom() const
- {
- return m_digitalZoom;
- }
-
- void zoomTo(qreal optical, qreal digital)
- {
- optical = qBound<qreal>(1.0, optical, maximumOpticalZoom());
- digital = qBound<qreal>(1.0, digital, maximumDigitalZoom());
-
- if (!qFuzzyCompare(digital, m_digitalZoom)) {
- m_digitalZoom = digital;
- emit requestedDigitalZoomChanged(m_digitalZoom);
- emit currentDigitalZoomChanged(m_digitalZoom);
- }
-
- if (!qFuzzyCompare(optical, m_opticalZoom)) {
- m_opticalZoom = optical;
- emit requestedOpticalZoomChanged(m_opticalZoom);
- emit currentOpticalZoomChanged(m_opticalZoom);
- }
-
- maxOpticalDigitalZoomChange(4.0, 5.0);
- }
-
- // helper function to emit maximum Optical and Digital Zoom Changed signals
- void maxOpticalDigitalZoomChange(qreal maxOptical, qreal maxDigital)
- {
- if (maxOptical != m_maxOpticalZoom) {
- m_maxOpticalZoom = maxOptical;
- emit maximumOpticalZoomChanged(m_maxOpticalZoom);
- }
-
- if (maxDigital != m_maxDigitalZoom) {
- m_maxDigitalZoom = maxDigital;
- emit maximumDigitalZoomChanged(m_maxDigitalZoom);
- }
- }
-
-private:
- qreal m_opticalZoom;
- qreal m_digitalZoom;
- qreal m_maxOpticalZoom;
- qreal m_maxDigitalZoom;
-};
-
-#endif // MOCKCAMERAZOOMCONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockcontainer.pri b/tests/auto/unit/qmultimedia_common/mockcontainer.pri
deleted file mode 100644
index e4a345adb..000000000
--- a/tests/auto/unit/qmultimedia_common/mockcontainer.pri
+++ /dev/null
@@ -1,7 +0,0 @@
-INCLUDEPATH *= $$PWD \
- ../../../src/multimedia \
-
-HEADERS *= \
- ../qmultimedia_common/mockmediacontainercontrol.h \
- ../qmultimedia_common/mockmetadatawritercontrol.h \
- ../qmultimedia_common/mockmetadatareadercontrol.h
diff --git a/tests/auto/unit/qmultimedia_common/mockcustomaudiorolecontrol.h b/tests/auto/unit/qmultimedia_common/mockcustomaudiorolecontrol.h
deleted file mode 100644
index f4031bb04..000000000
--- a/tests/auto/unit/qmultimedia_common/mockcustomaudiorolecontrol.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 QNX Software Systems. All rights reserved.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKCUSTOMAUDIOROLECONTROL_H
-#define MOCKCUSTOMAUDIOROLECONTROL_H
-
-#include <qcustomaudiorolecontrol.h>
-
-class MockCustomAudioRoleControl : public QCustomAudioRoleControl
-{
- friend class MockMediaPlayerService;
-
-public:
- MockCustomAudioRoleControl()
- : QCustomAudioRoleControl()
- , m_customAudioRole(QAudio::UnknownRole)
- {
- }
-
- QString customAudioRole() const
- {
- return m_customAudioRole;
- }
-
- void setCustomAudioRole(const QString &role)
- {
- if (role != m_customAudioRole)
- emit customAudioRoleChanged(m_customAudioRole = role);
- }
-
- QStringList supportedCustomAudioRoles() const
- {
- return QStringList() << QStringLiteral("customRole")
- << QStringLiteral("customRole2");
- }
-
- QString m_customAudioRole;
-};
-
-#endif // MOCKCUSTOMAUDIOROLECONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockdecoder.pri b/tests/auto/unit/qmultimedia_common/mockdecoder.pri
deleted file mode 100644
index 8b486e475..000000000
--- a/tests/auto/unit/qmultimedia_common/mockdecoder.pri
+++ /dev/null
@@ -1,9 +0,0 @@
-# Audio decoder related mock backend files
-INCLUDEPATH += $$PWD \
- ../../../src/multimedia \
- ../../../src/multimedia/audio \
- ../../../src/multimedia/controls
-
-HEADERS *= \
- ../qmultimedia_common/mockaudiodecoderservice.h \
- ../qmultimedia_common/mockaudiodecodercontrol.h
diff --git a/tests/auto/unit/qmultimedia_common/mockimageencodercontrol.h b/tests/auto/unit/qmultimedia_common/mockimageencodercontrol.h
deleted file mode 100644
index f03e15959..000000000
--- a/tests/auto/unit/qmultimedia_common/mockimageencodercontrol.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKIMAGEENCODERCONTROL_H
-#define MOCKIMAGEENCODERCONTROL_H
-
-#include "qimageencodercontrol.h"
-
-class MockImageEncoderControl : public QImageEncoderControl
-{
-public:
- MockImageEncoderControl(QObject *parent = 0)
- : QImageEncoderControl(parent)
- {
- m_settings = QImageEncoderSettings();
- }
-
- QList<QSize> supportedResolutions(const QImageEncoderSettings & settings = QImageEncoderSettings(),
- bool *continuous = 0) const
- {
- if (continuous)
- *continuous = true;
-
- QList<QSize> resolutions;
- if (settings.resolution().isValid()) {
- if (settings.resolution() == QSize(160,160) ||
- settings.resolution() == QSize(320,240))
- resolutions << settings.resolution();
-
- if (settings.quality() == QMultimedia::HighQuality && settings.resolution() == QSize(640,480))
- resolutions << settings.resolution();
- } else {
- resolutions << QSize(160, 120);
- resolutions << QSize(320, 240);
- if (settings.quality() == QMultimedia::HighQuality)
- resolutions << QSize(640, 480);
- }
-
- return resolutions;
- }
-
- QStringList supportedImageCodecs() const
- {
- QStringList codecs;
- codecs << "PNG" << "JPEG";
- return codecs;
- }
-
- QString imageCodecDescription(const QString &codecName) const {
- if (codecName == "PNG")
- return QString("Portable Network Graphic");
- if (codecName == "JPEG")
- return QString("Joint Photographic Expert Group");
- return QString();
- }
-
- QImageEncoderSettings imageSettings() const { return m_settings; }
- void setImageSettings(const QImageEncoderSettings &settings) { m_settings = settings; }
-
-private:
- QImageEncoderSettings m_settings;
-};
-
-
-#endif // MOCKIMAGEENCODERCONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockmediacontainercontrol.h b/tests/auto/unit/qmultimedia_common/mockmediacontainercontrol.h
deleted file mode 100644
index 08562a469..000000000
--- a/tests/auto/unit/qmultimedia_common/mockmediacontainercontrol.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKMEDIACONTAINERCONTROL_H
-#define MOCKMEDIACONTAINERCONTROL_H
-
-#include <QObject>
-#include "qmediacontainercontrol.h"
-#include <QMap>
-#include <QString>
-#include <QStringList>
-
-QT_USE_NAMESPACE
-class MockMediaContainerControl : public QMediaContainerControl
-{
- Q_OBJECT
-public:
- MockMediaContainerControl(QObject *parent):
- QMediaContainerControl(parent)
- {
- m_supportedContainers.append("wav");
- m_supportedContainers.append("mp3");
- m_supportedContainers.append("mov");
-
- m_descriptions.insert("wav", "WAV format");
- m_descriptions.insert("mp3", "MP3 format");
- m_descriptions.insert("mov", "MOV format");
- }
-
- virtual ~MockMediaContainerControl() {};
-
- QStringList supportedContainers() const
- {
- return m_supportedContainers;
- }
-
- QString containerFormat() const
- {
- return m_format;
- }
-
- void setContainerFormat(const QString &formatMimeType)
- {
- if (m_supportedContainers.contains(formatMimeType))
- m_format = formatMimeType;
- }
-
- QString containerDescription(const QString &formatMimeType) const
- {
- return m_descriptions.value(formatMimeType);
- }
-
-private:
- QStringList m_supportedContainers;
- QMap<QString, QString> m_descriptions;
- QString m_format;
-};
-
-#endif // MOCKMEDIACONTAINERCONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockmediaobject.h b/tests/auto/unit/qmultimedia_common/mockmediaobject.h
deleted file mode 100644
index 021cf9be8..000000000
--- a/tests/auto/unit/qmultimedia_common/mockmediaobject.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKMEDIAOBJECT_H
-#define MOCKMEDIAOBJECT_H
-
-#include "qmediaobject.h"
-
-class MockMediaObject : public QMediaObject
-{
- Q_OBJECT
-public:
- MockMediaObject(QObject *parent, QMediaService *service):
- QMediaObject(parent, service)
- {
- }
-};
-
-#endif // MOCKMEDIAOBJECT_H
diff --git a/tests/auto/unit/qmultimedia_common/mockmediaplayercontrol.h b/tests/auto/unit/qmultimedia_common/mockmediaplayercontrol.h
deleted file mode 100644
index 1c93bbbbf..000000000
--- a/tests/auto/unit/qmultimedia_common/mockmediaplayercontrol.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKMEDIAPLAYERCONTROL_H
-#define MOCKMEDIAPLAYERCONTROL_H
-
-#include "qmediaplayercontrol.h"
-
-class MockMediaPlayerControl : public QMediaPlayerControl
-{
- friend class MockMediaPlayerService;
-
-public:
- MockMediaPlayerControl()
- : QMediaPlayerControl(0)
- , _state(QMediaPlayer::StoppedState)
- , _mediaStatus(QMediaPlayer::NoMedia)
- , _error(QMediaPlayer::NoError)
- , _duration(0)
- , _position(0)
- , _volume(100)
- , _muted(false)
- , _bufferStatus(0)
- , _audioAvailable(false)
- , _videoAvailable(false)
- , _isSeekable(true)
- , _playbackRate(qreal(1.0))
- , _stream(0)
- , _isValid(false)
- {}
-
- QMediaPlayer::State state() const { return _state; }
- QMediaPlayer::MediaStatus mediaStatus() const { return _mediaStatus; }
-
- qint64 duration() const { return _duration; }
-
- qint64 position() const { return _position; }
-
- void setPosition(qint64 position) { if (position != _position) emit positionChanged(_position = position); }
-
- int volume() const { return _volume; }
- void setVolume(int volume) { emit volumeChanged(_volume = volume); }
-
- bool isMuted() const { return _muted; }
- void setMuted(bool muted) { if (muted != _muted) emit mutedChanged(_muted = muted); }
-
- int bufferStatus() const { return _bufferStatus; }
-
- bool isAudioAvailable() const { return _audioAvailable; }
- bool isVideoAvailable() const { return _videoAvailable; }
-
- bool isSeekable() const { return _isSeekable; }
- QMediaTimeRange availablePlaybackRanges() const { return QMediaTimeRange(_seekRange.first, _seekRange.second); }
- void setSeekRange(qint64 minimum, qint64 maximum) { _seekRange = qMakePair(minimum, maximum); }
-
- qreal playbackRate() const { return _playbackRate; }
- void setPlaybackRate(qreal rate) { if (rate != _playbackRate) emit playbackRateChanged(_playbackRate = rate); }
-
- QMediaContent media() const { return _media; }
- void setMedia(const QMediaContent &content, QIODevice *stream)
- {
- _stream = stream;
- _media = content;
- _mediaStatus = _media.isNull() ? QMediaPlayer::NoMedia : QMediaPlayer::LoadingMedia;
- if (_state != QMediaPlayer::StoppedState)
- emit stateChanged(_state = QMediaPlayer::StoppedState);
- emit mediaStatusChanged(_mediaStatus);
- emit mediaChanged(_media = content);
- }
- QIODevice *mediaStream() const { return _stream; }
-
- void play() { if (_isValid && !_media.isNull() && _state != QMediaPlayer::PlayingState) emit stateChanged(_state = QMediaPlayer::PlayingState); }
- void pause() { if (_isValid && !_media.isNull() && _state != QMediaPlayer::PausedState) emit stateChanged(_state = QMediaPlayer::PausedState); }
- void stop() { if (_state != QMediaPlayer::StoppedState) emit stateChanged(_state = QMediaPlayer::StoppedState); }
-
- QMediaPlayer::State _state;
- QMediaPlayer::MediaStatus _mediaStatus;
- QMediaPlayer::Error _error;
- qint64 _duration;
- qint64 _position;
- int _volume;
- bool _muted;
- int _bufferStatus;
- bool _audioAvailable;
- bool _videoAvailable;
- bool _isSeekable;
- QPair<qint64, qint64> _seekRange;
- qreal _playbackRate;
- QMediaContent _media;
- QIODevice *_stream;
- bool _isValid;
- QString _errorString;
-};
-
-#endif // MOCKMEDIAPLAYERCONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockmediaplayerservice.h b/tests/auto/unit/qmultimedia_common/mockmediaplayerservice.h
deleted file mode 100644
index 62f9c542e..000000000
--- a/tests/auto/unit/qmultimedia_common/mockmediaplayerservice.h
+++ /dev/null
@@ -1,170 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKPLAYERSERVICE_H
-#define MOCKPLAYERSERVICE_H
-
-#include "qmediaservice.h"
-
-#include "mockmediaplayercontrol.h"
-#include "mockmediastreamscontrol.h"
-#include "mockvideorenderercontrol.h"
-#include "mockvideoprobecontrol.h"
-#include "mockvideowindowcontrol.h"
-#include "mockaudiorolecontrol.h"
-#include "mockcustomaudiorolecontrol.h"
-
-class MockMediaPlayerService : public QMediaService
-{
- Q_OBJECT
-
-public:
- MockMediaPlayerService():QMediaService(0)
- {
- mockControl = new MockMediaPlayerControl;
- mockAudioRoleControl = new MockAudioRoleControl;
- mockCustomAudioRoleControl = new MockCustomAudioRoleControl;
- mockStreamsControl = new MockStreamsControl;
- rendererControl = new MockVideoRendererControl;
- rendererRef = 0;
- mockVideoProbeControl = new MockVideoProbeControl;
- windowControl = new MockVideoWindowControl;
- windowRef = 0;
- enableAudioRole = true;
- enableCustomAudioRole = true;
- }
-
- ~MockMediaPlayerService()
- {
- delete mockControl;
- delete mockAudioRoleControl;
- delete mockCustomAudioRoleControl;
- delete mockStreamsControl;
- delete rendererControl;
- delete mockVideoProbeControl;
- delete windowControl;
- }
-
- QMediaControl* requestControl(const char *iid)
- {
- if (qstrcmp(iid, QMediaPlayerControl_iid) == 0) {
- return mockControl;
- } else if (qstrcmp(iid, QVideoRendererControl_iid) == 0) {
- if (rendererRef == 0) {
- rendererRef += 1;
- return rendererControl;
- }
- } else if (qstrcmp(iid, QMediaVideoProbeControl_iid) == 0) {
- return mockVideoProbeControl;
- }
- if (qstrcmp(iid, QVideoWindowControl_iid) == 0) {
- if (windowRef == 0) {
- windowRef += 1;
- return windowControl;
- }
- } else if (enableAudioRole && qstrcmp(iid, QAudioRoleControl_iid) == 0) {
- return mockAudioRoleControl;
- } else if (enableCustomAudioRole && qstrcmp(iid, QCustomAudioRoleControl_iid) == 0) {
- return mockCustomAudioRoleControl;
- }
-
- return 0;
- }
-
- void releaseControl(QMediaControl *control)
- {
- if (control == rendererControl)
- rendererRef -= 1;
- if (control == windowControl)
- windowRef -= 1;
- }
-
- void setState(QMediaPlayer::State state) { emit mockControl->stateChanged(mockControl->_state = state); }
- void setState(QMediaPlayer::State state, QMediaPlayer::MediaStatus status) {
- mockControl->_state = state;
- mockControl->_mediaStatus = status;
- emit mockControl->mediaStatusChanged(status);
- emit mockControl->stateChanged(state);
- }
- void setMediaStatus(QMediaPlayer::MediaStatus status) { emit mockControl->mediaStatusChanged(mockControl->_mediaStatus = status); }
- void setIsValid(bool isValid) { mockControl->_isValid = isValid; }
- void setMedia(QMediaContent media) { mockControl->_media = media; }
- void setDuration(qint64 duration) { mockControl->_duration = duration; }
- void setPosition(qint64 position) { mockControl->_position = position; }
- void setSeekable(bool seekable) { mockControl->_isSeekable = seekable; }
- void setVolume(int volume) { mockControl->_volume = volume; }
- void setMuted(bool muted) { mockControl->_muted = muted; }
- void setVideoAvailable(bool videoAvailable) { mockControl->_videoAvailable = videoAvailable; }
- void setBufferStatus(int bufferStatus) { mockControl->_bufferStatus = bufferStatus; }
- void setPlaybackRate(qreal playbackRate) { mockControl->_playbackRate = playbackRate; }
- void setError(QMediaPlayer::Error error) { mockControl->_error = error; emit mockControl->error(mockControl->_error, mockControl->_errorString); }
- void setErrorString(QString errorString) { mockControl->_errorString = errorString; emit mockControl->error(mockControl->_error, mockControl->_errorString); }
-
- void setHasAudioRole(bool enable) { enableAudioRole = enable; }
- void setHasCustomAudioRole(bool enable) { enableCustomAudioRole = enable; }
-
- void reset()
- {
- mockControl->_state = QMediaPlayer::StoppedState;
- mockControl->_mediaStatus = QMediaPlayer::UnknownMediaStatus;
- mockControl->_error = QMediaPlayer::NoError;
- mockControl->_duration = 0;
- mockControl->_position = 0;
- mockControl->_volume = 0;
- mockControl->_muted = false;
- mockControl->_bufferStatus = 0;
- mockControl->_videoAvailable = false;
- mockControl->_isSeekable = false;
- mockControl->_playbackRate = 0.0;
- mockControl->_media = QMediaContent();
- mockControl->_stream = 0;
- mockControl->_isValid = false;
- mockControl->_errorString = QString();
-
- enableAudioRole = true;
- mockAudioRoleControl->m_audioRole = QAudio::UnknownRole;
- enableCustomAudioRole = true;
- mockCustomAudioRoleControl->m_customAudioRole.clear();
- }
-
- MockMediaPlayerControl *mockControl;
- MockAudioRoleControl *mockAudioRoleControl;
- MockCustomAudioRoleControl *mockCustomAudioRoleControl;
- MockStreamsControl *mockStreamsControl;
- MockVideoRendererControl *rendererControl;
- MockVideoProbeControl *mockVideoProbeControl;
- MockVideoWindowControl *windowControl;
- int windowRef;
- int rendererRef;
- bool enableAudioRole;
- bool enableCustomAudioRole;
-};
-
-
-
-#endif // MOCKPLAYERSERVICE_H
diff --git a/tests/auto/unit/qmultimedia_common/mockmediaplaylistcontrol.h b/tests/auto/unit/qmultimedia_common/mockmediaplaylistcontrol.h
deleted file mode 100644
index cc56e9adb..000000000
--- a/tests/auto/unit/qmultimedia_common/mockmediaplaylistcontrol.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKMEDIAPLAYLISTCONTROL_H
-#define MOCKMEDIAPLAYLISTCONTROL_H
-
-#include <private/qmediaplaylistcontrol_p.h>
-#include <private/qmediaplaylistnavigator_p.h>
-#include <private/qmedianetworkplaylistprovider_p.h>
-
-#include "mockreadonlyplaylistprovider.h"
-
-class MockMediaPlaylistControl : public QMediaPlaylistControl
-{
-public:
- MockMediaPlaylistControl(bool readonly = false, QObject *parent = 0)
- : QMediaPlaylistControl(parent)
- , m_navigator(0)
- , m_playlist(0)
- , m_ownsProvider(false)
- , m_readOnly(readonly)
- {
- reset();
- }
-
- ~MockMediaPlaylistControl()
- {
- }
-
- void reset()
- {
- delete m_navigator;
- if (m_ownsProvider)
- delete m_playlist;
-
- if (m_readOnly)
- m_playlist = new MockReadOnlyPlaylistProvider(this);
- else
- m_playlist = new QMediaNetworkPlaylistProvider(this);
-
- m_ownsProvider = true;
- m_navigator = new QMediaPlaylistNavigator(m_playlist, this);
- }
-
- void setReadOnly(bool ro)
- {
- if (m_readOnly == ro)
- return;
-
- m_readOnly = ro;
- reset();
- }
-
- QMediaPlaylistProvider* playlistProvider() const { return m_playlist; }
- bool setPlaylistProvider(QMediaPlaylistProvider *newProvider)
- {
- bool bMediaContentChanged = false;
- int i = 0;
- for (; i < playlistProvider()->mediaCount(); i++) {
- if (playlistProvider()->media(i).request().url().toString()
- != newProvider->media(i).request().url().toString()) {
- bMediaContentChanged = true;
- break;
- }
- }
-
- if (playlistProvider()->mediaCount() != newProvider->mediaCount() || bMediaContentChanged ) {
- emit playlistProviderChanged();
- emit currentMediaChanged(newProvider->media(i));
- }
-
- if (m_ownsProvider)
- delete m_playlist;
- m_playlist = newProvider;
- m_ownsProvider = false;
-
- m_navigator->setPlaylist(newProvider);
- return true;
- }
-
- int currentIndex() const { return m_navigator->currentIndex(); }
- void setCurrentIndex(int position)
- {
- if (position != currentIndex())
- emit currentIndexChanged(position);
- m_navigator->jump(position);
- }
-
- int nextIndex(int steps) const { return m_navigator->nextIndex(steps); }
- int previousIndex(int steps) const { return m_navigator->previousIndex(steps); }
-
- void next() { m_navigator->next(); }
- void previous() { m_navigator->previous(); }
-
- QMediaPlaylist::PlaybackMode playbackMode() const { return m_navigator->playbackMode(); }
- void setPlaybackMode(QMediaPlaylist::PlaybackMode mode)
- {
- if (playbackMode() != mode)
- emit playbackModeChanged(mode);
-
- m_navigator->setPlaybackMode(mode);
- }
-
-private:
- QMediaPlaylistNavigator *m_navigator;
- QMediaPlaylistProvider *m_playlist;
- bool m_ownsProvider;
- bool m_readOnly;
-};
-
-#endif // MOCKMEDIAPLAYLISTCONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockmediaplaylistsourcecontrol.h b/tests/auto/unit/qmultimedia_common/mockmediaplaylistsourcecontrol.h
deleted file mode 100644
index fb30e3c79..000000000
--- a/tests/auto/unit/qmultimedia_common/mockmediaplaylistsourcecontrol.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKMEDIAPLAYLISTSOURCECONTROL_H
-#define MOCKMEDIAPLAYLISTSOURCECONTROL_H
-
-#include <private/qmediaplaylistsourcecontrol_p.h>
-
-class MockPlaylistSourceControl : public QMediaPlaylistSourceControl
-{
- Q_OBJECT
-public:
- MockPlaylistSourceControl(QObject *parent)
- : QMediaPlaylistSourceControl(parent),
- m_playlist(0)
- {
- }
-
- ~MockPlaylistSourceControl()
- {
- }
-
- void setPlaylist(QMediaPlaylist *playlist)
- {
- m_playlist = playlist;
- }
-
- QMediaPlaylist *playlist() const
- {
- return m_playlist;
- }
-private:
- QMediaPlaylist *m_playlist;
-};
-
-#endif // MOCKMEDIAPLAYLISTSOURCECONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockmediarecordercontrol.h b/tests/auto/unit/qmultimedia_common/mockmediarecordercontrol.h
deleted file mode 100644
index 14fd313b6..000000000
--- a/tests/auto/unit/qmultimedia_common/mockmediarecordercontrol.h
+++ /dev/null
@@ -1,164 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKRECORDERCONTROL_H
-#define MOCKRECORDERCONTROL_H
-
-#include <QUrl>
-
-#include "qmediarecordercontrol.h"
-
-class MockMediaRecorderControl : public QMediaRecorderControl
-{
- Q_OBJECT
-
-public:
- MockMediaRecorderControl(QObject *parent = 0):
- QMediaRecorderControl(parent),
- m_state(QMediaRecorder::StoppedState),
- m_status(QMediaRecorder::LoadedStatus),
- m_position(0),
- m_muted(false),
- m_volume(1.0),
- m_settingAppliedCount(0)
- {
- }
-
- QUrl outputLocation() const
- {
- return m_sink;
- }
-
- bool setOutputLocation(const QUrl &sink)
- {
- m_sink = sink;
- return true;
- }
-
- QMediaRecorder::State state() const
- {
- return m_state;
- }
-
- QMediaRecorder::Status status() const
- {
- return m_status;
- }
-
- qint64 duration() const
- {
- return m_position;
- }
-
- bool isMuted() const
- {
- return m_muted;
- }
-
- qreal volume() const
- {
- return m_volume;
- }
-
- void applySettings()
- {
- m_settingAppliedCount++;
- }
-
- using QMediaRecorderControl::error;
-
-public slots:
- void record()
- {
- m_state = QMediaRecorder::RecordingState;
- m_status = QMediaRecorder::RecordingStatus;
- m_position=1;
- emit stateChanged(m_state);
- emit statusChanged(m_status);
- emit durationChanged(m_position);
-
- QUrl actualLocation = m_sink.isEmpty() ? QUrl::fromLocalFile("default_name.mp4") : m_sink;
- emit actualLocationChanged(actualLocation);
- }
-
- void pause()
- {
- m_state = QMediaRecorder::PausedState;
- m_status = QMediaRecorder::PausedStatus;
- emit stateChanged(m_state);
- emit statusChanged(m_status);
- }
-
- void stop()
- {
- m_position=0;
- m_state = QMediaRecorder::StoppedState;
- m_status = QMediaRecorder::LoadedStatus;
- emit stateChanged(m_state);
- emit statusChanged(m_status);
- }
-
- void setState(QMediaRecorder::State state)
- {
- switch (state) {
- case QMediaRecorder::StoppedState:
- stop();
- break;
- case QMediaRecorder::PausedState:
- pause();
- break;
- case QMediaRecorder::RecordingState:
- record();
- break;
- }
- }
-
-
- void setMuted(bool muted)
- {
- if (m_muted != muted)
- emit mutedChanged(m_muted = muted);
- }
-
- void setVolume(qreal volume)
- {
- if (!qFuzzyCompare(m_volume, volume))
- emit volumeChanged(m_volume = volume);
- }
-
-public:
- QUrl m_sink;
- QMediaRecorder::State m_state;
- QMediaRecorder::Status m_status;
- qint64 m_position;
- bool m_muted;
- qreal m_volume;
- int m_settingAppliedCount;
-};
-
-#endif // MOCKRECORDERCONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockmediarecorderservice.h b/tests/auto/unit/qmultimedia_common/mockmediarecorderservice.h
deleted file mode 100644
index 2e02ce286..000000000
--- a/tests/auto/unit/qmultimedia_common/mockmediarecorderservice.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKSERVICE_H
-#define MOCKSERVICE_H
-
-#include "qmediaservice.h"
-
-#include "mockaudioencodercontrol.h"
-#include "mockmediarecordercontrol.h"
-#include "mockvideoencodercontrol.h"
-#include "mockaudioinputselector.h"
-#include "mockmediacontainercontrol.h"
-#include "mockmetadatawritercontrol.h"
-#include "mockavailabilitycontrol.h"
-#include "mockaudioprobecontrol.h"
-
-class MockMediaRecorderService : public QMediaService
-{
- Q_OBJECT
-public:
- MockMediaRecorderService(QObject *parent = 0, QMediaControl *control = 0, MockAvailabilityControl *availability = 0):
- QMediaService(parent),
- mockControl(control),
- mockAvailabilityControl(availability),
- hasControls(true)
- {
- mockAudioInputSelector = new MockAudioInputSelector(this);
- mockAudioEncoderControl = new MockAudioEncoderControl(this);
- mockFormatControl = new MockMediaContainerControl(this);
- mockVideoEncoderControl = new MockVideoEncoderControl(this);
- mockMetaDataControl = new MockMetaDataWriterControl(this);
- mockAudioProbeControl = new MockAudioProbeControl(this);
- }
-
- QMediaControl* requestControl(const char *name)
- {
- if (hasControls && qstrcmp(name,QAudioEncoderSettingsControl_iid) == 0)
- return mockAudioEncoderControl;
- if (hasControls && qstrcmp(name,QAudioInputSelectorControl_iid) == 0)
- return mockAudioInputSelector;
- if (hasControls && qstrcmp(name,QMediaRecorderControl_iid) == 0)
- return mockControl;
- if (hasControls && qstrcmp(name,QMediaContainerControl_iid) == 0)
- return mockFormatControl;
- if (hasControls && qstrcmp(name,QVideoEncoderSettingsControl_iid) == 0)
- return mockVideoEncoderControl;
- if (hasControls && qstrcmp(name, QMetaDataWriterControl_iid) == 0)
- return mockMetaDataControl;
- if (hasControls && qstrcmp(name, QMediaAvailabilityControl_iid) == 0)
- return mockAvailabilityControl;
- if (hasControls && qstrcmp(name, QMediaAudioProbeControl_iid) == 0)
- return mockAudioProbeControl;
-
- return 0;
- }
-
- void releaseControl(QMediaControl*)
- {
- }
-
- QMediaControl *mockControl;
- QAudioInputSelectorControl *mockAudioInputSelector;
- QAudioEncoderSettingsControl *mockAudioEncoderControl;
- QMediaContainerControl *mockFormatControl;
- QVideoEncoderSettingsControl *mockVideoEncoderControl;
- MockMetaDataWriterControl *mockMetaDataControl;
- MockAvailabilityControl *mockAvailabilityControl;
- MockAudioProbeControl *mockAudioProbeControl;
-
- bool hasControls;
-};
-
-#endif // MOCKSERVICE_H
diff --git a/tests/auto/unit/qmultimedia_common/mockmediaservice.h b/tests/auto/unit/qmultimedia_common/mockmediaservice.h
deleted file mode 100644
index 3896437ce..000000000
--- a/tests/auto/unit/qmultimedia_common/mockmediaservice.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKMEDIASERVICE_H
-#define MOCKMEDIASERVICE_H
-
-#include "qmediaservice.h"
-#include <QtCore/QMap>
-
-Q_DECLARE_METATYPE(QMediaControl *)
-
-class MockMediaService : public QMediaService
-{
- Q_OBJECT
-public:
- MockMediaService(QObject *parent, QMediaControl *control):
- QMediaService(parent),
- mockControl(control) {}
-
- MockMediaService(QObject *parent, QMap<QString, QMediaControl *> controls):
- QMediaService(parent),
- mockControl(0),
- mockControls(controls) {}
-
- QMediaControl* requestControl(const char *key)
- {
- if (mockControl)
- return mockControl;
- else
- return mockControls.value(key);
- }
-
- void releaseControl(QMediaControl*) {}
-
- QMediaControl *mockControl;
- QMap<QString, QMediaControl *> mockControls;
-};
-
-
-#endif // MOCKMEDIASERVICE_H
diff --git a/tests/auto/unit/qmultimedia_common/mockmediaserviceprovider.h b/tests/auto/unit/qmultimedia_common/mockmediaserviceprovider.h
deleted file mode 100644
index 49f945cd6..000000000
--- a/tests/auto/unit/qmultimedia_common/mockmediaserviceprovider.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKMEDIASERVICEPROVIDER_H
-#define MOCKMEDIASERVICEPROVIDER_H
-
-#include "qmediaserviceprovider_p.h"
-#include "qmediaservice.h"
-#include "mockvideodeviceselectorcontrol.h"
-#include "mockcamerainfocontrol.h"
-
-// Simple provider that lets you set the service
-class MockMediaServiceProvider : public QMediaServiceProvider
-{
-public:
- MockMediaServiceProvider(QMediaService* s = 0, bool del=false)
- : service(s), deleteServiceOnRelease(del)
- {
- }
-
- QMediaService *requestService(const QByteArray &, const QMediaServiceProviderHint &)
- {
- return service;
- }
-
- void releaseService(QMediaService *service)
- {
- if (deleteServiceOnRelease) {
- delete service;
- this->service = 0;
- }
- }
-
- QMediaServiceProviderHint::Features supportedFeatures(const QMediaService *) const
- {
- return features;
- }
-
- void setSupportedFeatures(QMediaServiceProviderHint::Features f)
- {
- features = f;
- }
-
- QByteArray defaultDevice(const QByteArray &serviceType) const
- {
- if (serviceType == Q_MEDIASERVICE_CAMERA)
- return MockVideoDeviceSelectorControl::defaultCamera();
-
- return QByteArray();
- }
-
- QList<QByteArray> devices(const QByteArray &serviceType) const
- {
- if (serviceType == Q_MEDIASERVICE_CAMERA)
- return MockVideoDeviceSelectorControl::availableCameras();
-
- return QList<QByteArray>();
- }
-
- QString deviceDescription(const QByteArray &serviceType, const QByteArray &device)
- {
- if (serviceType == Q_MEDIASERVICE_CAMERA)
- return MockVideoDeviceSelectorControl::cameraDescription(device);
-
- return QString();
- }
-
- QCamera::Position cameraPosition(const QByteArray &device) const
- {
- return MockCameraInfoControl::position(device);
- }
-
- int cameraOrientation(const QByteArray &device) const
- {
- return MockCameraInfoControl::orientation(device);
- }
-
- QMediaService *service;
- bool deleteServiceOnRelease;
- QMediaServiceProviderHint::Features features;
-};
-
-#endif // MOCKMEDIASERVICEPROVIDER_H
diff --git a/tests/auto/unit/qmultimedia_common/mockmediastreamscontrol.h b/tests/auto/unit/qmultimedia_common/mockmediastreamscontrol.h
deleted file mode 100644
index 9242dae06..000000000
--- a/tests/auto/unit/qmultimedia_common/mockmediastreamscontrol.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKMEDIASTREAMSCONTROL_H
-#define MOCKMEDIASTREAMSCONTROL_H
-
-#include "qmediastreamscontrol.h"
-
-class MockStreamsControl : public QMediaStreamsControl
-{
-public:
- MockStreamsControl(QObject *parent = 0) : QMediaStreamsControl(parent) {}
-
- int streamCount() { return _streams.count(); }
- void setStreamCount(int count) { _streams.resize(count); }
-
- StreamType streamType(int index) { return _streams.at(index).type; }
- void setStreamType(int index, StreamType type) { _streams[index].type = type; }
-
- QVariant metaData(int index, const QString &key) {
- return _streams.at(index).metaData.value(key); }
- void setMetaData(int index, const QString &key, const QVariant &value) {
- _streams[index].metaData.insert(key, value); }
-
- bool isActive(int index) { return _streams.at(index).active; }
- void setActive(int index, bool state) { _streams[index].active = state; }
-
-private:
- struct Stream
- {
- Stream() : type(UnknownStream), active(false) {}
- StreamType type;
- QMap<QString, QVariant> metaData;
- bool active;
- };
-
- QList<Stream> _streams;
-};
-
-#endif // MOCKMEDIASTREAMSCONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockmetadatareadercontrol.h b/tests/auto/unit/qmultimedia_common/mockmetadatareadercontrol.h
deleted file mode 100644
index ac5aaa9e8..000000000
--- a/tests/auto/unit/qmultimedia_common/mockmetadatareadercontrol.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKMETADATAREADERCONTROL_H
-#define MOCKMETADATAREADERCONTROL_H
-
-#include "qmetadatareadercontrol.h"
-
-class MockMetaDataReaderControl : public QMetaDataReaderControl
-{
- Q_OBJECT
-public:
- MockMetaDataReaderControl(QObject *parent = 0)
- : QMetaDataReaderControl(parent)
- , m_available(false)
- {
- }
-
- bool isMetaDataAvailable() const
- {
- return m_available;
- }
- void setMetaDataAvailable(bool available)
- {
- if (m_available != available)
- emit metaDataAvailableChanged(m_available = available);
- }
- QStringList availableMetaData() const
- {
- return m_data.keys();
- }
-
- QVariant metaData(const QString &key) const
- {
- return m_data.value(key);
- }
-
- void setMetaData(const QString &key, const QVariant &value)
- {
- if (m_data[key] != value) {
- if (value.isNull())
- m_data.remove(key);
- else
- m_data[key] = value;
-
- emit metaDataChanged(key, value);
- emit metaDataChanged();
- }
- }
-
- using QMetaDataReaderControl::metaDataChanged;
-
- void populateMetaData()
- {
- m_available = true;
- }
-
- bool m_available;
- QMap<QString, QVariant> m_data;
-};
-
-#endif // MOCKMETADATAREADERCONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockmetadatawritercontrol.h b/tests/auto/unit/qmultimedia_common/mockmetadatawritercontrol.h
deleted file mode 100644
index b3b0924e1..000000000
--- a/tests/auto/unit/qmultimedia_common/mockmetadatawritercontrol.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKMETADATAWRITERCONTROL_H
-#define MOCKMETADATAWRITERCONTROL_H
-
-#include <QObject>
-#include <QMap>
-
-#include "qmetadatawritercontrol.h"
-
-class MockMetaDataWriterControl : public QMetaDataWriterControl
-{
- Q_OBJECT
-public:
- MockMetaDataWriterControl(QObject *parent = 0)
- : QMetaDataWriterControl(parent)
- , m_available(false)
- , m_writable(false)
- {
- }
-
- bool isMetaDataAvailable() const { return m_available; }
- void setMetaDataAvailable(bool available)
- {
- if (m_available != available)
- emit metaDataAvailableChanged(m_available = available);
- }
- QStringList availableMetaData() const { return m_data.keys(); }
-
- bool isWritable() const { return m_writable; }
- void setWritable(bool writable) { emit writableChanged(m_writable = writable); }
-
- QVariant metaData(const QString &key) const { return m_data.value(key); }//Getting the metadata from Multimediakit
- void setMetaData(const QString &key, const QVariant &value)
- {
- if (m_data[key] != value) {
- if (value.isNull())
- m_data.remove(key);
- else
- m_data[key] = value;
-
- emit metaDataChanged(key, value);
- emit metaDataChanged();
- }
- }
-
- using QMetaDataWriterControl::metaDataChanged;
-
- void populateMetaData()
- {
- m_available = true;
- }
- void setWritable()
- {
- emit writableChanged(true);
- }
- void setMetaDataAvailable()
- {
- emit metaDataAvailableChanged(true);
- }
-
- bool m_available;
- bool m_writable;
- QMap<QString, QVariant> m_data;
-};
-
-#endif // MOCKMETADATAWRITERCONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockplayer.pri b/tests/auto/unit/qmultimedia_common/mockplayer.pri
deleted file mode 100644
index 93cdbf3d8..000000000
--- a/tests/auto/unit/qmultimedia_common/mockplayer.pri
+++ /dev/null
@@ -1,15 +0,0 @@
-INCLUDEPATH *= $$PWD \
- ../../../src/multimedia \
- ../../../src/multimedia/audio \
- ../../../src/multimedia/video \
-
-HEADERS *= \
- ../qmultimedia_common/mockmediaplayerservice.h \
- ../qmultimedia_common/mockmediaplayercontrol.h \
- ../qmultimedia_common/mockmediastreamscontrol.h \
- ../qmultimedia_common/mockmedianetworkaccesscontrol.h \
- ../qmultimedia_common/mockvideoprobecontrol.h \
- ../qmultimedia_common/mockaudiorolecontrol.h \
- ../qmultimedia_common/mockcustomaudiorolecontrol.h
-
-include(mockvideo.pri)
diff --git a/tests/auto/unit/qmultimedia_common/mockplaylist.pri b/tests/auto/unit/qmultimedia_common/mockplaylist.pri
deleted file mode 100644
index c27c839c5..000000000
--- a/tests/auto/unit/qmultimedia_common/mockplaylist.pri
+++ /dev/null
@@ -1,8 +0,0 @@
-INCLUDEPATH *= $$PWD \
- ../../../src/multimedia \
-
-HEADERS *= \
- ../qmultimedia_common/mockmediaplaylistsourcecontrol.h \
- ../qmultimedia_common/mockmediaplaylistcontrol.h \
- ../qmultimedia_common/mockreadonlyplaylistprovider.h \
- ../qmultimedia_common/mockplaylistservice.h
diff --git a/tests/auto/unit/qmultimedia_common/mockplaylistservice.h b/tests/auto/unit/qmultimedia_common/mockplaylistservice.h
deleted file mode 100644
index cb1971a44..000000000
--- a/tests/auto/unit/qmultimedia_common/mockplaylistservice.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKPLAYLISTSERVICE_H
-#define MOCKPLAYLISTSERVICE_H
-
-#include "qmediaservice.h"
-#include "mockmediaplaylistcontrol.h"
-
-class MockPlaylistService : public QMediaService
-{
- Q_OBJECT
-
-public:
- MockPlaylistService():QMediaService(0)
- {
- mockControl = new MockMediaPlaylistControl(false, this);
- }
-
- ~MockPlaylistService()
- {
- }
-
- QMediaControl* requestControl(const char *iid)
- {
- if (qstrcmp(iid, QMediaPlaylistControl_iid) == 0)
- return mockControl;
- return 0;
- }
-
- void releaseControl(QMediaControl *)
- {
- }
-
- MockMediaPlaylistControl *mockControl;
-};
-
-
-#endif // MOCKPLAYLISTSERVICE_H
diff --git a/tests/auto/unit/qmultimedia_common/mockreadonlyplaylistprovider.h b/tests/auto/unit/qmultimedia_common/mockreadonlyplaylistprovider.h
deleted file mode 100644
index f0117d653..000000000
--- a/tests/auto/unit/qmultimedia_common/mockreadonlyplaylistprovider.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKREADONLYPLAYLISTPROVIDER_H
-#define MOCKREADONLYPLAYLISTPROVIDER_H
-
-#include <private/qmediaplaylistprovider_p.h>
-
-class MockReadOnlyPlaylistProvider : public QMediaPlaylistProvider
-{
-public:
- MockReadOnlyPlaylistProvider(QObject *parent)
- :QMediaPlaylistProvider(parent)
- {
- m_items.append(QMediaContent(QUrl(QLatin1String("file:///1"))));
- m_items.append(QMediaContent(QUrl(QLatin1String("file:///2"))));
- m_items.append(QMediaContent(QUrl(QLatin1String("file:///3"))));
- }
-
- int mediaCount() const { return m_items.size(); }
- QMediaContent media(int index) const
- {
- return index >=0 && index < mediaCount() ? m_items.at(index) : QMediaContent();
- }
-
-private:
- QList<QMediaContent> m_items;
-};
-
-#endif // MOCKREADONLYPLAYLISTPROVIDER_H
diff --git a/tests/auto/unit/qmultimedia_common/mockrecorder.pri b/tests/auto/unit/qmultimedia_common/mockrecorder.pri
deleted file mode 100644
index bdbcba0b8..000000000
--- a/tests/auto/unit/qmultimedia_common/mockrecorder.pri
+++ /dev/null
@@ -1,15 +0,0 @@
-INCLUDEPATH *= $$PWD \
- ../../../src/multimedia \
- ../../../src/multimedia/audio \
- ../../../src/multimedia/video \
-
-HEADERS *= \
- ../qmultimedia_common/mockmediarecorderservice.h \
- ../qmultimedia_common/mockmediarecordercontrol.h \
- ../qmultimedia_common/mockvideoencodercontrol.h \
- ../qmultimedia_common/mockaudioencodercontrol.h \
- ../qmultimedia_common/mockaudioinputselector.h \
- ../qmultimedia_common/mockaudioprobecontrol.h \
-
-# We also need all the container/metadata bits
-include(mockcontainer.pri)
diff --git a/tests/auto/unit/qmultimedia_common/mockvideo.pri b/tests/auto/unit/qmultimedia_common/mockvideo.pri
deleted file mode 100644
index a2492298c..000000000
--- a/tests/auto/unit/qmultimedia_common/mockvideo.pri
+++ /dev/null
@@ -1,10 +0,0 @@
-# video related mock backend files
-INCLUDEPATH += $$PWD \
- ../../../src/multimedia \
- ../../../src/multimedia/video
-
-HEADERS *= \
- ../qmultimedia_common/mockvideosurface.h \
- ../qmultimedia_common/mockvideorenderercontrol.h \
- ../qmultimedia_common/mockvideowindowcontrol.h
-
diff --git a/tests/auto/unit/qmultimedia_common/mockvideodeviceselectorcontrol.h b/tests/auto/unit/qmultimedia_common/mockvideodeviceselectorcontrol.h
deleted file mode 100644
index b391a282d..000000000
--- a/tests/auto/unit/qmultimedia_common/mockvideodeviceselectorcontrol.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKVIDEODEVICESELECTORCONTROL_H
-#define MOCKVIDEODEVICESELECTORCONTROL_H
-
-#include <qvideodeviceselectorcontrol.h>
-
-class MockVideoDeviceSelectorControl : public QVideoDeviceSelectorControl
-{
- Q_OBJECT
-public:
- MockVideoDeviceSelectorControl(QObject *parent)
- : QVideoDeviceSelectorControl(parent)
- , m_selectedDevice(1)
- {
- }
-
- ~MockVideoDeviceSelectorControl() { }
-
- int deviceCount() const { return availableCameras().count(); }
-
- QString deviceName(int index) const { return QString::fromLatin1(availableCameras().at(index)); }
- QString deviceDescription(int index) const { return cameraDescription(availableCameras().at(index)); }
-
- int defaultDevice() const { return availableCameras().indexOf(defaultCamera()); }
- int selectedDevice() const { return m_selectedDevice; }
- void setSelectedDevice(int index)
- {
- m_selectedDevice = index;
- emit selectedDeviceChanged(m_selectedDevice);
- emit selectedDeviceChanged(deviceName(m_selectedDevice));
- }
-
- static QByteArray defaultCamera()
- {
- return "othercamera";
- }
-
- static QList<QByteArray> availableCameras()
- {
- return QList<QByteArray>() << "backcamera" << "othercamera";
- }
-
- static QString cameraDescription(const QByteArray &camera)
- {
- if (camera == "backcamera")
- return QStringLiteral("backcamera desc");
- else if (camera == "othercamera")
- return QStringLiteral("othercamera desc");
- else
- return QString();
- }
-
-private:
- int m_selectedDevice;
- QStringList m_devices;
- QStringList m_descriptions;
-};
-
-#endif // MOCKVIDEODEVICESELECTORCONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockvideoencodercontrol.h b/tests/auto/unit/qmultimedia_common/mockvideoencodercontrol.h
deleted file mode 100644
index a1ee8ff9f..000000000
--- a/tests/auto/unit/qmultimedia_common/mockvideoencodercontrol.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKVIDEOENCODERCONTROL_H
-#define MOCKVIDEOENCODERCONTROL_H
-
-#include "qvideoencodersettingscontrol.h"
-
-class MockVideoEncoderControl : public QVideoEncoderSettingsControl
-{
- Q_OBJECT
-public:
- MockVideoEncoderControl(QObject *parent):
- QVideoEncoderSettingsControl(parent)
- {
- m_videoCodecs << "video/3gpp" << "video/H264";
- m_sizes << QSize(320,240) << QSize(640,480);
- m_framerates << 30 << 15 << 1;
- }
- ~MockVideoEncoderControl() {}
-
- QVideoEncoderSettings videoSettings() const { return m_videoSettings; }
- void setVideoSettings(const QVideoEncoderSettings &settings) { m_videoSettings = settings; };
-
- QList<QSize> supportedResolutions(const QVideoEncoderSettings & = QVideoEncoderSettings(),
- bool *continuous = 0) const
- {
- if (continuous)
- *continuous = true;
-
- return m_sizes;
- }
-
- QList<qreal> supportedFrameRates(const QVideoEncoderSettings & = QVideoEncoderSettings(),
- bool *continuous = 0) const
- {
- if (continuous)
- *continuous = false;
-
- return m_framerates;
- }
-
- QStringList supportedVideoCodecs() const { return m_videoCodecs; }
- QString videoCodecDescription(const QString &codecName) const { return codecName; }
-
-private:
- QVideoEncoderSettings m_videoSettings;
-
- QStringList m_videoCodecs;
- QList<QSize> m_sizes;
- QList<qreal> m_framerates;
-};
-
-#endif // MOCKVIDEOENCODERCONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockvideoprobecontrol.h b/tests/auto/unit/qmultimedia_common/mockvideoprobecontrol.h
deleted file mode 100644
index 6d953c2a7..000000000
--- a/tests/auto/unit/qmultimedia_common/mockvideoprobecontrol.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKVIDEOPROBECONTROL_H
-#define MOCKVIDEOPROBECONTROL_H
-
-#include "qmediavideoprobecontrol.h"
-
-class MockVideoProbeControl : public QMediaVideoProbeControl
-{
- Q_OBJECT
-public:
- MockVideoProbeControl(QObject *parent = 0):
- QMediaVideoProbeControl(parent)
- {
- }
-
- ~MockVideoProbeControl() {}
-
-private:
-};
-
-#endif // MOCKVIDEOPROBECONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockvideorenderercontrol.h b/tests/auto/unit/qmultimedia_common/mockvideorenderercontrol.h
deleted file mode 100644
index 9c2265426..000000000
--- a/tests/auto/unit/qmultimedia_common/mockvideorenderercontrol.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKVIDEORENDERERCONTROL_H
-#define MOCKVIDEORENDERERCONTROL_H
-
-#include "qvideorenderercontrol.h"
-
-class MockVideoRendererControl : public QVideoRendererControl
-{
-public:
- MockVideoRendererControl(QObject *parent = 0) : QVideoRendererControl(parent), m_surface(0) {}
-
- QAbstractVideoSurface *surface() const { return m_surface; }
- void setSurface(QAbstractVideoSurface *surface) { m_surface = surface; }
-
- QAbstractVideoSurface *m_surface;
-};
-
-#endif // MOCKVIDEORENDERERCONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockvideosurface.h b/tests/auto/unit/qmultimedia_common/mockvideosurface.h
deleted file mode 100644
index d9cd4aec9..000000000
--- a/tests/auto/unit/qmultimedia_common/mockvideosurface.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKVIDEOSURFACE_H
-#define MOCKVIDEOSURFACE_H
-
-#include "qabstractvideosurface.h"
-
-class MockVideoSurface : public QAbstractVideoSurface
-{
-public:
- QList<QVideoFrame::PixelFormat> supportedPixelFormats(
- QAbstractVideoBuffer::HandleType = QAbstractVideoBuffer::NoHandle) const
- {
- return QList<QVideoFrame::PixelFormat>();
- }
-
- bool present(const QVideoFrame &) { return false; }
-};
-
-#endif // MOCKVIDEOSURFACE_H
diff --git a/tests/auto/unit/qmultimedia_common/mockvideowindowcontrol.h b/tests/auto/unit/qmultimedia_common/mockvideowindowcontrol.h
deleted file mode 100644
index 13dad3b20..000000000
--- a/tests/auto/unit/qmultimedia_common/mockvideowindowcontrol.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKVIDEOWINDOWCONTROL_H
-#define MOCKVIDEOWINDOWCONTROL_H
-
-#include "qvideowindowcontrol.h"
-
-class MockVideoWindowControl : public QVideoWindowControl
-{
-public:
- MockVideoWindowControl(QObject *parent = 0) : QVideoWindowControl(parent) {}
- WId winId() const { return 0; }
- void setWinId(WId) {}
- QRect displayRect() const { return QRect(); }
- void setDisplayRect(const QRect &) {}
- bool isFullScreen() const { return false; }
- void setFullScreen(bool) {}
- void repaint() {}
- QSize nativeSize() const { return QSize(); }
- Qt::AspectRatioMode aspectRatioMode() const { return Qt::KeepAspectRatio; }
- void setAspectRatioMode(Qt::AspectRatioMode) {}
- int brightness() const { return 0; }
- void setBrightness(int) {}
- int contrast() const { return 0; }
- void setContrast(int) {}
- int hue() const { return 0; }
- void setHue(int) {}
- int saturation() const { return 0; }
- void setSaturation(int) {}
-};
-
-#endif // MOCKVIDEOWINDOWCONTROL_H
diff --git a/tests/auto/unit/qpaintervideosurface/qpaintervideosurface.pro b/tests/auto/unit/qpaintervideosurface/qpaintervideosurface.pro
deleted file mode 100644
index f1db2c5fb..000000000
--- a/tests/auto/unit/qpaintervideosurface/qpaintervideosurface.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qpaintervideosurface
-
-QT += multimedia-private multimediawidgets-private testlib
-qtHaveModule(opengl): \
- QT += opengl
-
-
-SOURCES += tst_qpaintervideosurface.cpp
-
-QT+=widgets
-
-linux-*:system(". /etc/lsb-release && [ $DISTRIB_CODENAME = precise ]"):DEFINES+=UBUNTU_PRECISE_PANGOLIN
diff --git a/tests/auto/unit/qpaintervideosurface/tst_qpaintervideosurface.cpp b/tests/auto/unit/qpaintervideosurface/tst_qpaintervideosurface.cpp
deleted file mode 100644
index 98ec5fc06..000000000
--- a/tests/auto/unit/qpaintervideosurface/tst_qpaintervideosurface.cpp
+++ /dev/null
@@ -1,1279 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//TESTED_COMPONENT=src/multimedia
-
-#include <private/qpaintervideosurface_p.h>
-#include <QtTest/QtTest>
-
-#include <QtWidgets/qapplication.h>
-#include <qvideosurfaceformat.h>
-
-#if QT_CONFIG(opengl)
-#include <QOpenGLContext>
-#include <QOpenGLFunctions>
-#include <QOpenGLWidget>
-#endif
-
-QT_USE_NAMESPACE
-class tst_QPainterVideoSurface : public QObject
-{
- Q_OBJECT
-private slots:
- void cleanup() {}
- void cleanupTestCase() {}
-
- void colors();
-
- void supportedFormat_data();
- void supportedFormat();
-
- void present_data();
- void present();
- void presentOpaqueFrame();
-
-#if QT_CONFIG(opengl)
-
- void shaderType();
-
- void shaderTypeStarted_data();
- void shaderTypeStarted();
-
- void shaderSupportedFormat_data();
- void shaderSupportedFormat();
-
- void shaderPresent_data();
- void shaderPresent();
- void shaderPresentOpaqueFrame_data();
- void shaderPresentOpaqueFrame();
- void shaderPresentGLFrame_data();
- void shaderPresentGLFrame();
-#endif
-private:
- bool m_libGL = QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL;
-};
-
-Q_DECLARE_METATYPE(const uchar *)
-
-#if QT_CONFIG(opengl)
-Q_DECLARE_METATYPE(QPainterVideoSurface::ShaderType);
-
-class QtTestGLVideoBuffer : public QAbstractVideoBuffer
-{
-public:
- QtTestGLVideoBuffer()
- : QAbstractVideoBuffer(GLTextureHandle)
- , m_textureId(0)
- {
- QOpenGLContext::currentContext()->functions()->glGenTextures(1, &m_textureId);
- }
-
- ~QtTestGLVideoBuffer()
- {
- QOpenGLContext::currentContext()->functions()->glDeleteTextures(1, &m_textureId);
- }
-
- GLuint textureId() const { return m_textureId; }
-
- QVariant handle() const { return m_textureId; }
-
- uchar *map(MapMode, int *, int *) { return 0; }
- void unmap() {}
- MapMode mapMode() const { return NotMapped; }
-
-private:
- GLuint m_textureId;
-};
-
-#endif
-
-class QtTestOpaqueVideoBuffer : public QAbstractVideoBuffer
-{
-public:
- QtTestOpaqueVideoBuffer()
- : QAbstractVideoBuffer(UserHandle)
- {}
-
- uchar *map(MapMode, int *, int *) { return 0; }
- void unmap() {}
- MapMode mapMode() const { return NotMapped; }
-};
-
-void tst_QPainterVideoSurface::colors()
-{
- QPainterVideoSurface surface;
-
- QCOMPARE(surface.brightness(), 0);
- QCOMPARE(surface.contrast(), 0);
- QCOMPARE(surface.hue(), 0);
- QCOMPARE(surface.saturation(), 0);
-
- surface.setBrightness(56);
- QCOMPARE(surface.brightness(), 56);
-
- surface.setContrast(43);
- QCOMPARE(surface.contrast(), 43);
-
- surface.setHue(-84);
- QCOMPARE(surface.hue(), -84);
-
- surface.setSaturation(100);
- QCOMPARE(surface.saturation(), 100);
-}
-
-static const uchar rgb32ImageData[] =
-{
- 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00,
- 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00
-};
-
-static const uchar argb32ImageData[] =
-{
- 0x00, 0xff, 0x00, 0x00, 0xcc, 0x00, 0xff, 0xcc,
- 0x77, 0x00, 0x00, 0x77, 0x00, 0xff, 0xff, 0x00
-};
-
-static const uchar rgb24ImageData[] =
-{
- 0x00, 0xff, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00,
- 0xcc, 0x00, 0xcc, 0x77, 0xff, 0x77, 0x00, 0x00
-};
-
-static const uchar rgb565ImageData[] =
-{
- 0xff, 0xff, 0xff, 0xff,
- 0x00, 0x00, 0x00, 0x00
-};
-
-static const uchar yuvPlanarImageData[] =
-{
- 0x00, 0x00, 0x0f, 0xff, 0xff, 0x0f, 0x00, 0x00,
- 0x00, 0x0f, 0xff, 0x0f, 0x0f, 0xff, 0x0f, 0x00,
- 0x00, 0xff, 0x0f, 0x00, 0x00, 0x0f, 0xff, 0x00,
- 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff,
- 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff,
- 0x0f, 0xff, 0x0f, 0x00, 0x00, 0x0f, 0xff, 0x0f,
- 0x00, 0x0f, 0xff, 0x0f, 0x0f, 0xff, 0x0f, 0x00,
- 0x00, 0x00, 0x0f, 0xff, 0xff, 0x0f, 0x00, 0x00,
- 0x00, 0x0f, 0x0f, 0x00,
- 0x0f, 0x00, 0x00, 0x0f,
- 0x0f, 0x00, 0x00, 0x0f,
- 0x00, 0x0f, 0x0f, 0x00,
- 0x00, 0x0f, 0x0f, 0x00,
- 0x0f, 0x00, 0x00, 0x0f,
- 0x0f, 0x00, 0x00, 0x0f,
- 0x00, 0x0f, 0x0f, 0x00,
-};
-
-void tst_QPainterVideoSurface::supportedFormat_data()
-{
- QTest::addColumn<QAbstractVideoBuffer::HandleType>("handleType");
- QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat");
- QTest::addColumn<QSize>("frameSize");
- QTest::addColumn<bool>("supportedPixelFormat");
- QTest::addColumn<bool>("supportedFormat");
-
- QTest::newRow("rgb32 640x480")
- << QAbstractVideoBuffer::NoHandle
- << QVideoFrame::Format_RGB32
- << QSize(640, 480)
- << true
- << true;
- QTest::newRow("rgb32 -640x480")
- << QAbstractVideoBuffer::NoHandle
- << QVideoFrame::Format_RGB32
- << QSize(-640, 480)
- << true
- << false;
- QTest::newRow("rgb24 1024x768")
- << QAbstractVideoBuffer::NoHandle
- << QVideoFrame::Format_RGB24
- << QSize(1024, 768)
-#if !defined(QT_OPENGL_ES)
- << m_libGL
- << m_libGL;
-#else
- << false
- << false;
-#endif
- QTest::newRow("rgb24 -1024x-768")
- << QAbstractVideoBuffer::NoHandle
- << QVideoFrame::Format_RGB24
- << QSize(-1024, -768)
-#if !defined(QT_OPENGL_ES)
- << m_libGL
-#else
- << false
-#endif
- << false;
- QTest::newRow("rgb565 0x0")
- << QAbstractVideoBuffer::NoHandle
- << QVideoFrame::Format_RGB565
- << QSize(0, 0)
- << true
- << false;
- QTest::newRow("YUV420P 640x480")
- << QAbstractVideoBuffer::NoHandle
- << QVideoFrame::Format_YUV420P
- << QSize(640, 480)
- << false
- << false;
- QTest::newRow("YUV420P 640x-480")
- << QAbstractVideoBuffer::NoHandle
- << QVideoFrame::Format_YUV420P
- << QSize(640, -480)
- << false
- << false;
- QTest::newRow("Y8 640x480")
- << QAbstractVideoBuffer::NoHandle
- << QVideoFrame::Format_Y8
- << QSize(640, 480)
- << true
- << true;
- QTest::newRow("Texture: rgb32 640x480")
- << QAbstractVideoBuffer::GLTextureHandle
- << QVideoFrame::Format_RGB32
- << QSize(640, 480)
- << false
- << false;
- QTest::newRow("Texture: rgb32 -640x480")
- << QAbstractVideoBuffer::GLTextureHandle
- << QVideoFrame::Format_RGB32
- << QSize(-640, 480)
- << false
- << false;
- QTest::newRow("rgb565 32x32")
- << QAbstractVideoBuffer::NoHandle
- << QVideoFrame::Format_RGB565
- << QSize(32, 32)
- << true
- << true;
- QTest::newRow("rgb565 0x0")
- << QAbstractVideoBuffer::NoHandle
- << QVideoFrame::Format_RGB565
- << QSize(0, 0)
- << true
- << false;
- QTest::newRow("argb32 256x256")
- << QAbstractVideoBuffer::NoHandle
- << QVideoFrame::Format_ARGB32
- << QSize(256, 256)
- << true
- << true;
- QTest::newRow("Texture: rgb24 1024x768")
- << QAbstractVideoBuffer::GLTextureHandle
- << QVideoFrame::Format_RGB24
- << QSize(1024, 768)
- << false
- << false;
- QTest::newRow("Texture: rgb24 -1024x-768")
- << QAbstractVideoBuffer::GLTextureHandle
- << QVideoFrame::Format_RGB24
- << QSize(-1024, -768)
- << false
- << false;
- QTest::newRow("Texture: YUV420P 640x480")
- << QAbstractVideoBuffer::GLTextureHandle
- << QVideoFrame::Format_YUV420P
- << QSize(640, 480)
- << false
- << false;
- QTest::newRow("Texture: YUV420P 640x-480")
- << QAbstractVideoBuffer::GLTextureHandle
- << QVideoFrame::Format_YUV420P
- << QSize(640, -480)
- << false
- << false;
- QTest::newRow("User Buffer: rgb32 256x256")
- << QAbstractVideoBuffer::UserHandle
- << QVideoFrame::Format_RGB32
- << QSize(256, 256)
- << false
- << false;
-#if !defined(Q_OS_MAC)
- QTest::newRow("Pixmap: rgb32 640x480")
- << QAbstractVideoBuffer::QPixmapHandle
- << QVideoFrame::Format_RGB32
- << QSize(640, 480)
- << true
- << true;
- QTest::newRow("Pixmap: YUV420P 640x480")
- << QAbstractVideoBuffer::QPixmapHandle
- << QVideoFrame::Format_YUV420P
- << QSize(640, 480)
- << false
- << true;
-#endif
-}
-
-void tst_QPainterVideoSurface::supportedFormat()
-{
- QFETCH(QAbstractVideoBuffer::HandleType, handleType);
- QFETCH(QVideoFrame::PixelFormat, pixelFormat);
- QFETCH(QSize, frameSize);
- QFETCH(bool, supportedPixelFormat);
- QFETCH(bool, supportedFormat);
-
- QPainterVideoSurface surface;
-
- const QList<QVideoFrame::PixelFormat> pixelFormats = surface.supportedPixelFormats(handleType);
-
- QCOMPARE(pixelFormats.contains(pixelFormat), supportedPixelFormat);
-
- QVideoSurfaceFormat format(frameSize, pixelFormat, handleType);
-
- QCOMPARE(surface.isFormatSupported(format), supportedFormat);
- QCOMPARE(surface.start(format), supportedFormat);
-}
-
-void tst_QPainterVideoSurface::present_data()
-{
- QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormatA");
- QTest::addColumn<QSize>("frameSizeA");
- QTest::addColumn<const uchar *>("frameDataA");
- QTest::addColumn<int>("bytesA");
- QTest::addColumn<int>("bytesPerLineA");
- QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormatB");
- QTest::addColumn<QSize>("frameSizeB");
- QTest::addColumn<const uchar *>("frameDataB");
- QTest::addColumn<int>("bytesB");
- QTest::addColumn<int>("bytesPerLineB");
-
- QTest::newRow("rgb32 -> argb32")
- << QVideoFrame::Format_RGB32
- << QSize(2, 2)
- << static_cast<const uchar *>(rgb32ImageData)
- << int(sizeof(rgb32ImageData))
- << 8
- << QVideoFrame::Format_ARGB32
- << QSize(2, 2)
- << static_cast<const uchar *>(argb32ImageData)
- << int(sizeof(argb32ImageData))
- << 8;
-
-#if !defined(QT_OPENGL_ES)
- if (m_libGL)
- QTest::newRow("rgb32 -> rgb24")
- << QVideoFrame::Format_RGB32
- << QSize(2, 2)
- << static_cast<const uchar *>(rgb32ImageData)
- << int(sizeof(rgb32ImageData))
- << 8
- << QVideoFrame::Format_RGB24
- << QSize(2, 2)
- << static_cast<const uchar *>(rgb24ImageData)
- << int(sizeof(rgb24ImageData))
- << 8;
-#endif
-
- QTest::newRow("rgb32 -> rgb565")
- << QVideoFrame::Format_RGB32
- << QSize(2, 2)
- << static_cast<const uchar *>(rgb32ImageData)
- << int(sizeof(rgb32ImageData))
- << 8
- << QVideoFrame::Format_RGB565
- << QSize(2, 2)
- << static_cast<const uchar *>(rgb565ImageData)
- << int(sizeof(rgb565ImageData))
- << 4;
-
-#if !defined(QT_OPENGL_ES)
- if (m_libGL)
- QTest::newRow("rgb24 -> rgb565")
- << QVideoFrame::Format_RGB24
- << QSize(2, 2)
- << static_cast<const uchar *>(rgb24ImageData)
- << int(sizeof(rgb24ImageData))
- << 8
- << QVideoFrame::Format_RGB565
- << QSize(2, 2)
- << static_cast<const uchar *>(rgb565ImageData)
- << int(sizeof(rgb565ImageData))
- << 4;
-#endif
-}
-
-void tst_QPainterVideoSurface::present()
-{
- QFETCH(QVideoFrame::PixelFormat, pixelFormatA);
- QFETCH(QSize, frameSizeA);
- QFETCH(const uchar *, frameDataA);
- QFETCH(int, bytesA);
- QFETCH(int, bytesPerLineA);
- QFETCH(QVideoFrame::PixelFormat, pixelFormatB);
- QFETCH(QSize, frameSizeB);
- QFETCH(const uchar *, frameDataB);
- QFETCH(int, bytesB);
- QFETCH(int, bytesPerLineB);
-
- QPainterVideoSurface surface;
-
- QImage image(320, 240, QImage::Format_RGB32);
-
- QSignalSpy frameSpy(&surface, SIGNAL(frameChanged()));
-
- const QList<QVideoFrame::PixelFormat> pixelFormats = surface.supportedPixelFormats();
-
- { // Test painting before started.
- QPainter painter(&image);
- surface.paint(&painter, QRect(0, 0, 320, 240));
- }
-
- QVideoSurfaceFormat formatA(frameSizeA, pixelFormatA);
-
- QVERIFY(surface.start(formatA));
- QCOMPARE(surface.isActive(), true);
- QCOMPARE(surface.isReady(), true);
-
- { // Test painting before receiving a frame.
- QPainter painter(&image);
- surface.paint(&painter, QRect(0, 0, 320, 240));
- }
- QCOMPARE(surface.error(), QAbstractVideoSurface::NoError);
-
- QVideoFrame frameA(bytesA, frameSizeA, bytesPerLineA, pixelFormatA);
-
- frameA.map(QAbstractVideoBuffer::WriteOnly);
- memcpy(frameA.bits(), frameDataA, frameA.mappedBytes());
- frameA.unmap();
-
- QVERIFY(surface.present(frameA));
- QCOMPARE(surface.isReady(), false);
- QCOMPARE(frameSpy.count(), 1);
-
- {
- QPainter painter(&image);
- surface.paint(&painter, QRect(0, 0, 320, 240));
- }
- QCOMPARE(surface.isActive(), true);
- QCOMPARE(surface.isReady(), false);
-
- { // Test repainting before receiving another frame.
- QPainter painter(&image);
- surface.paint(&painter, QRect(0, 0, 320, 240));
- }
- QCOMPARE(surface.isActive(), true);
- QCOMPARE(surface.isReady(), false);
-
- QVERIFY(surface.present(frameA));
- QCOMPARE(frameSpy.count(), 1);
-
- surface.setReady(true);
- QCOMPARE(surface.isReady(), true);
- QVERIFY(surface.present(frameA));
- QCOMPARE(frameSpy.count(), 2);
-
- // Try switching to a different format after starting.
- QVideoSurfaceFormat formatB(frameSizeB, pixelFormatB);
-
- QVERIFY(surface.start(formatB));
- QCOMPARE(surface.isActive(), true);
- QCOMPARE(surface.isReady(), true);
-
- QVideoFrame frameB(bytesB, frameSizeB, bytesPerLineB, pixelFormatB);
-
- frameB.map(QAbstractVideoBuffer::WriteOnly);
- memcpy(frameB.bits(), frameDataB, frameB.mappedBytes());
- frameB.unmap();
-
- QVERIFY(surface.present(frameB));
- QCOMPARE(surface.isReady(), false);
- QCOMPARE(frameSpy.count(), 3);
-
- {
- QPainter painter(&image);
- surface.paint(&painter, QRect(0, 0, 320, 240));
- }
- QVERIFY(surface.isActive());
-
- surface.stop();
-
- QCOMPARE(surface.isActive(), false);
- QCOMPARE(surface.isReady(), false);
-
- // Try presenting a frame while stopped.
- QVERIFY(!surface.present(frameB));
- QCOMPARE(surface.isReady(), false);
- QCOMPARE(surface.error(), QAbstractVideoSurface::StoppedError);
-
- // Try presenting a frame with a different format.
- QVERIFY(surface.start(formatB));
- QVERIFY(!surface.present(frameA));
- QCOMPARE(surface.isActive(), false);
- QCOMPARE(surface.isReady(), false);
- QCOMPARE(surface.error(), QAbstractVideoSurface::IncorrectFormatError);
-}
-
-void tst_QPainterVideoSurface::presentOpaqueFrame()
-{
- QPainterVideoSurface surface;
-
- QImage image(320, 240, QImage::Format_RGB32);
-
- QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32);
-
- QVERIFY(surface.start(format));
- QCOMPARE(surface.isActive(), true);
- QCOMPARE(surface.isReady(), true);
-
- QVideoFrame frame(new QtTestOpaqueVideoBuffer, QSize(64, 64), QVideoFrame::Format_RGB32);
-
- if (surface.present(frame)) {
- QPainter painter(&image);
- surface.paint(&painter, QRect(0, 0, 320, 240));
- }
-
- QCOMPARE(surface.isActive(), false);
- QCOMPARE(surface.isReady(), false);
- QCOMPARE(surface.error(), QAbstractVideoSurface::IncorrectFormatError);
-}
-
-#if QT_CONFIG(opengl)
-
-void tst_QPainterVideoSurface::shaderType()
-{
- QPainterVideoSurface surface;
- QOpenGLWidget widget;
- widget.show();
-
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
-
- if (!widget.context() || !widget.context()->isValid())
- QSKIP("Platform does not support OpenGLContext");
-
- QCOMPARE(surface.shaderType(), QPainterVideoSurface::NoShaders);
- QCOMPARE(surface.supportedShaderTypes(), QPainterVideoSurface::NoShaders);
-
- widget.makeCurrent();
- surface.updateGLContext();
- QCOMPARE(surface.glContext(), widget.context());
-
- {
- QSignalSpy spy(&surface, SIGNAL(supportedFormatsChanged()));
-
- surface.setShaderType(QPainterVideoSurface::NoShaders);
- QCOMPARE(surface.shaderType(), QPainterVideoSurface::NoShaders);
- QCOMPARE(spy.count(), 0);
- }
-
-#if !defined(QT_OPENGL_ES)
- if (surface.supportedShaderTypes() & QPainterVideoSurface::FragmentProgramShader) {
- QSignalSpy spy(&surface, SIGNAL(supportedFormatsChanged()));
-
- surface.setShaderType(QPainterVideoSurface::FragmentProgramShader);
- QCOMPARE(surface.shaderType(), QPainterVideoSurface::FragmentProgramShader);
- QCOMPARE(spy.count(), 1);
-
- surface.setShaderType(QPainterVideoSurface::FragmentProgramShader);
- QCOMPARE(surface.shaderType(), QPainterVideoSurface::FragmentProgramShader);
- QCOMPARE(spy.count(), 1);
- }
-#endif
-
- if (surface.supportedShaderTypes() & QPainterVideoSurface::GlslShader) {
- QSignalSpy spy(&surface, SIGNAL(supportedFormatsChanged()));
-
- surface.setShaderType(QPainterVideoSurface::GlslShader);
- QCOMPARE(surface.shaderType(), QPainterVideoSurface::GlslShader);
- QCOMPARE(spy.count(), 1);
-
- surface.setShaderType(QPainterVideoSurface::GlslShader);
- QCOMPARE(surface.shaderType(), QPainterVideoSurface::GlslShader);
- QCOMPARE(spy.count(), 1);
- }
-
- {
- QSignalSpy spy(&surface, SIGNAL(supportedFormatsChanged()));
-
- widget.makeCurrent();
- surface.updateGLContext();
- QCOMPARE(surface.glContext(), widget.context());
- QCOMPARE(spy.count(), 0);
- }
-
- widget.doneCurrent();
- surface.updateGLContext();
- QCOMPARE(surface.shaderType(), QPainterVideoSurface::NoShaders);
- QCOMPARE(surface.supportedShaderTypes(), QPainterVideoSurface::NoShaders);
-
- {
- QSignalSpy spy(&surface, SIGNAL(supportedFormatsChanged()));
-
- surface.setShaderType(QPainterVideoSurface::NoShaders);
- QCOMPARE(surface.shaderType(), QPainterVideoSurface::NoShaders);
- QCOMPARE(spy.count(), 0);
-
-#if !defined(QT_OPENGL_ES)
- surface.setShaderType(QPainterVideoSurface::FragmentProgramShader);
- QCOMPARE(surface.shaderType(), QPainterVideoSurface::NoShaders);
- QCOMPARE(spy.count(), 0);
-#endif
-
- surface.setShaderType(QPainterVideoSurface::GlslShader);
- QCOMPARE(surface.shaderType(), QPainterVideoSurface::NoShaders);
- QCOMPARE(spy.count(), 0);
- }
-}
-
-void tst_QPainterVideoSurface::shaderTypeStarted_data()
-{
- QTest::addColumn<QPainterVideoSurface::ShaderType>("shaderType");
-
-#if !defined(QT_OPENGL_ES)
- QTest::newRow("ARBfp")
- << QPainterVideoSurface::FragmentProgramShader;
-#endif
- QTest::newRow("GLSL")
- << QPainterVideoSurface::GlslShader;
-}
-
-void tst_QPainterVideoSurface::shaderTypeStarted()
-{
- QFETCH(QPainterVideoSurface::ShaderType, shaderType);
-
- QOpenGLWidget widget;
- widget.show();
-
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
-
- if (!widget.context() || !widget.context()->isValid())
- QSKIP("Platform does not support OpenGLContext");
-
- QPainterVideoSurface surface;
-
- widget.makeCurrent();
- surface.updateGLContext();
-
- if (!(surface.supportedShaderTypes() & shaderType))
- QSKIP("Shader type unsupported on this platform");
-
- surface.setShaderType(shaderType);
- QCOMPARE(surface.shaderType(), shaderType);
-
- QVERIFY(surface.start(QVideoSurfaceFormat(QSize(640, 480), QVideoFrame::Format_RGB32)));
- {
- QSignalSpy spy(&surface, SIGNAL(activeChanged(bool)));
-
- surface.setShaderType(QPainterVideoSurface::NoShaders);
- QCOMPARE(surface.shaderType(), QPainterVideoSurface::NoShaders);
- QCOMPARE(surface.isActive(), false);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.last().value(0).toBool(), false);
- }
-
- QVERIFY(surface.start(QVideoSurfaceFormat(QSize(640, 480), QVideoFrame::Format_RGB32)));
- {
- QSignalSpy spy(&surface, SIGNAL(activeChanged(bool)));
-
- surface.setShaderType(QPainterVideoSurface::NoShaders);
- QCOMPARE(surface.shaderType(), QPainterVideoSurface::NoShaders);
- QCOMPARE(surface.isActive(), true);
- QCOMPARE(spy.count(), 0);
-
- surface.setShaderType(shaderType);
- QCOMPARE(surface.shaderType(), shaderType);
- QCOMPARE(surface.isActive(), false);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.last().value(0).toBool(), false);
- }
-
- QVERIFY(surface.start(QVideoSurfaceFormat(QSize(640, 480), QVideoFrame::Format_RGB32)));
- {
- QSignalSpy spy(&surface, SIGNAL(activeChanged(bool)));
-
- surface.setShaderType(shaderType);
- QCOMPARE(surface.shaderType(), shaderType);
- QCOMPARE(surface.isActive(), true);
- QCOMPARE(spy.count(), 0);
-
- widget.doneCurrent();
- surface.updateGLContext();
- QCOMPARE(surface.shaderType(), QPainterVideoSurface::NoShaders);
- QCOMPARE(surface.isActive(), false);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.last().value(0).toBool(), false);
- }
-}
-
-void tst_QPainterVideoSurface::shaderSupportedFormat_data()
-{
- QTest::addColumn<QPainterVideoSurface::ShaderType>("shaderType");
- QTest::addColumn<QAbstractVideoBuffer::HandleType>("handleType");
- QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat");
- QTest::addColumn<QSize>("frameSize");
- QTest::addColumn<bool>("supportedPixelFormat");
- QTest::addColumn<bool>("supportedFormat");
-
- const QPair<QPainterVideoSurface::ShaderType, QByteArray> types[] = {
-#if !defined(QT_OPENGL_ES)
- qMakePair(QPainterVideoSurface::FragmentProgramShader, QByteArray("ARBfp: ")),
-#endif
- qMakePair(QPainterVideoSurface::GlslShader, QByteArray("GLSL: ")),
- };
-
- for (const auto &type : types) {
- QTest::newRow((type.second + "rgb32 640x480").constData())
- << type.first
- << QAbstractVideoBuffer::NoHandle
- << QVideoFrame::Format_RGB32
- << QSize(640, 480)
- << true
- << true;
- QTest::newRow((type.second + "rgb32 -640x480").constData())
- << type.first
- << QAbstractVideoBuffer::NoHandle
- << QVideoFrame::Format_RGB32
- << QSize(-640, 480)
- << true
- << false;
- QTest::newRow((type.second + "rgb565 32x32").constData())
- << type.first
- << QAbstractVideoBuffer::NoHandle
- << QVideoFrame::Format_RGB565
- << QSize(32, 32)
- << true
- << true;
- QTest::newRow((type.second + "rgb565 0x0").constData())
- << type.first
- << QAbstractVideoBuffer::NoHandle
- << QVideoFrame::Format_RGB565
- << QSize(0, 0)
- << true
- << false;
- QTest::newRow((type.second + "argb32 256x256").constData())
- << type.first
- << QAbstractVideoBuffer::NoHandle
- << QVideoFrame::Format_ARGB32
- << QSize(256, 256)
- << true
- << true;
- QTest::newRow((type.second + "rgb24 1024x768").constData())
- << type.first
- << QAbstractVideoBuffer::NoHandle
- << QVideoFrame::Format_RGB24
- << QSize(1024, 768)
-#if !defined(QT_OPENGL_ES)
- << m_libGL
- << m_libGL;
-#else
- << false
- << false;
-#endif
- QTest::newRow((type.second + "rgb24 -1024x-768").constData())
- << type.first
- << QAbstractVideoBuffer::NoHandle
- << QVideoFrame::Format_RGB24
- << QSize(-1024, -768)
-#if !defined(QT_OPENGL_ES)
- << m_libGL
-#else
- << false
-#endif
- << false;
-#ifndef Q_OS_MAC
- QTest::newRow((type.second + "YUV420P 640x480").constData())
- << type.first
- << QAbstractVideoBuffer::NoHandle
- << QVideoFrame::Format_YUV420P
- << QSize(640, 480)
- << true
- << true;
- QTest::newRow((type.second + "YUV420P 640x-480").constData())
- << type.first
- << QAbstractVideoBuffer::NoHandle
- << QVideoFrame::Format_YUV420P
- << QSize(640, -480)
- << true
- << false;
-#endif
- QTest::newRow((type.second + "Y8 640x480").constData())
- << type.first
- << QAbstractVideoBuffer::NoHandle
- << QVideoFrame::Format_Y8
- << QSize(640, 480)
- << false
- << false;
- QTest::newRow((type.second + "Texture: rgb32 640x480").constData())
- << type.first
- << QAbstractVideoBuffer::GLTextureHandle
- << QVideoFrame::Format_RGB32
- << QSize(640, 480)
- << true
- << true;
- QTest::newRow((type.second + "Texture: rgb32 -640x480").constData())
- << type.first
- << QAbstractVideoBuffer::GLTextureHandle
- << QVideoFrame::Format_RGB32
- << QSize(-640, 480)
- << true
- << false;
-#ifndef Q_OS_MAC
- QTest::newRow((type.second + "Texture: rgb565 32x32").constData())
- << type.first
- << QAbstractVideoBuffer::GLTextureHandle
- << QVideoFrame::Format_RGB565
- << QSize(32, 32)
- << false
- << false;
- QTest::newRow((type.second + "Texture: rgb565 0x0").constData())
- << type.first
- << QAbstractVideoBuffer::GLTextureHandle
- << QVideoFrame::Format_RGB565
- << QSize(0, 0)
- << false
- << false;
-#endif
- QTest::newRow((type.second + "Texture argb32 256x256").constData())
- << type.first
- << QAbstractVideoBuffer::GLTextureHandle
- << QVideoFrame::Format_ARGB32
- << QSize(256, 256)
- << true
- << true;
-#ifndef Q_OS_MAC
- QTest::newRow((type.second + "Texture: rgb24 1024x768").constData())
- << type.first
- << QAbstractVideoBuffer::GLTextureHandle
- << QVideoFrame::Format_RGB24
- << QSize(1024, 768)
- << false
- << false;
- QTest::newRow((type.second + "Texture: rgb24 -1024x-768").constData())
- << type.first
- << QAbstractVideoBuffer::GLTextureHandle
- << QVideoFrame::Format_RGB24
- << QSize(-1024, -768)
- << false
- << false;
- QTest::newRow((type.second + "Texture: YUV420P 640x480").constData())
- << type.first
- << QAbstractVideoBuffer::GLTextureHandle
- << QVideoFrame::Format_YUV420P
- << QSize(640, 480)
- << false
- << false;
- QTest::newRow((type.second + "Texture: YUV420P 640x-480").constData())
- << type.first
- << QAbstractVideoBuffer::GLTextureHandle
- << QVideoFrame::Format_YUV420P
- << QSize(640, -480)
- << false
- << false;
-#endif
- QTest::newRow(type.second + "User Buffer: rgb32 256x256")
- << type.first
- << QAbstractVideoBuffer::UserHandle
- << QVideoFrame::Format_RGB32
- << QSize(256, 256)
- << false
- << false;
- }
-}
-
-void tst_QPainterVideoSurface::shaderSupportedFormat()
-{
- QFETCH(QPainterVideoSurface::ShaderType, shaderType);
- QFETCH(QAbstractVideoBuffer::HandleType, handleType);
- QFETCH(QVideoFrame::PixelFormat, pixelFormat);
- QFETCH(QSize, frameSize);
- QFETCH(bool, supportedPixelFormat);
- QFETCH(bool, supportedFormat);
-
- QOpenGLWidget widget;
- widget.show();
-
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
-
- if (!widget.context() || !widget.context()->isValid())
- QSKIP("Platform does not support GLContext");
-
- QPainterVideoSurface surface;
- widget.makeCurrent();
- surface.updateGLContext();
-
-
- if (!(surface.supportedShaderTypes() & shaderType))
- QSKIP("Shader type not supported on this platform");
-
- surface.setShaderType(shaderType);
- if (surface.shaderType() != shaderType)
- QSKIP("Shader type couldn't be set");
-
- const QList<QVideoFrame::PixelFormat> pixelFormats = surface.supportedPixelFormats(handleType);
-
- QCOMPARE(pixelFormats.contains(pixelFormat), supportedPixelFormat);
-
- QVideoSurfaceFormat format(frameSize, pixelFormat, handleType);
-
- QCOMPARE(surface.isFormatSupported(format), supportedFormat);
- QCOMPARE(surface.start(format), supportedFormat);
-}
-
-void tst_QPainterVideoSurface::shaderPresent_data()
-{
- QTest::addColumn<QPainterVideoSurface::ShaderType>("shaderType");
- QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormatA");
- QTest::addColumn<QSize>("frameSizeA");
- QTest::addColumn<const uchar *>("frameDataA");
- QTest::addColumn<int>("bytesA");
- QTest::addColumn<int>("bytesPerLineA");
- QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormatB");
- QTest::addColumn<QSize>("frameSizeB");
- QTest::addColumn<const uchar *>("frameDataB");
- QTest::addColumn<int>("bytesB");
- QTest::addColumn<int>("bytesPerLineB");
-
- const QPair<QPainterVideoSurface::ShaderType, QByteArray> types[] = {
-#if !defined(QT_OPENGL_ES)
- qMakePair(QPainterVideoSurface::FragmentProgramShader, QByteArray("ARBfp: ")),
-#endif
- qMakePair(QPainterVideoSurface::GlslShader, QByteArray("GLSL: ")),
- };
-
- for (const auto &type : types) {
- QTest::newRow((type.second + "rgb32 -> argb32").constData())
- << type.first
- << QVideoFrame::Format_RGB32
- << QSize(2, 2)
- << static_cast<const uchar *>(rgb32ImageData)
- << int(sizeof(rgb32ImageData))
- << 8
- << QVideoFrame::Format_ARGB32
- << QSize(2, 2)
- << static_cast<const uchar *>(argb32ImageData)
- << int(sizeof(argb32ImageData))
- << 8;
-
- QTest::newRow((type.second + "rgb32 -> rgb565").constData())
- << type.first
- << QVideoFrame::Format_RGB32
- << QSize(2, 2)
- << static_cast<const uchar *>(rgb32ImageData)
- << int(sizeof(rgb32ImageData))
- << 8
- << QVideoFrame::Format_RGB565
- << QSize(2, 2)
- << static_cast<const uchar *>(rgb565ImageData)
- << int(sizeof(rgb565ImageData))
- << 4;
-#ifndef Q_OS_MAC
- QTest::newRow((type.second + "rgb32 -> yuv420p").constData())
- << type.first
- << QVideoFrame::Format_RGB32
- << QSize(2, 2)
- << static_cast<const uchar *>(rgb32ImageData)
- << int(sizeof(rgb32ImageData))
- << 8
- << QVideoFrame::Format_YUV420P
- << QSize(8, 8)
- << static_cast<const uchar *>(yuvPlanarImageData)
- << int(sizeof(yuvPlanarImageData))
- << 8;
-
- QTest::newRow((type.second + "yv12 -> rgb32").constData())
- << type.first
- << QVideoFrame::Format_YV12
- << QSize(8, 8)
- << static_cast<const uchar *>(yuvPlanarImageData)
- << int(sizeof(yuvPlanarImageData))
- << 8
- << QVideoFrame::Format_RGB32
- << QSize(2, 2)
- << static_cast<const uchar *>(rgb32ImageData)
- << int(sizeof(rgb32ImageData))
- << 8;
-#endif
- }
-}
-
-void tst_QPainterVideoSurface::shaderPresent()
-{
- QFETCH(QPainterVideoSurface::ShaderType, shaderType);
- QFETCH(QVideoFrame::PixelFormat, pixelFormatA);
- QFETCH(QSize, frameSizeA);
- QFETCH(const uchar *, frameDataA);
- QFETCH(int, bytesA);
- QFETCH(int, bytesPerLineA);
- QFETCH(QVideoFrame::PixelFormat, pixelFormatB);
- QFETCH(QSize, frameSizeB);
- QFETCH(const uchar *, frameDataB);
- QFETCH(int, bytesB);
- QFETCH(int, bytesPerLineB);
-
- QOpenGLWidget widget;
- widget.show();
-
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
-
- if (!widget.context() || !widget.context()->isValid())
- QSKIP("Platform does not support GLContext");
-
- QPainterVideoSurface surface;
- widget.makeCurrent();
- surface.updateGLContext();
-
- if (!(surface.supportedShaderTypes() & shaderType))
- QSKIP("Shader type unsupported on this platform");
-
- surface.setShaderType(shaderType);
- if (surface.shaderType() != shaderType)
- QSKIP("Shader type couldn't be set");
-
- QSignalSpy frameSpy(&surface, SIGNAL(frameChanged()));
-
- { // Test painting before starting the surface.
- QPainter painter(&widget);
- surface.paint(&painter, QRect(0, 0, 320, 240));
- }
- QCOMPARE(surface.error(), QAbstractVideoSurface::NoError);
-
- QVideoSurfaceFormat formatA(frameSizeA, pixelFormatA);
-
- QVERIFY(surface.start(formatA));
- QCOMPARE(surface.isActive(), true);
- QCOMPARE(surface.isReady(), true);
-
- // Test painting before receiving a frame.
- {
- QPainter painter(&widget);
- surface.paint(&painter, QRect(0, 0, 320, 240));
- }
- QCOMPARE(surface.isActive(), true);
- QCOMPARE(surface.isReady(), true);
-
- QVideoFrame frameA(bytesA, frameSizeA, bytesPerLineA, pixelFormatA);
-
- frameA.map(QAbstractVideoBuffer::WriteOnly);
- memcpy(frameA.bits(), frameDataA, frameA.mappedBytes());
- frameA.unmap();
-
- QVERIFY(surface.present(frameA));
- QCOMPARE(surface.isReady(), false);
- QCOMPARE(frameSpy.count(), 1);
-
- {
- QPainter painter(&widget);
- surface.paint(&painter, QRect(0, 0, 320, 240));
- }
- QCOMPARE(surface.isActive(), true);
- QCOMPARE(surface.isReady(), false);
-
- { // Test repainting before receiving another frame.
- QPainter painter(&widget);
- surface.paint(&painter, QRect(0, 0, 320, 240));
- }
- QCOMPARE(surface.isActive(), true);
- QCOMPARE(surface.isReady(), false);
-
- // If present() fails for any other reason the surface should immediately enter the stopped state
- // and an error() value will be set.
- QVERIFY(surface.present(frameA));
- QCOMPARE(frameSpy.count(), 1);
-
- surface.setReady(true);
- QCOMPARE(surface.isReady(), true);
- QVERIFY(surface.present(frameA));
- QCOMPARE(frameSpy.count(), 2);
-
- // Try switching to a different format after starting.
- QVideoSurfaceFormat formatB(frameSizeB, pixelFormatB);
-
- QVERIFY(surface.start(formatB));
- QCOMPARE(surface.isActive(), true);
- QCOMPARE(surface.isReady(), true);
-
- QVideoFrame frameB(bytesB, frameSizeB, bytesPerLineB, pixelFormatB);
-
- frameB.map(QAbstractVideoBuffer::WriteOnly);
- memcpy(frameB.bits(), frameDataB, frameB.mappedBytes());
- frameB.unmap();
-
- QVERIFY(surface.present(frameB));
- QCOMPARE(surface.isReady(), false);
- QCOMPARE(frameSpy.count(), 3);
-
- {
- QPainter painter(&widget);
- surface.paint(&painter, QRect(0, 0, 320, 240));
- }
- QCOMPARE(surface.isActive(), true);
-
- surface.stop();
- QCOMPARE(surface.isActive(), false);
- QCOMPARE(surface.isReady(), false);
-
- // Try presenting a frame while stopped.
- QVERIFY(!surface.present(frameB));
- QCOMPARE(surface.isReady(), false);
- QCOMPARE(surface.error(), QAbstractVideoSurface::StoppedError);
-
- // Try stopping while already stopped.
- surface.stop();
- QCOMPARE(surface.isActive(), false);
- QCOMPARE(surface.isReady(), false);
-
- // Try presenting a frame with a different format.
- QVERIFY(surface.start(formatB));
- QVERIFY(!surface.present(frameA));
- QCOMPARE(surface.isActive(), false);
- QCOMPARE(surface.isReady(), false);
- QCOMPARE(surface.error(), QAbstractVideoSurface::IncorrectFormatError);
-}
-
-void tst_QPainterVideoSurface::shaderPresentOpaqueFrame_data()
-{
- QTest::addColumn<QPainterVideoSurface::ShaderType>("shaderType");
-
-#if !defined(QT_OPENGL_ES)
- QTest::newRow("ARBfp")
- << QPainterVideoSurface::FragmentProgramShader;
-#endif
- QTest::newRow("GLSL")
- << QPainterVideoSurface::GlslShader;
-}
-
-void tst_QPainterVideoSurface::shaderPresentOpaqueFrame()
-{
- QFETCH(QPainterVideoSurface::ShaderType, shaderType);
-
- QOpenGLWidget widget;
- widget.show();
-
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
-
- if (!widget.context() || !widget.context()->isValid())
- QSKIP("Platform does not support GLContext");
-
- QPainterVideoSurface surface;
- widget.makeCurrent();
- surface.updateGLContext();
-
- if (!(surface.supportedShaderTypes() & shaderType))
- QSKIP("Shader type unsupported on this platform");
-
- surface.setShaderType(shaderType);
- if (surface.shaderType() != shaderType)
- QSKIP("Shader type couldn't be set");
-
- QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32);
-
- QVERIFY(surface.start(format));
- QCOMPARE(surface.isActive(), true);
- QCOMPARE(surface.isReady(), true);
-
- QVideoFrame frame(new QtTestOpaqueVideoBuffer, QSize(64, 64), QVideoFrame::Format_RGB32);
-
- if (surface.present(frame)) {
- QPainter painter(&widget);
- surface.paint(&painter, QRect(0, 0, 320, 240));
- }
-
- QCOMPARE(surface.isActive(), false);
- QCOMPARE(surface.isReady(), false);
- QCOMPARE(surface.error(), QAbstractVideoSurface::IncorrectFormatError);
-}
-
-void tst_QPainterVideoSurface::shaderPresentGLFrame_data()
-{
- QTest::addColumn<QPainterVideoSurface::ShaderType>("shaderType");
-
-#if !defined(QT_OPENGL_ES)
- QTest::newRow("ARBfp")
- << QPainterVideoSurface::FragmentProgramShader;
-#endif
- QTest::newRow("GLSL")
- << QPainterVideoSurface::GlslShader;
-}
-
-void tst_QPainterVideoSurface::shaderPresentGLFrame()
-{
- QFETCH(QPainterVideoSurface::ShaderType, shaderType);
-
- QOpenGLWidget widget;
- widget.show();
-
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
-
- if (!widget.context() || !widget.context()->isValid())
- QSKIP("Platform does not support GLContext");
-
- QPainterVideoSurface surface;
- widget.makeCurrent();
- surface.updateGLContext();
-
- if (!(surface.supportedShaderTypes() & shaderType))
- QSKIP("Shader type unsupported on this platform");
-
- surface.setShaderType(shaderType);
- if (surface.shaderType() != shaderType)
- QSKIP("Shader type couldn't be set");
-
- QVideoSurfaceFormat format(
- QSize(2, 2), QVideoFrame::Format_RGB32, QAbstractVideoBuffer::GLTextureHandle);
-
- QVERIFY(surface.start(format));
- QCOMPARE(surface.isActive(), true);
- QCOMPARE(surface.isReady(), true);
-
- QtTestGLVideoBuffer *buffer = new QtTestGLVideoBuffer;
-
- QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
- f->glBindTexture(GL_TEXTURE_2D, buffer->textureId());
- f->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 2, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, rgb32ImageData);
- f->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- f->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- f->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- f->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
-
- QVideoFrame frame(buffer, QSize(2, 2), QVideoFrame::Format_RGB32);
-
- QVERIFY(surface.present(frame));
-
- {
- QPainter painter(&widget);
- surface.paint(&painter, QRect(0, 0, 320, 240));
- }
-
- QCOMPARE(surface.isActive(), true);
- QCOMPARE(surface.isReady(), false);
-
- {
- QPainter painter(&widget);
- surface.paint(&painter, QRect(0, 0, 320, 240));
- }
-
- QCOMPARE(surface.isActive(), true);
- QCOMPARE(surface.isReady(), false);
-}
-
-#endif
-
-QTEST_MAIN(tst_QPainterVideoSurface)
-
-#include "tst_qpaintervideosurface.moc"
diff --git a/tests/auto/unit/qsamplecache/qsamplecache.pro b/tests/auto/unit/qsamplecache/qsamplecache.pro
deleted file mode 100644
index 02ca7cb18..000000000
--- a/tests/auto/unit/qsamplecache/qsamplecache.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qsamplecache
-
-QT += multimedia-private testlib
-
-SOURCES += tst_qsamplecache.cpp
-
-TESTDATA += testdata/*
diff --git a/tests/auto/unit/qvideoencodersettingscontrol/qvideoencodersettingscontrol.pro b/tests/auto/unit/qvideoencodersettingscontrol/qvideoencodersettingscontrol.pro
deleted file mode 100644
index 7b7ef7679..000000000
--- a/tests/auto/unit/qvideoencodersettingscontrol/qvideoencodersettingscontrol.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qvideoencodersettingscontrol
-
-QT += multimedia-private testlib
-
-SOURCES += \
- tst_qvideoencodersettingscontrol.cpp
-
diff --git a/tests/auto/unit/qvideoencodersettingscontrol/tst_qvideoencodersettingscontrol.cpp b/tests/auto/unit/qvideoencodersettingscontrol/tst_qvideoencodersettingscontrol.cpp
deleted file mode 100644
index 47da7be19..000000000
--- a/tests/auto/unit/qvideoencodersettingscontrol/tst_qvideoencodersettingscontrol.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//TESTED_COMPONENT=src/multimedia
-
-#include <QtTest/QtTest>
-#include "qvideoencodersettingscontrol.h"
-class MyVideEncoderControl: public QVideoEncoderSettingsControl
-{
- Q_OBJECT
-
-public:
- MyVideEncoderControl(QObject *parent = 0 ):QVideoEncoderSettingsControl(parent)
- {
-
- }
-
- ~MyVideEncoderControl()
- {
-
- }
-
- QList<QSize> supportedResolutions(const QVideoEncoderSettings &settings,bool *continuous = 0) const
- {
- Q_UNUSED(settings);
- Q_UNUSED(continuous);
-
- return (QList<QSize>());
- }
-
- QList<qreal> supportedFrameRates(const QVideoEncoderSettings &settings, bool *continuous = 0) const
- {
- Q_UNUSED(settings);
- Q_UNUSED(continuous);
-
- return (QList<qreal>());
-
- }
-
- QStringList supportedVideoCodecs() const
- {
- return QStringList();
-
- }
-
- QString videoCodecDescription(const QString &codecName) const
- {
- Q_UNUSED(codecName);
- return QString();
-
- }
-
- QVideoEncoderSettings videoSettings() const
- {
- return QVideoEncoderSettings();
- }
-
- void setVideoSettings(const QVideoEncoderSettings &settings)
- {
- Q_UNUSED(settings);
- }
-};
-
-class tst_QVideoEncoderSettingsControl: public QObject
-{
- Q_OBJECT
-private slots:
- void constructor();
-};
-
-void tst_QVideoEncoderSettingsControl::constructor()
-{
- QObject parent;
- MyVideEncoderControl control(&parent);
-}
-
-QTEST_MAIN(tst_QVideoEncoderSettingsControl)
-#include "tst_qvideoencodersettingscontrol.moc"
-
-
diff --git a/tests/auto/unit/qvideoframe/qvideoframe.pro b/tests/auto/unit/qvideoframe/qvideoframe.pro
deleted file mode 100644
index 2d7bc0360..000000000
--- a/tests/auto/unit/qvideoframe/qvideoframe.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qvideoframe
-
-QT += core multimedia-private testlib
-
-SOURCES += tst_qvideoframe.cpp
-
diff --git a/tests/auto/unit/qvideoframe/tst_qvideoframe.cpp b/tests/auto/unit/qvideoframe/tst_qvideoframe.cpp
deleted file mode 100644
index e99c4bf77..000000000
--- a/tests/auto/unit/qvideoframe/tst_qvideoframe.cpp
+++ /dev/null
@@ -1,1316 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//TESTED_COMPONENT=src/multimedia
-
-#include <QtTest/QtTest>
-
-#include <qvideoframe.h>
-#include "private/qmemoryvideobuffer_p.h"
-#include <QtGui/QImage>
-#include <QtCore/QPointer>
-#include <QtMultimedia/private/qtmultimedia-config_p.h>
-
-// Adds an enum, and the stringized version
-#define ADD_ENUM_TEST(x) \
- QTest::newRow(#x) \
- << QVideoFrame::x \
- << QString(QLatin1String(#x));
-
-
-class tst_QVideoFrame : public QObject
-{
- Q_OBJECT
-public:
- tst_QVideoFrame();
- ~tst_QVideoFrame();
-
-public slots:
- void initTestCase();
- void cleanupTestCase();
- void init();
- void cleanup();
-
-private slots:
- void create_data();
- void create();
- void createInvalid_data();
- void createInvalid();
- void createFromBuffer_data();
- void createFromBuffer();
- void createFromImage_data();
- void createFromImage();
- void createFromIncompatibleImage();
- void createNull();
- void destructor();
- void copy_data();
- void copy();
- void assign_data();
- void assign();
- void map_data();
- void map();
- void mapImage_data();
- void mapImage();
- void mapPlanes_data();
- void mapPlanes();
- void imageDetach();
- void formatConversion_data();
- void formatConversion();
-
- void metadata();
-
- void isMapped();
- void isReadable();
- void isWritable();
-
- void image_data();
- void image();
-
- void emptyData();
-};
-
-Q_DECLARE_METATYPE(QImage::Format)
-
-class QtTestVideoBuffer : public QObject, public QAbstractVideoBuffer
-{
- Q_OBJECT
-public:
- QtTestVideoBuffer()
- : QAbstractVideoBuffer(NoHandle) {}
- explicit QtTestVideoBuffer(QAbstractVideoBuffer::HandleType type)
- : QAbstractVideoBuffer(type) {}
-
- MapMode mapMode() const { return NotMapped; }
-
- uchar *map(MapMode, int *, int *) { return 0; }
- void unmap() {}
-};
-
-class QtTestPlanarVideoBuffer : public QAbstractPlanarVideoBuffer
-{
-public:
- QtTestPlanarVideoBuffer()
- : QAbstractPlanarVideoBuffer(NoHandle), m_planeCount(0), m_mapMode(NotMapped) {}
- explicit QtTestPlanarVideoBuffer(QAbstractVideoBuffer::HandleType type)
- : QAbstractPlanarVideoBuffer(type), m_planeCount(0), m_mapMode(NotMapped) {}
-
- MapMode mapMode() const { return m_mapMode; }
-
- int map(MapMode mode, int *numBytes, int bytesPerLine[4], uchar *data[4]) {
- m_mapMode = mode;
- if (numBytes)
- *numBytes = m_numBytes;
- for (int i = 0; i < m_planeCount; ++i) {
- data[i] = m_data[i];
- bytesPerLine[i] = m_bytesPerLine[i];
- }
- return m_planeCount;
- }
- void unmap() { m_mapMode = NotMapped; }
-
- uchar *m_data[4];
- int m_bytesPerLine[4];
- int m_planeCount;
- int m_numBytes;
- MapMode m_mapMode;
-};
-
-tst_QVideoFrame::tst_QVideoFrame()
-{
-}
-
-tst_QVideoFrame::~tst_QVideoFrame()
-{
-}
-
-void tst_QVideoFrame::initTestCase()
-{
-}
-
-void tst_QVideoFrame::cleanupTestCase()
-{
-}
-
-void tst_QVideoFrame::init()
-{
-}
-
-void tst_QVideoFrame::cleanup()
-{
-}
-
-void tst_QVideoFrame::create_data()
-{
- QTest::addColumn<QSize>("size");
- QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat");
- QTest::addColumn<int>("bytes");
- QTest::addColumn<int>("bytesPerLine");
-
- QTest::newRow("64x64 ARGB32")
- << QSize(64, 64)
- << QVideoFrame::Format_ARGB32
- << 16384
- << 256;
- QTest::newRow("32x256 YUV420P")
- << QSize(32, 256)
- << QVideoFrame::Format_YUV420P
- << 13288
- << 32;
-}
-
-void tst_QVideoFrame::create()
-{
- QFETCH(QSize, size);
- QFETCH(QVideoFrame::PixelFormat, pixelFormat);
- QFETCH(int, bytes);
- QFETCH(int, bytesPerLine);
-
- QVideoFrame frame(bytes, size, bytesPerLine, pixelFormat);
-
- QVERIFY(frame.isValid());
- QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle);
- QCOMPARE(frame.handle(), QVariant());
- QCOMPARE(frame.pixelFormat(), pixelFormat);
- QCOMPARE(frame.size(), size);
- QCOMPARE(frame.width(), size.width());
- QCOMPARE(frame.height(), size.height());
- QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame);
- QCOMPARE(frame.startTime(), qint64(-1));
- QCOMPARE(frame.endTime(), qint64(-1));
-}
-
-void tst_QVideoFrame::createInvalid_data()
-{
- QTest::addColumn<QSize>("size");
- QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat");
- QTest::addColumn<int>("bytes");
- QTest::addColumn<int>("bytesPerLine");
-
- QTest::newRow("64x64 ARGB32 0 size")
- << QSize(64, 64)
- << QVideoFrame::Format_ARGB32
- << 0
- << 45;
- QTest::newRow("32x256 YUV420P negative size")
- << QSize(32, 256)
- << QVideoFrame::Format_YUV420P
- << -13288
- << 32;
-}
-
-void tst_QVideoFrame::createInvalid()
-{
- QFETCH(QSize, size);
- QFETCH(QVideoFrame::PixelFormat, pixelFormat);
- QFETCH(int, bytes);
- QFETCH(int, bytesPerLine);
-
- QVideoFrame frame(bytes, size, bytesPerLine, pixelFormat);
-
- QVERIFY(!frame.isValid());
- QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle);
- QCOMPARE(frame.handle(), QVariant());
- QCOMPARE(frame.pixelFormat(), pixelFormat);
- QCOMPARE(frame.size(), size);
- QCOMPARE(frame.width(), size.width());
- QCOMPARE(frame.height(), size.height());
- QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame);
- QCOMPARE(frame.startTime(), qint64(-1));
- QCOMPARE(frame.endTime(), qint64(-1));
-}
-
-void tst_QVideoFrame::createFromBuffer_data()
-{
- QTest::addColumn<QAbstractVideoBuffer::HandleType>("handleType");
- QTest::addColumn<QSize>("size");
- QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat");
-
- QTest::newRow("64x64 ARGB32 no handle")
- << QAbstractVideoBuffer::NoHandle
- << QSize(64, 64)
- << QVideoFrame::Format_ARGB32;
- QTest::newRow("64x64 ARGB32 gl handle")
- << QAbstractVideoBuffer::GLTextureHandle
- << QSize(64, 64)
- << QVideoFrame::Format_ARGB32;
- QTest::newRow("64x64 ARGB32 user handle")
- << QAbstractVideoBuffer::UserHandle
- << QSize(64, 64)
- << QVideoFrame::Format_ARGB32;
-}
-
-void tst_QVideoFrame::createFromBuffer()
-{
- QFETCH(QAbstractVideoBuffer::HandleType, handleType);
- QFETCH(QSize, size);
- QFETCH(QVideoFrame::PixelFormat, pixelFormat);
-
- QVideoFrame frame(new QtTestVideoBuffer(handleType), size, pixelFormat);
-
- QVERIFY(frame.isValid());
- QCOMPARE(frame.handleType(), handleType);
- QCOMPARE(frame.pixelFormat(), pixelFormat);
- QCOMPARE(frame.size(), size);
- QCOMPARE(frame.width(), size.width());
- QCOMPARE(frame.height(), size.height());
- QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame);
- QCOMPARE(frame.startTime(), qint64(-1));
- QCOMPARE(frame.endTime(), qint64(-1));
-}
-
-void tst_QVideoFrame::createFromImage_data()
-{
- QTest::addColumn<QSize>("size");
- QTest::addColumn<QImage::Format>("imageFormat");
- QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat");
-
- QTest::newRow("64x64 RGB32")
- << QSize(64, 64)
- << QImage::Format_RGB32
- << QVideoFrame::Format_RGB32;
- QTest::newRow("12x45 RGB16")
- << QSize(12, 45)
- << QImage::Format_RGB16
- << QVideoFrame::Format_RGB565;
- QTest::newRow("19x46 ARGB32_Premultiplied")
- << QSize(19, 46)
- << QImage::Format_ARGB32_Premultiplied
- << QVideoFrame::Format_ARGB32_Premultiplied;
-}
-
-void tst_QVideoFrame::createFromImage()
-{
- QFETCH(QSize, size);
- QFETCH(QImage::Format, imageFormat);
- QFETCH(QVideoFrame::PixelFormat, pixelFormat);
-
- const QImage image(size.width(), size.height(), imageFormat);
-
- QVideoFrame frame(image);
-
- QVERIFY(frame.isValid());
- QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle);
- QCOMPARE(frame.pixelFormat(), pixelFormat);
- QCOMPARE(frame.size(), size);
- QCOMPARE(frame.width(), size.width());
- QCOMPARE(frame.height(), size.height());
- QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame);
- QCOMPARE(frame.startTime(), qint64(-1));
- QCOMPARE(frame.endTime(), qint64(-1));
-}
-
-void tst_QVideoFrame::createFromIncompatibleImage()
-{
- const QImage image(64, 64, QImage::Format_Mono);
-
- QVideoFrame frame(image);
-
- QVERIFY(!frame.isValid());
- QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle);
- QCOMPARE(frame.pixelFormat(), QVideoFrame::Format_Invalid);
- QCOMPARE(frame.size(), QSize(64, 64));
- QCOMPARE(frame.width(), 64);
- QCOMPARE(frame.height(), 64);
- QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame);
- QCOMPARE(frame.startTime(), qint64(-1));
- QCOMPARE(frame.endTime(), qint64(-1));
-}
-
-void tst_QVideoFrame::createNull()
-{
- // Default ctor
- {
- QVideoFrame frame;
-
- QVERIFY(!frame.isValid());
- QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle);
- QCOMPARE(frame.pixelFormat(), QVideoFrame::Format_Invalid);
- QCOMPARE(frame.size(), QSize());
- QCOMPARE(frame.width(), -1);
- QCOMPARE(frame.height(), -1);
- QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame);
- QCOMPARE(frame.startTime(), qint64(-1));
- QCOMPARE(frame.endTime(), qint64(-1));
- QCOMPARE(frame.mapMode(), QAbstractVideoBuffer::NotMapped);
- QVERIFY(!frame.map(QAbstractVideoBuffer::ReadOnly));
- QVERIFY(!frame.map(QAbstractVideoBuffer::ReadWrite));
- QVERIFY(!frame.map(QAbstractVideoBuffer::WriteOnly));
- QCOMPARE(frame.isMapped(), false);
- frame.unmap(); // Shouldn't crash
- QCOMPARE(frame.isReadable(), false);
- QCOMPARE(frame.isWritable(), false);
- }
-
- // Null buffer (shouldn't crash)
- {
- QVideoFrame frame(0, QSize(1024,768), QVideoFrame::Format_ARGB32);
- QVERIFY(!frame.isValid());
- QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle);
- QCOMPARE(frame.pixelFormat(), QVideoFrame::Format_ARGB32);
- QCOMPARE(frame.size(), QSize(1024, 768));
- QCOMPARE(frame.width(), 1024);
- QCOMPARE(frame.height(), 768);
- QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame);
- QCOMPARE(frame.startTime(), qint64(-1));
- QCOMPARE(frame.endTime(), qint64(-1));
- QCOMPARE(frame.mapMode(), QAbstractVideoBuffer::NotMapped);
- QVERIFY(!frame.map(QAbstractVideoBuffer::ReadOnly));
- QVERIFY(!frame.map(QAbstractVideoBuffer::ReadWrite));
- QVERIFY(!frame.map(QAbstractVideoBuffer::WriteOnly));
- QCOMPARE(frame.isMapped(), false);
- frame.unmap(); // Shouldn't crash
- QCOMPARE(frame.isReadable(), false);
- QCOMPARE(frame.isWritable(), false);
- }
-}
-
-void tst_QVideoFrame::destructor()
-{
- QPointer<QtTestVideoBuffer> buffer = new QtTestVideoBuffer;
-
- {
- QVideoFrame frame(buffer, QSize(4, 1), QVideoFrame::Format_ARGB32);
- }
-
- QVERIFY(buffer.isNull());
-}
-
-void tst_QVideoFrame::copy_data()
-{
- QTest::addColumn<QAbstractVideoBuffer::HandleType>("handleType");
- QTest::addColumn<QSize>("size");
- QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat");
- QTest::addColumn<QVideoFrame::FieldType>("fieldType");
- QTest::addColumn<qint64>("startTime");
- QTest::addColumn<qint64>("endTime");
-
- QTest::newRow("64x64 ARGB32")
- << QAbstractVideoBuffer::GLTextureHandle
- << QSize(64, 64)
- << QVideoFrame::Format_ARGB32
- << QVideoFrame::TopField
- << qint64(63641740)
- << qint64(63641954);
- QTest::newRow("64x64 ARGB32")
- << QAbstractVideoBuffer::GLTextureHandle
- << QSize(64, 64)
- << QVideoFrame::Format_ARGB32
- << QVideoFrame::BottomField
- << qint64(63641740)
- << qint64(63641954);
- QTest::newRow("32x256 YUV420P")
- << QAbstractVideoBuffer::UserHandle
- << QSize(32, 256)
- << QVideoFrame::Format_YUV420P
- << QVideoFrame::InterlacedFrame
- << qint64(12345)
- << qint64(12389);
- QTest::newRow("1052x756 ARGB32")
- << QAbstractVideoBuffer::NoHandle
- << QSize(1052, 756)
- << QVideoFrame::Format_ARGB32
- << QVideoFrame::ProgressiveFrame
- << qint64(12345)
- << qint64(12389);
- QTest::newRow("32x256 YUV420P")
- << QAbstractVideoBuffer::UserHandle
- << QSize(32, 256)
- << QVideoFrame::Format_YUV420P
- << QVideoFrame::InterlacedFrame
- << qint64(12345)
- << qint64(12389);
-}
-
-void tst_QVideoFrame::copy()
-{
- QFETCH(QAbstractVideoBuffer::HandleType, handleType);
- QFETCH(QSize, size);
- QFETCH(QVideoFrame::PixelFormat, pixelFormat);
- QFETCH(QVideoFrame::FieldType, fieldType);
- QFETCH(qint64, startTime);
- QFETCH(qint64, endTime);
-
- QPointer<QtTestVideoBuffer> buffer = new QtTestVideoBuffer(handleType);
-
- {
- QVideoFrame frame(buffer, size, pixelFormat);
- frame.setFieldType(QVideoFrame::FieldType(fieldType));
- frame.setStartTime(startTime);
- frame.setEndTime(endTime);
-
- QVERIFY(frame.isValid());
- QCOMPARE(frame.handleType(), handleType);
- QCOMPARE(frame.pixelFormat(), pixelFormat);
- QCOMPARE(frame.size(), size);
- QCOMPARE(frame.width(), size.width());
- QCOMPARE(frame.height(), size.height());
- QCOMPARE(frame.fieldType(), fieldType);
- QCOMPARE(frame.startTime(), startTime);
- QCOMPARE(frame.endTime(), endTime);
-
- {
- QVideoFrame otherFrame(frame);
-
- QVERIFY(!buffer.isNull());
-
- QVERIFY(otherFrame.isValid());
- QCOMPARE(otherFrame.handleType(), handleType);
- QCOMPARE(otherFrame.pixelFormat(), pixelFormat);
- QCOMPARE(otherFrame.size(), size);
- QCOMPARE(otherFrame.width(), size.width());
- QCOMPARE(otherFrame.height(), size.height());
- QCOMPARE(otherFrame.fieldType(), fieldType);
- QCOMPARE(otherFrame.startTime(), startTime);
- QCOMPARE(otherFrame.endTime(), endTime);
-
- otherFrame.setEndTime(-1);
-
- QVERIFY(!buffer.isNull());
-
- QVERIFY(otherFrame.isValid());
- QCOMPARE(otherFrame.handleType(), handleType);
- QCOMPARE(otherFrame.pixelFormat(), pixelFormat);
- QCOMPARE(otherFrame.size(), size);
- QCOMPARE(otherFrame.width(), size.width());
- QCOMPARE(otherFrame.height(), size.height());
- QCOMPARE(otherFrame.fieldType(), fieldType);
- QCOMPARE(otherFrame.startTime(), startTime);
- QCOMPARE(otherFrame.endTime(), qint64(-1));
- }
-
- QVERIFY(!buffer.isNull());
-
- QVERIFY(frame.isValid());
- QCOMPARE(frame.handleType(), handleType);
- QCOMPARE(frame.pixelFormat(), pixelFormat);
- QCOMPARE(frame.size(), size);
- QCOMPARE(frame.width(), size.width());
- QCOMPARE(frame.height(), size.height());
- QCOMPARE(frame.fieldType(), fieldType);
- QCOMPARE(frame.startTime(), startTime);
- QCOMPARE(frame.endTime(), qint64(-1)); // Explicitly shared.
- }
-
- QVERIFY(buffer.isNull());
-}
-
-void tst_QVideoFrame::assign_data()
-{
- QTest::addColumn<QAbstractVideoBuffer::HandleType>("handleType");
- QTest::addColumn<QSize>("size");
- QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat");
- QTest::addColumn<QVideoFrame::FieldType>("fieldType");
- QTest::addColumn<qint64>("startTime");
- QTest::addColumn<qint64>("endTime");
-
- QTest::newRow("64x64 ARGB32")
- << QAbstractVideoBuffer::GLTextureHandle
- << QSize(64, 64)
- << QVideoFrame::Format_ARGB32
- << QVideoFrame::TopField
- << qint64(63641740)
- << qint64(63641954);
- QTest::newRow("32x256 YUV420P")
- << QAbstractVideoBuffer::UserHandle
- << QSize(32, 256)
- << QVideoFrame::Format_YUV420P
- << QVideoFrame::InterlacedFrame
- << qint64(12345)
- << qint64(12389);
-}
-
-void tst_QVideoFrame::assign()
-{
- QFETCH(QAbstractVideoBuffer::HandleType, handleType);
- QFETCH(QSize, size);
- QFETCH(QVideoFrame::PixelFormat, pixelFormat);
- QFETCH(QVideoFrame::FieldType, fieldType);
- QFETCH(qint64, startTime);
- QFETCH(qint64, endTime);
-
- QPointer<QtTestVideoBuffer> buffer = new QtTestVideoBuffer(handleType);
-
- QVideoFrame frame;
- {
- QVideoFrame otherFrame(buffer, size, pixelFormat);
- otherFrame.setFieldType(fieldType);
- otherFrame.setStartTime(startTime);
- otherFrame.setEndTime(endTime);
-
- frame = otherFrame;
-
- QVERIFY(!buffer.isNull());
-
- QVERIFY(otherFrame.isValid());
- QCOMPARE(otherFrame.handleType(), handleType);
- QCOMPARE(otherFrame.pixelFormat(), pixelFormat);
- QCOMPARE(otherFrame.size(), size);
- QCOMPARE(otherFrame.width(), size.width());
- QCOMPARE(otherFrame.height(), size.height());
- QCOMPARE(otherFrame.fieldType(), fieldType);
- QCOMPARE(otherFrame.startTime(), startTime);
- QCOMPARE(otherFrame.endTime(), endTime);
-
- otherFrame.setStartTime(-1);
-
- QVERIFY(!buffer.isNull());
-
- QVERIFY(otherFrame.isValid());
- QCOMPARE(otherFrame.handleType(), handleType);
- QCOMPARE(otherFrame.pixelFormat(), pixelFormat);
- QCOMPARE(otherFrame.size(), size);
- QCOMPARE(otherFrame.width(), size.width());
- QCOMPARE(otherFrame.height(), size.height());
- QCOMPARE(otherFrame.fieldType(), fieldType);
- QCOMPARE(otherFrame.startTime(), qint64(-1));
- QCOMPARE(otherFrame.endTime(), endTime);
- }
-
- QVERIFY(!buffer.isNull());
-
- QVERIFY(frame.isValid());
- QCOMPARE(frame.handleType(), handleType);
- QCOMPARE(frame.pixelFormat(), pixelFormat);
- QCOMPARE(frame.size(), size);
- QCOMPARE(frame.width(), size.width());
- QCOMPARE(frame.height(), size.height());
- QCOMPARE(frame.fieldType(), fieldType);
- QCOMPARE(frame.startTime(), qint64(-1));
- QCOMPARE(frame.endTime(), endTime);
-
- frame = QVideoFrame();
-
- QVERIFY(buffer.isNull());
-
- QVERIFY(!frame.isValid());
- QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle);
- QCOMPARE(frame.pixelFormat(), QVideoFrame::Format_Invalid);
- QCOMPARE(frame.size(), QSize());
- QCOMPARE(frame.width(), -1);
- QCOMPARE(frame.height(), -1);
- QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame);
- QCOMPARE(frame.startTime(), qint64(-1));
- QCOMPARE(frame.endTime(), qint64(-1));
-}
-
-void tst_QVideoFrame::map_data()
-{
- QTest::addColumn<QSize>("size");
- QTest::addColumn<int>("mappedBytes");
- QTest::addColumn<int>("bytesPerLine");
- QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat");
- QTest::addColumn<QAbstractVideoBuffer::MapMode>("mode");
-
- QTest::newRow("read-only")
- << QSize(64, 64)
- << 16384
- << 256
- << QVideoFrame::Format_ARGB32
- << QAbstractVideoBuffer::ReadOnly;
-
- QTest::newRow("write-only")
- << QSize(64, 64)
- << 16384
- << 256
- << QVideoFrame::Format_ARGB32
- << QAbstractVideoBuffer::WriteOnly;
-
- QTest::newRow("read-write")
- << QSize(64, 64)
- << 16384
- << 256
- << QVideoFrame::Format_ARGB32
- << QAbstractVideoBuffer::ReadWrite;
-}
-
-void tst_QVideoFrame::map()
-{
- QFETCH(QSize, size);
- QFETCH(int, mappedBytes);
- QFETCH(int, bytesPerLine);
- QFETCH(QVideoFrame::PixelFormat, pixelFormat);
- QFETCH(QAbstractVideoBuffer::MapMode, mode);
-
- QVideoFrame frame(mappedBytes, size, bytesPerLine, pixelFormat);
-
- QVERIFY(!frame.bits());
- QCOMPARE(frame.mappedBytes(), 0);
- QCOMPARE(frame.bytesPerLine(), 0);
- QCOMPARE(frame.mapMode(), QAbstractVideoBuffer::NotMapped);
-
- QVERIFY(frame.map(mode));
-
- // Mapping multiple times is allowed in ReadOnly mode
- if (mode == QAbstractVideoBuffer::ReadOnly) {
- const uchar *bits = frame.bits();
-
- QVERIFY(frame.map(QAbstractVideoBuffer::ReadOnly));
- QVERIFY(frame.isMapped());
- QCOMPARE(frame.bits(), bits);
-
- frame.unmap();
- //frame should still be mapped after the first nested unmap
- QVERIFY(frame.isMapped());
- QCOMPARE(frame.bits(), bits);
-
- //re-mapping in Write or ReadWrite modes should fail
- QVERIFY(!frame.map(QAbstractVideoBuffer::WriteOnly));
- QVERIFY(!frame.map(QAbstractVideoBuffer::ReadWrite));
- } else {
- // Mapping twice in ReadWrite or WriteOnly modes should fail, but leave it mapped (and the mode is ignored)
- QVERIFY(!frame.map(mode));
- QVERIFY(!frame.map(QAbstractVideoBuffer::ReadOnly));
- }
-
- QVERIFY(frame.bits());
- QCOMPARE(frame.mappedBytes(), mappedBytes);
- QCOMPARE(frame.bytesPerLine(), bytesPerLine);
- QCOMPARE(frame.mapMode(), mode);
-
- frame.unmap();
-
- QVERIFY(!frame.bits());
- QCOMPARE(frame.mappedBytes(), 0);
- QCOMPARE(frame.bytesPerLine(), 0);
- QCOMPARE(frame.mapMode(), QAbstractVideoBuffer::NotMapped);
-}
-
-void tst_QVideoFrame::mapImage_data()
-{
- QTest::addColumn<QSize>("size");
- QTest::addColumn<QImage::Format>("format");
- QTest::addColumn<QAbstractVideoBuffer::MapMode>("mode");
-
- QTest::newRow("read-only")
- << QSize(64, 64)
- << QImage::Format_ARGB32
- << QAbstractVideoBuffer::ReadOnly;
-
- QTest::newRow("write-only")
- << QSize(15, 106)
- << QImage::Format_RGB32
- << QAbstractVideoBuffer::WriteOnly;
-
- QTest::newRow("read-write")
- << QSize(23, 111)
- << QImage::Format_RGB16
- << QAbstractVideoBuffer::ReadWrite;
-}
-
-void tst_QVideoFrame::mapImage()
-{
- QFETCH(QSize, size);
- QFETCH(QImage::Format, format);
- QFETCH(QAbstractVideoBuffer::MapMode, mode);
-
- QImage image(size.width(), size.height(), format);
-
- QVideoFrame frame(image);
-
- QVERIFY(!frame.bits());
- QCOMPARE(frame.mappedBytes(), 0);
- QCOMPARE(frame.bytesPerLine(), 0);
- QCOMPARE(frame.mapMode(), QAbstractVideoBuffer::NotMapped);
-
- QVERIFY(frame.map(mode));
-
- QVERIFY(frame.bits());
- QCOMPARE(qsizetype(frame.mappedBytes()), image.sizeInBytes());
- QCOMPARE(frame.bytesPerLine(), image.bytesPerLine());
- QCOMPARE(frame.mapMode(), mode);
-
- frame.unmap();
-
- QVERIFY(!frame.bits());
- QCOMPARE(frame.mappedBytes(), 0);
- QCOMPARE(frame.bytesPerLine(), 0);
- QCOMPARE(frame.mapMode(), QAbstractVideoBuffer::NotMapped);
-}
-
-void tst_QVideoFrame::mapPlanes_data()
-{
- QTest::addColumn<QVideoFrame>("frame");
- QTest::addColumn<QList<int> >("strides");
- QTest::addColumn<QList<int> >("offsets");
-
- static uchar bufferData[1024];
-
- QtTestPlanarVideoBuffer *planarBuffer = new QtTestPlanarVideoBuffer;
- planarBuffer->m_data[0] = bufferData;
- planarBuffer->m_data[1] = bufferData + 512;
- planarBuffer->m_data[2] = bufferData + 765;
- planarBuffer->m_bytesPerLine[0] = 64;
- planarBuffer->m_bytesPerLine[1] = 36;
- planarBuffer->m_bytesPerLine[2] = 36;
- planarBuffer->m_planeCount = 3;
- planarBuffer->m_numBytes = sizeof(bufferData);
-
- QTest::newRow("Planar")
- << QVideoFrame(planarBuffer, QSize(64, 64), QVideoFrame::Format_YUV420P)
- << (QList<int>() << 64 << 36 << 36)
- << (QList<int>() << 512 << 765);
- QTest::newRow("Format_YUV420P")
- << QVideoFrame(8096, QSize(60, 64), 64, QVideoFrame::Format_YUV420P)
- << (QList<int>() << 64 << 62 << 62)
- << (QList<int>() << 4096 << 6080);
- QTest::newRow("Format_YV12")
- << QVideoFrame(8096, QSize(60, 64), 64, QVideoFrame::Format_YV12)
- << (QList<int>() << 64 << 62 << 62)
- << (QList<int>() << 4096 << 6080);
- QTest::newRow("Format_NV12")
- << QVideoFrame(8096, QSize(60, 64), 64, QVideoFrame::Format_NV12)
- << (QList<int>() << 64 << 64)
- << (QList<int>() << 4096);
- QTest::newRow("Format_NV21")
- << QVideoFrame(8096, QSize(60, 64), 64, QVideoFrame::Format_NV21)
- << (QList<int>() << 64 << 64)
- << (QList<int>() << 4096);
- QTest::newRow("Format_IMC2")
- << QVideoFrame(8096, QSize(60, 64), 64, QVideoFrame::Format_IMC2)
- << (QList<int>() << 64 << 64)
- << (QList<int>() << 4096);
- QTest::newRow("Format_IMC4")
- << QVideoFrame(8096, QSize(60, 64), 64, QVideoFrame::Format_IMC4)
- << (QList<int>() << 64 << 64)
- << (QList<int>() << 4096);
- QTest::newRow("Format_IMC1")
- << QVideoFrame(8096, QSize(60, 64), 64, QVideoFrame::Format_IMC1)
- << (QList<int>() << 64 << 64 << 64)
- << (QList<int>() << 4096 << 6144);
- QTest::newRow("Format_IMC3")
- << QVideoFrame(8096, QSize(60, 64), 64, QVideoFrame::Format_IMC3)
- << (QList<int>() << 64 << 64 << 64)
- << (QList<int>() << 4096 << 6144);
- QTest::newRow("Format_ARGB32")
- << QVideoFrame(8096, QSize(60, 64), 256, QVideoFrame::Format_ARGB32)
- << (QList<int>() << 256)
- << (QList<int>());
-}
-
-void tst_QVideoFrame::mapPlanes()
-{
- QFETCH(QVideoFrame, frame);
- QFETCH(QList<int>, strides);
- QFETCH(QList<int>, offsets);
-
- QCOMPARE(strides.count(), offsets.count() + 1);
-
- QCOMPARE(frame.map(QAbstractVideoBuffer::ReadOnly), true);
- QCOMPARE(frame.planeCount(), strides.count());
-
- QVERIFY(strides.count() > 0);
- QCOMPARE(frame.bytesPerLine(0), strides.at(0));
- QVERIFY(frame.bits(0));
-
- if (strides.count() > 1) {
- QCOMPARE(frame.bytesPerLine(1), strides.at(1));
- QCOMPARE(int(frame.bits(1) - frame.bits(0)), offsets.at(0));
- }
- if (strides.count() > 2) {
- QCOMPARE(frame.bytesPerLine(2), strides.at(2));
- QCOMPARE(int(frame.bits(2) - frame.bits(0)), offsets.at(1));
- }
- if (strides.count() > 3) {
- QCOMPARE(frame.bytesPerLine(3), strides.at(3));
- QCOMPARE(int(frame.bits(3) - frame.bits(0)), offsets.at(0));
- }
-
- frame.unmap();
-}
-
-void tst_QVideoFrame::imageDetach()
-{
- const uint red = qRgb(255, 0, 0);
- const uint blue = qRgb(0, 0, 255);
-
- QImage image(8, 8, QImage::Format_RGB32);
-
- image.fill(red);
- QCOMPARE(image.pixel(4, 4), red);
-
- QVideoFrame frame(image);
-
- QVERIFY(frame.map(QAbstractVideoBuffer::ReadWrite));
-
- QImage frameImage(frame.bits(), 8, 8, frame.bytesPerLine(), QImage::Format_RGB32);
-
- QCOMPARE(frameImage.pixel(4, 4), red);
-
- frameImage.fill(blue);
- QCOMPARE(frameImage.pixel(4, 4), blue);
-
- // Original image has detached and is therefore unchanged.
- QCOMPARE(image.pixel(4, 4), red);
-}
-
-void tst_QVideoFrame::formatConversion_data()
-{
- QTest::addColumn<QImage::Format>("imageFormat");
- QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat");
-
- QTest::newRow("QImage::Format_RGB32 | QVideoFrame::Format_RGB32")
- << QImage::Format_RGB32
- << QVideoFrame::Format_RGB32;
- QTest::newRow("QImage::Format_ARGB32 | QVideoFrame::Format_ARGB32")
- << QImage::Format_ARGB32
- << QVideoFrame::Format_ARGB32;
- QTest::newRow("QImage::Format_ARGB32_Premultiplied | QVideoFrame::Format_ARGB32_Premultiplied")
- << QImage::Format_ARGB32_Premultiplied
- << QVideoFrame::Format_ARGB32_Premultiplied;
- QTest::newRow("QImage::Format_RGB16 | QVideoFrame::Format_RGB565")
- << QImage::Format_RGB16
- << QVideoFrame::Format_RGB565;
- QTest::newRow("QImage::Format_ARGB8565_Premultiplied | QVideoFrame::Format_ARGB8565_Premultiplied")
- << QImage::Format_ARGB8565_Premultiplied
- << QVideoFrame::Format_ARGB8565_Premultiplied;
- QTest::newRow("QImage::Format_RGB555 | QVideoFrame::Format_RGB555")
- << QImage::Format_RGB555
- << QVideoFrame::Format_RGB555;
- QTest::newRow("QImage::Format_RGB888 | QVideoFrame::Format_RGB24")
- << QImage::Format_RGB888
- << QVideoFrame::Format_RGB24;
-
- QTest::newRow("QImage::Format_MonoLSB")
- << QImage::Format_MonoLSB
- << QVideoFrame::Format_Invalid;
- QTest::newRow("QImage::Format_Indexed8")
- << QImage::Format_Indexed8
- << QVideoFrame::Format_Invalid;
- QTest::newRow("QImage::Format_ARGB6666_Premultiplied")
- << QImage::Format_ARGB6666_Premultiplied
- << QVideoFrame::Format_Invalid;
- QTest::newRow("QImage::Format_ARGB8555_Premultiplied")
- << QImage::Format_ARGB8555_Premultiplied
- << QVideoFrame::Format_Invalid;
- QTest::newRow("QImage::Format_RGB666")
- << QImage::Format_RGB666
- << QVideoFrame::Format_Invalid;
- QTest::newRow("QImage::Format_RGB444")
- << QImage::Format_RGB444
- << QVideoFrame::Format_Invalid;
- QTest::newRow("QImage::Format_ARGB4444_Premultiplied")
- << QImage::Format_ARGB4444_Premultiplied
- << QVideoFrame::Format_Invalid;
-
- QTest::newRow("QVideoFrame::Format_BGRA32")
- << QImage::Format_Invalid
- << QVideoFrame::Format_BGRA32;
- QTest::newRow("QVideoFrame::Format_BGRA32_Premultiplied")
- << QImage::Format_Invalid
- << QVideoFrame::Format_BGRA32_Premultiplied;
- QTest::newRow("QVideoFrame::Format_BGR32")
- << QImage::Format_Invalid
- << QVideoFrame::Format_BGR32;
- QTest::newRow("QVideoFrame::Format_BGR24")
- << QImage::Format_Invalid
- << QVideoFrame::Format_BGR24;
- QTest::newRow("QVideoFrame::Format_BGR565")
- << QImage::Format_Invalid
- << QVideoFrame::Format_BGR565;
- QTest::newRow("QVideoFrame::Format_BGR555")
- << QImage::Format_Invalid
- << QVideoFrame::Format_BGR555;
- QTest::newRow("QVideoFrame::Format_BGRA5658_Premultiplied")
- << QImage::Format_Invalid
- << QVideoFrame::Format_BGRA5658_Premultiplied;
- QTest::newRow("QVideoFrame::Format_AYUV444")
- << QImage::Format_Invalid
- << QVideoFrame::Format_AYUV444;
- QTest::newRow("QVideoFrame::Format_AYUV444_Premultiplied")
- << QImage::Format_Invalid
- << QVideoFrame::Format_AYUV444_Premultiplied;
- QTest::newRow("QVideoFrame::Format_YUV444")
- << QImage::Format_Invalid
- << QVideoFrame::Format_YUV444;
- QTest::newRow("QVideoFrame::Format_YUV420P")
- << QImage::Format_Invalid
- << QVideoFrame::Format_YUV420P;
- QTest::newRow("QVideoFrame::Format_YV12")
- << QImage::Format_Invalid
- << QVideoFrame::Format_YV12;
- QTest::newRow("QVideoFrame::Format_UYVY")
- << QImage::Format_Invalid
- << QVideoFrame::Format_UYVY;
- QTest::newRow("QVideoFrame::Format_YUYV")
- << QImage::Format_Invalid
- << QVideoFrame::Format_YUYV;
- QTest::newRow("QVideoFrame::Format_NV12")
- << QImage::Format_Invalid
- << QVideoFrame::Format_NV12;
- QTest::newRow("QVideoFrame::Format_NV21")
- << QImage::Format_Invalid
- << QVideoFrame::Format_NV21;
- QTest::newRow("QVideoFrame::Format_IMC1")
- << QImage::Format_Invalid
- << QVideoFrame::Format_IMC1;
- QTest::newRow("QVideoFrame::Format_IMC2")
- << QImage::Format_Invalid
- << QVideoFrame::Format_IMC2;
- QTest::newRow("QVideoFrame::Format_IMC3")
- << QImage::Format_Invalid
- << QVideoFrame::Format_IMC3;
- QTest::newRow("QVideoFrame::Format_IMC4")
- << QImage::Format_Invalid
- << QVideoFrame::Format_IMC4;
- QTest::newRow("QVideoFrame::Format_Y8")
- << QImage::Format_Grayscale8
- << QVideoFrame::Format_Y8;
- QTest::newRow("QVideoFrame::Format_Y16")
- << QImage::Format_Invalid
- << QVideoFrame::Format_Y16;
- QTest::newRow("QVideoFrame::Format_Jpeg")
- << QImage::Format_Invalid
- << QVideoFrame::Format_Jpeg;
- QTest::newRow("QVideoFrame::Format_CameraRaw")
- << QImage::Format_Invalid
- << QVideoFrame::Format_CameraRaw;
- QTest::newRow("QVideoFrame::Format_AdobeDng")
- << QImage::Format_Invalid
- << QVideoFrame::Format_AdobeDng;
- QTest::newRow("QVideoFrame::Format_User")
- << QImage::Format_Invalid
- << QVideoFrame::Format_User;
- QTest::newRow("QVideoFrame::Format_User + 1")
- << QImage::Format_Invalid
- << QVideoFrame::PixelFormat(QVideoFrame::Format_User + 1);
-}
-
-void tst_QVideoFrame::formatConversion()
-{
- QFETCH(QImage::Format, imageFormat);
- QFETCH(QVideoFrame::PixelFormat, pixelFormat);
-
- QCOMPARE(QVideoFrame::pixelFormatFromImageFormat(imageFormat) == pixelFormat,
- imageFormat != QImage::Format_Invalid);
-
- QCOMPARE(QVideoFrame::imageFormatFromPixelFormat(pixelFormat) == imageFormat,
- pixelFormat != QVideoFrame::Format_Invalid);
-}
-
-void tst_QVideoFrame::metadata()
-{
- // Simple metadata test
- QVideoFrame f;
-
- QCOMPARE(f.availableMetaData(), QVariantMap());
- f.setMetaData("frob", QVariant("string"));
- f.setMetaData("bar", QVariant(42));
- QCOMPARE(f.metaData("frob"), QVariant("string"));
- QCOMPARE(f.metaData("bar"), QVariant(42));
-
- QVariantMap map;
- map.insert("frob", QVariant("string"));
- map.insert("bar", QVariant(42));
-
- QCOMPARE(f.availableMetaData(), map);
-
- f.setMetaData("frob", QVariant(56));
- QCOMPARE(f.metaData("frob"), QVariant(56));
-
- f.setMetaData("frob", QVariant());
- QCOMPARE(f.metaData("frob"), QVariant());
-
- QCOMPARE(f.availableMetaData().count(), 1);
-
- f.setMetaData("frob", QVariant("")); // empty but not null
- QCOMPARE(f.availableMetaData().count(), 2);
-}
-
-#define TEST_MAPPED(frame, mode) \
-do { \
- QVERIFY(frame.bits()); \
- QVERIFY(frame.isMapped()); \
- QCOMPARE(frame.mappedBytes(), 16384); \
- QCOMPARE(frame.bytesPerLine(), 256); \
- QCOMPARE(frame.mapMode(), mode); \
-} while (0)
-
-#define TEST_UNMAPPED(frame) \
-do { \
- QVERIFY(!frame.bits()); \
- QVERIFY(!frame.isMapped()); \
- QCOMPARE(frame.mappedBytes(), 0); \
- QCOMPARE(frame.bytesPerLine(), 0); \
- QCOMPARE(frame.mapMode(), QAbstractVideoBuffer::NotMapped); \
-} while (0)
-
-void tst_QVideoFrame::isMapped()
-{
- QVideoFrame frame(16384, QSize(64, 64), 256, QVideoFrame::Format_ARGB32);
- const QVideoFrame& constFrame(frame);
-
- TEST_UNMAPPED(frame);
- TEST_UNMAPPED(constFrame);
-
- QVERIFY(frame.map(QAbstractVideoBuffer::ReadOnly));
- TEST_MAPPED(frame, QAbstractVideoBuffer::ReadOnly);
- TEST_MAPPED(constFrame, QAbstractVideoBuffer::ReadOnly);
- frame.unmap();
- TEST_UNMAPPED(frame);
- TEST_UNMAPPED(constFrame);
-
- QVERIFY(frame.map(QAbstractVideoBuffer::WriteOnly));
- TEST_MAPPED(frame, QAbstractVideoBuffer::WriteOnly);
- TEST_MAPPED(constFrame, QAbstractVideoBuffer::WriteOnly);
- frame.unmap();
- TEST_UNMAPPED(frame);
- TEST_UNMAPPED(constFrame);
-
- QVERIFY(frame.map(QAbstractVideoBuffer::ReadWrite));
- TEST_MAPPED(frame, QAbstractVideoBuffer::ReadWrite);
- TEST_MAPPED(constFrame, QAbstractVideoBuffer::ReadWrite);
- frame.unmap();
- TEST_UNMAPPED(frame);
- TEST_UNMAPPED(constFrame);
-}
-
-void tst_QVideoFrame::isReadable()
-{
- QVideoFrame frame(16384, QSize(64, 64), 256, QVideoFrame::Format_ARGB32);
-
- QVERIFY(!frame.isMapped());
- QVERIFY(!frame.isReadable());
-
- QVERIFY(frame.map(QAbstractVideoBuffer::ReadOnly));
- QVERIFY(frame.isMapped());
- QVERIFY(frame.isReadable());
- frame.unmap();
-
- QVERIFY(frame.map(QAbstractVideoBuffer::WriteOnly));
- QVERIFY(frame.isMapped());
- QVERIFY(!frame.isReadable());
- frame.unmap();
-
- QVERIFY(frame.map(QAbstractVideoBuffer::ReadWrite));
- QVERIFY(frame.isMapped());
- QVERIFY(frame.isReadable());
- frame.unmap();
-}
-
-void tst_QVideoFrame::isWritable()
-{
- QVideoFrame frame(16384, QSize(64, 64), 256, QVideoFrame::Format_ARGB32);
-
- QVERIFY(!frame.isMapped());
- QVERIFY(!frame.isWritable());
-
- QVERIFY(frame.map(QAbstractVideoBuffer::ReadOnly));
- QVERIFY(frame.isMapped());
- QVERIFY(!frame.isWritable());
- frame.unmap();
-
- QVERIFY(frame.map(QAbstractVideoBuffer::WriteOnly));
- QVERIFY(frame.isMapped());
- QVERIFY(frame.isWritable());
- frame.unmap();
-
- QVERIFY(frame.map(QAbstractVideoBuffer::ReadWrite));
- QVERIFY(frame.isMapped());
- QVERIFY(frame.isWritable());
- frame.unmap();
-}
-
-void tst_QVideoFrame::image_data()
-{
- QTest::addColumn<QSize>("size");
- QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat");
- QTest::addColumn<int>("bytes");
- QTest::addColumn<int>("bytesPerLine");
- QTest::addColumn<QImage::Format>("imageFormat");
-
- QTest::newRow("64x64 ARGB32")
- << QSize(64, 64)
- << QVideoFrame::Format_ARGB32
- << 16384
- << 256
- << QImage::Format_ARGB32;
-
- QTest::newRow("64x64 ARGB32_Premultiplied")
- << QSize(64, 64)
- << QVideoFrame::Format_ARGB32_Premultiplied
- << 16384
- << 256
- << QImage::Format_ARGB32_Premultiplied;
-
- QTest::newRow("64x64 RGB32")
- << QSize(64, 64)
- << QVideoFrame::Format_RGB32
- << 16384
- << 256
- << QImage::Format_RGB32;
-
- QTest::newRow("64x64 RGB24")
- << QSize(64, 64)
- << QVideoFrame::Format_RGB24
- << 16384
- << 192
- << QImage::Format_RGB888;
-
- QTest::newRow("64x64 RGB565")
- << QSize(64, 64)
- << QVideoFrame::Format_RGB565
- << 16384
- << 128
- << QImage::Format_RGB16;
-
- QTest::newRow("64x64 RGB555")
- << QSize(64, 64)
- << QVideoFrame::Format_RGB555
- << 16384
- << 128
- << QImage::Format_RGB555;
-
- QTest::newRow("64x64 BGRA32")
- << QSize(64, 64)
- << QVideoFrame::Format_BGRA32
- << 16384
- << 256
- << QImage::Format_ARGB32;
-
- QTest::newRow("64x64 BGRA32_Premultiplied")
- << QSize(64, 64)
- << QVideoFrame::Format_BGRA32_Premultiplied
- << 16384
- << 256
- << QImage::Format_ARGB32;
-
- QTest::newRow("64x64 BGR32")
- << QSize(64, 64)
- << QVideoFrame::Format_BGR32
- << 16384
- << 256
- << QImage::Format_ARGB32;
-
- QTest::newRow("64x64 BGR24")
- << QSize(64, 64)
- << QVideoFrame::Format_BGR24
- << 16384
- << 256
- << QImage::Format_ARGB32;
-
- QTest::newRow("64x64 BGR565")
- << QSize(64, 64)
- << QVideoFrame::Format_BGR565
- << 16384
- << 256
- << QImage::Format_ARGB32;
-
- QTest::newRow("64x64 BGR555")
- << QSize(64, 64)
- << QVideoFrame::Format_BGR555
- << 16384
- << 256
- << QImage::Format_ARGB32;
-#if !QT_CONFIG(directshow)
- QTest::newRow("64x64 AYUV444")
- << QSize(64, 64)
- << QVideoFrame::Format_AYUV444
- << 16384
- << 256
- << QImage::Format_ARGB32;
-
- QTest::newRow("64x64 YUV444")
- << QSize(64, 64)
- << QVideoFrame::Format_YUV444
- << 16384
- << 256
- << QImage::Format_ARGB32;
-
- QTest::newRow("64x64 YUV420P")
- << QSize(64, 64)
- << QVideoFrame::Format_YUV420P
- << 13288
- << 256
- << QImage::Format_ARGB32;
-
- QTest::newRow("64x64 YV12")
- << QSize(64, 64)
- << QVideoFrame::Format_YV12
- << 16384
- << 256
- << QImage::Format_ARGB32;
-
- QTest::newRow("64x64 UYVY")
- << QSize(64, 64)
- << QVideoFrame::Format_UYVY
- << 16384
- << 256
- << QImage::Format_ARGB32;
-
- QTest::newRow("64x64 YUYV")
- << QSize(64, 64)
- << QVideoFrame::Format_YUYV
- << 16384
- << 256
- << QImage::Format_ARGB32;
-
- QTest::newRow("64x64 NV12")
- << QSize(64, 64)
- << QVideoFrame::Format_NV12
- << 16384
- << 256
- << QImage::Format_ARGB32;
-
- QTest::newRow("64x64 NV21")
- << QSize(64, 64)
- << QVideoFrame::Format_NV21
- << 16384
- << 256
- << QImage::Format_ARGB32;
-#endif
-}
-
-void tst_QVideoFrame::image()
-{
- QFETCH(QSize, size);
- QFETCH(QVideoFrame::PixelFormat, pixelFormat);
- QFETCH(int, bytes);
- QFETCH(int, bytesPerLine);
- QFETCH(QImage::Format, imageFormat);
-
- QVideoFrame frame(bytes, size, bytesPerLine, pixelFormat);
- QImage img = frame.image();
-
- QVERIFY(!img.isNull());
- QCOMPARE(img.format(), imageFormat);
- QCOMPARE(img.size(), size);
- QCOMPARE(img.bytesPerLine(), bytesPerLine);
-}
-
-void tst_QVideoFrame::emptyData()
-{
- QByteArray data(nullptr, 0);
- QVideoFrame f(new QMemoryVideoBuffer(data, 600),
- QSize(800, 600),
- QVideoFrame::Format_ARGB32);
- QVERIFY(!f.map(QAbstractVideoBuffer::ReadOnly));
-}
-
-QTEST_MAIN(tst_QVideoFrame)
-
-#include "tst_qvideoframe.moc"
diff --git a/tests/auto/unit/qvideoprobe/qvideoprobe.pro b/tests/auto/unit/qvideoprobe/qvideoprobe.pro
deleted file mode 100644
index 52fb9cde5..000000000
--- a/tests/auto/unit/qvideoprobe/qvideoprobe.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qvideoprobe
-
-QT += multimedia-private testlib
-
-SOURCES += tst_qvideoprobe.cpp
-
-include (../qmultimedia_common/mock.pri)
-include (../qmultimedia_common/mockrecorder.pri)
-include (../qmultimedia_common/mockplayer.pri)
diff --git a/tests/auto/unit/qvideoprobe/tst_qvideoprobe.cpp b/tests/auto/unit/qvideoprobe/tst_qvideoprobe.cpp
deleted file mode 100644
index a53742469..000000000
--- a/tests/auto/unit/qvideoprobe/tst_qvideoprobe.cpp
+++ /dev/null
@@ -1,176 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QDebug>
-
-#include <qvideoprobe.h>
-#include <qaudiorecorder.h>
-#include <qmediaplayer.h>
-
-//TESTED_COMPONENT=src/multimedia
-
-#include "mockmediaserviceprovider.h"
-#include "mockmediarecorderservice.h"
-#include "mockmediaplayerservice.h"
-#include "mockmediaobject.h"
-
-QT_USE_NAMESPACE
-
-class tst_QVideoProbe: public QObject
-{
- Q_OBJECT
-
-public slots:
- void init();
- void cleanup();
-
-private slots:
- void testNullService();
- void testPlayer();
- void testPlayerDeleteRecorder();
- void testPlayerDeleteProbe();
- void testRecorder();
-
-private:
- QMediaPlayer *player;
- MockMediaPlayerService *mockMediaPlayerService;
- MockMediaServiceProvider *mockProvider;
-
- MockMediaRecorderControl *mockMediaRecorderControl;
- MockMediaRecorderService *mockMediaRecorderService;
- MockMediaServiceProvider *mockProviderRecorder;
-};
-
-void tst_QVideoProbe::init()
-{
- mockMediaPlayerService = new MockMediaPlayerService();
- mockProvider = new MockMediaServiceProvider(mockMediaPlayerService);
- mockProvider->deleteServiceOnRelease = true;
- player = 0;
-
- mockMediaRecorderControl = new MockMediaRecorderControl(this);
- mockMediaRecorderService = new MockMediaRecorderService(this, mockMediaRecorderControl);
- mockProviderRecorder = new MockMediaServiceProvider(mockMediaRecorderService);
- mockProviderRecorder->deleteServiceOnRelease = true;
-
- QMediaServiceProvider::setDefaultServiceProvider(mockProvider);
-}
-
-void tst_QVideoProbe::cleanup()
-{
- delete player;
- delete mockProvider;
- mockMediaPlayerService = 0;
- mockProvider = 0;
- player = 0;
-
- delete mockMediaRecorderControl;
- delete mockProviderRecorder;
- mockMediaRecorderControl = 0;
- mockMediaRecorderService = 0;
- mockProviderRecorder = 0;
-}
-
-void tst_QVideoProbe::testNullService()
-{
- mockProvider->service = 0;
- player = new QMediaPlayer;
-
- QVERIFY(!player->isAvailable());
- QCOMPARE(player->availability(), QMultimedia::ServiceMissing);
-
- QVideoProbe probe;
- QVERIFY(!probe.isActive());
- QVERIFY(!probe.setSource(player));
- QVERIFY(!probe.isActive());
- delete player;
- player = 0;
- QVERIFY(!probe.isActive());
-}
-
-void tst_QVideoProbe::testPlayer()
-{
- player = new QMediaPlayer;
- QVERIFY(player->isAvailable());
-
- QVideoProbe probe;
- QVERIFY(!probe.isActive());
- QVERIFY(probe.setSource(player));
- QVERIFY(probe.isActive());
- probe.setSource((QMediaPlayer*)0);
- QVERIFY(!probe.isActive());
-}
-
-void tst_QVideoProbe::testPlayerDeleteRecorder()
-{
- player = new QMediaPlayer;
- QVERIFY(player->isAvailable());
-
- QVideoProbe probe;
- QVERIFY(!probe.isActive());
- QVERIFY(probe.setSource(player));
- QVERIFY(probe.isActive());
-
- delete player;
- player = 0;
- QVERIFY(!probe.isActive());
- probe.setSource((QMediaPlayer*)0);
- QVERIFY(!probe.isActive());
-}
-
-void tst_QVideoProbe::testPlayerDeleteProbe()
-{
- player = new QMediaPlayer;
- QVERIFY(player->isAvailable());
-
- QVideoProbe *probe = new QVideoProbe;
- QVERIFY(!probe->isActive());
- QVERIFY(probe->setSource(player));
- QVERIFY(probe->isActive());
-
- delete probe;
- QVERIFY(player->isAvailable());
-}
-
-void tst_QVideoProbe::testRecorder()
-{
- QMediaServiceProvider::setDefaultServiceProvider(mockProviderRecorder);
-
- QAudioRecorder recorder;
- QVERIFY(recorder.isAvailable());
-
- QVideoProbe probe;
- QVERIFY(!probe.isActive());
- QVERIFY(!probe.setSource(&recorder)); // No QMediaVideoProbeControl available
- QVERIFY(!probe.isActive());
-}
-
-QTEST_GUILESS_MAIN(tst_QVideoProbe)
-
-#include "tst_qvideoprobe.moc"
diff --git a/tests/auto/unit/qvideosurfaceformat/qvideosurfaceformat.pro b/tests/auto/unit/qvideosurfaceformat/qvideosurfaceformat.pro
deleted file mode 100644
index 28cd0ad55..000000000
--- a/tests/auto/unit/qvideosurfaceformat/qvideosurfaceformat.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qvideosurfaceformat
-
-QT += core multimedia-private testlib
-
-SOURCES += tst_qvideosurfaceformat.cpp
-
diff --git a/tests/auto/unit/qvideosurfaceformat/tst_qvideosurfaceformat.cpp b/tests/auto/unit/qvideosurfaceformat/tst_qvideosurfaceformat.cpp
deleted file mode 100644
index 4fa754a45..000000000
--- a/tests/auto/unit/qvideosurfaceformat/tst_qvideosurfaceformat.cpp
+++ /dev/null
@@ -1,912 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//TESTED_COMPONENT=src/multimedia
-
-#include <QtTest/QtTest>
-
-#include <qvideosurfaceformat.h>
-
-// Adds an enum, and the stringized version
-#define ADD_ENUM_TEST(x) \
- QTest::newRow(#x) \
- << QVideoSurfaceFormat::x \
- << QString(QLatin1String(#x));
-
-class tst_QVideoSurfaceFormat : public QObject
-{
- Q_OBJECT
-public:
- tst_QVideoSurfaceFormat();
- ~tst_QVideoSurfaceFormat();
-
-public slots:
- void initTestCase();
- void cleanupTestCase();
- void init();
- void cleanup();
-
-private slots:
- void constructNull();
- void construct_data();
- void construct();
- void frameSize_data();
- void frameSize();
- void viewport_data();
- void viewport();
- void scanLineDirection_data();
- void scanLineDirection();
- void frameRate_data();
- void frameRate();
- void pixelAspectRatio_data();
- void pixelAspectRatio();
- void sizeHint_data();
- void sizeHint();
- void yCbCrColorSpaceEnum_data();
- void yCbCrColorSpaceEnum ();
- void staticPropertyNames();
- void dynamicProperty();
- void compare();
- void copy();
- void assign();
-
- void isValid();
- void copyAllParameters ();
- void assignAllParameters ();
-
- void propertyEdgeCases();
-};
-
-tst_QVideoSurfaceFormat::tst_QVideoSurfaceFormat()
-{
-}
-
-tst_QVideoSurfaceFormat::~tst_QVideoSurfaceFormat()
-{
-}
-
-void tst_QVideoSurfaceFormat::initTestCase()
-{
-}
-
-void tst_QVideoSurfaceFormat::cleanupTestCase()
-{
-}
-
-void tst_QVideoSurfaceFormat::init()
-{
-}
-
-void tst_QVideoSurfaceFormat::cleanup()
-{
-}
-
-void tst_QVideoSurfaceFormat::constructNull()
-{
- QVideoSurfaceFormat format;
-
- QVERIFY(!format.isValid());
- QCOMPARE(format.handleType(), QAbstractVideoBuffer::NoHandle);
- QCOMPARE(format.pixelFormat(), QVideoFrame::Format_Invalid);
- QCOMPARE(format.frameSize(), QSize());
- QCOMPARE(format.frameWidth(), -1);
- QCOMPARE(format.frameHeight(), -1);
- QCOMPARE(format.viewport(), QRect());
- QCOMPARE(format.scanLineDirection(), QVideoSurfaceFormat::TopToBottom);
- QCOMPARE(format.frameRate(), 0.0);
- QCOMPARE(format.pixelAspectRatio(), QSize(1, 1));
- QCOMPARE(format.yCbCrColorSpace(), QVideoSurfaceFormat::YCbCr_Undefined);
-}
-
-void tst_QVideoSurfaceFormat::construct_data()
-{
- QTest::addColumn<QSize>("frameSize");
- QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat");
- QTest::addColumn<QAbstractVideoBuffer::HandleType>("handleType");
- QTest::addColumn<bool>("valid");
-
- QTest::newRow("32x32 rgb32 no handle")
- << QSize(32, 32)
- << QVideoFrame::Format_RGB32
- << QAbstractVideoBuffer::NoHandle
- << true;
-
- QTest::newRow("1024x768 YUV444 GL texture")
- << QSize(32, 32)
- << QVideoFrame::Format_YUV444
- << QAbstractVideoBuffer::GLTextureHandle
- << true;
-
- QTest::newRow("32x32 invalid no handle")
- << QSize(32, 32)
- << QVideoFrame::Format_Invalid
- << QAbstractVideoBuffer::NoHandle
- << false;
-
- QTest::newRow("invalid size, rgb32 no handle")
- << QSize()
- << QVideoFrame::Format_RGB32
- << QAbstractVideoBuffer::NoHandle
- << false;
-
- QTest::newRow("0x0 rgb32 no handle")
- << QSize(0,0)
- << QVideoFrame::Format_RGB32
- << QAbstractVideoBuffer::NoHandle
- << true;
-}
-
-void tst_QVideoSurfaceFormat::construct()
-{
- QFETCH(QSize, frameSize);
- QFETCH(QVideoFrame::PixelFormat, pixelFormat);
- QFETCH(QAbstractVideoBuffer::HandleType, handleType);
- QFETCH(bool, valid);
-
- QRect viewport(QPoint(0, 0), frameSize);
-
- QVideoSurfaceFormat format(frameSize, pixelFormat, handleType);
-
- QCOMPARE(format.handleType(), handleType);
- QCOMPARE(format.property("handleType").value<QAbstractVideoBuffer::HandleType>(), handleType);
- QCOMPARE(format.pixelFormat(), pixelFormat);
- QCOMPARE(format.property("pixelFormat").value<QVideoFrame::PixelFormat>(), pixelFormat);
- QCOMPARE(format.frameSize(), frameSize);
- QCOMPARE(format.frameWidth(), frameSize.width());
- QCOMPARE(format.property("frameWidth").toInt(), frameSize.width());
- QCOMPARE(format.frameHeight(), frameSize.height());
- QCOMPARE(format.property("frameHeight").toInt(), frameSize.height());
- QCOMPARE(format.isValid(), valid);
- QCOMPARE(format.viewport(), viewport);
- QCOMPARE(format.scanLineDirection(), QVideoSurfaceFormat::TopToBottom);
- QCOMPARE(format.frameRate(), 0.0);
- QCOMPARE(format.pixelAspectRatio(), QSize(1, 1));
- QCOMPARE(format.yCbCrColorSpace(), QVideoSurfaceFormat::YCbCr_Undefined);
-}
-
-void tst_QVideoSurfaceFormat::frameSize_data()
-{
- QTest::addColumn<QSize>("initialSize");
- QTest::addColumn<QSize>("newSize");
-
- QTest::newRow("grow")
- << QSize(64, 64)
- << QSize(1024, 1024);
- QTest::newRow("shrink")
- << QSize(1024, 1024)
- << QSize(64, 64);
- QTest::newRow("unchanged")
- << QSize(512, 512)
- << QSize(512, 512);
-}
-
-void tst_QVideoSurfaceFormat::frameSize()
-{
- QFETCH(QSize, initialSize);
- QFETCH(QSize, newSize);
-
- {
- QVideoSurfaceFormat format(initialSize, QVideoFrame::Format_RGB32);
-
- format.setFrameSize(newSize);
-
- QCOMPARE(format.frameSize(), newSize);
- QCOMPARE(format.property("frameSize").toSize(), newSize);
- QCOMPARE(format.frameWidth(), newSize.width());
- QCOMPARE(format.property("frameWidth").toInt(), newSize.width());
- QCOMPARE(format.frameHeight(), newSize.height());
- QCOMPARE(format.property("frameHeight").toInt(), newSize.height());
- }
-
- {
- QVideoSurfaceFormat format(initialSize, QVideoFrame::Format_RGB32);
-
- format.setProperty("frameSize", newSize);
-
- QCOMPARE(format.frameSize(), newSize);
- QCOMPARE(format.property("frameSize").toSize(), newSize);
- QCOMPARE(format.frameWidth(), newSize.width());
- QCOMPARE(format.property("frameWidth").toInt(), newSize.width());
- QCOMPARE(format.frameHeight(), newSize.height());
- QCOMPARE(format.property("frameHeight").toInt(), newSize.height());
- }
-
-}
-
-void tst_QVideoSurfaceFormat::viewport_data()
-{
- QTest::addColumn<QSize>("initialSize");
- QTest::addColumn<QRect>("viewport");
- QTest::addColumn<QSize>("newSize");
- QTest::addColumn<QRect>("expectedViewport");
-
- QTest::newRow("grow reset")
- << QSize(64, 64)
- << QRect(8, 8, 48, 48)
- << QSize(1024, 1024)
- << QRect(0, 0, 1024, 1024);
- QTest::newRow("shrink reset")
- << QSize(1024, 1024)
- << QRect(8, 8, 1008, 1008)
- << QSize(64, 64)
- << QRect(0, 0, 64, 64);
- QTest::newRow("unchanged reset")
- << QSize(512, 512)
- << QRect(8, 8, 496, 496)
- << QSize(512, 512)
- << QRect(0, 0, 512, 512);
-}
-
-void tst_QVideoSurfaceFormat::viewport()
-{
- QFETCH(QSize, initialSize);
- QFETCH(QRect, viewport);
- QFETCH(QSize, newSize);
- QFETCH(QRect, expectedViewport);
-
- {
- QRect initialViewport(QPoint(0, 0), initialSize);
-
- QVideoSurfaceFormat format(initialSize, QVideoFrame::Format_RGB32);
-
- format.setViewport(viewport);
-
- QCOMPARE(format.viewport(), viewport);
- QCOMPARE(format.property("viewport").toRect(), viewport);
-
- format.setFrameSize(newSize);
-
- QCOMPARE(format.viewport(), expectedViewport);
- QCOMPARE(format.property("viewport").toRect(), expectedViewport);
- }
- {
- QVideoSurfaceFormat format(initialSize, QVideoFrame::Format_RGB32);
-
- format.setProperty("viewport", viewport);
-
- QCOMPARE(format.viewport(), viewport);
- QCOMPARE(format.property("viewport").toRect(), viewport);
- }
-}
-
-void tst_QVideoSurfaceFormat::scanLineDirection_data()
-{
- QTest::addColumn<QVideoSurfaceFormat::Direction>("direction");
- QTest::addColumn<QString>("stringized");
-
- ADD_ENUM_TEST(TopToBottom);
- ADD_ENUM_TEST(BottomToTop);
-}
-
-void tst_QVideoSurfaceFormat::scanLineDirection()
-{
- QFETCH(QVideoSurfaceFormat::Direction, direction);
- QFETCH(QString, stringized);
-
- {
- QVideoSurfaceFormat format(QSize(16, 16), QVideoFrame::Format_RGB32);
-
- format.setScanLineDirection(direction);
-
- QCOMPARE(format.scanLineDirection(), direction);
- QCOMPARE(
- qvariant_cast<QVideoSurfaceFormat::Direction>(format.property("scanLineDirection")),
- direction);
- }
- {
- QVideoSurfaceFormat format(QSize(16, 16), QVideoFrame::Format_RGB32);
-
- format.setProperty("scanLineDirection", QVariant::fromValue(direction));
-
- QCOMPARE(format.scanLineDirection(), direction);
- QCOMPARE(
- qvariant_cast<QVideoSurfaceFormat::Direction>(format.property("scanLineDirection")),
- direction);
- }
-
- QTest::ignoreMessage(QtDebugMsg, stringized.toLatin1().constData());
- qDebug() << direction;
-}
-
-void tst_QVideoSurfaceFormat::yCbCrColorSpaceEnum_data()
-{
- QTest::addColumn<QVideoSurfaceFormat::YCbCrColorSpace>("colorspace");
- QTest::addColumn<QString>("stringized");
-
- ADD_ENUM_TEST(YCbCr_BT601);
- ADD_ENUM_TEST(YCbCr_BT709);
- ADD_ENUM_TEST(YCbCr_xvYCC601);
- ADD_ENUM_TEST(YCbCr_xvYCC709);
- ADD_ENUM_TEST(YCbCr_JPEG);
- ADD_ENUM_TEST(YCbCr_CustomMatrix);
- ADD_ENUM_TEST(YCbCr_Undefined);
-}
-
-/* Test case for Enum YCbCr_BT601, YCbCr_xvYCC709 */
-void tst_QVideoSurfaceFormat::yCbCrColorSpaceEnum()
-{
- QFETCH(QVideoSurfaceFormat::YCbCrColorSpace, colorspace);
- QFETCH(QString, stringized);
-
- {
- QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32);
- format.setYCbCrColorSpace(colorspace);
-
- QCOMPARE(format.yCbCrColorSpace(), colorspace);
- QCOMPARE(qvariant_cast<QVideoSurfaceFormat::YCbCrColorSpace>(format.property("yCbCrColorSpace")),
- colorspace);
- }
- {
- QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32);
- format.setProperty("yCbCrColorSpace", QVariant::fromValue(colorspace));
-
- QCOMPARE(format.yCbCrColorSpace(), colorspace);
- QCOMPARE(qvariant_cast<QVideoSurfaceFormat::YCbCrColorSpace>(format.property("yCbCrColorSpace")),
- colorspace);
- }
-
- QTest::ignoreMessage(QtDebugMsg, stringized.toLatin1().constData());
- qDebug() << colorspace;
-}
-
-
-void tst_QVideoSurfaceFormat::frameRate_data()
-{
- QTest::addColumn<qreal>("frameRate");
-
- QTest::newRow("null")
- << qreal(0.0);
- QTest::newRow("1/1")
- << qreal(1.0);
- QTest::newRow("24/1")
- << qreal(24.0);
- QTest::newRow("15/2")
- << qreal(7.5);
-}
-
-void tst_QVideoSurfaceFormat::frameRate()
-{
- QFETCH(qreal, frameRate);
-
- {
- QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32);
-
- format.setFrameRate(frameRate);
-
- QCOMPARE(format.frameRate(), frameRate);
- QCOMPARE(qvariant_cast<qreal>(format.property("frameRate")), frameRate);
- }
- {
- QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32);
-
- format.setFrameRate(frameRate);
- format.setProperty("frameRate", frameRate);
-
- QCOMPARE(format.frameRate(), frameRate);
- QCOMPARE(qvariant_cast<qreal>(format.property("frameRate")), frameRate);
- }
-}
-
-void tst_QVideoSurfaceFormat::pixelAspectRatio_data()
-{
- QTest::addColumn<QSize>("aspectRatio");
-
- QTest::newRow("1:1")
- << QSize(1, 1);
- QTest::newRow("4:3")
- << QSize(4, 3);
- QTest::newRow("16:9")
- << QSize(16, 9);
-}
-
-void tst_QVideoSurfaceFormat::pixelAspectRatio()
-{
- QFETCH(QSize, aspectRatio);
-
- {
- QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32);
- format.setPixelAspectRatio(aspectRatio);
-
- QCOMPARE(format.pixelAspectRatio(), aspectRatio);
- QCOMPARE(format.property("pixelAspectRatio").toSize(), aspectRatio);
- }
- {
- QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32);
- format.setPixelAspectRatio(aspectRatio.width(), aspectRatio.height());
-
- QCOMPARE(format.pixelAspectRatio(), aspectRatio);
- QCOMPARE(format.property("pixelAspectRatio").toSize(), aspectRatio);
- }
- {
- QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32);
- format.setProperty("pixelAspectRatio", aspectRatio);
-
- QCOMPARE(format.pixelAspectRatio(), aspectRatio);
- QCOMPARE(format.property("pixelAspectRatio").toSize(), aspectRatio);
- }
-}
-
-void tst_QVideoSurfaceFormat::sizeHint_data()
-{
- QTest::addColumn<QSize>("frameSize");
- QTest::addColumn<QRect>("viewport");
- QTest::addColumn<QSize>("aspectRatio");
- QTest::addColumn<QSize>("sizeHint");
-
- QTest::newRow("(0, 0, 1024x768), 1:1")
- << QSize(1024, 768)
- << QRect(0, 0, 1024, 768)
- << QSize(1, 1)
- << QSize(1024, 768);
- QTest::newRow("0, 0, 1024x768), 4:3")
- << QSize(1024, 768)
- << QRect(0, 0, 1024, 768)
- << QSize(4, 3)
- << QSize(1365, 768);
- QTest::newRow("(168, 84, 800x600), 1:1")
- << QSize(1024, 768)
- << QRect(168, 84, 800, 600)
- << QSize(1, 1)
- << QSize(800, 600);
- QTest::newRow("(168, 84, 800x600), 4:3")
- << QSize(1024, 768)
- << QRect(168, 84, 800, 600)
- << QSize(4, 3)
- << QSize(1066, 600);
- QTest::newRow("(168, 84, 800x600), 4:0")
- << QSize(1024, 768)
- << QRect(168, 84, 800, 600)
- << QSize(4, 0)
- << QSize(800, 600);
-}
-
-void tst_QVideoSurfaceFormat::sizeHint()
-{
- QFETCH(QSize, frameSize);
- QFETCH(QRect, viewport);
- QFETCH(QSize, aspectRatio);
- QFETCH(QSize, sizeHint);
-
- QVideoSurfaceFormat format(frameSize, QVideoFrame::Format_RGB32);
- format.setViewport(viewport);
- format.setPixelAspectRatio(aspectRatio);
-
- QCOMPARE(format.sizeHint(), sizeHint);
- QCOMPARE(format.property("sizeHint").toSize(), sizeHint);
-}
-
-void tst_QVideoSurfaceFormat::staticPropertyNames()
-{
- QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32);
-
- QList<QByteArray> propertyNames = format.propertyNames();
-
- QVERIFY(propertyNames.contains("handleType"));
- QVERIFY(propertyNames.contains("pixelFormat"));
- QVERIFY(propertyNames.contains("frameSize"));
- QVERIFY(propertyNames.contains("frameWidth"));
- QVERIFY(propertyNames.contains("viewport"));
- QVERIFY(propertyNames.contains("scanLineDirection"));
- QVERIFY(propertyNames.contains("frameRate"));
- QVERIFY(propertyNames.contains("pixelAspectRatio"));
- QVERIFY(propertyNames.contains("yCbCrColorSpace"));
- QVERIFY(propertyNames.contains("sizeHint"));
- QVERIFY(propertyNames.contains("mirrored"));
- QCOMPARE(propertyNames.count(), 11);
-}
-
-void tst_QVideoSurfaceFormat::dynamicProperty()
-{
- QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32);
-
- QCOMPARE(format.property("integer"), QVariant());
- QCOMPARE(format.property("size"), QVariant());
- QCOMPARE(format.property("string"), QVariant());
- QCOMPARE(format.property("null"), QVariant());
-
- QList<QByteArray> propertyNames = format.propertyNames();
-
- QCOMPARE(propertyNames.count(QByteArray("integer")), 0);
- QCOMPARE(propertyNames.count(QByteArray("string")), 0);
- QCOMPARE(propertyNames.count(QByteArray("size")), 0);
- QCOMPARE(propertyNames.count(QByteArray("null")), 0);
-
- format.setProperty("string", QString::fromLatin1("Hello"));
- format.setProperty("integer", 198);
- format.setProperty("size", QSize(43, 65));
-
- QCOMPARE(format.property("integer").toInt(), 198);
- QCOMPARE(format.property("size").toSize(), QSize(43, 65));
- QCOMPARE(format.property("string").toString(), QString::fromLatin1("Hello"));
-
- propertyNames = format.propertyNames();
-
- QCOMPARE(propertyNames.count(QByteArray("integer")), 1);
- QCOMPARE(propertyNames.count(QByteArray("string")), 1);
- QCOMPARE(propertyNames.count(QByteArray("size")), 1);
-
- format.setProperty("integer", 125423);
- format.setProperty("size", QSize(1, 986));
-
- QCOMPARE(format.property("integer").toInt(), 125423);
- QCOMPARE(format.property("size").toSize(), QSize(1, 986));
- QCOMPARE(format.property("string").toString(), QString::fromLatin1("Hello"));
-
- propertyNames = format.propertyNames();
-
- QCOMPARE(propertyNames.count(QByteArray("integer")), 1);
- QCOMPARE(propertyNames.count(QByteArray("string")), 1);
- QCOMPARE(propertyNames.count(QByteArray("size")), 1);
-
- format.setProperty("string", QVariant());
- format.setProperty("size", QVariant());
- format.setProperty("null", QVariant());
-
- QCOMPARE(format.property("integer").toInt(), 125423);
- QCOMPARE(format.property("size"), QVariant());
- QCOMPARE(format.property("string"), QVariant());
- QCOMPARE(format.property("null"), QVariant());
-
- propertyNames = format.propertyNames();
-
- QCOMPARE(propertyNames.count(QByteArray("integer")), 1);
- QCOMPARE(propertyNames.count(QByteArray("string")), 0);
- QCOMPARE(propertyNames.count(QByteArray("size")), 0);
- QCOMPARE(propertyNames.count(QByteArray("null")), 0);
-}
-
-void tst_QVideoSurfaceFormat::compare()
-{
- QVideoSurfaceFormat format1(
- QSize(16, 16), QVideoFrame::Format_RGB32, QAbstractVideoBuffer::GLTextureHandle);
- QVideoSurfaceFormat format2(
- QSize(16, 16), QVideoFrame::Format_RGB32, QAbstractVideoBuffer::GLTextureHandle);
- QVideoSurfaceFormat format3(
- QSize(32, 32), QVideoFrame::Format_YUV444, QAbstractVideoBuffer::GLTextureHandle);
- QVideoSurfaceFormat format4(
- QSize(16, 16), QVideoFrame::Format_RGB32, QAbstractVideoBuffer::UserHandle);
-
- QCOMPARE(format1 == format2, true);
- QCOMPARE(format1 != format2, false);
- QCOMPARE(format1 == format3, false);
- QCOMPARE(format1 != format3, true);
- QCOMPARE(format1 == format4, false);
- QCOMPARE(format1 != format4, true);
-
- format2.setFrameSize(1024, 768);
-
- // Not equal, frame size differs.
- QCOMPARE(format1 == format2, false);
- QCOMPARE(format1 != format2, true);
-
- format1.setFrameSize(1024, 768);
-
- // Equal.
- QCOMPARE(format1 == format2, true);
- QCOMPARE(format1 != format2, false);
-
- format1.setViewport(QRect(0, 0, 800, 600));
- format2.setViewport(QRect(112, 84, 800, 600));
-
- // Not equal, viewports differ.
- QCOMPARE(format1 == format2, false);
- QCOMPARE(format1 != format2, true);
-
- format1.setViewport(QRect(112, 84, 800, 600));
-
- // Equal.
- QCOMPARE(format1 == format2, true);
- QCOMPARE(format1 != format2, false);
-
- format2.setScanLineDirection(QVideoSurfaceFormat::BottomToTop);
-
- // Not equal scan line direction differs.
- QCOMPARE(format1 == format2, false);
- QCOMPARE(format1 != format2, true);
-
- format1.setScanLineDirection(QVideoSurfaceFormat::BottomToTop);
-
- // Equal.
- QCOMPARE(format1 == format2, true);
- QCOMPARE(format1 != format2, false);
-
- format1.setFrameRate(7.5);
-
- // Not equal frame rate differs.
- QCOMPARE(format1 == format2, false);
- QCOMPARE(format1 != format2, true);
-
- format2.setFrameRate(qreal(7.50001));
-
- // Equal.
- QCOMPARE(format1 == format2, true);
- QCOMPARE(format1 != format2, false);
-
- format2.setPixelAspectRatio(4, 3);
-
- // Not equal pixel aspect ratio differs.
- QCOMPARE(format1 == format2, false);
- QCOMPARE(format1 != format2, true);
-
- format1.setPixelAspectRatio(QSize(4, 3));
-
- // Equal.
- QCOMPARE(format1 == format2, true);
- QCOMPARE(format1 != format2, false);
-
- format2.setYCbCrColorSpace(QVideoSurfaceFormat::YCbCr_xvYCC601);
-
- // Not equal yuv color space differs.
- QCOMPARE(format1 == format2, false);
- QCOMPARE(format1 != format2, true);
-
- format1.setYCbCrColorSpace(QVideoSurfaceFormat::YCbCr_xvYCC601);
-
- // Equal.
- QCOMPARE(format1 == format2, true);
- QCOMPARE(format1 != format2, false);
-
- format1.setProperty("integer", 12);
-
- // Not equal, property mismatch.
- QCOMPARE(format1 == format2, false);
- QCOMPARE(format1 != format2, true);
-
- format2.setProperty("integer", 45);
-
- // Not equal, integer differs.
- QCOMPARE(format1 == format2, false);
- QCOMPARE(format1 != format2, true);
-
- format2.setProperty("integer", 12);
-
- // Equal.
- QCOMPARE(format1 == format2, true);
- QCOMPARE(format1 != format2, false);
-
- format1.setProperty("string", QString::fromLatin1("Hello"));
- format2.setProperty("size", QSize(12, 54));
-
- // Not equal, property mismatch.
- QCOMPARE(format1 == format2, false);
- QCOMPARE(format1 != format2, true);
-
- format2.setProperty("string", QString::fromLatin1("Hello"));
- format1.setProperty("size", QSize(12, 54));
-
- // Equal.
- QCOMPARE(format1 == format2, true);
- QCOMPARE(format1 != format2, false);
-
- format1.setProperty("string", QVariant());
-
- // Not equal, property mismatch.
- QCOMPARE(format1 == format2, false);
- QCOMPARE(format1 != format2, true);
-}
-
-
-void tst_QVideoSurfaceFormat::copy()
-{
- QVideoSurfaceFormat original(
- QSize(1024, 768), QVideoFrame::Format_ARGB32, QAbstractVideoBuffer::GLTextureHandle);
- original.setScanLineDirection(QVideoSurfaceFormat::BottomToTop);
-
- QVideoSurfaceFormat copy(original);
-
- QCOMPARE(copy.handleType(), QAbstractVideoBuffer::GLTextureHandle);
- QCOMPARE(copy.pixelFormat(), QVideoFrame::Format_ARGB32);
- QCOMPARE(copy.frameSize(), QSize(1024, 768));
- QCOMPARE(copy.scanLineDirection(), QVideoSurfaceFormat::BottomToTop);
-
- QCOMPARE(original == copy, true);
- QCOMPARE(original != copy, false);
-
- copy.setScanLineDirection(QVideoSurfaceFormat::TopToBottom);
-
- QCOMPARE(copy.scanLineDirection(), QVideoSurfaceFormat::TopToBottom);
-
- QCOMPARE(original.scanLineDirection(), QVideoSurfaceFormat::BottomToTop);
-
- QCOMPARE(original == copy, false);
- QCOMPARE(original != copy, true);
-}
-
-void tst_QVideoSurfaceFormat::assign()
-{
- QVideoSurfaceFormat copy(
- QSize(64, 64), QVideoFrame::Format_AYUV444, QAbstractVideoBuffer::UserHandle);
-
- QVideoSurfaceFormat original(
- QSize(1024, 768), QVideoFrame::Format_ARGB32, QAbstractVideoBuffer::GLTextureHandle);
- original.setScanLineDirection(QVideoSurfaceFormat::BottomToTop);
-
- copy = original;
-
- QCOMPARE(copy.handleType(), QAbstractVideoBuffer::GLTextureHandle);
- QCOMPARE(copy.pixelFormat(), QVideoFrame::Format_ARGB32);
- QCOMPARE(copy.frameSize(), QSize(1024, 768));
- QCOMPARE(copy.scanLineDirection(), QVideoSurfaceFormat::BottomToTop);
-
- QCOMPARE(original == copy, true);
- QCOMPARE(original != copy, false);
-
- copy.setScanLineDirection(QVideoSurfaceFormat::TopToBottom);
-
- QCOMPARE(copy.scanLineDirection(), QVideoSurfaceFormat::TopToBottom);
-
- QCOMPARE(original.scanLineDirection(), QVideoSurfaceFormat::BottomToTop);
-
- QCOMPARE(original == copy, false);
- QCOMPARE(original != copy, true);
-}
-
-/* Test case for api isValid */
-void tst_QVideoSurfaceFormat::isValid()
-{
- /* When both pixel format and framesize is not valid */
- QVideoSurfaceFormat format;
- QVERIFY(!format.isValid());
-
- /* When framesize is valid and pixel format is not valid */
- format.setFrameSize(64,64);
- QVERIFY(format.frameSize() == QSize(64,64));
- QVERIFY(!format.pixelFormat());
- QVERIFY(!format.isValid());
-
- /* When both the pixel format and framesize is valid. */
- QVideoSurfaceFormat format1(QSize(32, 32), QVideoFrame::Format_AYUV444);
- QVERIFY(format1.isValid());
-
- /* When pixel format is valid and frame size is not valid */
- format1.setFrameSize(-1,-1);
- QVERIFY(!format1.frameSize().isValid());
- QVERIFY(!format1.isValid());
-}
-
-/* Test case for copy constructor with all the parameters. */
-void tst_QVideoSurfaceFormat::copyAllParameters()
-{
- /* Create the instance and set all the parameters. */
- QVideoSurfaceFormat original(
- QSize(1024, 768), QVideoFrame::Format_ARGB32, QAbstractVideoBuffer::GLTextureHandle);
-
- original.setScanLineDirection(QVideoSurfaceFormat::BottomToTop);
- original.setViewport(QRect(0, 0, 1024, 1024));
- original.setFrameRate(qreal(15.0));
- original.setPixelAspectRatio(QSize(320,480));
- original.setYCbCrColorSpace(QVideoSurfaceFormat::YCbCr_BT709);
-
- /* Copy the original instance to copy and verify if both the instances
- have the same parameters. */
- QVideoSurfaceFormat copy(original);
-
- QCOMPARE(copy.handleType(), QAbstractVideoBuffer::GLTextureHandle);
- QCOMPARE(copy.pixelFormat(), QVideoFrame::Format_ARGB32);
- QCOMPARE(copy.frameSize(), QSize(1024, 768));
- QCOMPARE(copy.scanLineDirection(), QVideoSurfaceFormat::BottomToTop);
- QCOMPARE(copy.viewport(), QRect(0, 0, 1024, 1024));
- QCOMPARE(copy.frameRate(), qreal(15.0));
- QCOMPARE(copy.pixelAspectRatio(), QSize(320,480));
- QCOMPARE(copy.yCbCrColorSpace(), QVideoSurfaceFormat::YCbCr_BT709);
-
- /* Verify if both the instances are eqaul */
- QCOMPARE(original == copy, true);
- QCOMPARE(original != copy, false);
-}
-
-/* Test case for copy constructor with all the parameters. */
-void tst_QVideoSurfaceFormat::assignAllParameters()
-{
- /* Create the instance and set all the parameters. */
- QVideoSurfaceFormat copy(
- QSize(64, 64), QVideoFrame::Format_AYUV444, QAbstractVideoBuffer::UserHandle);
- copy.setScanLineDirection(QVideoSurfaceFormat::TopToBottom);
- copy.setViewport(QRect(0, 0, 640, 320));
- copy.setFrameRate(qreal(7.5));
- copy.setPixelAspectRatio(QSize(640,320));
- copy.setYCbCrColorSpace(QVideoSurfaceFormat::YCbCr_BT601);
-
- /* Create the instance and set all the parameters. */
- QVideoSurfaceFormat original(
- QSize(1024, 768), QVideoFrame::Format_ARGB32, QAbstractVideoBuffer::GLTextureHandle);
- original.setScanLineDirection(QVideoSurfaceFormat::BottomToTop);
- original.setViewport(QRect(0, 0, 1024, 1024));
- original.setFrameRate(qreal(15.0));
- original.setPixelAspectRatio(QSize(320,480));
- original.setYCbCrColorSpace(QVideoSurfaceFormat::YCbCr_BT709);
-
- /* Assign the original instance to copy and verify if both the instancess
- have the same parameters. */
- copy = original;
-
- QCOMPARE(copy.handleType(), QAbstractVideoBuffer::GLTextureHandle);
- QCOMPARE(copy.pixelFormat(), QVideoFrame::Format_ARGB32);
- QCOMPARE(copy.frameSize(), QSize(1024, 768));
- QCOMPARE(copy.scanLineDirection(), QVideoSurfaceFormat::BottomToTop);
- QCOMPARE(copy.viewport(), QRect(0, 0, 1024, 1024));
- QCOMPARE(copy.frameRate(), qreal(15.0));
- QCOMPARE(copy.pixelAspectRatio(), QSize(320,480));
- QCOMPARE(copy.yCbCrColorSpace(), QVideoSurfaceFormat::YCbCr_BT709);
-
- /* Verify if both the instances are eqaul */
- QCOMPARE(original == copy, true);
- QCOMPARE(original != copy, false);
-}
-
-void tst_QVideoSurfaceFormat::propertyEdgeCases()
-{
- // Test setting read only properties doesn't change anything
- QVideoSurfaceFormat original(
- QSize(1024, 768), QVideoFrame::Format_ARGB32, QAbstractVideoBuffer::GLTextureHandle);
-
- original.setProperty("handleType", QAbstractVideoBuffer::UserHandle);
- QCOMPARE(original.handleType(), QAbstractVideoBuffer::GLTextureHandle);
-
- original.setProperty("pixelFormat", QVideoFrame::Format_AYUV444);
- QCOMPARE(original.pixelFormat(), QVideoFrame::Format_ARGB32);
-
- original.setProperty("frameWidth", 512);
- QCOMPARE(original.frameWidth(), 1024);
-
- original.setProperty("frameHeight", 77);
- QCOMPARE(original.frameHeight(), 768);
-
- original.setProperty("sizeHint", QSize(512, 384));
- QCOMPARE(original.sizeHint(), QSize(1024,768));
-
- // Now test setting some r/w properties with the wrong data type
- original.setProperty("frameSize", QColor(Qt::red));
- QCOMPARE(original.frameSize(), QSize(1024, 768));
-
- original.setProperty("viewport", QColor(Qt::red));
- QCOMPARE(original.viewport(), QRect(0, 0, 1024, 768));
-
- original.setScanLineDirection(QVideoSurfaceFormat::BottomToTop);
- original.setProperty("scanLineDirection", QColor(Qt::red));
- QCOMPARE(original.scanLineDirection(), QVideoSurfaceFormat::BottomToTop);
-
- original.setFrameRate(32);
- original.setProperty("frameRate", QSize(32, 43));
- QCOMPARE(original.frameRate(), qreal(32));
-
- original.setYCbCrColorSpace(QVideoSurfaceFormat::YCbCr_BT709);
- original.setProperty("yCbCrColorSpace", QSize(43,43));
- QCOMPARE(original.yCbCrColorSpace(), QVideoSurfaceFormat::YCbCr_BT709);
-
- original.setPixelAspectRatio(53, 45);
- original.setProperty("pixelAspectRatio", QColor(Qt::red));
- QCOMPARE(original.pixelAspectRatio(), QSize(53, 45));
-}
-
-
-QTEST_MAIN(tst_QVideoSurfaceFormat)
-
-
-
-#include "tst_qvideosurfaceformat.moc"
diff --git a/tests/auto/unit/qvideowidget/qvideowidget.pro b/tests/auto/unit/qvideowidget/qvideowidget.pro
deleted file mode 100644
index e12e3a050..000000000
--- a/tests/auto/unit/qvideowidget/qvideowidget.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qvideowidget
-
-QT += multimedia-private multimediawidgets-private testlib
-
-SOURCES += tst_qvideowidget.cpp
-
-QT+=widgets
diff --git a/tests/auto/unit/qvideowidget/tst_qvideowidget.cpp b/tests/auto/unit/qvideowidget/tst_qvideowidget.cpp
deleted file mode 100644
index bcc4acb3a..000000000
--- a/tests/auto/unit/qvideowidget/tst_qvideowidget.cpp
+++ /dev/null
@@ -1,1643 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//TESTED_COMPONENT=src/multimedia
-
-#include <qtmultimediaglobal.h>
-#include <QtTest/QtTest>
-
-#include "qvideowidget.h"
-
-#include "qmediaobject.h"
-#include "qmediaservice.h"
-#include <private/qpaintervideosurface_p.h>
-#include "qvideowindowcontrol.h"
-#include "qvideowidgetcontrol.h"
-
-#include "qvideorenderercontrol.h"
-#include <qabstractvideosurface.h>
-#include <qvideosurfaceformat.h>
-
-#include <QtWidgets/qapplication.h>
-
-QT_USE_NAMESPACE
-class tst_QVideoWidget : public QObject
-{
- Q_OBJECT
-private slots:
- void nullObject();
- void nullService();
- void noOutputs();
- void serviceDestroyed();
- void objectDestroyed();
- void setMediaObject();
-
- void showWindowControl();
- void fullScreenWindowControl();
- void aspectRatioWindowControl();
- void sizeHintWindowControl_data() { sizeHint_data(); }
- void sizeHintWindowControl();
- void brightnessWindowControl_data() { color_data(); }
- void brightnessWindowControl();
- void contrastWindowControl_data() { color_data(); }
- void contrastWindowControl();
- void hueWindowControl_data() { color_data(); }
- void hueWindowControl();
- void saturationWindowControl_data() { color_data(); }
- void saturationWindowControl();
-
- void showWidgetControl();
- void fullScreenWidgetControl();
- void aspectRatioWidgetControl();
- void sizeHintWidgetControl_data() { sizeHint_data(); }
- void sizeHintWidgetControl();
- void brightnessWidgetControl_data() { color_data(); }
- void brightnessWidgetControl();
- void contrastWidgetControl_data() { color_data(); }
- void contrastWidgetControl();
- void hueWidgetControl_data() { color_data(); }
- void hueWidgetControl();
- void saturationWidgetControl_data() { color_data(); }
- void saturationWidgetControl();
-
- void showRendererControl();
- void fullScreenRendererControl();
- void aspectRatioRendererControl();
- void sizeHintRendererControl_data();
- void sizeHintRendererControl();
- void brightnessRendererControl_data() { color_data(); }
- void brightnessRendererControl();
- void contrastRendererControl_data() { color_data(); }
- void contrastRendererControl();
- void hueRendererControl_data() { color_data(); }
- void hueRendererControl();
- void saturationRendererControl_data() { color_data(); }
- void saturationRendererControl();
-
- void paintRendererControl();
- void paintSurface();
-
-private:
- void sizeHint_data();
- void color_data();
-};
-
-Q_DECLARE_METATYPE(Qt::AspectRatioMode)
-Q_DECLARE_METATYPE(const uchar *)
-
-class QtTestVideoWidget : public QVideoWidget
-{
-public:
- QtTestVideoWidget(QWidget *parent = 0)
- : QVideoWidget(parent)
- {
- setWindowFlags(Qt::X11BypassWindowManagerHint);
- resize(320, 240);
- }
-};
-
-class QtTestWindowControl : public QVideoWindowControl
-{
-public:
- QtTestWindowControl()
- : m_winId(0)
- , m_repaintCount(0)
- , m_brightness(0)
- , m_contrast(0)
- , m_saturation(0)
- , m_aspectRatioMode(Qt::KeepAspectRatio)
- , m_fullScreen(0)
- {
- }
-
- WId winId() const { return m_winId; }
- void setWinId(WId id) { m_winId = id; }
-
- QRect displayRect() const { return m_displayRect; }
- void setDisplayRect(const QRect &rect) { m_displayRect = rect; }
-
- bool isFullScreen() const { return m_fullScreen; }
- void setFullScreen(bool fullScreen) { emit fullScreenChanged(m_fullScreen = fullScreen); }
-
- int repaintCount() const { return m_repaintCount; }
- void setRepaintCount(int count) { m_repaintCount = count; }
- void repaint() { ++m_repaintCount; }
-
- QSize nativeSize() const { return m_nativeSize; }
- void setNativeSize(const QSize &size) { m_nativeSize = size; emit nativeSizeChanged(); }
-
- Qt::AspectRatioMode aspectRatioMode() const { return m_aspectRatioMode; }
- void setAspectRatioMode(Qt::AspectRatioMode mode) { m_aspectRatioMode = mode; }
-
- int brightness() const { return m_brightness; }
- void setBrightness(int brightness) { emit brightnessChanged(m_brightness = brightness); }
-
- int contrast() const { return m_contrast; }
- void setContrast(int contrast) { emit contrastChanged(m_contrast = contrast); }
-
- int hue() const { return m_hue; }
- void setHue(int hue) { emit hueChanged(m_hue = hue); }
-
- int saturation() const { return m_saturation; }
- void setSaturation(int saturation) { emit saturationChanged(m_saturation = saturation); }
-
-private:
- WId m_winId;
- int m_repaintCount;
- int m_brightness;
- int m_contrast;
- int m_hue;
- int m_saturation;
- Qt::AspectRatioMode m_aspectRatioMode;
- QRect m_displayRect;
- QSize m_nativeSize;
- bool m_fullScreen;
-};
-
-class QtTestWidgetControl : public QVideoWidgetControl
-{
-public:
- QtTestWidgetControl()
- : m_brightness(1.0)
- , m_contrast(1.0)
- , m_hue(1.0)
- , m_saturation(1.0)
- , m_aspectRatioMode(Qt::KeepAspectRatio)
- , m_fullScreen(false)
- {
- }
-
- bool isFullScreen() const { return m_fullScreen; }
- void setFullScreen(bool fullScreen) { emit fullScreenChanged(m_fullScreen = fullScreen); }
-
- Qt::AspectRatioMode aspectRatioMode() const { return m_aspectRatioMode; }
- void setAspectRatioMode(Qt::AspectRatioMode mode) { m_aspectRatioMode = mode; }
-
- int brightness() const { return m_brightness; }
- void setBrightness(int brightness) { emit brightnessChanged(m_brightness = brightness); }
-
- int contrast() const { return m_contrast; }
- void setContrast(int contrast) { emit contrastChanged(m_contrast = contrast); }
-
- int hue() const { return m_hue; }
- void setHue(int hue) { emit hueChanged(m_hue = hue); }
-
- int saturation() const { return m_saturation; }
- void setSaturation(int saturation) { emit saturationChanged(m_saturation = saturation); }
-
- void setSizeHint(const QSize &size) { m_widget.setSizeHint(size); }
-
- QWidget *videoWidget() { return &m_widget; }
-
-private:
- class Widget : public QWidget
- {
- public:
- QSize sizeHint() const { return m_sizeHint; }
- void setSizeHint(const QSize &size) { m_sizeHint = size; updateGeometry(); }
- private:
- QSize m_sizeHint;
- } m_widget;
- int m_brightness;
- int m_contrast;
- int m_hue;
- int m_saturation;
- Qt::AspectRatioMode m_aspectRatioMode;
- QSize m_sizeHint;
- bool m_fullScreen;
-};
-
-class QtTestRendererControl : public QVideoRendererControl
-{
-public:
- QtTestRendererControl()
- : m_surface(0)
- {
- }
-
- QAbstractVideoSurface *surface() const { return m_surface; }
- void setSurface(QAbstractVideoSurface *surface) { m_surface = surface; }
-
-private:
- QAbstractVideoSurface *m_surface;
-};
-
-class QtTestVideoService : public QMediaService
-{
- Q_OBJECT
-public:
- QtTestVideoService(
- QtTestWindowControl *window,
- QtTestWidgetControl *widget,
- QtTestRendererControl *renderer)
- : QMediaService(0)
- , windowRef(0)
- , widgetRef(0)
- , rendererRef(0)
- , windowControl(window)
- , widgetControl(widget)
- , rendererControl(renderer)
- {
- }
-
- ~QtTestVideoService()
- {
- delete windowControl;
- delete widgetControl;
- delete rendererControl;
- }
-
- QMediaControl *requestControl(const char *name)
- {
- if (qstrcmp(name, QVideoWindowControl_iid) == 0) {
- if (windowControl) {
- windowRef += 1;
-
- return windowControl;
- }
- } else if (qstrcmp(name, QVideoWidgetControl_iid) == 0) {
- if (widgetControl) {
- widgetRef += 1;
-
- return widgetControl;
- }
- } else if (qstrcmp(name, QVideoRendererControl_iid) == 0) {
- if (rendererControl) {
- rendererRef += 1;
-
- return rendererControl;
- }
- }
- return 0;
- }
-
- void releaseControl(QMediaControl *control)
- {
- Q_ASSERT(control);
-
- if (control == windowControl)
- windowRef -= 1;
- else if (control == widgetControl)
- widgetRef -= 1;
- else if (control == rendererControl)
- rendererRef -= 1;
- }
-
- int windowRef;
- int widgetRef;
- int rendererRef;
-
- QtTestWindowControl *windowControl;
- QtTestWidgetControl *widgetControl;
- QtTestRendererControl *rendererControl;
-};
-
-class QtTestVideoObject : public QMediaObject
-{
- Q_OBJECT
-public:
- QtTestVideoObject(
- QtTestWindowControl *window,
- QtTestWidgetControl *widget,
- QtTestRendererControl *renderer):
- QMediaObject(0, new QtTestVideoService(window, widget, renderer))
- {
- testService = qobject_cast<QtTestVideoService*>(service());
- }
-
- QtTestVideoObject(QtTestVideoService *service):
- QMediaObject(0, service),
- testService(service)
- {
- }
-
- ~QtTestVideoObject()
- {
- delete testService;
- }
-
- QtTestVideoService *testService;
-};
-
-void tst_QVideoWidget::nullObject()
-{
- QtTestVideoWidget widget;
-
- QVERIFY(widget.sizeHint().isEmpty());
-
- widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
-
- widget.setFullScreen(true);
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
- QCOMPARE(widget.isFullScreen(), true);
-
- widget.setAspectRatioMode(Qt::IgnoreAspectRatio);
- QCOMPARE(widget.aspectRatioMode(), Qt::IgnoreAspectRatio);
-
- {
- QSignalSpy spy(&widget, SIGNAL(brightnessChanged(int)));
-
- widget.setBrightness(100);
- QCOMPARE(widget.brightness(), 100);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.value(0).value(0).toInt(), 100);
-
- widget.setBrightness(100);
- QCOMPARE(widget.brightness(), 100);
- QCOMPARE(spy.count(), 1);
-
- widget.setBrightness(-120);
- QCOMPARE(widget.brightness(), -100);
- QCOMPARE(spy.count(), 2);
- QCOMPARE(spy.value(1).value(0).toInt(), -100);
- } {
- QSignalSpy spy(&widget, SIGNAL(contrastChanged(int)));
-
- widget.setContrast(100);
- QCOMPARE(widget.contrast(), 100);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.value(0).value(0).toInt(), 100);
-
- widget.setContrast(100);
- QCOMPARE(widget.contrast(), 100);
- QCOMPARE(spy.count(), 1);
-
- widget.setContrast(-120);
- QCOMPARE(widget.contrast(), -100);
- QCOMPARE(spy.count(), 2);
- QCOMPARE(spy.value(1).value(0).toInt(), -100);
- } {
- QSignalSpy spy(&widget, SIGNAL(hueChanged(int)));
-
- widget.setHue(100);
- QCOMPARE(widget.hue(), 100);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.value(0).value(0).toInt(), 100);
-
- widget.setHue(100);
- QCOMPARE(widget.hue(), 100);
- QCOMPARE(spy.count(), 1);
-
- widget.setHue(-120);
- QCOMPARE(widget.hue(), -100);
- QCOMPARE(spy.count(), 2);
- QCOMPARE(spy.value(1).value(0).toInt(), -100);
- } {
- QSignalSpy spy(&widget, SIGNAL(saturationChanged(int)));
-
- widget.setSaturation(100);
- QCOMPARE(widget.saturation(), 100);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.value(0).value(0).toInt(), 100);
-
- widget.setSaturation(100);
- QCOMPARE(widget.saturation(), 100);
- QCOMPARE(spy.count(), 1);
-
- widget.setSaturation(-120);
- QCOMPARE(widget.saturation(), -100);
- QCOMPARE(spy.count(), 2);
- QCOMPARE(spy.value(1).value(0).toInt(), -100);
- }
-}
-
-void tst_QVideoWidget::nullService()
-{
- QtTestVideoObject object(0);
-
- QtTestVideoWidget widget;
- object.bind(&widget);
-
- QVERIFY(widget.sizeHint().isEmpty());
-
- widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
-
- widget.setFullScreen(true);
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
- QCOMPARE(widget.isFullScreen(), true);
-
- widget.setAspectRatioMode(Qt::IgnoreAspectRatio);
- QCOMPARE(widget.aspectRatioMode(), Qt::IgnoreAspectRatio);
-
- widget.setBrightness(100);
- QCOMPARE(widget.brightness(), 100);
-
- widget.setContrast(100);
- QCOMPARE(widget.contrast(), 100);
-
- widget.setHue(100);
- QCOMPARE(widget.hue(), 100);
-
- widget.setSaturation(100);
- QCOMPARE(widget.saturation(), 100);
-}
-
-void tst_QVideoWidget::noOutputs()
-{
- QtTestVideoObject object(0, 0, 0);
-
- QtTestVideoWidget widget;
- object.bind(&widget);
-
- QVERIFY(widget.sizeHint().isEmpty());
-
- widget.setFullScreen(true);
- QCOMPARE(widget.isFullScreen(), true);
-
- widget.setBrightness(100);
- QCOMPARE(widget.brightness(), 100);
-
- widget.setContrast(100);
- QCOMPARE(widget.contrast(), 100);
-
- widget.setHue(100);
- QCOMPARE(widget.hue(), 100);
-
- widget.setSaturation(100);
- QCOMPARE(widget.saturation(), 100);
-}
-
-void tst_QVideoWidget::serviceDestroyed()
-{
-#ifdef Q_OS_MAC
- QSKIP("QTBUG-26481 - Crashes on Mac");
-#endif
-
- QtTestVideoObject object(new QtTestWindowControl, new QtTestWidgetControl, 0);
-
- QtTestVideoWidget widget;
- object.bind(&widget);
-
- widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
-
- widget.setBrightness(100);
- widget.setContrast(100);
- widget.setHue(100);
- widget.setSaturation(100);
-
- delete object.testService;
- object.testService = 0;
-
- QCOMPARE(widget.mediaObject(), static_cast<QMediaObject *>(&object));
-
- QCOMPARE(widget.brightness(), 100);
- QCOMPARE(widget.contrast(), 100);
- QCOMPARE(widget.hue(), 100);
- QCOMPARE(widget.saturation(), 100);
-
- widget.setFullScreen(true);
- QCOMPARE(widget.isFullScreen(), true);
-}
-
-void tst_QVideoWidget::objectDestroyed()
-{
-#ifdef Q_OS_MAC
- QSKIP("QTBUG-26481 - Crashes on Mac");
-#endif
-
- QtTestVideoObject *object = new QtTestVideoObject(
- new QtTestWindowControl,
- new QtTestWidgetControl,
- 0);
-
- QtTestVideoWidget widget;
- object->bind(&widget);
-
- QCOMPARE(object->testService->windowRef, 0);
- QCOMPARE(object->testService->widgetRef, 1);
- QCOMPARE(object->testService->rendererRef, 0);
-
- widget.show();
-
- widget.setBrightness(100);
- widget.setContrast(100);
- widget.setHue(100);
- widget.setSaturation(100);
-
- // Delete the media object without deleting the service.
- QtTestVideoService *service = object->testService;
- object->testService = 0;
-
- delete object;
- object = 0;
-
- QCOMPARE(widget.mediaObject(), static_cast<QMediaObject *>(object));
-
- QCOMPARE(widget.brightness(), 100);
- QCOMPARE(widget.contrast(), 100);
- QCOMPARE(widget.hue(), 100);
- QCOMPARE(widget.saturation(), 100);
-
- widget.setFullScreen(true);
- QCOMPARE(widget.isFullScreen(), true);
-
- delete service;
-}
-
-void tst_QVideoWidget::setMediaObject()
-{
- QMediaObject *nullObject = 0;
- QtTestVideoObject windowObject(new QtTestWindowControl, 0, 0);
- QtTestVideoObject widgetObject(0, new QtTestWidgetControl, 0);
- QtTestVideoObject rendererObject(0, 0, new QtTestRendererControl);
-
- QtTestVideoWidget widget;
-
- widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
-
- QCOMPARE(widget.mediaObject(), nullObject);
- QCOMPARE(windowObject.testService->windowRef, 0);
- QCOMPARE(widgetObject.testService->widgetRef, 0);
- QCOMPARE(rendererObject.testService->rendererRef, 0);
-
- windowObject.bind(&widget);
- QCOMPARE(widget.mediaObject(), static_cast<QMediaObject *>(&windowObject));
- QCOMPARE(windowObject.testService->windowRef, 1);
- QCOMPARE(widgetObject.testService->widgetRef, 0);
- QCOMPARE(rendererObject.testService->rendererRef, 0);
- QVERIFY(windowObject.testService->windowControl->winId() != 0);
-
-
- widgetObject.bind(&widget);
- QCOMPARE(widget.mediaObject(), static_cast<QMediaObject *>(&widgetObject));
- QCOMPARE(windowObject.testService->windowRef, 0);
- QCOMPARE(widgetObject.testService->widgetRef, 1);
- QCOMPARE(rendererObject.testService->rendererRef, 0);
-
- QCoreApplication::processEvents(QEventLoop::AllEvents);
- QCOMPARE(widgetObject.testService->widgetControl->videoWidget()->isVisible(), true);
-
- QCOMPARE(windowObject.testService->windowRef, 0);
- QCOMPARE(widgetObject.testService->widgetRef, 1);
- QCOMPARE(rendererObject.testService->rendererRef, 0);
-
- rendererObject.bind(&widget);
- QCOMPARE(widget.mediaObject(), static_cast<QMediaObject *>(&rendererObject));
-
- QCOMPARE(windowObject.testService->windowRef, 0);
- QCOMPARE(widgetObject.testService->widgetRef, 0);
- QCOMPARE(rendererObject.testService->rendererRef, 1);
- QVERIFY(rendererObject.testService->rendererControl->surface() != 0);
-
- rendererObject.unbind(&widget);
- QCOMPARE(widget.mediaObject(), nullObject);
-
- QCOMPARE(windowObject.testService->windowRef, 0);
- QCOMPARE(widgetObject.testService->widgetRef, 0);
- QCOMPARE(rendererObject.testService->rendererRef, 0);
-}
-
-void tst_QVideoWidget::showWindowControl()
-{
- QtTestVideoObject object(new QtTestWindowControl, 0, 0);
- object.testService->windowControl->setNativeSize(QSize(240, 180));
-
- QtTestVideoWidget widget;
- object.bind(&widget);
-
- widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
-
- QVERIFY(object.testService->windowControl->winId() != 0);
- QVERIFY(object.testService->windowControl->repaintCount() > 0);
-
- widget.resize(640, 480);
- QCOMPARE(object.testService->windowControl->displayRect(), QRect(0, 0, 640, 480));
-
- widget.move(10, 10);
- QCOMPARE(object.testService->windowControl->displayRect(), QRect(0, 0, 640, 480));
-
- widget.hide();
-}
-
-void tst_QVideoWidget::showWidgetControl()
-{
-#ifdef Q_OS_MAC
- QSKIP("QTBUG-26481 - Crashes on Mac");
-#endif
-
- QtTestVideoObject object(0, new QtTestWidgetControl, 0);
- QtTestVideoWidget widget;
- object.bind(&widget);
-
- widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
- QCOMPARE(object.testService->widgetControl->videoWidget()->isVisible(), true);
-
- widget.resize(640, 480);
-
- widget.move(10, 10);
-
- widget.hide();
-
- QCOMPARE(object.testService->widgetControl->videoWidget()->isVisible(), false);
-}
-
-void tst_QVideoWidget::showRendererControl()
-{
-#ifdef Q_OS_MAC
- QSKIP("QTBUG-26481 - Crashes on Mac");
-#endif
-
- QtTestVideoObject object(0, 0, new QtTestRendererControl);
- QtTestVideoWidget widget;
- object.bind(&widget);
-
- widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
-
- QVERIFY(object.testService->rendererControl->surface() != 0);
-
- widget.resize(640, 480);
-
- widget.move(10, 10);
-
- widget.hide();
-}
-
-void tst_QVideoWidget::aspectRatioWindowControl()
-{
- QtTestVideoObject object(new QtTestWindowControl, 0, 0);
- object.testService->windowControl->setAspectRatioMode(Qt::IgnoreAspectRatio);
-
- QtTestVideoWidget widget;
- object.bind(&widget);
-
- // Test the aspect ratio defaults to keeping the aspect ratio.
- QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio);
-
- // Test the control has been informed of the aspect ratio change, post show.
- widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
- QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio);
- QCOMPARE(object.testService->windowControl->aspectRatioMode(), Qt::KeepAspectRatio);
-
- // Test an aspect ratio change is enforced immediately while visible.
- widget.setAspectRatioMode(Qt::IgnoreAspectRatio);
- QCOMPARE(widget.aspectRatioMode(), Qt::IgnoreAspectRatio);
- QCOMPARE(object.testService->windowControl->aspectRatioMode(), Qt::IgnoreAspectRatio);
-
- // Test an aspect ratio set while not visible is respected.
- widget.hide();
- widget.setAspectRatioMode(Qt::KeepAspectRatio);
- QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio);
- widget.show();
- QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio);
- QCOMPARE(object.testService->windowControl->aspectRatioMode(), Qt::KeepAspectRatio);
-}
-
-void tst_QVideoWidget::aspectRatioWidgetControl()
-{
-#ifdef Q_OS_MAC
- QSKIP("QTBUG-26481 - Crashes on Mac");
-#endif
-
- QtTestVideoObject object(0, new QtTestWidgetControl, 0);
- object.testService->widgetControl->setAspectRatioMode(Qt::IgnoreAspectRatio);
-
- QtTestVideoWidget widget;
- object.bind(&widget);
-
- // Test the aspect ratio defaults to keeping the aspect ratio.
- QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio);
-
- // Test the control has been informed of the aspect ratio change, post show.
- widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
- QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio);
- QCOMPARE(object.testService->widgetControl->aspectRatioMode(), Qt::KeepAspectRatio);
-
- // Test an aspect ratio change is enforced immediately while visible.
- widget.setAspectRatioMode(Qt::IgnoreAspectRatio);
- QCOMPARE(widget.aspectRatioMode(), Qt::IgnoreAspectRatio);
- QCOMPARE(object.testService->widgetControl->aspectRatioMode(), Qt::IgnoreAspectRatio);
-
- // Test an aspect ratio set while not visible is respected.
- widget.hide();
- widget.setAspectRatioMode(Qt::KeepAspectRatio);
- QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio);
- widget.show();
- QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio);
- QCOMPARE(object.testService->widgetControl->aspectRatioMode(), Qt::KeepAspectRatio);
-}
-
-void tst_QVideoWidget::aspectRatioRendererControl()
-{
-#ifdef Q_OS_MAC
- QSKIP("QTBUG-26481 - Crashes on Mac");
-#endif
-
- QtTestVideoObject object(0, 0, new QtTestRendererControl);
-
- QtTestVideoWidget widget;
- object.bind(&widget);
-
- // Test the aspect ratio defaults to keeping the aspect ratio.
- QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio);
-
- // Test the control has been informed of the aspect ratio change, post show.
- widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
- QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio);
-
- // Test an aspect ratio change is enforced immediately while visible.
- widget.setAspectRatioMode(Qt::IgnoreAspectRatio);
- QCOMPARE(widget.aspectRatioMode(), Qt::IgnoreAspectRatio);
-
- // Test an aspect ratio set while not visible is respected.
- widget.hide();
- widget.setAspectRatioMode(Qt::KeepAspectRatio);
- QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio);
- widget.show();
- QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio);
-}
-
-void tst_QVideoWidget::sizeHint_data()
-{
- QTest::addColumn<QSize>("size");
-
- QTest::newRow("720x576")
- << QSize(720, 576);
-}
-
-void tst_QVideoWidget::sizeHintWindowControl()
-{
- QFETCH(QSize, size);
-
- QtTestVideoObject object(new QtTestWindowControl, 0, 0);
- QtTestVideoWidget widget;
- object.bind(&widget);
- widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
-
- QVERIFY(widget.sizeHint().isEmpty());
-
- object.testService->windowControl->setNativeSize(size);
- QCOMPARE(widget.sizeHint(), size);
-}
-
-void tst_QVideoWidget::sizeHintWidgetControl()
-{
-#ifdef Q_OS_MAC
- QSKIP("QTBUG-26481 - Crashes on Mac");
-#endif
-
- QFETCH(QSize, size);
-
- QtTestVideoObject object(0, new QtTestWidgetControl, 0);
- QtTestVideoWidget widget;
- object.bind(&widget);
- widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
-
- QVERIFY(widget.sizeHint().isEmpty());
-
- object.testService->widgetControl->setSizeHint(size);
- QCOMPARE(widget.sizeHint(), size);
-}
-
-void tst_QVideoWidget::sizeHintRendererControl_data()
-{
-#ifdef Q_OS_MAC
- QSKIP("QTBUG-26481 - Crashes on Mac");
-#endif
-
- QTest::addColumn<QSize>("frameSize");
- QTest::addColumn<QRect>("viewport");
- QTest::addColumn<QSize>("pixelAspectRatio");
- QTest::addColumn<QSize>("expectedSize");
-
- QTest::newRow("640x480")
- << QSize(640, 480)
- << QRect(0, 0, 640, 480)
- << QSize(1, 1)
- << QSize(640, 480);
-
- QTest::newRow("800x600, (80,60, 640x480) viewport")
- << QSize(800, 600)
- << QRect(80, 60, 640, 480)
- << QSize(1, 1)
- << QSize(640, 480);
-
- QTest::newRow("800x600, (80,60, 640x480) viewport, 4:3")
- << QSize(800, 600)
- << QRect(80, 60, 640, 480)
- << QSize(4, 3)
- << QSize(853, 480);
-
-}
-
-void tst_QVideoWidget::sizeHintRendererControl()
-{
-#ifdef Q_OS_MAC
- QSKIP("QTBUG-26481 - Crashes on Mac");
-#endif
-
- QFETCH(QSize, frameSize);
- QFETCH(QRect, viewport);
- QFETCH(QSize, pixelAspectRatio);
- QFETCH(QSize, expectedSize);
-
- QtTestVideoObject object(0, 0, new QtTestRendererControl);
- QtTestVideoWidget widget;
- object.bind(&widget);
-
- widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
-
- QVideoSurfaceFormat format(frameSize, QVideoFrame::Format_ARGB32);
- format.setViewport(viewport);
- format.setPixelAspectRatio(pixelAspectRatio);
-
- QVERIFY(object.testService->rendererControl->surface()->start(format));
-
- QCOMPARE(widget.sizeHint(), expectedSize);
-}
-
-
-void tst_QVideoWidget::fullScreenWindowControl()
-{
- QtTestVideoObject object(new QtTestWindowControl, 0, 0);
- QtTestVideoWidget widget;
- object.bind(&widget);
- widget.showNormal();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
-
- Qt::WindowFlags windowFlags = widget.windowFlags();
-
- QSignalSpy spy(&widget, SIGNAL(fullScreenChanged(bool)));
-
- // Test showing full screen with setFullScreen(true).
- widget.setFullScreen(true);
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
- QCOMPARE(object.testService->windowControl->isFullScreen(), true);
- QCOMPARE(widget.isFullScreen(), true);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.value(0).value(0).toBool(), true);
-
- // Test returning to normal with setFullScreen(false).
- widget.setFullScreen(false);
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
- QCOMPARE(object.testService->windowControl->isFullScreen(), false);
- QCOMPARE(widget.isFullScreen(), false);
- QCOMPARE(spy.count(), 2);
- QCOMPARE(spy.value(1).value(0).toBool(), false);
- QCOMPARE(widget.windowFlags(), windowFlags);
-
- // Test showing full screen with showFullScreen().
- widget.showFullScreen();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
- QCOMPARE(object.testService->windowControl->isFullScreen(), true);
- QCOMPARE(widget.isFullScreen(), true);
- QCOMPARE(spy.count(), 3);
- QCOMPARE(spy.value(2).value(0).toBool(), true);
-
- // Test returning to normal with showNormal().
- widget.showNormal();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
- QCOMPARE(object.testService->windowControl->isFullScreen(), false);
- QCOMPARE(widget.isFullScreen(), false);
- QCOMPARE(spy.count(), 4);
- QCOMPARE(spy.value(3).value(0).toBool(), false);
- QCOMPARE(widget.windowFlags(), windowFlags);
-
- // Test setFullScreen(false) and showNormal() do nothing when isFullScreen() == false.
- widget.setFullScreen(false);
- QCOMPARE(object.testService->windowControl->isFullScreen(), false);
- QCOMPARE(widget.isFullScreen(), false);
- QCOMPARE(spy.count(), 4);
- widget.showNormal();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
- QCOMPARE(object.testService->windowControl->isFullScreen(), false);
- QCOMPARE(widget.isFullScreen(), false);
- QCOMPARE(spy.count(), 4);
-
- // Test setFullScreen(true) and showFullScreen() do nothing when isFullScreen() == true.
- widget.showFullScreen();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
- widget.setFullScreen(true);
- QCOMPARE(object.testService->windowControl->isFullScreen(), true);
- QCOMPARE(widget.isFullScreen(), true);
- QCOMPARE(spy.count(), 5);
- widget.showFullScreen();
- QCOMPARE(object.testService->windowControl->isFullScreen(), true);
- QCOMPARE(widget.isFullScreen(), true);
- QCOMPARE(spy.count(), 5);
-
- // Test if the window control exits full screen mode, the widget follows suit.
- object.testService->windowControl->setFullScreen(false);
- QCOMPARE(widget.isFullScreen(), false);
- QCOMPARE(spy.count(), 6);
- QCOMPARE(spy.value(5).value(0).toBool(), false);
-
- // Test if the window control enters full screen mode, the widget does nothing.
- object.testService->windowControl->setFullScreen(false);
- QCOMPARE(widget.isFullScreen(), false);
- QCOMPARE(spy.count(), 6);
-}
-
-void tst_QVideoWidget::fullScreenWidgetControl()
-{
-#ifdef Q_OS_MAC
- QSKIP("QTBUG-26481 - Crashes on Mac");
-#endif
-
- QtTestVideoObject object(0, new QtTestWidgetControl, 0);
- QtTestVideoWidget widget;
- object.bind(&widget);
- widget.showNormal();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
-
- Qt::WindowFlags windowFlags = widget.windowFlags();
-
- QSignalSpy spy(&widget, SIGNAL(fullScreenChanged(bool)));
-
- // Test showing full screen with setFullScreen(true).
- widget.setFullScreen(true);
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
- QCOMPARE(object.testService->widgetControl->isFullScreen(), true);
- QCOMPARE(widget.isFullScreen(), true);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.value(0).value(0).toBool(), true);
-
- // Test returning to normal with setFullScreen(false).
- widget.setFullScreen(false);
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
- QCOMPARE(object.testService->widgetControl->isFullScreen(), false);
- QCOMPARE(widget.isFullScreen(), false);
- QCOMPARE(spy.count(), 2);
- QCOMPARE(spy.value(1).value(0).toBool(), false);
- QCOMPARE(widget.windowFlags(), windowFlags);
-
- // Test showing full screen with showFullScreen().
- widget.showFullScreen();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
- QCOMPARE(object.testService->widgetControl->isFullScreen(), true);
- QCOMPARE(widget.isFullScreen(), true);
- QCOMPARE(spy.count(), 3);
- QCOMPARE(spy.value(2).value(0).toBool(), true);
-
- // Test returning to normal with showNormal().
- widget.showNormal();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
- QCOMPARE(object.testService->widgetControl->isFullScreen(), false);
- QCOMPARE(widget.isFullScreen(), false);
- QCOMPARE(spy.count(), 4);
- QCOMPARE(spy.value(3).value(0).toBool(), false);
- QCOMPARE(widget.windowFlags(), windowFlags);
-
- // Test setFullScreen(false) and showNormal() do nothing when isFullScreen() == false.
- widget.setFullScreen(false);
- QCOMPARE(object.testService->widgetControl->isFullScreen(), false);
- QCOMPARE(widget.isFullScreen(), false);
- QCOMPARE(spy.count(), 4);
- widget.showNormal();
- QCOMPARE(object.testService->widgetControl->isFullScreen(), false);
- QCOMPARE(widget.isFullScreen(), false);
- QCOMPARE(spy.count(), 4);
-
- // Test setFullScreen(true) and showFullScreen() do nothing when isFullScreen() == true.
- widget.showFullScreen();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
- widget.setFullScreen(true);
- QCOMPARE(object.testService->widgetControl->isFullScreen(), true);
- QCOMPARE(widget.isFullScreen(), true);
- QCOMPARE(spy.count(), 5);
- widget.showFullScreen();
- QCOMPARE(object.testService->widgetControl->isFullScreen(), true);
- QCOMPARE(widget.isFullScreen(), true);
- QCOMPARE(spy.count(), 5);
-
- // Test if the window control exits full screen mode, the widget follows suit.
- object.testService->widgetControl->setFullScreen(false);
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
- QCOMPARE(widget.isFullScreen(), false);
- QCOMPARE(spy.count(), 6);
- QCOMPARE(spy.value(5).value(0).toBool(), false);
-
- // Test if the window control enters full screen mode, the widget does nothing.
- object.testService->widgetControl->setFullScreen(false);
- QCOMPARE(widget.isFullScreen(), false);
- QCOMPARE(spy.count(), 6);
-}
-
-
-void tst_QVideoWidget::fullScreenRendererControl()
-{
-#ifdef Q_OS_MAC
- QSKIP("QTBUG-26481 - Crashes on Mac");
-#endif
-
- QtTestVideoObject object(0, 0, new QtTestRendererControl);
- QtTestVideoWidget widget;
- object.bind(&widget);
- widget.showNormal();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
-
- Qt::WindowFlags windowFlags = widget.windowFlags();
-
- QSignalSpy spy(&widget, SIGNAL(fullScreenChanged(bool)));
-
- // Test showing full screen with setFullScreen(true).
- widget.setFullScreen(true);
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
- QCOMPARE(widget.isFullScreen(), true);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.value(0).value(0).toBool(), true);
-
- // Test returning to normal with setFullScreen(false).
- widget.setFullScreen(false);
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
- QCOMPARE(widget.isFullScreen(), false);
- QCOMPARE(spy.count(), 2);
- QCOMPARE(spy.value(1).value(0).toBool(), false);
- QCOMPARE(widget.windowFlags(), windowFlags);
-
- // Test showing full screen with showFullScreen().
- widget.showFullScreen();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
- QCOMPARE(widget.isFullScreen(), true);
- QCOMPARE(spy.count(), 3);
- QCOMPARE(spy.value(2).value(0).toBool(), true);
-
- // Test returning to normal with showNormal().
- widget.showNormal();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
- QCOMPARE(widget.isFullScreen(), false);
- QCOMPARE(spy.count(), 4);
- QCOMPARE(spy.value(3).value(0).toBool(), false);
- QCOMPARE(widget.windowFlags(), windowFlags);
-
- // Test setFullScreen(false) and showNormal() do nothing when isFullScreen() == false.
- widget.setFullScreen(false);
- QCOMPARE(widget.isFullScreen(), false);
- QCOMPARE(spy.count(), 4);
- widget.showNormal();
- QCOMPARE(widget.isFullScreen(), false);
- QCOMPARE(spy.count(), 4);
-
- // Test setFullScreen(true) and showFullScreen() do nothing when isFullScreen() == true.
- widget.showFullScreen();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
- widget.setFullScreen(true);
- QCOMPARE(widget.isFullScreen(), true);
- QCOMPARE(spy.count(), 5);
- widget.showFullScreen();
- QCOMPARE(widget.isFullScreen(), true);
- QCOMPARE(spy.count(), 5);
-}
-
-
-void tst_QVideoWidget::color_data()
-{
- QTest::addColumn<int>("controlValue");
- QTest::addColumn<int>("value");
- QTest::addColumn<int>("expectedValue");
-
- QTest::newRow("12")
- << 0
- << 12
- << 12;
- QTest::newRow("-56")
- << 87
- << -56
- << -56;
- QTest::newRow("100")
- << 32
- << 100
- << 100;
- QTest::newRow("1294")
- << 0
- << 1294
- << 100;
- QTest::newRow("-102")
- << 34
- << -102
- << -100;
-}
-
-void tst_QVideoWidget::brightnessWindowControl()
-{
- QFETCH(int, controlValue);
- QFETCH(int, value);
- QFETCH(int, expectedValue);
-
- QtTestVideoObject object(new QtTestWindowControl, 0, 0);
- object.testService->windowControl->setBrightness(controlValue);
-
- QtTestVideoWidget widget;
- object.bind(&widget);
- widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
-
- // Test the video widget resets the controls starting brightness to the default.
- QCOMPARE(widget.brightness(), 0);
-
- QSignalSpy spy(&widget, SIGNAL(brightnessChanged(int)));
-
- // Test the video widget sets the brightness value, bounded if necessary and emits a changed
- // signal.
- widget.setBrightness(value);
- QCOMPARE(widget.brightness(), expectedValue);
- QCOMPARE(object.testService->windowControl->brightness(), expectedValue);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.value(0).value(0).toInt(), expectedValue);
-
- // Test the changed signal isn't emitted if the value is unchanged.
- widget.setBrightness(value);
- QCOMPARE(widget.brightness(), expectedValue);
- QCOMPARE(object.testService->windowControl->brightness(), expectedValue);
- QCOMPARE(spy.count(), 1);
-
- // Test the changed signal is emitted if the brightness is changed internally.
- object.testService->windowControl->setBrightness(controlValue);
- QCOMPARE(widget.brightness(), controlValue);
- QCOMPARE(spy.count(), 2);
- QCOMPARE(spy.value(1).value(0).toInt(), controlValue);
-}
-
-void tst_QVideoWidget::brightnessWidgetControl()
-{
-#ifdef Q_OS_MAC
- QSKIP("QTBUG-26481 - Crashes on Mac");
-#endif
-
- QFETCH(int, controlValue);
- QFETCH(int, value);
- QFETCH(int, expectedValue);
-
- QtTestVideoObject object(0, new QtTestWidgetControl, 0);
- object.testService->widgetControl->setBrightness(controlValue);
-
- QtTestVideoWidget widget;
- object.bind(&widget);
-
- QCOMPARE(widget.brightness(), 0);
-
- widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
-
- QSignalSpy spy(&widget, SIGNAL(brightnessChanged(int)));
-
- widget.setBrightness(value);
- QCOMPARE(widget.brightness(), expectedValue);
- QCOMPARE(object.testService->widgetControl->brightness(), expectedValue);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.value(0).value(0).toInt(), expectedValue);
-
- widget.setBrightness(value);
- QCOMPARE(widget.brightness(), expectedValue);
- QCOMPARE(object.testService->widgetControl->brightness(), expectedValue);
- QCOMPARE(spy.count(), 1);
-
- object.testService->widgetControl->setBrightness(controlValue);
- QCOMPARE(widget.brightness(), controlValue);
- QCOMPARE(spy.count(), 2);
- QCOMPARE(spy.value(1).value(0).toInt(), controlValue);
-}
-
-void tst_QVideoWidget::brightnessRendererControl()
-{
-#ifdef Q_OS_MAC
- QSKIP("QTBUG-26481 - Crashes on Mac");
-#endif
-
- QFETCH(int, value);
- QFETCH(int, expectedValue);
-
- QtTestVideoObject object(0, 0, new QtTestRendererControl);
-
- QtTestVideoWidget widget;
- object.bind(&widget);
- widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
-
- QSignalSpy spy(&widget, SIGNAL(brightnessChanged(int)));
-
- widget.setBrightness(value);
- QCOMPARE(widget.brightness(), expectedValue);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.value(0).value(0).toInt(), expectedValue);
-
- widget.setBrightness(value);
- QCOMPARE(widget.brightness(), expectedValue);
- QCOMPARE(spy.count(), 1);
-}
-
-void tst_QVideoWidget::contrastWindowControl()
-{
- QFETCH(int, controlValue);
- QFETCH(int, value);
- QFETCH(int, expectedValue);
-
- QtTestVideoObject object(new QtTestWindowControl, 0, 0);
- object.testService->windowControl->setContrast(controlValue);
-
- QtTestVideoWidget widget;
- object.bind(&widget);
-
- QCOMPARE(widget.contrast(), 0);
-
- widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
- QCOMPARE(widget.contrast(), 0);
-
- QSignalSpy spy(&widget, SIGNAL(contrastChanged(int)));
-
- widget.setContrast(value);
- QCOMPARE(widget.contrast(), expectedValue);
- QCOMPARE(object.testService->windowControl->contrast(), expectedValue);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.value(0).value(0).toInt(), expectedValue);
-
- widget.setContrast(value);
- QCOMPARE(widget.contrast(), expectedValue);
- QCOMPARE(object.testService->windowControl->contrast(), expectedValue);
- QCOMPARE(spy.count(), 1);
-
- object.testService->windowControl->setContrast(controlValue);
- QCOMPARE(widget.contrast(), controlValue);
- QCOMPARE(spy.count(), 2);
- QCOMPARE(spy.value(1).value(0).toInt(), controlValue);
-}
-
-void tst_QVideoWidget::contrastWidgetControl()
-{
-#ifdef Q_OS_MAC
- QSKIP("QTBUG-26481 - Crashes on Mac");
-#endif
-
- QFETCH(int, controlValue);
- QFETCH(int, value);
- QFETCH(int, expectedValue);
-
- QtTestVideoObject object(0, new QtTestWidgetControl, 0);
- object.testService->widgetControl->setContrast(controlValue);
-
- QtTestVideoWidget widget;
- object.bind(&widget);
- QCOMPARE(widget.contrast(), 0);
-
- widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
- QCOMPARE(widget.contrast(), 0);
-
- QSignalSpy spy(&widget, SIGNAL(contrastChanged(int)));
-
- widget.setContrast(value);
- QCOMPARE(widget.contrast(), expectedValue);
- QCOMPARE(object.testService->widgetControl->contrast(), expectedValue);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.value(0).value(0).toInt(), expectedValue);
-
- widget.setContrast(value);
- QCOMPARE(widget.contrast(), expectedValue);
- QCOMPARE(object.testService->widgetControl->contrast(), expectedValue);
- QCOMPARE(spy.count(), 1);
-
- object.testService->widgetControl->setContrast(controlValue);
- QCOMPARE(widget.contrast(), controlValue);
- QCOMPARE(spy.count(), 2);
- QCOMPARE(spy.value(1).value(0).toInt(), controlValue);
-}
-
-void tst_QVideoWidget::contrastRendererControl()
-{
-#ifdef Q_OS_MAC
- QSKIP("QTBUG-26481 - Crashes on Mac");
-#endif
-
- QFETCH(int, value);
- QFETCH(int, expectedValue);
-
- QtTestVideoObject object(0, 0, new QtTestRendererControl);
-
- QtTestVideoWidget widget;
- object.bind(&widget);
- widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
-
- QSignalSpy spy(&widget, SIGNAL(contrastChanged(int)));
-
- widget.setContrast(value);
- QCOMPARE(widget.contrast(), expectedValue);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.value(0).value(0).toInt(), expectedValue);
-
- widget.setContrast(value);
- QCOMPARE(widget.contrast(), expectedValue);
- QCOMPARE(spy.count(), 1);
-}
-
-void tst_QVideoWidget::hueWindowControl()
-{
- QFETCH(int, controlValue);
- QFETCH(int, value);
- QFETCH(int, expectedValue);
-
- QtTestVideoObject object(new QtTestWindowControl, 0, 0);
- object.testService->windowControl->setHue(controlValue);
-
- QtTestVideoWidget widget;
- object.bind(&widget);
- QCOMPARE(widget.hue(), 0);
-
- widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
- QCOMPARE(widget.hue(), 0);
-
- QSignalSpy spy(&widget, SIGNAL(hueChanged(int)));
-
- widget.setHue(value);
- QCOMPARE(widget.hue(), expectedValue);
- QCOMPARE(object.testService->windowControl->hue(), expectedValue);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.value(0).value(0).toInt(), expectedValue);
-
- widget.setHue(value);
- QCOMPARE(widget.hue(), expectedValue);
- QCOMPARE(object.testService->windowControl->hue(), expectedValue);
- QCOMPARE(spy.count(), 1);
-
- object.testService->windowControl->setHue(controlValue);
- QCOMPARE(widget.hue(), controlValue);
- QCOMPARE(spy.count(), 2);
- QCOMPARE(spy.value(1).value(0).toInt(), controlValue);
-}
-
-void tst_QVideoWidget::hueWidgetControl()
-{
-#ifdef Q_OS_MAC
- QSKIP("QTBUG-26481 - Crashes on Mac");
-#endif
-
- QFETCH(int, controlValue);
- QFETCH(int, value);
- QFETCH(int, expectedValue);
-
- QtTestVideoObject object(0, new QtTestWidgetControl, 0);
- object.testService->widgetControl->setHue(controlValue);
-
- QtTestVideoWidget widget;
- object.bind(&widget);
- QCOMPARE(widget.hue(), 0);
-
- widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
- QCOMPARE(widget.hue(), 0);
-
- QSignalSpy spy(&widget, SIGNAL(hueChanged(int)));
-
- widget.setHue(value);
- QCOMPARE(widget.hue(), expectedValue);
- QCOMPARE(object.testService->widgetControl->hue(), expectedValue);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.value(0).value(0).toInt(), expectedValue);
-
- widget.setHue(value);
- QCOMPARE(widget.hue(), expectedValue);
- QCOMPARE(object.testService->widgetControl->hue(), expectedValue);
- QCOMPARE(spy.count(), 1);
-
- object.testService->widgetControl->setHue(controlValue);
- QCOMPARE(widget.hue(), controlValue);
- QCOMPARE(spy.count(), 2);
- QCOMPARE(spy.value(1).value(0).toInt(), controlValue);
-}
-
-void tst_QVideoWidget::hueRendererControl()
-{
-#ifdef Q_OS_MAC
- QSKIP("QTBUG-26481 - Crashes on Mac");
-#endif
-
- QFETCH(int, value);
- QFETCH(int, expectedValue);
-
- QtTestVideoObject object(0, 0, new QtTestRendererControl);
-
- QtTestVideoWidget widget;
- object.bind(&widget);
- widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
-
- QSignalSpy spy(&widget, SIGNAL(hueChanged(int)));
-
- widget.setHue(value);
- QCOMPARE(widget.hue(), expectedValue);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.value(0).value(0).toInt(), expectedValue);
-
- widget.setHue(value);
- QCOMPARE(widget.hue(), expectedValue);
- QCOMPARE(spy.count(), 1);
-}
-
-void tst_QVideoWidget::saturationWindowControl()
-{
- QFETCH(int, controlValue);
- QFETCH(int, value);
- QFETCH(int, expectedValue);
-
- QtTestVideoObject object(new QtTestWindowControl, 0, 0);
- object.testService->windowControl->setSaturation(controlValue);
-
- QtTestVideoWidget widget;
- object.bind(&widget);
- QCOMPARE(widget.saturation(), 0);
- widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
- QCOMPARE(widget.saturation(), 0);
-
- QSignalSpy spy(&widget, SIGNAL(saturationChanged(int)));
-
- widget.setSaturation(value);
- QCOMPARE(widget.saturation(), expectedValue);
- QCOMPARE(object.testService->windowControl->saturation(), expectedValue);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.value(0).value(0).toInt(), expectedValue);
-
- widget.setSaturation(value);
- QCOMPARE(widget.saturation(), expectedValue);
- QCOMPARE(object.testService->windowControl->saturation(), expectedValue);
- QCOMPARE(spy.count(), 1);
-
- object.testService->windowControl->setSaturation(controlValue);
- QCOMPARE(widget.saturation(), controlValue);
- QCOMPARE(spy.count(), 2);
- QCOMPARE(spy.value(1).value(0).toInt(), controlValue);
-}
-
-void tst_QVideoWidget::saturationWidgetControl()
-{
-#ifdef Q_OS_MAC
- QSKIP("QTBUG-26481 - Crashes on Mac");
-#endif
-
- QFETCH(int, controlValue);
- QFETCH(int, value);
- QFETCH(int, expectedValue);
-
- QtTestVideoObject object(0, new QtTestWidgetControl, 0);
- object.testService->widgetControl->setSaturation(controlValue);
-
- QtTestVideoWidget widget;
- object.bind(&widget);
-
- QCOMPARE(widget.saturation(), 0);
- widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
- QCOMPARE(widget.saturation(), 0);
-
- QSignalSpy spy(&widget, SIGNAL(saturationChanged(int)));
-
- widget.setSaturation(value);
- QCOMPARE(widget.saturation(), expectedValue);
- QCOMPARE(object.testService->widgetControl->saturation(), expectedValue);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.value(0).value(0).toInt(), expectedValue);
-
- widget.setSaturation(value);
- QCOMPARE(widget.saturation(), expectedValue);
- QCOMPARE(object.testService->widgetControl->saturation(), expectedValue);
- QCOMPARE(spy.count(), 1);
-
- object.testService->widgetControl->setSaturation(controlValue);
- QCOMPARE(widget.saturation(), controlValue);
- QCOMPARE(spy.count(), 2);
- QCOMPARE(spy.value(1).value(0).toInt(), controlValue);
-
-}
-
-void tst_QVideoWidget::saturationRendererControl()
-{
-#ifdef Q_OS_MAC
- QSKIP("QTBUG-26481 - Crashes on Mac");
-#endif
-
- QFETCH(int, value);
- QFETCH(int, expectedValue);
-
- QtTestVideoObject object(0, 0, new QtTestRendererControl);
-
- QtTestVideoWidget widget;
- object.bind(&widget);
- widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
- QSignalSpy spy(&widget, SIGNAL(saturationChanged(int)));
-
- widget.setSaturation(value);
- QCOMPARE(widget.saturation(), expectedValue);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.value(0).value(0).toInt(), expectedValue);
-
- widget.setSaturation(value);
- QCOMPARE(widget.saturation(), expectedValue);
- QCOMPARE(spy.count(), 1);
-}
-
-static const uchar rgb32ImageData[] =
-{
- 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00,
- 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00
-};
-
-void tst_QVideoWidget::paintRendererControl()
-{
- QtTestVideoObject object(0, 0, new QtTestRendererControl);
-
- QtTestVideoWidget widget;
- object.bind(&widget);
- widget.resize(640,480);
- widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
-
- QPainterVideoSurface *surface = qobject_cast<QPainterVideoSurface *>(
- object.testService->rendererControl->surface());
-
- QVideoSurfaceFormat format(QSize(2, 2), QVideoFrame::Format_RGB32);
-
- QVERIFY(surface->start(format));
- QCOMPARE(surface->isActive(), true);
- QCOMPARE(surface->isReady(), true);
-
- QCoreApplication::processEvents(QEventLoop::AllEvents);
-
- QCOMPARE(surface->isActive(), true);
- QCOMPARE(surface->isReady(), true);
-
- QVideoFrame frame(sizeof(rgb32ImageData), QSize(2, 2), 8, QVideoFrame::Format_RGB32);
-
- frame.map(QAbstractVideoBuffer::WriteOnly);
- memcpy(frame.bits(), rgb32ImageData, frame.mappedBytes());
- frame.unmap();
-
- QVERIFY(surface->present(frame));
- QCOMPARE(surface->isActive(), true);
- QCOMPARE(surface->isReady(), false);
-
- QTRY_COMPARE(surface->isReady(), true);
- QCOMPARE(surface->isActive(), true);
- QCOMPARE(surface->isReady(), true);
-}
-
-void tst_QVideoWidget::paintSurface()
-{
- QtTestVideoWidget widget;
- widget.resize(640,480);
- widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
-
- QVERIFY(widget.videoSurface());
- auto surface = qobject_cast<QPainterVideoSurface *>(
- widget.videoSurface());
- QVERIFY(surface);
-
- QVideoSurfaceFormat format(QSize(2, 2), QVideoFrame::Format_RGB32);
- QVERIFY(surface->start(format));
- QCOMPARE(surface->isActive(), true);
-
- QVideoFrame frame(sizeof(rgb32ImageData), QSize(2, 2), 8, QVideoFrame::Format_RGB32);
- frame.map(QAbstractVideoBuffer::WriteOnly);
- memcpy(frame.bits(), rgb32ImageData, frame.mappedBytes());
- frame.unmap();
-
- QVERIFY(surface->present(frame));
- QCOMPARE(surface->isReady(), false);
- QTRY_COMPARE(surface->isReady(), true);
- QCOMPARE(surface->isActive(), true);
- QCOMPARE(surface->isReady(), true);
-}
-
-QTEST_MAIN(tst_QVideoWidget)
-
-#include "tst_qvideowidget.moc"
diff --git a/tests/auto/unit/qwavedecoder/data/gendata.sh b/tests/auto/unit/qwavedecoder/data/gendata.sh
deleted file mode 100755
index c799e6f9f..000000000
--- a/tests/auto/unit/qwavedecoder/data/gendata.sh
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/bin/bash
-#############################################################################
-##
-## Copyright (C) 2016 The Qt Company Ltd.
-## Contact: https://www.qt.io/licensing/
-##
-## This file is the build configuration utility of the Qt Toolkit.
-##
-## $QT_BEGIN_LICENSE:GPL-EXCEPT$
-## Commercial License Usage
-## Licensees holding valid commercial Qt licenses may use this file in
-## accordance with the commercial license agreement provided with the
-## Software or, alternatively, in accordance with the terms contained in
-## a written agreement between you and The Qt Company. For licensing terms
-## and conditions see https://www.qt.io/terms-conditions. For further
-## information use the contact form at https://www.qt.io/contact-us.
-##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 3 as published by the Free Software
-## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-## included in the packaging of this file. Please review the following
-## information to ensure the GNU General Public License requirements will
-## be met: https://www.gnu.org/licenses/gpl-3.0.html.
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
-
-# Generate some simple test data. Uses "sox".
-
-endian=""
-endian_extn=""
-
-for channel in 1 2; do
- if [ $channel -eq 1 ]; then
- endian="little"
- endian_extn="le"
- fi
-
- if [ $channel -eq 2 ]; then
- endian="big"
- endian_extn="be"
- fi
- for samplebits in 8 16 32; do
- for samplerate in 44100 8000; do
- if [ $samplebits -ne 8 ]; then
- sox -n --endian "${endian}" -c ${channel} -b ${samplebits} -r ${samplerate} isawav_${channel}_${samplebits}_${samplerate}_${endian_extn}.wav synth 0.25 sine 300-3300
- else
- sox -n -c ${channel} -b ${samplebits} -r ${samplerate} isawav_${channel}_${samplebits}_${samplerate}.wav synth 0.25 sine 300-3300
- fi
- done
- done
-done
-
diff --git a/tests/auto/unit/qwavedecoder/qwavedecoder.pro b/tests/auto/unit/qwavedecoder/qwavedecoder.pro
deleted file mode 100644
index 1409df98b..000000000
--- a/tests/auto/unit/qwavedecoder/qwavedecoder.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-TARGET = tst_qwavedecoder
-HEADERS += ../../../../src/multimedia/audio/qwavedecoder_p.h
-SOURCES += tst_qwavedecoder.cpp \
- ../../../../src/multimedia/audio/qwavedecoder_p.cpp
-
-QT += multimedia-private testlib network
-CONFIG += testcase
-
-TESTDATA += data/*
diff --git a/tests/auto/unit/unit.pro b/tests/auto/unit/unit.pro
deleted file mode 100644
index 37f85209e..000000000
--- a/tests/auto/unit/unit.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-TEMPLATE = subdirs
-
-SUBDIRS += multimedia.pro
-qtHaveModule(widgets): SUBDIRS += multimediawidgets.pro
-qtHaveModule(qml): SUBDIRS += multimediaqml.pro