Add parameter for hyperlink for TextItem 87/200587/5 submit/tizen/20190228.000028
authorSukHyung, Kang <shine.kang@samsung.com>
Wed, 27 Feb 2019 06:02:39 +0000 (15:02 +0900)
committerSukHyung, Kang <shine.kang@samsung.com>
Wed, 27 Feb 2019 09:13:05 +0000 (18:13 +0900)
Change-Id: I79395e017e9c3621aaaa20405892bcab9a2f5750
Signed-off-by: SukHyung, Kang <shine.kang@samsung.com>
notification-ex/item_factory.cc
notification-ex/text_item.cc
notification-ex/text_item.h
notification-ex/text_item_implementation.h
unittest/src/test_text_item.cc

index 672bc98..721c4b8 100644 (file)
@@ -43,7 +43,7 @@ shared_ptr<AbstractItem> ItemFactory::CreateItem(AbstractItem::Type type) {
   case AbstractItem::NullObject :
     THROW(NOTIFICATION_ERROR_INVALID_PARAMETER);
   case AbstractItem::Text :
-    return make_shared<TextItem>("");
+    return make_shared<TextItem>("","");
   case AbstractItem::Icon :
     return make_shared<ButtonItem>("");
   case AbstractItem::Image :
index 64b0773..f01d3e0 100644 (file)
 
 namespace notification {
 namespace item {
-TextItem::TextItem(std::string text, std::shared_ptr<AbstractAction> action)
-  : AbstractItem(AbstractItem::Type::Text), impl_(new Impl(text)) {
-}
-
-TextItem::TextItem(std::string id, std::string text,
+TextItem::TextItem(std::string id, std::string text, std::string hyperlink,
       std::shared_ptr<AbstractAction> action)
-  : AbstractItem(id, AbstractItem::Type::Text), impl_(new Impl(text)) {
+  : AbstractItem(id, AbstractItem::Type::Text), impl_(new Impl(text, hyperlink)) {
 }
 
-TextItem::Impl::Impl(std::string text)
-  : text_(text) {
+TextItem::Impl::Impl(std::string text, std::string hyperlink)
+  : text_(text), hyperlink_(hyperlink) {
   LOGI("TextItem created");
 }
 
index ccbf2fd..2814992 100644 (file)
@@ -31,9 +31,8 @@ namespace item {
 
 class EXPORT_API TextItem : public AbstractItem {
  public:
-  TextItem(std::string text,
-      std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
-  TextItem(std::string id, std::string text,
+  TextItem(std::string id ,std::string text,
+      std::string hyperlink = std::string(),
       std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
   virtual ~TextItem();
 
index 3af64c2..48eb92b 100644 (file)
@@ -30,7 +30,7 @@ class TextItem::Impl {
   virtual ~Impl();
 
  private:
-  Impl(std::string text);
+  Impl(std::string text, std::string hyperlink);
 
  private:
   friend class TextItem;
index 9bef5f2..316e2cd 100644 (file)
@@ -33,22 +33,22 @@ class TexttItemTest : public ::testing::Test {
 };
 
 TEST_F(TexttItemTest, FindByID) {
-  TextItem item("text_id", "default");
+  TextItem item("text_id", "contents", "hyperlink");
 
   AbstractItem& child = item.FindByID("text_id");
   TextItem& btn = static_cast<TextItem&>(child);
-  ASSERT_EQ(btn.GetContents(), "default");
+  ASSERT_EQ(btn.GetContents(), "contents");
 }
 
 TEST_F(TexttItemTest, FindByIDNullItemReturn) {
-  TextItem item("text_id", "default");
+  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", "default");
+  TextItem item("text_id", "contents");
   Bundle b = item.Serialize();
   ItemFactory factory;
   std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(factory, b);
@@ -59,16 +59,19 @@ TEST_F(TexttItemTest, SerializeDeserializeGetContents) {
 }
 
 TEST_F(TexttItemTest, SetContentsGetContents) {
-  TextItem item("text_id", "default");
-  item.SetContents("test");
+  TextItem item("text_id", "contents");
+  ASSERT_EQ(item.GetContents(), "contents");
 
-  ASSERT_EQ(item.GetContents(), "test");
+  item.SetContents("changed");
+  ASSERT_EQ(item.GetContents(), "changed");
 }
 
 TEST_F(TexttItemTest, GetHyperLink) {
-  TextItem item("text_id", "default");
+  TextItem item("text_id", "contents");
+  ASSERT_TRUE(item.GetHyperLink().empty());
 
-  ASSERT_EQ(item.GetHyperLink(), "");
+  TextItem item2("text_id", "contents", "hyperlink2");
+  ASSERT_EQ(item2.GetHyperLink(), "hyperlink2");
 }
 
 }  // namespace
\ No newline at end of file