From ee61c0ea204480e7a0a493581a09fcaf76a12189 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 13 Jan 2022 17:46:54 +0900 Subject: [PATCH] Reduce elapsed time of unit tests - Add mockup hook codes about aul APIs - Use g_idle_add_full() instead of g_timeout_add() Change-Id: I8715fbc958e4c225b9e40e93535ebf5b689eb2a0 Signed-off-by: Hwankyu Jhun --- unittests/app_core_base_test.cc | 80 ++++++++++++++-------------- unittests/app_core_efl_base_test.cc | 56 +++++++++---------- unittests/app_core_multi_window_base_test.cc | 32 +++++------ unittests/mock/aul_mock.cc | 18 ++++++- unittests/mock/aul_mock.h | 21 ++++++++ 5 files changed, 122 insertions(+), 85 deletions(-) diff --git a/unittests/app_core_base_test.cc b/unittests/app_core_base_test.cc index 57ca17f..08c749d 100644 --- a/unittests/app_core_base_test.cc +++ b/unittests/app_core_base_test.cc @@ -142,11 +142,11 @@ TEST_F(AppCoreBaseTest, AppCoreBase_Run) { EXPECT_CALL(core, OnCreate()) .WillOnce(Invoke([&core]() -> int { core.AppCoreBase::OnCreate(); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnTerminate()) @@ -162,11 +162,11 @@ TEST_F(AppCoreBaseTest, AppCoreBase_Init_Fini) { EXPECT_CALL(core, OnCreate()) .WillOnce(Invoke([&core]() -> int { core.AppCoreBase::OnCreate(); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnTerminate()) @@ -183,11 +183,11 @@ TEST_F(AppCoreBaseTest, AppCoreBase_Run_Again) { ON_CALL(core, OnCreate()) .WillByDefault(Invoke([&core]() -> int { core.AppCoreBase::OnCreate(); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); @@ -207,11 +207,11 @@ TEST_F(AppCoreBaseTest, AppCoreBase_OnControl) { EXPECT_CALL(core, OnCreate()) .WillOnce(Invoke([&core]() -> int { core.AppCoreBase::OnCreate(); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnReceive(_, _)) @@ -229,13 +229,13 @@ TEST_F(AppCoreBaseTest, AppCoreBase_AddEvent) { EXPECT_CALL(core, OnCreate()) .WillOnce(Invoke([&core]() -> int { core.AppCoreBase::OnCreate(); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->RaiseEvent(9216, IAppCore::IEvent::Type::LOW_MEMORY); obj->RaiseEvent("test", IAppCore::IEvent::Type::LOW_MEMORY); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnTerminate()) @@ -258,11 +258,11 @@ TEST_F(AppCoreBaseTest, AppCoreBase_AllowBG) { EXPECT_CALL(core, OnCreate()) .WillOnce(Invoke([&core]() -> int { core.AppCoreBase::OnCreate(); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnTerminate()) @@ -297,12 +297,12 @@ TEST_F(AppCoreBaseTest, AppCoreBase_FlushMemory) { .WillOnce(Invoke([&core]() -> int { core.AppCoreBase::OnCreate(); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->FlushMemory(); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnTerminate()) @@ -336,11 +336,11 @@ TEST_F(AppCoreBaseTest, AppCoreBase_GetRotationState) { .WillOnce(Invoke([&core, &rst]() -> int { core.AppCoreBase::OnCreate(); rst = AppCoreBase::GetRotationState(); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnTerminate()) @@ -375,11 +375,11 @@ TEST_F(AppCoreBaseTest, AppCoreBase_LockCb) { core.AppCoreBase::OnCreate(); GetMock().ChangeBool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, true); rst = AppCoreBase::GetRotationState(); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnTerminate()) @@ -402,11 +402,11 @@ TEST_F(AppCoreBaseTest, AppCoreBase_ChargerStatusChangedCb) { core.AppCoreBase::OnCreate(); GetMock().ChangeInt(VCONFKEY_SYSMAN_CHARGER_STATUS, 0); GetMock().ChangeInt(VCONFKEY_SYSMAN_CHARGER_STATUS, 1); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnTerminate()) @@ -427,11 +427,11 @@ TEST_F(AppCoreBaseTest, AppCoreBase_AddEvent_LanguageChanged) { EXPECT_CALL(core, OnCreate()) .WillOnce(Invoke([&core]() -> int { core.AppCoreBase::OnCreate(); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnTerminate()) @@ -465,11 +465,11 @@ TEST_F(AppCoreBaseTest, AppCoreBase_AddEvent_RegionChanged) { EXPECT_CALL(core, OnCreate()) .WillOnce(Invoke([&core]() -> int { core.AppCoreBase::OnCreate(); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnTerminate()) @@ -503,11 +503,11 @@ TEST_F(AppCoreBaseTest, AppCoreBase_AddEvent_LowBattery) { EXPECT_CALL(core, OnCreate()) .WillOnce(Invoke([&core]() -> int { core.AppCoreBase::OnCreate(); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnTerminate()) @@ -535,11 +535,11 @@ TEST_F(AppCoreBaseTest, AppCoreBase_AddEvent_LowMemory) { EXPECT_CALL(core, OnCreate()) .WillOnce(Invoke([&core]() -> int { core.AppCoreBase::OnCreate(); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnTerminate()) @@ -607,11 +607,11 @@ TEST_F(AppCoreBaseTest, AppCoreBase_OnReceive_AUL_RESUME) { EXPECT_CALL(core, OnCreate()) .WillOnce(Invoke([&core]() -> int { core.AppCoreBase::OnCreate(); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnReceive(_, _)) @@ -638,11 +638,11 @@ TEST_F(AppCoreBaseTest, AppCoreBase_OnReceive_AUL_UPDATE_REQUESTED) { EXPECT_CALL(core, OnCreate()) .WillOnce(Invoke([&core]() -> int { core.AppCoreBase::OnCreate(); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnReceive(_, _)) @@ -666,11 +666,11 @@ TEST_F(AppCoreBaseTest, AppCoreBase_OnReceive_INVALID_EVENT) { EXPECT_CALL(core, OnCreate()) .WillOnce(Invoke([&core]() -> int { core.AppCoreBase::OnCreate(); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnReceive(_, _)) @@ -694,11 +694,11 @@ TEST_F(AppCoreBaseTest, AppCoreBase_OnReceive_AUL_TERMINATE_INST) { EXPECT_CALL(core, OnCreate()) .WillOnce(Invoke([&core]() -> int { core.AppCoreBase::OnCreate(); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnReceive(_, _)) @@ -722,11 +722,11 @@ TEST_F(AppCoreBaseTest, AppCoreBase_OnReceive_AUL_SUSPEND) { EXPECT_CALL(core, OnCreate()) .WillOnce(Invoke([&core]() -> int { core.AppCoreBase::OnCreate(); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnReceive(_, _)) @@ -753,11 +753,11 @@ TEST_F(AppCoreBaseTest, AppCoreBase_OnReceive_AUL_WAKE) { .WillOnce(Invoke([&core]() -> int { core.AppCoreBase::OnCreate(); core.ToggleSuspendedState(); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnReceive(_, _)) diff --git a/unittests/app_core_efl_base_test.cc b/unittests/app_core_efl_base_test.cc index ec8d075..9de1a3c 100644 --- a/unittests/app_core_efl_base_test.cc +++ b/unittests/app_core_efl_base_test.cc @@ -124,11 +124,11 @@ TEST_F(AppCoreEflBaseTest, AppCoreEflBase_Run) { EXPECT_CALL(core, OnCreate()) .WillOnce(Invoke([&core]() -> int { core.AppCoreEflBase::OnCreate(); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnTerminate()) @@ -155,11 +155,11 @@ TEST_F(AppCoreEflBaseTest, AppCoreEflBase_AddEvent_OnTrimMemory) { EXPECT_CALL(core, OnCreate()) .WillOnce(Invoke([&core]() -> int { core.AppCoreEflBase::OnCreate(); - g_timeout_add(3000, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnReceive(_, _)) @@ -186,11 +186,11 @@ TEST_F(AppCoreEflBaseTest, AppCoreEflBase_AddEvent_SetSystemResourceReclaiming) EXPECT_CALL(core, OnCreate()) .WillOnce(Invoke([&core]() -> int { core.AppCoreEflBase::OnCreate(); - g_timeout_add(3000, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnControl(_)) @@ -217,11 +217,11 @@ TEST_F(AppCoreEflBaseTest, AppCoreEflBase_OnResume) { EXPECT_CALL(core, OnCreate()) .WillOnce(Invoke([&core]() -> int { core.AppCoreEflBase::OnCreate(); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnTerminate()) @@ -275,11 +275,11 @@ TEST_F(AppCoreEflBaseTest, AppCoreEflBase_RaiseWin) { EXPECT_CALL(core, OnCreate()) .WillOnce(Invoke([&core]() -> int { core.AppCoreEflBase::OnCreate(); - g_timeout_add(1500, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnTerminate()) @@ -340,11 +340,11 @@ TEST_F(AppCoreEflBaseTest, AppCoreEflBase_PauseWin) { EXPECT_CALL(core, OnCreate()) .WillOnce(Invoke([&core]() -> int { core.AppCoreEflBase::OnCreate(); - g_timeout_add(1500, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnTerminate()) @@ -401,11 +401,11 @@ TEST_F(AppCoreEflBaseTest, AppCoreEflBase_AUL_RESUME) { EXPECT_CALL(core, OnCreate()) .WillOnce(Invoke([&core]() -> int { core.AppCoreEflBase::OnCreate(); - g_timeout_add(1500, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnTerminate()) @@ -526,11 +526,11 @@ TEST_F(AppCoreEflBaseTest, AppCoreEflBase_VcElm) { EXPECT_CALL(core, OnCreate()) .WillOnce(Invoke([&core]() -> int { core.AppCoreEflBase::OnCreate(); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnTerminate()) @@ -569,13 +569,13 @@ TEST_F(AppCoreEflBaseTest, AppCoreEflBase_VcElm2) { EXPECT_CALL(core, OnCreate()) .WillOnce(Invoke([&core]() -> int { core.AppCoreEflBase::OnCreate(); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); GetMock().ChangeBool(VCONFKEY_VC_VOICE_TOUCH_AUTOMODE, false); GetMock().ChangeBool(VCONFKEY_VC_VOICE_TOUCH_AUTOMODE, true); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnTerminate()) @@ -615,11 +615,11 @@ TEST_F(AppCoreEflBaseTest, AppCoreEflBase_Aux) { EXPECT_CALL(core, OnCreate()) .WillOnce(Invoke([&core]() -> int { core.AppCoreEflBase::OnCreate(); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnTerminate()) @@ -660,11 +660,11 @@ TEST_F(AppCoreEflBaseTest, AppCoreEflBase_IsLegacyLifecycle) { EXPECT_CALL(core, OnCreate()) .WillOnce(Invoke([&core]() -> int { core.AppCoreEflBase::OnCreate(); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnTerminate()) @@ -689,11 +689,11 @@ TEST_F(AppCoreEflBaseTest, AppCoreEflBase_ApplyBgState) { EXPECT_CALL(core, OnCreate()) .WillOnce(Invoke([&core]() -> int { core.AppCoreEflBase::OnCreate(); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnTerminate()) @@ -759,11 +759,11 @@ TEST_F(AppCoreEflBaseTest, AppCoreEflBase_Plugin) { EXPECT_CALL(core, OnCreate()) .WillOnce(Invoke([&core]() -> int { core.AppCoreEflBase::OnCreate(); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnTerminate()) @@ -789,11 +789,11 @@ TEST_F(AppCoreEflBaseTest, AppCoreEflBase_Plugin2) { EXPECT_CALL(core, OnCreate()) .WillOnce(Invoke([&core]() -> int { core.AppCoreEflBase::OnCreate(); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnTerminate()) diff --git a/unittests/app_core_multi_window_base_test.cc b/unittests/app_core_multi_window_base_test.cc index a6cd385..b7d7c74 100644 --- a/unittests/app_core_multi_window_base_test.cc +++ b/unittests/app_core_multi_window_base_test.cc @@ -102,11 +102,11 @@ TEST_F(AppCoreMultiWindowBaseTest, AppCoreMultiWindowBase_Run) { EXPECT_CALL(core, OnCreate()) .WillOnce(Invoke([&core]() -> int { core.AppCoreMultiWindowBase::OnCreate(); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnTerminate()) @@ -127,11 +127,11 @@ TEST_F(AppCoreMultiWindowBaseTest, AppCoreMultiWindowBase_AddContextFactory) { auto f = std::make_shared(context_id, &core); core.AddContextFactory(f, context_id); ret_factory = core.GetContextFactory(context_id); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnTerminate()) @@ -154,11 +154,11 @@ TEST_F(AppCoreMultiWindowBaseTest, AppCoreMultiWindowBase_RunContext) { .WillOnce(Invoke([&]() -> int { core.AppCoreMultiWindowBase::OnCreate(); core.AddContextFactory(f, context_id); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnTerminate()) @@ -196,11 +196,11 @@ TEST_F(AppCoreMultiWindowBaseTest, AppCoreMultiWindowBase_ExitContext) { .WillOnce(Invoke([&]() -> int { core.AppCoreMultiWindowBase::OnCreate(); core.AddContextFactory(f, context_id); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnTerminate()) @@ -236,11 +236,11 @@ TEST_F(AppCoreMultiWindowBaseTest, AppCoreMultiWindowBase_Resume) { .WillOnce(Invoke([&]() -> int { core.AppCoreMultiWindowBase::OnCreate(); core.AddContextFactory(f, context_id); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnTerminate()) @@ -278,11 +278,11 @@ TEST_F(AppCoreMultiWindowBaseTest, AppCoreMultiWindowBase_OnVisibility) { .WillOnce(Invoke([&]() -> int { core.AppCoreMultiWindowBase::OnCreate(); core.AddContextFactory(f, context_id); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnTerminate()) @@ -356,11 +356,11 @@ TEST_F(AppCoreMultiWindowBaseTest, AppCoreMultiWindowBase_OnAuxMessage) { .WillOnce(Invoke([&]() -> int { core.AppCoreMultiWindowBase::OnCreate(); core.AddContextFactory(f, context_id); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnTerminate()) @@ -410,11 +410,11 @@ TEST_F(AppCoreMultiWindowBaseTest, AppCoreMultiWindowBase_FindById) { .WillOnce(Invoke([&]() -> int { core.AppCoreMultiWindowBase::OnCreate(); core.AddContextFactory(f, context_id); - g_timeout_add(400, [](gpointer data) -> gboolean { + g_idle_add_full(G_PRIORITY_LOW, [](gpointer data) -> gboolean { auto* obj = static_cast*>(data); obj->Exit(); return G_SOURCE_REMOVE; - }, &core); + }, &core, nullptr); return 0; })); EXPECT_CALL(core, OnTerminate()) diff --git a/unittests/mock/aul_mock.cc b/unittests/mock/aul_mock.cc index 332259f..36f828f 100644 --- a/unittests/mock/aul_mock.cc +++ b/unittests/mock/aul_mock.cc @@ -56,4 +56,20 @@ extern "C" int aul_watchdog_kick(void) { extern "C" void aul_app_group_lower(int* exit) { MOCK_HOOK_P1(AulMock, aul_app_group_lower, exit); -} \ No newline at end of file +} + +extern "C" int aul_app_lifecycle_update_state(aul_app_lifecycle_state_e state) { + return MOCK_HOOK_P1(AulMock, aul_app_lifecycle_update_state, state); +} + +extern "C" int aul_status_update(int status) { + return MOCK_HOOK_P1(AulMock, aul_status_update, status); +} + +extern "C" int aul_app_group_set_window(int wid) { + return MOCK_HOOK_P1(AulMock, aul_app_group_set_window, wid); +} + +extern "C" int aul_app_group_activate_below(const char* below_appid) { + return MOCK_HOOK_P1(AulMock, aul_app_group_activate_below, below_appid); +} diff --git a/unittests/mock/aul_mock.h b/unittests/mock/aul_mock.h index 7348693..28fe725 100644 --- a/unittests/mock/aul_mock.h +++ b/unittests/mock/aul_mock.h @@ -21,6 +21,7 @@ #include #include #include +#include #include "mock/module_mock.h" @@ -81,6 +82,22 @@ class AulMock : public virtual ModuleMock { .WillByDefault(Return(0)); ON_CALL(*this, aul_watchdog_kick()) .WillByDefault(Return(0)); + ON_CALL(*this, aul_app_lifecycle_update_state(_)) + .WillByDefault(Invoke([&](aul_app_lifecycle_state_e state) -> int { + return 0; + })); + ON_CALL(*this, aul_status_update(_)) + .WillByDefault(Invoke([&](int status) -> int { + return 0; + })); + ON_CALL(*this, aul_app_group_set_window(_)) + .WillByDefault(Invoke([&](int wid) -> int { + return 0; + })); + ON_CALL(*this, aul_app_group_activate_below(_)) + .WillByDefault(Invoke([&](const char* below_appid) -> int { + return 0; + })); } virtual ~AulMock() {} @@ -94,6 +111,10 @@ class AulMock : public virtual ModuleMock { MOCK_METHOD0(aul_watchdog_disable, int ()); MOCK_METHOD0(aul_watchdog_kick, int ()); MOCK_METHOD1(aul_app_group_lower, void (int*)); + MOCK_METHOD1(aul_app_lifecycle_update_state, int (aul_app_lifecycle_state_e)); + MOCK_METHOD1(aul_status_update, int (int)); + MOCK_METHOD1(aul_app_group_set_window, int (int)); + MOCK_METHOD1(aul_app_group_activate_below, int (const char*)); void SetEvent(aul_type type, bundle* b) { if (args_) -- 2.7.4