Commit 204b623a authored by VaL Doroshchuk's avatar VaL Doroshchuk
Browse files

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: default avatarChristian Stromme <christian.stromme@qt.io>
parent e0a069ed
Branches
Tags
No related merge requests found
Showing with 22 additions and 0 deletions
......@@ -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;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment