| 1 | /**************************************************************************** | 
| 2 | ** | 
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | 
| 4 | ** Contact: https://www.qt.io/licensing/ | 
| 5 | ** | 
| 6 | ** This file is part of the test suite of the Qt Toolkit. | 
| 7 | ** | 
| 8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ | 
| 9 | ** Commercial License Usage | 
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | 
| 11 | ** accordance with the commercial license agreement provided with the | 
| 12 | ** Software or, alternatively, in accordance with the terms contained in | 
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | 
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | 
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | 
| 16 | ** | 
| 17 | ** GNU General Public License Usage | 
| 18 | ** Alternatively, this file may be used under the terms of the GNU | 
| 19 | ** General Public License version 3 as published by the Free Software | 
| 20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT | 
| 21 | ** included in the packaging of this file. Please review the following | 
| 22 | ** information to ensure the GNU General Public License requirements will | 
| 23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | 
| 24 | ** | 
| 25 | ** $QT_END_LICENSE$ | 
| 26 | ** | 
| 27 | ****************************************************************************/ | 
| 28 |  | 
| 29 | #ifndef MOCKCAMERAZOOMCONTROL_H | 
| 30 | #define MOCKCAMERAZOOMCONTROL_H | 
| 31 |  | 
| 32 | #include "qcamerazoomcontrol.h" | 
| 33 |  | 
| 34 | class MockCameraZoomControl : public QCameraZoomControl | 
| 35 | { | 
| 36 |     Q_OBJECT | 
| 37 | public: | 
| 38 |     MockCameraZoomControl(QObject *parent = 0): | 
| 39 |         QCameraZoomControl(parent), | 
| 40 |         m_opticalZoom(1.0), | 
| 41 |         m_digitalZoom(1.0), | 
| 42 |         m_maxOpticalZoom(3.0), | 
| 43 |         m_maxDigitalZoom(4.0) | 
| 44 |  | 
| 45 |     { | 
| 46 |     } | 
| 47 |  | 
| 48 |     ~MockCameraZoomControl() {} | 
| 49 |  | 
| 50 |     qreal maximumOpticalZoom() const | 
| 51 |     { | 
| 52 |         return m_maxOpticalZoom; | 
| 53 |     } | 
| 54 |  | 
| 55 |     qreal maximumDigitalZoom() const | 
| 56 |     { | 
| 57 |         return m_maxDigitalZoom; | 
| 58 |     } | 
| 59 |  | 
| 60 |     qreal currentOpticalZoom() const | 
| 61 |     { | 
| 62 |         return m_opticalZoom; | 
| 63 |     } | 
| 64 |  | 
| 65 |     qreal currentDigitalZoom() const | 
| 66 |     { | 
| 67 |         return m_digitalZoom; | 
| 68 |     } | 
| 69 |  | 
| 70 |     qreal requestedOpticalZoom() const | 
| 71 |     { | 
| 72 |         return m_opticalZoom; | 
| 73 |     } | 
| 74 |  | 
| 75 |     qreal requestedDigitalZoom() const | 
| 76 |     { | 
| 77 |         return m_digitalZoom; | 
| 78 |     } | 
| 79 |  | 
| 80 |     void zoomTo(qreal optical, qreal digital) | 
| 81 |     { | 
| 82 |         optical = qBound<qreal>(min: 1.0, val: optical, max: maximumOpticalZoom()); | 
| 83 |         digital = qBound<qreal>(min: 1.0, val: digital, max: maximumDigitalZoom()); | 
| 84 |  | 
| 85 |         if (!qFuzzyCompare(p1: digital, p2: m_digitalZoom)) { | 
| 86 |             m_digitalZoom = digital; | 
| 87 |             emit requestedDigitalZoomChanged(digitalZoom: m_digitalZoom); | 
| 88 |             emit currentDigitalZoomChanged(digitalZoom: m_digitalZoom); | 
| 89 |         } | 
| 90 |  | 
| 91 |         if (!qFuzzyCompare(p1: optical, p2: m_opticalZoom)) { | 
| 92 |             m_opticalZoom = optical; | 
| 93 |             emit requestedOpticalZoomChanged(opticalZoom: m_opticalZoom); | 
| 94 |             emit currentOpticalZoomChanged(opticalZoom: m_opticalZoom); | 
| 95 |         } | 
| 96 |  | 
| 97 |         maxOpticalDigitalZoomChange(maxOptical: 4.0, maxDigital: 5.0); | 
| 98 |     } | 
| 99 |  | 
| 100 |     // helper function to emit maximum Optical and Digital Zoom Changed signals | 
| 101 |     void maxOpticalDigitalZoomChange(qreal maxOptical, qreal maxDigital) | 
| 102 |     { | 
| 103 |         if (maxOptical != m_maxOpticalZoom) { | 
| 104 |             m_maxOpticalZoom = maxOptical; | 
| 105 |             emit maximumOpticalZoomChanged(m_maxOpticalZoom); | 
| 106 |         } | 
| 107 |  | 
| 108 |         if (maxDigital != m_maxDigitalZoom) { | 
| 109 |             m_maxDigitalZoom = maxDigital; | 
| 110 |             emit maximumDigitalZoomChanged(m_maxDigitalZoom); | 
| 111 |         } | 
| 112 |     } | 
| 113 |  | 
| 114 | private: | 
| 115 |     qreal m_opticalZoom; | 
| 116 |     qreal m_digitalZoom; | 
| 117 |     qreal m_maxOpticalZoom; | 
| 118 |     qreal m_maxDigitalZoom; | 
| 119 | }; | 
| 120 |  | 
| 121 | #endif // MOCKCAMERAZOOMCONTROL_H | 
| 122 |  |