diff options
author | VaL Doroshchuk <valentyn.doroshchuk@qt.io> | 2017-11-15 09:31:09 +0100 |
---|---|---|
committer | VaL Doroshchuk <valentyn.doroshchuk@qt.io> | 2018-03-21 12:32:15 +0000 |
commit | 204b623a8cfe2b2c9fb95fcf7b71fe0f183a5302 (patch) | |
tree | 15527cfbb43264d5a5bda943e782a29256997121 /tests/auto/integration | |
parent | e0a069edc2d79b69fd187ffbe03a8388a612b3ff (diff) | |
download | qtmultimedia-204b623a8cfe2b2c9fb95fcf7b71fe0f183a5302.tar.gz |
Add test for checking error handling on start
If a camera is not started successfully error() signal has to be
emitted.
This change adds a test for checking that we emit
and set the correct status and state when trying
to start an already active camera.
Task-number: QTBUG-51825
Change-Id: Ia14119aa9a93a76e363214401b8c2e9f216e35c9
Reviewed-by: Christian Stromme <christian.stromme@qt.io>
Diffstat (limited to 'tests/auto/integration')
-rw-r--r-- | tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp b/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp index 5035cb6b1..b568f38fc 100644 --- a/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp +++ b/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp @@ -76,6 +76,7 @@ private slots: void testCtorWithPosition(); void testCameraStates(); + void testCameraStartError(); void testCaptureMode(); void testCameraCapture(); void testCaptureToBuffer(); @@ -251,6 +252,27 @@ void tst_QCameraBackend::testCameraStates() QCOMPARE(errorSignal.count(), 0); } +void tst_QCameraBackend::testCameraStartError() +{ + QCamera camera1(QCameraInfo::defaultCamera()); + QCamera camera2(QCameraInfo::defaultCamera()); + QSignalSpy errorSpy1(&camera1, QOverload<QCamera::Error>::of(&QCamera::error)); + QSignalSpy errorSpy2(&camera2, QOverload<QCamera::Error>::of(&QCamera::error)); + + camera1.start(); + camera2.start(); + + QCOMPARE(camera1.state(), QCamera::ActiveState); + QTRY_COMPARE(camera1.status(), QCamera::ActiveStatus); + QCOMPARE(camera1.error(), QCamera::NoError); + QCOMPARE(camera2.state(), QCamera::UnloadedState); + QCOMPARE(camera2.status(), QCamera::UnloadedStatus); + QCOMPARE(camera2.error(), QCamera::CameraError); + + QCOMPARE(errorSpy1.count(), 0); + QCOMPARE(errorSpy2.count(), 1); +} + void tst_QCameraBackend::testCaptureMode() { QCamera camera; |