[core] parse more Style JSON properties
We're now parsing "name", "center", "zoom", "bearing", and "pitch" from the stylesheet.
This commit is contained in:
@@ -61,3 +61,37 @@ TEST(Style, UnusedSourceActiveViaClassUpdate) {
|
||||
EXPECT_TRUE(unusedSource);
|
||||
EXPECT_FALSE(unusedSource->baseImpl->isLoaded());
|
||||
}
|
||||
|
||||
TEST(Style, Properties) {
|
||||
util::RunLoop loop;
|
||||
|
||||
StubFileSource fileSource;
|
||||
Style style { fileSource, 1.0 };
|
||||
|
||||
style.setJSON(R"STYLE({"name": "Test"})STYLE");
|
||||
ASSERT_EQ("Test", style.getName());
|
||||
|
||||
style.setJSON(R"STYLE({"center": [10, 20]})STYLE");
|
||||
ASSERT_EQ("", style.getName());
|
||||
ASSERT_EQ((LatLng{20, 10}), style.getDefaultLatLng());
|
||||
|
||||
style.setJSON(R"STYLE({"bearing": 24})STYLE");
|
||||
ASSERT_EQ("", style.getName());
|
||||
ASSERT_EQ((LatLng{0, 0}), style.getDefaultLatLng());
|
||||
ASSERT_EQ(24, style.getDefaultBearing());
|
||||
|
||||
style.setJSON(R"STYLE({"zoom": 13.3})STYLE");
|
||||
ASSERT_EQ("", style.getName());
|
||||
ASSERT_EQ(13.3, style.getDefaultZoom());
|
||||
|
||||
style.setJSON(R"STYLE({"pitch": 60})STYLE");
|
||||
ASSERT_EQ("", style.getName());
|
||||
ASSERT_EQ(60, style.getDefaultPitch());
|
||||
|
||||
style.setJSON(R"STYLE({"name": 23, "center": {}, "bearing": "north", "zoom": null, "pitch": "wide"})STYLE");
|
||||
ASSERT_EQ("", style.getName());
|
||||
ASSERT_EQ((LatLng{0, 0}), style.getDefaultLatLng());
|
||||
ASSERT_EQ(0, style.getDefaultBearing());
|
||||
ASSERT_EQ(0, style.getDefaultZoom());
|
||||
ASSERT_EQ(0, style.getDefaultPitch());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user