diff options
27 files changed, 208 insertions, 0 deletions
diff --git a/notification-ex/abstract_item.h b/notification-ex/abstract_item.h index ccb9d62..4a9f3b7 100644 --- a/notification-ex/abstract_item.h +++ b/notification-ex/abstract_item.h @@ -776,6 +776,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 * @return The type of notification item diff --git a/notification-ex/button_item.cc b/notification-ex/button_item.cc index 0c862ab..1535914 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 4e11722..d489208 100644 --- a/notification-ex/button_item.h +++ b/notification-ex/button_item.h @@ -83,6 +83,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 * @return AbstractItem::Type::Button diff --git a/notification-ex/chat_message_item.cc b/notification-ex/chat_message_item.cc index ae02fd7..bad7938 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 bae99b7..95f4c9c 100644 --- a/notification-ex/chat_message_item.h +++ b/notification-ex/chat_message_item.h @@ -96,6 +96,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 * @return The list of shared path. diff --git a/notification-ex/checkbox_item.cc b/notification-ex/checkbox_item.cc index ed5e99a..a67dce0 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 fa1d20a..b59fa04 100644 --- a/notification-ex/checkbox_item.h +++ b/notification-ex/checkbox_item.h @@ -73,6 +73,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 * @return AbstractItem::Type::CheckBox diff --git a/notification-ex/entry_item.cc b/notification-ex/entry_item.cc index 9b0bdc6..de242cb 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 6bc04a3..23bb400 100644 --- a/notification-ex/entry_item.h +++ b/notification-ex/entry_item.h @@ -81,6 +81,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 * @return AbstractItem::Type::Entry diff --git a/notification-ex/group_item.cc b/notification-ex/group_item.cc index 4ead0d9..dbe1b2f 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<string> GroupItem::GetSharedPath() const { list<string> ret; diff --git a/notification-ex/group_item.h b/notification-ex/group_item.h index fe93cd0..5b34979 100644 --- a/notification-ex/group_item.h +++ b/notification-ex/group_item.h @@ -79,6 +79,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 * @return AbstractItem::Type::Group diff --git a/notification-ex/icon_text_item.cc b/notification-ex/icon_text_item.cc index 9718d4e..9173c40 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 9225ad9..afe6197 100644 --- a/notification-ex/icon_text_item.h +++ b/notification-ex/icon_text_item.h @@ -76,6 +76,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 * @return AbstractItem::Type::IconText diff --git a/notification-ex/image_item.cc b/notification-ex/image_item.cc index 07fd987..21689f3 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 0ac43e3..3e7a9e8 100644 --- a/notification-ex/image_item.h +++ b/notification-ex/image_item.h @@ -88,6 +88,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 * @return The path of image diff --git a/notification-ex/input_selector_item.cc b/notification-ex/input_selector_item.cc index f8ea926..2aaa1f5 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<string> InputSelectorItem::GetContents() const { return impl_->contents_; } diff --git a/notification-ex/input_selector_item.h b/notification-ex/input_selector_item.h index f769be9..90c673c 100644 --- a/notification-ex/input_selector_item.h +++ b/notification-ex/input_selector_item.h @@ -79,6 +79,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 * @return AbstractItem::Type::InputSelector diff --git a/notification-ex/null_item.cc b/notification-ex/null_item.cc index 3c0f7f8..0c3e867 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 fe5927b..75b0421 100644 --- a/notification-ex/null_item.h +++ b/notification-ex/null_item.h @@ -77,6 +77,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 * @param[in] id notification item id diff --git a/notification-ex/progress_item.cc b/notification-ex/progress_item.cc index 3a0c6b2..c06d0ed 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 8aefcc6..a83e6d0 100644 --- a/notification-ex/progress_item.h +++ b/notification-ex/progress_item.h @@ -93,6 +93,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 * @return AbstractItem::Type::Progress diff --git a/notification-ex/text_item.cc b/notification-ex/text_item.cc index 075df87..01fe1d2 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 4ac8731..8f1681e 100644 --- a/notification-ex/text_item.h +++ b/notification-ex/text_item.h @@ -85,6 +85,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 * @return The text contents diff --git a/notification-ex/time_item.cc b/notification-ex/time_item.cc index 719eb50..e22d543 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 4291344..afbcc78 100644 --- a/notification-ex/time_item.h +++ b/notification-ex/time_item.h @@ -98,6 +98,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 * @return The time state of TimeItem. diff --git a/unittest/src/test_abstract_item.cc b/unittest/src/test_abstract_item.cc index 784b8df..3a205c3 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 1e6817c..ee54af9 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<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")); |