Fix component termination behavior 86/274486/3
authorHwankyu Jhun <h.jhun@samsung.com>
Fri, 29 Apr 2022 04:57:50 +0000 (13:57 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 2 May 2022 02:57:46 +0000 (11:57 +0900)
If there is no components, the component-based application has to be
terminated itself.

Change-Id: Id58276e7a7d0e79e8e4adafc8ebbeeb7f8b57a62
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
component_based/base/application_base.cc
test/unit_tests/base/test_component_based_application_base.cc
test/unit_tests/efl_base/test_component_based_app.cc
test/unit_tests/mock/aul_mock.cc [new file with mode: 0644]
test/unit_tests/mock/aul_mock.h [new file with mode: 0644]

index 6e5c0504aeef6d66ab7944d124106d51b1122cac..db10b6a7749866ea5a595d6db274a9bcc61d9f06 100644 (file)
@@ -24,6 +24,7 @@
 #include <glib.h>
 
 #include <memory>
+#include <queue>
 #include <utility>
 
 #include "component_based/common/exception.h"
@@ -45,6 +46,10 @@ class ApplicationBase::Impl {
       g_source_remove(idler_);
   }
 
+  void PendingQueuePush(std::string inst_id);
+  std::string PendingQueuePop();
+  bool PendingQueueEmpty();
+
  private:
   friend class ApplicationBase;
   explicit Impl(ApplicationBase* parent);
@@ -53,8 +58,8 @@ class ApplicationBase::Impl {
   ApplicationBase* parent_;
   std::string app_id_;
   bool exiting_ = false;
-  std::pair<std::string, ApplicationBase*> pending_context_;
-  int idler_ = 0;
+  std::queue<std::string> pending_queue_;
+  guint idler_ = 0;
   tizen_base::Bundle data_;
 };
 
@@ -70,6 +75,20 @@ ApplicationBase::Impl::Impl(ApplicationBase* parent)
   app_id_ = std::string(p.get());
 }
 
