summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@theqtcompany.com>2016-05-27 08:57:53 +0200
committerAlex Blasche <alexander.blasche@theqtcompany.com>2016-05-27 09:26:43 +0200
commit2fb16a044cea839dd2616e6cae45e434906f0379 (patch)
tree3d6a0eb35b361d1540fb1de21dd56e4a1d938875 /tests
parent4a5e6d6e8b816ac2dd8c673feb56a0af096a4a18 (diff)
parentf897775850dfbe0e668e9c8b428537e8bb096c01 (diff)
downloadqtlocation-2fb16a044cea839dd2616e6cae45e434906f0379.tar.gz
Merge remote-tracking branch 'gerrit/5.6' into 5.7
Change-Id: I066dc4f161f4bdfe182ba9fe00d273e5fbcedf5d
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative_ui/tst_map_flick.qml1
-rw-r--r--tests/auto/declarative_ui/tst_map_item.qml176
-rw-r--r--tests/auto/declarative_ui/tst_map_item_details.qml88
-rw-r--r--tests/auto/declarative_ui/tst_map_item_fit_viewport.qml2
-rw-r--r--tests/plugins/declarativetestplugin/declarativetestplugin.pro16
-rw-r--r--tests/plugins/declarativetestplugin/locationtest.cpp10
-rw-r--r--tests/plugins/declarativetestplugin/qdeclarativelocationtestmodel.cpp4
-rw-r--r--tests/plugins/declarativetestplugin/qdeclarativelocationtestmodel_p.h4
-rw-r--r--tests/plugins/declarativetestplugin/qdeclarativepinchgenerator.cpp4
-rw-r--r--tests/plugins/declarativetestplugin/qdeclarativepinchgenerator_p.h4
-rw-r--r--tests/plugins/declarativetestplugin/testhelper.h58
11 files changed, 215 insertions, 152 deletions
diff --git a/tests/auto/declarative_ui/tst_map_flick.qml b/tests/auto/declarative_ui/tst_map_flick.qml
index 304ca4f2..15f13b5f 100644
--- a/tests/auto/declarative_ui/tst_map_flick.qml
+++ b/tests/auto/declarative_ui/tst_map_flick.qml
@@ -283,7 +283,6 @@ Item {
{
map.center.latitude = 50
map.center.longitude = 50
- waitForRendering(map)
mousePress(page, 0, 0)
for (var i = 0; i < 50; i += 5) {
wait(20)
diff --git a/tests/auto/declarative_ui/tst_map_item.qml b/tests/auto/declarative_ui/tst_map_item.qml
index 2f6fedc3..8ede357f 100644
--- a/tests/auto/declarative_ui/tst_map_item.qml
+++ b/tests/auto/declarative_ui/tst_map_item.qml
@@ -30,6 +30,7 @@ import QtQuick 2.0
import QtTest 1.0
import QtLocation 5.6
import QtPositioning 5.5
+import QtLocation.Test 5.6
/*
@@ -62,7 +63,6 @@ Item {
height: 240
Plugin { id: testPlugin; name : "qmlgeo.test.plugin"; allowExperimental: true }
- property variant mapDefaultCenter: QtPositioning.coordinate(20, 20)
property variant someCoordinate1: QtPositioning.coordinate(15, 15)
property variant someCoordinate2: QtPositioning.coordinate(16, 16)
@@ -110,21 +110,10 @@ Item {
id: map;
x: 20; y: 20; width: 200; height: 200
zoomLevel: 9
- center: mapDefaultCenter
plugin: testPlugin;
MapRectangle {
id: preMapRect
- color: 'darkcyan'
- border.width: 0
- topLeft {
- latitude: 20
- longitude: 20
- }
- bottomRight {
- latitude: 10
- longitude: 30
- }
MouseArea {
id: preMapRectMa
anchors.fill: parent
@@ -139,13 +128,6 @@ Item {
}
MapCircle {
id: preMapCircle
- color: 'darkmagenta'
- border.width: 0
- center {
- latitude: 10
- longitude: 30
- }
- radius: 10000
MouseArea {
id: preMapCircleMa
anchors.fill: parent
@@ -170,11 +152,8 @@ Item {
SignalSpy { id: preMapQuickItemClicked; target: parent; signalName: "clicked" }
SignalSpy { id: preMapQuickItemActiveChanged; target: parent.drag; signalName: "activeChanged" }
}
- coordinate {
- latitude: 35
- longitude: 3
- }
sourceItem: Rectangle {
+ id: preMapQuickItemSource
color: 'darkgreen'
width: 20
height: 20
@@ -235,21 +214,69 @@ Item {
name: "MapItems"
when: windowShown
- function test_aa_items_on_map() { // aa et al. for execution order
- wait(10)
+ function initTestCase()
+ {
// sanity check that the coordinate conversion works, as
// rest of the case relies on it. for robustness cut
// a little slack with fuzzy compare
var mapcenter = map.fromCoordinate(map.center)
verify (fuzzy_compare(mapcenter.x, 100, 2))
verify (fuzzy_compare(mapcenter.y, 100, 2))
+ }
- // precondition
- compare(preMapRectClicked.count, 0)
- compare(preMapCircleClicked.count, 0)
+ function init()
+ {
+ map.center = QtPositioning.coordinate(20, 20)
+ preMapCircle.center = QtPositioning.coordinate(10,30)
+ preMapCircle.border.width = 0
+ preMapCircle.color = 'red'
+ preMapCircle.radius = 10000
+ preMapCircleClicked.clear()
+ preMapCircleCenterChanged.clear()
+ preMapCircleColorChanged.clear()
+ preMapCircleRadiusChanged.clear()
+ preMapCircleBorderColorChanged.clear()
+ preMapCircleBorderWidthChanged.clear()
+
+ preMapRect.color = 'red'
+ preMapRect.border.width = 0
+ preMapRect.topLeft = QtPositioning.coordinate(20, 20)
+ preMapRect.bottomRight = QtPositioning.coordinate(10, 30)
+ preMapRectTopLeftChanged.clear()
+ preMapRectBottomRightChanged.clear()
+ preMapRectColorChanged.clear()
+ preMapRectClicked.clear()
+ preMapRectActiveChanged.clear()
+
+ preMapQuickItem.sourceItem = preMapQuickItemSource
+ preMapQuickItem.zoomLevel = 0
+ preMapQuickItem.coordinate = QtPositioning.coordinate(35, 3)
+ preMapQuickItemClicked.clear()
+ preMapQuickItem.anchorPoint = Qt.point(0,0)
+ preMapQuickItemCoordinateChanged.clear()
+ preMapQuickItemAnchorPointChanged.clear()
+ preMapQuickItemZoomLevelChanged.clear()
+ preMapQuickItemSourceItemChanged.clear()
+
+ preMapPolygonClicked.clear()
+ preMapPolylineColorChanged.clear()
+ preMapPolylineWidthChanged.clear()
+ preMapPolylinePathChanged.clear()
+ preMapPolygonPathChanged.clear()
+ preMapPolygonColorChanged.clear()
+ preMapPolygonBorderColorChanged.clear()
+ preMapPolygonBorderWidthChanged.clear()
+ preMapRouteRouteChanged.clear()
+ preMapRouteLineColorChanged.clear()
+ preMapRouteLineWidthChanged.clear()
+ verify(LocationTestHelper.waitForPolished(map))
+ }
+ function test_items_on_map()
+ {
// click rect
map.center = preMapRect.topLeft
+ verify(LocationTestHelper.waitForPolished(map))
var point = map.fromCoordinate(preMapRect.topLeft)
mouseClick(map, point.x + 5, point.y + 5)
tryCompare(preMapRectClicked, "count", 1)
@@ -259,11 +286,11 @@ Item {
// click circle, overlaps and is above rect
map.center = preMapCircle.center
- verify(waitForRendering(map))
+ verify(LocationTestHelper.waitForPolished(map))
point = map.fromCoordinate(preMapCircle.center)
mouseClick(map, point.x - 5, point.y - 5)
- tryCompare(preMapRectClicked, "count", 1)
- compare(preMapCircleClicked.count, 1)
+ tryCompare(preMapCircleClicked, "count", 1)
+ compare(preMapRectClicked.count, 1)
// click within circle bounding rect but not inside the circle geometry
map.center = preMapCircle.center.atDistanceAndAzimuth(preMapCircle.radius, -45)
@@ -274,7 +301,7 @@ Item {
// click quick item
compare(preMapQuickItemClicked.count, 0)
map.center = preMapQuickItem.coordinate
- verify(waitForRendering(map))
+ verify(LocationTestHelper.waitForPolished(map))
point = map.fromCoordinate(preMapQuickItem.coordinate)
mouseClick(map, point.x + 5, point.y + 5)
tryCompare(preMapQuickItemClicked, "count", 1)
@@ -282,20 +309,22 @@ Item {
// click polygon
compare (preMapPolygonClicked.count, 0)
map.center = preMapPolygon.path[1]
- verify(waitForRendering(map))
+ verify(LocationTestHelper.waitForPolished(map))
point = map.fromCoordinate(preMapPolygon.path[1])
mouseClick(map, point.x - 5, point.y)
tryCompare(preMapPolygonClicked, "count", 1)
+ }
+ function test_no_items_on_map()
+ {
// remove items and repeat clicks to verify they are gone
map.clearMapItems()
- clear_data()
compare (map.mapItems.length, 0)
map.center = preMapRect.topLeft
- point = map.fromCoordinate(preMapRect.topLeft)
+ var point = map.fromCoordinate(preMapRect.topLeft)
mouseClick(map, point.x + 5, point.y + 5)
compare(preMapRectClicked.count, 0)
- visualInspectionPoint()
+ verify(LocationTestHelper.waitForPolished(map))
map.center = preMapCircle.center
point = map.fromCoordinate(preMapCircle.center)
mouseClick(map, point.x - 5, point.y - 5)
@@ -324,30 +353,31 @@ Item {
map.addMapItem(preMapPolyline)
map.addMapItem(preMapRoute)
compare (map.mapItems.length, 6)
- visualInspectionPoint()
+
map.center = preMapRect.topLeft
- verify(waitForRendering(map))
+ verify(LocationTestHelper.waitForPolished(map))
point = map.fromCoordinate(preMapRect.topLeft)
mouseClick(map, point.x + 5, point.y + 5)
tryCompare(preMapRectClicked, "count", 1)
map.center = preMapCircle.center
- verify(waitForRendering(map))
+ verify(LocationTestHelper.waitForPolished(map))
point = map.fromCoordinate(preMapCircle.center)
mouseClick(map, point.x - 5, point.y - 5)
tryCompare(preMapRectClicked, "count", 1)
compare(preMapCircleClicked.count, 1)
map.center = preMapCircle.center.atDistanceAndAzimuth(preMapCircle.radius, -45)
+ verify(LocationTestHelper.waitForPolished(map))
mouseClick(map, preMapCircle.x + 4, preMapCircle.y + 4)
tryCompare(preMapRectClicked, "count", 2)
compare(preMapCircleClicked.count, 1)
compare(preMapQuickItemClicked.count, 0)
map.center = preMapQuickItem.coordinate
- verify(waitForRendering(map))
+ verify(LocationTestHelper.waitForPolished(map))
point = map.fromCoordinate(preMapQuickItem.coordinate)
mouseClick(map, point.x + 5, point.y + 5)
tryCompare(preMapQuickItemClicked, "count", 1)
map.center = preMapPolygon.path[1]
- verify(waitForRendering(map))
+ verify(LocationTestHelper.waitForPolished(map))
point = map.fromCoordinate(preMapPolygon.path[1])
mouseClick(map, point.x - 5, point.y)
tryCompare(preMapPolygonClicked, "count", 1)
@@ -356,8 +386,7 @@ Item {
// item clips to map. not sure if this is sensible test
map.addMapItem(extMapCircle)
map.center = extMapCircle.center
- verify(waitForRendering(map))
- visualInspectionPoint();
+ verify(LocationTestHelper.waitForPolished(map))
point = map.fromCoordinate(extMapCircle.center)
mouseClick(map, point.x, point.y)
tryCompare(extMapCircleClicked, "count", 1)
@@ -367,8 +396,7 @@ Item {
map.addMapItem(extMapQuickItem)
map.center = extMapQuickItem.coordinate
- verify(waitForRendering(map))
- visualInspectionPoint();
+ verify(LocationTestHelper.waitForPolished(map))
point = map.fromCoordinate(extMapQuickItem.coordinate)
mouseClick(map, point.x + 5, point.y + 5)
tryCompare(extMapQuickItemClicked, "count", 1)
@@ -377,13 +405,12 @@ Item {
map.removeMapItem(extMapQuickItem)
}
- function test_ab_drag() {
- clear_data()
+ function test_drag()
+ {
// basic drags, drag rectangle
compare (preMapRectActiveChanged.count, 0)
map.center = preMapRect.topLeft
- verify(waitForRendering(map))
-
+ verify(LocationTestHelper.waitForPolished(map))
var i
var point = map.fromCoordinate(preMapRect.topLeft)
var targetCoordinate = map.toCoordinate(51, 51)
@@ -406,7 +433,7 @@ Item {
// drag circle
compare (preMapCircleActiveChanged.count, 0)
map.center = preMapCircle.center
- verify(waitForRendering(map))
+ verify(LocationTestHelper.waitForPolished(map))
point = map.fromCoordinate(preMapCircle.center)
targetCoordinate = map.toCoordinate(51, 51)
mousePress(map, point.x, point.y)
@@ -415,7 +442,7 @@ Item {
mouseMove(map, point.x - i, point.y - i)
}
mouseRelease(map, point.x - i, point.y - i)
- visualInspectionPoint()
+ verify(LocationTestHelper.waitForPolished(map))
compare(preMapRectActiveChanged.count, 2)
compare(preMapCircleActiveChanged.count, 2)
verify(preMapCircleCenterChanged.count > 1)
@@ -425,7 +452,7 @@ Item {
// drag quick item
compare (preMapQuickItemActiveChanged.count, 0)
map.center = preMapQuickItem.coordinate
- verify(waitForRendering(map))
+ verify(LocationTestHelper.waitForPolished(map))
point = map.fromCoordinate(preMapQuickItem.coordinate)
targetCoordinate = map.toCoordinate(51, 51)
mousePress(map, point.x + 5, point.y + 5)
@@ -434,15 +461,15 @@ Item {
mouseMove(map, point.x - i, point.y - i)
}
mouseRelease(map, point.x - i, point.y - i)
- visualInspectionPoint()
+ verify(LocationTestHelper.waitForPolished(map))
compare(preMapQuickItemActiveChanged.count, 2)
verify(preMapQuickItemCoordinateChanged.count > 1)
verify(fuzzy_compare(preMapQuickItem.coordinate.latitude, targetCoordinate.latitude, 0.2))
verify(fuzzy_compare(preMapQuickItem.coordinate.longitude, targetCoordinate.longitude, 0.2))
}
- function test_ac_basic_properties() {
- clear_data()
+ function test_basic_items_properties()
+ {
// circle
preMapCircle.center = someCoordinate1
compare (preMapCircleCenterChanged.count, 1)
@@ -558,35 +585,6 @@ Item {
compare (preMapQuickItemSourceItemChanged.count, 1)
}
- function clear_data() {
- preMapRectClicked.clear()
- preMapCircleClicked.clear()
- preMapQuickItemClicked.clear()
- preMapPolygonClicked.clear()
- preMapCircleCenterChanged.clear()
- preMapCircleColorChanged.clear()
- preMapCircleRadiusChanged.clear()
- preMapCircleBorderColorChanged.clear()
- preMapCircleBorderWidthChanged.clear()
- preMapRectTopLeftChanged.clear()
- preMapRectBottomRightChanged.clear()
- preMapRectColorChanged.clear()
- preMapPolylineColorChanged.clear()
- preMapPolylineWidthChanged.clear()
- preMapPolylinePathChanged.clear()
- preMapPolygonPathChanged.clear()
- preMapPolygonColorChanged.clear()
- preMapPolygonBorderColorChanged.clear()
- preMapPolygonBorderWidthChanged.clear()
- preMapRouteRouteChanged.clear()
- preMapRouteLineColorChanged.clear()
- preMapRouteLineWidthChanged.clear()
- preMapQuickItemCoordinateChanged.clear()
- preMapQuickItemAnchorPointChanged.clear()
- preMapQuickItemZoomLevelChanged.clear()
- preMapQuickItemSourceItemChanged.clear()
- }
-
function fuzzy_compare(val, ref, tol) {
var tolerance = 2
if (tol !== undefined)
@@ -597,16 +595,6 @@ Item {
return false;
}
- // call to visualInspectionPoint testcase (for dev time visual inspection)
- function visualInspectionPoint(time) {
- var waitTime = 0 // 300
- if (time !== undefined)
- waitTime = time
- if (waitTime > 0) {
- console.log('halting for ' + waitTime + ' milliseconds')
- wait (waitTime)
- }
- }
// these 'real_' prefixed functions do sequences as
// it would occur on real app (e.g. doubleclick is in fact
// a sequence of press, release, doubleclick, release).
diff --git a/tests/auto/declarative_ui/tst_map_item_details.qml b/tests/auto/declarative_ui/tst_map_item_details.qml
index 1758c954..4b1af61b 100644
--- a/tests/auto/declarative_ui/tst_map_item_details.qml
+++ b/tests/auto/declarative_ui/tst_map_item_details.qml
@@ -30,6 +30,7 @@ import QtQuick 2.0
import QtTest 1.0
import QtPositioning 5.5
import QtLocation 5.6
+import QtLocation.Test 5.6
Item {
id: page
@@ -303,22 +304,34 @@ Item {
(0,240) ---------------------------------------------------- (240,240)
*/
- function test_aa_precondition() {
- wait(10)
+ function initTestCase()
+ {
// sanity check that the coordinate conversion works
var mapcenter = map.fromCoordinate(map.center)
verify (fuzzy_compare(mapcenter.x, 100, 2))
verify (fuzzy_compare(mapcenter.y, 100, 2))
}
- function test_polygon() {
+ function init()
+ {
map.clearMapItems()
- clear_data()
- compare (extMapPolygon.border.width, 1.0)
- compare (extMapPolygonClicked.count, 0)
+ extMapPolygon.border.width = 1.0
+ extMapPolygonClicked.clear()
+ extMapPolylineColorChanged.clear()
+ extMapPolylineWidthChanged.clear()
+ extMapPolylinePathChanged.clear()
+ extMapPolygonPathChanged.clear()
+ extMapPolygonColorChanged.clear()
+ extMapPolygonBorderColorChanged.clear()
+ extMapPolygonBorderWidthChanged.clear()
+ }
+
+ function test_polygon()
+ {
map.center = extMapPolygon.path[1]
var point = map.fromCoordinate(extMapPolygon.path[1])
map.addMapItem(extMapPolygon)
+ verify(LocationTestHelper.waitForPolished(map))
verify(extMapPolygon.path.length == 2)
mouseClick(map, point.x - 5, point.y)
compare(extMapPolygonClicked.count, 0)
@@ -326,7 +339,7 @@ Item {
verify(extMapPolygon0.path.length == 0)
extMapPolygon.addCoordinate(polyCoordinate)
verify(extMapPolygon.path.length == 3)
- verify(waitForRendering(map))
+ verify(LocationTestHelper.waitForPolished(map))
mouseClick(map, point.x - 5, point.y)
tryCompare(extMapPolygonClicked, "count", 1)
@@ -347,9 +360,8 @@ Item {
verify(extMapPolygon.path.length == 0)
}
- function test_polyline() {
- map.clearMapItems()
- clear_data()
+ function test_polyline()
+ {
compare (extMapPolyline.line.width, 1.0)
var point = map.fromCoordinate(extMapPolyline.path[1])
map.addMapItem(extMapPolyline0) // mustn't crash or ill-behave
@@ -406,14 +418,9 @@ Item {
(0,240) ---------------------------------------------------- (600,240)
*/
- function test_yz_dateline() {
- if (Qt.platform.os === "windows")
- skip("QTBUG-53455");
- map.clearMapItems()
- clear_data()
+ function test_dateline() {
map.center = datelineCoordinate
map.zoomLevel = 2.2
-
// rectangle
// item spanning across dateline
map.addMapItem(extMapRectDateline)
@@ -429,10 +436,10 @@ Item {
verify(point.x > map.width / 2.0)
// move item edge onto dateline
extMapRectDateline.topLeft.longitude = datelineCoordinate.longitude
- verify(waitForRendering(map))
point = map.fromCoordinate(extMapRectDateline.topLeft)
verify(point.x == map.width / 2.0)
// drag item back onto dateline
+ verify(LocationTestHelper.waitForPolished(map))
mousePress(map, point.x + 5, point.y + 5)
var i
for (i=0; i < 20; i += 2) {
@@ -440,6 +447,7 @@ Item {
mouseMove(map, point.x + 5 - i, point.y + 5 )
}
mouseRelease(map, point.x + 5 - i, point.y + 5)
+ verify(LocationTestHelper.waitForPolished(map))
point = map.fromCoordinate(extMapRectDateline.topLeft)
verify(point.x < map.width / 2.0)
point = map.fromCoordinate(extMapRectDateline.bottomRight)
@@ -453,15 +461,16 @@ Item {
point = map.fromCoordinate(extMapCircleDateline.center)
verify(point.x == map.width / 2.0)
extMapCircleDateline.center.longitude = datelineCoordinateRight.longitude
- verify(waitForRendering(map))
point = map.fromCoordinate(extMapCircleDateline.center)
verify(point.x > map.width / 2.0)
+ verify(LocationTestHelper.waitForPolished(map))
mousePress(map, point.x, point.y)
for (i=0; i < 40; i += 4) {
wait(1)
mouseMove(map, point.x - i, point.y)
}
mouseRelease(map, point.x - i, point.y)
+ verify(LocationTestHelper.waitForPolished(map))
point = map.fromCoordinate(extMapCircleDateline.center)
verify(point.x < map.width / 2.0)
map.removeMapItem(extMapCircleDateline)
@@ -473,15 +482,16 @@ Item {
point = map.fromCoordinate(extMapQuickItemDateline.coordinate)
verify(point.x < map.width / 2.0)
extMapQuickItemDateline.coordinate.longitude = datelineCoordinateRight.longitude
- verify(waitForRendering(map))
point = map.fromCoordinate(extMapQuickItemDateline.coordinate)
verify(point.x > map.width / 2.0)
+ verify(LocationTestHelper.waitForPolished(map))
mousePress(map, point.x + 5, point.y + 5)
for (i=0; i < 50; i += 5) {
wait(1)
mouseMove(map, point.x + 5 - i, point.y + 5 )
}
mouseRelease(map, point.x + 5 - i, point.y + 5)
+ verify(LocationTestHelper.waitForPolished(map))
point = map.fromCoordinate(extMapQuickItemDateline.coordinate)
verify(point.x < map.width / 2.0)
map.removeMapItem(extMapQuickItemDateline)
@@ -515,16 +525,16 @@ Item {
path = extMapPolygonDateline.path;
path[3].longitude = datelineCoordinate.longitude;
extMapPolygonDateline.path = path;
- verify(waitForRendering(map))
point = map.fromCoordinate(extMapPolygonDateline.path[3])
verify(point.x == map.width / 2.0)
+ verify(LocationTestHelper.waitForPolished(map))
mousePress(map, point.x + 5, point.y - 5)
for (i=0; i < 16; i += 2) {
wait(1)
mouseMove(map, point.x + 5 - i, point.y - 5 )
}
mouseRelease(map, point.x + 5 - i, point.y - 5)
- verify(waitForRendering(map,10000))
+ verify(LocationTestHelper.waitForPolished(map))
point = map.fromCoordinate(extMapPolygonDateline.path[0])
verify(point.x < map.width / 2.0)
point = map.fromCoordinate(extMapPolygonDateline.path[1])
@@ -589,11 +599,7 @@ Item {
(0,240) ---------------------------------------------------- (600,240)
*/
- function test_zz_border_drag() {
- if (Qt.platform.os === "windows")
- skip("QTBUG-53455");
- map.clearMapItems()
- clear_data()
+ function test_border_drag() {
map.center = datelineCoordinate
// lower zoom level and change widths to reveal map border.
@@ -602,10 +608,9 @@ Item {
map.zoomLevel = 1
page.width = 600
map.width = 560
-
// rectangle
map.addMapItem(extMapRectEdge)
- verify(waitForRendering(map))
+ verify(LocationTestHelper.waitForPolished(map))
verify(extMapRectEdge.topLeft.longitude == -15)
verify(extMapRectEdge.bottomRight.longitude == -5)
var point = map.fromCoordinate(extMapRectEdge.topLeft)
@@ -625,6 +630,7 @@ Item {
mouseMove(map, point.x + 5 + i, point.y + 5)
}
mouseRelease(map, point.x + 5 + i, point.y + 5)
+ verify(LocationTestHelper.waitForPolished(map))
// currently the bottom right screen point is unwrapped and drawn
// out of the map border, but in the future culling may take place
// so tests for points outside the map border are ignored,
@@ -638,6 +644,7 @@ Item {
// circle
map.addMapItem(extMapCircleEdge)
map.center = datelineCoordinate
+ verify(LocationTestHelper.waitForPolished(map))
verify(extMapCircleEdge.center.longitude == -15)
var point = map.fromCoordinate(extMapCircleEdge.center)
verify(point.x < map.width)
@@ -651,6 +658,7 @@ Item {
mouseMove(map, point.x + i, point.y)
}
mouseRelease(map, point.x + i, point.y)
+ verify(LocationTestHelper.waitForPolished(map))
point = map.fromCoordinate(extMapCircleEdge.center)
verify(point.x < map.width)
verify(point.x > map.width / 2.0)
@@ -660,7 +668,7 @@ Item {
// quickitem
map.addMapItem(extMapQuickItemEdge)
map.center = datelineCoordinate
- verify(waitForRendering(map))
+ verify(LocationTestHelper.waitForPolished(map))
verify(extMapQuickItemEdge.coordinate.longitude == -15)
point = map.fromCoordinate(extMapQuickItemEdge.coordinate)
verify(point.x < map.width)
@@ -673,6 +681,7 @@ Item {
mouseMove(map, point.x + 5 + i, point.y + 5)
}
mouseRelease(map, point.x + 5 + i, point.y + 5)
+ verify(LocationTestHelper.waitForPolished(map))
point = map.fromCoordinate(extMapQuickItemEdge.coordinate)
verify(point.x < map.width)
verify(point.x > map.width / 2.0)
@@ -682,7 +691,7 @@ Item {
// polygon
map.center = datelineCoordinate
map.addMapItem(extMapPolygonEdge)
- verify(waitForRendering(map))
+ verify(LocationTestHelper.waitForPolished(map))
verify(extMapPolygonEdge.path[0].longitude == -15)
verify(extMapPolygonEdge.path[1].longitude == -5)
verify(extMapPolygonEdge.path[2].longitude == -5)
@@ -707,6 +716,7 @@ Item {
mouseMove(map, point.x + 5 + i, point.y - 5)
}
mouseRelease(map, point.x + 5 + i, point.y - 5)
+ verify(LocationTestHelper.waitForPolished(map))
point = map.fromCoordinate(extMapPolygonEdge.path[0])
verify(point.x < map.width)
verify(point.x > map.width / 2.0)
@@ -717,18 +727,6 @@ Item {
map.removeMapItem(extMapPolygonEdge)
}
-
- function clear_data() {
- extMapPolygonClicked.clear()
- extMapPolylineColorChanged.clear()
- extMapPolylineWidthChanged.clear()
- extMapPolylinePathChanged.clear()
- extMapPolygonPathChanged.clear()
- extMapPolygonColorChanged.clear()
- extMapPolygonBorderColorChanged.clear()
- extMapPolygonBorderWidthChanged.clear()
- }
-
function fuzzy_compare(val, ref, tol) {
var tolerance = 2
if (tol !== undefined)
@@ -738,11 +736,5 @@ Item {
console.log('map fuzzy cmp returns false for value, ref, tolerance: ' + val + ', ' + ref + ', ' + tolerance)
return false;
}
-
- // call to visualInspectionPoint testcase (only for development time visual inspection)
- function visualInspectionPoint(text) {
- progressText.text = text
- //wait (500)
- }
}
}
diff --git a/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml b/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml
index f8797ecb..e296fd8d 100644
--- a/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml
+++ b/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml
@@ -235,7 +235,6 @@ Item {
// normal case - fit viewport to items which are all already visible
verify_visibility_all_items()
map.fitViewportToMapItems()
- verify(waitForRendering(map))
visualInspectionPoint()
verify_visibility_all_items()
}
@@ -573,7 +572,6 @@ Item {
map.addMapItem(preMapPolygon)
map.addMapItem(preMapPolyline)
map.addMapItem(preMapRoute)
- verify(waitForRendering(map))
compare (map.mapItems.length, 6)
calculate_bounds()
}
diff --git a/tests/plugins/declarativetestplugin/declarativetestplugin.pro b/tests/plugins/declarativetestplugin/declarativetestplugin.pro
index a27267d7..0a99e7a7 100644
--- a/tests/plugins/declarativetestplugin/declarativetestplugin.pro
+++ b/tests/plugins/declarativetestplugin/declarativetestplugin.pro
@@ -7,13 +7,15 @@ QT += gui-private qml quick location testlib
INCLUDEPATH += ../../../src/imports/location
INCLUDEPATH += ../../../src/location
-HEADERS += qdeclarativepinchgenerator_p.h \
- qdeclarativelocationtestmodel_p.h
-
-
-SOURCES += locationtest.cpp \
- qdeclarativepinchgenerator.cpp \
- qdeclarativelocationtestmodel.cpp
+HEADERS += \
+ qdeclarativepinchgenerator_p.h \
+ qdeclarativelocationtestmodel_p.h \
+ testhelper.h
+
+SOURCES += \
+ locationtest.cpp \
+ qdeclarativepinchgenerator.cpp \
+ qdeclarativelocationtestmodel.cpp
IMPORT_FILES = \
qmldir
diff --git a/tests/plugins/declarativetestplugin/locationtest.cpp b/tests/plugins/declarativetestplugin/locationtest.cpp
index 85812b39..f0389d90 100644
--- a/tests/plugins/declarativetestplugin/locationtest.cpp
+++ b/tests/plugins/declarativetestplugin/locationtest.cpp
@@ -28,6 +28,7 @@
#include "qdeclarativepinchgenerator_p.h"
#include "qdeclarativelocationtestmodel_p.h"
+#include "testhelper.h"
#include <QtQml/QQmlExtensionPlugin>
#include <QtQml/qqml.h>
@@ -36,6 +37,14 @@
QT_BEGIN_NAMESPACE
+static QObject *helper_factory(QQmlEngine *engine, QJSEngine *scriptEngine)
+{
+ Q_UNUSED(engine);
+ Q_UNUSED(scriptEngine);
+ TestHelper *helper = new TestHelper();
+ return helper;
+}
+
class QLocationDeclarativeTestModule: public QQmlExtensionPlugin
{
Q_OBJECT
@@ -46,6 +55,7 @@ public:
if (QLatin1String(uri) == QLatin1String("QtLocation.Test")) {
qmlRegisterType<QDeclarativePinchGenerator>(uri, 5, 5, "PinchGenerator");
qmlRegisterType<QDeclarativeLocationTestModel>(uri, 5, 5, "TestModel");
+ qmlRegisterSingletonType<TestHelper>(uri, 5, 6, "LocationTestHelper", helper_factory);
} else {
qWarning() << "Unsupported URI given to load location test QML plugin: " << QLatin1String(uri);
}
diff --git a/tests/plugins/declarativetestplugin/qdeclarativelocationtestmodel.cpp b/tests/plugins/declarativetestplugin/qdeclarativelocationtestmodel.cpp
index eb8bd054..e0004596 100644
--- a/tests/plugins/declarativetestplugin/qdeclarativelocationtestmodel.cpp
+++ b/tests/plugins/declarativetestplugin/qdeclarativelocationtestmodel.cpp
@@ -31,6 +31,8 @@
#include <QtCore/QTime>
#include <QtCore>
+QT_BEGIN_NAMESPACE
+
QDeclarativeLocationTestModel::QDeclarativeLocationTestModel(QObject *parent):
QAbstractListModel(parent),
delay_(0),
@@ -242,3 +244,5 @@ QHash<int, QByteArray> QDeclarativeLocationTestModel::roleNames() const
roles.insert(TestDataRole, "modeldata");
return roles;
}
+
+QT_END_NAMESPACE
diff --git a/tests/plugins/declarativetestplugin/qdeclarativelocationtestmodel_p.h b/tests/plugins/declarativetestplugin/qdeclarativelocationtestmodel_p.h
index 5d6f2395..925125af 100644
--- a/tests/plugins/declarativetestplugin/qdeclarativelocationtestmodel_p.h
+++ b/tests/plugins/declarativetestplugin/qdeclarativelocationtestmodel_p.h
@@ -36,6 +36,8 @@
#include <QList>
#include <QtPositioning/QGeoCoordinate>
+QT_BEGIN_NAMESPACE
+
class DataObject: public QObject
{
Q_OBJECT
@@ -123,4 +125,6 @@ private:
bool crazyMode_;
};
+QT_END_NAMESPACE
+
#endif
diff --git a/tests/plugins/declarativetestplugin/qdeclarativepinchgenerator.cpp b/tests/plugins/declarativetestplugin/qdeclarativepinchgenerator.cpp
index 37f0583d..3026cd92 100644
--- a/tests/plugins/declarativetestplugin/qdeclarativepinchgenerator.cpp
+++ b/tests/plugins/declarativetestplugin/qdeclarativepinchgenerator.cpp
@@ -33,6 +33,8 @@
#include <QtGui/qpa/qwindowsysteminterface.h>
#include <QtGui/QStyleHints>
+QT_BEGIN_NAMESPACE
+
QDeclarativePinchGenerator::QDeclarativePinchGenerator():
target_(0),
state_(Invalid),
@@ -376,3 +378,5 @@ int QDeclarativePinchGenerator::startDragDistance()
{
return qApp->styleHints()->startDragDistance();
}
+
+QT_END_NAMESPACE
diff --git a/tests/plugins/declarativetestplugin/qdeclarativepinchgenerator_p.h b/tests/plugins/declarativetestplugin/qdeclarativepinchgenerator_p.h
index f3b06943..23d8b650 100644
--- a/tests/plugins/declarativetestplugin/qdeclarativepinchgenerator_p.h
+++ b/tests/plugins/declarativetestplugin/qdeclarativepinchgenerator_p.h
@@ -41,6 +41,8 @@
#define SWIPES_REQUIRED 2
+QT_BEGIN_NAMESPACE
+
typedef struct {
QList<QPoint> touchPoints;
QList<int> durations;
@@ -132,4 +134,6 @@ private:
QTouchDevice* device_;
};
+QT_END_NAMESPACE
+
#endif
diff --git a/tests/plugins/declarativetestplugin/testhelper.h b/tests/plugins/declarativetestplugin/testhelper.h
new file mode 100644
index 00000000..c6d9f3b3
--- /dev/null
+++ b/tests/plugins/declarativetestplugin/testhelper.h
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTHELPER_H
+#define TESTHELPER_H
+
+#include <QObject>
+#include <QSignalSpy>
+#include <QQuickItem>
+#include <QQuickWindow>
+
+QT_BEGIN_NAMESPACE
+
+class TestHelper: public QObject
+{
+ Q_OBJECT
+public:
+ TestHelper(QObject *parent = Q_NULLPTR):QObject(parent){}
+ Q_INVOKABLE bool waitForPolished(QQuickItem *item, int timeout = 10000) const
+ {
+ QSignalSpy spy(item->window(), &QQuickWindow::afterAnimating);
+ return spy.wait(timeout);
+ }
+};
+
+QT_END_NAMESPACE
+
+#endif // TESTHELPER_H