diff options
author | Michael Goddard <michael.goddard@nokia.com> | 2011-11-04 13:38:44 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-11-04 08:19:17 +0100 |
commit | e3a8c165eabe139d71a762089ab396e5b492c70b (patch) | |
tree | 16d9960d2d20d65e0a5d1becc181c0a7b095d0aa /tests/auto/unit/qmultimedia_common/mockcameraexposurecontrol.h | |
parent | 7dfb883df639f8d80cec7bd2c51eb37561bc4522 (diff) | |
download | qtmultimedia-e3a8c165eabe139d71a762089ab396e5b492c70b.tar.gz |
Rearrange the automatic tests.
Split them into unit and integration tests. Integration tests really
need to be run on the real platform (not in a VM etc) since they are
somewhat unstable or nonfunctional otherwise.
A few tests were previously broken by QUrl changes and they were repaired.
Removed one test since it was not providing a lot of value.
There are still a number of tests that rely on Q_AUTOTEST_EXPORT symbols.
Change-Id: Ic402abf0af946baa5945075d975b3f584f9ef280
Reviewed-by: Kalle Lehtonen <kalle.ju.lehtonen@nokia.com>
Diffstat (limited to 'tests/auto/unit/qmultimedia_common/mockcameraexposurecontrol.h')
-rw-r--r-- | tests/auto/unit/qmultimedia_common/mockcameraexposurecontrol.h | 282 |
1 files changed, 282 insertions, 0 deletions
diff --git a/tests/auto/unit/qmultimedia_common/mockcameraexposurecontrol.h b/tests/auto/unit/qmultimedia_common/mockcameraexposurecontrol.h new file mode 100644 index 000000000..d89762d43 --- /dev/null +++ b/tests/auto/unit/qmultimedia_common/mockcameraexposurecontrol.h @@ -0,0 +1,282 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MOCKCAMERAEXPOSURECONTROL_H +#define MOCKCAMERAEXPOSURECONTROL_H + +#include "qcameraexposurecontrol.h" + +class MockCameraExposureControl : public QCameraExposureControl +{ + Q_OBJECT +public: + MockCameraExposureControl(QObject *parent = 0): + QCameraExposureControl(parent), + m_aperture(2.8), + m_shutterSpeed(0.01), + m_isoSensitivity(100), + m_meteringMode(QCameraExposure::MeteringMatrix), + m_exposureCompensation(0), + m_exposureMode(QCameraExposure::ExposureAuto), + m_flashMode(QCameraExposure::FlashAuto) + { + m_isoRanges << 100 << 200 << 400 << 800; + m_apertureRanges << 2.8 << 4.0 << 5.6 << 8.0 << 11.0 << 16.0; + m_shutterRanges << 0.001 << 0.01 << 0.1 << 1.0; + m_exposureRanges << -2.0 << 2.0; + } + + ~MockCameraExposureControl() {} + + QCameraExposure::FlashModes flashMode() const {return m_flashMode;} + + void setFlashMode(QCameraExposure::FlashModes mode) + { + if (isFlashModeSupported(mode)) { + m_flashMode = mode; + } + } + + bool isFlashModeSupported(QCameraExposure::FlashModes mode) const + { + return mode & (QCameraExposure::FlashAuto | QCameraExposure::FlashOff | QCameraExposure::FlashOn); + } + + bool isFlashReady() const { return true;} + + QCameraExposure::ExposureMode exposureMode() const { return m_exposureMode; } + + void setExposureMode(QCameraExposure::ExposureMode mode) + { + if (isExposureModeSupported(mode)) + m_exposureMode = mode; + } + + //Setting the Exposure Mode Supported Enum values + bool isExposureModeSupported(QCameraExposure::ExposureMode mode) const + { + return ( mode == QCameraExposure::ExposureAuto || mode == QCameraExposure::ExposureManual || mode == QCameraExposure::ExposureBacklight || + mode == QCameraExposure::ExposureNight || mode == QCameraExposure::ExposureSpotlight ||mode == QCameraExposure::ExposureSports || + mode == QCameraExposure::ExposureSnow || mode == QCameraExposure:: ExposureLargeAperture ||mode == QCameraExposure::ExposureSmallAperture || + mode == QCameraExposure::ExposurePortrait || mode == QCameraExposure::ExposureModeVendor ||mode == QCameraExposure::ExposureBeach ); + } + + bool isParameterSupported(ExposureParameter parameter) const + { + switch (parameter) { + case QCameraExposureControl::ExposureCompensation: + case QCameraExposureControl::ISO: + case QCameraExposureControl::Aperture: + case QCameraExposureControl::ShutterSpeed: + return true; + default: + return false; + } + } + + QVariant exposureParameter(ExposureParameter parameter) const + { + switch (parameter) { + case QCameraExposureControl::ExposureCompensation: + return QVariant(m_exposureCompensation); + case QCameraExposureControl::ISO: + return QVariant(m_isoSensitivity); + case QCameraExposureControl::Aperture: + return QVariant(m_aperture); + case QCameraExposureControl::ShutterSpeed: + return QVariant(m_shutterSpeed); + default: + return QVariant(); + } + } + + QVariantList supportedParameterRange(ExposureParameter parameter) const + { + QVariantList res; + switch (parameter) { + case QCameraExposureControl::ExposureCompensation: + return m_exposureRanges; + case QCameraExposureControl::ISO: + return m_isoRanges; + case QCameraExposureControl::Aperture: + return m_apertureRanges; + case QCameraExposureControl::ShutterSpeed: + return m_shutterRanges; + default: + break; + } + + return res; + } + + ParameterFlags exposureParameterFlags(ExposureParameter parameter) const + { + ParameterFlags res = 0; + switch (parameter) { + case QCameraExposureControl::ExposureCompensation: + case QCameraExposureControl::Aperture: + case QCameraExposureControl::ShutterSpeed: + res |= ContinuousRange; + default: + break; + } + + return res; + } + + // Added exposureParameterChanged and exposureParameterRangeChanged signal + bool setExposureParameter(ExposureParameter parameter, const QVariant& value) + { + switch (parameter) { + case QCameraExposureControl::ExposureCompensation: + { + m_res.clear(); + m_res << -4.0 << 4.0; + qreal exposureCompensationlocal = qBound<qreal>(-2.0, value.toReal(), 2.0); + if (exposureParameter(parameter).toReal() != exposureCompensationlocal) { + m_exposureCompensation = exposureCompensationlocal; + emit exposureParameterChanged(parameter); + } + + if (m_exposureRanges.last().toReal() != m_res.last().toReal()) { + m_exposureRanges.clear(); + m_exposureRanges = m_res; + emit exposureParameterRangeChanged(parameter); + } + } + break; + case QCameraExposureControl::ISO: + { + m_res.clear(); + m_res << 20 << 50; + qreal exposureCompensationlocal = 100*qRound(qBound(100, value.toInt(), 800)/100.0); + if (exposureParameter(parameter).toReal() != exposureCompensationlocal) { + m_isoSensitivity = exposureCompensationlocal; + emit exposureParameterChanged(parameter); + } + + if (m_isoRanges.last().toInt() != m_res.last().toInt()) { + m_isoRanges.clear(); + m_isoRanges = m_res; + emit exposureParameterRangeChanged(parameter); + } + } + break; + case QCameraExposureControl::Aperture: + { + m_res.clear(); + m_res << 12.0 << 18.0 << 20.0; + qreal exposureCompensationlocal = qBound<qreal>(2.8, value.toReal(), 16.0); + if (exposureParameter(parameter).toReal() != exposureCompensationlocal) { + m_aperture = exposureCompensationlocal; + emit exposureParameterChanged(parameter); + } + + if (m_apertureRanges.last().toReal() != m_res.last().toReal()) { + m_apertureRanges.clear(); + m_apertureRanges = m_res; + emit exposureParameterRangeChanged(parameter); + } + } + break; + case QCameraExposureControl::ShutterSpeed: + { + m_res.clear(); + m_res << 0.12 << 1.0 << 2.0; + qreal exposureCompensationlocal = qBound<qreal>(0.001, value.toReal(), 1.0); + if (exposureParameter(parameter).toReal() != exposureCompensationlocal) { + m_shutterSpeed = exposureCompensationlocal; + emit exposureParameterChanged(parameter); + } + + if (m_shutterRanges.last().toReal() != m_res.last().toReal()) { + m_shutterRanges.clear(); + m_shutterRanges = m_res; + emit exposureParameterRangeChanged(parameter); + } + } + break; + default: + return false; + } + + emit flashReady(true); // depends on Flashcontrol + + return true; + } + + QString extendedParameterName(ExposureParameter) + { + return QString(); + } + + QCameraExposure::MeteringMode meteringMode() const + { + return m_meteringMode; + } + + void setMeteringMode(QCameraExposure::MeteringMode mode) + { + if (isMeteringModeSupported(mode)) + m_meteringMode = mode; + } + + //Setting the values for metering mode + bool isMeteringModeSupported(QCameraExposure::MeteringMode mode) const + { + return mode == QCameraExposure::MeteringAverage + || mode == QCameraExposure::MeteringMatrix + || mode == QCameraExposure::MeteringAverage + || mode ==QCameraExposure::MeteringSpot; + } + +private: + qreal m_aperture; + qreal m_shutterSpeed; + int m_isoSensitivity; + QCameraExposure::MeteringMode m_meteringMode; + qreal m_exposureCompensation; + QCameraExposure::ExposureMode m_exposureMode; + QCameraExposure::FlashModes m_flashMode; + QVariantList m_isoRanges,m_apertureRanges, m_shutterRanges, m_exposureRanges, m_res; +}; + +#endif // MOCKCAMERAEXPOSURECONTROL_H |