Files
MapLibreParticleLab/test/resources/mock_file_source.hpp
Thiago Marcos P. Santos 6ef6591a52 Add MockFileSource and MockView for testing the ResourceLoader
- MockFileSource
  Will load pre-defined resources from the filesystem. It supports
  passing a string, that when it matches an URL, will simulate a failure.

- MockView
  It is just a no-op to not get in the way when testing
  resource loading.

Few more additions:

- style.json
  Specially crafted style that will look always for the same tile,
  glyph range, etc at the "test/fixtures/resources/" path. No matter
  where you look (or at what zoom), you always get the same stuff.

- vector.pbf
  This taken from a part of Taipei that will request several glyph
  ranges.
2015-05-22 10:44:18 +03:00

34 lines
720 B
C++

#ifndef TEST_RESOURCES_MOCK_FILE_SOURCE
#define TEST_RESOURCES_MOCK_FILE_SOURCE
#include <mbgl/storage/file_source.hpp>
#include <string>
namespace mbgl {
namespace util {
template <typename T> class Thread;
}
// This mock FileSource will read data from the disk and will fail
// the request if the URL matches the 'matchFail' string.
class MockFileSource : public FileSource {
public:
class Impl;
MockFileSource(const std::string& matchFail);
~MockFileSource() override = default;
// FileSource implementation.
Request* request(const Resource&, uv_loop_t*, Callback) override;
void cancel(Request*) override;
private:
const std::unique_ptr<util::Thread<Impl>> thread_;
};
}
#endif