From 0cf450e3e529423737c6b4aa196b271442530345 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Wed, 10 Feb 2016 13:22:09 -0800 Subject: [core] Retry errors encountered during offline downloads --- test/storage/offline_download.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'test/storage') diff --git a/test/storage/offline_download.cpp b/test/storage/offline_download.cpp index d89d4a035c..6de14d37b2 100644 --- a/test/storage/offline_download.cpp +++ b/test/storage/offline_download.cpp @@ -300,3 +300,35 @@ TEST(OfflineDownload, RequestError) { test.loop.run(); } + +TEST(OfflineDownload, RequestErrorsAreRetried) { + OfflineTest test; + OfflineDownload download( + 1, + OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/offline/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0), + test.db, test.fileSource); + + test.fileSource.styleResponse = [&] (const Resource&) { + test.fileSource.styleResponse = [&] (const Resource&) { + return test.response("offline/empty.style.json"); + }; + + Response response; + response.error = std::make_unique(Response::Error::Reason::Connection, "connection error"); + return response; + }; + + auto observer = std::make_unique(); + + observer->statusChangedFn = [&] (OfflineRegionStatus status) { + if (status.complete()) { + EXPECT_EQ(1, status.completedResourceCount); + test.loop.stop(); + } + }; + + download.setObserver(std::move(observer)); + download.setState(OfflineRegionDownloadState::Active); + + test.loop.run(); +} -- cgit v1.2.1