diff options
author | Lars Knoll <lars.knoll@qt.io> | 2021-05-17 18:23:49 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2021-05-18 08:45:00 +0000 |
commit | 1955e9f3fb527a8e1a33f51e0a50b7627a1ac8fe (patch) | |
tree | 82d17a8167eb45b8410d96ee4c5d27730a26484e /tests | |
parent | b22138591fd65b012ae8267f053a64092a797737 (diff) |
Merge the QPlatformCameraFocus class into QPlatformCamera
Adjust the backend API while we're at it, so that the base
class does some of the state management and signal emissions.
Slight cleanups of the code in the different backends.
Change-Id: Ie246da060260c5aeb6af54e7414deb0395b0cdf1
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests')
7 files changed, 12 insertions, 106 deletions
diff --git a/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp b/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp index f4f2e3a10..8a8057966 100644 --- a/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp +++ b/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp @@ -34,7 +34,6 @@ #include <private/qplatformcamera_p.h> #include <private/qplatformcameraexposure_p.h> -#include <private/qplatformcamerafocus_p.h> #include <private/qplatformcameraimagecapture_p.h> #include <private/qplatformcameraimageprocessing_p.h> #include <qcamera.h> diff --git a/tests/auto/unit/mockbackend/CMakeLists.txt b/tests/auto/unit/mockbackend/CMakeLists.txt index 5bddb393b..8def1a078 100644 --- a/tests/auto/unit/mockbackend/CMakeLists.txt +++ b/tests/auto/unit/mockbackend/CMakeLists.txt @@ -16,7 +16,6 @@ target_sources(QtMultimediaMockBackend INTERFACE qmockaudiodecoder.h qmockcamera.h qmockcameraexposure.h - qmockcamerafocus.h qmockcameraimageprocessing.h qmockimagecapture.h qmockimagecapture.cpp qmockmediaplayer.h diff --git a/tests/auto/unit/mockbackend/qmockcamera.h b/tests/auto/unit/mockbackend/qmockcamera.h index 3f7966526..9a8a6549f 100644 --- a/tests/auto/unit/mockbackend/qmockcamera.h +++ b/tests/auto/unit/mockbackend/qmockcamera.h @@ -31,7 +31,6 @@ #include "private/qplatformcamera_p.h" #include "qcamerainfo.h" -#include "qmockcamerafocus.h" #include "qmockcameraimageprocessing.h" #include "qmockcameraexposure.h" #include <qtimer.h> @@ -56,7 +55,6 @@ public: { if (!simpleCamera) { mockExposure = new QMockCameraExposure(this); - mockFocus = new QMockCameraFocus(this); mockImageProcessing = new QMockCameraImageProcessing(this); } } @@ -92,7 +90,16 @@ public: m_camera = camera; } - QPlatformCameraFocus *focusControl() override{ return mockFocus; } + void setFocusMode(QCamera::FocusMode mode) override { focusModeChanged(mode); } + bool isFocusModeSupported(QCamera::FocusMode /*mode*/) const override { return true; } + + bool isCustomFocusPointSupported() const override { return true; } + void setCustomFocusPoint(const QPointF &point) override { customFocusPointChanged(point); } + + void setFocusDistance(float d) override { focusDistanceChanged(d); } + + void zoomTo(float newZoomFactor, float /*rate*/) override { zoomFactorChanged(newZoomFactor); } + QPlatformCameraExposure *exposureControl() override { return mockExposure; } QPlatformCameraImageProcessing *imageProcessingControl() override { return mockImageProcessing; } @@ -102,7 +109,6 @@ public: bool m_propertyChangesSupported; QMockCameraExposure *mockExposure = nullptr; - QMockCameraFocus *mockFocus = nullptr; QMockCameraImageProcessing *mockImageProcessing = nullptr; }; diff --git a/tests/auto/unit/mockbackend/qmockcamerafocus.h b/tests/auto/unit/mockbackend/qmockcamerafocus.h deleted file mode 100644 index c1276fbad..000000000 --- a/tests/auto/unit/mockbackend/qmockcamerafocus.h +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2021 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 "private/qplatformcamerafocus_p.h" -#include "qcamera.h" - -class QMockCameraFocus : public QPlatformCameraFocus -{ - Q_OBJECT -public: - QMockCameraFocus(QObject *parent = 0): - QPlatformCameraFocus(parent) - { - } - - ~QMockCameraFocus() {} - - QCamera::FocusMode focusMode() const - { - return m_focusMode; - } - - void setFocusMode(QCamera::FocusMode mode) - { - if (isFocusModeSupported(mode)) - m_focusMode = mode; - } - - bool isFocusModeSupported(QCamera::FocusMode mode) const - { - return mode == QCamera::FocusModeAuto; - } - - QPointF focusPoint() const - { - return m_focusPoint; - } - - void setCustomFocusPoint(const QPointF &point) - { - m_focusPoint = point; - } - - ZoomRange zoomFactorRange() const { - return { 1., m_maxZoom }; - } - - void zoomTo(float zoom, float /*rate*/) - { - m_zoom = zoom; - } - - void setMaxZoomFactor(float factor) { - m_maxZoom = factor; - emit maximumZoomFactorChanged(m_maxZoom); - } - -private: - QCamera::FocusMode m_focusMode = QCamera::FocusModeAuto; - QPointF m_focusPoint{.5, .5}; - - float m_zoom = 1.; - float m_maxZoom = 4.; -}; - -#endif // MOCKCAMERAFOCUSCONTROL_H diff --git a/tests/auto/unit/multimedia/qcamera/tst_qcamera.cpp b/tests/auto/unit/multimedia/qcamera/tst_qcamera.cpp index 41099d667..6f5c584c5 100644 --- a/tests/auto/unit/multimedia/qcamera/tst_qcamera.cpp +++ b/tests/auto/unit/multimedia/qcamera/tst_qcamera.cpp @@ -34,7 +34,6 @@ #include <qvideosink.h> #include <private/qplatformcamera_p.h> #include <private/qplatformcameraexposure_p.h> -#include <private/qplatformcamerafocus_p.h> #include <private/qplatformcameraimagecapture_p.h> #include <private/qplatformcameraimageprocessing_p.h> #include <qcamera.h> @@ -46,7 +45,7 @@ #include "qmockintegration_p.h" #include "qmockmediacapturesession.h" -#include "qmockcamerafocus.h" +#include "qmockcamera.h" QT_USE_NAMESPACE @@ -878,11 +877,10 @@ void tst_QCamera::testMaxZoomChangedSignal() QCamera camera; session.setCamera(&camera); QMockCamera *mock = integration.lastCamera(); - QMockCameraFocus *mockFocus = mock->mockFocus; // ### change max zoom factor on backend, e.g. by changing camera QSignalSpy spy(&camera, SIGNAL(maximumZoomFactorChanged(float))); - mockFocus->setMaxZoomFactor(55); + mock->maximumZoomFactorChanged(55); QVERIFY(spy.count() == 1); QCOMPARE(camera.maximumZoomFactor(), 55); } diff --git a/tests/auto/unit/multimedia/qcameraimagecapture/tst_qcameraimagecapture.cpp b/tests/auto/unit/multimedia/qcameraimagecapture/tst_qcameraimagecapture.cpp index b4a05bbde..78c1d4c99 100644 --- a/tests/auto/unit/multimedia/qcameraimagecapture/tst_qcameraimagecapture.cpp +++ b/tests/auto/unit/multimedia/qcameraimagecapture/tst_qcameraimagecapture.cpp @@ -31,7 +31,6 @@ #include <private/qplatformcamera_p.h> #include <private/qplatformcameraexposure_p.h> -#include <private/qplatformcamerafocus_p.h> #include <private/qplatformcameraimagecapture_p.h> #include <private/qplatformcameraimageprocessing_p.h> #include <qcamera.h> diff --git a/tests/auto/unit/multimediawidgets/qcamerawidgets/tst_qcamerawidgets.cpp b/tests/auto/unit/multimediawidgets/qcamerawidgets/tst_qcamerawidgets.cpp index eb692f077..235294779 100644 --- a/tests/auto/unit/multimediawidgets/qcamerawidgets/tst_qcamerawidgets.cpp +++ b/tests/auto/unit/multimediawidgets/qcamerawidgets/tst_qcamerawidgets.cpp @@ -33,7 +33,6 @@ #include <private/qplatformcamera_p.h> #include <private/qplatformcameraexposure_p.h> -#include <private/qplatformcamerafocus_p.h> #include <private/qplatformcameraimagecapture_p.h> #include <private/qplatformcameraimageprocessing_p.h> #include <qmediacapturesession.h> |