diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-01-13 17:10:13 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-02-10 15:40:20 -0800 |
commit | dbb8e58aea00a84716aafa6887b50c0186169f9e (patch) | |
tree | e981b82badcf800d6d33acac94d44a78f7b57776 /test | |
parent | f3d4107d19eef20cc2cf30cd347301128b4f9a86 (diff) | |
download | qtlocation-mapboxgl-dbb8e58aea00a84716aafa6887b50c0186169f9e.tar.gz |
[core] Moving caching logic to DefaultFileSource
This results in OnlineFileSource containing precisely the logic we want for reuse by OfflineFileSource, and no more.
Diffstat (limited to 'test')
-rw-r--r-- | test/api/annotations.cpp | 22 | ||||
-rw-r--r-- | test/api/api_misuse.cpp | 4 | ||||
-rw-r--r-- | test/api/custom_layer.cpp | 2 | ||||
-rw-r--r-- | test/api/set_style.cpp | 2 | ||||
-rw-r--r-- | test/map/map.cpp | 8 | ||||
-rw-r--r-- | test/map/map_context.cpp | 2 | ||||
-rw-r--r-- | test/storage/cache_response.cpp | 26 | ||||
-rw-r--r-- | test/storage/cache_revalidate.cpp | 12 | ||||
-rw-r--r-- | test/storage/http_cancel.cpp | 4 | ||||
-rw-r--r-- | test/storage/http_error.cpp | 4 | ||||
-rw-r--r-- | test/storage/http_header_parsing.cpp | 4 | ||||
-rw-r--r-- | test/storage/http_issue_1369.cpp | 7 | ||||
-rw-r--r-- | test/storage/http_load.cpp | 2 | ||||
-rw-r--r-- | test/storage/http_other_loop.cpp | 2 | ||||
-rw-r--r-- | test/storage/http_reading.cpp | 8 | ||||
-rw-r--r-- | test/storage/http_retry_network_status.cpp | 4 | ||||
-rw-r--r-- | test/storage/http_timeout.cpp | 2 |
17 files changed, 52 insertions, 63 deletions
diff --git a/test/api/annotations.cpp b/test/api/annotations.cpp index f427331eef..3e74d79d08 100644 --- a/test/api/annotations.cpp +++ b/test/api/annotations.cpp @@ -31,7 +31,7 @@ void checkRendering(Map& map, const char * name) { TEST(Annotations, PointAnnotation) { auto display = std::make_shared<mbgl::HeadlessDisplay>(); HeadlessView view(display, 1); - OnlineFileSource fileSource(nullptr); + OnlineFileSource fileSource; Map map(view, fileSource, MapMode::Still); map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), ""); @@ -44,7 +44,7 @@ TEST(Annotations, PointAnnotation) { TEST(Annotations, LineAnnotation) { auto display = std::make_shared<mbgl::HeadlessDisplay>(); HeadlessView view(display, 1); - OnlineFileSource fileSource(nullptr); + OnlineFileSource fileSource; Map map(view, fileSource, MapMode::Still); map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), ""); @@ -63,7 +63,7 @@ TEST(Annotations, LineAnnotation) { TEST(Annotations, FillAnnotation) { auto display = std::make_shared<mbgl::HeadlessDisplay>(); HeadlessView view(display, 1); - OnlineFileSource fileSource(nullptr); + OnlineFileSource fileSource; Map map(view, fileSource, MapMode::Still); map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), ""); @@ -81,7 +81,7 @@ TEST(Annotations, FillAnnotation) { TEST(Annotations, StyleSourcedShapeAnnotation) { auto display = std::make_shared<mbgl::HeadlessDisplay>(); HeadlessView view(display, 1); - OnlineFileSource fileSource(nullptr); + OnlineFileSource fileSource; Map map(view, fileSource, MapMode::Still); map.setStyleJSON(util::read_file("test/fixtures/api/annotation.json"), ""); @@ -96,7 +96,7 @@ TEST(Annotations, StyleSourcedShapeAnnotation) { TEST(Annotations, AddMultiple) { auto display = std::make_shared<mbgl::HeadlessDisplay>(); HeadlessView view(display, 1); - OnlineFileSource fileSource(nullptr); + OnlineFileSource fileSource; Map map(view, fileSource, MapMode::Still); map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), ""); @@ -113,7 +113,7 @@ TEST(Annotations, AddMultiple) { TEST(Annotations, NonImmediateAdd) { auto display = std::make_shared<mbgl::HeadlessDisplay>(); HeadlessView view(display, 1); - OnlineFileSource fileSource(nullptr); + OnlineFileSource fileSource; Map map(view, fileSource, MapMode::Still); map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), ""); @@ -133,7 +133,7 @@ TEST(Annotations, NonImmediateAdd) { TEST(Annotations, UpdatePoint) { auto display = std::make_shared<mbgl::HeadlessDisplay>(); HeadlessView view(display, 1); - OnlineFileSource fileSource(nullptr); + OnlineFileSource fileSource; Map map(view, fileSource, MapMode::Still); map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), ""); @@ -152,7 +152,7 @@ TEST(Annotations, UpdatePoint) { TEST(Annotations, RemovePoint) { auto display = std::make_shared<mbgl::HeadlessDisplay>(); HeadlessView view(display, 1); - OnlineFileSource fileSource(nullptr); + OnlineFileSource fileSource; Map map(view, fileSource, MapMode::Still); map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), ""); @@ -169,7 +169,7 @@ TEST(Annotations, RemovePoint) { TEST(Annotations, RemoveShape) { auto display = std::make_shared<mbgl::HeadlessDisplay>(); HeadlessView view(display, 1); - OnlineFileSource fileSource(nullptr); + OnlineFileSource fileSource; AnnotationSegments segments = {{ {{ { 0, 0 }, { 45, 45 } }} }}; @@ -191,7 +191,7 @@ TEST(Annotations, RemoveShape) { TEST(Annotations, ImmediateRemoveShape) { auto display = std::make_shared<mbgl::HeadlessDisplay>(); HeadlessView view(display, 1); - OnlineFileSource fileSource(nullptr); + OnlineFileSource fileSource; Map map(view, fileSource, MapMode::Still); map.removeAnnotation(map.addShapeAnnotation(ShapeAnnotation({}, {}))); @@ -203,7 +203,7 @@ TEST(Annotations, ImmediateRemoveShape) { TEST(Annotations, SwitchStyle) { auto display = std::make_shared<mbgl::HeadlessDisplay>(); HeadlessView view(display, 1); - OnlineFileSource fileSource(nullptr); + OnlineFileSource fileSource; Map map(view, fileSource, MapMode::Still); map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), ""); diff --git a/test/api/api_misuse.cpp b/test/api/api_misuse.cpp index 3ac6939b49..b1bfa5a59a 100644 --- a/test/api/api_misuse.cpp +++ b/test/api/api_misuse.cpp @@ -18,7 +18,7 @@ TEST(API, RenderWithoutCallback) { auto display = std::make_shared<mbgl::HeadlessDisplay>(); HeadlessView view(display, 1); view.resize(128, 512); - OnlineFileSource fileSource(nullptr); + OnlineFileSource fileSource; std::unique_ptr<Map> map = std::make_unique<Map>(view, fileSource, MapMode::Still); map->renderStill(nullptr); @@ -40,7 +40,7 @@ TEST(API, RenderWithoutStyle) { auto display = std::make_shared<mbgl::HeadlessDisplay>(); HeadlessView view(display, 1); view.resize(128, 512); - OnlineFileSource fileSource(nullptr); + OnlineFileSource fileSource; Map map(view, fileSource, MapMode::Still); diff --git a/test/api/custom_layer.cpp b/test/api/custom_layer.cpp index 923bf4566e..73258534d9 100644 --- a/test/api/custom_layer.cpp +++ b/test/api/custom_layer.cpp @@ -66,7 +66,7 @@ public: TEST(CustomLayer, Basic) { auto display = std::make_shared<mbgl::HeadlessDisplay>(); HeadlessView view(display, 1); - OnlineFileSource fileSource(nullptr); + OnlineFileSource fileSource; Map map(view, fileSource, MapMode::Still); map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), ""); diff --git a/test/api/set_style.cpp b/test/api/set_style.cpp index f5c1592516..befbf62210 100644 --- a/test/api/set_style.cpp +++ b/test/api/set_style.cpp @@ -12,7 +12,7 @@ TEST(API, SetStyle) { auto display = std::make_shared<mbgl::HeadlessDisplay>(); HeadlessView view(display, 1); - OnlineFileSource fileSource(nullptr); + OnlineFileSource fileSource; Log::setObserver(std::make_unique<FixtureLogObserver>()); diff --git a/test/map/map.cpp b/test/map/map.cpp index ed63bb085c..37caa95e97 100644 --- a/test/map/map.cpp +++ b/test/map/map.cpp @@ -12,7 +12,7 @@ TEST(Map, PauseResume) { auto display = std::make_shared<mbgl::HeadlessDisplay>(); HeadlessView view(display, 1); - OnlineFileSource fileSource(nullptr); + OnlineFileSource fileSource; Map map(view, fileSource, MapMode::Continuous); @@ -25,7 +25,7 @@ TEST(Map, DoublePause) { auto display = std::make_shared<mbgl::HeadlessDisplay>(); HeadlessView view(display, 1); - OnlineFileSource fileSource(nullptr); + OnlineFileSource fileSource; Map map(view, fileSource, MapMode::Continuous); @@ -39,7 +39,7 @@ TEST(Map, ResumeWithoutPause) { auto display = std::make_shared<mbgl::HeadlessDisplay>(); HeadlessView view(display, 1); - OnlineFileSource fileSource(nullptr); + OnlineFileSource fileSource; Map map(view, fileSource, MapMode::Continuous); @@ -51,7 +51,7 @@ TEST(Map, DestroyPaused) { auto display = std::make_shared<mbgl::HeadlessDisplay>(); HeadlessView view(display, 1); - OnlineFileSource fileSource(nullptr); + OnlineFileSource fileSource; Map map(view, fileSource, MapMode::Continuous); diff --git a/test/map/map_context.cpp b/test/map/map_context.cpp index 60cb3d6b7f..2f3576a3b5 100644 --- a/test/map/map_context.cpp +++ b/test/map/map_context.cpp @@ -12,7 +12,7 @@ using namespace mbgl; TEST(MapContext, DoubleStyleLoad) { std::shared_ptr<HeadlessDisplay> display = std::make_shared<HeadlessDisplay>(); HeadlessView view(display, 1, 512, 512); - OnlineFileSource fileSource(nullptr); + OnlineFileSource fileSource; util::Thread<MapContext> context({"Map", util::ThreadType::Map, util::ThreadPriority::Regular}, view, fileSource, MapMode::Continuous, GLContextMode::Unique, view.getPixelRatio()); diff --git a/test/storage/cache_response.cpp b/test/storage/cache_response.cpp index aa5e5dbfcf..adeb45727e 100644 --- a/test/storage/cache_response.cpp +++ b/test/storage/cache_response.cpp @@ -1,6 +1,6 @@ #include "storage.hpp" -#include <mbgl/storage/online_file_source.hpp> +#include <mbgl/storage/default_file_source.hpp> #include <mbgl/storage/sqlite_cache.hpp> #include <mbgl/util/chrono.hpp> #include <mbgl/util/run_loop.hpp> @@ -11,8 +11,7 @@ TEST_F(Storage, CacheResponse) { using namespace mbgl; util::RunLoop loop; - SQLiteCache cache(":memory:"); - OnlineFileSource fs(&cache); + DefaultFileSource fs(":memory:", "."); const Resource resource { Resource::Unknown, "http://127.0.0.1:3000/cache" }; Response response; @@ -56,15 +55,14 @@ TEST_F(Storage, CacheNotFound) { using namespace mbgl; util::RunLoop loop; - SQLiteCache cache(":memory:"); - OnlineFileSource fs(&cache); + DefaultFileSource fs(":memory:", "."); const Resource resource{ Resource::Unknown, "http://127.0.0.1:3000/not-found" }; // Insert existing data into the cache that will be marked as stale. Response response; response.data = std::make_shared<const std::string>("existing data"); - cache.put(resource, response); + fs.getCache().put(resource, response); std::unique_ptr<FileRequest> req1; std::unique_ptr<WorkRequest> req2; @@ -89,7 +87,7 @@ TEST_F(Storage, CacheNotFound) { req1.reset(); // Finally, check the cache to make sure we cached the 404 response. - req2 = cache.get(resource, [&](std::unique_ptr<Response> res2) { + req2 = fs.getCache().get(resource, [&](std::unique_ptr<Response> res2) { EXPECT_NE(nullptr, res2->error); EXPECT_EQ(Response::Error::Reason::NotFound, res2->error->reason); ASSERT_TRUE(res2->data.get()); @@ -113,15 +111,14 @@ TEST_F(Storage, DontCacheConnectionErrors) { using namespace mbgl; util::RunLoop loop; - SQLiteCache cache(":memory:"); - OnlineFileSource fs(&cache); + DefaultFileSource fs(":memory:", "."); const Resource resource{ Resource::Unknown, "http://127.0.0.1:3001" }; // Insert existing data into the cache that will be marked as stale. Response response; response.data = std::make_shared<const std::string>("existing data"); - cache.put(resource, response); + fs.getCache().put(resource, response); std::unique_ptr<FileRequest> req1; std::unique_ptr<WorkRequest> req2; @@ -145,7 +142,7 @@ TEST_F(Storage, DontCacheConnectionErrors) { // Finally, check the cache to make sure we still have our original data in there rather // than the failed connection attempt. - req2 = cache.get(resource, [&](std::unique_ptr<Response> res2) { + req2 = fs.getCache().get(resource, [&](std::unique_ptr<Response> res2) { EXPECT_EQ(nullptr, res2->error); ASSERT_TRUE(res2->data.get()); EXPECT_EQ("existing data", *res2->data); @@ -168,15 +165,14 @@ TEST_F(Storage, DontCacheServerErrors) { using namespace mbgl; util::RunLoop loop; - SQLiteCache cache(":memory:"); - OnlineFileSource fs(&cache); + DefaultFileSource fs(":memory:", "."); const Resource resource{ Resource::Unknown, "http://127.0.0.1:3000/permanent-error" }; // Insert existing data into the cache that will be marked as stale. Response response; response.data = std::make_shared<const std::string>("existing data"); - cache.put(resource, response); + fs.getCache().put(resource, response); std::unique_ptr<FileRequest> req1; std::unique_ptr<WorkRequest> req2; @@ -202,7 +198,7 @@ TEST_F(Storage, DontCacheServerErrors) { // Finally, check the cache to make sure we still have our original data in there rather // than the failed connection attempt. - req2 = cache.get(resource, [&](std::unique_ptr<Response> res2) { + req2 = fs.getCache().get(resource, [&](std::unique_ptr<Response> res2) { EXPECT_EQ(nullptr, res2->error); ASSERT_TRUE(res2->data.get()); EXPECT_EQ("existing data", *res2->data); diff --git a/test/storage/cache_revalidate.cpp b/test/storage/cache_revalidate.cpp index 10dee80a00..e769e934d5 100644 --- a/test/storage/cache_revalidate.cpp +++ b/test/storage/cache_revalidate.cpp @@ -1,7 +1,6 @@ #include "storage.hpp" -#include <mbgl/storage/online_file_source.hpp> -#include <mbgl/storage/sqlite_cache.hpp> +#include <mbgl/storage/default_file_source.hpp> #include <mbgl/util/chrono.hpp> #include <mbgl/util/run_loop.hpp> @@ -11,8 +10,7 @@ TEST_F(Storage, CacheRevalidateSame) { using namespace mbgl; util::RunLoop loop; - SQLiteCache cache(":memory:"); - OnlineFileSource fs(&cache); + DefaultFileSource fs(":memory:", "."); const Resource revalidateSame { Resource::Unknown, "http://127.0.0.1:3000/revalidate-same" }; std::unique_ptr<FileRequest> req1; @@ -61,8 +59,7 @@ TEST_F(Storage, CacheRevalidateModified) { using namespace mbgl; util::RunLoop loop; - SQLiteCache cache(":memory:"); - OnlineFileSource fs(&cache); + DefaultFileSource fs(":memory:", "."); const Resource revalidateModified{ Resource::Unknown, "http://127.0.0.1:3000/revalidate-modified" }; @@ -111,8 +108,7 @@ TEST_F(Storage, CacheRevalidateEtag) { using namespace mbgl; util::RunLoop loop; - SQLiteCache cache(":memory:"); - OnlineFileSource fs(&cache); + DefaultFileSource fs(":memory:", "."); const Resource revalidateEtag { Resource::Unknown, "http://127.0.0.1:3000/revalidate-etag" }; std::unique_ptr<FileRequest> req1; diff --git a/test/storage/http_cancel.cpp b/test/storage/http_cancel.cpp index 4d816c5095..983bc22b16 100644 --- a/test/storage/http_cancel.cpp +++ b/test/storage/http_cancel.cpp @@ -13,7 +13,7 @@ TEST_F(Storage, HTTPCancel) { using namespace mbgl; util::RunLoop loop; - OnlineFileSource fs(nullptr); + OnlineFileSource fs; auto req = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/test" }, @@ -31,7 +31,7 @@ TEST_F(Storage, HTTPCancelMultiple) { using namespace mbgl; util::RunLoop loop; - OnlineFileSource fs(nullptr); + OnlineFileSource fs; const Resource resource { Resource::Unknown, "http://127.0.0.1:3000/test" }; diff --git a/test/storage/http_error.cpp b/test/storage/http_error.cpp index 28e8573a2c..3f29e5c745 100644 --- a/test/storage/http_error.cpp +++ b/test/storage/http_error.cpp @@ -13,7 +13,7 @@ TEST_F(Storage, HTTPTemporaryError) { using namespace mbgl; util::RunLoop loop; - OnlineFileSource fs(nullptr); + OnlineFileSource fs; const auto start = Clock::now(); @@ -58,7 +58,7 @@ TEST_F(Storage, HTTPConnectionError) { using namespace mbgl; util::RunLoop loop; - OnlineFileSource fs(nullptr); + OnlineFileSource fs; const auto start = Clock::now(); diff --git a/test/storage/http_header_parsing.cpp b/test/storage/http_header_parsing.cpp index 521fa239e6..d98b09924f 100644 --- a/test/storage/http_header_parsing.cpp +++ b/test/storage/http_header_parsing.cpp @@ -12,7 +12,7 @@ TEST_F(Storage, HTTPExpiresParsing) { using namespace mbgl; util::RunLoop loop; - OnlineFileSource fs(nullptr); + OnlineFileSource fs; std::unique_ptr<FileRequest> req1 = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/test?modified=1420794326&expires=1420797926&etag=foo" }, @@ -37,7 +37,7 @@ TEST_F(Storage, HTTPCacheControlParsing) { using namespace mbgl; util::RunLoop loop; - OnlineFileSource fs(nullptr); + OnlineFileSource fs; std::unique_ptr<FileRequest> req2 = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/test?cachecontrol=max-age=120" }, [&](Response res) { diff --git a/test/storage/http_issue_1369.cpp b/test/storage/http_issue_1369.cpp index 17c6f86f74..3830a51718 100644 --- a/test/storage/http_issue_1369.cpp +++ b/test/storage/http_issue_1369.cpp @@ -1,8 +1,6 @@ #include "storage.hpp" -#include <mbgl/storage/online_file_source.hpp> -#include <mbgl/storage/sqlite_cache.hpp> -#include <mbgl/util/chrono.hpp> +#include <mbgl/storage/default_file_source.hpp> #include <mbgl/util/run_loop.hpp> // Test for https://github.com/mapbox/mapbox-gl-native/issue/1369 @@ -22,8 +20,7 @@ TEST_F(Storage, HTTPIssue1369) { using namespace mbgl; util::RunLoop loop; - SQLiteCache cache; - OnlineFileSource fs(&cache); + DefaultFileSource fs(":memory:", "."); const Resource resource { Resource::Unknown, "http://127.0.0.1:3000/test" }; diff --git a/test/storage/http_load.cpp b/test/storage/http_load.cpp index 8088bb5e34..52f700c4f8 100644 --- a/test/storage/http_load.cpp +++ b/test/storage/http_load.cpp @@ -10,7 +10,7 @@ TEST_F(Storage, HTTPLoad) { using namespace mbgl; util::RunLoop loop; - OnlineFileSource fs(nullptr); + OnlineFileSource fs; const int concurrency = 50; const int max = 10000; diff --git a/test/storage/http_other_loop.cpp b/test/storage/http_other_loop.cpp index fda51c3cf3..4eb6a7df18 100644 --- a/test/storage/http_other_loop.cpp +++ b/test/storage/http_other_loop.cpp @@ -11,7 +11,7 @@ TEST_F(Storage, HTTPOtherLoop) { // This file source launches a separate thread to do the processing. util::RunLoop loop; - OnlineFileSource fs(nullptr); + OnlineFileSource fs; std::unique_ptr<FileRequest> req = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/test" }, [&](Response res) { diff --git a/test/storage/http_reading.cpp b/test/storage/http_reading.cpp index 4d8d510615..36fbf43a14 100644 --- a/test/storage/http_reading.cpp +++ b/test/storage/http_reading.cpp @@ -14,7 +14,7 @@ TEST_F(Storage, HTTPTest) { using namespace mbgl; util::RunLoop loop; - OnlineFileSource fs(nullptr); + OnlineFileSource fs; std::unique_ptr<FileRequest> req1 = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/test" }, [&](Response res) { @@ -39,7 +39,7 @@ TEST_F(Storage, HTTP404) { using namespace mbgl; util::RunLoop loop; - OnlineFileSource fs(nullptr); + OnlineFileSource fs; std::unique_ptr<FileRequest> req2 = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/doesnotexist" }, [&](Response res) { @@ -66,7 +66,7 @@ TEST_F(Storage, HTTP500) { using namespace mbgl; util::RunLoop loop; - OnlineFileSource fs(nullptr); + OnlineFileSource fs; std::unique_ptr<FileRequest> req3 = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/permanent-error" }, [&](Response res) { @@ -93,7 +93,7 @@ TEST_F(Storage, HTTPNoCallback) { using namespace mbgl; util::RunLoop loop; - OnlineFileSource fs(nullptr); + OnlineFileSource fs; try { fs.request({ Resource::Unknown, "http://127.0.0.1:3000/test" }, diff --git a/test/storage/http_retry_network_status.cpp b/test/storage/http_retry_network_status.cpp index df9284f995..bf875cbd57 100644 --- a/test/storage/http_retry_network_status.cpp +++ b/test/storage/http_retry_network_status.cpp @@ -18,7 +18,7 @@ TEST_F(Storage, HTTPNetworkStatusChange) { using namespace mbgl; util::RunLoop loop; - OnlineFileSource fs(nullptr); + OnlineFileSource fs; const Resource resource { Resource::Unknown, "http://127.0.0.1:3000/delayed" }; @@ -57,7 +57,7 @@ TEST_F(Storage, HTTPNetworkStatusChangePreempt) { using namespace mbgl; util::RunLoop loop; - OnlineFileSource fs(nullptr); + OnlineFileSource fs; const auto start = Clock::now(); diff --git a/test/storage/http_timeout.cpp b/test/storage/http_timeout.cpp index 8f8a5e2633..ef0750010e 100644 --- a/test/storage/http_timeout.cpp +++ b/test/storage/http_timeout.cpp @@ -11,7 +11,7 @@ TEST_F(Storage, HTTPTimeout) { using namespace mbgl; util::RunLoop loop; - OnlineFileSource fs(nullptr); + OnlineFileSource fs; int counter = 0; |