From: SukhyungKang Date: Wed, 27 Sep 2023 02:13:46 +0000 (+0900) Subject: move notification ex unittest to notification unittest X-Git-Tag: accepted/tizen/8.0/unified/20231115.024702~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c220db4df0bb89d9a6ace05dbd86b71aae099f76;p=platform%2Fcore%2Fapi%2Fnotification.git move notification ex unittest to notification unittest Change-Id: I55d49671d5255a350396df228d7b85fa47dd8933 Signed-off-by: SukhyungKang --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c0fea1c..c07856c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,9 +5,6 @@ ADD_SUBDIRECTORY(notification-ex) ADD_SUBDIRECTORY(tests) ENABLE_TESTING() -SET(NOTIFICATION_EX_UNIT_TESTS notification-ex-unittests) -ADD_TEST(NAME ${NOTIFICATION_EX_UNIT_TESTS} COMMAND ${NOTIFICATION_EX_UNIT_TESTS}) -ADD_DEPENDENCIES(${NOTIFICATION_EX_UNIT_TESTS} notification-ex) SET(NOTIFICATION_UNIT_TESTS notification-unittests) ADD_TEST(NAME ${NOTIFICATION_UNIT_TESTS} COMMAND ${NOTIFICATION_UNIT_TESTS}) diff --git a/packaging/notification.spec b/packaging/notification.spec index f1ad08db..6edb49a5 100644 --- a/packaging/notification.spec +++ b/packaging/notification.spec @@ -121,10 +121,6 @@ mkdir -p %{buildroot}%{_bindir}/tizen-unittests/%{name} install -m 0755 run-unittest.sh %{buildroot}%{_bindir}/tizen-unittests/%{name}/ sed -i -e 's//notification/g' %{buildroot}%{_bindir}/tizen-unittests/%{name}/run-unittest.sh -mkdir -p %{buildroot}%{_bindir}/tizen-unittests/%{name}-ex -install -m 0755 run-unittest.sh %{buildroot}%{_bindir}/tizen-unittests/%{name}-ex/ -sed -i -e 's//notification-ex/g' %{buildroot}%{_bindir}/tizen-unittests/%{name}-ex/run-unittest.sh - mkdir -p %{buildroot}%{upgrade_script_path} cp -f scripts/505.notification_upgrade.sh %{buildroot}%{upgrade_script_path} @@ -209,20 +205,6 @@ Header & package configuration files to support development of the notification. %{_libdir}/pkgconfig/notification-ex.pc %attr(0644,root,root) %{_libdir}/libnotification-ex.so -################################################# -# notification-ex-unittests -################################################# -%package -n notification-ex-unittests -Summary: GTest for notification-ex -Group: Development/Libraries - -%description -n notification-ex-unittests -GTest for notification-ex - -%files -n notification-ex-unittests -%{_bindir}/notification-ex-unittests -%{_bindir}/tizen-unittests/%{name}/run-unittest.sh - ################################################# # notification-unittests ################################################# @@ -235,7 +217,7 @@ GTest for notification %files -n notification-unittests %{_bindir}/notification-unittests -%{_bindir}/tizen-unittests/%{name}-ex/run-unittest.sh +%{_bindir}/tizen-unittests/%{name}/run-unittest.sh %if 0%{?gcov:1} %files gcov diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5e5460b8..00bcdf90 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,2 +1 @@ ADD_SUBDIRECTORY(noti_unittest) -ADD_SUBDIRECTORY(noti_ex_unittest) diff --git a/tests/noti_ex_unittest/CMakeLists.txt b/tests/noti_ex_unittest/CMakeLists.txt deleted file mode 100644 index 5ff9faa5..00000000 --- a/tests/noti_ex_unittest/CMakeLists.txt +++ /dev/null @@ -1,50 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) -PROJECT(notification-ex-unittests CXX) - -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(notification-ex-unittests REQUIRED - dlog - gmock - capi-appfw-app-control - glib-2.0 - gio-2.0 - gio-unix-2.0 - aul - security-manager - libtzplatform-config -) - -FOREACH(flag ${notification-ex-unittests_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) -SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall") - -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}") -SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") -SET(CMAKE_CXX_FLAGS_RELEASE "-O2") - -INCLUDE_DIRECTORIES( - ${CMAKE_SOURCE_DIR}/ - ${CMAKE_SOURCE_DIR}/notification-ex/ - ${CMAKE_SOURCE_DIR}/notification-ex/api - ${CMAKE_CURRENT_SOURCE_DIR}/../ - ${CMAKE_CURRENT_SOURCE_DIR}/../mock -) - -AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCES) -AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../mock MOCK_SOURCES) -AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR}/notification-ex NOTIFICATION_EX_SOURCES) -ADD_EXECUTABLE(${PROJECT_NAME} - ${SOURCES} - ${NOTIFICATION_EX_SOURCES} - ${MOCK_SOURCES} -) - -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${notification-ex-unittests_LDFLAGS} - ${pkgs_LDFLAGS} - ${pkgs_LIBRARIES} - gmock - notification-ex -) - -INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin/) diff --git a/tests/noti_ex_unittest/src/test_main.cc b/tests/noti_ex_unittest/src/test_main.cc deleted file mode 100644 index ad7ec6c6..00000000 --- a/tests/noti_ex_unittest/src/test_main.cc +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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. - */ - -#include -#include - -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; -} diff --git a/tests/noti_ex_unittest/src/test_noti_ex_abstract_item.cc b/tests/noti_ex_unittest/src/test_noti_ex_abstract_item.cc deleted file mode 100644 index 3d1549a5..00000000 --- a/tests/noti_ex_unittest/src/test_noti_ex_abstract_item.cc +++ /dev/null @@ -1,349 +0,0 @@ -/* - * 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. - */ - -#include -#include -#include -#include - -#include "notification-ex/item_inflator.h" -#include "notification-ex/app_control_action.h" -#include "notification-ex/item_info_internal.h" -#include "notification-ex/iitem_factory.h" -#include "notification-ex/factory_manager.h" -#include "notification-ex/default_item_factory.h" -#include "notification-ex/group_item.h" -#include "notification-ex/button_item.h" - -#include "mock/test_fixture.hh" -#include "mock/smack_mock.hh" -#include "mock/app_common_mock.hh" -#include "mock/aul_mock.hh" - -#define MY_ITEM_TYPE AbstractItem::Type::Custom + 1 - -using namespace notification; -using namespace tizen_base; -using namespace notification::item; - -using ::testing::_; -using ::testing::Invoke; - -namespace { -class TestItem : public AbstractItem { - public: - TestItem(std::shared_ptr action = std::shared_ptr({})) - : AbstractItem(action) { - } - TestItem(std::string id, std::shared_ptr action = std::shared_ptr({})) - : AbstractItem(id, action) { - } - virtual ~TestItem() {} - - Bundle Serialize() const override { - Bundle b; - b = AbstractItem::Serialize(); - return b; - } - void Deserialize(Bundle b) override { - AbstractItem::Deserialize(b); - } - AbstractItem& FindByID(std::string id) override { - return *this; - } - bool IsItemTypeExist(int type) { - if (GetType() == type) - return true; - return false; - } - int GetType() const override { - return MY_ITEM_TYPE; - } -}; - -class MyFactory : public IItemFactory { - public: - MyFactory() {} - virtual ~MyFactory() {} - - std::unique_ptr CreateItem(int type) override { - if (type == MY_ITEM_TYPE) - return std::unique_ptr(new TestItem("")); - - return nullptr; - } -}; - -class Mocks : - virtual public ::testing::NiceMock, - virtual public ::testing::NiceMock, - virtual public ::testing::NiceMock {}; -} // namespace - -class AbstractItemTest : public TestFixture { - public: - AbstractItemTest() : TestFixture(std::make_unique<::Mocks>()) {} - - virtual void SetUp() { - FactoryManager::GetInst().RegisterFactory(std::unique_ptr(new MyFactory())); - } - virtual void TearDown() { - FactoryManager::GetInst().RegisterFactory(std::unique_ptr(new DefaultItemFactory())); - } -}; - -TEST_F(AbstractItemTest, SerializeDeserialize) { - /* Serialize */ - app_control_h app_control, app_control_1; - char* app_id = NULL; - time_t current_time; - Bundle extension_b; - - app_control_create(&app_control); - app_control_set_app_id(app_control, "new_appid"); - std::shared_ptr action = std::make_shared(app_control); - app_control_destroy(app_control); - - app_control_create(&app_control_1); - app_control_set_app_id(app_control_1, "new_appid_1"); - std::shared_ptr action_1 = std::make_shared(app_control_1); - app_control_destroy(app_control_1); - - TestItem item("test_id", action); - - std::shared_ptr color = std::make_shared(50, 100,150,200); - std::shared_ptr padding = std::make_shared(10, 20, 30, 40); - std::shared_ptr geometry = std::make_shared(110, 120, 130, 140); - std::shared_ptr bg_color = std::make_shared(71, 72, 73, 74); - - item.SetStyle(std::make_shared