Exemple #1
0
TEST(Style, UnusedSourceActiveViaClassUpdate) {
    util::RunLoop loop;
    util::ThreadContext context { "Map", util::ThreadType::Map, util::ThreadPriority::Regular };
    util::ThreadContext::Set(&context);

    MapData data { MapMode::Still, GLContextMode::Unique, 1.0 };
    StubFileSource fileSource;
    Style style { data, fileSource };

    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);
    style.recalculate(0, now);

    Source *unusedSource = style.getSource("unusedsource");
    EXPECT_TRUE(unusedSource);
    EXPECT_TRUE(unusedSource->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);
    style.recalculate(0, now);

    unusedSource = style.getSource("unusedsource");
    EXPECT_TRUE(unusedSource);
    EXPECT_FALSE(unusedSource->isLoaded());
}
Exemple #2
0
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());
}
Exemple #3
0
TEST(Style, UnusedSource) {
    util::RunLoop loop;
    util::ThreadContext context { "Map", util::ThreadType::Map, util::ThreadPriority::Regular };
    util::ThreadContext::Set(&context);

    MapData data { MapMode::Still, GLContextMode::Unique, 1.0 };
    StubFileSource fileSource;
    Style style { data, fileSource };

    auto now = Clock::now();

    style.setJSON(util::read_file("test/fixtures/resources/style-unused-sources.json"), "");
    style.cascade(now);
    style.recalculate(0, now);

    Source *usedSource = style.getSource("usedsource");
    EXPECT_TRUE(usedSource);
    EXPECT_TRUE(usedSource->isLoaded());

    Source *unusedSource = style.getSource("unusedsource");
    EXPECT_TRUE(unusedSource);
    EXPECT_FALSE(unusedSource->isLoaded());
}