diff options
Diffstat (limited to 'test/algorithm/mock.hpp')
-rw-r--r-- | test/algorithm/mock.hpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/test/algorithm/mock.hpp b/test/algorithm/mock.hpp new file mode 100644 index 0000000000..89f51b15b8 --- /dev/null +++ b/test/algorithm/mock.hpp @@ -0,0 +1,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 |