summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@theqtcompany.com>2016-07-29 15:37:19 +0200
committerAlex Blasche <alexander.blasche@theqtcompany.com>2016-07-29 15:37:19 +0200
commit76e3fea9e77713860211c599b2a0aff3a72902c6 (patch)
tree0a24d1c3b987a6f4ebc2fbde6cb0d0a2daae7142 /tests
parent1753409f92a6b865b71612465b887f808568ada2 (diff)
parent1a1d2e3fff5856dc9d1283b510a9f325c6fb8a93 (diff)
downloadqtlocation-76e3fea9e77713860211c599b2a0aff3a72902c6.tar.gz
Merge remote-tracking branch 'gerrit/5.7' into dev
Change-Id: I6a1a72547077c628429ee9a0781070ad3ae787f1
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative_ui/tst_map_item_details.qml12
-rw-r--r--tests/auto/declarative_ui/tst_map_item_fit_viewport.qml215
-rw-r--r--tests/auto/declarative_ui/tst_map_itemview.qml2
3 files changed, 158 insertions, 71 deletions
diff --git a/tests/auto/declarative_ui/tst_map_item_details.qml b/tests/auto/declarative_ui/tst_map_item_details.qml
index 68e069d4..ebaf1ea7 100644
--- a/tests/auto/declarative_ui/tst_map_item_details.qml
+++ b/tests/auto/declarative_ui/tst_map_item_details.qml
@@ -421,6 +421,8 @@ Item {
function test_dateline() {
map.center = datelineCoordinate
map.zoomLevel = 2.2
+ var inspectionTime = 0 // change this to inspect the behavior.
+
// rectangle
// item spanning across dateline
map.addMapItem(extMapRectDateline)
@@ -440,6 +442,7 @@ Item {
verify(point.x == map.width / 2.0)
// drag item back onto dateline
verify(LocationTestHelper.waitForPolished(map))
+ visualInspectionPoint(inspectionTime)
mousePress(map, point.x + 5, point.y + 5)
var i
for (i=0; i < 20; i += 2) {
@@ -448,6 +451,7 @@ Item {
}
mouseRelease(map, point.x + 5 - i, point.y + 5)
verify(LocationTestHelper.waitForPolished(map))
+ visualInspectionPoint(inspectionTime)
point = map.fromCoordinate(extMapRectDateline.topLeft)
verify(point.x < map.width / 2.0)
point = map.fromCoordinate(extMapRectDateline.bottomRight)
@@ -465,7 +469,7 @@ Item {
point = map.fromCoordinate(extMapCircleDateline.center)
verify(LocationTestHelper.waitForPolished(map))
verify(point.x > map.width / 2.0)
- visualInspectionPoint()
+ visualInspectionPoint(inspectionTime)
mousePress(map, point.x, point.y)
for (i=0; i < 50; i += 4) {
wait(1)
@@ -473,6 +477,7 @@ Item {
}
mouseRelease(map, point.x - i, point.y)
verify(LocationTestHelper.waitForPolished(map))
+ visualInspectionPoint(inspectionTime)
point = map.fromCoordinate(extMapCircleDateline.center)
visualInspectionPoint()
verify(point.x < map.width / 2.0)
@@ -489,7 +494,7 @@ Item {
point = map.fromCoordinate(extMapQuickItemDateline.coordinate)
verify(point.x > map.width / 2.0)
verify(LocationTestHelper.waitForPolished(map))
- visualInspectionPoint()
+ visualInspectionPoint(inspectionTime)
mousePress(map, point.x + 5, point.y + 5)
for (i=0; i < 64; i += 5) {
wait(1)
@@ -497,6 +502,7 @@ Item {
}
mouseRelease(map, point.x + 5 - i, point.y + 5)
verify(LocationTestHelper.waitForPolished(map))
+ visualInspectionPoint(inspectionTime)
point = map.fromCoordinate(extMapQuickItemDateline.coordinate)
visualInspectionPoint()
verify(point.x < map.width / 2.0)
@@ -534,6 +540,7 @@ Item {
point = map.fromCoordinate(extMapPolygonDateline.path[3])
verify(point.x == map.width / 2.0)
verify(LocationTestHelper.waitForPolished(map))
+ visualInspectionPoint(inspectionTime)
mousePress(map, point.x + 5, point.y - 5)
for (i=0; i < 16; i += 2) {
wait(1)
@@ -541,6 +548,7 @@ Item {
}
mouseRelease(map, point.x + 5 - i, point.y - 5)
verify(LocationTestHelper.waitForPolished(map))
+ visualInspectionPoint(inspectionTime)
point = map.fromCoordinate(extMapPolygonDateline.path[0])
verify(point.x < map.width / 2.0)
point = map.fromCoordinate(extMapPolygonDateline.path[1])
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 e296fd8d..fe4d9e49 100644
--- a/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml
+++ b/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml
@@ -34,10 +34,10 @@ import QtLocation.Test 5.5
/*
- (0,0) ---------------------------------------------------- (240,0)
+ (0,0) ---------------------------------------------------- (296,0)
| no map |
| (20,20) |
- (0,20) | ------------------------------------------ | (240,20)
+ (0,20) | ------------------------------------------ | (296,20)
| | | |
| | map | |
| | | |
@@ -52,15 +52,15 @@ import QtLocation.Test 5.5
| | | |
| ------------------------------------------ |
| |
- (0,240) ---------------------------------------------------- (240,240)
+ (0,296) ---------------------------------------------------- (296,296)
*/
Item {
id: page
x: 0; y: 0;
- width: 240
- height: 240
+ width: 296
+ height: 296
Plugin { id: testPlugin; name : "qmlgeo.test.plugin"; allowExperimental: true }
property variant mapDefaultCenter: QtPositioning.coordinate(20, 20)
@@ -97,11 +97,8 @@ Item {
property variant mapPolylineBottomRight: QtPositioning.coordinate(0, 0)
property variant mapRouteTopLeft: QtPositioning.coordinate(0, 0)
property variant mapRouteBottomRight: QtPositioning.coordinate(0, 0)
-
- property variant boundingBox: QtPositioning.rectangle(QtPositioning.coordinate(0, 0),
- QtPositioning.coordinate(0, 0))
-
- property variant fitRect: QtPositioning.rectangle(QtPositioning.coordinate(80, 80), QtPositioning.coordinate(78, 82))
+ property variant fitRect: QtPositioning.rectangle(QtPositioning.coordinate(80, 80),
+ QtPositioning.coordinate(78, 82))
property variant fitEmptyRect: QtPositioning.rectangle(QtPositioning.coordinate(79, 79),-1, -1)
property variant fitCircle: QtPositioning.circle(QtPositioning.coordinate(-50, -100), 1500)
property variant fitInvalidShape: QtPositioning.shape()
@@ -111,7 +108,7 @@ Item {
Map {
id: map;
- x: 20; y: 20; width: 200; height: 200
+ x: 20; y: 20; width: 256; height: 256
zoomLevel: 3
center: mapDefaultCenter
plugin: testPlugin;
@@ -222,16 +219,58 @@ Item {
name: "MapItemsFitViewport"
when: windowShown
- function test_aa_visible_basic() { // aa et al. for execution order
- wait(10)
- // sanity check that the coordinate conversion works, as
- // rest of the case relies on it. for robustness cut
- // a little slack with fuzzy compare
+ 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))
+ verify (fuzzy_compare(mapcenter.x, 128, 2))
+ verify (fuzzy_compare(mapcenter.y, 128, 2))
+ }
+
+ function init()
+ {
+ preMapRect.topLeft.latitude = 20
+ preMapRect.topLeft.longitude = 20
+ preMapRect.bottomRight.latitude = 10
+ preMapRect.bottomRight.longitude = 30
+ preMapCircle.center.latitude = 10
+ preMapCircle.center.longitude = 30
+ preMapQuickItem.coordinate.latitude = 35
+ preMapQuickItem.coordinate.longitude = 3
+ var i
+ for (i = 0; i < preMapPolygon.path.length; ++i) {
+ preMapPolygon.path[i].latitude = preMapPolygonDefaultPath[i].latitude
+ preMapPolygon.path[i].longitude = preMapPolygonDefaultPath[i].longitude
+ }
+ for (i = 0; i < preMapPolyline.path.length; ++i) {
+ preMapPolyline.path[i].latitude = preMapPolylineDefaultPath[i].latitude
+ preMapPolyline.path[i].longitude = preMapPolylineDefaultPath[i].longitude
+ }
+ for (i = 0; i < preMapRoute.route.path.length; ++i) {
+ preMapRoute.route.path[i].latitude = preMapRouteDefaultPath[i].latitude
+ preMapRoute.route.path[i].longitude = preMapRouteDefaultPath[i].longitude
+ }
+ // remove items
+ map.clearMapItems()
+ //clear_data()
+ compare (map.mapItems.length, 0)
+ // reset map
+ map.center.latitude = 20
+ map.center.longitude = 20
+ map.zoomLevel = 3
+ // re-add items and verify they are back (without needing to pan map etc.)
+ map.addMapItem(preMapRect)
+ map.addMapItem(preMapCircle)
+ map.addMapItem(preMapQuickItem)
+ map.addMapItem(preMapPolygon)
+ map.addMapItem(preMapPolyline)
+ map.addMapItem(preMapRoute)
+ compare (map.mapItems.length, 6)
+ calculate_bounds()
+ }
- reset()
+ function test_visible_itmes()
+ {
// normal case - fit viewport to items which are all already visible
verify_visibility_all_items()
map.fitViewportToMapItems()
@@ -239,21 +278,23 @@ Item {
verify_visibility_all_items()
}
- function test_ab_visible_zoom() {
- var i
+ function test_visible_zoom_in()
+ {
// zoom in (clipping also occurs)
var z = map.zoomLevel
- for (i = (z + 1); i < map.maximumZoomLevel; ++i ) {
- reset()
+ for (var i = (z + 1); i < map.maximumZoomLevel; ++i ) {
map.zoomLevel = i
visualInspectionPoint()
map.fitViewportToMapItems()
visualInspectionPoint()
verify_visibility_all_items()
}
+ }
+
+ function test_visible_zoom_out()
+ {
// zoom out
- for (i = (z - 1); i >= 0; --i ) {
- reset()
+ for (var i = (z - 1); i >= 0; --i ) {
map.zoomLevel = i
visualInspectionPoint()
verify_visibility_all_items()
@@ -263,7 +304,7 @@ Item {
}
}
- function test_ac_visible_map_move() {
+ function test_visible_map_move() {
// move map so all items are out of screen
// then fit viewport
var xDir = 1
@@ -272,7 +313,6 @@ Item {
var yDirChange = 1
var dir = 0
for (dir = 0; dir < 4; dir++) {
- reset()
verify_visibility_all_items()
var i = 0
var panX = map.width * xDir * 0.5
@@ -307,8 +347,7 @@ Item {
}
}
- function test_ad_fit_to_geoshape() {
- reset()
+ function test_fit_to_geoshape() {
visualInspectionPoint()
calculate_fit_circle_bounds()
//None should be visible
@@ -352,6 +391,84 @@ Item {
verify(!is_coord_on_screen(fitCircleBottomRight))
verify(is_coord_on_screen(fitEmptyRect.topLeft))
verify(is_coord_on_screen(fitEmptyRect.bottomRight))
+
+ // Test if this can be reset
+ map.visibleRegion = fitRect
+ verify(is_coord_on_screen(fitRect.topLeft))
+ verify(is_coord_on_screen(fitRect.bottomRight))
+ // move map
+ map.center = QtPositioning.coordinate(0,0)
+ verify(!is_coord_on_screen(fitRect.topLeft))
+ verify(!is_coord_on_screen(fitRect.bottomRight))
+ // recheck
+ map.visibleRegion = fitRect
+ verify(is_coord_on_screen(fitRect.topLeft))
+ verify(is_coord_on_screen(fitRect.bottomRight))
+ //zoom map
+ map.zoomLevel++
+ verify(!is_coord_on_screen(fitRect.topLeft))
+ verify(!is_coord_on_screen(fitRect.bottomRight))
+ // recheck
+ map.visibleRegion = fitRect
+ verify(is_coord_on_screen(fitRect.topLeft))
+ verify(is_coord_on_screen(fitRect.bottomRight))
+ }
+
+ // checks that circles belongs to the view port
+ function circle_in_viewport(center, radius, visible)
+ {
+ for (var i = 0; i < 128; ++i) {
+ var azimuth = 360.0 * i / 128.0;
+ var coord = center.atDistanceAndAzimuth(radius,azimuth)
+ if (coord.isValid)
+ verify(is_coord_on_screen(coord) === visible, visible ?
+ "circle not visible" : "circle visible")
+ }
+ }
+
+ function test_fit_circle_to_viewport(data)
+ {
+ verify(!is_coord_on_screen(data.center))
+ circle_in_viewport(data.center, data.radius, false)
+ map.visibleRegion = QtPositioning.circle(data.center, data.radius)
+ circle_in_viewport(data.center, data.radius, true)
+ }
+
+ function test_fit_circle_to_viewport_data()
+ {
+ return [
+ { tag: "circle 1", center:
+ QtPositioning.coordinate(70,70), radius: 10 },
+ { tag: "circle 2", center:
+ QtPositioning.coordinate(80,30), radius: 2000000 },
+ { tag: "circle 3", center:
+ QtPositioning.coordinate(-82,30), radius: 2000000 },
+ { tag: "circle 4", center:
+ QtPositioning.coordinate(60,179), radius: 20000 },
+ { tag: "circle 5", center:
+ QtPositioning.coordinate(60,-179), radius: 20000 },
+ ]
+ }
+
+ function test_fit_rectangle_to_viewport(data)
+ {
+ verify(!is_coord_on_screen(data.topLeft),"rectangle visible")
+ verify(!is_coord_on_screen(data.bottomRight),"rectangle visible")
+ map.visibleRegion = QtPositioning.rectangle(data.topLeft,data.bottomRight)
+ verify(is_coord_on_screen(data.topLeft),"rectangle not visible")
+ verify(is_coord_on_screen(data.bottomRight),"rectangle not visible")
+ }
+
+ function test_fit_rectangle_to_viewport_data()
+ {
+ return [
+ { tag: "rectangle 1",
+ topLeft: QtPositioning.coordinate(80, 80),
+ bottomRight: QtPositioning.coordinate(78, 82) },
+ { tag: "rectangle 2",
+ topLeft: QtPositioning.coordinate(30,-130),
+ bottomRight: QtPositioning.coordinate(0,-100)}
+ ]
}
/*function test_ad_visible_items_move() {
@@ -535,46 +652,6 @@ Item {
verify(is_coord_on_screen(mapRouteBottomRight))
}
- function reset(){
- preMapRect.topLeft.latitude = 20
- preMapRect.topLeft.longitude = 20
- preMapRect.bottomRight.latitude = 10
- preMapRect.bottomRight.longitude = 30
- preMapCircle.center.latitude = 10
- preMapCircle.center.longitude = 30
- preMapQuickItem.coordinate.latitude = 35
- preMapQuickItem.coordinate.longitude = 3
- var i
- for (i=0; i< preMapPolygon.path.length; ++i) {
- preMapPolygon.path[i].latitude = preMapPolygonDefaultPath[i].latitude
- preMapPolygon.path[i].longitude = preMapPolygonDefaultPath[i].longitude
- }
- for (i=0; i< preMapPolyline.path.length; ++i) {
- preMapPolyline.path[i].latitude = preMapPolylineDefaultPath[i].latitude
- preMapPolyline.path[i].longitude = preMapPolylineDefaultPath[i].longitude
- }
- for (i=0; i< preMapRoute.route.path.length; ++i) {
- preMapRoute.route.path[i].latitude = preMapRouteDefaultPath[i].latitude
- preMapRoute.route.path[i].longitude = preMapRouteDefaultPath[i].longitude
- }
- // remove items
- map.clearMapItems()
- //clear_data()
- compare (map.mapItems.length, 0)
- // reset map
- map.center.latitude = 20
- map.center.longitude = 20
- map.zoomLevel = 3
- // re-add items and verify they are back (without needing to pan map etc.)
- map.addMapItem(preMapRect)
- map.addMapItem(preMapCircle)
- map.addMapItem(preMapQuickItem)
- map.addMapItem(preMapPolygon)
- map.addMapItem(preMapPolyline)
- map.addMapItem(preMapRoute)
- compare (map.mapItems.length, 6)
- calculate_bounds()
- }
function is_coord_on_screen(coord) {
return is_point_on_screen(map.fromCoordinate(coord))
diff --git a/tests/auto/declarative_ui/tst_map_itemview.qml b/tests/auto/declarative_ui/tst_map_itemview.qml
index d3e64b6c..db788ace 100644
--- a/tests/auto/declarative_ui/tst_map_itemview.qml
+++ b/tests/auto/declarative_ui/tst_map_itemview.qml
@@ -393,6 +393,8 @@ Item {
tryCompare(mapForView, "mapItemsLength", 7)
testModel.datacount += 2
testModel2.datacount += 1
+ // delegate spawning is async. wait a bit.
+ wait(1)
tryCompare(mapForView, "mapItemsLength", 9)
theItemView.model = testModel