- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
template<int I> struct Tag {};
template<int I>
struct StaticMock : mirage::ecs::Component<StaticMock<I>>
{
static bool initializeds;
void initialize(void)
{
initializeds = true;
}
};
template<>
struct StaticMock<2> : mirage::ecs::Component<StaticMock<2>>
{
static bool initializeds;
void initialize(Tag<2>&)
{
initializeds = true;
}
};
template<int I>
inline bool StaticMock<I>::initializeds = false;
inline bool StaticMock<2>::initializeds = false;
using Tag1 = Tag<1>;
using StaticMock1 = StaticMock<1>;
using Tag2 = Tag<2>;
using StaticMock2 = StaticMock<2>;
MIRAGE_CREATE_ON_STARTUP(StaticMock<0>, staticOnStartMock);
MIRAGE_CREATE_ON_EVENT(Tag1, StaticMock1);
MIRAGE_CREATE_WITH_EVENT(Tag2, StaticMock2);
TEST(Ecs, StaticOnStart)
{
EXPECT_EQ(StaticMock<0>::initializeds, true);
}
TEST(Ecs, StaticOnEvent)
{
EXPECT_NE(StaticMock1::initializeds, true);
mirage::event::enqueueEvent<Tag1>();
std::this_thread::sleep_for(std::chrono::milliseconds(
mirage::ecs::processing::EventDispatcherProcessing::updatePeriod * 2));
EXPECT_EQ(StaticMock1::initializeds, true);
}
TEST(Ecs, StaticWithEvent)
{
EXPECT_NE(StaticMock2::initializeds, true);
mirage::event::enqueueEvent<Tag2>();
std::this_thread::sleep_for(std::chrono::milliseconds(
mirage::ecs::processing::EventDispatcherProcessing::updatePeriod * 2));
EXPECT_EQ(StaticMock2::initializeds, true);
}
Комментарии (0) RSS
Добавить комментарий