diff options
author | Paolo Angelelli <paolo.angelelli@qt.io> | 2019-04-26 21:46:45 +0200 |
---|---|---|
committer | paolo <paolo.angelelli@qt.io> | 2019-07-24 16:25:29 +0200 |
commit | 17e3f08377c34d301401fbd3c40b525790fcd9a5 (patch) | |
tree | 6830eb8d19d237fc06b05cc96a7e4d113b864329 /tests/auto/declarative_core/tst_positionsource.qml | |
parent | f13a93cf4c6f874e9d737e83182e0ab6aadb7de0 (diff) |
Add tests for PluginParameters in PositionSource
Testing parameters in QGeoPositionInfoSourceFactory becomes implicit
with this test.
Task-number: QTBUG-66304
Change-Id: I3e9fbf99762e9a03e4c8cae3ff317ea36313e687
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'tests/auto/declarative_core/tst_positionsource.qml')
-rw-r--r-- | tests/auto/declarative_core/tst_positionsource.qml | 131 |
1 files changed, 96 insertions, 35 deletions
diff --git a/tests/auto/declarative_core/tst_positionsource.qml b/tests/auto/declarative_core/tst_positionsource.qml index a663f3ab..9b78936b 100644 --- a/tests/auto/declarative_core/tst_positionsource.qml +++ b/tests/auto/declarative_core/tst_positionsource.qml @@ -28,7 +28,7 @@ import QtQuick 2.0 import QtTest 1.0 -import QtPositioning 5.2 +import QtPositioning 5.14 TestCase { id: testCase @@ -106,6 +106,26 @@ TestCase { SignalSpy { id: directionValidSpy; target: testingSource.position; signalName: "directionValidChanged" } SignalSpy { id: directionSpy; target: testingSource.position; signalName: "directionChanged" } + PositionSource { + id: testingSourceWParams + name: "test.source" + updateInterval: 1000 + PluginParameter { + id: altitudeParameter + name: "test.source.altitude" + value: 42.42 + } + } + + SignalSpy { id: updateSpyWParams; target: testingSourceWParams; signalName: "positionChanged" } + SignalSpy { id: directionValidSpyWParams; target: testingSourceWParams.position; signalName: "directionValidChanged" } + SignalSpy { id: directionSpyWParams; target: testingSourceWParams.position; signalName: "directionChanged" } + + PositionSource { id: testingSourceV1; name: "test.source.v1"; updateInterval: 1000 } + SignalSpy { id: updateSpyV1; target: testingSourceV1; signalName: "positionChanged" } + SignalSpy { id: directionValidSpyV1; target: testingSourceV1.position; signalName: "directionValidChanged" } + SignalSpy { id: directionSpyV1; target: testingSourceV1.position; signalName: "directionChanged" } + function test_updateInterval() { testingSource.updateInterval = 1000; compare(testingSource.updateInterval, 1000); @@ -125,40 +145,81 @@ TestCase { } function test_updates() { - updateSpy.clear(); - - compare(directionValidSpy.count, 0) - compare(directionSpy.count, 0) - - testingSource.active = true; - - tryCompare(updateSpy, "count", 1, 1500); - compare(testingSource.position.coordinate.longitude, 0.1); - compare(testingSource.position.coordinate.latitude, 0.1); - compare(directionValidSpy.count, 1) - compare(directionSpy.count, 1) - fuzzyCompare(testingSource.position.direction, 45, 0.1) - verify(!testingSource.position.speedValid) - verify(isNaN(testingSource.position.speed)) - - tryCompare(updateSpy, "count", 2, 1500); - compare(testingSource.position.coordinate.longitude, 0.2); - compare(testingSource.position.coordinate.latitude, 0.2); - compare(directionValidSpy.count, 1) - compare(directionSpy.count, 2) - fuzzyCompare(testingSource.position.direction, 45, 0.1) - verify(testingSource.position.speedValid) - verify(testingSource.position.speed > 10000) - - testingSource.active = false; + updateSpyV1.clear(); + + compare(directionValidSpyV1.count, 0) + compare(directionSpyV1.count, 0) + + testingSourceV1.active = true; + + tryCompare(updateSpyV1, "count", 1, 1500); + compare(testingSourceV1.position.coordinate.longitude, 0.1); + compare(testingSourceV1.position.coordinate.latitude, 0.1); + compare(directionValidSpyV1.count, 1) + compare(directionSpyV1.count, 1) + fuzzyCompare(testingSourceV1.position.direction, 45, 0.1) + verify(!testingSourceV1.position.speedValid) + verify(isNaN(testingSourceV1.position.speed)) + + tryCompare(updateSpyV1, "count", 2, 1500); + compare(testingSourceV1.position.coordinate.longitude, 0.2); + compare(testingSourceV1.position.coordinate.latitude, 0.2); + compare(directionValidSpyV1.count, 1) + compare(directionSpyV1.count, 2) + fuzzyCompare(testingSourceV1.position.direction, 45, 0.1) + verify(testingSourceV1.position.speedValid) + verify(testingSourceV1.position.speed > 10000) + + testingSourceV1.active = false; + wait(2500); + compare(updateSpyV1.count, 2); + compare(testingSourceV1.position.coordinate.longitude, 0.2); + compare(testingSourceV1.position.coordinate.latitude, 0.2); + compare(directionValidSpyV1.count, 1) + compare(directionSpyV1.count, 2) + fuzzyCompare(testingSourceV1.position.direction, 45, 0.1) + verify(testingSourceV1.position.speedValid) + verify(testingSourceV1.position.speed > 10000) + } + + function test_updates_w_params() { + updateSpyWParams.clear(); + + compare(directionValidSpyWParams.count, 0) + compare(directionSpyWParams.count, 0) + + testingSourceWParams.active = true; + + tryCompare(updateSpyWParams, "count", 1, 1500); + compare(testingSourceWParams.position.coordinate.longitude, 0.1); + compare(testingSourceWParams.position.coordinate.latitude, 0.1); + compare(testingSourceWParams.position.coordinate.altitude, altitudeParameter.value); + compare(directionValidSpyWParams.count, 1) + compare(directionSpyWParams.count, 1) + fuzzyCompare(testingSourceWParams.position.direction, 45, 0.1) + verify(!testingSourceWParams.position.speedValid) + verify(isNaN(testingSourceWParams.position.speed)) + + tryCompare(updateSpyWParams, "count", 2, 1500); + compare(testingSourceWParams.position.coordinate.longitude, 0.2); + compare(testingSourceWParams.position.coordinate.latitude, 0.2); + compare(testingSourceWParams.position.coordinate.altitude, altitudeParameter.value); + compare(directionValidSpyWParams.count, 1) + compare(directionSpyWParams.count, 2) + fuzzyCompare(testingSourceWParams.position.direction, 45, 0.1) + verify(testingSourceWParams.position.speedValid) + verify(testingSourceWParams.position.speed > 10000) + + testingSourceWParams.active = false; wait(2500); - compare(updateSpy.count, 2); - compare(testingSource.position.coordinate.longitude, 0.2); - compare(testingSource.position.coordinate.latitude, 0.2); - compare(directionValidSpy.count, 1) - compare(directionSpy.count, 2) - fuzzyCompare(testingSource.position.direction, 45, 0.1) - verify(testingSource.position.speedValid) - verify(testingSource.position.speed > 10000) + compare(updateSpyWParams.count, 2); + compare(testingSourceWParams.position.coordinate.longitude, 0.2); + compare(testingSourceWParams.position.coordinate.latitude, 0.2); + compare(testingSourceWParams.position.coordinate.altitude, altitudeParameter.value); + compare(directionValidSpyWParams.count, 1) + compare(directionSpyWParams.count, 2) + fuzzyCompare(testingSourceWParams.position.direction, 45, 0.1) + verify(testingSourceWParams.position.speedValid) + verify(testingSourceWParams.position.speed > 10000) } } |