diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-02-01 14:07:26 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-02-01 15:29:42 -0800 |
commit | 716997b99eed50ecf35fd1ec3124a85760a05753 (patch) | |
tree | d2314e6ba16273b4ab232d2c38995d1ce59210eb /test/style/style.cpp | |
parent | 0e66d4dcc53fad046673346f3db83346ad54e3e8 (diff) | |
download | qtlocation-mapboxgl-716997b99eed50ecf35fd1ec3124a85760a05753.tar.gz |
[tests] Refactor and make MockFileSource more general
Now it works more like StubStyleObserver: you can assign std::functions to specific slots based on resource type.
Rewrite resource loading tests in that style, making them less like integration tests of Style and more like unit tests of Source, GlyphStore, and SpriteStore.
Diffstat (limited to 'test/style/style.cpp')
-rw-r--r-- | test/style/style.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/style/style.cpp b/test/style/style.cpp new file mode 100644 index 0000000000..59366ea7dd --- /dev/null +++ b/test/style/style.cpp @@ -0,0 +1,45 @@ +#include "../fixtures/util.hpp" + +#include <mbgl/map/map_data.hpp> +#include <mbgl/style/style.hpp> +#include <mbgl/util/io.hpp> + +using namespace mbgl; + +TEST(Style, UnusedSource) { + util::ThreadContext context { "Map", util::ThreadType::Map, util::ThreadPriority::Regular }; + util::ThreadContext::Set(&context); + + MapData data { MapMode::Still, GLContextMode::Unique, 1.0 }; + Style style { data }; + + style.setJSON(util::read_file("test/fixtures/resources/style-unused-sources.json"), ""); + style.cascade(); + style.recalculate(0); + + Source *usedSource = style.getSource("usedsource"); + EXPECT_TRUE(usedSource); + EXPECT_TRUE(usedSource->isLoaded()); + + Source *unusedSource = style.getSource("unusedsource"); + EXPECT_TRUE(unusedSource); + EXPECT_FALSE(unusedSource->isLoaded()); +} + +TEST(Style, UnusedSourceActiveViaClassUpdate) { + util::ThreadContext context { "Map", util::ThreadType::Map, util::ThreadPriority::Regular }; + util::ThreadContext::Set(&context); + + MapData data { MapMode::Still, GLContextMode::Unique, 1.0 }; + Style style { data }; + + data.addClass("visible"); + + style.setJSON(util::read_file("test/fixtures/resources/style-unused-sources.json"), ""); + style.cascade(); + style.recalculate(0); + + Source *unusedSource = style.getSource("unusedsource"); + EXPECT_TRUE(unusedSource); + EXPECT_TRUE(unusedSource->isLoaded()); +} |