Apply gcov ON build 62/238262/2
authormk5004.lee <mk5004.lee@samsung.com>
Fri, 10 Jul 2020 05:36:09 +0000 (14:36 +0900)
committermk5004.lee <mk5004.lee@samsung.com>
Fri, 10 Jul 2020 06:00:42 +0000 (15:00 +0900)
Change-Id: Iec33ef377ddf51302db5fc53f18ea64aabf20741
Signed-off-by: mk5004.lee <mk5004.lee@samsung.com>
35 files changed:
packaging/notification.spec
unittest/CMakeLists.txt
unittest/src/test_abstract_item.cc [deleted file]
unittest/src/test_app_control_action.cc [deleted file]
unittest/src/test_button_item.cc [deleted file]
unittest/src/test_chat_message_item.cc [deleted file]
unittest/src/test_checkbox_item.cc [deleted file]
unittest/src/test_entry_item.cc [deleted file]
unittest/src/test_event_info.cc [deleted file]
unittest/src/test_group_item.cc [deleted file]
unittest/src/test_icon_item.cc [deleted file]
unittest/src/test_image_item.cc [deleted file]
unittest/src/test_input_selector_item.cc [deleted file]
unittest/src/test_main.cc
unittest/src/test_noti_ex_abstract_item.cc [new file with mode: 0644]
unittest/src/test_noti_ex_app_control_action.cc [new file with mode: 0644]
unittest/src/test_noti_ex_button_item.cc [new file with mode: 0644]
unittest/src/test_noti_ex_chat_message_item.cc [new file with mode: 0644]
unittest/src/test_noti_ex_checkbox_item.cc [new file with mode: 0644]
unittest/src/test_noti_ex_entry_item.cc [new file with mode: 0644]
unittest/src/test_noti_ex_event_info.cc [new file with mode: 0644]
unittest/src/test_noti_ex_group_item.cc [new file with mode: 0644]
unittest/src/test_noti_ex_icon_item.cc [new file with mode: 0644]
unittest/src/test_noti_ex_image_item.cc [new file with mode: 0644]
unittest/src/test_noti_ex_input_selector_item.cc [new file with mode: 0644]
unittest/src/test_noti_ex_progress_item.cc [new file with mode: 0644]
unittest/src/test_noti_ex_shared_file.cc [new file with mode: 0644]
unittest/src/test_noti_ex_text_item.cc [new file with mode: 0644]
unittest/src/test_noti_ex_time_item.cc [new file with mode: 0644]
unittest/src/test_noti_ex_visibility_action.cc [new file with mode: 0644]
unittest/src/test_progress_item.cc [deleted file]
unittest/src/test_shared_file.cc [deleted file]
unittest/src/test_text_item.cc [deleted file]
unittest/src/test_time_item.cc [deleted file]
unittest/src/test_visibility_action.cc [deleted file]

