summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSudarsana Babu Nagineni <sudarsana.babu@mapbox.com>2019-03-27 19:17:04 +0200
committerSudarsana Babu Nagineni <sudarsana.babu@mapbox.com>2019-03-28 16:41:15 +0200
commit7af00a404f22742fed4a83e9a36d023d7515025f (patch)
treeac050d12346d81030969f88607dbfd59ca33be11 /test
parentf5064e710884d5b822e59d05e51c127c8b3e852b (diff)
downloadqtlocation-mapboxgl-7af00a404f22742fed4a83e9a36d023d7515025f.tar.gz
[core] Include pixelRatio property in MapOptions
Move pixelRatio property from Map constructor to MapOptions.
Diffstat (limited to 'test')
-rw-r--r--test/api/annotations.test.cpp7
-rw-r--r--test/api/api_misuse.test.cpp5
-rw-r--r--test/api/custom_geometry_source.test.cpp5
-rw-r--r--test/api/custom_layer.test.cpp5
-rw-r--r--test/api/query.test.cpp7
-rw-r--r--test/api/recycle_map.cpp5
-rw-r--r--test/gl/context.test.cpp5
-rw-r--r--test/map/map.test.cpp18
-rw-r--r--test/map/prefetch.test.cpp2
-rw-r--r--test/src/mbgl/test/map_adapter.hpp3
-rw-r--r--test/text/local_glyph_rasterizer.test.cpp7
-rw-r--r--test/util/memory.test.cpp12
12 files changed, 37 insertions, 44 deletions
diff --git a/test/api/annotations.test.cpp b/test/api/annotations.test.cpp
index 612c4f0ab8..11920d1624 100644
--- a/test/api/annotations.test.cpp
+++ b/test/api/annotations.test.cpp
@@ -29,11 +29,10 @@ class AnnotationTest {
public:
util::RunLoop loop;
ThreadPool threadPool { 4 };
- float pixelRatio { 1 };
- HeadlessFrontend frontend { pixelRatio, threadPool };
+ HeadlessFrontend frontend { 1, threadPool };
- MapAdapter map { frontend, MapObserver::nullObserver(), pixelRatio, std::make_shared<StubFileSource>(),
- threadPool, MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize())};
+ MapAdapter map { frontend, MapObserver::nullObserver(), std::make_shared<StubFileSource>(), threadPool,
+ MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize())};
void checkRendering(const char * name) {
test::checkImage(std::string("test/fixtures/annotations/") + name,
diff --git a/test/api/api_misuse.test.cpp b/test/api/api_misuse.test.cpp
index 17eb2de14b..cca47de69c 100644
--- a/test/api/api_misuse.test.cpp
+++ b/test/api/api_misuse.test.cpp
@@ -22,11 +22,10 @@ TEST(API, RenderWithoutCallback) {
util::RunLoop loop;
ThreadPool threadPool(4);
- float pixelRatio { 1 };
- HeadlessFrontend frontend { pixelRatio, threadPool };
+ HeadlessFrontend frontend { 1, threadPool };
auto map = std::make_unique<MapAdapter>(frontend, MapObserver::nullObserver(),
- pixelRatio, std::make_shared<StubFileSource>(), threadPool,
+ std::make_shared<StubFileSource>(), threadPool,
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()));
map->renderStill(nullptr);
diff --git a/test/api/custom_geometry_source.test.cpp b/test/api/custom_geometry_source.test.cpp
index 679291372d..f796e3086b 100644
--- a/test/api/custom_geometry_source.test.cpp
+++ b/test/api/custom_geometry_source.test.cpp
@@ -21,9 +21,8 @@ TEST(CustomGeometrySource, Grid) {
util::RunLoop loop;
auto threadPool = sharedThreadPool();
- float pixelRatio { 1 };
- HeadlessFrontend frontend { pixelRatio, *threadPool };
- Map map(frontend, MapObserver::nullObserver(), pixelRatio, *threadPool,
+ HeadlessFrontend frontend { 1, *threadPool };
+ Map map(frontend, MapObserver::nullObserver(), *threadPool,
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()),
ResourceOptions().withCachePath(":memory:").withAssetPath("test/fixtures/api/assets"));
map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json"));
diff --git a/test/api/custom_layer.test.cpp b/test/api/custom_layer.test.cpp
index 4f1429d637..c836ab81ac 100644
--- a/test/api/custom_layer.test.cpp
+++ b/test/api/custom_layer.test.cpp
@@ -91,9 +91,8 @@ TEST(CustomLayer, Basic) {
util::RunLoop loop;
ThreadPool threadPool(4);
- float pixelRatio { 1 };
- HeadlessFrontend frontend { pixelRatio, threadPool };
- Map map(frontend, MapObserver::nullObserver(), pixelRatio, threadPool,
+ HeadlessFrontend frontend { 1, threadPool };
+ Map map(frontend, MapObserver::nullObserver(), threadPool,
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()),
ResourceOptions().withCachePath(":memory:").withAssetPath("test/fixtures/api/assets"));
map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json"));
diff --git a/test/api/query.test.cpp b/test/api/query.test.cpp
index 0dd9882be2..ddf5df6aab 100644
--- a/test/api/query.test.cpp
+++ b/test/api/query.test.cpp
@@ -36,10 +36,9 @@ public:
util::RunLoop loop;
std::shared_ptr<StubFileSource> fileSource = std::make_shared<StubFileSource>();
ThreadPool threadPool { 4 };
- float pixelRatio { 1 };
- HeadlessFrontend frontend { pixelRatio, threadPool };
- MapAdapter map { frontend, MapObserver::nullObserver(), pixelRatio, fileSource,
- threadPool, MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize())};
+ HeadlessFrontend frontend { 1, threadPool };
+ MapAdapter map { frontend, MapObserver::nullObserver(), fileSource, threadPool,
+ MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize())};
};
std::vector<Feature> getTopClusterFeature(QueryTest& test) {
diff --git a/test/api/recycle_map.cpp b/test/api/recycle_map.cpp
index 6f1560d463..ac9de9b230 100644
--- a/test/api/recycle_map.cpp
+++ b/test/api/recycle_map.cpp
@@ -24,11 +24,10 @@ TEST(API, RecycleMapUpdateImages) {
util::RunLoop loop;
ThreadPool threadPool(4);
- float pixelRatio { 1 };
- HeadlessFrontend frontend { pixelRatio, threadPool };
+ HeadlessFrontend frontend { 1, threadPool };
auto map = std::make_unique<MapAdapter>(frontend, MapObserver::nullObserver(),
- pixelRatio, std::make_shared<StubFileSource>(), threadPool,
+ std::make_shared<StubFileSource>(), threadPool,
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()));
EXPECT_TRUE(map);
diff --git a/test/gl/context.test.cpp b/test/gl/context.test.cpp
index d9b2750a95..291813bd9a 100644
--- a/test/gl/context.test.cpp
+++ b/test/gl/context.test.cpp
@@ -87,11 +87,10 @@ TEST(GLContextMode, Shared) {
util::RunLoop loop;
ThreadPool threadPool(4);
- float pixelRatio { 1 };
- HeadlessFrontend frontend { pixelRatio, threadPool, {}, GLContextMode::Shared };
+ HeadlessFrontend frontend { 1, threadPool, {}, GLContextMode::Shared };
- Map map(frontend, MapObserver::nullObserver(), pixelRatio, threadPool,
+ Map map(frontend, MapObserver::nullObserver(), threadPool,
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()),
ResourceOptions().withCachePath(":memory:").withAssetPath("test/fixtures/api/assets"));
map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json"));
diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp
index d443b5eacc..be92890b07 100644
--- a/test/map/map.test.cpp
+++ b/test/map/map.test.cpp
@@ -41,8 +41,8 @@ public:
MapTest(float pixelRatio = 1, MapMode mode = MapMode::Static)
: fileSource(std::make_shared<FileSource>())
, frontend(pixelRatio, threadPool)
- , map(frontend, observer, pixelRatio,
- fileSource, threadPool, MapOptions().withMapMode(mode).withSize(frontend.getSize())) {}
+ , map(frontend, observer, fileSource, threadPool,
+ MapOptions().withMapMode(mode).withSize(frontend.getSize()).withPixelRatio(pixelRatio)) {}
template <typename T = FileSource>
MapTest(const std::string& cachePath, const std::string& assetPath,
@@ -50,8 +50,8 @@ public:
typename std::enable_if<std::is_same<T, DefaultFileSource>::value>::type* = 0)
: fileSource(std::make_shared<T>(cachePath, assetPath))
, frontend(pixelRatio, threadPool)
- , map(frontend, observer, pixelRatio,
- fileSource, threadPool, MapOptions().withMapMode(mode).withSize(frontend.getSize())) {}
+ , map(frontend, observer, fileSource, threadPool,
+ MapOptions().withMapMode(mode).withSize(frontend.getSize()).withPixelRatio(pixelRatio)) {}
};
TEST(Map, RendererState) {
@@ -322,7 +322,8 @@ TEST(Map, DefaultBoundOptions) {
}
TEST(Map, MapOptions) {
- MapTest<> test { 1, MapMode::Continuous };
+ float pixelRatio { 2 };
+ MapTest<> test { pixelRatio, MapMode::Continuous };
test.map.setNorthOrientation(NorthOrientation::Rightwards);
test.map.setConstrainMode(ConstrainMode::None);
@@ -336,6 +337,7 @@ TEST(Map, MapOptions) {
EXPECT_EQ(options.constrainMode(), ConstrainMode::None);
EXPECT_EQ(options.northOrientation(), NorthOrientation::Rightwards);
EXPECT_EQ(options.size(), size);
+ EXPECT_EQ(options.pixelRatio(), pixelRatio);
}
TEST(Map, DefaultMapOptions) {
@@ -349,6 +351,7 @@ TEST(Map, DefaultMapOptions) {
EXPECT_TRUE(options.crossSourceCollisions());
EXPECT_EQ(options.size().width, 256);
EXPECT_EQ(options.size().height, 256);
+ EXPECT_EQ(options.pixelRatio(), 1);
}
TEST(Map, SetStyleInvalidJSON) {
@@ -741,7 +744,6 @@ TEST(Map, DontLoadUnneededTiles) {
TEST(Map, TEST_DISABLED_ON_CI(ContinuousRendering)) {
util::RunLoop runLoop;
ThreadPool threadPool { 4 };
- float pixelRatio { 1 };
using namespace std::chrono_literals;
@@ -753,7 +755,7 @@ TEST(Map, TEST_DISABLED_ON_CI(ContinuousRendering)) {
util::Timer timer;
- HeadlessFrontend frontend(pixelRatio, threadPool);
+ HeadlessFrontend frontend(1, threadPool);
StubMapObserver observer;
observer.didFinishRenderingFrameCallback = [&] (MapObserver::RenderMode) {
@@ -765,7 +767,7 @@ TEST(Map, TEST_DISABLED_ON_CI(ContinuousRendering)) {
});
};
- Map map(frontend, observer, pixelRatio, threadPool,
+ Map map(frontend, observer, threadPool,
MapOptions().withMapMode(MapMode::Continuous).withSize(frontend.getSize()),
ResourceOptions().withCachePath(":memory:").withAssetPath("test/fixtures/api/assets"));
map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json"));
diff --git a/test/map/prefetch.test.cpp b/test/map/prefetch.test.cpp
index 520228e010..3232c99a22 100644
--- a/test/map/prefetch.test.cpp
+++ b/test/map/prefetch.test.cpp
@@ -37,7 +37,7 @@ TEST(Map, PrefetchTiles) {
};
HeadlessFrontend frontend { { 512, 512 }, 1, threadPool };
- MapAdapter map(frontend, observer, 1, fileSource, threadPool,
+ MapAdapter map(frontend, observer, fileSource, threadPool,
MapOptions().withMapMode(MapMode::Continuous).withSize(frontend.getSize()));
std::vector<int> tiles;
diff --git a/test/src/mbgl/test/map_adapter.hpp b/test/src/mbgl/test/map_adapter.hpp
index 67abea953d..5bdab1d164 100644
--- a/test/src/mbgl/test/map_adapter.hpp
+++ b/test/src/mbgl/test/map_adapter.hpp
@@ -12,11 +12,10 @@ class MapAdapter : public Map {
public:
explicit MapAdapter(RendererFrontend& frontend,
MapObserver& observer,
- float ratio,
std::shared_ptr<FileSource> fileSource,
Scheduler& scheduler,
const MapOptions& options)
- : Map(std::make_unique<Map::Impl>(frontend, observer, scheduler, ratio, std::move(fileSource), options)) {}
+ : Map(std::make_unique<Map::Impl>(frontend, observer, scheduler, std::move(fileSource), options)) {}
};
} // namespace mbgl
diff --git a/test/text/local_glyph_rasterizer.test.cpp b/test/text/local_glyph_rasterizer.test.cpp
index ac272e2f9f..26e4a2eb1d 100644
--- a/test/text/local_glyph_rasterizer.test.cpp
+++ b/test/text/local_glyph_rasterizer.test.cpp
@@ -34,17 +34,16 @@ namespace {
class LocalGlyphRasterizerTest {
public:
LocalGlyphRasterizerTest(const optional<std::string> fontFamily)
- : frontend(pixelRatio, threadPool, optional<std::string>(), GLContextMode::Unique, fontFamily)
+ : frontend(1, threadPool, optional<std::string>(), GLContextMode::Unique, fontFamily)
{
}
util::RunLoop loop;
std::shared_ptr<StubFileSource> fileSource = std::make_shared<StubFileSource>();
ThreadPool threadPool { 4 };
- float pixelRatio { 1 };
HeadlessFrontend frontend;
- MapAdapter map { frontend, MapObserver::nullObserver(), pixelRatio, fileSource,
- threadPool, MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize())};
+ MapAdapter map { frontend, MapObserver::nullObserver(), fileSource, threadPool,
+ MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize())};
void checkRendering(const char * name) {
test::checkImage(std::string("test/fixtures/local_glyphs/") + name,
diff --git a/test/util/memory.test.cpp b/test/util/memory.test.cpp
index 03545c648b..e3ad976432 100644
--- a/test/util/memory.test.cpp
+++ b/test/util/memory.test.cpp
@@ -73,8 +73,8 @@ TEST(Memory, Vector) {
float ratio { 2 };
HeadlessFrontend frontend { { 256, 256 }, ratio, test.threadPool };
- MapAdapter map(frontend, MapObserver::nullObserver(), ratio, test.fileSource,
- test.threadPool, MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()));
+ MapAdapter map(frontend, MapObserver::nullObserver(), test.fileSource, test.threadPool,
+ MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()).withPixelRatio(ratio));
map.jumpTo(CameraOptions().withZoom(16));
map.getStyle().loadURL("mapbox://streets");
@@ -86,8 +86,8 @@ TEST(Memory, Raster) {
float ratio { 2 };
HeadlessFrontend frontend { { 256, 256 }, ratio, test.threadPool };
- MapAdapter map(frontend, MapObserver::nullObserver(), ratio, test.fileSource,
- test.threadPool, MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()));
+ MapAdapter map(frontend, MapObserver::nullObserver(), test.fileSource, test.threadPool,
+ MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()).withPixelRatio(ratio));
map.getStyle().loadURL("mapbox://satellite");
frontend.render(map);
@@ -124,8 +124,8 @@ TEST(Memory, Footprint) {
public:
FrontendAndMap(MemoryTest& test_, const char* style)
: frontend(Size{ 256, 256 }, 2, test_.threadPool)
- , map(frontend, MapObserver::nullObserver(), 2, test_.fileSource
- , test_.threadPool, MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize())) {
+ , map(frontend, MapObserver::nullObserver(), test_.fileSource, test_.threadPool,
+ MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()).withPixelRatio(2)) {
map.jumpTo(CameraOptions().withZoom(16));
map.getStyle().loadURL(style);
frontend.render(map);