diff options
author | Erik Mattsson <erik.mattsson@appello.com> | 2013-10-07 10:23:01 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-10-15 11:38:26 +0200 |
commit | d2411f350e407da0dd299606b8d6f988cf2f9f80 (patch) | |
tree | 25d09afb06f0f0b5d9d09ad96e3111d82cda3462 /tests/auto | |
parent | 42541b2406f6b35e109ee6bee64283582dfd2adc (diff) | |
download | qtlocation-d2411f350e407da0dd299606b8d6f988cf2f9f80.tar.gz |
Added qml function to fit map to geo shape
Added a qml invokable function in the map object to fit the viewport
to a geo shape. It's heavily influenced from fitViewportToMapItems.
Also added some basic ui tests.
Added handlig for the case with an empty shape
Change-Id: Iecad849f2c1b6d9a54eab90e26435b31a138886c
Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/declarative_ui/tst_map_item_fit_viewport.qml | 61 |
1 files changed, 61 insertions, 0 deletions
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 d0af06be..4415541c 100644 --- a/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml +++ b/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml @@ -114,6 +114,14 @@ Item { 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 fitEmptyRect: QtPositioning.rectangle(QtPositioning.coordinate(79, 79),-1, -1) + property variant fitCircle: QtPositioning.circle(QtPositioning.coordinate(-50, -100), 1500) + property variant fitInvalidShape: QtPositioning.shape() + + property variant fitCircleTopLeft: QtPositioning.coordinate(0, 0) + property variant fitCircleBottomRight: QtPositioning.coordinate(0, 0) + Map { id: map; x: 20; y: 20; width: 200; height: 200 @@ -313,6 +321,53 @@ Item { } } + function test_ad_fit_to_geoshape() { + reset() + visualInspectionPoint() + calculate_fit_circle_bounds() + //None should be visible + verify(!is_coord_on_screen(fitCircleTopLeft)) + verify(!is_coord_on_screen(fitCircleBottomRight)) + verify(!is_coord_on_screen(fitRect.topLeft)) + verify(!is_coord_on_screen(fitRect.bottomRight)) + + map.fitViewportToGeoShape(fitRect) + visualInspectionPoint() + calculate_fit_circle_bounds() + //Rectangle should be visible, not circle + verify(!is_coord_on_screen(fitCircleTopLeft)) + verify(!is_coord_on_screen(fitCircleBottomRight)) + verify(is_coord_on_screen(fitRect.topLeft)) + verify(is_coord_on_screen(fitRect.bottomRight)) + + map.fitViewportToGeoShape(fitCircle) + visualInspectionPoint() + calculate_fit_circle_bounds() + //Circle should be visible, not rectangle + verify(is_coord_on_screen(fitCircleTopLeft)) + verify(is_coord_on_screen(fitCircleBottomRight)) + verify(!is_coord_on_screen(fitRect.topLeft)) + verify(!is_coord_on_screen(fitRect.bottomRight)) + + map.fitViewportToGeoShape(fitInvalidShape) + visualInspectionPoint() + calculate_fit_circle_bounds() + //Invalid shape, map should be in the same position as before + verify(is_coord_on_screen(fitCircleTopLeft)) + verify(is_coord_on_screen(fitCircleBottomRight)) + verify(!is_coord_on_screen(fitRect.topLeft)) + verify(!is_coord_on_screen(fitRect.bottomRight)) + + map.fitViewportToGeoShape(fitEmptyRect) + visualInspectionPoint() + calculate_fit_circle_bounds() + //Empty shape, map should change centerlocation, empty rect visible + verify(!is_coord_on_screen(fitCircleTopLeft)) + verify(!is_coord_on_screen(fitCircleBottomRight)) + verify(is_coord_on_screen(fitEmptyRect.topLeft)) + verify(is_coord_on_screen(fitEmptyRect.bottomRight)) + } + /*function test_ad_visible_items_move() { // move different individual items out of screen // then fit viewport @@ -413,6 +468,12 @@ Item { preMapQuickItemSourceItemChanged.clear() } + function calculate_fit_circle_bounds() { + var circleDiagonal = Math.sqrt(2 * fitCircle.radius * fitCircle.radius) + fitCircleTopLeft = fitCircle.center.atDistanceAndAzimuth(circleDiagonal,-45) + fitCircleBottomRight = fitCircle.center.atDistanceAndAzimuth(circleDiagonal,135) + } + function calculate_bounds(){ var circleDiagonal = Math.sqrt(2 * preMapCircle.radius * preMapCircle.radius) var itemTopLeft = preMapCircle.center.atDistanceAndAzimuth(circleDiagonal,-45) |