@@ -9,8 +9,8 @@ using namespace mbgl;
|
||||
|
||||
class StubRendererBackend : public gl::RendererBackend {
|
||||
public:
|
||||
StubRendererBackend() : gl::RendererBackend(gfx::ContextMode::Unique) {
|
||||
}
|
||||
StubRendererBackend()
|
||||
: gl::RendererBackend(gfx::ContextMode::Unique) {}
|
||||
|
||||
void activate() override {
|
||||
if (activateFunction) activateFunction();
|
||||
@@ -34,9 +34,9 @@ public:
|
||||
return reinterpret_cast<gfx::Renderable&>(*this);
|
||||
}
|
||||
|
||||
std::function<void ()> activateFunction;
|
||||
std::function<void ()> deactivateFunction;
|
||||
std::function<void ()> updateAssumedStateFunction;
|
||||
std::function<void()> activateFunction;
|
||||
std::function<void()> deactivateFunction;
|
||||
std::function<void()> updateAssumedStateFunction;
|
||||
};
|
||||
|
||||
// A scope should activate on construction
|
||||
@@ -47,12 +47,14 @@ TEST(BackendScope, SingleScope) {
|
||||
bool deactivated;
|
||||
|
||||
StubRendererBackend backend;
|
||||
backend.activateFunction = [&] { activated = true; };
|
||||
backend.deactivateFunction = [&] { deactivated = true; };
|
||||
backend.activateFunction = [&] {
|
||||
activated = true;
|
||||
};
|
||||
backend.deactivateFunction = [&] {
|
||||
deactivated = true;
|
||||
};
|
||||
|
||||
{
|
||||
gfx::BackendScope test { backend };
|
||||
}
|
||||
{ gfx::BackendScope test{backend}; }
|
||||
|
||||
ASSERT_TRUE(activated);
|
||||
ASSERT_TRUE(deactivated);
|
||||
@@ -65,14 +67,18 @@ TEST(BackendScope, NestedScopes) {
|
||||
int deactivated = 0;
|
||||
|
||||
StubRendererBackend backend;
|
||||
backend.activateFunction = [&] { activated++; };
|
||||
backend.deactivateFunction = [&] { deactivated++; };
|
||||
backend.activateFunction = [&] {
|
||||
activated++;
|
||||
};
|
||||
backend.deactivateFunction = [&] {
|
||||
deactivated++;
|
||||
};
|
||||
|
||||
{
|
||||
gfx::BackendScope outer { backend };
|
||||
gfx::BackendScope outer{backend};
|
||||
ASSERT_EQ(1, activated);
|
||||
{
|
||||
gfx::BackendScope inner { backend };
|
||||
gfx::BackendScope inner{backend};
|
||||
ASSERT_EQ(1, activated);
|
||||
}
|
||||
ASSERT_EQ(0, deactivated);
|
||||
@@ -90,18 +96,26 @@ TEST(BackendScope, ChainedScopes) {
|
||||
bool activatedB = false;
|
||||
|
||||
StubRendererBackend backendA;
|
||||
backendA.activateFunction = [&] { activatedA = true; };
|
||||
backendA.deactivateFunction = [&] { activatedA = false; };
|
||||
backendA.activateFunction = [&] {
|
||||
activatedA = true;
|
||||
};
|
||||
backendA.deactivateFunction = [&] {
|
||||
activatedA = false;
|
||||
};
|
||||
|
||||
StubRendererBackend backendB;
|
||||
backendB.activateFunction = [&] { activatedB = true; };
|
||||
backendB.deactivateFunction = [&] { activatedB = false; };
|
||||
backendB.activateFunction = [&] {
|
||||
activatedB = true;
|
||||
};
|
||||
backendB.deactivateFunction = [&] {
|
||||
activatedB = false;
|
||||
};
|
||||
|
||||
{
|
||||
gfx::BackendScope scopeA { backendA };
|
||||
gfx::BackendScope scopeA{backendA};
|
||||
ASSERT_TRUE(activatedA);
|
||||
{
|
||||
gfx::BackendScope scopeB { backendB };
|
||||
gfx::BackendScope scopeB{backendB};
|
||||
ASSERT_FALSE(activatedA);
|
||||
ASSERT_TRUE(activatedB);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user