summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-03-07 17:54:45 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-03-07 19:08:03 -0800
commita3791b2325a4a2e7c38b9a41404f231faf6c3ed5 (patch)
treed83d9ff5e4997eddc4e06bd97b8d1c5936658501 /test
parentc5f85bf9e7648b2c760a1a0425df68d782316e36 (diff)
downloadqtlocation-mapboxgl-a3791b2325a4a2e7c38b9a41404f231faf6c3ed5.tar.gz
[core] Ensure OfflineRegionStatus::downloadState is accurately reported
Diffstat (limited to 'test')
-rw-r--r--test/storage/offline_download.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/storage/offline_download.cpp b/test/storage/offline_download.cpp
index 15980e2fdc..eee0586770 100644
--- a/test/storage/offline_download.cpp
+++ b/test/storage/offline_download.cpp
@@ -73,6 +73,7 @@ TEST(OfflineDownload, NoSubresources) {
observer->statusChangedFn = [&] (OfflineRegionStatus status) {
if (status.complete()) {
+ EXPECT_EQ(OfflineRegionDownloadState::Active, status.downloadState);
EXPECT_EQ(1, status.completedResourceCount);
EXPECT_EQ(test.size, status.completedResourceSize);
EXPECT_TRUE(status.requiredResourceCountIsPrecise);
@@ -212,6 +213,7 @@ TEST(OfflineDownload, Activate) {
download.setState(OfflineRegionDownloadState::Inactive);
OfflineRegionStatus computedStatus = download.getStatus();
+ EXPECT_EQ(OfflineRegionDownloadState::Inactive, computedStatus.downloadState);
EXPECT_EQ(status.requiredResourceCount, computedStatus.requiredResourceCount);
EXPECT_EQ(status.completedResourceCount, computedStatus.completedResourceCount);
EXPECT_EQ(status.completedResourceSize, computedStatus.completedResourceSize);
@@ -455,3 +457,32 @@ TEST(OfflineDownload, ReactivatePreviouslyCompletedDownload) {
test.loop.run();
}
+
+TEST(OfflineDownload, Deactivate) {
+ OfflineTest test;
+ OfflineRegion region = test.createRegion();
+ OfflineDownload download(
+ region.getID(),
+ 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& resource) {
+ EXPECT_EQ("http://127.0.0.1:3000/offline/style.json", resource.url);
+ return test.response("offline/mapbox_source.style.json");
+ };
+
+ auto observer = std::make_unique<MockObserver>();
+
+ observer->statusChangedFn = [&] (OfflineRegionStatus status) {
+ if (status.downloadState == OfflineRegionDownloadState::Inactive) {
+ test.loop.stop();
+ } else {
+ download.setState(OfflineRegionDownloadState::Inactive);
+ }
+ };
+
+ download.setObserver(std::move(observer));
+ download.setState(OfflineRegionDownloadState::Active);
+
+ test.loop.run();
+}