| 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 MOCKIMAGEENCODERCONTROL_H | 
| 30 | #define MOCKIMAGEENCODERCONTROL_H | 
| 31 |  | 
| 32 | #include "qimageencodercontrol.h" | 
| 33 |  | 
| 34 | class MockImageEncoderControl : public QImageEncoderControl | 
| 35 | { | 
| 36 | public: | 
| 37 |     MockImageEncoderControl(QObject *parent = 0) | 
| 38 |         : QImageEncoderControl(parent) | 
| 39 |     { | 
| 40 |         m_settings = QImageEncoderSettings(); | 
| 41 |     } | 
| 42 |  | 
| 43 |     QList<QSize> supportedResolutions(const QImageEncoderSettings & settings = QImageEncoderSettings(), | 
| 44 |                                       bool *continuous = 0) const | 
| 45 |     { | 
| 46 |         if (continuous) | 
| 47 |             *continuous = true; | 
| 48 |  | 
| 49 |         QList<QSize> resolutions; | 
| 50 |         if (settings.resolution().isValid()) { | 
| 51 |             if (settings.resolution() == QSize(160,160) || | 
| 52 |                 settings.resolution() == QSize(320,240)) | 
| 53 |                 resolutions << settings.resolution(); | 
| 54 |  | 
| 55 |             if (settings.quality() == QMultimedia::HighQuality && settings.resolution() == QSize(640,480)) | 
| 56 |                 resolutions << settings.resolution(); | 
| 57 |         } else { | 
| 58 |             resolutions << QSize(160, 120); | 
| 59 |             resolutions << QSize(320, 240); | 
| 60 |             if (settings.quality() == QMultimedia::HighQuality) | 
| 61 |                 resolutions << QSize(640, 480); | 
| 62 |         } | 
| 63 |  | 
| 64 |         return resolutions; | 
| 65 |     } | 
| 66 |  | 
| 67 |     QStringList supportedImageCodecs() const | 
| 68 |     { | 
| 69 |         QStringList codecs; | 
| 70 |         codecs << "PNG"  << "JPEG" ; | 
| 71 |         return codecs; | 
| 72 |     } | 
| 73 |  | 
| 74 |     QString imageCodecDescription(const QString &codecName) const { | 
| 75 |         if (codecName == "PNG" ) | 
| 76 |             return QString("Portable Network Graphic" ); | 
| 77 |         if (codecName == "JPEG" ) | 
| 78 |             return QString("Joint Photographic Expert Group" ); | 
| 79 |         return QString(); | 
| 80 |     } | 
| 81 |  | 
| 82 |     QImageEncoderSettings imageSettings() const { return m_settings; } | 
| 83 |     void setImageSettings(const QImageEncoderSettings &settings) { m_settings = settings; } | 
| 84 |  | 
| 85 | private: | 
| 86 |     QImageEncoderSettings m_settings; | 
| 87 | }; | 
| 88 |  | 
| 89 |  | 
| 90 | #endif // MOCKIMAGEENCODERCONTROL_H | 
| 91 |  |