|
@@ -3,7 +3,7 @@
|
|
|
* Company: Lynar Studios
|
|
|
* E-Mail: webmaster@lynarstudios.com
|
|
|
* Created: 2024-05-16
|
|
|
-* Changed: 2024-05-17
|
|
|
+* Changed: 2024-05-30
|
|
|
*
|
|
|
* */
|
|
|
|
|
@@ -18,6 +18,7 @@ using ls::std::event::EventManager;
|
|
|
using ::std::make_shared;
|
|
|
using ::std::string;
|
|
|
using test::event::Button;
|
|
|
+using test::event::ChangeColorEvent;
|
|
|
using test::event::OnClickEvent;
|
|
|
using testing::Test;
|
|
|
|
|
@@ -56,18 +57,31 @@ namespace
|
|
|
|
|
|
auto myBlueButton = make_shared<Button>();
|
|
|
myBlueButton->subscribe(OnClickEvent().of(eventManager), [myBlueButton]() mutable { myBlueButton->onClickEvent(); });
|
|
|
+ myBlueButton->subscribe(ChangeColorEvent().of(eventManager), [myBlueButton]() mutable { myBlueButton->onChangeColorEvent(); });
|
|
|
auto myRedButton = make_shared<Button>();
|
|
|
auto myGreenButton = make_shared<Button>();
|
|
|
+ myGreenButton->subscribe(ChangeColorEvent().of(eventManager), [myGreenButton]() mutable { myGreenButton->onChangeColorEvent(); });
|
|
|
+
|
|
|
+ // status without any event invoked
|
|
|
|
|
|
ASSERT_FALSE(myBlueButton->isClicked());
|
|
|
+ ASSERT_STREQ("black", myBlueButton->getColor().c_str());
|
|
|
ASSERT_FALSE(myRedButton->isClicked());
|
|
|
+ ASSERT_STREQ("black", myRedButton->getColor().c_str());
|
|
|
ASSERT_FALSE(myGreenButton->isClicked());
|
|
|
+ ASSERT_STREQ("black", myGreenButton->getColor().c_str());
|
|
|
|
|
|
eventManager->invoke(OnClickEvent());
|
|
|
+ eventManager->invoke(ChangeColorEvent());
|
|
|
+
|
|
|
+ // status with events invoked
|
|
|
|
|
|
ASSERT_TRUE(myBlueButton->isClicked());
|
|
|
+ ASSERT_STREQ("blue", myBlueButton->getColor().c_str());
|
|
|
ASSERT_FALSE(myRedButton->isClicked());
|
|
|
+ ASSERT_STREQ("black", myRedButton->getColor().c_str());
|
|
|
ASSERT_FALSE(myGreenButton->isClicked());
|
|
|
+ ASSERT_STREQ("blue", myGreenButton->getColor().c_str());
|
|
|
}
|
|
|
|
|
|
TEST_F(EventManagerTest, invoke_event_not_known)
|