|
@@ -1,26 +1,19 @@
|
|
|
#include <gtest/gtest.h>
|
|
#include <gtest/gtest.h>
|
|
|
#include <common/boxed_type.h>
|
|
#include <common/boxed_type.h>
|
|
|
|
|
+#include <common/listener.h>
|
|
|
#include <entt/core/attribute.h>
|
|
#include <entt/core/attribute.h>
|
|
|
#include <entt/core/utility.hpp>
|
|
#include <entt/core/utility.hpp>
|
|
|
#include <entt/signal/dispatcher.hpp>
|
|
#include <entt/signal/dispatcher.hpp>
|
|
|
|
|
|
|
|
ENTT_API void trigger(entt::dispatcher &);
|
|
ENTT_API void trigger(entt::dispatcher &);
|
|
|
|
|
|
|
|
-struct listener {
|
|
|
|
|
- void on(test::boxed_int msg) {
|
|
|
|
|
- value = msg.value;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- int value{};
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
TEST(Lib, Dispatcher) {
|
|
TEST(Lib, Dispatcher) {
|
|
|
entt::dispatcher dispatcher;
|
|
entt::dispatcher dispatcher;
|
|
|
- listener listener;
|
|
|
|
|
|
|
+ test::listener<test::boxed_int> listener;
|
|
|
|
|
|
|
|
ASSERT_EQ(listener.value, 0);
|
|
ASSERT_EQ(listener.value, 0);
|
|
|
|
|
|
|
|
- dispatcher.sink<test::boxed_int>().connect<entt::overload<void(test::boxed_int)>(&listener::on)>(listener);
|
|
|
|
|
|
|
+ dispatcher.sink<test::boxed_int>().connect<entt::overload<void(test::boxed_int)>(&test::listener<test::boxed_int>::on)>(listener);
|
|
|
trigger(dispatcher);
|
|
trigger(dispatcher);
|
|
|
|
|
|
|
|
ASSERT_EQ(listener.value, 2);
|
|
ASSERT_EQ(listener.value, 2);
|