From 197751bace6181f2c2dbe4c890f277a0dc7e58b1 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Thu, 20 Apr 2017 17:10:33 -0700 Subject: [core] Load source TileJSON immediately This reverses #3095. Rationale: * We're now exposing source attributes as a public API. Making those attributes unavailable at certain times complicates that API. * We're preparing to split RenderSource out of Source. Removing this removes a point of coupling between the two. --- test/fixtures/api/annotation.json | 2 +- test/fixtures/api/query_style.json | 4 +-- test/fixtures/api/water.json | 2 +- test/style/style.test.cpp | 72 -------------------------------------- 4 files changed, 4 insertions(+), 76 deletions(-) (limited to 'test') diff --git a/test/fixtures/api/annotation.json b/test/fixtures/api/annotation.json index ab83d43476..972b22fc4d 100644 --- a/test/fixtures/api/annotation.json +++ b/test/fixtures/api/annotation.json @@ -3,7 +3,7 @@ "sources": { "fake": { "type": "vector", - "url": "fake" + "tiles": ["fake"] } }, "layers": [{ diff --git a/test/fixtures/api/query_style.json b/test/fixtures/api/query_style.json index 97f1d04432..2e499c383d 100644 --- a/test/fixtures/api/query_style.json +++ b/test/fixtures/api/query_style.json @@ -53,11 +53,11 @@ }, "source5": { "type": "vector", - "url": "mapbox://mapbox.mapbox-streets-v6" + "tiles": ["fake"] }, "source6": { "type": "raster", - "url": "mapbox://mapbox.satellite", + "tiles": ["fake"], "tileSize": 256 } }, diff --git a/test/fixtures/api/water.json b/test/fixtures/api/water.json index 387471b842..0a563a4955 100644 --- a/test/fixtures/api/water.json +++ b/test/fixtures/api/water.json @@ -4,7 +4,7 @@ "sources": { "mapbox": { "type": "vector", - "url": "asset://streets.json" + "tiles": ["asset://streets/{z}-{x}-{y}.vector.pbf"] } }, "layers": [{ diff --git a/test/style/style.test.cpp b/test/style/style.test.cpp index f87e31cce2..b529abad4a 100644 --- a/test/style/style.test.cpp +++ b/test/style/style.test.cpp @@ -14,78 +14,6 @@ using namespace mbgl; using namespace mbgl::style; -TEST(Style, UnusedSource) { - util::RunLoop loop; - - ThreadPool threadPool{ 1 }; - StubFileSource fileSource; - Style style { threadPool, fileSource, 1.0 }; - - auto now = Clock::now(); - - style.setJSON(util::read_file("test/fixtures/resources/style-unused-sources.json")); - - // If we haven't calculated whether the source is used, we have to assume it is used. - EXPECT_FALSE(style.isLoaded()); - - style.cascade(now, MapMode::Still); - style.recalculate(0, now, MapMode::Still); - - Source* usedSource = style.getSource("usedsource"); - EXPECT_TRUE(usedSource); - EXPECT_TRUE(usedSource->baseImpl->isLoaded()); - - Source* unusedSource = style.getSource("unusedsource"); - EXPECT_TRUE(unusedSource); - EXPECT_FALSE(unusedSource->baseImpl->isLoaded()); - - Layer* unusedLayer = style.getLayer("unusedlayervisibility"); - EXPECT_TRUE(unusedLayer); - - unusedLayer->setVisibility(mbgl::style::VisibilityType::Visible); - - style.relayout(); - EXPECT_FALSE(unusedSource->baseImpl->isLoaded()); - - // Style loads sources upon request when recalculating style. - style.recalculate(0, now, MapMode::Still); - EXPECT_TRUE(unusedSource->baseImpl->isLoaded()); -} - -TEST(Style, UnusedSourceActiveViaClassUpdate) { - util::RunLoop loop; - - ThreadPool threadPool{ 1 }; - StubFileSource fileSource; - Style style { threadPool, fileSource, 1.0 }; - - style.setJSON(util::read_file("test/fixtures/resources/style-unused-sources.json")); - EXPECT_TRUE(style.addClass("visible")); - EXPECT_TRUE(style.hasClass("visible")); - - auto now = Clock::now(); - - style.cascade(now, MapMode::Still); - style.recalculate(0, now, MapMode::Still); - - Source *unusedSource = style.getSource("unusedsource"); - EXPECT_TRUE(unusedSource); - EXPECT_TRUE(unusedSource->baseImpl->isLoaded()); - - // Style classes should be cleared upon new style load. - style.setJSON(util::read_file("test/fixtures/resources/style-unused-sources.json")); - EXPECT_FALSE(style.hasClass("visible")); - - now = Clock::now(); - - style.cascade(now, MapMode::Still); - style.recalculate(0, now, MapMode::Still); - - unusedSource = style.getSource("unusedsource"); - EXPECT_TRUE(unusedSource); - EXPECT_FALSE(unusedSource->baseImpl->isLoaded()); -} - TEST(Style, Properties) { util::RunLoop loop; -- cgit v1.2.1