index e2f4b09a800bf533ff856ea314a6b3aed49709cd..c385c481dd3b9e7549437911b40826fd28734358 100644 (file)
@@ -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
index 93823e72939c3ff93ace91fb84c9ddaacc2a89c0..afbc3baf2bf946d5010a30e2fe5e378b46bc73e5 100644 (file)
@@ -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 (file)
index ef3650e..0000000
+++ /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 <gtest/gtest.h>
-#include <gmock/gmock.h>
-#include <app_control.h>
-#include <app_common.h>
-
-#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<AbstractAction> action = std::shared_ptr<AbstractAction>({}))
-     : AbstractItem(action) {
-   }
-   TestItem(std::string id, std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}))
-     : 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<AbstractItem> CreateItem(int type) override {
-    if (type == MY_ITEM_TYPE)
-      return std::unique_ptr<AbstractItem>(new TestItem(""));
-
-    return nullptr;
-  }
-};
-
-class AbstractItemTest : public ::testing::Test {
- public:
-  virtual void SetUp() {
-    FactoryManager::GetInst().RegisterFactory(std::unique_ptr<IItemFactory>(new MyFactory()));
-  }
-  virtual void TearDown() {
-    FactoryManager::GetInst().RegisterFactory(std::unique_ptr<IItemFactory>(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<AppControlAction> action = std::make_shared<AppControlAction>(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<AppControlAction> action_1 = std::make_shared<AppControlAction>(app_control_1);
-  app_control_destroy(app_control_1);
-
-  TestItem item("test_id", action);
-
-  std::shared_ptr<Color> color = std::make_shared<Color>(50, 100,150,200);
-  std::shared_ptr<Padding> padding = std::make_shared<Padding>(10, 20, 30, 40);
-  std::shared_ptr<Geometry> geometry = std::make_shared<Geometry>(110, 120, 130, 140);
-  std::shared_ptr<Color> bg_color = std::make_shared<Color>(71, 72, 73, 74);
-
-  item.SetStyle(std::make_shared<Style>(color, padding, geometry, bg_color, "bg path"));
-  item.SetVisible(false);
-  item.SetEnable(false);
-  item.AddReceiver("receiver_1");
-  item.AddReceiver("receiver_2");
-  std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->AddHideViewer("hide_1");
-  std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->AddHideViewer("hide_2");
-  item.SetPolicy(AbstractItem::Policy::OnBootClear);
-  std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->SetVersion(3);
-  item.GetInfo()->SetHideTime(5);
-  item.GetInfo()->SetDeleteTime(9);
-  item.SetChannel("channel99");
-  item.SetSoundPath("soundpath");
-  item.SetVibrationPath("vibrationpath");
-  std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->SetUid(3);
-  item.SetSenderAppId("sender");
-  item.SetTag("tag");
-
-  time(&current_time);
-  std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->SetTime(current_time);
-
-  std::shared_ptr<Color> color2 = std::make_shared<Color>(150, 160, 170, 180);
-  std::shared_ptr<LEDInfo> led = std::make_shared<LEDInfo>(color2);
-  led->SetOnPeriod(10);
-  led->SetOffPeriod(20);
-
-  item.SetLEDInfo(led);
-  item.SetOnGoingState(true);
-
-  extension_b.Add("test_key", "test_value");
-  item.SetExtensionData("extension_key", extension_b);
-
-  /* Deserialize */
-  Bundle b = item.Serialize();
-
-  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
-  TestItem* gen_test = static_cast<TestItem*>(gen_item.get());
-
-  ASSERT_EQ(gen_test->GetId(), "test_id");
-  ASSERT_EQ(gen_test->GetType(), MY_ITEM_TYPE);
-  ASSERT_EQ(std::static_pointer_cast<IItemInfoInternal>(gen_test->GetInfo())->GetUid(), 3);
-  ASSERT_EQ(gen_test->GetEnable(), false);
-  ASSERT_EQ(gen_test->GetVisible(),false);
-  ASSERT_EQ(gen_test->GetPolicy(), AbstractItem::Policy::OnBootClear);
-  ASSERT_EQ(std::static_pointer_cast<IItemInfoInternal>(gen_test->GetInfo())->GetVersion(), 3);
-  ASSERT_EQ(gen_test->GetInfo()->GetHideTime(), 5);
-  ASSERT_EQ(gen_test->GetInfo()->GetDeleteTime(), 9);
-  ASSERT_EQ(gen_test->GetChannel(), "channel99");
-  ASSERT_EQ(gen_test->GetSoundPath(), "soundpath");
-  ASSERT_EQ(gen_test->GetVibrationPath(), "vibrationpath");
-  ASSERT_EQ(gen_test->GetSenderAppId(), "sender");
-  ASSERT_EQ(gen_test->GetTag(), "tag");
-  ASSERT_EQ(gen_test->GetInfo()->GetTime(), current_time);
-
-  ASSERT_EQ(gen_test->GetStyle()->GetPadding()->GetLeft(), 10);
-  ASSERT_EQ(gen_test->GetStyle()->GetPadding()->GetTop(), 20);
-  ASSERT_EQ(gen_test->GetStyle()->GetPadding()->GetRight(), 30);
-  ASSERT_EQ(gen_test->GetStyle()->GetPadding()->GetBottom(), 40);
-
-  ASSERT_EQ(gen_test->GetStyle()->GetColor()->GetAVal(), 50);
-  ASSERT_EQ(gen_test->GetStyle()->GetColor()->GetRVal(), 100);
-  ASSERT_EQ(gen_test->GetStyle()->GetColor()->GetGVal(), 150);
-  ASSERT_EQ(gen_test->GetStyle()->GetColor()->GetBVal(), 200);
-
-  ASSERT_EQ(gen_test->GetStyle()->GetGeometry()->GetX(), 110);
-  ASSERT_EQ(gen_test->GetStyle()->GetGeometry()->GetY(), 120);
-  ASSERT_EQ(gen_test->GetStyle()->GetGeometry()->GetWidth(), 130);
-  ASSERT_EQ(gen_test->GetStyle()->GetGeometry()->GetHeight(), 140);
-
-  ASSERT_EQ(gen_test->GetStyle()->GetBackgroundColor()->GetAVal(), 71);
-  ASSERT_EQ(gen_test->GetStyle()->GetBackgroundColor()->GetRVal(), 72);
-  ASSERT_EQ(gen_test->GetStyle()->GetBackgroundColor()->GetGVal(), 73);
-  ASSERT_EQ(gen_test->GetStyle()->GetBackgroundColor()->GetBVal(), 74);
-
-  ASSERT_EQ(gen_test->GetStyle()->GetBackgroundImage(), "bg path");
-
-  ASSERT_EQ(gen_test->GetLEDInfo()->GetColor()->GetAVal(), 150);
-  ASSERT_EQ(gen_test->GetLEDInfo()->GetColor()->GetRVal(), 160);
-  ASSERT_EQ(gen_test->GetLEDInfo()->GetColor()->GetGVal(), 170);
-  ASSERT_EQ(gen_test->GetLEDInfo()->GetColor()->GetBVal(), 180);
-  ASSERT_EQ(gen_test->GetLEDInfo()->GetOnPeriod(), 10);
-  ASSERT_EQ(gen_test->GetLEDInfo()->GetOffPeriod(), 20);
-
-  std::list<std::string> receiver1 = item.GetReceiverList();
-  std::list<std::string> receiver2 = gen_test->GetReceiverList();
-
-  ASSERT_EQ(receiver1.size(), receiver2.size());
-
-  for (unsigned int i = 0; i < receiver1.size(); i++) {
-    ASSERT_EQ(receiver1.front(), receiver2.front());
-    receiver1.pop_front();
-    receiver2.pop_front();
-  }
-
-  std::list<std::string> hide1 =
-      std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->GetHideViewerList();
-  std::list<std::string> hide2 =
-      std::static_pointer_cast<IItemInfoInternal>(gen_test->GetInfo())->GetHideViewerList();
-
-  ASSERT_EQ(hide1.size(), hide2.size());
-
-  for (unsigned int i = 0; i < hide1.size(); i++) {
-    ASSERT_EQ(hide1.front(), hide2.front());
-    hide1.pop_front();
-    hide2.pop_front();
-  }
-
-  ASSERT_EQ(gen_test->GetAction()->GetType(), AbstractAction::Type::AppControl);
-
-  std::shared_ptr<AppControlAction> ac =
-      std::static_pointer_cast<AppControlAction>(gen_test->GetAction());
-  app_control_get_app_id(ac->GetAppControl(), &app_id);
-
-  ASSERT_STREQ(app_id, "new_appid");
-
-  item.SetAction(action_1);
-
-  b = item.Serialize();
-  gen_item = ItemInflator::Create(b);
-  gen_test = static_cast<TestItem*>(gen_item.get());
-
-  ac = std::static_pointer_cast<AppControlAction>(gen_test->GetAction());
-  app_control_get_app_id(ac->GetAppControl(), &app_id);
-
-  ASSERT_STREQ(app_id, "new_appid_1");
-  ASSERT_EQ(gen_test->GetOnGoingState(), true);
-
-  Bundle extension_b2 = gen_test->GetExtensionData("extension_key");
-  ASSERT_EQ(extension_b2.GetString("test_key"), "test_value");
-}
-
-TEST_F(AbstractItemTest, SerializeDeserialize2) {
-  /* Serialize */
-  TestItem item("test_id");
-
-  std::shared_ptr<Color> color = std::make_shared<Color>(50, 100,150,200);
-  std::shared_ptr<Padding> padding = std::make_shared<Padding>(10, 20, 30, 40);
-  std::shared_ptr<Geometry> geometry = std::make_shared<Geometry>(110, 120, 130, 140);
-
-  item.SetStyle(std::make_shared<Style>(color, padding, geometry, nullptr, ""));
-
-  /* Deserialize */
-  Bundle b = item.Serialize();
-
-  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
-  TestItem* gen_test = static_cast<TestItem*>(gen_item.get());
-
-  ASSERT_EQ(gen_test->GetStyle()->GetPadding()->GetLeft(), 10);
-  ASSERT_EQ(gen_test->GetStyle()->GetPadding()->GetTop(), 20);
-  ASSERT_EQ(gen_test->GetStyle()->GetPadding()->GetRight(), 30);
-  ASSERT_EQ(gen_test->GetStyle()->GetPadding()->GetBottom(), 40);
-
-  ASSERT_EQ(gen_test->GetStyle()->GetColor()->GetAVal(), 50);
-  ASSERT_EQ(gen_test->GetStyle()->GetColor()->GetRVal(), 100);
-  ASSERT_EQ(gen_test->GetStyle()->GetColor()->GetGVal(), 150);
-  ASSERT_EQ(gen_test->GetStyle()->GetColor()->GetBVal(), 200);
-
-  ASSERT_EQ(gen_test->GetStyle()->GetGeometry()->GetX(), 110);
-  ASSERT_EQ(gen_test->GetStyle()->GetGeometry()->GetY(), 120);
-  ASSERT_EQ(gen_test->GetStyle()->GetGeometry()->GetWidth(), 130);
-  ASSERT_EQ(gen_test->GetStyle()->GetGeometry()->GetHeight(), 140);
-
-  ASSERT_EQ(gen_test->GetStyle()->GetBackgroundColor(), nullptr);
-  ASSERT_EQ(gen_test->GetStyle()->GetBackgroundImage(), "");
-}
-
-TEST_F(AbstractItemTest, ItemInfoCanReceive) {
-  TestItem item("test_id");
-
-  item.AddReceiver(ReceiverGroup::Panel);
-  item.AddReceiver(ReceiverGroup::LockScreen);
-
-  ASSERT_TRUE(std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->CanReceive(ReceiverGroup::Panel));
-  ASSERT_TRUE(std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->CanReceive(ReceiverGroup::LockScreen));
-  ASSERT_FALSE(std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->CanReceive(ReceiverGroup::Popup));
-}
-
-TEST_F(AbstractItemTest, SetGetOnGoingState) {
-  TestItem item("test_id");
-
-  ASSERT_EQ(item.GetOnGoingState(), false);
-
-  item.SetOnGoingState(true);
-
-  ASSERT_EQ(item.GetOnGoingState(), true);
-}
-
-int __fake_app_get_name(char** app_name) {
-  *app_name = strdup("unittest_appname");
-  return 0;
-}
-
-TEST_F(AbstractItemTest, SetGetFindMainType) {
-  app_get_name_fake.custom_fake = __fake_app_get_name;
-
-  auto root = std::make_shared<GroupItem>("test_group");
-  auto item = std::make_shared<ButtonItem>("test_id", "title");
-  root->AddChild(item);
-
-  bool ret = root->SetMainType("test_id", AbstractItem::MainButton);
-  EXPECT_TRUE(ret);
-  EXPECT_EQ(item->GetMainType(), AbstractItem::MainButton);
-  auto& i = root->FindByMainType(AbstractItem::MainButton);
-  EXPECT_EQ(i.GetId(), "test_id");
-}
-
-TEST_F(AbstractItemTest, SetInvalidMainType) {
-  auto root = std::make_shared<GroupItem>("test_group");
-  auto item = std::make_shared<ButtonItem>("test_id", "title");
-  root->AddChild(item);
-
-  bool ret = root->SetMainType("test_id", AbstractItem::MainTitle);
-  EXPECT_FALSE(ret);
-}
-
-}  // namespace
diff --git a/unittest/src/test_app_control_action.cc b/unittest/src/test_app_control_action.cc
deleted file mode 100644 (file)
index 7b49c60..0000000
+++ /dev/null
@@ -1,93 +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 <gtest/gtest.h>
-#include <gmock/gmock.h>
-
-#include "notification-ex/app_control_action.h"
-#include "notification-ex/action_inflator.h"
-
-using namespace tizen_base;
-using namespace notification;
-using namespace notification::item;
-
-class AppControlActionTest : public ::testing::Test {
- public:
-  AppControlAction* action;
-  app_control_h app_control;
-  const char* app_id = "test_appid";
-  std::string extra = "appcontrol_extra";
-
-  virtual void SetUp() {
-    app_control_create(&app_control);
-    app_control_set_app_id(app_control, app_id);
-
-    action = new AppControlAction(app_control, extra);
-  }
-  virtual void TearDown() {
-    delete action;
-    app_control_destroy(app_control);
-  }
-};
-
-TEST_F(AppControlActionTest, create) {
-  EXPECT_NE(AppControlActionTest::action, nullptr);
-}
-
-TEST_F(AppControlActionTest, IsLocal) {
-  ASSERT_EQ(AppControlActionTest::action->IsLocal(), 1);
-}
-
-TEST_F(AppControlActionTest, GetExtra) {
-  ASSERT_EQ(AppControlActionTest::action->GetExtra(),
-    AppControlActionTest::extra);
-}
-
-TEST_F(AppControlActionTest, SerializeDeserialize) {
-  Bundle b = AppControlActionTest::action->Serialize();
-
-  std::shared_ptr<AbstractAction> gen_action = ActionInflator::Create(b);
-  ASSERT_EQ(gen_action->GetType(), AbstractAction::AppControl);
-
-  AppControlAction* gen_appcontrol_action =
-    static_cast<AppControlAction*>(gen_action.get());
-
-  char* app_id = nullptr;
-  app_control_get_app_id(gen_appcontrol_action->GetAppControl(), &app_id);
-  std::unique_ptr<char, decltype(std::free)*> ptr(app_id, std::free);
-  ASSERT_STREQ(app_id, AppControlActionTest::app_id);
-}
-
-TEST_F(AppControlActionTest, AppControl) {
-  app_control_h app_control;
-  const char* app_id = "new_appid";
-
-  app_control_create(&app_control);
-  app_control_set_app_id(app_control, app_id);
-  AppControlActionTest::action->SetAppControl(app_control);
-  app_control_destroy(app_control);
-
-  Bundle b = AppControlActionTest::action->Serialize();
-
-  std::shared_ptr<AbstractAction> gen_action = ActionInflator::Create(b);
-  AppControlAction* gen_appcontrol_action =
-    static_cast<AppControlAction*>(gen_action.get());
-
-  char* app_id_ = nullptr;
-  app_control_get_app_id(gen_appcontrol_action->GetAppControl(), &app_id_);
-  std::unique_ptr<char, decltype(std::free)*> ptr(app_id_, std::free);
-  EXPECT_STREQ(app_id, app_id_);
-}
diff --git a/unittest/src/test_button_item.cc b/unittest/src/test_button_item.cc
deleted file mode 100644 (file)
index dc14b30..0000000
+++ /dev/null
@@ -1,61 +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 <gmock/gmock.h>
-
-#include "notification-ex/button_item.h"
-#include "notification-ex/item_inflator.h"
-
-using namespace tizen_base;
-using namespace notification;
-using namespace notification::item;
-using namespace std;
-
-namespace {
-
-class ButtonItemTest : public ::testing::Test {
- protected:
-  void SetUp() override {}
-  void TearDown() override {}
-};
-
-
-TEST_F(ButtonItemTest, FindByID) {
-  ButtonItem item("btn_id", "title");
-
-  AbstractItem& child = item.FindByID("btn_id");
-  ButtonItem& btn = static_cast<ButtonItem&>(child);
-  ASSERT_EQ(btn.GetTitle(), "title");
-}
-
-TEST_F(ButtonItemTest, FindByIDNullItemReturn) {
-  ButtonItem item("btn_id", "title");
-
-  AbstractItem& child = item.FindByID("not_exist_button");
-  ASSERT_EQ(child.GetType(), AbstractItem::NullObject);
-}
-
-TEST_F(ButtonItemTest, SerializeDeserializeGetTitle) {
-  ButtonItem item("title");
-  Bundle b = item.Serialize();
-  shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
-  ASSERT_EQ(gen_item->GetType(), item.GetType());
-
-  auto gen_btn = std::static_pointer_cast<ButtonItem>(gen_item);
-  ASSERT_EQ(item.GetTitle(), gen_btn->GetTitle());
-}
-
-}  // namespace
diff --git a/unittest/src/test_chat_message_item.cc b/unittest/src/test_chat_message_item.cc
deleted file mode 100644 (file)
index cde985a..0000000
+++ /dev/null
@@ -1,75 +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 <gtest/gtest.h>
-#include <gmock/gmock.h>
-
-#include "notification-ex/chat_message_item.h"
-#include "notification-ex/item_inflator.h"
-
-using namespace tizen_base;
-using namespace notification;
-using namespace notification::item;
-
-class ChatMessageItemTest : public ::testing::Test {
- public:
-  ChatMessageItem* item;
-  ChatMessageItem::Type type = ChatMessageItem::Type::user;
-  std::string id = "chatmessage_id";
-  time_t current_time;
-  virtual void SetUp() {
-    time(&current_time);
-
-    item = new ChatMessageItem(id,
-      std::make_shared<TextItem>("name_id", "name"),
-      std::make_shared<TextItem>("text_id", "text"),
-      std::make_shared<ImageItem>("image_id", "path"),
-      std::make_shared<TimeItem>(current_time),type);
-  }
-  virtual void TearDown() {
-    delete item;
-  }
-};
-
-TEST_F(ChatMessageItemTest, create) {
-  EXPECT_NE(ChatMessageItemTest::item, nullptr);
-}
-
-TEST_F(ChatMessageItemTest, FindByID) {
-  AbstractItem& child = ChatMessageItemTest::item->FindByID(ChatMessageItemTest::id);
-  ChatMessageItem& message = static_cast<ChatMessageItem&>(child);
-  ASSERT_EQ(message.GetNameItem().GetContents(), "name");
-  ASSERT_EQ(message.GetTextItem().GetContents(), "text");
-  ASSERT_EQ(message.GetImageItem().GetImagePath(), "path");
-  ASSERT_EQ(message.GetMessageType(), ChatMessageItemTest::type);
-}
-
-TEST_F(ChatMessageItemTest, FindByIDNullItemReturn) {
-  AbstractItem& child = ChatMessageItemTest::item->FindByID("not_existed_item");
-  ASSERT_EQ(child.GetType(), ChatMessageItem::NullObject);
-}
-
-TEST_F(ChatMessageItemTest, SerializeDeserialize) {
-  Bundle b = ChatMessageItemTest::item->Serialize();
-
-  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
-  auto gen_message = std::static_pointer_cast<ChatMessageItem>(gen_item);
-  ASSERT_EQ(gen_message->GetNameItem().GetContents(), "name");
-  ASSERT_EQ(gen_message->GetTextItem().GetContents(), "text");
-  ASSERT_EQ(gen_message->GetImageItem().GetImagePath(), "path");
-  ASSERT_EQ(gen_message->GetTimeItem().GetTime(), ChatMessageItemTest::current_time);
-  ASSERT_EQ(gen_message->GetMessageType(), ChatMessageItemTest::type);
-}
diff --git a/unittest/src/test_checkbox_item.cc b/unittest/src/test_checkbox_item.cc
deleted file mode 100644 (file)
index eba55a7..0000000
+++ /dev/null
@@ -1,65 +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 <gtest/gtest.h>
-#include <gmock/gmock.h>
-
-#include "notification-ex/checkbox_item.h"
-#include "notification-ex/item_inflator.h"
-
-using namespace tizen_base;
-using namespace notification;
-using namespace notification::item;
-
-class CheckBoxItemTest : public ::testing::Test {
- public:
-  CheckBoxItem* item;
-  std::string id = "checkbox_id";
-  std::string title = "title";
-  bool isChecked = false;
-  virtual void SetUp() {
-    item = new CheckBoxItem(id, title, isChecked);
-  }
-  virtual void TearDown() {
-    delete item;
-  }
-};
-
-TEST_F(CheckBoxItemTest, create) {
-  EXPECT_NE(CheckBoxItemTest::item, nullptr);
-}
-
-TEST_F(CheckBoxItemTest, FindByID) {
-  AbstractItem& child = CheckBoxItemTest::item->FindByID(CheckBoxItemTest::id);
-  CheckBoxItem& checkbox = static_cast<CheckBoxItem&>(child);
-  ASSERT_EQ(checkbox.GetTitle(), CheckBoxItemTest::title);
-  ASSERT_EQ(checkbox.IsChecked(), CheckBoxItemTest::isChecked);
-}
-
-TEST_F(CheckBoxItemTest, FindByIDNullItemReturn) {
-  AbstractItem& child = CheckBoxItemTest::item->FindByID("not_existed_item");
-  ASSERT_EQ(child.GetType(), CheckBoxItem::NullObject);
-}
-
-TEST_F(CheckBoxItemTest, SerializeDeserialize) {
-  Bundle b = CheckBoxItemTest::item->Serialize();
-
-  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
-  ASSERT_EQ(CheckBoxItemTest::item->GetType(), gen_item->GetType());
-
-  auto gen_checkbox = std::static_pointer_cast<CheckBoxItem>(gen_item);
-  ASSERT_EQ(CheckBoxItemTest::item->GetTitle(), gen_checkbox->GetTitle());
-}
diff --git a/unittest/src/test_entry_item.cc b/unittest/src/test_entry_item.cc
deleted file mode 100644 (file)
index 76b0006..0000000
+++ /dev/null
@@ -1,74 +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 <gtest/gtest.h>
-#include <gmock/gmock.h>
-
-#include "notification-ex/entry_item.h"
-#include "notification-ex/item_inflator.h"
-
-using namespace tizen_base;
-using namespace notification;
-using namespace notification::item;
-
-namespace {
-
-class EntryItemTest : public ::testing::Test {
- public:
-  virtual void SetUp() {}
-  virtual void TearDown() {}
-};
-
-TEST_F(EntryItemTest, FindByID) {
-  EntryItem item("entry_id");
-
-  AbstractItem& child = item.FindByID("entry_id");
-  EntryItem& btn = static_cast<EntryItem&>(child);
-  ASSERT_EQ(btn.GetId(), "entry_id");
-}
-
-TEST_F(EntryItemTest, FindByIDNullItemReturn) {
-  EntryItem item("entry_id");
-
-  AbstractItem& child = item.FindByID("not_existed_item");
-  ASSERT_EQ(child.GetType(), EntryItem::NullObject);
-}
-
-TEST_F(EntryItemTest, SerializeDeserialize) {
-  EntryItem item("entry_id");
-
-  Bundle b = item.Serialize();
-  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
-  ASSERT_EQ(gen_item->GetType(), item.GetType());
-
-  auto gen_effect = std::static_pointer_cast<EntryItem>(gen_item);
-  ASSERT_EQ(item.GetId(), gen_effect->GetId());
-}
-
-TEST_F(EntryItemTest, SetTextGetText) {
-  EntryItem item("entry_id");
-  item.SetText("test");
-
-  ASSERT_EQ(item.GetText(), "test");
-}
-
-TEST_F(EntryItemTest, GetTextLimit) {
-  EntryItem item("entry_id");
-
-  ASSERT_EQ(item.GetTextLimit(), 160);
-}
-
-}  // namespace
\ No newline at end of file
diff --git a/unittest/src/test_event_info.cc b/unittest/src/test_event_info.cc
deleted file mode 100644 (file)
index e478c44..0000000
+++ /dev/null
@@ -1,51 +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 <gmock/gmock.h>
-
-#include "notification-ex/event_info_internal.h"
-
-using namespace tizen_base;
-using namespace notification;
-using namespace std;
-
-namespace {
-
-class EventInfoTest : public ::testing::Test {
- protected:
-  void SetUp() override {}
-  void TearDown() override {}
-};
-
-TEST_F(EventInfoTest, SerializeDeserialize) {
-  EventInfo info(EventInfo::Get, "test", "channel", "id");
-  Bundle b = info.Serialize();
-  EventInfo serialized(b);
-  ASSERT_EQ(serialized.GetEventType(), info.GetEventType());
-  ASSERT_EQ(serialized.GetOwner(), info.GetOwner());
-  ASSERT_EQ(serialized.GetChannel(), info.GetChannel());
-  ASSERT_EQ(serialized.GetItemId(), info.GetItemId());
-  ASSERT_EQ(serialized.GetUid(), info.GetUid());
-}
-
-TEST_F(EventInfoTest, GetString) {
-  ASSERT_EQ(EventInfo::GetString(EventInfo::Post), "Post");
-  ASSERT_EQ(EventInfo::GetString(EventInfo::Update), "Update");
-  ASSERT_EQ(EventInfo::GetString(EventInfo::Delete), "Delete");
-  ASSERT_EQ(EventInfo::GetString(EventInfo::Get), "Get");
-}
-
-}  // namespace
diff --git a/unittest/src/test_group_item.cc b/unittest/src/test_group_item.cc
deleted file mode 100755 (executable)
index 8cf8c79..0000000
+++ /dev/null
@@ -1,178 +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 <gmock/gmock.h>
-
-#include "notification-ex/group_item.h"
-#include "notification-ex/button_item.h"
-#include "notification-ex/text_item.h"
-#include "notification-ex/item_inflator.h"
-#include "mock/app_common.h"
-
-using namespace tizen_base;
-using namespace notification;
-using namespace notification::item;
-using namespace std;
-
-namespace {
-
-class GroupItemTest : public ::testing::Test {
- protected:
-  void SetUp() override {}
-  void TearDown() override {}
-};
-
-TEST_F(GroupItemTest, AddChild) {
-  GroupItem item("GROUP1");
-  item.AddChild(std::make_shared<ButtonItem>("btn1", "test1"));
-  item.AddChild(std::make_shared<ButtonItem>("btn2", "test2"));
-  ASSERT_EQ(item.GetChildren().size(), 2);
-}
-
-TEST_F(GroupItemTest, RemoveChild) {
-  GroupItem item("GROUP1");
-  item.AddChild(std::make_shared<ButtonItem>("btn1", "test1"));
-  item.AddChild(std::make_shared<ButtonItem>("btn2", "test2"));
-  ASSERT_EQ(item.GetChildren().size(), 2);
-
-  item.RemoveChild("btn1");
-  ASSERT_EQ(item.GetChildren().size(), 1);
-}
-
-int __fake_app_get_name(char** app_name) {
-  *app_name = strdup("unittest_appname");
-  return 0;
-}
-
-TEST_F(GroupItemTest, SerializeDeserialize) {
-  app_get_name_fake.custom_fake = __fake_app_get_name;
-
-  GroupItem item("GROUP1");
-  item.AddChild(std::make_shared<ButtonItem>("btn1", "test1"));
-  item.AddChild(std::make_shared<ButtonItem>("btn2", "test2"));
-
-  Bundle b = item.Serialize();
-  shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
-  ASSERT_EQ(gen_item->GetType(), item.GetType());
-
-  auto gen_group = static_pointer_cast<GroupItem>(gen_item);
-  list<shared_ptr<AbstractItem>> gen_children_list = gen_group->GetChildren();
-  list<shared_ptr<AbstractItem>> origin_children_list = item.GetChildren();
-
-  list<shared_ptr<AbstractItem>>::iterator it = origin_children_list.begin();
-  for (auto& i : gen_children_list) {
-    ASSERT_EQ(i->GetType(), (*it)->GetType());
-    if (i->GetType() == AbstractItem::Button) {
-      ButtonItem* btn1 = static_cast<ButtonItem*>(i.get());
-      ButtonItem* btn2 = static_cast<ButtonItem*>((*it).get());
-      ASSERT_EQ(btn1->GetTitle(), btn2->GetTitle());
-    }
-    it++;
-  }
-  ASSERT_EQ(item.GetChildren().size(), 2);
-}
-
-TEST_F(GroupItemTest, FindByID) {
-  GroupItem item("GROUP1");
-  item.AddChild(std::make_shared<ButtonItem>("btn1", "test1"));
-  item.AddChild(std::make_shared<ButtonItem>("btn2", "test2"));
-  ASSERT_EQ(item.GetChildren().size(), 2);
-
-  AbstractItem& child = item.FindByID("btn2");
-  ButtonItem& btn = static_cast<ButtonItem&>(child);
-  ASSERT_EQ(btn.GetTitle(), "test2");
-}
-
-TEST_F(GroupItemTest, FindByIDGroupItem) {
-  GroupItem item("GROUP1");
-  shared_ptr<GroupItem> gr2 = shared_ptr<GroupItem>(new GroupItem("GROUP2"));
-  shared_ptr<GroupItem> gr3 = shared_ptr<GroupItem>(new GroupItem("GROUP3"));
-  gr2->AddChild(std::make_shared<ButtonItem>("btn2", "test2"));
-  gr2->AddChild(std::make_shared<ButtonItem>("btn3", "test3"));
-  gr2->AddChild(std::make_shared<ButtonItem>("btn4", "test4"));
-  gr3->AddChild(std::make_shared<ButtonItem>("btn6", "test6"));
-  gr2->AddChild(gr3);
-
-  item.AddChild(std::make_shared<ButtonItem>("btn1", "test1"));
-  item.AddChild(gr2);
-  item.AddChild(std::make_shared<ButtonItem>("btn5", "test5"));
-  ASSERT_EQ(item.GetChildren().size(), 3);
-
-  AbstractItem& child = item.FindByID("btn3");
-  ButtonItem& btn = static_cast<ButtonItem&>(child);
-  ASSERT_EQ(btn.GetTitle(), "test3");
-
-  AbstractItem& child2 = item.FindByID("GROUP3");
-  GroupItem& ret_gr = static_cast<GroupItem&>(child2);
-  ASSERT_EQ(ret_gr.GetChildren().size(), 1);
-}
-
-
-TEST_F(GroupItemTest, IsItemTypeExist) {
-  GroupItem item("GROUP1");
-  shared_ptr<GroupItem> gr2 = shared_ptr<GroupItem>(new GroupItem("GROUP2"));
-  shared_ptr<GroupItem> gr3 = shared_ptr<GroupItem>(new GroupItem("GROUP3"));
-  gr2->AddChild(std::make_shared<ButtonItem>("btn2", "test2"));
-  gr2->AddChild(std::make_shared<ButtonItem>("btn3", "test3"));
-  gr2->AddChild(std::make_shared<ButtonItem>("btn4", "test4"));
-  gr3->AddChild(std::make_shared<ButtonItem>("btn6", "test6"));
-  gr3->AddChild(std::make_shared<TextItem>("text1", "text1"));
-  gr2->AddChild(gr3);
-
-  item.AddChild(std::make_shared<ButtonItem>("btn1", "test1"));
-  item.AddChild(gr2);
-  item.AddChild(std::make_shared<ButtonItem>("btn5", "test5"));
-  ASSERT_EQ(item.GetChildren().size(), 3);
-
-  ASSERT_EQ(item.IsItemTypeExist(AbstractItem::Text), true);
-  ASSERT_EQ(item.IsItemTypeExist(AbstractItem::Image), false);
-}
-
-TEST_F(GroupItemTest, FindByIDNullItemReturn) {
-  GroupItem item("GROUP1");
-  item.AddChild(std::make_shared<ButtonItem>("btn1", "test1"));
-  item.AddChild(std::make_shared<ButtonItem>("btn2", "test2"));
-  ASSERT_EQ(item.GetChildren().size(), 2);
-
-  AbstractItem& child = item.FindByID("not_exist_button");
-  ASSERT_EQ(child.GetType(), AbstractItem::NullObject);
-}
-
-TEST_F(GroupItemTest, GetAppLabel) {
-  app_get_name_fake.custom_fake = __fake_app_get_name;
-
-  GroupItem item("GROUP1");
-  string app_label = item.GetAppLabel();
-
-  ASSERT_EQ(app_label, "unittest_appname");
-}
-
-TEST_F(GroupItemTest, SetAppLabel) {
-  GroupItem item("GROUP1");
-  item.SetAppLabel("test");
-  string app_label = item.GetAppLabel();
-
-  ASSERT_EQ(app_label, "test");
-}
-
-TEST_F(GroupItemTest, SetDirection) {
-  GroupItem item("GROUP1");
-  item.SetDirection(true);
-
-  ASSERT_TRUE(item.IsVertical());
-}
-
-}  // namespace
diff --git a/unittest/src/test_icon_item.cc b/unittest/src/test_icon_item.cc
deleted file mode 100644 (file)
index 98ff517..0000000
+++ /dev/null
@@ -1,62 +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 <gtest/gtest.h>
-#include <gmock/gmock.h>
-
-#include "notification-ex/icon_item.h"
-#include "notification-ex/item_inflator.h"
-
-using namespace tizen_base;
-using namespace notification;
-using namespace notification::item;
-
-class IconItemTest : public ::testing::Test {
- public:
-  IconItem* item;
-  std::string id = "icon_id";
-  virtual void SetUp() {
-    item = new IconItem(id, "icon_path");
-  }
-  virtual void TearDown() {
-    delete item;
-  }
-};
-
-TEST_F(IconItemTest, create) {
-  EXPECT_NE(IconItemTest::item, nullptr);
-}
-
-TEST_F(IconItemTest, FindByID) {
-  AbstractItem& child = IconItemTest::item->FindByID(IconItemTest::id);
-  IconItem& icon = static_cast<IconItem&>(child);
-  ASSERT_EQ(icon.GetImagePath(), "icon_path");
-}
-
-TEST_F(IconItemTest, FindByIDNullItemReturn) {
-  AbstractItem& child = IconItemTest::item->FindByID("not_existed_item");
-  ASSERT_EQ(child.GetType(), IconItem::NullObject);
-}
-
-TEST_F(IconItemTest, SerializeDeserialize) {
-  Bundle b = IconItemTest::item->Serialize();
-
-  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
-  ASSERT_EQ(IconItemTest::item->GetType(), gen_item->GetType());
-
-  auto gen_icon = std::static_pointer_cast<IconItem>(gen_item);
-  ASSERT_EQ(IconItemTest::item->GetImagePath(), gen_icon->GetImagePath());
-}
diff --git a/unittest/src/test_image_item.cc b/unittest/src/test_image_item.cc
deleted file mode 100644 (file)
index 66c6786..0000000
+++ /dev/null
@@ -1,63 +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 <gtest/gtest.h>
-#include <gmock/gmock.h>
-
-#include "notification-ex/image_item.h"
-#include "notification-ex/item_inflator.h"
-
-using namespace tizen_base;
-using namespace notification;
-using namespace notification::item;
-
-class ImageItemTest : public ::testing::Test {
- public:
-  ImageItem* item;
-  std::string id = "image_id";
-  std::string imagePath = "image_path";
-  virtual void SetUp() {
-    item = new ImageItem(id, imagePath);
-  }
-  virtual void TearDown() {
-    delete item;
-  }
-};
-
-TEST_F(ImageItemTest, create) {
-  EXPECT_NE(ImageItemTest::item, nullptr);
-}
-
-TEST_F(ImageItemTest, FindByID) {
-  AbstractItem& child = ImageItemTest::item->FindByID(ImageItemTest::id);
-  ImageItem& image = static_cast<ImageItem&>(child);
-  ASSERT_EQ(image.GetImagePath(), ImageItemTest::imagePath);
-}
-
-TEST_F(ImageItemTest, FindByIDNullItemReturn) {
-  AbstractItem& child = ImageItemTest::item->FindByID("not_existed_item");
-  ASSERT_EQ(child.GetType(), ImageItem::NullObject);
-}
-
-TEST_F(ImageItemTest, SerializeDeserialize) {
-  Bundle b = ImageItemTest::item->Serialize();
-
-  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
-  ASSERT_EQ(ImageItemTest::item->GetType(), gen_item->GetType());
-
-  auto gen_image = std::static_pointer_cast<ImageItem>(gen_item);
-  ASSERT_EQ(ImageItemTest::item->GetImagePath(), gen_image->GetImagePath());
-}
diff --git a/unittest/src/test_input_selector_item.cc b/unittest/src/test_input_selector_item.cc
deleted file mode 100644 (file)
index 862cfc5..0000000
+++ /dev/null
@@ -1,60 +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 <gmock/gmock.h>
-
-#include "notification-ex/input_selector_item.h"
-#include "notification-ex/item_inflator.h"
-
-using namespace tizen_base;
-using namespace notification;
-using namespace notification::item;
-using namespace std;
-
-namespace {
-
-class InputSelectorItemTest : public ::testing::Test {
- protected:
-  void SetUp() override {}
-  void TearDown() override {}
-};
-
-TEST_F(InputSelectorItemTest, SerializeDeserialize) {
-  InputSelectorItem item;
-  list<string> contents;
-  contents.push_back("AA");
-  contents.push_back("BB");
-  contents.push_back("CC");
-  item.SetContents(contents);
-
-  Bundle b = item.Serialize();
-  shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
-  ASSERT_EQ(gen_item->GetType(), item.GetType());
-
-  auto gen_input = static_pointer_cast<InputSelectorItem>(gen_item);
-
-  list<string> l1 = item.GetContents();
-  list<string> l2 = gen_input->GetContents();
-  list<string>::iterator it1 = l1.begin();
-  list<string>::iterator it2 = l2.begin();
-  while(it1 != l1.end() && it2 != l2.end()) {
-    ASSERT_EQ((*it1), (*it2));
-    it1++;
-    it2++;
-  }
-}
-
-}  // namespace
index 4be05dc275d23d77c861d58b112c96439bb0d594..ad7ec6c6b9e93764787c3b02553d351665f9e3ec 100644 (file)
@@ -17,9 +17,9 @@
 #include <gtest/gtest.h>
 #include <gmock/gmock.h>
 
-int main(int argc, char** argv){
+int main(int argc, char** argv) {
   int ret = -1;
-  setenv("GCOV_PREFIX", "/tmp/", 1);
+
   try {
     testing::InitGoogleTest(&argc, argv);
   } catch(...) {
diff --git a/unittest/src/test_noti_ex_abstract_item.cc b/unittest/src/test_noti_ex_abstract_item.cc
new file mode 100644 (file)
index 0000000..ef3650e
--- /dev/null
@@ -0,0 +1,331 @@
+/*
+ * 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 <gtest/gtest.h>
+#include <gmock/gmock.h>
+#include <app_control.h>
+#include <app_common.h>
+
+#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<AbstractAction> action = std::shared_ptr<AbstractAction>({}))
+     : AbstractItem(action) {
+   }
+   TestItem(std::string id, std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}))
+     : 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<AbstractItem> CreateItem(int type) override {
+    if (type == MY_ITEM_TYPE)
+      return std::unique_ptr<AbstractItem>(new TestItem(""));
+
+    return nullptr;
+  }
+};
+
+class AbstractItemTest : public ::testing::Test {
+ public:
+  virtual void SetUp() {
+    FactoryManager::GetInst().RegisterFactory(std::unique_ptr<IItemFactory>(new MyFactory()));
+  }
+  virtual void TearDown() {
+    FactoryManager::GetInst().RegisterFactory(std::unique_ptr<IItemFactory>(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<AppControlAction> action = std::make_shared<AppControlAction>(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<AppControlAction> action_1 = std::make_shared<AppControlAction>(app_control_1);
+  app_control_destroy(app_control_1);
+
+  TestItem item("test_id", action);
+
+  std::shared_ptr<Color> color = std::make_shared<Color>(50, 100,150,200);
+  std::shared_ptr<Padding> padding = std::make_shared<Padding>(10, 20, 30, 40);
+  std::shared_ptr<Geometry> geometry = std::make_shared<Geometry>(110, 120, 130, 140);
+  std::shared_ptr<Color> bg_color = std::make_shared<Color>(71, 72, 73, 74);
+
+  item.SetStyle(std::make_shared<Style>(color, padding, geometry, bg_color, "bg path"));
+  item.SetVisible(false);
+  item.SetEnable(false);
+  item.AddReceiver("receiver_1");
+  item.AddReceiver("receiver_2");
+  std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->AddHideViewer("hide_1");
+  std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->AddHideViewer("hide_2");
+  item.SetPolicy(AbstractItem::Policy::OnBootClear);
+  std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->SetVersion(3);
+  item.GetInfo()->SetHideTime(5);
+  item.GetInfo()->SetDeleteTime(9);
+  item.SetChannel("channel99");
+  item.SetSoundPath("soundpath");
+  item.SetVibrationPath("vibrationpath");
+  std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->SetUid(3);
+  item.SetSenderAppId("sender");
+  item.SetTag("tag");
+
+  time(&current_time);
+  std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->SetTime(current_time);
+
+  std::shared_ptr<Color> color2 = std::make_shared<Color>(150, 160, 170, 180);
+  std::shared_ptr<LEDInfo> led = std::make_shared<LEDInfo>(color2);
+  led->SetOnPeriod(10);
+  led->SetOffPeriod(20);
+
+  item.SetLEDInfo(led);
+  item.SetOnGoingState(true);
+
+  extension_b.Add("test_key", "test_value");
+  item.SetExtensionData("extension_key", extension_b);
+
+  /* Deserialize */
+  Bundle b = item.Serialize();
+
+  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
+  TestItem* gen_test = static_cast<TestItem*>(gen_item.get());
+
+  ASSERT_EQ(gen_test->GetId(), "test_id");
+  ASSERT_EQ(gen_test->GetType(), MY_ITEM_TYPE);
+  ASSERT_EQ(std::static_pointer_cast<IItemInfoInternal>(gen_test->GetInfo())->GetUid(), 3);
+  ASSERT_EQ(gen_test->GetEnable(), false);
+  ASSERT_EQ(gen_test->GetVisible(),false);
+  ASSERT_EQ(gen_test->GetPolicy(), AbstractItem::Policy::OnBootClear);
+  ASSERT_EQ(std::static_pointer_cast<IItemInfoInternal>(gen_test->GetInfo())->GetVersion(), 3);
+  ASSERT_EQ(gen_test->GetInfo()->GetHideTime(), 5);
+  ASSERT_EQ(gen_test->GetInfo()->GetDeleteTime(), 9);
+  ASSERT_EQ(gen_test->GetChannel(), "channel99");
+  ASSERT_EQ(gen_test->GetSoundPath(), "soundpath");
+  ASSERT_EQ(gen_test->GetVibrationPath(), "vibrationpath");
+  ASSERT_EQ(gen_test->GetSenderAppId(), "sender");
+  ASSERT_EQ(gen_test->GetTag(), "tag");
+  ASSERT_EQ(gen_test->GetInfo()->GetTime(), current_time);
+
+  ASSERT_EQ(gen_test->GetStyle()->GetPadding()->GetLeft(), 10);
+  ASSERT_EQ(gen_test->GetStyle()->GetPadding()->GetTop(), 20);
+  ASSERT_EQ(gen_test->GetStyle()->GetPadding()->GetRight(), 30);
+  ASSERT_EQ(gen_test->GetStyle()->GetPadding()->GetBottom(), 40);
+
+  ASSERT_EQ(gen_test->GetStyle()->GetColor()->GetAVal(), 50);
+  ASSERT_EQ(gen_test->GetStyle()->GetColor()->GetRVal(), 100);
+  ASSERT_EQ(gen_test->GetStyle()->GetColor()->GetGVal(), 150);
+  ASSERT_EQ(gen_test->GetStyle()->GetColor()->GetBVal(), 200);
+
+  ASSERT_EQ(gen_test->GetStyle()->GetGeometry()->GetX(), 110);
+  ASSERT_EQ(gen_test->GetStyle()->GetGeometry()->GetY(), 120);
+  ASSERT_EQ(gen_test->GetStyle()->GetGeometry()->GetWidth(), 130);
+  ASSERT_EQ(gen_test->GetStyle()->GetGeometry()->GetHeight(), 140);
+
+  ASSERT_EQ(gen_test->GetStyle()->GetBackgroundColor()->GetAVal(), 71);
+  ASSERT_EQ(gen_test->GetStyle()->GetBackgroundColor()->GetRVal(), 72);
+  ASSERT_EQ(gen_test->GetStyle()->GetBackgroundColor()->GetGVal(), 73);
+  ASSERT_EQ(gen_test->GetStyle()->GetBackgroundColor()->GetBVal(), 74);
+
+  ASSERT_EQ(gen_test->GetStyle()->GetBackgroundImage(), "bg path");
+
+  ASSERT_EQ(gen_test->GetLEDInfo()->GetColor()->GetAVal(), 150);
+  ASSERT_EQ(gen_test->GetLEDInfo()->GetColor()->GetRVal(), 160);
+  ASSERT_EQ(gen_test->GetLEDInfo()->GetColor()->GetGVal(), 170);
+  ASSERT_EQ(gen_test->GetLEDInfo()->GetColor()->GetBVal(), 180);
+  ASSERT_EQ(gen_test->GetLEDInfo()->GetOnPeriod(), 10);
+  ASSERT_EQ(gen_test->GetLEDInfo()->GetOffPeriod(), 20);
+
+  std::list<std::string> receiver1 = item.GetReceiverList();
+  std::list<std::string> receiver2 = gen_test->GetReceiverList();
+
+  ASSERT_EQ(receiver1.size(), receiver2.size());
+
+  for (unsigned int i = 0; i < receiver1.size(); i++) {
+    ASSERT_EQ(receiver1.front(), receiver2.front());
+    receiver1.pop_front();
+    receiver2.pop_front();
+  }
+
+  std::list<std::string> hide1 =
+      std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->GetHideViewerList();
+  std::list<std::string> hide2 =
+      std::static_pointer_cast<IItemInfoInternal>(gen_test->GetInfo())->GetHideViewerList();
+
+  ASSERT_EQ(hide1.size(), hide2.size());
+
+  for (unsigned int i = 0; i < hide1.size(); i++) {
+    ASSERT_EQ(hide1.front(), hide2.front());
+    hide1.pop_front();
+    hide2.pop_front();
+  }
+
+  ASSERT_EQ(gen_test->GetAction()->GetType(), AbstractAction::Type::AppControl);
+
+  std::shared_ptr<AppControlAction> ac =
+      std::static_pointer_cast<AppControlAction>(gen_test->GetAction());
+  app_control_get_app_id(ac->GetAppControl(), &app_id);
+
+  ASSERT_STREQ(app_id, "new_appid");
+
+  item.SetAction(action_1);
+
+  b = item.Serialize();
+  gen_item = ItemInflator::Create(b);
+  gen_test = static_cast<TestItem*>(gen_item.get());
+
+  ac = std::static_pointer_cast<AppControlAction>(gen_test->GetAction());
+  app_control_get_app_id(ac->GetAppControl(), &app_id);
+
+  ASSERT_STREQ(app_id, "new_appid_1");
+  ASSERT_EQ(gen_test->GetOnGoingState(), true);
+
+  Bundle extension_b2 = gen_test->GetExtensionData("extension_key");
+  ASSERT_EQ(extension_b2.GetString("test_key"), "test_value");
+}
+
+TEST_F(AbstractItemTest, SerializeDeserialize2) {
+  /* Serialize */
+  TestItem item("test_id");
+
+  std::shared_ptr<Color> color = std::make_shared<Color>(50, 100,150,200);
+  std::shared_ptr<Padding> padding = std::make_shared<Padding>(10, 20, 30, 40);
+  std::shared_ptr<Geometry> geometry = std::make_shared<Geometry>(110, 120, 130, 140);
+
+  item.SetStyle(std::make_shared<Style>(color, padding, geometry, nullptr, ""));
+
+  /* Deserialize */
+  Bundle b = item.Serialize();
+
+  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
+  TestItem* gen_test = static_cast<TestItem*>(gen_item.get());
+
+  ASSERT_EQ(gen_test->GetStyle()->GetPadding()->GetLeft(), 10);
+  ASSERT_EQ(gen_test->GetStyle()->GetPadding()->GetTop(), 20);
+  ASSERT_EQ(gen_test->GetStyle()->GetPadding()->GetRight(), 30);
+  ASSERT_EQ(gen_test->GetStyle()->GetPadding()->GetBottom(), 40);
+
+  ASSERT_EQ(gen_test->GetStyle()->GetColor()->GetAVal(), 50);
+  ASSERT_EQ(gen_test->GetStyle()->GetColor()->GetRVal(), 100);
+  ASSERT_EQ(gen_test->GetStyle()->GetColor()->GetGVal(), 150);
+  ASSERT_EQ(gen_test->GetStyle()->GetColor()->GetBVal(), 200);
+
+  ASSERT_EQ(gen_test->GetStyle()->GetGeometry()->GetX(), 110);
+  ASSERT_EQ(gen_test->GetStyle()->GetGeometry()->GetY(), 120);
+  ASSERT_EQ(gen_test->GetStyle()->GetGeometry()->GetWidth(), 130);
+  ASSERT_EQ(gen_test->GetStyle()->GetGeometry()->GetHeight(), 140);
+
+  ASSERT_EQ(gen_test->GetStyle()->GetBackgroundColor(), nullptr);
+  ASSERT_EQ(gen_test->GetStyle()->GetBackgroundImage(), "");
+}
+
+TEST_F(AbstractItemTest, ItemInfoCanReceive) {
+  TestItem item("test_id");
+
+  item.AddReceiver(ReceiverGroup::Panel);
+  item.AddReceiver(ReceiverGroup::LockScreen);
+
+  ASSERT_TRUE(std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->CanReceive(ReceiverGroup::Panel));
+  ASSERT_TRUE(std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->CanReceive(ReceiverGroup::LockScreen));
+  ASSERT_FALSE(std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->CanReceive(ReceiverGroup::Popup));
+}
+
+TEST_F(AbstractItemTest, SetGetOnGoingState) {
+  TestItem item("test_id");
+
+  ASSERT_EQ(item.GetOnGoingState(), false);
+
+  item.SetOnGoingState(true);
+
+  ASSERT_EQ(item.GetOnGoingState(), true);
+}
+
+int __fake_app_get_name(char** app_name) {
+  *app_name = strdup("unittest_appname");
+  return 0;
+}
+
+TEST_F(AbstractItemTest, SetGetFindMainType) {
+  app_get_name_fake.custom_fake = __fake_app_get_name;
+
+  auto root = std::make_shared<GroupItem>("test_group");
+  auto item = std::make_shared<ButtonItem>("test_id", "title");
+  root->AddChild(item);
+
+  bool ret = root->SetMainType("test_id", AbstractItem::MainButton);
+  EXPECT_TRUE(ret);
+  EXPECT_EQ(item->GetMainType(), AbstractItem::MainButton);
+  auto& i = root->FindByMainType(AbstractItem::MainButton);
+  EXPECT_EQ(i.GetId(), "test_id");
+}
+
+TEST_F(AbstractItemTest, SetInvalidMainType) {
+  auto root = std::make_shared<GroupItem>("test_group");
+  auto item = std::make_shared<ButtonItem>("test_id", "title");
+  root->AddChild(item);
+
+  bool ret = root->SetMainType("test_id", AbstractItem::MainTitle);
+  EXPECT_FALSE(ret);
+}
+
+}  // namespace
diff --git a/unittest/src/test_noti_ex_app_control_action.cc b/unittest/src/test_noti_ex_app_control_action.cc
new file mode 100644 (file)
index 0000000..7b49c60
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * 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 <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include "notification-ex/app_control_action.h"
+#include "notification-ex/action_inflator.h"
+
+using namespace tizen_base;
+using namespace notification;
+using namespace notification::item;
+
+class AppControlActionTest : public ::testing::Test {
+ public:
+  AppControlAction* action;
+  app_control_h app_control;
+  const char* app_id = "test_appid";
+  std::string extra = "appcontrol_extra";
+
+  virtual void SetUp() {
+    app_control_create(&app_control);
+    app_control_set_app_id(app_control, app_id);
+
+    action = new AppControlAction(app_control, extra);
+  }
+  virtual void TearDown() {
+    delete action;
+    app_control_destroy(app_control);
+  }
+};
+
+TEST_F(AppControlActionTest, create) {
+  EXPECT_NE(AppControlActionTest::action, nullptr);
+}
+
+TEST_F(AppControlActionTest, IsLocal) {
+  ASSERT_EQ(AppControlActionTest::action->IsLocal(), 1);
+}
+
+TEST_F(AppControlActionTest, GetExtra) {
+  ASSERT_EQ(AppControlActionTest::action->GetExtra(),
+    AppControlActionTest::extra);
+}
+
+TEST_F(AppControlActionTest, SerializeDeserialize) {
+  Bundle b = AppControlActionTest::action->Serialize();
+
+  std::shared_ptr<AbstractAction> gen_action = ActionInflator::Create(b);
+  ASSERT_EQ(gen_action->GetType(), AbstractAction::AppControl);
+
+  AppControlAction* gen_appcontrol_action =
+    static_cast<AppControlAction*>(gen_action.get());
+
+  char* app_id = nullptr;
+  app_control_get_app_id(gen_appcontrol_action->GetAppControl(), &app_id);
+  std::unique_ptr<char, decltype(std::free)*> ptr(app_id, std::free);
+  ASSERT_STREQ(app_id, AppControlActionTest::app_id);
+}
+
+TEST_F(AppControlActionTest, AppControl) {
+  app_control_h app_control;
+  const char* app_id = "new_appid";
+
+  app_control_create(&app_control);
+  app_control_set_app_id(app_control, app_id);
+  AppControlActionTest::action->SetAppControl(app_control);
+  app_control_destroy(app_control);
+
+  Bundle b = AppControlActionTest::action->Serialize();
+
+  std::shared_ptr<AbstractAction> gen_action = ActionInflator::Create(b);
+  AppControlAction* gen_appcontrol_action =
+    static_cast<AppControlAction*>(gen_action.get());
+
+  char* app_id_ = nullptr;
+  app_control_get_app_id(gen_appcontrol_action->GetAppControl(), &app_id_);
+  std::unique_ptr<char, decltype(std::free)*> ptr(app_id_, std::free);
+  EXPECT_STREQ(app_id, app_id_);
+}
diff --git a/unittest/src/test_noti_ex_button_item.cc b/unittest/src/test_noti_ex_button_item.cc
new file mode 100644 (file)
index 0000000..dc14b30
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * 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 <gmock/gmock.h>
+
+#include "notification-ex/button_item.h"
+#include "notification-ex/item_inflator.h"
+
+using namespace tizen_base;
+using namespace notification;
+using namespace notification::item;
+using namespace std;
+
+namespace {
+
+class ButtonItemTest : public ::testing::Test {
+ protected:
+  void SetUp() override {}
+  void TearDown() override {}
+};
+
+
+TEST_F(ButtonItemTest, FindByID) {
+  ButtonItem item("btn_id", "title");
+
+  AbstractItem& child = item.FindByID("btn_id");
+  ButtonItem& btn = static_cast<ButtonItem&>(child);
+  ASSERT_EQ(btn.GetTitle(), "title");
+}
+
+TEST_F(ButtonItemTest, FindByIDNullItemReturn) {
+  ButtonItem item("btn_id", "title");
+
+  AbstractItem& child = item.FindByID("not_exist_button");
+  ASSERT_EQ(child.GetType(), AbstractItem::NullObject);
+}
+
+TEST_F(ButtonItemTest, SerializeDeserializeGetTitle) {
+  ButtonItem item("title");
+  Bundle b = item.Serialize();
+  shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
+  ASSERT_EQ(gen_item->GetType(), item.GetType());
+
+  auto gen_btn = std::static_pointer_cast<ButtonItem>(gen_item);
+  ASSERT_EQ(item.GetTitle(), gen_btn->GetTitle());
+}
+
+}  // namespace
diff --git a/unittest/src/test_noti_ex_chat_message_item.cc b/unittest/src/test_noti_ex_chat_message_item.cc
new file mode 100644 (file)
index 0000000..cde985a
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * 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 <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include "notification-ex/chat_message_item.h"
+#include "notification-ex/item_inflator.h"
+
+using namespace tizen_base;
+using namespace notification;
+using namespace notification::item;
+
+class ChatMessageItemTest : public ::testing::Test {
+ public:
+  ChatMessageItem* item;
+  ChatMessageItem::Type type = ChatMessageItem::Type::user;
+  std::string id = "chatmessage_id";
+  time_t current_time;
+  virtual void SetUp() {
+    time(&current_time);
+
+    item = new ChatMessageItem(id,
+      std::make_shared<TextItem>("name_id", "name"),
+      std::make_shared<TextItem>("text_id", "text"),
+      std::make_shared<ImageItem>("image_id", "path"),
+      std::make_shared<TimeItem>(current_time),type);
+  }
+  virtual void TearDown() {
+    delete item;
+  }
+};
+
+TEST_F(ChatMessageItemTest, create) {
+  EXPECT_NE(ChatMessageItemTest::item, nullptr);
+}
+
+TEST_F(ChatMessageItemTest, FindByID) {
+  AbstractItem& child = ChatMessageItemTest::item->FindByID(ChatMessageItemTest::id);
+  ChatMessageItem& message = static_cast<ChatMessageItem&>(child);
+  ASSERT_EQ(message.GetNameItem().GetContents(), "name");
+  ASSERT_EQ(message.GetTextItem().GetContents(), "text");
+  ASSERT_EQ(message.GetImageItem().GetImagePath(), "path");
+  ASSERT_EQ(message.GetMessageType(), ChatMessageItemTest::type);
+}
+
+TEST_F(ChatMessageItemTest, FindByIDNullItemReturn) {
+  AbstractItem& child = ChatMessageItemTest::item->FindByID("not_existed_item");
+  ASSERT_EQ(child.GetType(), ChatMessageItem::NullObject);
+}
+
+TEST_F(ChatMessageItemTest, SerializeDeserialize) {
+  Bundle b = ChatMessageItemTest::item->Serialize();
+
+  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
+  auto gen_message = std::static_pointer_cast<ChatMessageItem>(gen_item);
+  ASSERT_EQ(gen_message->GetNameItem().GetContents(), "name");
+  ASSERT_EQ(gen_message->GetTextItem().GetContents(), "text");
+  ASSERT_EQ(gen_message->GetImageItem().GetImagePath(), "path");
+  ASSERT_EQ(gen_message->GetTimeItem().GetTime(), ChatMessageItemTest::current_time);
+  ASSERT_EQ(gen_message->GetMessageType(), ChatMessageItemTest::type);
+}
diff --git a/unittest/src/test_noti_ex_checkbox_item.cc b/unittest/src/test_noti_ex_checkbox_item.cc
new file mode 100644 (file)
index 0000000..eba55a7
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * 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 <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include "notification-ex/checkbox_item.h"
+#include "notification-ex/item_inflator.h"
+
+using namespace tizen_base;
+using namespace notification;
+using namespace notification::item;
+
+class CheckBoxItemTest : public ::testing::Test {
+ public:
+  CheckBoxItem* item;
+  std::string id = "checkbox_id";
+  std::string title = "title";
+  bool isChecked = false;
+  virtual void SetUp() {
+    item = new CheckBoxItem(id, title, isChecked);
+  }
+  virtual void TearDown() {
+    delete item;
+  }
+};
+
+TEST_F(CheckBoxItemTest, create) {
+  EXPECT_NE(CheckBoxItemTest::item, nullptr);
+}
+
+TEST_F(CheckBoxItemTest, FindByID) {
+  AbstractItem& child = CheckBoxItemTest::item->FindByID(CheckBoxItemTest::id);
+  CheckBoxItem& checkbox = static_cast<CheckBoxItem&>(child);
+  ASSERT_EQ(checkbox.GetTitle(), CheckBoxItemTest::title);
+  ASSERT_EQ(checkbox.IsChecked(), CheckBoxItemTest::isChecked);
+}
+
+TEST_F(CheckBoxItemTest, FindByIDNullItemReturn) {
+  AbstractItem& child = CheckBoxItemTest::item->FindByID("not_existed_item");
+  ASSERT_EQ(child.GetType(), CheckBoxItem::NullObject);
+}
+
+TEST_F(CheckBoxItemTest, SerializeDeserialize) {
+  Bundle b = CheckBoxItemTest::item->Serialize();
+
+  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
+  ASSERT_EQ(CheckBoxItemTest::item->GetType(), gen_item->GetType());
+
+  auto gen_checkbox = std::static_pointer_cast<CheckBoxItem>(gen_item);
+  ASSERT_EQ(CheckBoxItemTest::item->GetTitle(), gen_checkbox->GetTitle());
+}
diff --git a/unittest/src/test_noti_ex_entry_item.cc b/unittest/src/test_noti_ex_entry_item.cc
new file mode 100644 (file)
index 0000000..76b0006
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * 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 <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include "notification-ex/entry_item.h"
+#include "notification-ex/item_inflator.h"
+
+using namespace tizen_base;
+using namespace notification;
+using namespace notification::item;
+
+namespace {
+
+class EntryItemTest : public ::testing::Test {
+ public:
+  virtual void SetUp() {}
+  virtual void TearDown() {}
+};
+
+TEST_F(EntryItemTest, FindByID) {
+  EntryItem item("entry_id");
+
+  AbstractItem& child = item.FindByID("entry_id");
+  EntryItem& btn = static_cast<EntryItem&>(child);
+  ASSERT_EQ(btn.GetId(), "entry_id");
+}
+
+TEST_F(EntryItemTest, FindByIDNullItemReturn) {
+  EntryItem item("entry_id");
+
+  AbstractItem& child = item.FindByID("not_existed_item");
+  ASSERT_EQ(child.GetType(), EntryItem::NullObject);
+}
+
+TEST_F(EntryItemTest, SerializeDeserialize) {
+  EntryItem item("entry_id");
+
+  Bundle b = item.Serialize();
+  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
+  ASSERT_EQ(gen_item->GetType(), item.GetType());
+
+  auto gen_effect = std::static_pointer_cast<EntryItem>(gen_item);
+  ASSERT_EQ(item.GetId(), gen_effect->GetId());
+}
+
+TEST_F(EntryItemTest, SetTextGetText) {
+  EntryItem item("entry_id");
+  item.SetText("test");
+
+  ASSERT_EQ(item.GetText(), "test");
+}
+
+TEST_F(EntryItemTest, GetTextLimit) {
+  EntryItem item("entry_id");
+
+  ASSERT_EQ(item.GetTextLimit(), 160);
+}
+
+}  // namespace
\ No newline at end of file
diff --git a/unittest/src/test_noti_ex_event_info.cc b/unittest/src/test_noti_ex_event_info.cc
new file mode 100644 (file)
index 0000000..e478c44
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * 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 <gmock/gmock.h>
+
+#include "notification-ex/event_info_internal.h"
+
+using namespace tizen_base;
+using namespace notification;
+using namespace std;
+
+namespace {
+
+class EventInfoTest : public ::testing::Test {
+ protected:
+  void SetUp() override {}
+  void TearDown() override {}
+};
+
+TEST_F(EventInfoTest, SerializeDeserialize) {
+  EventInfo info(EventInfo::Get, "test", "channel", "id");
+  Bundle b = info.Serialize();
+  EventInfo serialized(b);
+  ASSERT_EQ(serialized.GetEventType(), info.GetEventType());
+  ASSERT_EQ(serialized.GetOwner(), info.GetOwner());
+  ASSERT_EQ(serialized.GetChannel(), info.GetChannel());
+  ASSERT_EQ(serialized.GetItemId(), info.GetItemId());
+  ASSERT_EQ(serialized.GetUid(), info.GetUid());
+}
+
+TEST_F(EventInfoTest, GetString) {
+  ASSERT_EQ(EventInfo::GetString(EventInfo::Post), "Post");
+  ASSERT_EQ(EventInfo::GetString(EventInfo::Update), "Update");
+  ASSERT_EQ(EventInfo::GetString(EventInfo::Delete), "Delete");
+  ASSERT_EQ(EventInfo::GetString(EventInfo::Get), "Get");
+}
+
+}  // namespace
diff --git a/unittest/src/test_noti_ex_group_item.cc b/unittest/src/test_noti_ex_group_item.cc
new file mode 100644 (file)
index 0000000..8cf8c79
--- /dev/null
@@ -0,0 +1,178 @@
+/*
+ * 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 <gmock/gmock.h>
+
+#include "notification-ex/group_item.h"
+#include "notification-ex/button_item.h"
+#include "notification-ex/text_item.h"
+#include "notification-ex/item_inflator.h"
+#include "mock/app_common.h"
+
+using namespace tizen_base;
+using namespace notification;
+using namespace notification::item;
+using namespace std;
+
+namespace {
+
+class GroupItemTest : public ::testing::Test {
+ protected:
+  void SetUp() override {}
+  void TearDown() override {}
+};
+
+TEST_F(GroupItemTest, AddChild) {
+  GroupItem item("GROUP1");
+  item.AddChild(std::make_shared<ButtonItem>("btn1", "test1"));
+  item.AddChild(std::make_shared<ButtonItem>("btn2", "test2"));
+  ASSERT_EQ(item.GetChildren().size(), 2);
+}
+
+TEST_F(GroupItemTest, RemoveChild) {
+  GroupItem item("GROUP1");
+  item.AddChild(std::make_shared<ButtonItem>("btn1", "test1"));
+  item.AddChild(std::make_shared<ButtonItem>("btn2", "test2"));
+  ASSERT_EQ(item.GetChildren().size(), 2);
+
+  item.RemoveChild("btn1");
+  ASSERT_EQ(item.GetChildren().size(), 1);
+}
+
+int __fake_app_get_name(char** app_name) {
+  *app_name = strdup("unittest_appname");
+  return 0;
+}
+
+TEST_F(GroupItemTest, SerializeDeserialize) {
+  app_get_name_fake.custom_fake = __fake_app_get_name;
+
+  GroupItem item("GROUP1");
+  item.AddChild(std::make_shared<ButtonItem>("btn1", "test1"));
+  item.AddChild(std::make_shared<ButtonItem>("btn2", "test2"));
+
+  Bundle b = item.Serialize();
+  shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
+  ASSERT_EQ(gen_item->GetType(), item.GetType());
+
+  auto gen_group = static_pointer_cast<GroupItem>(gen_item);
+  list<shared_ptr<AbstractItem>> gen_children_list = gen_group->GetChildren();
+  list<shared_ptr<AbstractItem>> origin_children_list = item.GetChildren();
+
+  list<shared_ptr<AbstractItem>>::iterator it = origin_children_list.begin();
+  for (auto& i : gen_children_list) {
+    ASSERT_EQ(i->GetType(), (*it)->GetType());
+    if (i->GetType() == AbstractItem::Button) {
+      ButtonItem* btn1 = static_cast<ButtonItem*>(i.get());
+      ButtonItem* btn2 = static_cast<ButtonItem*>((*it).get());
+      ASSERT_EQ(btn1->GetTitle(), btn2->GetTitle());
+    }
+    it++;
+  }
+  ASSERT_EQ(item.GetChildren().size(), 2);
+}
+
+TEST_F(GroupItemTest, FindByID) {
+  GroupItem item("GROUP1");
+  item.AddChild(std::make_shared<ButtonItem>("btn1", "test1"));
+  item.AddChild(std::make_shared<ButtonItem>("btn2", "test2"));
+  ASSERT_EQ(item.GetChildren().size(), 2);
+
+  AbstractItem& child = item.FindByID("btn2");
+  ButtonItem& btn = static_cast<ButtonItem&>(child);
+  ASSERT_EQ(btn.GetTitle(), "test2");
+}
+
+TEST_F(GroupItemTest, FindByIDGroupItem) {
+  GroupItem item("GROUP1");
+  shared_ptr<GroupItem> gr2 = shared_ptr<GroupItem>(new GroupItem("GROUP2"));
+  shared_ptr<GroupItem> gr3 = shared_ptr<GroupItem>(new GroupItem("GROUP3"));
+  gr2->AddChild(std::make_shared<ButtonItem>("btn2", "test2"));
+  gr2->AddChild(std::make_shared<ButtonItem>("btn3", "test3"));
+  gr2->AddChild(std::make_shared<ButtonItem>("btn4", "test4"));
+  gr3->AddChild(std::make_shared<ButtonItem>("btn6", "test6"));
+  gr2->AddChild(gr3);
+
+  item.AddChild(std::make_shared<ButtonItem>("btn1", "test1"));
+  item.AddChild(gr2);
+  item.AddChild(std::make_shared<ButtonItem>("btn5", "test5"));
+  ASSERT_EQ(item.GetChildren().size(), 3);
+
+  AbstractItem& child = item.FindByID("btn3");
+  ButtonItem& btn = static_cast<ButtonItem&>(child);
+  ASSERT_EQ(btn.GetTitle(), "test3");
+
+  AbstractItem& child2 = item.FindByID("GROUP3");
+  GroupItem& ret_gr = static_cast<GroupItem&>(child2);
+  ASSERT_EQ(ret_gr.GetChildren().size(), 1);
+}
+
+
+TEST_F(GroupItemTest, IsItemTypeExist) {
+  GroupItem item("GROUP1");
+  shared_ptr<GroupItem> gr2 = shared_ptr<GroupItem>(new GroupItem("GROUP2"));
+  shared_ptr<GroupItem> gr3 = shared_ptr<GroupItem>(new GroupItem("GROUP3"));
+  gr2->AddChild(std::make_shared<ButtonItem>("btn2", "test2"));
+  gr2->AddChild(std::make_shared<ButtonItem>("btn3", "test3"));
+  gr2->AddChild(std::make_shared<ButtonItem>("btn4", "test4"));
+  gr3->AddChild(std::make_shared<ButtonItem>("btn6", "test6"));
+  gr3->AddChild(std::make_shared<TextItem>("text1", "text1"));
+  gr2->AddChild(gr3);
+
+  item.AddChild(std::make_shared<ButtonItem>("btn1", "test1"));
+  item.AddChild(gr2);
+  item.AddChild(std::make_shared<ButtonItem>("btn5", "test5"));
+  ASSERT_EQ(item.GetChildren().size(), 3);
+
+  ASSERT_EQ(item.IsItemTypeExist(AbstractItem::Text), true);
+  ASSERT_EQ(item.IsItemTypeExist(AbstractItem::Image), false);
+}
+
+TEST_F(GroupItemTest, FindByIDNullItemReturn) {
+  GroupItem item("GROUP1");
+  item.AddChild(std::make_shared<ButtonItem>("btn1", "test1"));
+  item.AddChild(std::make_shared<ButtonItem>("btn2", "test2"));
+  ASSERT_EQ(item.GetChildren().size(), 2);
+
+  AbstractItem& child = item.FindByID("not_exist_button");
+  ASSERT_EQ(child.GetType(), AbstractItem::NullObject);
+}
+
+TEST_F(GroupItemTest, GetAppLabel) {
+  app_get_name_fake.custom_fake = __fake_app_get_name;
+
+  GroupItem item("GROUP1");
+  string app_label = item.GetAppLabel();
+
+  ASSERT_EQ(app_label, "unittest_appname");
+}
+
+TEST_F(GroupItemTest, SetAppLabel) {
+  GroupItem item("GROUP1");
+  item.SetAppLabel("test");
+  string app_label = item.GetAppLabel();
+
+  ASSERT_EQ(app_label, "test");
+}
+
+TEST_F(GroupItemTest, SetDirection) {
+  GroupItem item("GROUP1");
+  item.SetDirection(true);
+
+  ASSERT_TRUE(item.IsVertical());
+}
+
+}  // namespace
diff --git a/unittest/src/test_noti_ex_icon_item.cc b/unittest/src/test_noti_ex_icon_item.cc
new file mode 100644 (file)
index 0000000..98ff517
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * 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 <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include "notification-ex/icon_item.h"
+#include "notification-ex/item_inflator.h"
+
+using namespace tizen_base;
+using namespace notification;
+using namespace notification::item;
+
+class IconItemTest : public ::testing::Test {
+ public:
+  IconItem* item;
+  std::string id = "icon_id";
+  virtual void SetUp() {
+    item = new IconItem(id, "icon_path");
+  }
+  virtual void TearDown() {
+    delete item;
+  }
+};
+
+TEST_F(IconItemTest, create) {
+  EXPECT_NE(IconItemTest::item, nullptr);
+}
+
+TEST_F(IconItemTest, FindByID) {
+  AbstractItem& child = IconItemTest::item->FindByID(IconItemTest::id);
+  IconItem& icon = static_cast<IconItem&>(child);
+  ASSERT_EQ(icon.GetImagePath(), "icon_path");
+}
+
+TEST_F(IconItemTest, FindByIDNullItemReturn) {
+  AbstractItem& child = IconItemTest::item->FindByID("not_existed_item");
+  ASSERT_EQ(child.GetType(), IconItem::NullObject);
+}
+
+TEST_F(IconItemTest, SerializeDeserialize) {
+  Bundle b = IconItemTest::item->Serialize();
+
+  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
+  ASSERT_EQ(IconItemTest::item->GetType(), gen_item->GetType());
+
+  auto gen_icon = std::static_pointer_cast<IconItem>(gen_item);
+  ASSERT_EQ(IconItemTest::item->GetImagePath(), gen_icon->GetImagePath());
+}
diff --git a/unittest/src/test_noti_ex_image_item.cc b/unittest/src/test_noti_ex_image_item.cc
new file mode 100644 (file)
index 0000000..66c6786
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * 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 <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include "notification-ex/image_item.h"
+#include "notification-ex/item_inflator.h"
+
+using namespace tizen_base;
+using namespace notification;
+using namespace notification::item;
+
+class ImageItemTest : public ::testing::Test {
+ public:
+  ImageItem* item;
+  std::string id = "image_id";
+  std::string imagePath = "image_path";
+  virtual void SetUp() {
+    item = new ImageItem(id, imagePath);
+  }
+  virtual void TearDown() {
+    delete item;
+  }
+};
+
+TEST_F(ImageItemTest, create) {
+  EXPECT_NE(ImageItemTest::item, nullptr);
+}
+
+TEST_F(ImageItemTest, FindByID) {
+  AbstractItem& child = ImageItemTest::item->FindByID(ImageItemTest::id);
+  ImageItem& image = static_cast<ImageItem&>(child);
+  ASSERT_EQ(image.GetImagePath(), ImageItemTest::imagePath);
+}
+
+TEST_F(ImageItemTest, FindByIDNullItemReturn) {
+  AbstractItem& child = ImageItemTest::item->FindByID("not_existed_item");
+  ASSERT_EQ(child.GetType(), ImageItem::NullObject);
+}
+
+TEST_F(ImageItemTest, SerializeDeserialize) {
+  Bundle b = ImageItemTest::item->Serialize();
+
+  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
+  ASSERT_EQ(ImageItemTest::item->GetType(), gen_item->GetType());
+
+  auto gen_image = std::static_pointer_cast<ImageItem>(gen_item);
+  ASSERT_EQ(ImageItemTest::item->GetImagePath(), gen_image->GetImagePath());
+}
diff --git a/unittest/src/test_noti_ex_input_selector_item.cc b/unittest/src/test_noti_ex_input_selector_item.cc
new file mode 100644 (file)
index 0000000..862cfc5
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * 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 <gmock/gmock.h>
+
+#include "notification-ex/input_selector_item.h"
+#include "notification-ex/item_inflator.h"
+
+using namespace tizen_base;
+using namespace notification;
+using namespace notification::item;
+using namespace std;
+
+namespace {
+
+class InputSelectorItemTest : public ::testing::Test {
+ protected:
+  void SetUp() override {}
+  void TearDown() override {}
+};
+
+TEST_F(InputSelectorItemTest, SerializeDeserialize) {
+  InputSelectorItem item;
+  list<string> contents;
+  contents.push_back("AA");
+  contents.push_back("BB");
+  contents.push_back("CC");
+  item.SetContents(contents);
+
+  Bundle b = item.Serialize();
+  shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
+  ASSERT_EQ(gen_item->GetType(), item.GetType());
+
+  auto gen_input = static_pointer_cast<InputSelectorItem>(gen_item);
+
+  list<string> l1 = item.GetContents();
+  list<string> l2 = gen_input->GetContents();
+  list<string>::iterator it1 = l1.begin();
+  list<string>::iterator it2 = l2.begin();
+  while(it1 != l1.end() && it2 != l2.end()) {
+    ASSERT_EQ((*it1), (*it2));
+    it1++;
+    it2++;
+  }
+}
+
+}  // namespace
diff --git a/unittest/src/test_noti_ex_progress_item.cc b/unittest/src/test_noti_ex_progress_item.cc
new file mode 100644 (file)
index 0000000..3b34c82
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * 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 <gmock/gmock.h>
+
+#include "notification-ex/progress_item.h"
+#include "notification-ex/item_inflator.h"
+
+using namespace tizen_base;
+using namespace notification;
+using namespace notification::item;
+using namespace std;
+
+namespace {
+
+class ProgressItemTest : public ::testing::Test {
+ protected:
+  void SetUp() override {}
+  void TearDown() override {}
+};
+
+TEST_F(ProgressItemTest, SerializeDeserializeGetTitle) {
+  ProgressItem item(1.0, 10.0, 100.0);
+  item.SetDefaultUnit("byte");
+  Bundle b = item.Serialize();
+  shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
+
+  auto gen_progress = std::static_pointer_cast<ProgressItem>(gen_item);
+  ASSERT_EQ(item.GetCurrent(), gen_progress->GetCurrent());
+  ASSERT_EQ(item.GetMin(), gen_progress->GetMin());
+  ASSERT_EQ(item.GetMax(), gen_progress->GetMax());
+  ASSERT_EQ(item.GetType(), gen_progress->GetType());
+  ASSERT_EQ(item.GetDefaultUnit(), gen_progress->GetDefaultUnit());
+
+  ASSERT_EQ(gen_progress->GetMin(), 1.0);
+  ASSERT_EQ(gen_progress->GetCurrent(), 10.0);
+  ASSERT_EQ(gen_progress->GetMax(), 100.0);
+  ASSERT_EQ(gen_progress->GetProgressType(), ProgressItem::Type::Default);
+  ASSERT_EQ(gen_progress->GetDefaultUnit(), "byte");
+}
+
+TEST_F(ProgressItemTest, SetGetProgressType) {
+  ProgressItem item(1.0, 10.0, 100.0);
+
+  ASSERT_EQ(item.GetProgressType(), ProgressItem::Type::Default);
+
+  item.SetProgressType(ProgressItem::Type::Pending);
+  ASSERT_EQ(item.GetProgressType(), ProgressItem::Type::Pending);
+}
+
+TEST_F(ProgressItemTest, SetGetUnit) {
+  ProgressItem item(1.0, 10.0, 100.0);
+  item.SetDefaultUnit("byte");
+
+  ASSERT_EQ(item.GetDefaultUnit(), "byte");
+}
+
+}  // namespace
diff --git a/unittest/src/test_noti_ex_shared_file.cc b/unittest/src/test_noti_ex_shared_file.cc
new file mode 100644 (file)
index 0000000..1a09b7d
--- /dev/null
@@ -0,0 +1,153 @@
+/*
+ * 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 <gtest/gtest.h>
+#include <gmock/gmock.h>
+#include <app_common.h>
+
+#include "notification-ex/shared_file.h"
+#include "notification-ex/image_item.h"
+#include "notification-ex/common.h"
+
+#include "mock/gio_mock.h"
+#include "mock/smack_mock.h"
+#include "mock/tzplatform_config_mock.h"
+#include "mock/security_manager_mock.h"
+
+
+using namespace notification;
+using namespace notification::item;
+using namespace std;
+
+namespace {
+
+GFile* __fake_g_file_new_for_path(const char* path) {
+  GFile* noti_dir = {};
+  return noti_dir;
+}
+
+gboolean __fake_g_file_query_exists(GFile* file, GCancellable* cancellable) {
+  return false;
+}
+
+gboolean __fake_g_file_make_directory(GFile* file, GCancellable* cancellable,
+    GError** error) {
+  return true;
+}
+
+int __fake_access(const char* path, int mode) {
+  return 0;
+}
+
+// smack
+ssize_t __fake_smack_new_label_from_path(const char* path, const char* xattr,
+    int follow, char** label) {
+  *label = strdup("User::Pkg::unittest::RO");
+  return 1;
+}
+
+// tzplatform
+const char* __fake_tzplatform_getenv(tzplatform_variable_e id) {
+  return "/opt/usr/home/owner/apps_rw";
+}
+
+// security-manager
+int __fake_security_manager_private_sharing_req_new(private_sharing_req** pp_req) {
+  return 0;
+}
+
+int __fake_security_manager_private_sharing_req_add_paths(
+    private_sharing_req* p_req, const char** pp_paths, size_t count) {
+  return 0;
+}
+
+int __fake_security_manager_private_sharing_req_set_target_appid(
+    private_sharing_req* p_req, const char* appid) {
+  return 0;
+}
+
+int __fake_security_manager_private_sharing_apply(const private_sharing_req* p_req) {
+  return 0;
+}
+
+int __fake_security_manager_private_sharing_drop(const private_sharing_req* p_req) {
+  return 0;
+}
+
+class SharedFileTest  : public ::testing::Test {
+ public:
+  std::shared_ptr<ImageItem> item;
+  std::string id = "image_id";
+  std::string image_path = "res/image.png";
+
+  SharedFile* shared_file;
+
+  virtual void SetUp() {
+    smack_new_label_from_path_fake.custom_fake = __fake_smack_new_label_from_path;
+    tzplatform_getenv_fake.custom_fake = __fake_tzplatform_getenv;
+    g_file_new_for_path_fake.custom_fake = __fake_g_file_new_for_path;
+    g_file_query_exists_fake.custom_fake = __fake_g_file_query_exists;
+    g_file_make_directory_fake.custom_fake = __fake_g_file_make_directory;
+    access_fake.custom_fake = __fake_access;
+    security_manager_private_sharing_req_new_fake.custom_fake =
+      __fake_security_manager_private_sharing_req_new;
+    security_manager_private_sharing_req_add_paths_fake.custom_fake =
+      __fake_security_manager_private_sharing_req_add_paths;
+    security_manager_private_sharing_req_set_target_appid_fake.custom_fake =
+      __fake_security_manager_private_sharing_req_set_target_appid;
+    security_manager_private_sharing_apply_fake.custom_fake =
+      __fake_security_manager_private_sharing_apply;
+    security_manager_private_sharing_drop_fake.custom_fake =
+      __fake_security_manager_private_sharing_drop;
+
+    item = make_shared<ImageItem>(id, image_path);
+    shared_file = new SharedFile();
+  }
+
+  virtual void TearDown() {
+  }
+};
+
+TEST_F(SharedFileTest, IsPrivatePath) {
+  ASSERT_TRUE(shared_file->IsPrivatePath(SharedFileTest::image_path));
+}
+
+TEST_F(SharedFileTest, GetDataPath) {
+  ASSERT_EQ(shared_file->GetDataPath(item->GetSenderAppId(), SharedFileTest::image_path),
+    "/opt/usr/home/owner/apps_rw/notification-ex_unittests/data/.notification_ex/image.png");
+}
+
+TEST_F(SharedFileTest, SetPrivateSharing) {
+  list<shared_ptr<item::AbstractItem>> notiList;
+  notiList.push_back(SharedFileTest::item);
+
+  std::multimap<std::string, std::string> map_;
+  map_.insert(make_pair("tizen.org/receiver/popup", "test_appid"));
+
+  ASSERT_EQ(shared_file->SetPrivateSharing(notiList, map_), ERROR_NONE);
+}
+
+TEST_F(SharedFileTest, RemovePrivateSharing) {
+  list<shared_ptr<item::AbstractItem>> notiList;
+  notiList.push_back(SharedFileTest::item);
+
+  std::multimap<std::string, std::string> map_;
+  map_.insert(make_pair("tizen.org/receiver/popup", "test_appid"));
+
+  ASSERT_EQ(shared_file->RemovePrivateSharing(notiList, map_), ERROR_NONE);
+}
+
+}  // namespace
diff --git a/unittest/src/test_noti_ex_text_item.cc b/unittest/src/test_noti_ex_text_item.cc
new file mode 100644 (file)
index 0000000..1921567
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * 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 <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include "notification-ex/text_item.h"
+#include "notification-ex/item_inflator.h"
+
+using namespace tizen_base;
+using namespace notification;
+using namespace notification::item;
+
+namespace {
+
+class TexttItemTest : public ::testing::Test {
+ public:
+  virtual void SetUp() {
+  }
+  virtual void TearDown() {
+  }
+};
+
+TEST_F(TexttItemTest, FindByID) {
+  TextItem item("text_id", "contents", "hyperlink");
+
+  AbstractItem& child = item.FindByID("text_id");
+  TextItem& btn = static_cast<TextItem&>(child);
+  ASSERT_EQ(btn.GetContents(), "contents");
+}
+
+TEST_F(TexttItemTest, FindByIDNullItemReturn) {
+  TextItem item("text_id", "contents", "hyperlink");
+
+  AbstractItem& child = item.FindByID("not_existed_item");
+  ASSERT_EQ(child.GetType(), TextItem::NullObject);
+}
+
+TEST_F(TexttItemTest, SerializeDeserializeGetContents) {
+  TextItem item("text_id", "contents");
+  Bundle b = item.Serialize();
+  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
+  ASSERT_EQ(gen_item->GetType(), item.GetType());
+
+  auto gen_text = std::static_pointer_cast<TextItem>(gen_item);
+  ASSERT_EQ(item.GetContents(), gen_text->GetContents());
+}
+
+TEST_F(TexttItemTest, SetContentsGetContents) {
+  TextItem item("text_id", "contents");
+  ASSERT_EQ(item.GetContents(), "contents");
+
+  item.SetContents("changed");
+  ASSERT_EQ(item.GetContents(), "changed");
+}
+
+TEST_F(TexttItemTest, GetHyperLink) {
+  TextItem item("text_id", "contents");
+  ASSERT_TRUE(item.GetHyperLink().empty());
+
+  TextItem item2("text_id", "contents", "hyperlink2");
+  ASSERT_EQ(item2.GetHyperLink(), "hyperlink2");
+}
+
+}  // namespace
\ No newline at end of file
diff --git a/unittest/src/test_noti_ex_time_item.cc b/unittest/src/test_noti_ex_time_item.cc
new file mode 100644 (file)
index 0000000..96e8e74
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * 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 <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include "notification-ex/time_item.h"
+#include "notification-ex/item_inflator.h"
+
+using namespace tizen_base;
+using namespace notification;
+using namespace notification::item;
+
+class TimeItemTest : public ::testing::Test {
+ public:
+  TimeItem* item;
+  time_t current_time;
+  std::string id = "time_id";
+  virtual void SetUp() {
+    time(&current_time);
+    item = new TimeItem(id, current_time);
+  }
+  virtual void TearDown() {
+    delete item;
+  }
+};
+
+TEST_F(TimeItemTest, create) {
+  EXPECT_NE(TimeItemTest::item, nullptr);
+}
+
+TEST_F(TimeItemTest, FindByID) {
+  AbstractItem& child = TimeItemTest::item->FindByID(TimeItemTest::id);
+  TimeItem& time_ = static_cast<TimeItem&>(child);
+  ASSERT_EQ(time_.GetTime(), TimeItemTest::current_time);
+}
+
+TEST_F(TimeItemTest, FindByIDNullItemReturn) {
+  AbstractItem& child = TimeItemTest::item->FindByID("not_existed_item");
+  ASSERT_EQ(child.GetType(), TimeItem::NullObject);
+}
+
+TEST_F(TimeItemTest, SerializeDeserialize) {
+  Bundle b = TimeItemTest::item->Serialize();
+
+  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
+  ASSERT_EQ(TimeItemTest::item->GetType(), gen_item->GetType());
+
+  auto gen_time = std::static_pointer_cast<TimeItem>(gen_item);
+  ASSERT_EQ(item->GetTime(), gen_time->GetTime());
+}
diff --git a/unittest/src/test_noti_ex_visibility_action.cc b/unittest/src/test_noti_ex_visibility_action.cc
new file mode 100644 (file)
index 0000000..e231b36
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * 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 <string>
+
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include "notification-ex/visibility_action.h"
+#include "notification-ex/action_inflator.h"
+
+using namespace tizen_base;
+using namespace notification;
+using namespace notification::item;
+
+class VisibilityActionTest : public ::testing::Test {
+ public:
+  VisibilityAction* visibility;
+  std::string id = "visibility_id";
+  std::string extra = "visibility_extra";
+  bool visible = true;
+
+  virtual void SetUp() {
+    visibility = new VisibilityAction(extra);
+    visibility->SetVisibility("visibility_id", visible);
+  }
+  virtual void TearDown() {
+    delete visibility;
+  }
+};
+
+TEST_F(VisibilityActionTest, create) {
+  EXPECT_NE(VisibilityActionTest::visibility, nullptr);
+}
+
+TEST_F(VisibilityActionTest, IsLocal) {
+  ASSERT_EQ(VisibilityActionTest::visibility->IsLocal(), 1);
+}
+
+TEST_F(VisibilityActionTest, GetExtra) {
+  ASSERT_EQ(VisibilityActionTest::visibility->GetExtra(),
+    VisibilityActionTest::extra);
+}
+
+TEST_F(VisibilityActionTest, SerializeDeserialize) {
+  Bundle b = VisibilityActionTest::visibility->Serialize();
+
+  std::shared_ptr<AbstractAction> gen_action = ActionInflator::Create(b);
+  ASSERT_EQ(gen_action->GetType(), AbstractAction::Visibility);
+
+  auto gen_visibility_action =
+    std::static_pointer_cast<VisibilityAction>(gen_action);
+  EXPECT_NE(gen_visibility_action, nullptr);
+  ASSERT_EQ(gen_visibility_action->IsLocal(), true);
+  ASSERT_EQ(gen_visibility_action->GetExtra(), VisibilityActionTest::extra);
+}
+
+TEST_F(VisibilityActionTest, SetVisibility) {
+  VisibilityActionTest::visibility->SetVisibility("test_id", true);
+  Bundle b = VisibilityActionTest::visibility->Serialize();
+
+  std::shared_ptr<AbstractAction> gen_action = ActionInflator::Create(b);
+  ASSERT_EQ(gen_action->GetType(), AbstractAction::Visibility);
+
+  auto gen_visibility_action =
+    std::static_pointer_cast<VisibilityAction>(gen_action);
+  EXPECT_NE(gen_visibility_action, nullptr);
+  ASSERT_EQ(gen_visibility_action->IsLocal(), true);
+  ASSERT_EQ(gen_visibility_action->GetExtra(), VisibilityActionTest::extra);
+}
diff --git a/unittest/src/test_progress_item.cc b/unittest/src/test_progress_item.cc
deleted file mode 100644 (file)
index 3b34c82..0000000
+++ /dev/null
@@ -1,71 +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 <gmock/gmock.h>
-
-#include "notification-ex/progress_item.h"
-#include "notification-ex/item_inflator.h"
-
-using namespace tizen_base;
-using namespace notification;
-using namespace notification::item;
-using namespace std;
-
-namespace {
-
-class ProgressItemTest : public ::testing::Test {
- protected:
-  void SetUp() override {}
-  void TearDown() override {}
-};
-
-TEST_F(ProgressItemTest, SerializeDeserializeGetTitle) {
-  ProgressItem item(1.0, 10.0, 100.0);
-  item.SetDefaultUnit("byte");
-  Bundle b = item.Serialize();
-  shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
-
-  auto gen_progress = std::static_pointer_cast<ProgressItem>(gen_item);
-  ASSERT_EQ(item.GetCurrent(), gen_progress->GetCurrent());
-  ASSERT_EQ(item.GetMin(), gen_progress->GetMin());
-  ASSERT_EQ(item.GetMax(), gen_progress->GetMax());
-  ASSERT_EQ(item.GetType(), gen_progress->GetType());
-  ASSERT_EQ(item.GetDefaultUnit(), gen_progress->GetDefaultUnit());
-
-  ASSERT_EQ(gen_progress->GetMin(), 1.0);
-  ASSERT_EQ(gen_progress->GetCurrent(), 10.0);
-  ASSERT_EQ(gen_progress->GetMax(), 100.0);
-  ASSERT_EQ(gen_progress->GetProgressType(), ProgressItem::Type::Default);
-  ASSERT_EQ(gen_progress->GetDefaultUnit(), "byte");
-}
-
-TEST_F(ProgressItemTest, SetGetProgressType) {
-  ProgressItem item(1.0, 10.0, 100.0);
-
-  ASSERT_EQ(item.GetProgressType(), ProgressItem::Type::Default);
-
-  item.SetProgressType(ProgressItem::Type::Pending);
-  ASSERT_EQ(item.GetProgressType(), ProgressItem::Type::Pending);
-}
-
-TEST_F(ProgressItemTest, SetGetUnit) {
-  ProgressItem item(1.0, 10.0, 100.0);
-  item.SetDefaultUnit("byte");
-
-  ASSERT_EQ(item.GetDefaultUnit(), "byte");
-}
-
-}  // namespace
diff --git a/unittest/src/test_shared_file.cc b/unittest/src/test_shared_file.cc
deleted file mode 100755 (executable)
index 1a09b7d..0000000
+++ /dev/null
@@ -1,153 +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 <gtest/gtest.h>
-#include <gmock/gmock.h>
-#include <app_common.h>
-
-#include "notification-ex/shared_file.h"
-#include "notification-ex/image_item.h"
-#include "notification-ex/common.h"
-
-#include "mock/gio_mock.h"
-#include "mock/smack_mock.h"
-#include "mock/tzplatform_config_mock.h"
-#include "mock/security_manager_mock.h"
-
-
-using namespace notification;
-using namespace notification::item;
-using namespace std;
-
-namespace {
-
-GFile* __fake_g_file_new_for_path(const char* path) {
-  GFile* noti_dir = {};
-  return noti_dir;
-}
-
-gboolean __fake_g_file_query_exists(GFile* file, GCancellable* cancellable) {
-  return false;
-}
-
-gboolean __fake_g_file_make_directory(GFile* file, GCancellable* cancellable,
-    GError** error) {
-  return true;
-}
-
-int __fake_access(const char* path, int mode) {
-  return 0;
-}
-
-// smack
-ssize_t __fake_smack_new_label_from_path(const char* path, const char* xattr,
-    int follow, char** label) {
-  *label = strdup("User::Pkg::unittest::RO");
-  return 1;
-}
-
-// tzplatform
-const char* __fake_tzplatform_getenv(tzplatform_variable_e id) {
-  return "/opt/usr/home/owner/apps_rw";
-}
-
-// security-manager
-int __fake_security_manager_private_sharing_req_new(private_sharing_req** pp_req) {
-  return 0;
-}
-
-int __fake_security_manager_private_sharing_req_add_paths(
-    private_sharing_req* p_req, const char** pp_paths, size_t count) {
-  return 0;
-}
-
-int __fake_security_manager_private_sharing_req_set_target_appid(
-    private_sharing_req* p_req, const char* appid) {
-  return 0;
-}
-
-int __fake_security_manager_private_sharing_apply(const private_sharing_req* p_req) {
-  return 0;
-}
-
-int __fake_security_manager_private_sharing_drop(const private_sharing_req* p_req) {
-  return 0;
-}
-
-class SharedFileTest  : public ::testing::Test {
- public:
-  std::shared_ptr<ImageItem> item;
-  std::string id = "image_id";
-  std::string image_path = "res/image.png";
-
-  SharedFile* shared_file;
-
-  virtual void SetUp() {
-    smack_new_label_from_path_fake.custom_fake = __fake_smack_new_label_from_path;
-    tzplatform_getenv_fake.custom_fake = __fake_tzplatform_getenv;
-    g_file_new_for_path_fake.custom_fake = __fake_g_file_new_for_path;
-    g_file_query_exists_fake.custom_fake = __fake_g_file_query_exists;
-    g_file_make_directory_fake.custom_fake = __fake_g_file_make_directory;
-    access_fake.custom_fake = __fake_access;
-    security_manager_private_sharing_req_new_fake.custom_fake =
-      __fake_security_manager_private_sharing_req_new;
-    security_manager_private_sharing_req_add_paths_fake.custom_fake =
-      __fake_security_manager_private_sharing_req_add_paths;
-    security_manager_private_sharing_req_set_target_appid_fake.custom_fake =
-      __fake_security_manager_private_sharing_req_set_target_appid;
-    security_manager_private_sharing_apply_fake.custom_fake =
-      __fake_security_manager_private_sharing_apply;
-    security_manager_private_sharing_drop_fake.custom_fake =
-      __fake_security_manager_private_sharing_drop;
-
-    item = make_shared<ImageItem>(id, image_path);
-    shared_file = new SharedFile();
-  }
-
-  virtual void TearDown() {
-  }
-};
-
-TEST_F(SharedFileTest, IsPrivatePath) {
-  ASSERT_TRUE(shared_file->IsPrivatePath(SharedFileTest::image_path));
-}
-
-TEST_F(SharedFileTest, GetDataPath) {
-  ASSERT_EQ(shared_file->GetDataPath(item->GetSenderAppId(), SharedFileTest::image_path),
-    "/opt/usr/home/owner/apps_rw/notification-ex_unittests/data/.notification_ex/image.png");
-}
-
-TEST_F(SharedFileTest, SetPrivateSharing) {
-  list<shared_ptr<item::AbstractItem>> notiList;
-  notiList.push_back(SharedFileTest::item);
-
-  std::multimap<std::string, std::string> map_;
-  map_.insert(make_pair("tizen.org/receiver/popup", "test_appid"));
-
-  ASSERT_EQ(shared_file->SetPrivateSharing(notiList, map_), ERROR_NONE);
-}
-
-TEST_F(SharedFileTest, RemovePrivateSharing) {
-  list<shared_ptr<item::AbstractItem>> notiList;
-  notiList.push_back(SharedFileTest::item);
-
-  std::multimap<std::string, std::string> map_;
-  map_.insert(make_pair("tizen.org/receiver/popup", "test_appid"));
-
-  ASSERT_EQ(shared_file->RemovePrivateSharing(notiList, map_), ERROR_NONE);
-}
-
-}  // namespace
diff --git a/unittest/src/test_text_item.cc b/unittest/src/test_text_item.cc
deleted file mode 100644 (file)
index 1921567..0000000
+++ /dev/null
@@ -1,78 +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 <gtest/gtest.h>
-#include <gmock/gmock.h>
-
-#include "notification-ex/text_item.h"
-#include "notification-ex/item_inflator.h"
-
-using namespace tizen_base;
-using namespace notification;
-using namespace notification::item;
-
-namespace {
-
-class TexttItemTest : public ::testing::Test {
- public:
-  virtual void SetUp() {
-  }
-  virtual void TearDown() {
-  }
-};
-
-TEST_F(TexttItemTest, FindByID) {
-  TextItem item("text_id", "contents", "hyperlink");
-
-  AbstractItem& child = item.FindByID("text_id");
-  TextItem& btn = static_cast<TextItem&>(child);
-  ASSERT_EQ(btn.GetContents(), "contents");
-}
-
-TEST_F(TexttItemTest, FindByIDNullItemReturn) {
-  TextItem item("text_id", "contents", "hyperlink");
-
-  AbstractItem& child = item.FindByID("not_existed_item");
-  ASSERT_EQ(child.GetType(), TextItem::NullObject);
-}
-
-TEST_F(TexttItemTest, SerializeDeserializeGetContents) {
-  TextItem item("text_id", "contents");
-  Bundle b = item.Serialize();
-  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
-  ASSERT_EQ(gen_item->GetType(), item.GetType());
-
-  auto gen_text = std::static_pointer_cast<TextItem>(gen_item);
-  ASSERT_EQ(item.GetContents(), gen_text->GetContents());
-}
-
-TEST_F(TexttItemTest, SetContentsGetContents) {
-  TextItem item("text_id", "contents");
-  ASSERT_EQ(item.GetContents(), "contents");
-
-  item.SetContents("changed");
-  ASSERT_EQ(item.GetContents(), "changed");
-}
-
-TEST_F(TexttItemTest, GetHyperLink) {
-  TextItem item("text_id", "contents");
-  ASSERT_TRUE(item.GetHyperLink().empty());
-
-  TextItem item2("text_id", "contents", "hyperlink2");
-  ASSERT_EQ(item2.GetHyperLink(), "hyperlink2");
-}
-
-}  // namespace
\ No newline at end of file
diff --git a/unittest/src/test_time_item.cc b/unittest/src/test_time_item.cc
deleted file mode 100644 (file)
index 96e8e74..0000000
+++ /dev/null
@@ -1,64 +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 <gtest/gtest.h>
-#include <gmock/gmock.h>
-
-#include "notification-ex/time_item.h"
-#include "notification-ex/item_inflator.h"
-
-using namespace tizen_base;
-using namespace notification;
-using namespace notification::item;
-
-class TimeItemTest : public ::testing::Test {
- public:
-  TimeItem* item;
-  time_t current_time;
-  std::string id = "time_id";
-  virtual void SetUp() {
-    time(&current_time);
-    item = new TimeItem(id, current_time);
-  }
-  virtual void TearDown() {
-    delete item;
-  }
-};
-
-TEST_F(TimeItemTest, create) {
-  EXPECT_NE(TimeItemTest::item, nullptr);
-}
-
-TEST_F(TimeItemTest, FindByID) {
-  AbstractItem& child = TimeItemTest::item->FindByID(TimeItemTest::id);
-  TimeItem& time_ = static_cast<TimeItem&>(child);
-  ASSERT_EQ(time_.GetTime(), TimeItemTest::current_time);
-}
-
-TEST_F(TimeItemTest, FindByIDNullItemReturn) {
-  AbstractItem& child = TimeItemTest::item->FindByID("not_existed_item");
-  ASSERT_EQ(child.GetType(), TimeItem::NullObject);
-}
-
-TEST_F(TimeItemTest, SerializeDeserialize) {
-  Bundle b = TimeItemTest::item->Serialize();
-
-  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
-  ASSERT_EQ(TimeItemTest::item->GetType(), gen_item->GetType());
-
-  auto gen_time = std::static_pointer_cast<TimeItem>(gen_item);
-  ASSERT_EQ(item->GetTime(), gen_time->GetTime());
-}
diff --git a/unittest/src/test_visibility_action.cc b/unittest/src/test_visibility_action.cc
deleted file mode 100644 (file)
index e231b36..0000000
+++ /dev/null
@@ -1,83 +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 <string>
-
-#include <gtest/gtest.h>
-#include <gmock/gmock.h>
-
-#include "notification-ex/visibility_action.h"
-#include "notification-ex/action_inflator.h"
-
-using namespace tizen_base;
-using namespace notification;
-using namespace notification::item;
-
-class VisibilityActionTest : public ::testing::Test {
- public:
-  VisibilityAction* visibility;
-  std::string id = "visibility_id";
-  std::string extra = "visibility_extra";
-  bool visible = true;
-
-  virtual void SetUp() {
-    visibility = new VisibilityAction(extra);
-    visibility->SetVisibility("visibility_id", visible);
-  }
-  virtual void TearDown() {
-    delete visibility;
-  }
-};
-
-TEST_F(VisibilityActionTest, create) {
-  EXPECT_NE(VisibilityActionTest::visibility, nullptr);
-}
-
-TEST_F(VisibilityActionTest, IsLocal) {
-  ASSERT_EQ(VisibilityActionTest::visibility->IsLocal(), 1);
-}
-
-TEST_F(VisibilityActionTest, GetExtra) {
-  ASSERT_EQ(VisibilityActionTest::visibility->GetExtra(),
-    VisibilityActionTest::extra);
-}
-
-TEST_F(VisibilityActionTest, SerializeDeserialize) {
-  Bundle b = VisibilityActionTest::visibility->Serialize();
-
-  std::shared_ptr<AbstractAction> gen_action = ActionInflator::Create(b);
-  ASSERT_EQ(gen_action->GetType(), AbstractAction::Visibility);
-
-  auto gen_visibility_action =
-    std::static_pointer_cast<VisibilityAction>(gen_action);
-  EXPECT_NE(gen_visibility_action, nullptr);
-  ASSERT_EQ(gen_visibility_action->IsLocal(), true);
-  ASSERT_EQ(gen_visibility_action->GetExtra(), VisibilityActionTest::extra);
-}
-
-TEST_F(VisibilityActionTest, SetVisibility) {
-  VisibilityActionTest::visibility->SetVisibility("test_id", true);
-  Bundle b = VisibilityActionTest::visibility->Serialize();
-
-  std::shared_ptr<AbstractAction> gen_action = ActionInflator::Create(b);
-  ASSERT_EQ(gen_action->GetType(), AbstractAction::Visibility);
-
-  auto gen_visibility_action =
-    std::static_pointer_cast<VisibilityAction>(gen_action);
-  EXPECT_NE(gen_visibility_action, nullptr);
-  ASSERT_EQ(gen_visibility_action->IsLocal(), true);
-  ASSERT_EQ(gen_visibility_action->GetExtra(), VisibilityActionTest::extra);
-}