From fb1fb97c3d9c3b362b4dacfc2227f29a71c323e4 Mon Sep 17 00:00:00 2001 From: "mk5004.lee" Date: Wed, 27 Mar 2019 09:26:17 +0900 Subject: [PATCH] Update chatmessage class Change-Id: I132dc83e33240a3d7df0b7fb509e5772883f0807 Signed-off-by: mk5004.lee --- notification-ex/chat_message_item.cc | 32 +++++++++++----------- notification-ex/chat_message_item.h | 5 ++-- notification-ex/chat_message_item_implementation.h | 4 +-- unittest/src/test_chat_message_item.cc | 6 ++-- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/notification-ex/chat_message_item.cc b/notification-ex/chat_message_item.cc index eb89fb8..b93a518 100644 --- a/notification-ex/chat_message_item.cc +++ b/notification-ex/chat_message_item.cc @@ -28,25 +28,25 @@ #define LOG_TAG "NOTIFICATION_EX" #define CHATMESSAGE_NAME_KEY "__CHATMESSAGE_NAME_KEY__" #define CHATMESSAGE_TEXT_KEY "__CHATMESSAGE_TEXT_KEY__" -#define CHATMESSAGE_DATA_KEY "__CHATMESSAGE_DATA_KEY__" +#define CHATMESSAGE_IMAGE_KEY "__CHATMESSAGE_IMAGE_KEY__" #define CHATMESSAGE_TIME_KEY "__CHATMESSAGE_TIME_KEY__" #define CHATMESSAGE_TYPE_KEY "__CHATMESSAGE_TYPE_KEY__" namespace notification { namespace item { -ChatMessageItem::ChatMessageItem(std::string id, std::shared_ptr name, - std::shared_ptr text, std::shared_ptr data, - std::shared_ptr time, Type type, - std::shared_ptr action) +ChatMessageItem::ChatMessageItem(std::string id, + std::shared_ptr name, std::shared_ptr text, + std::shared_ptr image, std::shared_ptr time, + Type type, std::shared_ptr action) : AbstractItem(id, action), - impl_(new Impl(this, name, text, data, time, type)) { + impl_(new Impl(this, name, text, image, time, type)) { } ChatMessageItem::Impl::Impl(ChatMessageItem* parent, std::shared_ptr name, std::shared_ptr text, - std::shared_ptr data, std::shared_ptr time, Type type) - : parent_(parent), name_(name), text_(text), data_(data), time_(time), + std::shared_ptr image, std::shared_ptr time, Type type) + : parent_(parent), name_(name), text_(text), image_(image), time_(time), type_(type) { LOGI("ChatMessageItem impl created"); } @@ -63,8 +63,8 @@ Bundle ChatMessageItem::Serialize() const { reinterpret_cast(impl_->name_->Serialize().ToRaw().first.get())); b.Add(CHATMESSAGE_TEXT_KEY, reinterpret_cast(impl_->text_->Serialize().ToRaw().first.get())); - b.Add(CHATMESSAGE_DATA_KEY, - reinterpret_cast(impl_->data_->Serialize().ToRaw().first.get())); + b.Add(CHATMESSAGE_IMAGE_KEY, + reinterpret_cast(impl_->image_->Serialize().ToRaw().first.get())); b.Add(CHATMESSAGE_TIME_KEY, reinterpret_cast(impl_->time_->Serialize().ToRaw().first.get())); b.Add(CHATMESSAGE_TYPE_KEY, std::to_string((int)impl_->type_)); @@ -84,10 +84,10 @@ void ChatMessageItem::Deserialize(Bundle b) { text.get()->Deserialize(Bundle(b.GetString(CHATMESSAGE_TEXT_KEY))); impl_->text_ = std::static_pointer_cast(text); - std::shared_ptr data = - FactoryManager::GetInst().CreateItem(AbstractItem::Text); - data.get()->Deserialize(Bundle(b.GetString(CHATMESSAGE_DATA_KEY))); - impl_->data_ = std::static_pointer_cast(data); + std::shared_ptr image = + FactoryManager::GetInst().CreateItem(AbstractItem::Image); + image.get()->Deserialize(Bundle(b.GetString(CHATMESSAGE_IMAGE_KEY))); + impl_->image_ = std::static_pointer_cast(image); std::shared_ptr time = FactoryManager::GetInst().CreateItem(AbstractItem::Time); @@ -112,8 +112,8 @@ TextItem& ChatMessageItem::GetTextItem() const { return *(impl_->text_); } -TextItem& ChatMessageItem::GetDataItem() const { - return *(impl_->data_); +ImageItem& ChatMessageItem::GetImageItem() const { + return *(impl_->image_); } TimeItem& ChatMessageItem::GetTimeItem() const { diff --git a/notification-ex/chat_message_item.h b/notification-ex/chat_message_item.h index 4585035..368bb75 100644 --- a/notification-ex/chat_message_item.h +++ b/notification-ex/chat_message_item.h @@ -25,6 +25,7 @@ #include "notification-ex/abstract_item.h" #include "notification-ex/text_item.h" +#include "notification-ex/image_item.h" #include "notification-ex/time_item.h" namespace notification { @@ -39,7 +40,7 @@ class EXPORT_API ChatMessageItem : public AbstractItem { public: ChatMessageItem(std::string id, std::shared_ptr name, - std::shared_ptr text, std::shared_ptr data, + std::shared_ptr text, std::shared_ptr image, std::shared_ptr time, Type type, std::shared_ptr action = std::shared_ptr({})); virtual ~ChatMessageItem(); @@ -50,7 +51,7 @@ class EXPORT_API ChatMessageItem : public AbstractItem { AbstractItem& FindByID(std::string id) override; TextItem& GetNameItem() const; TextItem& GetTextItem() const; - TextItem& GetDataItem() const; + ImageItem& GetImageItem() const; TimeItem& GetTimeItem() const; Type GetMessageType() const; diff --git a/notification-ex/chat_message_item_implementation.h b/notification-ex/chat_message_item_implementation.h index b6e0cc4..58084ca 100644 --- a/notification-ex/chat_message_item_implementation.h +++ b/notification-ex/chat_message_item_implementation.h @@ -35,14 +35,14 @@ class ChatMessageItem::Impl { private: friend class ChatMessageItem; Impl(ChatMessageItem* parent, std::shared_ptr name, - std::shared_ptr text, std::shared_ptr data, + std::shared_ptr text, std::shared_ptr image, std::shared_ptr time, Type type); private: ChatMessageItem* parent_; std::shared_ptr name_; std::shared_ptr text_; - std::shared_ptr data_; + std::shared_ptr image_; std::shared_ptr time_; Type type_; }; diff --git a/unittest/src/test_chat_message_item.cc b/unittest/src/test_chat_message_item.cc index 30bb353..c72e6fb 100644 --- a/unittest/src/test_chat_message_item.cc +++ b/unittest/src/test_chat_message_item.cc @@ -35,7 +35,7 @@ class ChatMessageItemTest : public ::testing::Test { item = new ChatMessageItem(id, std::make_shared("name_id", "name"), std::make_shared("text_id", "text"), - std::make_shared("data_id", "data"), + std::make_shared("image_id", "path"), std::make_shared(current_time),type); } virtual void TearDown() { @@ -52,7 +52,7 @@ TEST_F(ChatMessageItemTest, FindByID) { ChatMessageItem& message = static_cast(child); ASSERT_EQ(message.GetNameItem().GetContents(), "name"); ASSERT_EQ(message.GetTextItem().GetContents(), "text"); - ASSERT_EQ(message.GetDataItem().GetContents(), "data"); + ASSERT_EQ(message.GetImageItem().GetImagePath(), "path"); ASSERT_EQ(message.GetMessageType(), ChatMessageItemTest::type); } @@ -68,7 +68,7 @@ TEST_F(ChatMessageItemTest, SerializeDeserialize) { auto gen_message = std::static_pointer_cast(gen_item); ASSERT_EQ(gen_message->GetNameItem().GetContents(), "name"); ASSERT_EQ(gen_message->GetTextItem().GetContents(), "text"); - ASSERT_EQ(gen_message->GetDataItem().GetContents(), "data"); + ASSERT_EQ(gen_message->GetImageItem().GetImagePath(), "path"); ASSERT_EQ(gen_message->GetTimeItem().GetTime(), ChatMessageItemTest::current_time); ASSERT_EQ(gen_message->GetMessageType(), ChatMessageItemTest::type); } -- 2.7.4