summaryrefslogtreecommitdiff
path: root/test/tile/geojson_tile.test.cpp
blob: e2a026b5609f4f047331318b46baeccd2fc09875 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <mbgl/test/util.hpp>
#include <mbgl/test/fake_file_source.hpp>
#include <mbgl/test/stub_tile_observer.hpp>
#include <mbgl/tile/geojson_tile.hpp>
#include <mbgl/tile/tile_loader_impl.hpp>

#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/util/run_loop.hpp>
#include <mbgl/map/transform.hpp>
#include <mbgl/style/style.hpp>
#include <mbgl/style/update_parameters.hpp>
#include <mbgl/style/layers/circle_layer.hpp>
#include <mbgl/annotation/annotation_manager.hpp>

#include <memory>

using namespace mbgl;
using namespace mbgl::style;

class GeoJSONTileTest {
public:
    FakeFileSource fileSource;
    TransformState transformState;
    util::RunLoop loop;
    ThreadPool threadPool { 1 };
    AnnotationManager annotationManager { 1.0 };
    style::Style style { threadPool, fileSource, 1.0 };
    Tileset tileset { { "https://example.com" }, { 0, 22 }, "none" };

    style::UpdateParameters updateParameters {
        1.0,
        MapDebugOptions(),
        transformState,
        threadPool,
        fileSource,
        MapMode::Continuous,
        annotationManager,
        style
    };
};

TEST(GeoJSONTile, Issue7648) {
    GeoJSONTileTest test;
    GeoJSONTile tile(OverscaledTileID(0, 0, 0), "source", test.updateParameters);

    test.style.addLayer(std::make_unique<CircleLayer>("circle", "source"));

    StubTileObserver observer;
    observer.tileChanged = [&] (const Tile&) {
        // Once present, the bucket should never "disappear", which would cause
        // flickering.
        ASSERT_NE(nullptr, tile.getBucket(*test.style.getLayer("circle")));
    };
    tile.setObserver(&observer);

    tile.setPlacementConfig({});

    mapbox::geometry::feature_collection<int16_t> features;
    features.push_back(mapbox::geometry::feature<int16_t> {
        mapbox::geometry::point<int16_t>(0, 0)
    });

    tile.updateData(features);
    while (!tile.isComplete()) {
        test.loop.runOnce();
    }

    tile.updateData(features);
    while (!tile.isComplete()) {
        test.loop.runOnce();
    }
}