summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAsheem Mamoowala <asheem.mamoowala@mapbox.com>2017-05-18 13:56:09 -0700
committerAsheem Mamoowala <asheem.mamoowala@mapbox.com>2017-06-01 15:38:01 -0700
commitaa6647e910073edffbd1f3c087ed110927c38aeb (patch)
treeb112a9f14610da986f6436e8a713ae8016e08aef /test
parentc0c1028dcf57379db68a87d8d0a1780d9d901fe5 (diff)
downloadqtlocation-mapboxgl-aa6647e910073edffbd1f3c087ed110927c38aeb.tar.gz
[core] Offline support for Image Sources
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/offline_download/radar.gifbin0 -> 10958 bytes
-rw-r--r--test/fixtures/offline_download/style.json10
-rw-r--r--test/src/mbgl/test/stub_file_source.cpp3
-rw-r--r--test/src/mbgl/test/stub_file_source.hpp1
-rw-r--r--test/storage/offline_download.test.cpp11
-rw-r--r--test/storage/resource.test.cpp7
6 files changed, 29 insertions, 3 deletions
diff --git a/test/fixtures/offline_download/radar.gif b/test/fixtures/offline_download/radar.gif
new file mode 100644
index 0000000000..7398a060c0
--- /dev/null
+++ b/test/fixtures/offline_download/radar.gif
Binary files differ
diff --git a/test/fixtures/offline_download/style.json b/test/fixtures/offline_download/style.json
index 978df3aae3..618afd45f0 100644
--- a/test/fixtures/offline_download/style.json
+++ b/test/fixtures/offline_download/style.json
@@ -5,6 +5,16 @@
"mapbox": {
"type": "vector",
"url": "http://127.0.0.1:3000/streets.json"
+ },
+ "radar": {
+ "type": "image",
+ "url":"http://127.0.0.1:3000/radar.gif",
+ "coordinates": [
+ [-180, -85.0511],
+ [180, -85.0511],
+ [180, 85.0511],
+ [-180, 85.0511]
+ ]
}
},
"glyphs": "http://127.0.0.1:3000/{fontstack}/{range}.pbf",
diff --git a/test/src/mbgl/test/stub_file_source.cpp b/test/src/mbgl/test/stub_file_source.cpp
index ec0545e88c..7891d5d907 100644
--- a/test/src/mbgl/test/stub_file_source.cpp
+++ b/test/src/mbgl/test/stub_file_source.cpp
@@ -77,6 +77,9 @@ optional<Response> StubFileSource::defaultResponse(const Resource& resource) {
case Resource::Kind::SpriteImage:
if (!spriteImageResponse) throw std::runtime_error("unexpected sprite image request");
return spriteImageResponse(resource);
+ case Resource::Kind::Image:
+ if (!imageResponse) throw std::runtime_error("unexpected image request");
+ return imageResponse(resource);
case Resource::Kind::Unknown:
throw std::runtime_error("unknown resource type");
}
diff --git a/test/src/mbgl/test/stub_file_source.hpp b/test/src/mbgl/test/stub_file_source.hpp
index ee4175cc3f..85118e1a77 100644
--- a/test/src/mbgl/test/stub_file_source.hpp
+++ b/test/src/mbgl/test/stub_file_source.hpp
@@ -29,6 +29,7 @@ public:
ResponseFunction glyphsResponse;
ResponseFunction spriteJSONResponse;
ResponseFunction spriteImageResponse;
+ ResponseFunction imageResponse;
private:
// The default behavior is to throw if no per-kind callback has been set.
diff --git a/test/storage/offline_download.test.cpp b/test/storage/offline_download.test.cpp
index 27e57771c8..57780eba40 100644
--- a/test/storage/offline_download.test.cpp
+++ b/test/storage/offline_download.test.cpp
@@ -191,6 +191,11 @@ TEST(OfflineDownload, Activate) {
return test.response("sprite.png");
};
+ test.fileSource.imageResponse = [&] (const Resource& resource) {
+ EXPECT_EQ("http://127.0.0.1:3000/radar.gif", resource.url);
+ return test.response("radar.gif");
+ };
+
test.fileSource.spriteJSONResponse = [&] (const Resource& resource) {
EXPECT_EQ("http://127.0.0.1:3000/sprite.json", resource.url);
return test.response("sprite.json");
@@ -219,7 +224,7 @@ TEST(OfflineDownload, Activate) {
observer->statusChangedFn = [&] (OfflineRegionStatus status) {
if (status.complete()) {
- EXPECT_EQ(261u, status.completedResourceCount); // 256 glyphs, 1 tile, 1 style, source, sprite image, and sprite json
+ EXPECT_EQ(262u, status.completedResourceCount); // 256 glyphs, 1 tile, 1 style, source, image, sprite image, and sprite json
EXPECT_EQ(test.size, status.completedResourceSize);
download.setState(OfflineRegionDownloadState::Inactive);
@@ -299,7 +304,7 @@ TEST(OfflineDownload, GetStatusStyleComplete) {
EXPECT_EQ(OfflineRegionDownloadState::Inactive, status.downloadState);
EXPECT_EQ(1u, status.completedResourceCount);
EXPECT_EQ(test.size, status.completedResourceSize);
- EXPECT_EQ(260u, status.requiredResourceCount);
+ EXPECT_EQ(261u, status.requiredResourceCount);
EXPECT_FALSE(status.requiredResourceCountIsPrecise);
EXPECT_FALSE(status.complete());
}
@@ -325,7 +330,7 @@ TEST(OfflineDownload, GetStatusStyleAndSourceComplete) {
EXPECT_EQ(OfflineRegionDownloadState::Inactive, status.downloadState);
EXPECT_EQ(2u, status.completedResourceCount);
EXPECT_EQ(test.size, status.completedResourceSize);
- EXPECT_EQ(261u, status.requiredResourceCount);
+ EXPECT_EQ(262u, status.requiredResourceCount);
EXPECT_TRUE(status.requiredResourceCountIsPrecise);
EXPECT_FALSE(status.complete());
}
diff --git a/test/storage/resource.test.cpp b/test/storage/resource.test.cpp
index 1c15fe6503..5a27aa98a5 100644
--- a/test/storage/resource.test.cpp
+++ b/test/storage/resource.test.cpp
@@ -117,6 +117,13 @@ TEST(Resource, SpriteImage) {
EXPECT_EQ("http://example.com/sprite@2x.png", resource.url);
}
+TEST(Resource, Image) {
+ using namespace mbgl;
+ Resource resource = Resource::image("http://example.com/sprite.jpg");
+ EXPECT_EQ(Resource::Kind::Image, resource.kind);
+ EXPECT_EQ("http://example.com/sprite.jpg", resource.url);
+}
+
TEST(Resource, SpriteJSON) {
using namespace mbgl;
Resource resource = Resource::spriteJSON("http://example.com/sprite", 2.0);