diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2017-03-30 16:25:12 +0300 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2017-04-11 12:51:09 +0300 |
commit | c1c6c1e298521c177b64665b823d1444ce5e2cfe (patch) | |
tree | c5decfae633986d01579e731be2a78ec04d72542 /test/map | |
parent | bc7f6da1356fdfc22d8fa1d5f76821ab171647eb (diff) | |
download | qtlocation-mapboxgl-c1c6c1e298521c177b64665b823d1444ce5e2cfe.tar.gz |
[core] Added Map::{get,set}LatLngBounds
Diffstat (limited to 'test/map')
-rw-r--r-- | test/map/transform.test.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/map/transform.test.cpp b/test/map/transform.test.cpp index a8869b41bf..caee0ba23d 100644 --- a/test/map/transform.test.cpp +++ b/test/map/transform.test.cpp @@ -534,3 +534,42 @@ TEST(Transform, DefaultTransform) { ASSERT_DOUBLE_EQ(point.x, center.x); ASSERT_DOUBLE_EQ(point.y, center.y); } + +TEST(Transform, LatLngBounds) { + const LatLng nullIsland {}; + const LatLng sanFrancisco { 37.7749, -122.4194 }; + + Transform transform; + transform.resize({ 1000, 1000 }); + transform.setLatLngZoom({ 0, 0 }, transform.getState().getMaxZoom()); + + // Default bounds. + ASSERT_EQ(transform.getState().getLatLngBounds(), LatLngBounds::world()); + ASSERT_EQ(transform.getLatLng(), nullIsland); + + // Invalid bounds. + transform.setLatLngBounds(LatLngBounds::empty()); + ASSERT_EQ(transform.getState().getLatLngBounds(), LatLngBounds::world()); + + transform.setLatLng(sanFrancisco); + ASSERT_EQ(transform.getLatLng(), sanFrancisco); + + // Single location. + transform.setLatLngBounds(LatLngBounds::singleton(sanFrancisco)); + ASSERT_EQ(transform.getLatLng(), sanFrancisco); + + transform.setLatLngBounds(LatLngBounds::hull({ -90.0, -180.0 }, { 0.0, 180.0 })); + transform.setLatLng(sanFrancisco); + ASSERT_EQ(transform.getLatLng().latitude(), 0.0); + ASSERT_EQ(transform.getLatLng().longitude(), sanFrancisco.longitude()); + + transform.setLatLngBounds(LatLngBounds::hull({ -90.0, 0.0 }, { 90.0, 180.0 })); + transform.setLatLng(sanFrancisco); + ASSERT_EQ(transform.getLatLng().latitude(), sanFrancisco.latitude()); + ASSERT_EQ(transform.getLatLng().longitude(), 0.0); + + transform.setLatLngBounds(LatLngBounds::hull({ -90.0, 0.0 }, { 0.0, 180.0 })); + transform.setLatLng(sanFrancisco); + ASSERT_EQ(transform.getLatLng().latitude(), 0.0); + ASSERT_EQ(transform.getLatLng().longitude(), 0.0); +} |