set(CMAKE_SKIP_BUILD_RPATH true)
-ADD_SUBDIRECTORY("pkgmgr_shortcut")
-ADD_SUBDIRECTORY("lib")
+ADD_SUBDIRECTORY(pkgmgr_shortcut)
+ADD_SUBDIRECTORY(lib)
+ADD_SUBDIRECTORY(tests)
BuildRequires: pkgconfig(aul)
BuildRequires: pkgconfig(libtzplatform-config)
BuildRequires: pkgconfig(capi-system-info)
+BuildRequires: pkgconfig(gmock)
+
+%if 0%{?gcov:1}
+BuildRequires: lcov
+BuildRequires: zip
+%endif
%description
[Shortcut] AddToHome feature supporting library for menu/home screen developers.
+%package devel
+Summary: AddToHome feature supporting library development files
+Group: Development/Libraries
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+[Shortcut] AddToHome feature supporting library for menu/home screen developers(dev).
+
+#################################################
+# capi-appfw-app-common-unittests
+#################################################
+%package -n shortcut_unittests
+Summary: GTest for shortcut API
+Group: Development/Libraries
+Requires: %{name}
+
+%description -n shortcut_unittests
+GTest for shortcut API
+
+#################################################
+# gcov
+#################################################
%if 0%{?gcov:1}
%package gcov
Summary: Shortcut API(gcov)
gcov objects of an Shortcut library
%endif
-%package devel
-Summary: AddToHome feature supporting library development files
-Group: Development/Libraries
-Requires: %{name} = %{version}-%{release}
-
-%description devel
-[Shortcut] AddToHome feature supporting library for menu/home screen developers(dev).
-
%prep
%setup -q
cp %{SOURCE1001} .
find . -name '*.gcno' -exec cp '{}' gcov-obj ';'
%endif
+%check
+ctest --output-on-failure %{?_smp_mflags}
+%if 0%{?gcov:1}
+lcov -c --ignore-errors graph --no-external -q -d . -o shortcut.info
+genhtml shortcut.info -o shortcut.out
+zip -r shortcut.zip shortcut.out
+install -m 0644 shortcut.zip %{buildroot}%{_datadir}/gcov/badge.zip
+%endif
+
%install
rm -rf %{buildroot}
%{_libdir}/pkgconfig/shortcut.pc
%{_libdir}/libshortcut.so
+#################################################
+# shortcut_unittests
+#################################################
+%files -n shortcut_unittests
+%{_bindir}/shortcut_unittests
+#################################################
+# gcov
+#################################################
%if 0%{?gcov:1}
%files gcov
-%{_datadir}/gcov/obj/*
+%{_datadir}/gcov/*
%endif
-# End of a file
+++ /dev/null
-all:
- @gcc homescreen.c -Wall -o homescreen `pkg-config ecore elementary shortcut --cflags --libs`
- @gcc application.c -Wall -o application `pkg-config ecore elementary shortcut --cflags --libs`
- @gcc shortcut.c -Wall -o shortcut `pkg-config ecore elementary shortcut --cflags --libs`
+++ /dev/null
-/*
- * Copyright (c) 2011 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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 <Elementary.h>
-#include <shortcut.h>
-
-static int result_cb(int ret, int pid, void *data)
-{
- printf("Client: Return %d (%d)\n", ret, pid);
- /* elm_exit(); */
- return 0;
-}
-
-static Eina_Bool shortcut_add_cb(void *data)
-{
- int ret;
-
- ret = add_to_home_shortcut("pkgname", "MyName", 0, "/usr/bin/true", "/opt/share/image/what.png", result_cb, NULL);
- printf("Client: shortcut_add_to_home returns: %d\n", ret);
-
- ret = add_to_home_dynamicbox("pkgname", "MyName", 0, "/usr/bin/true", "/opt/share/image/what.png", 1.0f, result_cb, NULL);
- printf("Client: shortcut_add_to_home_with_period returns: %d\n", ret);
-
- return ECORE_CALLBACK_RENEW;
-}
-
-int elm_main(int argc, char *argv[])
-{
- Ecore_Timer *timer;
-
- timer = ecore_timer_add(3.0f, shortcut_add_cb, NULL);
- if (!timer)
- printf("Failed to add a timer\n");
-
- elm_run();
- elm_shutdown();
-
- return 0;
-}
-
-ELM_MAIN()
-/* End of a file */
+++ /dev/null
-/*
- * Copyright (c) 2011 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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 <Elementary.h>
-#include <shortcut.h>
-
-int shortcut_request_cb(const char *pkgname, const char *name, int type, const char *exec, const char *icon, int pid, double period, void *data)
-{
- printf("SERVER: name: %s, type: %d, exec: %s, icon: %s, pid: %d, data: %p, period: %lf\n",
- name, type, exec, icon, pid, data, period);
- return 0;
-}
-
-int elm_main(int argc, char *argv[])
-{
- shortcut_set_request_cb(shortcut_request_cb, NULL);
-
- elm_run();
- elm_shutdown();
-
- return 0;
-}
-
-ELM_MAIN()
-/* End of a file */
-
+++ /dev/null
-/*
- * Copyright (c) 2011 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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 <Elementary.h>
-#include <shortcut.h>
-#include <tzplatform_config.h>
-
-#define PATH_FMT_RO_ICONS_ROOT tzplatform_getenv(TZ_SYS_RO_ICONS)
-#define PATH_FMT_USER_SHARE_ROOT tzplatform_getenv(TZ_USER_SHARE)
-#define TIZEN_PATH_MAX 1024
-
-static int result_cb(struct shortcut_icon *handle, int ret, void *data)
-{
- printf("Client: Return %d (%p)\n", ret, handle);
- return 0;
-}
-
-static Eina_Bool test_main(void *data)
-{
- struct shortcut_icon *handle;
- static int idx = 0;
- int ret;
- char filename[256];
- int type;
- char path[TIZEN_PATH_MAX] = {0, };
-
- idx++;
-
- handle = shortcut_icon_request_create();
- if (!handle) {
- printf("Failed to create a request\n");
- return ECORE_CALLBACK_RENEW;
- }
-
- printf("Test: %d\n", idx);
- snprintf(path, TIZEN_PATH_MAX, "%s/default/small/org.tizen.music-player.png", PATH_FMT_RO_ICONS_ROOT);
- ret = shortcut_icon_request_set_info(handle, NULL, SHORTCUT_ICON_TYPE_IMAGE, DEFAULT_ICON_PART, path, NULL, NULL);
- printf("NAME set_info: %d\n", ret);
-
- snprintf(filename, sizeof(filename), "App Name %d", idx);
- ret = shortcut_icon_request_set_info(handle, NULL, SHORTCUT_ICON_TYPE_TEXT, DEFAULT_NAME_PART, filename, NULL, NULL);
- printf("TEXT set_info: %d\n", ret);
-
- snprintf(filename, sizeof(filename), "%s/live_magazine/always/out%d.png", PATH_FMT_USER_SHARE_ROOT, idx);
-
- switch (idx % 7) {
- case 0: type = DYNAMICBOX_TYPE_1x1; break;
- case 1: type = DYNAMICBOX_TYPE_2x1; break;
- case 2: type = DYNAMICBOX_TYPE_2x2; break;
- case 3: type = DYNAMICBOX_TYPE_4x1; break;
- case 4: type = DYNAMICBOX_TYPE_4x2; break;
- case 5: type = DYNAMICBOX_TYPE_4x3; break;
- case 6: type = DYNAMICBOX_TYPE_4x4; break;
- default: type = DYNAMICBOX_TYPE_1x1; break;
- }
-
- ret = shortcut_icon_request_send(handle, type, NULL, NULL, filename, result_cb, NULL);
- printf("request: %d\n", ret);
-
- ret = shortcut_icon_request_destroy(handle);
- printf("destroy: %d\n", ret);
- return ECORE_CALLBACK_RENEW;
-}
-
-static int initialized_cb(int status, void *data)
-{
- printf("Hello initializer\n");
- return 0;
-}
-
-int elm_main(int argc, char *argv[])
-{
- shortcut_icon_service_init(NULL, NULL);
-
- ecore_timer_add(5.0f, test_main, NULL);
-
- elm_run();
- shortcut_icon_service_fini();
- elm_shutdown();
- return 0;
-}
-
-ELM_MAIN()
-/* End of a file */
+++ /dev/null
-/*
- * Copyright (c) 2011 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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 <Elementary.h>
-#include <shortcut.h>
-
-static int shortcut_list_cb(const char *appid, const char *icon, const char *name, const char *extra_key, const char *extra_data, void *data)
-{
- printf("appid[%s] icon[%s], name[%s] extra_key[%s], extra_ata[%s]\n", appid, icon, name, extra_key, extra_data);
- return 0;
-}
-
-int elm_main(int argc, char *argv[])
-{
- int ret;
- ret = shortcut_get_list(NULL, shortcut_list_cb, NULL);
- if (ret < 0)
- printf("Error: %d\n", ret);
-
- elm_run();
- elm_shutdown();
-
- return 0;
-}
-
-ELM_MAIN()
-/* End of a file */
--- /dev/null
+IF(NOT DEFINED MINIMUM_BUILD)
+ENABLE_TESTING()
+SET(SHORTCUT_UNIT_TESTS shortcut_unittests)
+ADD_TEST(NAME ${SHORTCUT_UNIT_TESTS} COMMAND ${SHORTCUT_UNIT_TESTS})
+
+ADD_SUBDIRECTORY(unit_tests)
+ADD_DEPENDENCIES(${SHORTCUT_UNIT_TESTS} shortcut)
+ENDIF(NOT DEFINED MINIMUM_BUILD)
--- /dev/null
+/*
+ * Copyright (c) 2020 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 MOCK_MOCK_HOOK_H_
+#define MOCK_MOCK_HOOK_H_
+
+#define MOCK_HOOK_P0(MOCK_CLASS, f) \
+ TestFixture::GetMock<MOCK_CLASS>().f()
+#define MOCK_HOOK_P1(MOCK_CLASS, f, p1) \
+ TestFixture::GetMock<MOCK_CLASS>().f(p1)
+#define MOCK_HOOK_P2(MOCK_CLASS, f, p1, p2) \
+ TestFixture::GetMock<MOCK_CLASS>().f(p1, p2)
+#define MOCK_HOOK_P3(MOCK_CLASS, f, p1, p2, p3) \
+ TestFixture::GetMock<MOCK_CLASS>().f(p1, p2, p3)
+#define MOCK_HOOK_P4(MOCK_CLASS, f, p1, p2, p3, p4) \
+ TestFixture::GetMock<MOCK_CLASS>().f(p1, p2, p3, p4)
+#define MOCK_HOOK_P5(MOCK_CLASS, f, p1, p2, p3, p4, p5) \
+ TestFixture::GetMock<MOCK_CLASS>().f(p1, p2, p3, p4, p5)
+#define MOCK_HOOK_P6(MOCK_CLASS, f, p1, p2, p3, p4, p5, p6) \
+ TestFixture::GetMock<MOCK_CLASS>().f(p1, p2, p3, p4, p5, p6)
+#define MOCK_HOOK_P7(MOCK_CLASS, f, p1, p2, p3, p4, p5, p6, p7) \
+ TestFixture::GetMock<MOCK_CLASS>().f(p1, p2, p3, p4, p5, p6, p7)
+#define MOCK_HOOK_P8(MOCK_CLASS, f, p1, p2, p3, p4, p5, p6, p7, p8) \
+ TestFixture::GetMock<MOCK_CLASS>().f(p1, p2, p3, p4, p5, p6, p7, p8)
+#define MOCK_HOOK_P10(MOCK_CLASS, f, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) \
+ TestFixture::GetMock<MOCK_CLASS>().f( \
+ p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)
+
+#endif // MOCK_MOCK_HOOK_H_
--- /dev/null
+/*
+ * Copyright (c) 2020 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 MOCK_MODULE_MOCK_H_
+#define MOCK_MODULE_MOCK_H_
+
+class ModuleMock {
+ public:
+ virtual ~ModuleMock() {}
+};
+
+#endif // MOCK_MODULE_MOCK_H_
--- /dev/null
+/*
+ * Copyright (c) 2020 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 "system_info_mock.h"
+#include "mock_hook.h"
+#include "test_fixture.h"
+
+extern "C" int system_info_get_platform_bool(const char* arg0, bool* arg1) {
+ return MOCK_HOOK_P2(SystemInfoMock, system_info_get_platform_bool, arg0, arg1);
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 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 MOCK_SYSTEM_INFO_MOCK_H_
+#define MOCK_SYSTEM_INFO_MOCK_H_
+
+#include <tizen.h>
+#include <gmock/gmock.h>
+
+#include "module_mock.h"
+
+class SystemInfoMock : public virtual ModuleMock {
+ public:
+ virtual ~SystemInfoMock() {}
+
+ MOCK_METHOD2(system_info_get_platform_bool, int(const char*, bool*));
+};
+
+#endif // MOCK_SYSTEM_INFO_MOCK_H_
--- /dev/null
+/*
+ * Copyright (c) 2020 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 "test_fixture.h"
+
+#include <memory>
+
+std::unique_ptr<ModuleMock> TestFixture::mock_;
--- /dev/null
+/*
+ * Copyright (c) 2020 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 MOCK_TEST_FIXTURE_H_
+#define MOCK_TEST_FIXTURE_H_
+
+#include <gtest/gtest.h>
+
+#include <memory>
+#include <stdexcept>
+#include <string>
+#include <utility>
+
+#include "module_mock.h"
+
+class TestFixture : public ::testing::Test {
+ public:
+ explicit TestFixture(std::unique_ptr<ModuleMock>&& mock) {
+ mock_ = std::move(mock);
+ }
+ virtual ~TestFixture() {
+ mock_.reset();
+ }
+
+ virtual void SetUp() {}
+ virtual void TearDown() {}
+
+ template <typename T>
+ static T& GetMock() {
+ auto ptr = dynamic_cast<T*>(mock_.get());
+ if (!ptr)
+ throw std::invalid_argument("The test does not provide mock of \"" +
+ std::string(typeid(T).name()) + "\"");
+ return *ptr;
+ }
+
+ static std::unique_ptr<ModuleMock> mock_;
+};
+
+#endif // MOCK_TEST_FIXTURE_H_
--- /dev/null
+all:
+ @gcc homescreen.c -Wall -o homescreen `pkg-config ecore elementary shortcut --cflags --libs`
+ @gcc application.c -Wall -o application `pkg-config ecore elementary shortcut --cflags --libs`
+ @gcc shortcut.c -Wall -o shortcut `pkg-config ecore elementary shortcut --cflags --libs`
--- /dev/null
+/*
+ * Copyright (c) 2011 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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 <Elementary.h>
+#include <shortcut.h>
+
+static int result_cb(int ret, int pid, void *data)
+{
+ printf("Client: Return %d (%d)\n", ret, pid);
+ /* elm_exit(); */
+ return 0;
+}
+
+static Eina_Bool shortcut_add_cb(void *data)
+{
+ int ret;
+
+ ret = add_to_home_shortcut("pkgname", "MyName", 0, "/usr/bin/true", "/opt/share/image/what.png", result_cb, NULL);
+ printf("Client: shortcut_add_to_home returns: %d\n", ret);
+
+ ret = add_to_home_dynamicbox("pkgname", "MyName", 0, "/usr/bin/true", "/opt/share/image/what.png", 1.0f, result_cb, NULL);
+ printf("Client: shortcut_add_to_home_with_period returns: %d\n", ret);
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+int elm_main(int argc, char *argv[])
+{
+ Ecore_Timer *timer;
+
+ timer = ecore_timer_add(3.0f, shortcut_add_cb, NULL);
+ if (!timer)
+ printf("Failed to add a timer\n");
+
+ elm_run();
+ elm_shutdown();
+
+ return 0;
+}
+
+ELM_MAIN()
+/* End of a file */
--- /dev/null
+/*
+ * Copyright (c) 2011 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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 <Elementary.h>
+#include <shortcut.h>
+
+int shortcut_request_cb(const char *pkgname, const char *name, int type, const char *exec, const char *icon, int pid, double period, void *data)
+{
+ printf("SERVER: name: %s, type: %d, exec: %s, icon: %s, pid: %d, data: %p, period: %lf\n",
+ name, type, exec, icon, pid, data, period);
+ return 0;
+}
+
+int elm_main(int argc, char *argv[])
+{
+ shortcut_set_request_cb(shortcut_request_cb, NULL);
+
+ elm_run();
+ elm_shutdown();
+
+ return 0;
+}
+
+ELM_MAIN()
+/* End of a file */
+
--- /dev/null
+/*
+ * Copyright (c) 2011 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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 <Elementary.h>
+#include <shortcut.h>
+#include <tzplatform_config.h>
+
+#define PATH_FMT_RO_ICONS_ROOT tzplatform_getenv(TZ_SYS_RO_ICONS)
+#define PATH_FMT_USER_SHARE_ROOT tzplatform_getenv(TZ_USER_SHARE)
+#define TIZEN_PATH_MAX 1024
+
+static int result_cb(struct shortcut_icon *handle, int ret, void *data)
+{
+ printf("Client: Return %d (%p)\n", ret, handle);
+ return 0;
+}
+
+static Eina_Bool test_main(void *data)
+{
+ struct shortcut_icon *handle;
+ static int idx = 0;
+ int ret;
+ char filename[256];
+ int type;
+ char path[TIZEN_PATH_MAX] = {0, };
+
+ idx++;
+
+ handle = shortcut_icon_request_create();
+ if (!handle) {
+ printf("Failed to create a request\n");
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ printf("Test: %d\n", idx);
+ snprintf(path, TIZEN_PATH_MAX, "%s/default/small/org.tizen.music-player.png", PATH_FMT_RO_ICONS_ROOT);
+ ret = shortcut_icon_request_set_info(handle, NULL, SHORTCUT_ICON_TYPE_IMAGE, DEFAULT_ICON_PART, path, NULL, NULL);
+ printf("NAME set_info: %d\n", ret);
+
+ snprintf(filename, sizeof(filename), "App Name %d", idx);
+ ret = shortcut_icon_request_set_info(handle, NULL, SHORTCUT_ICON_TYPE_TEXT, DEFAULT_NAME_PART, filename, NULL, NULL);
+ printf("TEXT set_info: %d\n", ret);
+
+ snprintf(filename, sizeof(filename), "%s/live_magazine/always/out%d.png", PATH_FMT_USER_SHARE_ROOT, idx);
+
+ switch (idx % 7) {
+ case 0: type = DYNAMICBOX_TYPE_1x1; break;
+ case 1: type = DYNAMICBOX_TYPE_2x1; break;
+ case 2: type = DYNAMICBOX_TYPE_2x2; break;
+ case 3: type = DYNAMICBOX_TYPE_4x1; break;
+ case 4: type = DYNAMICBOX_TYPE_4x2; break;
+ case 5: type = DYNAMICBOX_TYPE_4x3; break;
+ case 6: type = DYNAMICBOX_TYPE_4x4; break;
+ default: type = DYNAMICBOX_TYPE_1x1; break;
+ }
+
+ ret = shortcut_icon_request_send(handle, type, NULL, NULL, filename, result_cb, NULL);
+ printf("request: %d\n", ret);
+
+ ret = shortcut_icon_request_destroy(handle);
+ printf("destroy: %d\n", ret);
+ return ECORE_CALLBACK_RENEW;
+}
+
+static int initialized_cb(int status, void *data)
+{
+ printf("Hello initializer\n");
+ return 0;
+}
+
+int elm_main(int argc, char *argv[])
+{
+ shortcut_icon_service_init(NULL, NULL);
+
+ ecore_timer_add(5.0f, test_main, NULL);
+
+ elm_run();
+ shortcut_icon_service_fini();
+ elm_shutdown();
+ return 0;
+}
+
+ELM_MAIN()
+/* End of a file */
--- /dev/null
+/*
+ * Copyright (c) 2011 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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 <Elementary.h>
+#include <shortcut.h>
+
+static int shortcut_list_cb(const char *appid, const char *icon, const char *name, const char *extra_key, const char *extra_data, void *data)
+{
+ printf("appid[%s] icon[%s], name[%s] extra_key[%s], extra_ata[%s]\n", appid, icon, name, extra_key, extra_data);
+ return 0;
+}
+
+int elm_main(int argc, char *argv[])
+{
+ int ret;
+ ret = shortcut_get_list(NULL, shortcut_list_cb, NULL);
+ if (ret < 0)
+ printf("Error: %d\n", ret);
+
+ elm_run();
+ elm_shutdown();
+
+ return 0;
+}
+
+ELM_MAIN()
+/* End of a file */
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8)\r
+PROJECT(shortcut_unittests C CXX)\r
+\r
+INCLUDE(FindPkgConfig)\r
+PKG_CHECK_MODULES(shortcut_unittests REQUIRED\r
+ gmock\r
+ dlog\r
+ sqlite3\r
+ libxml-2.0\r
+ glib-2.0\r
+ db-util\r
+ vconf\r
+ capi-base-common\r
+ aul\r
+ capi-system-info\r
+ libtzplatform-config\r
+)\r
+\r
+FOREACH(flag ${shortcut_unittests_CFLAGS})\r
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")\r
+ENDFOREACH(flag)\r
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Werror -Winline")\r
+\r
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -std=c++14")\r
+SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")\r
+SET(CMAKE_CXX_FLAGS_RELEASE "-O2")\r
+\r
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../lib/include)\r
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../lib/src)\r
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../mock)\r
+\r
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCES)\r
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../lib/src LIB_SOURCES)\r
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../mock MOCK_SOURCES)\r
+\r
+ADD_EXECUTABLE(${PROJECT_NAME}\r
+ ${SOURCES}\r
+ ${MOCK_SOURCES}\r
+ #${LIB_SOURCES}\r
+)\r
+\r
+TARGET_LINK_LIBRARIES(${PROJECT_NAME}\r
+ ${shortcut_unittests_LDFLAGS}\r
+)\r
+\r
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin/)\r
--- /dev/null
+/*
+ * Copyright (c) 2020 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 <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+int main(int argc, char** argv) {
+ int ret = -1;
+
+ try {
+ testing::InitGoogleTest(&argc, argv);
+ } catch(...) {
+ std::cout << "Exception occurred" << std::endl;
+ }
+
+ try {
+ ret = RUN_ALL_TESTS();
+ } catch (const ::testing::internal::GoogleTestFailureException& e) {
+ ret = -1;
+ std::cout << "GoogleTestFailureException was thrown:" << e.what() << std::endl;
+ }
+
+ return ret;
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 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 <stdlib.h>
+#include <gtest/gtest.h>
+#include <shortcut_manager.h>
+
+#include <memory>
+
+#include "system_info_mock.h"
+#include "test_fixture.h"
+
+using ::testing::_;
+using ::testing::DoAll;
+using ::testing::Return;
+using ::testing::SetArgPointee;
+using ::testing::Invoke;
+
+class Mocks : public ::testing::NiceMock<SystemInfoMock> {};
+
+class ShortcutTest : public TestFixture {
+ public:
+ ShortcutTest() : TestFixture(std::make_unique<Mocks>()) {}
+ virtual ~ShortcutTest() {}
+
+ virtual void SetUp() {
+ }
+
+ virtual void TearDown() {
+ }
+};