blob: 89f51b15b8d7ed682bf901b2a0a76bfa56707222 (
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
|
#ifndef MBGL_TEST_MOCK
#define MBGL_TEST_MOCK
#include <cstdint>
#include <string>
#include <memory>
#include <set>
#include <map>
#include <mbgl/tile/tile_id.hpp>
struct MockSourceInfo {
uint8_t maxZoom = 16;
uint8_t minZoom = 0;
};
struct MockTileData;
struct MockRenderable {
MockRenderable(mbgl::UnwrappedTileID id_, MockTileData& data_) : id(id_), data(data_) {}
const mbgl::UnwrappedTileID id;
MockTileData& data;
bool operator==(const MockRenderable& rhs) const {
return &data == &rhs.data;
}
};
::std::ostream& operator<<(::std::ostream& os, const MockRenderable&) {
return os << "Renderable{}";
}
struct MockSource {
MockSourceInfo info;
std::map<mbgl::OverscaledTileID, std::unique_ptr<MockTileData>> dataTiles;
std::set<mbgl::UnwrappedTileID> idealTiles;
std::map<mbgl::UnwrappedTileID, MockRenderable> renderables;
// Test API
inline MockTileData* createTileData(const mbgl::OverscaledTileID& tileID);
};
struct MockBucket {};
struct MockTileData {
bool isReady() {
return ready;
}
bool ready = false;
};
MockTileData* MockSource::createTileData(const mbgl::OverscaledTileID& tileID) {
// Replace the existing MockTileData object, if any.
return (dataTiles[tileID] = std::make_unique<MockTileData>()).get();
}
#endif
|