From bd859249e3295f06b66fe76a5f235faedf39bb4f Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Tue, 28 Jul 2020 14:23:42 +0900 Subject: [PATCH] Test: add DSZone::registerCallbackWindowCreated test Change-Id: I8be9afd92c693c17816ead059508885c14ea3f75 --- tests/DSZone-test.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tests/DSZone-test.cpp b/tests/DSZone-test.cpp index 0e813ce..8ec6a53 100644 --- a/tests/DSZone-test.cpp +++ b/tests/DSZone-test.cpp @@ -14,6 +14,33 @@ public: {} }; +class TestZone : public DSObject +{ +public: + TestZone(std::shared_ptr zone) + : __boolOnWindowCreated(false), + __zone(nullptr) + { + __zone->registerCallbackWindowCreated(this, std::bind(&TestZone::onWindowCreated, this, std::placeholders::_1)); + } + ~TestZone() + {} + + void callOnWindowCreated() { + __zone->callCallbackWindowCreated(); + } + bool getResultOnWindowCreated() { + return __boolOnWindowCreated; + } + void onWindowCreated(std::shared_ptr) { + __boolOnWindowCreated = true; + } + +private: + bool __boolOnWindowCreated; + std::shared_ptr __zone; +}; + TEST_F(DSZoneTest, NewDSZone) { auto policyArea = std::make_shared(); @@ -35,3 +62,18 @@ TEST_F(DSZoneTest, BasicMethods) EXPECT_TRUE(zone->getWidth() == 100); EXPECT_TRUE(zone->getHeight() == 100); } + +TEST_F(DSZoneTest, registerCallbackWindowCreated) +{ + auto policyArea = std::make_shared(); + EXPECT_TRUE(policyArea->setPosition(10, 10) == true); + EXPECT_TRUE(policyArea->setSize(100, 100) == true); + auto zone = std::make_shared(policyArea); + EXPECT_TRUE(zone != nullptr); + + auto testZone = std::make_shared(zone); + EXPECT_TRUE(testZone != nullptr); + + testZone->callOnWindowCreated(); + EXPECT_TRUE(testZone->getResultOnWindowCreated()); +} -- 2.7.4