summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@theqtcompany.com>2015-08-13 18:18:44 +0200
committerYoann Lopes <yoann.lopes@theqtcompany.com>2015-08-25 11:18:51 +0000
commit4eb4a3ada360af152b9403e8a88eb76b9474c4ba (patch)
tree4a3671e14c782f6f5b45e27460835fa943085b9b /tests/auto
parentded4d7b006180d12f4f2e7642877ffc6586a5331 (diff)
Fix QML Camera::supportedViewfinderFrameRateRanges().
Pass the resolution argument as a QJSValue instead of a QSize. This allows to be more flexible and doesn't require the QML argument to be an actual QML 'size' value. It can be any object with the 'width' and 'height' properties. Added missing auto-tests for supportedViewfinderResolutions() and supportedViewfinderFrameRateRanges(). Change-Id: I6c8ae72e6dab8c9d12bbada5b8e7f45e96e9289d Task-number: QTBUG-47630 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/unit/qdeclarativecamera/tst_qdeclarativecamera.qml154
1 files changed, 154 insertions, 0 deletions
diff --git a/tests/auto/unit/qdeclarativecamera/tst_qdeclarativecamera.qml b/tests/auto/unit/qdeclarativecamera/tst_qdeclarativecamera.qml
index 833ca522b..02e32f4c9 100644
--- a/tests/auto/unit/qdeclarativecamera/tst_qdeclarativecamera.qml
+++ b/tests/auto/unit/qdeclarativecamera/tst_qdeclarativecamera.qml
@@ -144,4 +144,158 @@ TestCase {
cameraLoader.sourceComponent = undefined;
}
+
+ function test_supportedViewfinderResolutions_data() {
+ // see mockcameraviewfindersettingscontrol.h for expected values
+
+ return [
+ {
+ tag: "all",
+ minimumFrameRate: 0, maximumFrameRate: 0,
+ expectedResolutions: [
+ { width: 320, height: 240 },
+ { width: 640, height: 480 },
+ { width: 1280, height: 720 },
+ { width: 1920, height: 1080 }
+ ]
+ },
+ {
+ tag: "invalid minimumFrameRate",
+ minimumFrameRate: 2, maximumFrameRate: 0,
+ expectedResolutions: [ ]
+ },
+ {
+ tag: "minimumFrameRate=5",
+ minimumFrameRate: 5, maximumFrameRate: 0,
+ expectedResolutions: [
+ { width: 1920, height: 1080 }
+ ]
+ },
+ {
+ tag: "minimumFrameRate=10",
+ minimumFrameRate: 10, maximumFrameRate: 0,
+ expectedResolutions: [
+ { width: 1280, height: 720 }
+ ]
+ },
+ {
+ tag: "minimumFrameRate=30",
+ minimumFrameRate: 30, maximumFrameRate: 0,
+ expectedResolutions: [
+ { width: 320, height: 240 },
+ { width: 640, height: 480 },
+ { width: 1280, height: 720 }
+ ]
+ },
+ {
+ tag: "invalid maximumFrameRate",
+ minimumFrameRate: 0, maximumFrameRate: 2,
+ expectedResolutions: [ ]
+ },
+ {
+ tag: "maximumFrameRate=10",
+ minimumFrameRate: 0, maximumFrameRate: 10,
+ expectedResolutions: [
+ { width: 1280, height: 720 },
+ { width: 1920, height: 1080 }
+ ]
+ },
+ {
+ tag: "minimumFrameRate=10, maximumFrameRate=10",
+ minimumFrameRate: 10, maximumFrameRate: 10,
+ expectedResolutions: [
+ { width: 1280, height: 720 }
+ ]
+ },
+ {
+ tag: "minimumFrameRate=30, maximumFrameRate=30",
+ minimumFrameRate: 30, maximumFrameRate: 30,
+ expectedResolutions: [
+ { width: 320, height: 240 },
+ { width: 640, height: 480 },
+ { width: 1280, height: 720 }
+ ]
+ }
+ ]
+ }
+
+ function test_supportedViewfinderResolutions(data) {
+ cameraLoader.sourceComponent = cameraComponent;
+ var camera = cameraLoader.item;
+
+ var actualResolutions = camera.supportedViewfinderResolutions(data.minimumFrameRate, data.maximumFrameRate);
+ compare(actualResolutions.length, data.expectedResolutions.length);
+ for (var i = 0; i < actualResolutions.length; ++i) {
+ compare(actualResolutions[i].width, data.expectedResolutions[i].width);
+ compare(actualResolutions[i].height, data.expectedResolutions[i].height);
+ }
+
+ cameraLoader.sourceComponent = undefined;
+ }
+
+ function test_supportedViewfinderFrameRateRanges_data() {
+ // see mockcameraviewfindersettingscontrol.h for expected values
+ return [
+ {
+ tag: "all",
+ expectedFrameRateRanges: [
+ { minimumFrameRate: 5, maximumFrameRate: 10 },
+ { minimumFrameRate: 10, maximumFrameRate: 10 },
+ { minimumFrameRate: 30, maximumFrameRate: 30 }
+ ]
+ },
+ {
+ tag: "invalid",
+ resolution: { width: 452472, height: 444534 },
+ expectedFrameRateRanges: [ ]
+ },
+ {
+ tag: "320, 240",
+ resolution: { width: 320, height: 240 },
+ expectedFrameRateRanges: [
+ { minimumFrameRate: 30, maximumFrameRate: 30 }
+ ]
+ },
+ {
+ tag: "1280, 720",
+ resolution: { width: 1280, height: 720 },
+ expectedFrameRateRanges: [
+ { minimumFrameRate: 10, maximumFrameRate: 10 },
+ { minimumFrameRate: 30, maximumFrameRate: 30 }
+ ]
+ },
+ {
+ tag: "1920, 1080",
+ resolution: { width: 1920, height: 1080 },
+ expectedFrameRateRanges: [
+ { minimumFrameRate: 5, maximumFrameRate: 10 }
+ ]
+ }
+ ]
+ }
+
+ function test_supportedViewfinderFrameRateRanges(data) {
+ cameraLoader.sourceComponent = cameraComponent;
+ var camera = cameraLoader.item;
+
+ // Pass the resolution as an object
+ var actualFrameRateRanges = camera.supportedViewfinderFrameRateRanges(data.resolution);
+ compare(actualFrameRateRanges.length, data.expectedFrameRateRanges.length);
+ for (var i = 0; i < actualFrameRateRanges.length; ++i) {
+ compare(actualFrameRateRanges[i].minimumFrameRate, data.expectedFrameRateRanges[i].minimumFrameRate);
+ compare(actualFrameRateRanges[i].maximumFrameRate, data.expectedFrameRateRanges[i].maximumFrameRate);
+ }
+
+ // Pass the resolution as a size
+ if (typeof data.resolution !== 'undefined') {
+ actualFrameRateRanges = camera.supportedViewfinderFrameRateRanges(Qt.size(data.resolution.width, data.resolution.height));
+ compare(actualFrameRateRanges.length, data.expectedFrameRateRanges.length);
+ for (i = 0; i < actualFrameRateRanges.length; ++i) {
+ compare(actualFrameRateRanges[i].minimumFrameRate, data.expectedFrameRateRanges[i].minimumFrameRate);
+ compare(actualFrameRateRanges[i].maximumFrameRate, data.expectedFrameRateRanges[i].maximumFrameRate);
+ }
+ }
+
+ cameraLoader.sourceComponent = undefined;
+ }
}