Add tag implementation for AbstractItem 16/202416/2
authorjusung son <jusung07.son@samsung.com>
Thu, 28 Mar 2019 07:20:04 +0000 (16:20 +0900)
committermk5004.lee <mk5004.lee@samsung.com>
Fri, 29 Mar 2019 08:06:46 +0000 (17:06 +0900)
Change-Id: Ibc947cfb699bacee69917e0286633f43928dfebb
Signed-off-by: jusung son <jusung07.son@samsung.com>
notification-ex/abstract_item.cc
notification-ex/abstract_item.h
notification-ex/event_info.cc
notification-ex/event_info_implementation.h
notification-ex/event_info_internal.h
notification-ex/ievent_info.h
unittest/src/test_abstract_item.cc
unittest/src/test_event_info.cc

index ef1663f..4dd60fb 100644 (file)
@@ -38,6 +38,7 @@
 #define ABSTRACT_ITEM_UID_KEY "__ABSTRACT_ITEM_UID_KEY__"
 #define ABSTRACT_ITEM_TIME_KEY "__ABSTRACT_ITEM_TIME_KEY__"
 #define ABSTRACT_ITEM_SENDER_APPID_KEY "__ABSTRACT_ITEM_SENDER_APPID_KEY__"
+#define ABSTRACT_ITEM_TAG_KEY "__ABSTRACT_ITEM_TAG_KEY__"
 #define ABSTRACT_ITEM_CHANNEL_KEY "__ABSTRACT_ITEM_CHANNEL_KEY__"
 #define ABSTRACT_ITEM_VERSION_KEY "__ABSTRACT_ITEM_VERSION_KEY__"
 #define ABSTRACT_ITEM_HIDE_TIME_KEY "__ABSTRACT_ITEM_HIDE_TIME_KEY__"
@@ -142,6 +143,7 @@ Bundle AbstractItem::Serialize() const {
   b.Add(ABSTRACT_ITEM_HIDE_TIME_KEY, to_string(impl_->hide_time_));
   b.Add(ABSTRACT_ITEM_DELETE_TIME_KEY, to_string(impl_->delete_time_));
   b.Add(ABSTRACT_ITEM_UID_KEY, to_string(impl_->uid_));
+  b.Add(ABSTRACT_ITEM_TAG_KEY, impl_->tag_);
 
   timeinfo = localtime(&impl_->time_);
   strftime (buf, sizeof(buf), "%s", timeinfo);
@@ -248,6 +250,7 @@ void AbstractItem::Deserialize(Bundle b) {
   impl_->sound_path_ = b.GetString(ABSTRACT_ITEM_SOUND_PATH_KEY);
   impl_->vibration_path_ = b.GetString(ABSTRACT_ITEM_VIBRATION_PATH_KEY);
   impl_->uid_ = stoi(b.GetString(ABSTRACT_ITEM_UID_KEY));
+  impl_->tag_ = b.GetString(ABSTRACT_ITEM_TAG_KEY);
 
   time_s = b.GetString(ABSTRACT_ITEM_TIME_KEY);
   strptime(time_s.c_str(), "%s", &timeinfo);
@@ -447,5 +450,13 @@ void AbstractItem::SetSenderAppId(std::string sender_appid) {
   impl_->sender_appid_ = sender_appid;
 }
 
+std::string AbstractItem::GetTag() const {
+  return impl_->tag_;
+}
+
+void AbstractItem::SetTag(std::string tag) {
+  impl_->tag_ = tag;
+}
+
 }  // namespace item
 }  // namespace notification
