summaryrefslogtreecommitdiff
path: root/test/style/custom_vector_source.test.cpp
blob: 2456a46fb3d10cd11779be3e721b08e0784da675 (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
#include <mbgl/test/util.hpp>
#include <mbgl/style/sources/geojson_source.hpp>

#include <mbgl/util/geo.hpp>

#include <mbgl/style/sources/custom_vector_source.hpp>

using namespace mbgl;


TEST(CustomVectorSource, EmptyData) {
    mbgl::style::GeoJSONOptions options;

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
    const auto callback = ^void(uint8_t z, uint32_t x, uint32_t y) {};
#pragma clang diagnostic pop

    auto testSource = std::make_unique<mbgl::style::CustomVectorSource>("source", options,  callback);

    mbgl::FeatureCollection featureCollection;
    testSource->setTileData(0, 0, 0, mbgl::GeoJSON{featureCollection});
}

TEST(CustomVectorSource, Geometry) {
    mbgl::style::GeoJSONOptions options;

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
    const auto callback = ^void(uint8_t z, uint32_t x, uint32_t y) {};
#pragma clang diagnostic pop

    auto testSource = std::make_unique<mbgl::style::CustomVectorSource>("source", options,  callback);

    Polygon<double> polygon = {{ {{ { 0, 0 }, { 0, 45 }, { 45, 45 }, { 45, 0 } }} }};
    testSource->setTileData(0, 0, 0, mbgl::GeoJSON{polygon});
}

TEST(CustomVectorSource, ReloadWithNoTiles) {
    mbgl::style::GeoJSONOptions options;

    __block bool called = false;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
    const auto callback = ^void(uint8_t z, uint32_t x, uint32_t y) {
        called = true;
    };
#pragma clang diagnostic pop

    auto testSource = std::make_unique<mbgl::style::CustomVectorSource>("source", options,  callback);
    testSource->reloadRegion(mbgl::LatLngBounds::world(), 0);
    EXPECT_EQ(called, false);
}