impl_->Exit();
}
+// LCOV_EXCL_START
void ApplicationBase::OnInit(int argc, char** argv) {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void ApplicationBase::OnFini() {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void ApplicationBase::OnRun() {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void ApplicationBase::OnExit() {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
std::map<std::string, std::unique_ptr<Component::Factory>>
ApplicationBase::OnCreate() {
std::map<std::string, std::unique_ptr<Component::Factory>> facs;
return facs;
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void ApplicationBase::OnTerminate() {
}
+// LCOV_EXCL_STOP
} // namespace component_based
parent_->OnBaseSuspendedStateChanged(state);
}
+// LCOV_EXCL_START
bool Component::OnBaseCreate() {
return true;
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void Component::OnBaseDestroy() {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void Component::OnBaseStart(AppControl control, bool restarted) {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void Component::OnBaseResume() {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void Component::OnBasePause() {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void Component::OnBaseStop() {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void Component::OnBaseRestoreContent(tizen_base::Bundle content) {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void Component::OnBaseSaveContent(tizen_base::Bundle& content) {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void Component::OnBaseAction(std::string action, AppControl app_control) {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void Component::OnBaseDeviceOrientationChanged(
DeviceOrientation::Orientation orientation) {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void Component::OnBaseLanguageChanged(std::string language) {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void Component::OnBaseRegionFormatChanged(std::string region) {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void Component::OnBaseLowBattery(LowBattery::Status status) {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void Component::OnBaseLowMemory(LowMemory::Status status) {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void Component::OnBaseSuspendedStateChanged(SuspendedState::State state) {
}
+// LCOV_EXCL_STOP
void Component::Impl::RegisterAction(std::string app_control_name) {
auto act_iter = act_map_.find(app_control_name);
return true;
}
+// LCOV_EXCL_START
void Component::Impl::OnAppControlReply(app_control_h request,
app_control_h reply,
app_control_result_e result,
LOGE("Exception occurred (%s)", ex.what());
}
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void Component::Impl::OnAppControlResult(app_control_h request,
app_control_error_e result,
void* user_data) {
LOGE("Exception occurred (%s)", ex.what());
}
}
+// LCOV_EXCL_STOP
Component::State Component::GetState() {
return impl_->state_;
return r;
}
+// LCOV_EXCL_START
int ContentManager::File::Delete() {
int retry_count = 0;
int r = TryDelete();
return r;
}
+// LCOV_EXCL_STOP
bool ContentManager::File::IsExisting() {
if (access(path_.c_str(), F_OK) == 0)
return static_cast<int>(total_size);
}
+// LCOV_EXCL_START
int ContentManager::File::TryDelete() {
int r = unlink(path_.c_str());
if (r != 0) {
}
return 0;
}
+// LCOV_EXCL_STOP
} // namespace internal
} // namespace component_based
path_ = std::string(data_path) + ".content/";
free(data_path);
} else {
- path_ = std::string("/run/aul/dbspace/.content/");
+ path_ = std::string("/run/.content/");
}
if (access(path_.c_str(), F_OK) != 0) {
void FrameComponent::OnBaseSaveContent(tizen_base::Bundle& content) {
}
+// LCOV_EXCL_START
void FrameComponent::OnBaseAction(std::string action, AppControl app_control) {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void FrameComponent::OnBaseDeviceOrientationChanged(
DeviceOrientation::Orientation orientation) {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void FrameComponent::OnBaseLanguageChanged(std::string language) {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void FrameComponent::OnBaseRegionFormatChanged(std::string region) {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void FrameComponent::OnBaseLowBattery(LowBattery::Status status) {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void FrameComponent::OnBaseLowMemory(LowMemory::Status status) {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void FrameComponent::OnBaseSuspendedStateChanged(SuspendedState::State state) {
}
+// LCOV_EXCL_STOP
std::unique_ptr<IWindow> FrameComponent::OnCreate() {
return nullptr;
namespace component_based {
+// LCOV_EXCL_START
FrameWindow::FrameWindow(int id, void* raw) : id_(id), raw_(raw) {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
FrameWindow::~FrameWindow() {
-
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
int FrameWindow::GetResID() const {
return id_;
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void* FrameWindow::GetRaw() {
return raw_;
}
+// LCOV_EXCL_STOP
} // namespace component_based
SetContent(std::move(content));
}
+// LCOV_EXCL_START
void ServiceComponent::OnBaseResume() {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void ServiceComponent::OnBasePause() {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void ServiceComponent::OnBaseStop() {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void ServiceComponent::OnBaseRestoreContent(tizen_base::Bundle content) {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void ServiceComponent::OnBaseSaveContent(tizen_base::Bundle& content) {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void ServiceComponent::OnBaseAction(std::string action, AppControl app_control) {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void ServiceComponent::OnBaseDeviceOrientationChanged(
DeviceOrientation::Orientation orientation) {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void ServiceComponent::OnBaseLanguageChanged(std::string language) {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void ServiceComponent::OnBaseRegionFormatChanged(std::string region) {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void ServiceComponent::OnBaseLowBattery(LowBattery::Status status) {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void ServiceComponent::OnBaseLowMemory(LowMemory::Status status) {
}
+// LCOV_EXCL_STOP
+// LCOV_EXCL_START
void ServiceComponent::OnBaseSuspendedStateChanged(SuspendedState::State state) {
}
+// LCOV_EXCL_STOP
bool ServiceComponent::OnCreate() {
return false;
}
void OnBaseAction(std::string action,
- component_based::AppControl app_control) override {
+ component_based::AppControl app_control) override {
if (cb_.action)
cb_.action(this, action.c_str(), app_control.GetHandle(), user_data_);
}
*res_id = ecore_wl2_window_id_get(wl_win);
return COMPONENT_ERROR_NONE;
-}
\ No newline at end of file
+}
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/mock UNIT_TEST_SOURCES)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCES)
-AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src/base SOURCES)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src/base BASE_SOURCES)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src/efl_base EFL_BASE_SOURCES)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../component_based/efl_base APPLICATION_SOURCES)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../component_based/base CORE_BASE_SOURCES)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../component_based/uri URI_SOURCES)
${CORE_BASE_SOURCES}
${UNIT_TEST_SOURCES}
${SOURCES}
+ ${BASE_SOURCES}
+ ${EFL_BASE_SOURCES}
)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${component-based_unittests_LDFLAGS})
#include "mock.h"
-#include "mock_app_control.h"
#include "mock_app_common.h"
-#include "mock_elementary.h"
+#include "mock_app_control.h"
#include "mock_appcore_multiwindow_base.h"
+#include "mock_aul.h"
+#include "mock_elementary.h"
DEFINE_FFF_GLOBALS;
/* app_common.h */
DEFINE_FAKE_VALUE_FUNC(int, app_get_id, char**);
+
DEFINE_FAKE_VALUE_FUNC(char*, app_get_data_path);
+
DEFINE_FAKE_VALUE_FUNC(int, app_get_display_state, app_display_state_e*);
+
DEFINE_FAKE_VALUE_FUNC(int, app_resource_manager_get, app_resource_e,
const char*, char**);
/* Elementary.h */
DEFINE_FAKE_VALUE_FUNC(int, elm_init, int, char**);
+
DEFINE_FAKE_VALUE_FUNC(int, elm_shutdown);
+
DEFINE_FAKE_VOID_FUNC(elm_run);
+
DEFINE_FAKE_VOID_FUNC(elm_exit);
+
DEFINE_FAKE_VALUE_FUNC(Evas_Object*, elm_win_util_standard_add, const char*,
const char*);
+
DEFINE_FAKE_VALUE_FUNC(Evas*, evas_object_evas_get, const Eo*);
+
DEFINE_FAKE_VALUE_FUNC(Ecore_Evas*, ecore_evas_ecore_evas_get, const Evas*);
+
DEFINE_FAKE_VALUE_FUNC(Ecore_Wl2_Window*, ecore_evas_wayland2_window_get,
- const Ecore_Evas*);
+ const Ecore_Evas*);
+
DEFINE_FAKE_VALUE_FUNC(int, ecore_wl2_window_id_get, Ecore_Wl2_Window*);
+DEFINE_FAKE_VOID_FUNC(evas_object_del, Evas_Object*);
+
+DEFINE_FAKE_VOID_FUNC(elm_config_accel_preference_set, const char*);
+
+DEFINE_FAKE_VOID_FUNC(ecore_wl2_window_activate, Ecore_Wl2_Window*);
+
+DEFINE_FAKE_VOID_FUNC(ecore_wl2_window_iconified_set, Ecore_Wl2_Window*,
+ Eina_Bool);
+
+DEFINE_FAKE_VALUE_FUNC(Ecore_Wl2_Window*, ecore_wl2_display_window_find,
+ Ecore_Wl2_Display*, unsigned int);
/* appcore_multiwindow_base.h */
DEFINE_FAKE_VALUE_FUNC(int, appcore_multiwindow_base_init,
appcore_multiwindow_base_ops, int, char**, void*);
+
DEFINE_FAKE_VALUE_FUNC(appcore_multiwindow_base_instance_h,
appcore_multiwindow_base_instance_run,
const char*, const char*, void*);
+
DEFINE_FAKE_VALUE_FUNC(appcore_multiwindow_base_instance_h,
appcore_multiwindow_base_instance_find, const char*);
+
DEFINE_FAKE_VALUE_FUNC(bool, appcore_multiwindow_base_instance_is_resumed,
- appcore_multiwindow_base_instance_h);
+ appcore_multiwindow_base_instance_h);
+
DEFINE_FAKE_VOID_FUNC(appcore_multiwindow_base_instance_exit,
- appcore_multiwindow_base_instance_h);
+ appcore_multiwindow_base_instance_h);
+
DEFINE_FAKE_VOID_FUNC(appcore_multiwindow_base_window_unbind,
- appcore_multiwindow_base_instance_h);
+ appcore_multiwindow_base_instance_h);
+
DEFINE_FAKE_VALUE_FUNC(appcore_multiwindow_base_ops,
- appcore_multiwindow_base_get_default_ops);
+ appcore_multiwindow_base_get_default_ops);
+
+DEFINE_FAKE_VOID_FUNC(appcore_multiwindow_base_fini);
+
+DEFINE_FAKE_VOID_FUNC(appcore_multiwindow_base_exit);
+
+DEFINE_FAKE_VOID_FUNC(appcore_multiwindow_base_class_add,
+ appcore_multiwindow_base_class);
+
+DEFINE_FAKE_VALUE_FUNC(const char*, appcore_multiwindow_base_instance_get_id,
+ appcore_multiwindow_base_instance_h);
+
+DEFINE_FAKE_VOID_FUNC(appcore_multiwindow_base_instance_resume,
+ appcore_multiwindow_base_instance_h);
+
+DEFINE_FAKE_VOID_FUNC(appcore_multiwindow_base_instance_pause,
+ appcore_multiwindow_base_instance_h);
+
+DEFINE_FAKE_VOID_FUNC(appcore_multiwindow_base_window_on_visibility,
+ int, void*);
+
+DEFINE_FAKE_VALUE_FUNC(appcore_base_event_h, appcore_base_add_event,
+ enum appcore_base_event, appcore_base_event_cb, void *);
+
+/* aul.h */
+DEFINE_FAKE_VALUE_FUNC(int, aul_app_group_set_window_v2, const char*, int);
+
+DEFINE_FAKE_VALUE_FUNC(int, aul_app_group_lower_v2, const char*, bool*);
+
+DEFINE_FAKE_VALUE_FUNC(int, aul_comp_notify_start, const char*);
+DEFINE_FAKE_VALUE_FUNC(int, aul_comp_status_update, const char*, int);
#endif
DECLARE_FAKE_VALUE_FUNC(int, app_get_id, char**);
+
DECLARE_FAKE_VALUE_FUNC(char*, app_get_data_path);
+
DECLARE_FAKE_VALUE_FUNC(int, app_get_display_state, app_display_state_e*);
+
DECLARE_FAKE_VALUE_FUNC(int, app_resource_manager_get, app_resource_e,
const char*, char**);
DECLARE_FAKE_VALUE_FUNC(int, appcore_multiwindow_base_init,
appcore_multiwindow_base_ops, int, char**, void*);
+
DECLARE_FAKE_VALUE_FUNC(appcore_multiwindow_base_instance_h,
- appcore_multiwindow_base_instance_run,
- const char*, const char*, void*);
+ appcore_multiwindow_base_instance_run, const char*,
+ const char*, void*);
+
DECLARE_FAKE_VALUE_FUNC(appcore_multiwindow_base_instance_h,
appcore_multiwindow_base_instance_find, const char*);
+
DECLARE_FAKE_VALUE_FUNC(bool, appcore_multiwindow_base_instance_is_resumed,
- appcore_multiwindow_base_instance_h);
+ appcore_multiwindow_base_instance_h);
+
DECLARE_FAKE_VOID_FUNC(appcore_multiwindow_base_instance_exit,
- appcore_multiwindow_base_instance_h);
+ appcore_multiwindow_base_instance_h);
+
DECLARE_FAKE_VOID_FUNC(appcore_multiwindow_base_window_unbind,
- appcore_multiwindow_base_instance_h);
+ appcore_multiwindow_base_instance_h);
+
DECLARE_FAKE_VALUE_FUNC(appcore_multiwindow_base_ops,
- appcore_multiwindow_base_get_default_ops);
+ appcore_multiwindow_base_get_default_ops);
+
+DECLARE_FAKE_VOID_FUNC(appcore_multiwindow_base_fini);
+
+DECLARE_FAKE_VOID_FUNC(appcore_multiwindow_base_exit);
+
+DECLARE_FAKE_VOID_FUNC(appcore_multiwindow_base_class_add,
+ appcore_multiwindow_base_class);
+
+DECLARE_FAKE_VALUE_FUNC(const char*, appcore_multiwindow_base_instance_get_id,
+ appcore_multiwindow_base_instance_h);
+
+DECLARE_FAKE_VOID_FUNC(appcore_multiwindow_base_instance_resume,
+ appcore_multiwindow_base_instance_h);
+
+DECLARE_FAKE_VOID_FUNC(appcore_multiwindow_base_instance_pause,
+ appcore_multiwindow_base_instance_h);
+
+DECLARE_FAKE_VOID_FUNC(appcore_multiwindow_base_window_on_visibility,
+ int, void *)
+
+DECLARE_FAKE_VALUE_FUNC(appcore_base_event_h, appcore_base_add_event,
+ enum appcore_base_event, appcore_base_event_cb, void *);
#ifdef __cplusplus
}
--- /dev/null
+/*
+ * Copyright (c) 2019 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_MOCK_AUL_H_
+#define UNIT_TESTS_MOCK_MOCK_AUL_H_
+
+#include <aul.h>
+
+#include "mock.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+DECLARE_FAKE_VALUE_FUNC(int, aul_app_group_set_window_v2, const char*, int);
+
+DECLARE_FAKE_VALUE_FUNC(int, aul_app_group_lower_v2, const char*, bool*);
+
+DECLARE_FAKE_VALUE_FUNC(int, aul_comp_notify_start, const char*);
+
+DECLARE_FAKE_VALUE_FUNC(int, aul_comp_status_update, const char*, int);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* UNIT_TESTS_MOCK_MOCK_AUL_H_ */
#endif
DECLARE_FAKE_VALUE_FUNC(int, elm_init, int, char**);
+
DECLARE_FAKE_VALUE_FUNC(int, elm_shutdown);
+
DECLARE_FAKE_VOID_FUNC(elm_run);
+
DECLARE_FAKE_VOID_FUNC(elm_exit);
-DECLARE_FAKE_VALUE_FUNC(Evas_Object*, elm_win_util_standard_add,
- const char*, const char*);
+
+DECLARE_FAKE_VALUE_FUNC(Evas_Object*, elm_win_util_standard_add, const char*,
+ const char*);
+
DECLARE_FAKE_VALUE_FUNC(Evas*, evas_object_evas_get, const Eo*);
+
DECLARE_FAKE_VALUE_FUNC(Ecore_Evas*, ecore_evas_ecore_evas_get, const Evas*);
+
DECLARE_FAKE_VALUE_FUNC(Ecore_Wl2_Window*, ecore_evas_wayland2_window_get,
- const Ecore_Evas*);
+ const Ecore_Evas*);
+
DECLARE_FAKE_VALUE_FUNC(int, ecore_wl2_window_id_get, Ecore_Wl2_Window*);
+DECLARE_FAKE_VOID_FUNC(evas_object_del, Evas_Object*);
+
+DECLARE_FAKE_VOID_FUNC(elm_config_accel_preference_set, const char*);
+
+DECLARE_FAKE_VOID_FUNC(ecore_wl2_window_activate, Ecore_Wl2_Window*);
+
+DECLARE_FAKE_VOID_FUNC(ecore_wl2_window_iconified_set, Ecore_Wl2_Window*,
+ Eina_Bool);
+
+DECLARE_FAKE_VALUE_FUNC(Ecore_Wl2_Window*, ecore_wl2_display_window_find,
+ Ecore_Wl2_Display*, unsigned int);
#ifdef __cplusplus
}
};
};
-appcore_multiwindow_base_instance_h __fake_appcore_multiwindow_base_instance_run(
+static appcore_multiwindow_base_instance_h __fake_appcore_multiwindow_base_instance_run(
const char* class_id, const char* id, void* extra)
{
return nullptr;
--- /dev/null
+// Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#include <glib.h>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+#include <stdlib.h>
+
+#include "component_based/efl_base/api/frame_component.h"
+#include "component_based/efl_base/api/service_component.h"
+#include "component_based/efl_base/api/component_based_app.h"
+
+#include "unit_tests/mock/mock_appcore_multiwindow_base.h"
+#include "unit_tests/mock/mock_elementary.h"
+
+namespace {
+
+static appcore_multiwindow_base_ops __ops;
+static int __argc;
+static char** __argv;
+static void* __user_data;
+
+static int __fake_appcore_multiwindow_base_init(
+ appcore_multiwindow_base_ops ops,
+ int argc,
+ char** argv,
+ void* user_data) {
+ __ops = ops;
+ __argc = argc;
+ __argv = argv;
+ __user_data = user_data;
+
+ __ops.base.init(__argc, __argv, __user_data);
+ __ops.base.create(__user_data);
+ __ops.base.run(__user_data);
+
+ return 0;
+}
+
+static void __fake_appcore_multiwindow_base_fini(void) {
+ __ops.base.terminate(__user_data);
+ __ops.base.finish();
+}
+
+static void __fake_appcore_multiwindow_base_exit(void) {
+ __ops.base.exit(__user_data);
+}
+
+static int __fake_elm_init(int argc, char** argv) {
+ return 0;
+}
+
+static int __fake_elm_shutdown(void) {
+ return 0;
+}
+
+static Evas_Object* __fake_elm_win_util_standard_add(const char* name,
+ const char* title) {
+ Evas_Object* win = reinterpret_cast<Evas_Object*>(malloc(sizeof(void*)));
+ return win;
+}
+
+static void __fake_evas_object_del(Evas_Object* object) {
+ free(object);
+}
+
+static void __fake_elm_config_accel_preference_set(const char* pref) {
+}
+
+class ComponentBasedAppTest : public ::testing::Test {
+ protected:
+ void SetUp() override {
+ appcore_multiwindow_base_init_fake.custom_fake =
+ __fake_appcore_multiwindow_base_init;
+ appcore_multiwindow_base_fini_fake.custom_fake =
+ __fake_appcore_multiwindow_base_fini;
+ appcore_multiwindow_base_exit_fake.custom_fake =
+ __fake_appcore_multiwindow_base_exit;
+
+ elm_init_fake.custom_fake =
+ __fake_elm_init;
+ elm_shutdown_fake.custom_fake =
+ __fake_elm_shutdown;
+ elm_win_util_standard_add_fake.custom_fake =
+ __fake_elm_win_util_standard_add;
+
+ evas_object_del_fake.custom_fake =
+ __fake_evas_object_del;
+
+ elm_config_accel_preference_set_fake.custom_fake =
+ __fake_elm_config_accel_preference_set;
+ }
+ void TearDown() override {}
+
+ bool created_ = false;
+ bool terminated_ = false;
+};
+
+static bool __service_component_create_cb(component_h context,
+ void* user_data) {
+ return true;
+}
+
+static void __service_component_start_command_cb(component_h context,
+ app_control_h app_control, bool restarted, void* user_data) {
+}
+
+static void __service_component_destroy_cb(component_h context,
+ void *user_data) {
+}
+
+static void __service_component_restore_content_cb(component_h context,
+ bundle* content, void* user_data) {
+}
+
+static void __service_component_save_content_cb(component_h context,
+ bundle* content, void* user_data) {
+}
+
+static void __service_component_action_cb(component_h context,
+ const char* action, app_control_h app_control, void* user_data) {
+}
+
+static void __service_component_device_orientation_changed_cb(
+ component_h context, component_device_orientation_e orientation,
+ void* user_data) {
+}
+
+static void __service_component_language_changed_cb(component_h context,
+ const char* language, void* user_data) {
+}
+
+static void __service_component_region_format_changed_cb(component_h context,
+ const char* region, void* user_data) {
+}
+
+static void __service_component_low_battery_cb(component_h context,
+ component_low_battery_status_e status, void* user_data) {
+}
+
+static void __service_component_low_memory_cb(component_h context,
+ component_low_memory_status_e status, void* user_data) {
+}
+
+static void __service_component_suspended_state_changed_cb(component_h context,
+ component_suspended_state_e state, void* user_data) {
+}
+
+static component_class_h __service_component_add(
+ component_class_h component_class, const char* component_id,
+ void* user_data) {
+ service_component_lifecycle_callback_s callback;
+ callback.create =
+ __service_component_create_cb;
+ callback.start_command =
+ __service_component_start_command_cb;
+ callback.destroy =
+ __service_component_destroy_cb;
+ callback.restore_content =
+ __service_component_restore_content_cb;
+ callback.save_content =
+ __service_component_save_content_cb;
+ callback.action =
+ __service_component_action_cb;
+ callback.device_orientation_changed =
+ __service_component_device_orientation_changed_cb;
+ callback.language_changed =
+ __service_component_language_changed_cb;
+ callback.region_format_changed =
+ __service_component_region_format_changed_cb;
+ callback.low_battery =
+ __service_component_low_battery_cb;
+ callback.low_memory =
+ __service_component_low_memory_cb;
+ callback.suspended_state_changed =
+ __service_component_suspended_state_changed_cb;
+
+ return component_based_app_add_service_component(component_class,
+ component_id, &callback, user_data);
+}
+
+static Evas_Object* __frame_component_create_cb(component_h context,
+ void* user_data) {
+ return elm_win_util_standard_add("frame", "frame");
+}
+
+static void __frame_component_start_cb(component_h context,
+ app_control_h app_control, bool restarted, void* user_data) {
+}
+
+static void __frame_component_resume_cb(component_h context,
+ void* user_data) {
+}
+
+static void __frame_component_pause_cb(component_h context,
+ void* user_data) {
+}
+
+static void __frame_component_stop_cb(component_h context,
+ void* user_data) {
+}
+
+static void __frame_component_destroy_cb(component_h context,
+ void *user_data) {
+}
+
+static void __frame_component_restore_content_cb(component_h context,
+ bundle* content, void* user_data) {
+}
+
+static void __frame_component_save_content_cb(component_h context,
+ bundle* content, void* user_data) {
+}
+
+static void __frame_component_action_cb(component_h context,
+ const char* action, app_control_h app_control, void* user_data) {
+}
+
+static void __frame_component_device_orientation_changed_cb(
+ component_h context, component_device_orientation_e orientation,
+ void* user_data) {
+}
+
+static void __frame_component_language_changed_cb(component_h context,
+ const char* language, void* user_data) {
+}
+
+static void __frame_component_region_format_changed_cb(component_h context,
+ const char* region, void* user_data) {
+}
+
+static void __frame_component_low_battery_cb(component_h context,
+ component_low_battery_status_e status, void* user_data) {
+}
+
+static void __frame_component_low_memory_cb(component_h context,
+ component_low_memory_status_e status, void* user_data) {
+}
+
+static void __frame_component_suspended_state_changed_cb(component_h context,
+ component_suspended_state_e state, void* user_data) {
+}
+
+static component_class_h __frame_component_add(
+ component_class_h component_class, const char* component_id,
+ void* user_data) {
+ frame_component_lifecycle_callback_s callback;
+ callback.create =
+ __frame_component_create_cb;
+ callback.start =
+ __frame_component_start_cb;
+ callback.resume =
+ __frame_component_resume_cb;
+ callback.pause =
+ __frame_component_pause_cb;
+ callback.stop =
+ __frame_component_stop_cb;
+ callback.destroy =
+ __frame_component_destroy_cb;
+ callback.restore_content =
+ __frame_component_restore_content_cb;
+ callback.save_content =
+ __frame_component_save_content_cb;
+ callback.action =
+ __frame_component_action_cb;
+ callback.device_orientation_changed =
+ __frame_component_device_orientation_changed_cb;
+ callback.language_changed =
+ __frame_component_language_changed_cb;
+ callback.region_format_changed =
+ __frame_component_region_format_changed_cb;
+ callback.low_battery =
+ __frame_component_low_battery_cb;
+ callback.low_memory =
+ __frame_component_low_memory_cb;
+ callback.suspended_state_changed =
+ __frame_component_suspended_state_changed_cb;
+
+ return component_based_app_add_frame_component(component_class,
+ component_id, &callback, user_data);
+}
+
+static component_class_h __component_based_app_create_cb(void* user_data) {
+ component_class_h component_class = nullptr;
+ component_class = __service_component_add(component_class,
+ "service-component", user_data);
+ component_class = __frame_component_add(component_class,
+ "frame-component", user_data);
+
+ return component_class;
+}
+
+static void __component_based_app_terminate_cb(void* user_data) {
+
+}
+
+TEST_F(ComponentBasedAppTest, component_based_app_main) {
+ component_based_app_lifecycle_callback_s callback;
+ callback.create = __component_based_app_create_cb;
+ callback.terminate = __component_based_app_terminate_cb;
+
+ int argc = 1;
+ char tmp_arg[] = "test";
+ char** argv = reinterpret_cast<char**>(&tmp_arg);
+
+ setenv("AUL_LOADER_INIT", "1", 1);
+ int ret = component_based_app_main(argc, argv, &callback, this);
+ unsetenv("AUL_LOADER_INIT");
+ EXPECT_EQ(ret, APP_ERROR_NONE);
+}
+
+TEST_F(ComponentBasedAppTest, component_based_app_main_with_hwacc) {
+ component_based_app_lifecycle_callback_s callback;
+ callback.create = __component_based_app_create_cb;
+ callback.terminate = __component_based_app_terminate_cb;
+
+ int argc = 1;
+ char tmp_arg[] = "test";
+ char** argv = reinterpret_cast<char**>(&tmp_arg);
+
+ setenv("HWACC", "USE", 1);
+ int ret = component_based_app_main(argc, argv, &callback, this);
+ unsetenv("HWACC");
+ EXPECT_EQ(ret, APP_ERROR_NONE);
+}
+
+TEST_F(ComponentBasedAppTest, component_based_app_main_without_hwacc) {
+ component_based_app_lifecycle_callback_s callback;
+ callback.create = __component_based_app_create_cb;
+ callback.terminate = __component_based_app_terminate_cb;
+
+ int argc = 1;
+ char tmp_arg[] = "test";
+ char** argv = reinterpret_cast<char**>(&tmp_arg);
+
+ setenv("HWACC", "NOT_USE", 1);
+ int ret = component_based_app_main(argc, argv, &callback, this);
+ unsetenv("HWACC");
+ EXPECT_EQ(ret, APP_ERROR_NONE);
+}
+
+TEST_F(ComponentBasedAppTest, component_based_app_main_with_nullptr) {
+ int ret = component_based_app_main(0, nullptr, nullptr, nullptr);
+ EXPECT_EQ(ret, APP_ERROR_INVALID_PARAMETER);
+}
+
+TEST_F(ComponentBasedAppTest, component_based_app_exit) {
+ int ret = component_based_app_exit();
+ EXPECT_EQ(ret, APP_ERROR_NONE);
+}
+
+TEST_F(ComponentBasedAppTest, component_based_app_add_frame_component) {
+ component_class_h component_class = nullptr;
+ component_class = __frame_component_add(component_class,
+ "frame-component-test", nullptr);
+ EXPECT_NE(component_class, nullptr);
+}
+
+TEST_F(ComponentBasedAppTest,
+ component_based_app_add_frame_component_with_nullptr) {
+ component_class_h component_class = nullptr;
+ component_class = __frame_component_add(component_class, nullptr, nullptr);
+ EXPECT_EQ(component_class, nullptr);
+ EXPECT_EQ(get_last_result(), APP_ERROR_INVALID_PARAMETER);
+}
+
+
+TEST_F(ComponentBasedAppTest,
+ component_based_app_add_service_component_with_nullptr) {
+ component_class_h component_class = nullptr;
+ component_class = __service_component_add(component_class, nullptr, nullptr);
+ EXPECT_EQ(component_class, nullptr);
+ EXPECT_EQ(get_last_result(), APP_ERROR_INVALID_PARAMETER);
+}
+
+} // namespace
--- /dev/null
+// Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#include <glib.h>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+#include <stdlib.h>
+#include <aul.h>
+#include <bundle.h>
+
+#include <memory>
+
+#include "component_based/efl_base/api/frame_component.h"
+#include "component_based/efl_base/api/frame_component_internal.h"
+#include "component_based/efl_base/api/service_component.h"
+#include "component_based/efl_base/api/component_based_app.h"
+
+#include "unit_tests/mock/mock_app_common.h"
+#include "unit_tests/mock/mock_app_control.h"
+#include "unit_tests/mock/mock_appcore_multiwindow_base.h"
+#include "unit_tests/mock/mock_aul.h"
+#include "unit_tests/mock/mock_elementary.h"
+
+namespace {
+
+static appcore_multiwindow_base_ops __ops;
+static int __argc;
+static char** __argv;
+static void* __user_data;
+static appcore_multiwindow_base_class __cls;
+static bool __is_resumed;
+static appcore_base_event_cb __event_cb[APPCORE_BASE_EVENT_MAX];
+static void* __event_data[APPCORE_BASE_EVENT_MAX];
+
+static void __generate_show_event(void) {
+ Ecore_Wl2_Event_Window_Show ev = {
+ .win = 1,
+ .parent_win = 1,
+ .event_win = 1,
+ .data = { 1, }
+ };
+
+ __ops.window.show(ECORE_WL2_EVENT_WINDOW_SHOW, &ev, __user_data);
+}
+
+static void __generate_hide_event(void) {
+ Ecore_Wl2_Event_Window_Hide ev = {
+ .win = 1,
+ .parent_win = 1,
+ .event_win = 1
+ };
+
+ __ops.window.hide(ECORE_WL2_EVENT_WINDOW_HIDE, &ev, __user_data);
+}
+
+static void __generate_lower_event(void) {
+ Ecore_Wl2_Event_Window_Lower ev = {
+ .win = 1,
+ .timestamp = 2
+ };
+
+ __ops.window.lower(ECORE_WL2_EVENT_WINDOW_LOWER, &ev, __user_data);
+}
+
+static void __generate_aux_message(void) {
+ Ecore_Wl2_Event_Aux_Message ev = {
+ .win = 1,
+ .key = "dpms",
+ .val = "on",
+ };
+
+ __ops.window.aux_message(ECORE_WL2_EVENT_AUX_MESSAGE, &ev, __user_data);
+}
+
+static void __generate_pre_visibility_change_event(void) {
+ Ecore_Wl2_Event_Window_Pre_Visibility_Change ev = {
+ .win = 1,
+ .type = ECORE_WL2_WINDOW_VISIBILITY_TYPE_UNOBSCURED,
+ };
+
+ __ops.window.pre_visibility(ECORE_WL2_EVENT_WINDOW_PRE_VISIBILITY_CHANGE, &ev,
+ __user_data);
+}
+
+static void __generate_visibility_change_event(int fully_obscured) {
+ Ecore_Wl2_Event_Window_Visibility_Change ev = {
+ .win = 1,
+ .fully_obscured = fully_obscured
+ };
+
+ __ops.window.visibility(ECORE_WL2_EVENT_WINDOW_VISIBILITY_CHANGE,
+ &ev, __user_data);
+}
+
+static void __fake_appcore_multiwindow_base_window_on_visibility(int type,
+ void* event) {
+ Ecore_Wl2_Event_Window_Visibility_Change* ev =
+ static_cast<Ecore_Wl2_Event_Window_Visibility_Change*>(event);
+
+ if (ev->fully_obscured)
+ appcore_multiwindow_base_instance_pause(nullptr);
+ else
+ appcore_multiwindow_base_instance_resume(nullptr);
+}
+
+static int __fake_aul_comp_notify_start(const char *id) {
+ return 0;
+}
+
+static int __fake_aul_comp_status_update(const char *id, int status) {
+ return 0;
+}
+
+static void __generate_system_event(void)
+{
+ char lang[] = "en-US";
+ int intval = 1;
+ void* event;
+
+ for (int i = APPCORE_BASE_EVENT_START + 1; i < APPCORE_BASE_EVENT_MAX; i++) {
+ if (i == APPCORE_BASE_EVENT_LANG_CHANGE ||
+ i == APPCORE_BASE_EVENT_REGION_CHANGE) {
+ event = static_cast<void*>(lang);
+ } else {
+ event = static_cast<void*>(&intval);
+ }
+
+ if (__event_cb[i]) {
+ __event_cb[i](event, __event_data[i]);
+ }
+ }
+}
+
+static int __fake_appcore_multiwindow_base_init(
+ appcore_multiwindow_base_ops ops,
+ int argc,
+ char** argv,
+ void* user_data) {
+ __ops = ops;
+ __argc = argc;
+ __argv = argv;
+ __user_data = user_data;
+
+ __ops.base.init(__argc, __argv, __user_data);
+ __ops.base.create(__user_data);
+ __ops.base.run(__user_data);
+
+ bundle* b = bundle_create();
+ bundle_add_str(b, AUL_K_COMPONENT_ID, "test-frame-component");
+ bundle_add_str(b, AUL_K_INSTANCE_ID, "@test-frame-component");
+ bundle_add_str(b, AUL_K_NEW_INSTANCE, "true");
+ std::unique_ptr<bundle, decltype(bundle_free)*> ptr(b, bundle_free);
+
+ __ops.base.receive(AUL_START, b, __user_data);
+ __generate_system_event();
+
+ __ops.base.control(b, __user_data);
+ __generate_show_event();
+
+ __ops.base.receive(AUL_RESUME, b, __user_data);
+ __ops.base.receive(AUL_PAUSE, b, __user_data);
+
+ __generate_hide_event();
+ __generate_lower_event();
+ __generate_aux_message();
+
+ __ops.base.receive(AUL_WAKE, b, __user_data);
+ __ops.base.receive(AUL_SUSPEND, b, __user_data);
+
+ __ops.base.receive(AUL_TERMINATE_INST, b, __user_data);
+ __ops.base.receive(AUL_TERMINATE_BG_INST, b, __user_data);
+ __ops.base.receive(AUL_TERMINATE_BGAPP, b, __user_data);
+
+ return 0;
+}
+
+static void __fake_appcore_multiwindow_base_fini(void) {
+ __cls.terminate(nullptr, __cls.data);
+
+ __ops.base.terminate(__user_data);
+ __ops.base.finish();
+}
+
+static void __fake_appcore_multiwindow_base_exit(void) {
+ __ops.base.exit(__user_data);
+}
+
+static int __fake_elm_init(int argc, char** argv) {
+ return 0;
+}
+
+static int __fake_elm_shutdown(void) {
+ return 0;
+}
+
+static Evas_Object* __fake_elm_win_util_standard_add(const char* name,
+ const char* title) {
+ Evas_Object* win = reinterpret_cast<Evas_Object*>(malloc(sizeof(void*)));
+ return win;
+}
+
+static void __fake_evas_object_del(Evas_Object* object) {
+ free(object);
+}
+
+static void __fake_elm_config_accel_preference_set(const char* pref) {
+}
+
+static void __fake_ecore_wl2_window_activate(Ecore_Wl2_Window* window) {
+ __generate_pre_visibility_change_event();
+ __generate_visibility_change_event(0);
+}
+
+static void __fake_ecore_wl2_window_iconified_set(Ecore_Wl2_Window* window,
+ Eina_Bool iconified) {
+ __generate_visibility_change_event(1);
+}
+
+static int __fake_aul_app_group_lower_v2(const char* id, bool* exit) {
+ *exit = true;
+ return 0;
+}
+
+static int __fake_aul_app_group_set_window_v2(const char* id, int wid) {
+ return 0;
+}
+
+static Ecore_Wl2_Window* __fake_ecore_wl2_display_window_find(
+ Ecore_Wl2_Display* display, unsigned int id) {
+ static int window;
+ return reinterpret_cast<Ecore_Wl2_Window*>(&window);
+}
+
+static void __fake_appcore_multiwindow_base_class_add(
+ appcore_multiwindow_base_class cls) {
+ __cls = cls;
+}
+
+static appcore_multiwindow_base_instance_h
+__fake_appcore_multiwindow_base_instance_run(const char* class_id,
+ const char* id, void* extra)
+{
+ static appcore_multiwindow_base_instance_h inst =
+ reinterpret_cast<appcore_multiwindow_base_instance_h>(&inst);
+ __cls.create(inst, __cls.data);
+
+ return inst;
+}
+
+static const char* __fake_appcore_multiwindow_base_instance_get_id(
+ appcore_multiwindow_base_instance_h context) {
+ return "@test-frame-component";
+}
+
+static bool __fake_appcore_multiwindow_base_instance_is_resumed(
+ appcore_multiwindow_base_instance_h context) {
+ return __is_resumed;
+}
+
+static void __fake_appcore_multiwindow_base_instance_resume(
+ appcore_multiwindow_base_instance_h context) {
+ if (__is_resumed)
+ return;
+
+ __cls.resume(context, __cls.data);
+ __is_resumed = true;
+}
+
+static void __fake_appcore_multiwindow_base_instance_pause(
+ appcore_multiwindow_base_instance_h context) {
+ if (!__is_resumed)
+ return;
+
+ __cls.pause(context, __cls.data);
+ __is_resumed = false;
+}
+
+static appcore_base_event_h __fake_appcore_base_add_event(
+ enum appcore_base_event type, appcore_base_event_cb cb, void* data) {
+ __event_cb[type] = cb;
+ __event_data[type] = data;
+ return nullptr;
+}
+
+static Ecore_Evas* __fake_ecore_evas_ecore_evas_get(const Evas* evas) {
+ static int ecore_evas;
+ return reinterpret_cast<Ecore_Evas*>(&ecore_evas);
+}
+
+static Evas* __fake_evas_object_evas_get(const Eo* eo) {
+ static int evas;
+ return reinterpret_cast<Evas*>(&evas);
+}
+
+static Ecore_Wl2_Window* __fake_ecore_evas_wayland2_window_get(
+ const Ecore_Evas* ee) {
+ static int wl2_window;
+ return reinterpret_cast<Ecore_Wl2_Window*>(&wl2_window);
+}
+
+static int __fake_ecore_wl2_window_id_get(Ecore_Wl2_Window* window) {
+ return 1;
+}
+
+static int __fake_app_get_display_state(app_display_state_e *state) {
+ *state = APP_DISPLAY_STATE_ON;
+ return 0;
+}
+
+static int __fake_app_control_add_action_handler(const char* action,
+ app_control_action_cb callback, void* user_data,
+ app_control_action_h* handle) {
+ callback(action, nullptr, user_data);
+ return 0;
+}
+
+class FrameComponentTest : public ::testing::Test {
+ protected:
+ void SetUp() override {
+ appcore_multiwindow_base_init_fake.custom_fake =
+ __fake_appcore_multiwindow_base_init;
+ appcore_multiwindow_base_fini_fake.custom_fake =
+ __fake_appcore_multiwindow_base_fini;
+ appcore_multiwindow_base_exit_fake.custom_fake =
+ __fake_appcore_multiwindow_base_exit;
+ appcore_multiwindow_base_instance_run_fake.custom_fake =
+ __fake_appcore_multiwindow_base_instance_run;
+ appcore_multiwindow_base_class_add_fake.custom_fake =
+ __fake_appcore_multiwindow_base_class_add;
+ appcore_multiwindow_base_instance_get_id_fake.custom_fake =
+ __fake_appcore_multiwindow_base_instance_get_id;
+ appcore_multiwindow_base_instance_is_resumed_fake.custom_fake =
+ __fake_appcore_multiwindow_base_instance_is_resumed;
+ appcore_multiwindow_base_instance_resume_fake.custom_fake =
+ __fake_appcore_multiwindow_base_instance_resume;
+ appcore_multiwindow_base_instance_pause_fake.custom_fake =
+ __fake_appcore_multiwindow_base_instance_pause;
+ appcore_multiwindow_base_window_on_visibility_fake.custom_fake =
+ __fake_appcore_multiwindow_base_window_on_visibility;
+ appcore_base_add_event_fake.custom_fake =
+ __fake_appcore_base_add_event;
+
+ elm_init_fake.custom_fake =
+ __fake_elm_init;
+ elm_shutdown_fake.custom_fake =
+ __fake_elm_shutdown;
+ elm_win_util_standard_add_fake.custom_fake =
+ __fake_elm_win_util_standard_add;
+ evas_object_del_fake.custom_fake =
+ __fake_evas_object_del;
+ elm_config_accel_preference_set_fake.custom_fake =
+ __fake_elm_config_accel_preference_set;
+ ecore_wl2_window_activate_fake.custom_fake =
+ __fake_ecore_wl2_window_activate;
+ ecore_wl2_window_iconified_set_fake.custom_fake =
+ __fake_ecore_wl2_window_iconified_set;
+ ecore_wl2_display_window_find_fake.custom_fake =
+ __fake_ecore_wl2_display_window_find;
+ ecore_evas_ecore_evas_get_fake.custom_fake =
+ __fake_ecore_evas_ecore_evas_get;
+ evas_object_evas_get_fake.custom_fake =
+ __fake_evas_object_evas_get;
+ ecore_evas_wayland2_window_get_fake.custom_fake =
+ __fake_ecore_evas_wayland2_window_get;
+ ecore_wl2_window_id_get_fake.custom_fake =
+ __fake_ecore_wl2_window_id_get;
+
+ aul_app_group_set_window_v2_fake.custom_fake =
+ __fake_aul_app_group_set_window_v2;
+ aul_app_group_lower_v2_fake.custom_fake =
+ __fake_aul_app_group_lower_v2;
+ aul_comp_notify_start_fake.custom_fake =
+ __fake_aul_comp_notify_start;
+ aul_comp_status_update_fake.custom_fake =
+ __fake_aul_comp_status_update;
+
+ app_get_display_state_fake.custom_fake =
+ __fake_app_get_display_state;
+
+ app_control_add_action_handler_fake.custom_fake =
+ __fake_app_control_add_action_handler;
+ }
+
+ void TearDown() override {}
+};
+
+static Evas_Object* __frame_component_create_cb(component_h context,
+ void* user_data) {
+ return elm_win_util_standard_add("frame", "frame");
+}
+
+static void __frame_component_start_cb(component_h context,
+ app_control_h app_control, bool restarted, void* user_data) {
+ component_register_action(context, "action");
+}
+
+static void __frame_component_resume_cb(component_h context,
+ void* user_data) {
+ component_display_status_e status;
+ frame_component_get_display_status(context, &status);
+
+ Evas_Object* win = nullptr;
+ frame_component_get_window(context, &win);
+
+ int res_id = 0;
+ frame_component_get_resource_id(win, &res_id);
+}
+
+static void __frame_component_pause_cb(component_h context,
+ void* user_data) {
+}
+
+static void __frame_component_stop_cb(component_h context,
+ void* user_data) {
+}
+
+static void __frame_component_destroy_cb(component_h context,
+ void *user_data) {
+}
+
+static void __frame_component_restore_content_cb(component_h context,
+ bundle* content, void* user_data) {
+}
+
+static void __frame_component_save_content_cb(component_h context,
+ bundle* content, void* user_data) {
+}
+
+static void __frame_component_action_cb(component_h context,
+ const char* action, app_control_h app_control, void* user_data) {
+}
+
+static void __frame_component_device_orientation_changed_cb(
+ component_h context, component_device_orientation_e orientation,
+ void* user_data) {
+}
+
+static void __frame_component_language_changed_cb(component_h context,
+ const char* language, void* user_data) {
+}
+
+static void __frame_component_region_format_changed_cb(component_h context,
+ const char* region, void* user_data) {
+}
+
+static void __frame_component_low_battery_cb(component_h context,
+ component_low_battery_status_e status, void* user_data) {
+}
+
+static void __frame_component_low_memory_cb(component_h context,
+ component_low_memory_status_e status, void* user_data) {
+}
+
+static void __frame_component_suspended_state_changed_cb(component_h context,
+ component_suspended_state_e state, void* user_data) {
+}
+
+static component_class_h __frame_component_add(
+ component_class_h component_class, const char* component_id,
+ void* user_data) {
+ frame_component_lifecycle_callback_s callback;
+ callback.create =
+ __frame_component_create_cb;
+ callback.start =
+ __frame_component_start_cb;
+ callback.resume =
+ __frame_component_resume_cb;
+ callback.pause =
+ __frame_component_pause_cb;
+ callback.stop =
+ __frame_component_stop_cb;
+ callback.destroy =
+ __frame_component_destroy_cb;
+ callback.restore_content =
+ __frame_component_restore_content_cb;
+ callback.save_content =
+ __frame_component_save_content_cb;
+ callback.action =
+ __frame_component_action_cb;
+ callback.device_orientation_changed =
+ __frame_component_device_orientation_changed_cb;
+ callback.language_changed =
+ __frame_component_language_changed_cb;
+ callback.region_format_changed =
+ __frame_component_region_format_changed_cb;
+ callback.low_battery =
+ __frame_component_low_battery_cb;
+ callback.low_memory =
+ __frame_component_low_memory_cb;
+ callback.suspended_state_changed =
+ __frame_component_suspended_state_changed_cb;
+
+ return component_based_app_add_frame_component(component_class,
+ component_id, &callback, user_data);
+}
+
+static component_class_h __component_based_app_create_cb(void* user_data) {
+ component_class_h component_class = nullptr;
+ component_class = __frame_component_add(component_class,
+ "test-frame-component", user_data);
+
+ return component_class;
+}
+
+static void __component_based_app_terminate_cb(void* user_data) {
+
+}
+
+TEST_F(FrameComponentTest, frame_component_test) {
+ component_based_app_lifecycle_callback_s callback;
+ callback.create = __component_based_app_create_cb;
+ callback.terminate = __component_based_app_terminate_cb;
+
+ int argc = 1;
+ char tmp_arg[] = "test";
+ char** argv = reinterpret_cast<char**>(&tmp_arg);
+
+ int ret = component_based_app_main(argc, argv, &callback, this);
+ EXPECT_EQ(ret, APP_ERROR_NONE);
+}
+
+} // namespace
--- /dev/null
+// Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#include <glib.h>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+#include <stdlib.h>
+#include <aul.h>
+#include <bundle.h>
+
+#include <memory>
+
+#include "component_based/efl_base/api/frame_component.h"
+#include "component_based/efl_base/api/service_component.h"
+#include "component_based/efl_base/api/component_based_app.h"
+
+#include "unit_tests/mock/mock_app_common.h"
+#include "unit_tests/mock/mock_app_control.h"
+#include "unit_tests/mock/mock_appcore_multiwindow_base.h"
+#include "unit_tests/mock/mock_aul.h"
+#include "unit_tests/mock/mock_elementary.h"
+
+namespace {
+
+static appcore_multiwindow_base_ops __ops;
+static int __argc;
+static char** __argv;
+static void* __user_data;
+static appcore_multiwindow_base_class __cls;
+static appcore_base_event_cb __event_cb[APPCORE_BASE_EVENT_MAX];
+static void* __event_data[APPCORE_BASE_EVENT_MAX];
+
+static int __fake_aul_comp_notify_start(const char *id) {
+ return 0;
+}
+
+static int __fake_aul_comp_status_update(const char *id, int status) {
+ return 0;
+}
+
+static void __generate_system_event(void)
+{
+ char lang[] = "en-US";
+ int intval = 1;
+ void* event;
+
+ for (int i = APPCORE_BASE_EVENT_START + 1; i < APPCORE_BASE_EVENT_MAX; i++) {
+ if (i == APPCORE_BASE_EVENT_LANG_CHANGE ||
+ i == APPCORE_BASE_EVENT_REGION_CHANGE) {
+ event = static_cast<void*>(lang);
+ } else {
+ event = static_cast<void*>(&intval);
+ }
+
+ if (__event_cb[i]) {
+ __event_cb[i](event, __event_data[i]);
+ }
+ }
+}
+
+static int __fake_appcore_multiwindow_base_init(
+ appcore_multiwindow_base_ops ops,
+ int argc,
+ char** argv,
+ void* user_data) {
+ __ops = ops;
+ __argc = argc;
+ __argv = argv;
+ __user_data = user_data;
+
+ __ops.base.init(__argc, __argv, __user_data);
+ __ops.base.create(__user_data);
+ __ops.base.run(__user_data);
+
+ bundle* b = bundle_create();
+ bundle_add_str(b, AUL_K_COMPONENT_ID, "test-service-component");
+ bundle_add_str(b, AUL_K_INSTANCE_ID, "@test-service-component");
+ bundle_add_str(b, AUL_K_NEW_INSTANCE, "true");
+ std::unique_ptr<bundle, decltype(bundle_free)*> ptr(b, bundle_free);
+
+ __ops.base.receive(AUL_START, b, __user_data);
+
+ __generate_system_event();
+
+ __ops.base.control(b, __user_data);
+
+ __ops.base.receive(AUL_RESUME, b, __user_data);
+ __ops.base.receive(AUL_PAUSE, b, __user_data);
+
+ __ops.base.receive(AUL_WAKE, b, __user_data);
+ __ops.base.receive(AUL_SUSPEND, b, __user_data);
+
+ __ops.base.receive(AUL_TERMINATE_INST, b, __user_data);
+ __ops.base.receive(AUL_TERMINATE_BG_INST, b, __user_data);
+ __ops.base.receive(AUL_TERMINATE_BGAPP, b, __user_data);
+
+ return 0;
+}
+
+static void __fake_appcore_multiwindow_base_fini(void) {
+ __cls.terminate(nullptr, __cls.data);
+
+ __ops.base.terminate(__user_data);
+ __ops.base.finish();
+}
+
+static void __fake_appcore_multiwindow_base_exit(void) {
+ __ops.base.exit(__user_data);
+}
+
+static int __fake_elm_init(int argc, char** argv) {
+ return 0;
+}
+
+static int __fake_elm_shutdown(void) {
+ return 0;
+}
+
+static void __fake_appcore_multiwindow_base_class_add(
+ appcore_multiwindow_base_class cls) {
+ __cls = cls;
+}
+
+static appcore_multiwindow_base_instance_h
+__fake_appcore_multiwindow_base_instance_run(const char* class_id,
+ const char* id, void* extra)
+{
+ static appcore_multiwindow_base_instance_h inst =
+ reinterpret_cast<appcore_multiwindow_base_instance_h>(&inst);
+
+ __cls.create(inst, __cls.data);
+
+ return inst;
+}
+
+static const char* __fake_appcore_multiwindow_base_instance_get_id(
+ appcore_multiwindow_base_instance_h context) {
+ return "@test-service-component";
+}
+
+static appcore_base_event_h __fake_appcore_base_add_event(
+ enum appcore_base_event type, appcore_base_event_cb cb, void* data) {
+ __event_cb[type] = cb;
+ __event_data[type] = data;
+ return nullptr;
+}
+
+static int __fake_app_control_add_action_handler(const char* action,
+ app_control_action_cb callback, void* user_data,
+ app_control_action_h* handle) {
+ callback(action, nullptr, user_data);
+ return 0;
+}
+
+static int __fake_app_control_send_launch_request_async(
+ app_control_h app_control,
+ app_control_result_cb result_cb,
+ app_control_reply_cb reply_cb,
+ void* user_data) {
+ result_cb(app_control, APP_CONTROL_ERROR_NONE, user_data);
+ reply_cb(app_control, app_control, APP_CONTROL_RESULT_SUCCEEDED, user_data);
+ return 0;
+}
+
+static int __fake_app_control_send_launch_request_sync(
+ app_control_h app_control,
+ app_control_h* reply,
+ app_control_result_e* result) {
+ app_control_h handle = nullptr;
+ app_control_create(&handle);
+ *reply = handle;
+ *result = APP_CONTROL_RESULT_SUCCEEDED;
+ return 0;
+}
+
+class ServiceComponentTest : public ::testing::Test {
+ protected:
+ void SetUp() override {
+ appcore_multiwindow_base_init_fake.custom_fake =
+ __fake_appcore_multiwindow_base_init;
+ appcore_multiwindow_base_fini_fake.custom_fake =
+ __fake_appcore_multiwindow_base_fini;
+ appcore_multiwindow_base_exit_fake.custom_fake =
+ __fake_appcore_multiwindow_base_exit;
+ appcore_multiwindow_base_instance_run_fake.custom_fake =
+ __fake_appcore_multiwindow_base_instance_run;
+ appcore_multiwindow_base_class_add_fake.custom_fake =
+ __fake_appcore_multiwindow_base_class_add;
+ appcore_multiwindow_base_instance_get_id_fake.custom_fake =
+ __fake_appcore_multiwindow_base_instance_get_id;
+ appcore_base_add_event_fake.custom_fake =
+ __fake_appcore_base_add_event;
+
+ elm_init_fake.custom_fake =
+ __fake_elm_init;
+ elm_shutdown_fake.custom_fake =
+ __fake_elm_shutdown;
+ aul_comp_notify_start_fake.custom_fake =
+ __fake_aul_comp_notify_start;
+ aul_comp_status_update_fake.custom_fake =
+ __fake_aul_comp_status_update;
+ app_control_add_action_handler_fake.custom_fake =
+ __fake_app_control_add_action_handler;
+ app_control_send_launch_request_async_fake.custom_fake =
+ __fake_app_control_send_launch_request_async;
+ app_control_send_launch_request_sync_fake.custom_fake =
+ __fake_app_control_send_launch_request_sync;
+ }
+
+ void TearDown() override {}
+};
+
+static void __app_control_result_cb(app_control_h request,
+ app_control_error_e result, void* user_data) {
+}
+
+static void __app_control_reply_cb(app_control_h request,
+ app_control_h reply, app_control_result_e result, void* user_data) {
+}
+
+static bool __service_component_create_cb(component_h context,
+ void* user_data) {
+ char* id = nullptr;
+ component_get_id(context, &id);
+ free(id);
+
+ char* inst_id = nullptr;
+ component_get_instance_id(context, &inst_id);
+ free(inst_id);
+ return true;
+}
+
+static void __service_component_start_command_cb(component_h context,
+ app_control_h app_control, bool restarted, void* user_data) {
+ component_register_action(context, "action");
+ component_deregister_action(context, "action");
+
+ app_control_h handle = nullptr;
+ app_control_create(&handle);
+ component_send_launch_request_async(context, handle, __app_control_result_cb,
+ __app_control_reply_cb, nullptr);
+
+ app_control_h reply = nullptr;
+ app_control_result_e result;
+ component_send_launch_request_sync(context, handle, &reply, &result);
+ app_control_destroy(reply);
+ app_control_destroy(handle);
+
+ component_finish(context);
+}
+
+static void __service_component_destroy_cb(component_h context,
+ void *user_data) {
+}
+
+static void __service_component_restore_content_cb(component_h context,
+ bundle* content, void* user_data) {
+}
+
+static void __service_component_save_content_cb(component_h context,
+ bundle* content, void* user_data) {
+}
+
+static void __service_component_action_cb(component_h context,
+ const char* action, app_control_h app_control, void* user_data) {
+}
+
+static void __service_component_device_orientation_changed_cb(
+ component_h context, component_device_orientation_e orientation,
+ void* user_data) {
+}
+
+static void __service_component_language_changed_cb(component_h context,
+ const char* language, void* user_data) {
+}
+
+static void __service_component_region_format_changed_cb(component_h context,
+ const char* region, void* user_data) {
+}
+
+static void __service_component_low_battery_cb(component_h context,
+ component_low_battery_status_e status, void* user_data) {
+}
+
+static void __service_component_low_memory_cb(component_h context,
+ component_low_memory_status_e status, void* user_data) {
+}
+
+static void __service_component_suspended_state_changed_cb(component_h context,
+ component_suspended_state_e state, void* user_data) {
+}
+
+static component_class_h __service_component_add(
+ component_class_h component_class, const char* component_id,
+ void* user_data) {
+ service_component_lifecycle_callback_s callback;
+ callback.create =
+ __service_component_create_cb;
+ callback.start_command =
+ __service_component_start_command_cb;
+ callback.destroy =
+ __service_component_destroy_cb;
+ callback.restore_content =
+ __service_component_restore_content_cb;
+ callback.save_content =
+ __service_component_save_content_cb;
+ callback.action =
+ __service_component_action_cb;
+ callback.device_orientation_changed =
+ __service_component_device_orientation_changed_cb;
+ callback.language_changed =
+ __service_component_language_changed_cb;
+ callback.region_format_changed =
+ __service_component_region_format_changed_cb;
+ callback.low_battery =
+ __service_component_low_battery_cb;
+ callback.low_memory =
+ __service_component_low_memory_cb;
+ callback.suspended_state_changed =
+ __service_component_suspended_state_changed_cb;
+
+ return component_based_app_add_service_component(component_class,
+ component_id, &callback, user_data);
+}
+
+static component_class_h __component_based_app_create_cb(void* user_data) {
+ component_class_h component_class = nullptr;
+ component_class = __service_component_add(component_class,
+ "test-service-component", user_data);
+
+ return component_class;
+}
+
+static void __component_based_app_terminate_cb(void* user_data) {
+}
+
+TEST_F(ServiceComponentTest, service_component_test) {
+ component_based_app_lifecycle_callback_s callback;
+ callback.create = __component_based_app_create_cb;
+ callback.terminate = __component_based_app_terminate_cb;
+
+ int argc = 1;
+ char tmp_arg[] = "test";
+ char** argv = reinterpret_cast<char**>(&tmp_arg);
+
+ int ret = component_based_app_main(argc, argv, &callback, this);
+ EXPECT_EQ(ret, APP_ERROR_NONE);
+}
+
+} // namespace