diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2016-01-08 13:05:51 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2016-01-08 13:05:51 +0100 |
commit | 4479f5db6c1ce26bc187a1b5a938f4bdb45915d4 (patch) | |
tree | 6344edec69099fe3bef3677ef465ca214066c1b1 /test | |
parent | bc309d84d77a5719a332f2dffdf24006d8610f97 (diff) | |
download | qtlocation-mapboxgl-4479f5db6c1ce26bc187a1b5a938f4bdb45915d4.tar.gz |
[core] don't consult cache for asset resources
Diffstat (limited to 'test')
-rw-r--r-- | test/storage/file_reading.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test/storage/file_reading.cpp b/test/storage/file_reading.cpp index 757decb612..a8ddd5a661 100644 --- a/test/storage/file_reading.cpp +++ b/test/storage/file_reading.cpp @@ -1,6 +1,7 @@ #include "storage.hpp" #include <mbgl/storage/online_file_source.hpp> +#include <mbgl/storage/sqlite_cache.hpp> #include <mbgl/platform/platform.hpp> #include <mbgl/util/chrono.hpp> #include <mbgl/util/run_loop.hpp> @@ -171,3 +172,44 @@ TEST_F(Storage, AssetNonExistentFile) { loop.run(); } + +TEST_F(Storage, AssetNotCached) { + SCOPED_TEST(NotCached) + + using namespace mbgl; + + const Resource resource { Resource::Unknown, "asset://TEST_DATA/fixtures/storage/nonempty" }; + + util::RunLoop loop; + + SQLiteCache cache(":memory:"); + + // Add a fake response to the cache to verify that we don't retrieve it. + { + auto response = std::make_shared<Response>(); + response->data = std::make_shared<const std::string>("cached data"); + cache.put(resource, response, FileCache::Hint::Full); + } + + OnlineFileSource fs(&cache, getFileSourceRoot()); + + std::unique_ptr<WorkRequest> workReq; + std::unique_ptr<FileRequest> req = fs.request(resource, [&](Response res) { + req.reset(); + + EXPECT_EQ(nullptr, res.error); + ASSERT_TRUE(res.data.get()); + EXPECT_EQ("content is here\n", *res.data); + + workReq = cache.get(resource, [&](std::shared_ptr<Response> response) { + // Check that we didn't put the file into the cache + ASSERT_TRUE(response->data.get()); + EXPECT_EQ(*response->data, "cached data"); + + loop.stop(); + NotCached.finish(); + }); + }); + + loop.run(); +} |