summaryrefslogtreecommitdiff
path: root/test/fixtures/mock_file_source.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/fixtures/mock_file_source.hpp')
-rw-r--r--test/fixtures/mock_file_source.hpp55
1 files changed, 0 insertions, 55 deletions
diff --git a/test/fixtures/mock_file_source.hpp b/test/fixtures/mock_file_source.hpp
deleted file mode 100644
index 245e0da0eb..0000000000
--- a/test/fixtures/mock_file_source.hpp
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef TEST_RESOURCES_MOCK_FILE_SOURCE
-#define TEST_RESOURCES_MOCK_FILE_SOURCE
-
-#include <mbgl/storage/file_source.hpp>
-#include <mbgl/util/timer.hpp>
-
-#include <string>
-#include <unordered_map>
-
-namespace mbgl {
-
-// The MockFileSource is a FileSource that can simulate different
-// types of failures and it will work completely offline.
-class MockFileSource : public FileSource {
-public:
- // Success:
- // Will reply to every request correctly with valid data.
- //
- // RequestFail:
- // Will reply with an error to requests that contains
- // the "match" string on the URL.
- //
- // RequestWithCorruptedData:
- // Will answer every request successfully but will return
- // corrupt data on the requests that contains the "match"
- // string on the URL.
- enum Type {
- Success,
- RequestFail,
- RequestWithCorruptedData
- };
-
- MockFileSource(Type, const std::string& match);
- ~MockFileSource() override;
-
- // Function that gets called when a matching resource is enqueued.
- std::function<void (void)> requestEnqueuedCallback;
-
- // FileSource implementation.
- std::unique_ptr<FileRequest> request(const Resource&, Callback) override;
-
-private:
- void respond(Resource, Callback) const;
-
- friend class MockFileRequest;
-
- Type type;
- std::string match;
- std::unordered_map<FileRequest*, std::pair<Resource, Callback>> pending;
- util::Timer timer;
-};
-
-}
-
-#endif