Add is_type_exist function to an abstract item 25/209125/4
authorhyunho <hhstark.kang@samsung.com>
Tue, 2 Jul 2019 10:27:20 +0000 (19:27 +0900)
committerhyunho <hhstark.kang@samsung.com>
Wed, 3 Jul 2019 04:26:06 +0000 (13:26 +0900)
Change-Id: I492fad061a0d804906cd4fb008e5a81c62fd3bb1
Signed-off-by: hyunho <hhstark.kang@samsung.com>
27 files changed:
notification-ex/abstract_item.h
notification-ex/button_item.cc
notification-ex/button_item.h
notification-ex/chat_message_item.cc
notification-ex/chat_message_item.h
notification-ex/checkbox_item.cc
notification-ex/checkbox_item.h
notification-ex/entry_item.cc
notification-ex/entry_item.h
notification-ex/group_item.cc
notification-ex/group_item.h
notification-ex/icon_text_item.cc
notification-ex/icon_text_item.h
notification-ex/image_item.cc
notification-ex/image_item.h
notification-ex/input_selector_item.cc
notification-ex/input_selector_item.h
notification-ex/null_item.cc
notification-ex/null_item.h
notification-ex/progress_item.cc
notification-ex/progress_item.h
notification-ex/text_item.cc
notification-ex/text_item.h
notification-ex/time_item.cc
notification-ex/time_item.h
unittest/src/test_abstract_item.cc
unittest/src/test_group_item.cc

index ccb9d62417d1baa716b79ed49dd2c489886907f9..4a9f3b7e2d6880a58d07c5df054c89acc1fce232 100644 (file)
@@ -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
index 0c862abc715d35c8a5fa2ed59ff221c00f01d945..1535914b874e972efe7de912cdcde3ec2d873cc0 100644 (file)
@@ -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_;
 }
index 4e11722a1a813c44f6f9a0130be4eb9e6fde7f5f..d489208fdc2d4f5b9f05d45e23aa88d381d7800e 100644 (file)
@@ -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
index ae02fd7ecc3352525603ce27b247772c4b876c6d..bad7938f0c2fc9c798f869d117e9ce449b9ba3b3 100644 (file)
@@ -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_);
 }
index bae99b7575d2bdac22653ab44df4b7c066e67f3e..95f4c9cdc407caff352a5efb5b4fe716a06ee01a 100644 (file)
@@ -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
index ed5e99a6c888b5b05aa8ef5a8a005308f19e72a2..a67dce09ad87a62b1e1b33e767c677d9d57a75dd 100644 (file)
@@ -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_;
 }
index fa1d20a203856daf07fcd89bdaa446db9f81cf2e..b59fa044675871fa0eb21e8889518d5136be40d7 100644 (file)
@@ -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
index 9b0bdc6bea62ddc19189d78e550cc4fc9b64f827..de242cbf50442d85187a63eb22e92108a1cad52a 100644 (file)
@@ -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_;
 }
index 6bc04a38eb214413713ab2d157b21582cb73c567..23bb4002efe1590ccca8b076619139995e0cfdc4 100644 (file)
@@ -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
index 4ead0d962207b8a4c14037996f15d48d5ecd31a5..dbe1b2fa4235148a152b85495f4f802c9365f84e 100644 (file)
@@ -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;
 
index fe93cd05b9e5108d3bdd0df9e6f8992e2045336a..5b3497905f985c4de6b6555c8905d4c3612df38b 100644 (file)
@@ -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
index 9718d4ee7474ea7e55963ab5919c342b45e94ce4..9173c407fc8c9c498e464ede577fcf0a4af5b18a 100644 (file)
@@ -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_);
 }
index 9225ad9d4f93609bcf88dd0a73602c50e3e57f83..afe61974bb0a4637bb66ce5e59be81272697dadb 100644 (file)
@@ -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
index 07fd987d440824b888ce3e5ab3fab9700e98d173..21689f3cdbcd25d2f58422a88709113c448ff98c 100644 (file)
@@ -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_;
 }
index 0ac43e313fe68881d2455ef4e4533d0e41d1a21f..3e7a9e82a6916045fe7cf3f9380a4457a6e8c091 100644 (file)
@@ -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
index f8ea9265f5c7ed5da5003be6a4f2929ae4340932..2aaa1f52d217ac5a01d2d1a54cf8eef75515f148 100644 (file)
@@ -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_;
 }
index f769be9ce2285177eaf5e72d08263a0d48c3c0b0..90c673c7229f71954d72a2fa24f144504b4d08bc 100644 (file)
@@ -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
index 3c0f7f8c08f14d33b19e3e93d4c99f2b7aedb5b6..0c3e867c251ec1f544b20c508195b550b0f92214 100644 (file)
@@ -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
index fe5927b46cbffdd03638b2d91ec4c54fb7f198d6..75b0421edd1684f8dfa6806086754f7cfbb6ed4d 100644 (file)
@@ -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
index 3a0c6b2db90900d2b1c79e7721a3d9455212d889..c06d0ed299fe831b8ece3eaf099f08979a859d40 100644 (file)
@@ -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_;
 }
index 8aefcc6811dc594ea149a0c0987ebbb92e743e11..a83e6d04239b40fbbe7b726de4498fb1c584f333 100644 (file)
@@ -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
index 075df87f3656f4ecf29294a661a825eb9a1dc9fd..01fe1d2726e574649e8abd431497690a997ce93c 100644 (file)
@@ -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;
 }
index 4ac8731aa20e1a70f3d3036509a0bbda1351304f..8f1681e427397fada7d156302eb772e50ef2325b 100644 (file)
@@ -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
index 719eb502eff74844cd245a43990f41889ea0991f..e22d543b0b9784374b93e717e2d4dd89d22ad34b 100644 (file)
@@ -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_;
 }
index 4291344cd4a98d8db7ea50585cdc358f4902007b..afbcc781525eaffd1c9060f8869ed1ae39751e99 100644 (file)
@@ -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
index 784b8df68ae9999beae0f1a06bbd2c4b96e5ba0e..3a205c347776d2f5bc9ef025c5f2996e9dccd524 100644 (file)
@@ -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;
   }
index 1e6817cd19d1acb067f808f4147b7d4824f9f90c..ee54af97caf22d65236b307ce405e839cd4d98f9 100644 (file)
@@ -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"));