From: mk5004.lee Date: Fri, 10 Jul 2020 05:36:09 +0000 (+0900) Subject: Apply gcov ON build X-Git-Tag: submit/tizen/20200710.064112~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=aaa5d3ad1aafe72d2ee3d8d64ff8dc0a3fdc441e;p=platform%2Fcore%2Fapi%2Fnotification.git Apply gcov ON build Change-Id: Iec33ef377ddf51302db5fc53f18ea64aabf20741 Signed-off-by: mk5004.lee --- diff --git a/packaging/notification.spec b/packaging/notification.spec index e2f4b09a..c385c481 100644 --- a/packaging/notification.spec +++ b/packaging/notification.spec @@ -24,6 +24,11 @@ BuildRequires: pkgconfig(libsmack) BuildRequires: pkgconfig(gmock) BuildRequires: pkgconfig(uuid) +%if 0%{?gcov:1} +BuildRequires: lcov +BuildRequires: zip +%endif + BuildRequires: cmake Requires(post): /sbin/ldconfig Requires(post): %{TZ_SYS_BIN}/sqlite3 @@ -75,6 +80,12 @@ find . -name '*.gcno' -exec cp '{}' gcov-obj ';' %check ctest --output-on-failure %{?_smp_mflags} +%if 0%{?gcov:1} +lcov -c --ignore-errors graph --no-external -q -d . -o notification-ex.info +genhtml notification-ex.info -o notification-ex.out +zip -r notification-ex.zip notification-ex.out +install -m 0644 notification-ex.zip %{buildroot}%{_datadir}/gcov/notification-ex.zip +%endif %install rm -rf %{buildroot} @@ -135,8 +146,6 @@ fi %{_libdir}/pkgconfig/notification.pc %{_libdir}/libnotification.so - - ################################################# # notification-ex ################################################# @@ -171,7 +180,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 ################################################# @@ -187,5 +195,5 @@ GTest for notification-ex %if 0%{?gcov:1} %files gcov -%{_datadir}/gcov/obj/* +%{_datadir}/gcov/* %endif diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt index 93823e72..afbc3baf 100644 --- a/unittest/CMakeLists.txt +++ b/unittest/CMakeLists.txt @@ -22,15 +22,15 @@ SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") SET(CMAKE_CXX_FLAGS_RELEASE "-O2") INCLUDE_DIRECTORIES( - ${CMAKE_CURRENT_SOURCE_DIR}/../notification-ex - ${CMAKE_CURRENT_SOURCE_DIR}/../notification-ex/api - ${CMAKE_CURRENT_SOURCE_DIR}/../mock - ${CMAKE_CURRENT_SOURCE_DIR}/../ + ${CMAKE_SOURCE_DIR}/notification-ex + ${CMAKE_SOURCE_DIR}/notification-ex/api + ${CMAKE_SOURCE_DIR}/mock + ${CMAKE_SOURCE_DIR}/ ) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCES) -AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../mock MOCK_SOURCES) -AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../notification-ex NOTIFICATION_EX_SOURCES) +AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR}/mock MOCK_SOURCES) +AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR}/notification-ex NOTIFICATION_EX_SOURCES) ADD_EXECUTABLE(${PROJECT_NAME} ${SOURCES} ${NOTIFICATION_EX_SOURCES} diff --git a/unittest/src/test_abstract_item.cc b/unittest/src/test_abstract_item.cc deleted file mode 100644 index ef3650ea..00000000 --- a/unittest/src/test_abstract_item.cc +++ /dev/null @@ -1,331 +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" - -#define MY_ITEM_TYPE AbstractItem::Type::Custom + 1 - -using namespace notification; -using namespace tizen_base; -using namespace notification::item; - -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 AbstractItemTest : public ::testing::Test { - public: - 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