From: hyunho Date: Tue, 2 Jul 2019 10:27:20 +0000 (+0900) Subject: Add is_type_exist function to an abstract item X-Git-Tag: submit/tizen/20190709.093200~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3d9da95ccf375b18a245c421574f9a2e62989c2f;p=platform%2Fcore%2Fapi%2Fnotification.git Add is_type_exist function to an abstract item Change-Id: I492fad061a0d804906cd4fb008e5a81c62fd3bb1 Signed-off-by: hyunho --- diff --git a/notification-ex/abstract_item.h b/notification-ex/abstract_item.h index ccb9d624..4a9f3b7e 100644 --- a/notification-ex/abstract_item.h +++ b/notification-ex/abstract_item.h @@ -775,6 +775,14 @@ class EXPORT_API AbstractItem { */ virtual AbstractItem& FindByID(std::string id) = 0; + /** + * @brief Checks the item type exist in this notification. + * @since_tizen 5.5 + * @param[in] type notification item type + * @return true if the item type exists + */ + virtual bool IsItemTypeExist(int type) = 0; + /** * @brief Gets the type of notification item. * @since_tizen 5.5 diff --git a/notification-ex/button_item.cc b/notification-ex/button_item.cc index 0c862abc..1535914b 100644 --- a/notification-ex/button_item.cc +++ b/notification-ex/button_item.cc @@ -72,6 +72,12 @@ AbstractItem& ButtonItem::FindByID(std::string id) { return FactoryManager::GetInst().GetNullItem(); } +bool ButtonItem::IsItemTypeExist(int type) { + if (GetType() == type) + return true; + return false; +} + std::string ButtonItem::GetTitle() const { return impl_->title_; } diff --git a/notification-ex/button_item.h b/notification-ex/button_item.h index 4e11722a..d489208f 100644 --- a/notification-ex/button_item.h +++ b/notification-ex/button_item.h @@ -82,6 +82,14 @@ class EXPORT_API ButtonItem : public AbstractItem { */ AbstractItem& FindByID(std::string id) override; + /** + * @brief Checks the item type exist in this notification. + * @since_tizen 5.5 + * @param[in] type notification item type + * @return true if the item type exists + */ + bool IsItemTypeExist(int type) override; + /** * @brief Gets the type of ButtonItem. * @since_tizen 5.5 diff --git a/notification-ex/chat_message_item.cc b/notification-ex/chat_message_item.cc index ae02fd7e..bad7938f 100644 --- a/notification-ex/chat_message_item.cc +++ b/notification-ex/chat_message_item.cc @@ -131,6 +131,12 @@ AbstractItem& ChatMessageItem::FindByID(std::string id) { return FactoryManager::GetInst().GetNullItem(); } +bool ChatMessageItem::IsItemTypeExist(int type) { + if (GetType() == type) + return true; + return false; +} + TextItem& ChatMessageItem::GetNameItem() const { return *(impl_->name_); } diff --git a/notification-ex/chat_message_item.h b/notification-ex/chat_message_item.h index bae99b75..95f4c9cd 100644 --- a/notification-ex/chat_message_item.h +++ b/notification-ex/chat_message_item.h @@ -95,6 +95,14 @@ class EXPORT_API ChatMessageItem : public AbstractItem { */ AbstractItem& FindByID(std::string id) override; + /** + * @brief Checks the item type exist in this notification. + * @since_tizen 5.5 + * @param[in] type notification item type + * @return true if the item type exists + */ + bool IsItemTypeExist(int type) override; + /** * @brief Gets the path of shared file location. * @since_tizen 5.5 diff --git a/notification-ex/checkbox_item.cc b/notification-ex/checkbox_item.cc index ed5e99a6..a67dce09 100644 --- a/notification-ex/checkbox_item.cc +++ b/notification-ex/checkbox_item.cc @@ -70,6 +70,12 @@ AbstractItem& CheckBoxItem::FindByID(std::string id) { return FactoryManager::GetInst().GetNullItem(); } +bool CheckBoxItem::IsItemTypeExist(int type) { + if (GetType() == type) + return true; + return false; +} + std::string CheckBoxItem::GetTitle(void) const { return impl_->title_; } diff --git a/notification-ex/checkbox_item.h b/notification-ex/checkbox_item.h index fa1d20a2..b59fa044 100644 --- a/notification-ex/checkbox_item.h +++ b/notification-ex/checkbox_item.h @@ -72,6 +72,14 @@ class EXPORT_API CheckBoxItem : public AbstractItem { */ AbstractItem& FindByID(std::string id) override; + /** + * @brief Checks the item type exist in this notification. + * @since_tizen 5.5 + * @param[in] type notification item type + * @return true if the item type exists + */ + bool IsItemTypeExist(int type) override; + /** * @brief Gets the type of CheckBoxItem. * @since_tizen 5.5 diff --git a/notification-ex/entry_item.cc b/notification-ex/entry_item.cc index 9b0bdc6b..de242cbf 100644 --- a/notification-ex/entry_item.cc +++ b/notification-ex/entry_item.cc @@ -77,6 +77,12 @@ AbstractItem& EntryItem::FindByID(std::string id) { return FactoryManager::GetInst().GetNullItem(); } +bool EntryItem::IsItemTypeExist(int type) { + if (GetType() == type) + return true; + return false; +} + std::string EntryItem::GetText() const { return impl_->text_; } diff --git a/notification-ex/entry_item.h b/notification-ex/entry_item.h index 6bc04a38..23bb4002 100644 --- a/notification-ex/entry_item.h +++ b/notification-ex/entry_item.h @@ -80,6 +80,14 @@ class EXPORT_API EntryItem : public AbstractItem { */ AbstractItem& FindByID(std::string id) override; + /** + * @brief Checks the item type exist in this notification. + * @since_tizen 5.5 + * @param[in] type notification item type + * @return true if the item type exists + */ + bool IsItemTypeExist(int type) override; + /** * @brief Gets the type of EntryItem. * @since_tizen 5.5 diff --git a/notification-ex/group_item.cc b/notification-ex/group_item.cc index 4ead0d96..dbe1b2fa 100644 --- a/notification-ex/group_item.cc +++ b/notification-ex/group_item.cc @@ -118,6 +118,17 @@ AbstractItem& GroupItem::FindByID(std::string id) { return FactoryManager::GetInst().GetNullItem(); } +bool GroupItem::IsItemTypeExist(int type) { + if (GetType() == type) + return true; + + for (auto& i : impl_->children_list_) { + if (i.get()->IsItemTypeExist(type)) + return true; + } + return false; +} + list GroupItem::GetSharedPath() const { list ret; diff --git a/notification-ex/group_item.h b/notification-ex/group_item.h index fe93cd05..5b349790 100644 --- a/notification-ex/group_item.h +++ b/notification-ex/group_item.h @@ -78,6 +78,14 @@ class EXPORT_API GroupItem : public AbstractItem { */ AbstractItem& FindByID(std::string id) override; + /** + * @brief Checks the item type exist in this notification. + * @since_tizen 5.5 + * @param[in] type notification item type + * @return true if the item type exists + */ + bool IsItemTypeExist(int type) override; + /** * @brief Gets the type of GroupItem. * @since_tizen 5.5 diff --git a/notification-ex/icon_text_item.cc b/notification-ex/icon_text_item.cc index 9718d4ee..9173c407 100644 --- a/notification-ex/icon_text_item.cc +++ b/notification-ex/icon_text_item.cc @@ -79,6 +79,12 @@ AbstractItem& IconTextItem::FindByID(std::string id) { return FactoryManager::GetInst().GetNullItem(); } +bool IconTextItem::IsItemTypeExist(int type) { + if (GetType() == type) + return true; + return false; +} + IconItem& IconTextItem::GetIconItem() const { return *(impl_->icon_); } diff --git a/notification-ex/icon_text_item.h b/notification-ex/icon_text_item.h index 9225ad9d..afe61974 100644 --- a/notification-ex/icon_text_item.h +++ b/notification-ex/icon_text_item.h @@ -75,6 +75,14 @@ class EXPORT_API IconTextItem : public AbstractItem { */ AbstractItem& FindByID(std::string id) override; + /** + * @brief Checks the item type exist in this notification. + * @since_tizen 5.5 + * @param[in] type notification item type + * @return true if the item type exists + */ + bool IsItemTypeExist(int type) override; + /** * @brief Gets the type of IconTextItem. * @since_tizen 5.5 diff --git a/notification-ex/image_item.cc b/notification-ex/image_item.cc index 07fd987d..21689f3c 100644 --- a/notification-ex/image_item.cc +++ b/notification-ex/image_item.cc @@ -70,6 +70,12 @@ AbstractItem& ImageItem::FindByID(std::string id) { return FactoryManager::GetInst().GetNullItem(); } +bool ImageItem::IsItemTypeExist(int type) { + if (GetType() == type) + return true; + return false; +} + std::string ImageItem::GetImagePath() const { return impl_->image_path_; } diff --git a/notification-ex/image_item.h b/notification-ex/image_item.h index 0ac43e31..3e7a9e82 100644 --- a/notification-ex/image_item.h +++ b/notification-ex/image_item.h @@ -87,6 +87,14 @@ class EXPORT_API ImageItem : public AbstractItem { */ AbstractItem& FindByID(std::string id) override; + /** + * @brief Checks the item type exist in this notification. + * @since_tizen 5.5 + * @param[in] type notification item type + * @return true if the item type exists + */ + bool IsItemTypeExist(int type) override; + /** * @brief Gets the path of image. * @since_tizen 5.5 diff --git a/notification-ex/input_selector_item.cc b/notification-ex/input_selector_item.cc index f8ea9265..2aaa1f52 100644 --- a/notification-ex/input_selector_item.cc +++ b/notification-ex/input_selector_item.cc @@ -78,6 +78,12 @@ AbstractItem& InputSelectorItem::FindByID(std::string id) { return FactoryManager::GetInst().GetNullItem(); } +bool InputSelectorItem::IsItemTypeExist(int type) { + if (GetType() == type) + return true; + return false; +} + list InputSelectorItem::GetContents() const { return impl_->contents_; } diff --git a/notification-ex/input_selector_item.h b/notification-ex/input_selector_item.h index f769be9c..90c673c7 100644 --- a/notification-ex/input_selector_item.h +++ b/notification-ex/input_selector_item.h @@ -78,6 +78,14 @@ class EXPORT_API InputSelectorItem : public AbstractItem { */ virtual AbstractItem& FindByID(std::string id) override; + /** + * @brief Checks the item type exist in this notification. + * @since_tizen 5.5 + * @param[in] type notification item type + * @return true if the item type exists + */ + bool IsItemTypeExist(int type) override; + /** * @brief Gets the type of InputSelectorItem. * @since_tizen 5.5 diff --git a/notification-ex/null_item.cc b/notification-ex/null_item.cc index 3c0f7f8c..0c3e867c 100644 --- a/notification-ex/null_item.cc +++ b/notification-ex/null_item.cc @@ -58,5 +58,11 @@ AbstractItem& NullItem::FindByID(std::string id) { return *this; } +bool NullItem::IsItemTypeExist(int type) { + if (GetType() == type) + return true; + return false; +} + } // namespace item } // namespace notification diff --git a/notification-ex/null_item.h b/notification-ex/null_item.h index fe5927b4..75b0421e 100644 --- a/notification-ex/null_item.h +++ b/notification-ex/null_item.h @@ -76,6 +76,14 @@ class EXPORT_API NullItem : public AbstractItem { */ void Deserialize(Bundle b) override; + /** + * @brief Checks the item type exist in this notification. + * @since_tizen 5.5 + * @param[in] type notification item type + * @return true if the item type exists + */ + bool IsItemTypeExist(int type) override; + /** * @brief Finds the AbstractItem using by notification item id. * @since_tizen 5.5 diff --git a/notification-ex/progress_item.cc b/notification-ex/progress_item.cc index 3a0c6b2d..c06d0ed2 100644 --- a/notification-ex/progress_item.cc +++ b/notification-ex/progress_item.cc @@ -93,6 +93,12 @@ AbstractItem& ProgressItem::FindByID(std::string id) { return FactoryManager::GetInst().GetNullItem(); } +bool ProgressItem::IsItemTypeExist(int type) { + if (GetType() == type) + return true; + return false; +} + float ProgressItem::GetCurrent() const { return impl_->current_; } diff --git a/notification-ex/progress_item.h b/notification-ex/progress_item.h index 8aefcc68..a83e6d04 100644 --- a/notification-ex/progress_item.h +++ b/notification-ex/progress_item.h @@ -92,6 +92,14 @@ class EXPORT_API ProgressItem : public AbstractItem { */ virtual AbstractItem& FindByID(std::string id) override; + /** + * @brief Checks the item type exist in this notification. + * @since_tizen 5.5 + * @param[in] type notification item type + * @return true if the item type exists + */ + bool IsItemTypeExist(int type) override; + /** * @brief Gets the type of ProgressItem. * @since_tizen 5.5 diff --git a/notification-ex/text_item.cc b/notification-ex/text_item.cc index 075df87f..01fe1d27 100644 --- a/notification-ex/text_item.cc +++ b/notification-ex/text_item.cc @@ -74,6 +74,12 @@ AbstractItem& TextItem::FindByID(std::string id) { return FactoryManager::GetInst().GetNullItem(); } +bool TextItem::IsItemTypeExist(int type) { + if (GetType() == type) + return true; + return false; +} + void TextItem::SetContents(std::string contents) { impl_->text_ = contents; } diff --git a/notification-ex/text_item.h b/notification-ex/text_item.h index 4ac8731a..8f1681e4 100644 --- a/notification-ex/text_item.h +++ b/notification-ex/text_item.h @@ -84,6 +84,14 @@ class EXPORT_API TextItem : public AbstractItem { */ AbstractItem& FindByID(std::string id) override; + /** + * @brief Checks the item type exist in this notification. + * @since_tizen 5.5 + * @param[in] type notification item type + * @return true if the item type exists + */ + bool IsItemTypeExist(int type) override; + /** * @brief Sets the contents of TextItem. * @since_tizen 5.5 diff --git a/notification-ex/time_item.cc b/notification-ex/time_item.cc index 719eb502..e22d543b 100644 --- a/notification-ex/time_item.cc +++ b/notification-ex/time_item.cc @@ -93,6 +93,12 @@ AbstractItem& TimeItem::FindByID(std::string id) { return FactoryManager::GetInst().GetNullItem(); } +bool TimeItem::IsItemTypeExist(int type) { + if (GetType() == type) + return true; + return false; +} + time_t TimeItem::GetTime() const { return impl_->time_; } diff --git a/notification-ex/time_item.h b/notification-ex/time_item.h index 4291344c..afbcc781 100644 --- a/notification-ex/time_item.h +++ b/notification-ex/time_item.h @@ -97,6 +97,14 @@ class EXPORT_API TimeItem : public AbstractItem { */ AbstractItem& FindByID(std::string id) override; + /** + * @brief Checks the item type exist in this notification. + * @since_tizen 5.5 + * @param[in] type notification item type + * @return true if the item type exists + */ + bool IsItemTypeExist(int type) override; + /** * @brief Gets the time state of TimeItem. * @since_tizen 5.5 diff --git a/unittest/src/test_abstract_item.cc b/unittest/src/test_abstract_item.cc index 784b8df6..3a205c34 100644 --- a/unittest/src/test_abstract_item.cc +++ b/unittest/src/test_abstract_item.cc @@ -52,6 +52,11 @@ class TestItem : public AbstractItem { 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; } diff --git a/unittest/src/test_group_item.cc b/unittest/src/test_group_item.cc index 1e6817cd..ee54af97 100644 --- a/unittest/src/test_group_item.cc +++ b/unittest/src/test_group_item.cc @@ -6,6 +6,7 @@ #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 "unittest/mock/app_common.h" @@ -99,6 +100,27 @@ TEST_F(GroupItemTest, FindByIDGroupItem) { ASSERT_EQ(ret_gr.GetChildren().size(), 1); } + +TEST_F(GroupItemTest, IsItemTypeExist) { + GroupItem item("GROUP1"); + shared_ptr gr2 = shared_ptr(new GroupItem("GROUP2")); + shared_ptr gr3 = shared_ptr(new GroupItem("GROUP3")); + gr2->AddChild(std::make_shared("btn2", "test2")); + gr2->AddChild(std::make_shared("btn3", "test3")); + gr2->AddChild(std::make_shared("btn4", "test4")); + gr3->AddChild(std::make_shared("btn6", "test6")); + gr3->AddChild(std::make_shared("text1", "text1")); + gr2->AddChild(gr3); + + item.AddChild(std::make_shared("btn1", "test1")); + item.AddChild(gr2); + item.AddChild(std::make_shared("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("btn1", "test1"));