+void ApplicationBase::Impl::PendingQueuePush(std::string inst_id) {
+  pending_queue_.push(std::move(inst_id));
+}
+
+std::string ApplicationBase::Impl::PendingQueuePop() {
+  auto inst_id = std::move(pending_queue_.front());
+  pending_queue_.pop();
+  return inst_id;
+}
+
+bool ApplicationBase::Impl::PendingQueueEmpty() {
+  return pending_queue_.empty();
+}
+
 int ApplicationBase::OnCreate() {
   LOGD("");
   int ret = AppCoreMultiWindowBase::OnCreate();
@@ -95,6 +114,11 @@ int ApplicationBase::OnCreate() {
 }
 
 int ApplicationBase::OnTerminate() {
+  if (impl_->idler_ != 0) {
+    g_source_remove(impl_->idler_);
+    impl_->idler_ = 0;
+  }
+
   LOGD("");
   return AppCoreMultiWindowBase::OnTerminate();
 }
@@ -265,13 +289,31 @@ std::string ApplicationBase::GetApplicationID() {
 }
 
 void ApplicationBase::ExitContextAtIdle(const std::string& inst_id) {
-  impl_->pending_context_ = { inst_id, this };
+  impl_->PendingQueuePush(inst_id);
+
+  if (impl_->idler_ != 0)
+    return;
+
   impl_->idler_ = g_idle_add([](gpointer data) -> gboolean {
         ApplicationBase* app = static_cast<ApplicationBase*>(data);
-        auto cxt = app->FindById(app->impl_->pending_context_.first);
-        app->ExitContext(cxt);
-        app->impl_->idler_ = 0;
-        return G_SOURCE_REMOVE;
+        auto inst_id = std::move(app->impl_->PendingQueuePop());
+        auto ctx = app->FindById(inst_id);
+        if (ctx.get() != nullptr)
+          app->ExitContext(ctx);
+
+        if (app->GetContextCnt() == 0) {
+          LOGW("Exit");
+          app->impl_->idler_ = 0;
+          app->Exit();
+          return G_SOURCE_REMOVE;
+        }
+
+        if (app->impl_->PendingQueueEmpty()) {
+          app->impl_->idler_ = 0;
+          return G_SOURCE_REMOVE;
+        }
+
+        return G_SOURCE_CONTINUE;
       }, this);
 }
 
index 548caa801eb6caad7003d264c16184c86388685b..3e1c643e8dc50d8131f6825007927e4627e2da5d 100644 (file)
@@ -16,6 +16,7 @@
 #include "mock/app_control_event_mock.h"
 #include "mock/app_control_mock.h"
 #include "mock/appcore_multiwindow_base_mock.h"
+#include "mock/aul_mock.h"
 #include "mock/base_component_callback_mock.h"
 #include "mock/base_frame_component_callback_mock.h"
 #include "mock/base_service_component_callback_mock.h"
@@ -48,7 +49,8 @@ class Mocks : virtual public ::testing::NiceMock<ElmMock>,
     virtual public ::testing::NiceMock<BaseFrameComponentCallbackMock>,
     virtual public ::testing::NiceMock<BaseServiceComponentCallbackMock>,
     virtual public ::testing::NiceMock<BaseComponentCallbackMock>,
-    virtual public ::testing::NiceMock<AppCoreMultiWindowBaseMock> {};
+    virtual public ::testing::NiceMock<AppCoreMultiWindowBaseMock>,
+    virtual public ::testing::NiceMock<AulMock>{};
 
 ACTION(ReturnFakeWindow) {
   frame_window_h frame_win = nullptr;
@@ -180,7 +182,7 @@ TEST_F(ComponentBasedAppBaseTest, component_based_app_base_main_service) {
       component_based_app_base_create_cb(_))
       .Times(1)
       .WillOnce(DoAll(
-          DoExit(1000),
+          DoExit(10),
           AddServiceBaseComponent(&GetMock<BaseServiceComponentCallbackMock>())
       ));
   EXPECT_CALL(GetMock<ComponentBasedAppBaseCallbackMock>(),
@@ -215,7 +217,7 @@ TEST_F(ComponentBasedAppBaseTest, component_based_app_base_main_frame) {
       component_based_app_base_create_cb(_))
       .Times(1)
       .WillOnce(DoAll(
-          DoExit(1000),
+          DoExit(10),
           AddFrameBaseComponent(&GetMock<BaseFrameComponentCallbackMock>())
       ));
   EXPECT_CALL(GetMock<ComponentBasedAppBaseCallbackMock>(),
@@ -234,7 +236,7 @@ TEST_F(ComponentBasedAppBaseTest, base_service_component_callbacks) {
       component_based_app_base_create_cb(_))
       .Times(1)
       .WillOnce(DoAll(
-          DoExit(1000),
+          DoExit(10),
           AddServiceBaseComponent(&GetMock<BaseServiceComponentCallbackMock>())
       ));
   EXPECT_CALL(GetMock<ComponentBasedAppBaseCallbackMock>(),
@@ -272,7 +274,7 @@ TEST_F(ComponentBasedAppBaseTest, base_service_component_callbacks2) {
       component_based_app_base_create_cb(_))
       .Times(1)
       .WillOnce(DoAll(
-          DoExit(1000),
+          DoExit(10),
           AddServiceBaseComponent(&GetMock<BaseServiceComponentCallbackMock>())
       ));
   EXPECT_CALL(GetMock<ComponentBasedAppBaseCallbackMock>(),
@@ -308,7 +310,7 @@ TEST_F(ComponentBasedAppBaseTest, base_frame_component_callbacks) {
       component_based_app_base_create_cb(_))
       .Times(1)
       .WillOnce(DoAll(
-          DoExit(1000),
+          DoExit(10),
           AddFrameBaseComponent(&GetMock<BaseFrameComponentCallbackMock>())
       ));
   EXPECT_CALL(GetMock<ComponentBasedAppBaseCallbackMock>(),
@@ -354,7 +356,7 @@ TEST_F(ComponentBasedAppBaseTest, base_component_callbacks) {
       component_based_app_base_create_cb(_))
       .Times(1)
       .WillOnce(DoAll(
-          DoExit(1000),
+          DoExit(10),
           AddBaseComponent(&GetMock<BaseComponentCallbackMock>())
       ));
   EXPECT_CALL(GetMock<ComponentBasedAppBaseCallbackMock>(),
@@ -398,7 +400,7 @@ TEST_F(ComponentBasedAppBaseTest, base_frame_component_resume_pause) {
       component_based_app_base_create_cb(_))
       .Times(1)
       .WillOnce(DoAll(
-          DoExit(1000),
+          DoExit(10),
           AddFrameBaseComponent(&GetMock<BaseFrameComponentCallbackMock>())
       ));
   EXPECT_CALL(GetMock<ComponentBasedAppBaseCallbackMock>(),
@@ -445,7 +447,7 @@ TEST_F(ComponentBasedAppBaseTest, component_finish) {
       component_based_app_base_create_cb(_))
       .Times(1)
       .WillOnce(DoAll(
-          DoExit(2000),
+          DoExit(200),
           AddServiceBaseComponent(&GetMock<BaseServiceComponentCallbackMock>())
       ));
   EXPECT_CALL(GetMock<ComponentBasedAppBaseCallbackMock>(),
@@ -483,7 +485,7 @@ TEST_F(ComponentBasedAppBaseTest, component_send_launch_request_sync) {
       component_based_app_base_create_cb(_))
       .Times(1)
       .WillOnce(DoAll(
-          DoExit(1000),
+          DoExit(10),
           AddServiceBaseComponent(&GetMock<BaseServiceComponentCallbackMock>())
       ));
   EXPECT_CALL(GetMock<ComponentBasedAppBaseCallbackMock>(),
@@ -534,7 +536,7 @@ TEST_F(ComponentBasedAppBaseTest, component_send_launch_request_sync2) {
       component_based_app_base_create_cb(_))
       .Times(1)
       .WillOnce(DoAll(
-          DoExit(1000),
+          DoExit(10),
           AddServiceBaseComponent(&GetMock<BaseServiceComponentCallbackMock>())
       ));
   EXPECT_CALL(GetMock<ComponentBasedAppBaseCallbackMock>(),
@@ -587,7 +589,7 @@ TEST_F(ComponentBasedAppBaseTest, component_send_launch_request_async) {
       component_based_app_base_create_cb(_))
       .Times(1)
       .WillOnce(DoAll(
-          DoExit(1000),
+          DoExit(10),
           AddServiceBaseComponent(&GetMock<BaseServiceComponentCallbackMock>())
       ));
   EXPECT_CALL(GetMock<ComponentBasedAppBaseCallbackMock>(),
@@ -639,7 +641,7 @@ TEST_F(ComponentBasedAppBaseTest, component_get_id) {
       component_based_app_base_create_cb(_))
       .Times(1)
       .WillOnce(DoAll(
-          DoExit(1000),
+          DoExit(10),
           AddServiceBaseComponent(&GetMock<BaseServiceComponentCallbackMock>())
       ));
   EXPECT_CALL(GetMock<ComponentBasedAppBaseCallbackMock>(),
@@ -689,7 +691,7 @@ TEST_F(ComponentBasedAppBaseTest, base_frame_component_get_display_status) {
       component_based_app_base_create_cb(_))
       .Times(1)
       .WillOnce(DoAll(
-          DoExit(1000),
+          DoExit(10),
           AddFrameBaseComponent(&GetMock<BaseFrameComponentCallbackMock>())
       ));
   EXPECT_CALL(GetMock<ComponentBasedAppBaseCallbackMock>(),
@@ -731,7 +733,7 @@ TEST_F(ComponentBasedAppBaseTest, component_register_action) {
       component_based_app_base_create_cb(_))
       .Times(1)
       .WillOnce(DoAll(
-          DoExit(1000),
+          DoExit(10),
           AddServiceBaseComponent(&GetMock<BaseServiceComponentCallbackMock>())
       ));
   EXPECT_CALL(GetMock<ComponentBasedAppBaseCallbackMock>(),
@@ -770,7 +772,7 @@ TEST_F(ComponentBasedAppBaseTest, component_send) {
   EXPECT_CALL(GetMock<ComponentBasedAppBaseCallbackMock>(),
       component_based_app_base_create_cb(_))
       .WillOnce(DoAll(
-          DoExit(1000),
+          DoExit(10),
           AddServiceBaseComponent(&GetMock<BaseServiceComponentCallbackMock>())
       ));
   EXPECT_CALL(GetMock<AppCoreMultiWindowBaseMock>(), Run(_, _))
@@ -821,7 +823,7 @@ TEST_F(ComponentBasedAppBaseTest, component_sendasync) {
   EXPECT_CALL(GetMock<ComponentBasedAppBaseCallbackMock>(),
       component_based_app_base_create_cb(_))
       .WillOnce(DoAll(
-          DoExit(1000),
+          DoExit(10),
           AddServiceBaseComponent(&GetMock<BaseServiceComponentCallbackMock>())
       ));
   EXPECT_CALL(GetMock<AppCoreMultiWindowBaseMock>(), Run(_, _))
index 4bd7d09747371468cf2111bf0096ffe20b2e442a..af0ae1f0c37906bda68de52362b38221d8d5cf6a 100644 (file)
@@ -14,6 +14,7 @@
 #include "component_based/efl_base/api/component_based_app.h"
 
 #include "mock/app_common_mock.h"
+#include "mock/aul_mock.h"
 #include "mock/appcore_multiwindow_base_mock.h"
 #include "mock/component_based_app_callback_mock.h"
 #include "mock/frame_component_callback_mock.h"
@@ -44,7 +45,8 @@ class Mocks : virtual public ::testing::NiceMock<ElmMock>,
     virtual public ::testing::NiceMock<ComponentBasedAppCallbackMock>,
     virtual public ::testing::NiceMock<ServiceComponentCallbackMock>,
     virtual public ::testing::NiceMock<FrameComponentCallbackMock>,
-    virtual public ::testing::NiceMock<AppCoreMultiWindowBaseMock> {};
+    virtual public ::testing::NiceMock<AppCoreMultiWindowBaseMock>,
+    virtual public ::testing::NiceMock<AulMock>{};
 
 ACTION_P(DoExit, timeout) {
   g_timeout_add(timeout, [](gpointer data) -> gboolean {
@@ -172,7 +174,7 @@ TEST_F(ComponentBasedAppTest, component_based_app_main) {
       component_based_app_create_cb(_))
       .Times(1)
       .WillOnce(DoAll(
-          DoExit(1000),
+          DoExit(10),
           AddServiceComponent(&GetMock<ServiceComponentCallbackMock>())
       ));
   EXPECT_CALL(GetMock<ComponentBasedAppCallbackMock>(),
@@ -193,7 +195,7 @@ TEST_F(ComponentBasedAppTest, component_based_app_main_with_hwacc) {
       component_based_app_create_cb(_))
       .Times(1)
       .WillOnce(DoAll(
-          DoExit(1000),
+          DoExit(10),
           AddServiceComponent(&GetMock<ServiceComponentCallbackMock>())
       ));
   EXPECT_CALL(GetMock<ComponentBasedAppCallbackMock>(),
@@ -214,7 +216,7 @@ TEST_F(ComponentBasedAppTest, component_based_app_main_without_hwacc) {
       component_based_app_create_cb(_))
       .Times(1)
       .WillOnce(DoAll(
-          DoExit(1000),
+          DoExit(10),
           AddFrameComponent(&GetMock<FrameComponentCallbackMock>())
       ));
   EXPECT_CALL(GetMock<ComponentBasedAppCallbackMock>(),
@@ -272,7 +274,7 @@ TEST_F(ComponentBasedAppTest, service_component_callbacks) {
       component_based_app_create_cb(_))
       .Times(1)
       .WillOnce(DoAll(
-          DoExit(1000),
+          DoExit(10),
           AddServiceComponent(&GetMock<ServiceComponentCallbackMock>())
       ));
   EXPECT_CALL(GetMock<ComponentBasedAppCallbackMock>(),
@@ -305,7 +307,7 @@ TEST_F(ComponentBasedAppTest, frame_component_callbacks) {
       component_based_app_create_cb(_))
       .Times(1)
       .WillOnce(DoAll(
-          DoExit(1000),
+          DoExit(10),
           AddFrameComponent(&GetMock<FrameComponentCallbackMock>())
       ));
   EXPECT_CALL(GetMock<ComponentBasedAppCallbackMock>(),
@@ -344,7 +346,7 @@ TEST_F(ComponentBasedAppTest, frame_component_resume_pause) {
       component_based_app_create_cb(_))
       .Times(1)
       .WillOnce(DoAll(
-          DoExit(1000),
+          DoExit(10),
           AddFrameComponent(&GetMock<FrameComponentCallbackMock>())
       ));
   EXPECT_CALL(GetMock<ComponentBasedAppCallbackMock>(),
@@ -391,7 +393,7 @@ TEST_F(ComponentBasedAppTest, frame_component_get_display_status) {
       component_based_app_create_cb(_))
       .Times(1)
       .WillOnce(DoAll(
-          DoExit(1000),
+          DoExit(10),
           AddFrameComponent(&GetMock<FrameComponentCallbackMock>())
       ));
   EXPECT_CALL(GetMock<ComponentBasedAppCallbackMock>(),
@@ -428,7 +430,7 @@ TEST_F(ComponentBasedAppTest, frame_component_get_window) {
       component_based_app_create_cb(_))
       .Times(1)
       .WillOnce(DoAll(
-          DoExit(1000),
+          DoExit(10),
           AddFrameComponent(&GetMock<FrameComponentCallbackMock>())
       ));
   EXPECT_CALL(GetMock<ComponentBasedAppCallbackMock>(),
@@ -471,7 +473,7 @@ TEST_F(ComponentBasedAppTest, frame_component_events) {
       component_based_app_create_cb(_))
       .Times(1)
       .WillOnce(DoAll(
-          DoExit(1000),
+          DoExit(10),
           AddFrameComponent(&GetMock<FrameComponentCallbackMock>())
       ));
   EXPECT_CALL(GetMock<ComponentBasedAppCallbackMock>(),
@@ -517,7 +519,7 @@ TEST_F(ComponentBasedAppTest, service_component_events) {
       component_based_app_create_cb(_))
       .Times(1)
       .WillOnce(DoAll(
-          DoExit(1000),
+          DoExit(10),
           AddServiceComponent(&GetMock<ServiceComponentCallbackMock>())
       ));
   EXPECT_CALL(GetMock<ComponentBasedAppCallbackMock>(),
@@ -563,7 +565,7 @@ TEST_F(ComponentBasedAppTest, frame_component_pause_resume_event) {
       component_based_app_create_cb(_))
       .Times(1)
       .WillOnce(DoAll(
-          DoExit(1000),
+          DoExit(10),
           AddFrameComponent(&GetMock<FrameComponentCallbackMock>())
       ));
   EXPECT_CALL(GetMock<ComponentBasedAppCallbackMock>(),
@@ -613,7 +615,7 @@ TEST_F(ComponentBasedAppTest, frame_component_previsibility_event) {
       component_based_app_create_cb(_))
       .Times(1)
       .WillOnce(DoAll(
-          DoExit(1000),
+          DoExit(10),
           AddFrameComponent(&GetMock<FrameComponentCallbackMock>())
       ));
   EXPECT_CALL(GetMock<ComponentBasedAppCallbackMock>(),
@@ -654,7 +656,7 @@ TEST_F(ComponentBasedAppTest, frame_component_aux_event) {
   EXPECT_CALL(GetMock<ComponentBasedAppCallbackMock>(),
       component_based_app_create_cb(_))
       .WillOnce(DoAll(
-          DoExit(1000),
+          DoExit(10),
           AddFrameComponent(&GetMock<FrameComponentCallbackMock>())
       ));
   EXPECT_CALL(GetMock<AppCoreMultiWindowBaseMock>(), Run(_, _))
@@ -692,7 +694,7 @@ TEST_F(ComponentBasedAppTest, frame_component_terminate_event) {
       component_based_app_create_cb(_))
       .Times(1)
       .WillOnce(DoAll(
-          DoExit(1000),
+          DoExit(10),
           AddFrameComponent(&GetMock<FrameComponentCallbackMock>())
       ));
   EXPECT_CALL(GetMock<ComponentBasedAppCallbackMock>(),
diff --git a/test/unit_tests/mock/aul_mock.cc b/test/unit_tests/mock/aul_mock.cc
new file mode 100644 (file)
index 0000000..ecdc0a5
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+#include <bundle_internal.h>
+
+#include "mock/aul_mock.h"
+#include "mock/mock_hook.h"
+#include "mock/test_fixture.h"
+
+extern "C" int aul_app_get_appid_bypid(int pid, char *appid, int len) {
+  return MOCK_HOOK_P3(AulMock, aul_app_get_appid_bypid, pid, appid, len);
+}
+
+extern "C" const char* aul_get_app_resource_path(void) {
+  return MOCK_HOOK_P0(AulMock, aul_get_app_resource_path);
+}
+
+extern "C" int aul_watchdog_enable(void) {
+  return MOCK_HOOK_P0(AulMock, aul_watchdog_enable);
+}
+
+extern "C" int aul_watchdog_disable(void) {
+  return MOCK_HOOK_P0(AulMock, aul_watchdog_disable);
+}
+
+extern "C" int aul_watchdog_kick(void) {
+  return MOCK_HOOK_P0(AulMock, aul_watchdog_kick);
+}
+
+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_comp_notify_start(const char* instance_id) {
+  return MOCK_HOOK_P1(AulMock, aul_comp_notify_start, instance_id);
+}
+
+extern "C" int aul_comp_notify_exit(const char* instance_id) {
+  return MOCK_HOOK_P1(AulMock, aul_comp_notify_exit, instance_id);
+}
+
+extern "C" int aul_comp_status_update(const char* instance_id, int status) {
+  return MOCK_HOOK_P2(AulMock, aul_comp_status_update, instance_id, status);
+}
diff --git a/test/unit_tests/mock/aul_mock.h b/test/unit_tests/mock/aul_mock.h
new file mode 100644 (file)
index 0000000..957ebca
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef UNIT_TESTS_MOCK_AUL_MOCK_H_
+#define UNIT_TESTS_MOCK_AUL_MOCK_H_
+
+#include <gmock/gmock.h>
+#include <bundle_internal.h>
+#include <bundle_cpp.h>
+#include <aul.h>
+#include <aul_app_lifecycle.h>
+
+#include "mock/module_mock.h"
+
+class AulMock : public virtual ModuleMock {
+ public:
+  AulMock() {
+    using ::testing::_;
+    using ::testing::Return;
+    using ::testing::Invoke;
+
+    ON_CALL(*this, aul_app_get_appid_bypid(_, _, _))
+        .WillByDefault(Invoke([&](int pid, char *appid, int len) -> int {
+          snprintf(appid, len, "test_appid");
+          return 0;
+        }));
+    ON_CALL(*this, aul_get_app_resource_path())
+        .WillByDefault(Invoke([&]() -> const char* {
+          static const char res_path[] = "/tmp/";
+          return res_path;
+        }));
+    ON_CALL(*this, aul_watchdog_enable())
+        .WillByDefault(Return(0));
+    ON_CALL(*this, aul_watchdog_disable())
+        .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_comp_notify_start(_))
+        .WillByDefault(Invoke([&](const char* instance_id) -> int {
+          return 0;
+        }));
+    ON_CALL(*this, aul_comp_notify_exit(_))
+        .WillByDefault(Invoke([&](const char* instance_id) -> int {
+          return 0;
+        }));
+    ON_CALL(*this, aul_comp_status_update(_, _))
+        .WillByDefault(Invoke([&](const char* instance_id, int status) -> int {
+          return 0;
+        }));
+  }
+
+  virtual ~AulMock() {}
+
+  MOCK_METHOD3(aul_app_get_appid_bypid, int (int, char*, int));
+  MOCK_METHOD0(aul_get_app_resource_path, const char* ());
+  MOCK_METHOD0(aul_watchdog_enable, int ());
+  MOCK_METHOD0(aul_watchdog_disable, int ());
+  MOCK_METHOD0(aul_watchdog_kick, int ());
+  MOCK_METHOD1(aul_app_lifecycle_update_state, int (aul_app_lifecycle_state_e));
+  MOCK_METHOD1(aul_status_update, int (int));
+  MOCK_METHOD1(aul_comp_notify_start, int (const char*));
+  MOCK_METHOD1(aul_comp_notify_exit, int (const char*));
+  MOCK_METHOD2(aul_comp_status_update, int (const char*, int));
+};
+
+#endif  // UNIT_TESTS_MOCK_AUL_MOCK_H_
+