index c7d2726..2ac01a2 100644 (file)
@@ -263,8 +263,8 @@ class EXPORT_API AbstractItem {
   std::shared_ptr<IItemInfo> GetInfo() const;
   std::string GetSenderAppId() const;
   void SetSenderAppId(std::string sender_appid);
-  std::string GetTag();
-  void SetTag();
+  std::string GetTag() const;
+  void SetTag(std::string tag);
 
  private:
   class Impl;
index c220603..2dbd554 100644 (file)
@@ -32,7 +32,6 @@
 #define NOTIFICATION_EX_EVENT_OWNER_KEY "__NOTIFICATION_EX_EVENT_OWNER_KEY__"
 #define NOTIFICATION_EX_EVENT_CHANNEL_KEY "__NOTIFICATION_EX_EVENT_CHANNEL_KEY__"
 #define NOTIFICATION_EX_EVENT_ITEM_ID_KEY "__NOTIFICATION_EX_EVENT_ITEM_ID_KEY__"
-#define NOTIFICATION_EX_EVENT_TAG_KEY "__NOTIFICATION_EX_EVENT_TAG_KEY__"
 #define NOTIFICATION_EX_EVENT_UID_KEY "__NOTIFICATION_EX_EVENT_UID_KEY__"
 #define NOTIFICATION_EX_EVENT_REQUEST_ID_KEY "__NOTIFICATION_EX_EVENT_REQUEST_ID_KEY__"
 #define NOTIFICATION_EX_EVENT_ERROR_KEY "__NOTIFICATION_EX_EVENT_ERROR_KEY__"
@@ -41,17 +40,16 @@ using namespace std;
 namespace notification {
 
 EventInfo::EventInfo(int type, std::string owner, std::string channel,
-    std::string item_id, std::string tag)
-    : impl_(new Impl(this, type, owner, channel, item_id, tag)) {
+    std::string item_id)
+    : impl_(new Impl(this, type, owner, channel, item_id)) {
 }
 EventInfo::~EventInfo() = default;
 EventInfo::Impl::~Impl() = default;
 
-EventInfo::Impl::Impl(EventInfo* parent,
-    int type, std::string owner, std::string channel,
-    std::string item_id, std::string tag)
-    : type_(type), owner_(owner), channel_(channel),
-    item_id_(item_id), tag_(tag), parent_(parent) {
+EventInfo::Impl::Impl(EventInfo* parent, int type, std::string owner,
+    std::string channel, std::string item_id)
+    : type_(type), owner_(owner), channel_(channel), item_id_(item_id),
+    parent_(parent) {
   uid_ = getuid();
   request_id_ = util::GetRequestId();
   error_ = NOTIFICATION_ERROR_NONE;
@@ -59,13 +57,12 @@ EventInfo::Impl::Impl(EventInfo* parent,
 }
 
 EventInfo::EventInfo(Bundle serialized)
-  : impl_(new Impl(this, EventInfo::Post, "", "", "", "")) {
+  : impl_(new Impl(this, EventInfo::Post, "", "", "")) {
   string event_str = serialized.GetString(NOTIFICATION_EX_EVENT_TYPE_KEY);
   impl_->type_ = (int)strtol(event_str.c_str(), NULL, 10);
   impl_->owner_ = serialized.GetString(NOTIFICATION_EX_EVENT_OWNER_KEY);
   impl_->channel_ = serialized.GetString(NOTIFICATION_EX_EVENT_CHANNEL_KEY);
   impl_->item_id_ = serialized.GetString(NOTIFICATION_EX_EVENT_ITEM_ID_KEY);
-  impl_->tag_ = serialized.GetString(NOTIFICATION_EX_EVENT_TAG_KEY);
   string uid_str = serialized.GetString(NOTIFICATION_EX_EVENT_UID_KEY);
   impl_->uid_ = (uid_t)strtol(uid_str.c_str(), NULL, 10);
   string request_id_str =
@@ -99,7 +96,6 @@ Bundle EventInfo::Serialize() const {
   serialized.Add(NOTIFICATION_EX_EVENT_OWNER_KEY, impl_->owner_);
   serialized.Add(NOTIFICATION_EX_EVENT_CHANNEL_KEY, impl_->channel_);
   serialized.Add(NOTIFICATION_EX_EVENT_ITEM_ID_KEY, impl_->item_id_);
-  serialized.Add(NOTIFICATION_EX_EVENT_TAG_KEY, impl_->tag_);
   serialized.Add(NOTIFICATION_EX_EVENT_UID_KEY, to_string((int)impl_->uid_));
   serialized.Add(
       NOTIFICATION_EX_EVENT_REQUEST_ID_KEY, to_string(impl_->request_id_));
@@ -129,10 +125,6 @@ string EventInfo::GetItemId() const {
   return impl_->item_id_;
 }
 
-string EventInfo::GetTag() const {
-  return impl_->tag_;
-}
-
 uid_t EventInfo::GetUid() const {
   return impl_->uid_;
 }
index d429211..41ef31f 100644 (file)
@@ -36,14 +36,13 @@ class EventInfo::Impl {
  private:
   friend class EventInfo;
   Impl(EventInfo* parent, int type, std::string owner, std::string channel,
-    std::string item_id, std::string tag);
+    std::string item_id);
 
  private:
   int type_;
   std::string owner_;
   std::string channel_;
   std::string item_id_;
-  std::string tag_;
   uid_t uid_;
   int request_id_;
   NotificationError error_;
@@ -51,4 +50,4 @@ class EventInfo::Impl {
 };
 
 }  // namespace notification
-#endif  // NOTIFICATION_EX_EVENT_INFO_IMPLEMENTATION_H_
\ No newline at end of file
+#endif  // NOTIFICATION_EX_EVENT_INFO_IMPLEMENTATION_H_
index 234c861..ada713a 100644 (file)
@@ -33,7 +33,7 @@ namespace notification {
 class EventInfo : public IEventInfoInternal {
  public:
   EventInfo(int type, std::string owner, std::string channel = "",
-      std::string item_id = "", std::string tag = "");
+      std::string item_id = "");
   EventInfo(Bundle serialized);
   virtual ~EventInfo();
   uid_t GetUid() const override;
@@ -45,7 +45,6 @@ class EventInfo : public IEventInfoInternal {
   std::string GetOwner() const override;
   std::string GetChannel() const override;
   std::string GetItemId() const override;
-  std::string GetTag() const override;
   int GetRequestId() const override;
   Bundle Serialize() const override;
   static std::string GetString(int type);
index 57eddb0..690b974 100644 (file)
@@ -40,7 +40,6 @@ class EXPORT_API IEventInfo {
   virtual std::string GetOwner() const = 0;
   virtual std::string GetChannel() const = 0;
   virtual std::string GetItemId() const = 0;
-  virtual std::string GetTag() const = 0;
   virtual int GetRequestId() const = 0;
   virtual Bundle Serialize() const = 0;
 };
index 2c1e6da..ecb8972 100644 (file)
@@ -118,6 +118,7 @@ TEST_F(AbstractItemTest, SerializeDeserialize) {
   item.SetVibrationPath("vibrationpath");
   std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->SetUid(3);
   item.SetSenderAppId("sender");
+  item.SetTag("tag");
 
   time(&current_time);
   std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->SetTime(current_time);
@@ -149,6 +150,7 @@ TEST_F(AbstractItemTest, SerializeDeserialize) {
   ASSERT_EQ(gen_test->GetSoundPath(), "soundpath");
   ASSERT_EQ(gen_test->GetVibrationPath(), "vibrationpath");
   ASSERT_EQ(gen_test->GetSenderAppId(), "sender");
+  ASSERT_EQ(gen_test->GetTag(), "tag");
   ASSERT_EQ(gen_test->GetInfo()->GetTime(), current_time);
 
   ASSERT_EQ(gen_test->GetStyle()->GetPadding().GetLeft(), 10);
index 7daafa6..120cee5 100644 (file)
@@ -18,14 +18,13 @@ class EventInfoTest : public ::testing::Test {
 };
 
 TEST_F(EventInfoTest, SerializeDeserialize) {
-  EventInfo info(EventInfo::Get, "test", "channel", "id", "tag");
+  EventInfo info(EventInfo::Get, "test", "channel", "id");
   Bundle b = info.Serialize();
   EventInfo serialized(b);
   ASSERT_EQ(serialized.GetEventType(), info.GetEventType());
   ASSERT_EQ(serialized.GetOwner(), info.GetOwner());
   ASSERT_EQ(serialized.GetChannel(), info.GetChannel());
   ASSERT_EQ(serialized.GetItemId(), info.GetItemId());
-  ASSERT_EQ(serialized.GetTag(), info.GetTag());
   ASSERT_EQ(serialized.GetUid(), info.GetUid());
 }