5TEST_F(Updater_test, Test_Updater_NoFunction)
7 Tested_t oExample{ Data_t{} };
8 ITested_t & IExample = oExample;
10 auto itCreator = IExample.GetCreators().find(uT(
"Updater"));
11 ASSERT_NE(IExample.GetCreators().end(), itCreator);
13 auto Render = itCreator->second(Component_t::Make({}));
14 ASSERT_NE(
nullptr, Render);
16 EXPECT_NO_THROW(Render());
20TEST_F(Updater_test, Test_Updater)
22 using Time_t = ::std::chrono::microseconds;
25 public ::alicorn::extension::testing::Proxy<Proxy>
28 MOCK_METHOD1(Update,
void(
float));
32 Proxy::GetInstance() = &theProxy;
34 using SystemClockProxy_t = ::mock::std::chrono::system_clock::Proxy;
35 SystemClockProxy_t SystemClockProxy;
36 SystemClockProxy_t::GetInstance() = &SystemClockProxy;
38 const auto BeginTime = 1907232116;
40 const ::covellite::api::Updater_t Updater = [&](
const float _Time)
42 theProxy.Update(_Time);
45 const auto pComponent = Component_t::Make(
47 { uT(
"function"), Updater },
50 using namespace ::testing;
54 EXPECT_CALL(SystemClockProxy, Now())
56 .WillOnce(Return(Time_t{ BeginTime }));
58 Tested_t oExample{ Data_t{} };
59 ITested_t & IExample = oExample;
61 auto itCreator = IExample.GetCreators().find(uT(
"Updater"));
62 ASSERT_NE(IExample.GetCreators().end(), itCreator);
64 auto Render = itCreator->second(pComponent);
65 ASSERT_NE(
nullptr, Render);
67 EXPECT_CALL(theProxy, Update(0.0f))
72 EXPECT_CALL(SystemClockProxy, Now())
74 .WillOnce(Return(Time_t{ BeginTime + 1000000 }));
76 IExample.PresentFrame();
78 EXPECT_CALL(theProxy, Update(1.0f))
85TEST_F(Updater_test, Test_Updater_ReplaceFunction)
88 public ::alicorn::extension::testing::Proxy<Proxy>
91 MOCK_METHOD1(Update,
void(
int));
95 Proxy::GetInstance() = &theProxy;
97 const auto pComponent = Component_t::Make({ });
99 const ::covellite::api::Updater_t Updater2 = [&](
const float)
104 const ::covellite::api::Updater_t Updater1 = [&](
const float)
106 (*pComponent)[uT(
"function")] = Updater2;
111 const ::covellite::api::Updater_t Updater0 = [&](
const float)
116 Tested_t oExample{ Data_t{} };
117 ITested_t & IExample = oExample;
119 auto itCreator = IExample.GetCreators().find(uT(
"Updater"));
120 ASSERT_NE(IExample.GetCreators().end(), itCreator);
122 auto Render = itCreator->second(pComponent);
123 ASSERT_NE(
nullptr, Render);
125 using namespace ::testing;
129 EXPECT_CALL(theProxy, Update(_))
134 (*pComponent)[uT(
"function")] = Updater0;
136 EXPECT_CALL(theProxy, Update(0))
141 (*pComponent)[uT(
"function")] = Updater1;
143 EXPECT_CALL(theProxy, Update(1))
150 EXPECT_CALL(theProxy, Update(2))