From 8e7f20a9910e830639fc08fc8b6e38bcb7bda454 Mon Sep 17 00:00:00 2001 From: "SukHyung, Kang" Date: Wed, 27 Feb 2019 15:02:39 +0900 Subject: [PATCH] Add parameter for hyperlink for TextItem Change-Id: I79395e017e9c3621aaaa20405892bcab9a2f5750 Signed-off-by: SukHyung, Kang --- notification-ex/item_factory.cc | 2 +- notification-ex/text_item.cc | 12 ++++-------- notification-ex/text_item.h | 5 ++--- notification-ex/text_item_implementation.h | 2 +- unittest/src/test_text_item.cc | 21 ++++++++++++--------- 5 files changed, 20 insertions(+), 22 deletions(-) diff --git a/notification-ex/item_factory.cc b/notification-ex/item_factory.cc index 672bc98..721c4b8 100644 --- a/notification-ex/item_factory.cc +++ b/notification-ex/item_factory.cc @@ -43,7 +43,7 @@ shared_ptr ItemFactory::CreateItem(AbstractItem::Type type) { case AbstractItem::NullObject : THROW(NOTIFICATION_ERROR_INVALID_PARAMETER); case AbstractItem::Text : - return make_shared(""); + return make_shared("",""); case AbstractItem::Icon : return make_shared(""); case AbstractItem::Image : diff --git a/notification-ex/text_item.cc b/notification-ex/text_item.cc index 64b0773..f01d3e0 100644 --- a/notification-ex/text_item.cc +++ b/notification-ex/text_item.cc @@ -32,17 +32,13 @@ namespace notification { namespace item { -TextItem::TextItem(std::string text, std::shared_ptr 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 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"); } diff --git a/notification-ex/text_item.h b/notification-ex/text_item.h index ccbf2fd..2814992 100644 --- a/notification-ex/text_item.h +++ b/notification-ex/text_item.h @@ -31,9 +31,8 @@ namespace item { class EXPORT_API TextItem : public AbstractItem { public: - TextItem(std::string text, - std::shared_ptr action = std::shared_ptr({})); - TextItem(std::string id, std::string text, + TextItem(std::string id ,std::string text, + std::string hyperlink = std::string(), std::shared_ptr action = std::shared_ptr({})); virtual ~TextItem(); diff --git a/notification-ex/text_item_implementation.h b/notification-ex/text_item_implementation.h index 3af64c2..48eb92b 100644 --- a/notification-ex/text_item_implementation.h +++ b/notification-ex/text_item_implementation.h @@ -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; diff --git a/unittest/src/test_text_item.cc b/unittest/src/test_text_item.cc index 9bef5f2..316e2cd 100644 --- a/unittest/src/test_text_item.cc +++ b/unittest/src/test_text_item.cc @@ -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(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 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 -- 2.7.4