summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2017-02-17 18:20:58 +0100
committerKonstantin Käfer <mail@kkaefer.com>2017-02-20 14:36:27 +0100
commitf0ec9fb74b18d3346a477798af72c4c37c976d4e (patch)
treebead8a53ea27972db58e5d3fb1e3360f54abf312 /test
parent9ad29af400c6172dc13ce1b18a73a47e8fb66e28 (diff)
downloadqtlocation-mapboxgl-f0ec9fb74b18d3346a477798af72c4c37c976d4e.tar.gz
[test] add unit test for DefaultFileSource::setResourceTransform()
Diffstat (limited to 'test')
-rw-r--r--test/storage/default_file_source.test.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/storage/default_file_source.test.cpp b/test/storage/default_file_source.test.cpp
index f4c23c4c7a..ffbeea1096 100644
--- a/test/storage/default_file_source.test.cpp
+++ b/test/storage/default_file_source.test.cpp
@@ -460,3 +460,33 @@ TEST(DefaultFileSource, TEST_REQUIRES_SERVER(NoCacheRefreshModifiedModified)) {
loop.run();
}
+
+TEST(DefaultFileSource, TEST_REQUIRES_SERVER(SetResourceTransform)) {
+ util::RunLoop loop;
+ DefaultFileSource fs(":memory:", ".");
+
+ // Translates the URL "localhost://test to http://127.0.0.1:3000/test
+ fs.setResourceTransform([](Resource::Kind, std::string&& url) -> std::string {
+ if (url == "localhost://test") {
+ return "http://127.0.0.1:3000/test";
+ } else {
+ return std::move(url);
+ }
+ });
+
+ const Resource resource { Resource::Unknown, "localhost://test" };
+
+ std::unique_ptr<AsyncRequest> req;
+ req = fs.request(resource, [&](Response res) {
+ req.reset();
+ EXPECT_EQ(nullptr, res.error);
+ ASSERT_TRUE(res.data.get());
+ EXPECT_EQ("Hello World!", *res.data);
+ EXPECT_FALSE(bool(res.expires));
+ EXPECT_FALSE(bool(res.modified));
+ EXPECT_FALSE(bool(res.etag));
+ loop.stop();
+ });
+
+ loop.run();
+}