summaryrefslogtreecommitdiff
path: root/test/tile
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2017-03-13 16:16:38 +0200
committerBruno de Oliveira Abinader <bruno@mapbox.com>2017-03-15 14:53:32 +0200
commitfc70cbf1e12e27737c7a256682524cd617d18f71 (patch)
tree10bf1b6c629bb4c642d060182ab1443cdf0084a4 /test/tile
parent98f5b71e6db748a2576e9fc6f17b9e76505df1aa (diff)
downloadqtlocation-mapboxgl-fc70cbf1e12e27737c7a256682524cd617d18f71.tar.gz
[core] Replace MapChange enum with MapObserver
Diffstat (limited to 'test/tile')
-rw-r--r--test/tile/tile_coordinate.test.cpp31
1 files changed, 24 insertions, 7 deletions
diff --git a/test/tile/tile_coordinate.test.cpp b/test/tile/tile_coordinate.test.cpp
index 4d58bf8c51..d1bef85cb5 100644
--- a/test/tile/tile_coordinate.test.cpp
+++ b/test/tile/tile_coordinate.test.cpp
@@ -1,6 +1,5 @@
#include <mbgl/test/util.hpp>
-#include <mbgl/map/change.hpp>
#include <mbgl/map/transform.hpp>
#include <mbgl/map/transform_state.hpp>
#include <mbgl/tile/tile.hpp>
@@ -13,17 +12,35 @@
using namespace mbgl;
TEST(TileCoordinate, FromLatLng) {
+
size_t changeCount = 0;
- std::vector<MapChange> changes = {
- MapChangeRegionWillChange,
- MapChangeRegionDidChange,
+ struct TransformObserver : public mbgl::MapObserver {
+ void onCameraWillChange(MapObserver::CameraChangeMode mode) final {
+ if (mode == MapObserver::CameraChangeMode::Immediate && cameraWillChangeImmediateCallback) {
+ cameraWillChangeImmediateCallback();
+ }
+ }
+
+ void onCameraDidChange(MapObserver::CameraChangeMode mode) final {
+ if (mode == MapObserver::CameraChangeMode::Immediate && cameraDidChangeImmediateCallback) {
+ cameraDidChangeImmediateCallback();
+ }
+ }
+
+ std::function<void()> cameraWillChangeImmediateCallback;
+ std::function<void()> cameraDidChangeImmediateCallback;
};
- auto onMapChange = [&](MapChange change) {
- ASSERT_EQ(change, changes[changeCount]);
+
+ TransformObserver observer;
+ observer.cameraWillChangeImmediateCallback = [&]() {
+ ASSERT_EQ(changeCount, 0u);
++changeCount;
};
+ observer.cameraDidChangeImmediateCallback = [&]() {
+ ASSERT_EQ(changeCount, 1u);
+ };
- Transform transform(onMapChange);
+ Transform transform(observer);
const double max = util::tileSize;
transform.resize({ static_cast<uint32_t>(max), static_cast<uint32_t>(max) });