summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeng Liu <peng.liu@mapbox.com>2020-01-03 18:24:58 +0200
committerPeng Liu <peng.liu@mapbox.com>2020-01-05 15:05:06 +0200
commitadb68b52f0b6b9065fb1bcd35f09630eb50525eb (patch)
treeeaa5c91c67143ddff41fb61c1d4f7c565dade7de
parent1d4cffe05b231986015e732aeb623d49f40b78cd (diff)
downloadqtlocation-mapboxgl-adb68b52f0b6b9065fb1bcd35f09630eb50525eb.tar.gz
Add unit tests for CameraToLatLngBoundsWithRotation and CameraToLatLngBoundsCrossDateLine.
-rw-r--r--test/map/map.test.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp
index 31cc85619e..e75fdf06da 100644
--- a/test/map/map.test.cpp
+++ b/test/map/map.test.cpp
@@ -252,6 +252,46 @@ TEST(Map, CameraToLatLngBounds) {
ASSERT_NEAR(camera.center->longitude(), virtualCamera.center->longitude(), 1e-7);
}
+TEST(Map, CameraToLatLngBoundsWithRotation) {
+ MapTest<> test;
+
+ test.map.jumpTo(CameraOptions().withCenter(LatLng{45, 90}).withZoom(16.0).withBearing(45.0));
+
+ const Size size = test.map.getMapOptions().size();
+
+ CameraOptions camera = test.map.getCameraOptions();
+
+ ASSERT_TRUE(test.map.latLngBoundsForCamera(camera).contains(test.map.latLngForPixel({})));
+ ASSERT_TRUE(test.map.latLngBoundsForCamera(camera).contains(test.map.latLngForPixel({0.0, double(size.height)})));
+ ASSERT_TRUE(test.map.latLngBoundsForCamera(camera).contains(test.map.latLngForPixel({double(size.width), 0.0})));
+ ASSERT_TRUE(test.map.latLngBoundsForCamera(camera).contains(
+ test.map.latLngForPixel({double(size.width), double(size.height)})));
+ ASSERT_TRUE(test.map.latLngBoundsForCamera(camera).contains(
+ test.map.latLngForPixel({double(size.width) / 2, double(size.height) / 2})));
+}
+
+TEST(Map, CameraToLatLngBoundsCrossDateLine) {
+ MapTest<> test;
+
+ test.map.jumpTo(CameraOptions().withCenter(LatLng{0, 180}).withZoom(16.0));
+
+ const Size size = test.map.getMapOptions().size();
+
+ CameraOptions camera = test.map.getCameraOptions();
+
+ ASSERT_TRUE(test.map.latLngBoundsForCamera(camera).contains(test.map.latLngForPixel({}), LatLng::Wrapped));
+ ASSERT_TRUE(test.map.latLngBoundsForCamera(camera).contains(test.map.latLngForPixel({0.0, double(size.height)}),
+ LatLng::Wrapped));
+ ASSERT_TRUE(test.map.latLngBoundsForCamera(camera).contains(test.map.latLngForPixel({double(size.width), 0.0}),
+ LatLng::Wrapped));
+ ASSERT_TRUE(test.map.latLngBoundsForCamera(camera).contains(
+ test.map.latLngForPixel({double(size.width), double(size.height)}), LatLng::Wrapped));
+ ASSERT_TRUE(test.map.latLngBoundsForCamera(camera).contains(
+ test.map.latLngForPixel({double(size.width) / 2, double(size.height) / 2})));
+
+ ASSERT_TRUE(test.map.latLngBoundsForCamera(camera).crossesAntimeridian());
+}
+
TEST(Map, Offline) {
MapTest<DefaultFileSource> test {":memory:", "."};