summaryrefslogtreecommitdiff
path: root/test/storage/offline.test.cpp
blob: 90f95703202e8196f3e270f974749d127ebe309a (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
#include <mbgl/storage/offline.hpp>
#include <mbgl/tile/tile_id.hpp>

#include <gtest/gtest.h>

using namespace mbgl;
using SourceType = mbgl::style::SourceType;


TEST(OfflineTilePyramidRegionDefinition, EncodeDecode) {
    OfflineTilePyramidRegionDefinition region("mapbox://style", LatLngBounds::hull({ 37.6609, -122.5744 }, { 37.8271, -122.3204 }), 0, 20, 1.0);

    auto encoded = encodeOfflineRegionDefinition(region);
    auto decoded = decodeOfflineRegionDefinition(encoded).get<OfflineTilePyramidRegionDefinition>();
    
    EXPECT_EQ(decoded.styleURL, region.styleURL);
    EXPECT_EQ(decoded.minZoom, region.minZoom);
    EXPECT_EQ(decoded.maxZoom, region.maxZoom);
    EXPECT_EQ(decoded.pixelRatio, region.pixelRatio);
    EXPECT_EQ(decoded.bounds.southwest(), region.bounds.southwest());
    EXPECT_EQ(decoded.bounds.northeast(), region.bounds.northeast());
}

TEST(OfflineGeometryRegionDefinition, EncodeDecode) {
    OfflineGeometryRegionDefinition region("mapbox://style", Point<double>(-122.5744, 37.6609), 0, 2, 1.0);

    auto encoded = encodeOfflineRegionDefinition(region);
    auto decoded = decodeOfflineRegionDefinition(encoded).get<OfflineGeometryRegionDefinition>();
    
    EXPECT_EQ(decoded.styleURL, region.styleURL);
    EXPECT_EQ(decoded.minZoom, region.minZoom);
    EXPECT_EQ(decoded.maxZoom, region.maxZoom);
    EXPECT_EQ(decoded.pixelRatio, region.pixelRatio);
    EXPECT_EQ(decoded.geometry, region.geometry);
}