@@ -22,16 +22,13 @@ TestCase {
2222 function test_instantiation () {
2323 verify (map !== null , " SimpleMapView widget failed to instantiate." )
2424
25- compare (map .tileServer , SimpleMapView .OSM , " Default `tileServer` should be OSM." )
26- compare (map .tileServerSource , SimpleMapView .Remote , " Default source should be Remote." )
25+ compare (map .tileServer , TileServers .OSM , " Default `tileServer` should be OSM." )
26+ compare (map .tileServerSource () , SimpleMapView .Remote , " Default source should be Remote." )
2727
28- verify (! map .isZoomLocked , " Default `isZoomLocked` should be false" )
29- verify (! map .isGeolocationLocked , " Default `isGeolocationLocked` should be false" )
30- verify (! map .isMouseWheelZoomDisabled , " Default `isMouseWheelZoomDisabled` should be false" )
31- verify (! map .isMouseMoveMapDisabled , " Default `isMouseMoveMapDisabled` should be false" )
32-
33- verify (map .markerIcon !== " " , " Default marker icon should not be empty" )
34- verify (map .markerIcon .toString ().indexOf (" marker.svg" ) >= 0 , " Default marker icon path mismatch." )
28+ verify (! map .isZoomLocked (), " Default `isZoomLocked` should be false" )
29+ verify (! map .isGeolocationLocked (), " Default `isGeolocationLocked` should be false" )
30+ verify (! map .isMouseWheelZoomDisabled (), " Default `isMouseWheelZoomDisabled` should be false" )
31+ verify (! map .isMouseMoveMapDisabled (), " Default `isMouseMoveMapDisabled` should be false" )
3532 }
3633
3734 function test_zoomLevel () {
@@ -66,25 +63,25 @@ TestCase {
6663 map .zoomLevel = 5
6764 zoomSpy .clear ()
6865
69- map .lockZoom ()
66+ map .lockZoom = true
7067 map .zoomLevel = 12
7168 compare (map .zoomLevel , 5 , " Failed to lock zoom." )
7269 compare (zoomSpy .count , 0 )
7370
74- map .unlockZoom ()
71+ map .lockZoom = false
7572 map .zoomLevel = 12
7673 compare (map .zoomLevel , 12 , " Failed to unlock zoom." )
7774 compare (zoomSpy .count , 1 )
7875
79- map .disableMouseWheelZoom ()
80- verify (map .isMouseWheelZoomDisabled , " Failed to disable mouse wheel zoom." )
76+ map .disableMouseWheelZoom = true
77+ verify (map .isMouseWheelZoomDisabled () , " Failed to disable mouse wheel zoom." )
8178
8279 preZoom = map .zoomLevel
8380 mouseWheel (map, map .width / 2 , map .height / 2 , 120 , 120 )
8481 compare (map .zoomLevel , preZoom, " Mouse wheel should be ignored when disabled." )
8582
86- map .enableMouseWheelZoom ()
87- verify (! map .isMouseWheelZoomDisabled , " Failed to enable mouse wheel zoom." )
83+ map .disableMouseWheelZoom = false
84+ verify (! map .isMouseWheelZoomDisabled () , " Failed to enable mouse wheel zoom." )
8885 }
8986
9087 function test_positioning () {
@@ -107,35 +104,49 @@ TestCase {
107104
108105 var startX = map .width / 2
109106 var startY = map .height / 2
110-
111107 var initialLon = map .longitude
112108 var initialLat = map .latitude
113109
114- mouseDrag (map, startX, startY, startX - 100 , startY)
110+ mousePress (map, startX, startY, Qt .LeftButton )
111+ mouseMove (map, startX - 100 , startY, 0 , Qt .LeftButton )
112+ mouseRelease (map, startX - 100 , startY, Qt .LeftButton )
113+
115114 verify (map .longitude > initialLon, " Failed to move map (Longitude) via mouse." )
116- verify (Math .abs (map .latitude - initialLat) < 0.0001 , " Latitude should remain constant on horizontal drag." )
115+ verify (map .latitude === initialLat, " Latitude should remain constant on horizontal drag." )
116+
117+ map .longitude = initialLon
118+ map .latitude = initialLat
119+
120+ mousePress (map, startX, startY, Qt .LeftButton )
121+ mouseMove (map, startX, startY + 100 , 0 , Qt .LeftButton )
122+ mouseRelease (map, startX, startY + 100 , Qt .LeftButton )
123+
124+ verify (map .longitude === initialLon, " Failed to move map (Longitude) via mouse." )
125+ verify (map .latitude > initialLat, " Latitude should remain constant on horizontal drag." )
117126
118127 map .latitude = 10.0
119128 centerSpy .clear ()
120129
121- map .lockGeolocation ()
130+ map .lockGeolocation = true
122131 map .latitude = 20.0
123132 compare (map .latitude , 10.0 , " Failed to lock geolocation." )
124133 compare (centerSpy .count , 0 )
125134
126- map .unlockGeolocation ()
135+ map .lockGeolocation = false
127136 map .latitude = 20.0
128137 compare (map .latitude , 20.0 , " Failed to unlock geolocation." )
129138
130- map .disableMouseMoveMap ()
131- verify (map .isMouseMoveMapDisabled , " Failed to flag mouse move disabled." )
139+ map .disableMouseMoveMap = true
140+ verify (map .isMouseMoveMapDisabled () , " Failed to flag mouse move disabled." )
132141
133142 var frozenCenter = map .center
134- mouseDrag (map, startX, startY, startX - 100 , startY)
143+ mousePress (map, startX, startY, Qt .LeftButton )
144+ mouseMove (map, startX - 100 , startY + 100 , 0 , Qt .LeftButton )
145+ mouseRelease (map, startX - 100 , startY + 100 , Qt .LeftButton )
135146 compare (map .center , frozenCenter, " Map should not move when mouse move is disabled." )
136147
137- map .enableMouseMoveMap ()
138- verify (! map .isMouseMoveMapDisabled , " Failed to flag mouse move enabled." )
148+ map .disableMouseMoveMap = false
149+ verify (! map .isMouseMoveMapDisabled () , " Failed to flag mouse move enabled." )
139150 }
140151
141152 function test_tileServers () {
@@ -146,20 +157,14 @@ TestCase {
146157 map .setTileServer (invalidUrl)
147158 wait (5000 )
148159
149- compare (map .tileServer , SimpleMapView .OSM , " Should default to OSM on invalid server." )
160+ compare (map .tileServer , TileServers .OSM , " Should default to OSM on invalid server." )
150161
151- map .setTileServer (SimpleMapView .GOOGLE_MAP )
152- compare (map .tileServer , SimpleMapView .GOOGLE_MAP , " Failed to change tile server." )
162+ map .setTileServer (TileServers .GOOGLE_MAP )
163+ compare (map .tileServer , TileServers .GOOGLE_MAP , " Failed to change tile server." )
153164 }
154165
155166 function test_markers () {
156167 var marker = map .addMarker (map .latitude , map .longitude )
157168 verify (marker !== null , " Failed to add marker." )
158-
159- map .setMarkerIcon (" qrc:/SimpleMapView/marker_alt.svg" )
160- var marker2 = map .addMarker (map .center )
161- verify (marker2 !== null , " Failed to add second marker." )
162-
163- verify (map .markerIcon .toString ().indexOf (" marker_alt.svg" ) >= 0 , " Global marker icon failed to update." )
164169 }
165170}
0 commit comments