#include #include "util/ScopedSingletonManager.h" namespace orxonox { namespace { class TestSingletonRoot : public Singleton { friend class Singleton; static TestSingletonRoot* singletonPtr_s; }; class TestSingletonGraphics : public Singleton { friend class Singleton; static TestSingletonGraphics* singletonPtr_s; }; ManageScopedSingleton(TestSingletonRoot, ScopeID::Root, false); ManageScopedSingleton(TestSingletonGraphics, ScopeID::Graphics, false); } TEST(Scope, ScopesDoNotExist) { EXPECT_FALSE(Scope::isActive()); EXPECT_FALSE(Scope::isActive()); } TEST(Scope, SingletonsDoNotExist) { EXPECT_FALSE(TestSingletonRoot::exists()); EXPECT_FALSE(TestSingletonGraphics::exists()); } TEST(Scope, RootScope) { EXPECT_FALSE(Scope::isActive()); { // create root scope Scope scope; EXPECT_TRUE(Scope::isActive()); } // destroy root scope EXPECT_FALSE(Scope::isActive()); } TEST(Scope, RootAndGraphicsScope) { EXPECT_FALSE(Scope::isActive()); { // create root scope Scope scope; EXPECT_FALSE(Scope::isActive()); { // create graphics scope Scope scope; EXPECT_TRUE(Scope::isActive()); } // destroy graphics scope EXPECT_FALSE(Scope::isActive()); } // destroy root scope EXPECT_FALSE(Scope::isActive()); } TEST(Scope, RootSingleton) { EXPECT_FALSE(TestSingletonRoot::exists()); { // create root scope Scope scope; EXPECT_TRUE(TestSingletonRoot::exists()); } // destroy root scope EXPECT_FALSE(TestSingletonRoot::exists()); } TEST(Scope, RootAndGraphicsSingleton) { EXPECT_FALSE(TestSingletonGraphics::exists()); { // create root scope Scope scope; EXPECT_FALSE(TestSingletonGraphics::exists()); { // create graphics scope Scope scope; EXPECT_TRUE(TestSingletonGraphics::exists()); } // destroy graphics scope EXPECT_FALSE(TestSingletonGraphics::exists()); } // destroy root scope EXPECT_FALSE(TestSingletonGraphics::exists()); } }