Update some items 04/200304/13
authormk5004.lee <mk5004.lee@samsung.com>
Thu, 21 Feb 2019 09:13:19 +0000 (18:13 +0900)
committermk5004.lee <mk5004.lee@samsung.com>
Thu, 28 Feb 2019 02:28:50 +0000 (11:28 +0900)
- image, icon, icontext, checkbox, time, chatmessage

Change-Id: I74f8b7192037da6ae8f608ea08d542e4fa803716
Signed-off-by: mk5004.lee <mk5004.lee@samsung.com>
28 files changed:
notification-ex/abstract_item.h
notification-ex/chat_message_item.cc [new file with mode: 0644]
notification-ex/chat_message_item.h [new file with mode: 0644]
notification-ex/chat_message_item_implementation.h [new file with mode: 0644]
notification-ex/checkbox_item.cc [new file with mode: 0644]
notification-ex/checkbox_item.h [new file with mode: 0644]
notification-ex/checkbox_item_implementation.h [new file with mode: 0644]
notification-ex/icon_item.cc [new file with mode: 0644]
notification-ex/icon_item.h [new file with mode: 0644]
notification-ex/icon_item_implementation.h [new file with mode: 0644]
notification-ex/icon_text_item.cc [new file with mode: 0644]
notification-ex/icon_text_item.h [new file with mode: 0644]
notification-ex/icon_text_item_implementation.h [new file with mode: 0644]
notification-ex/image_item.cc [new file with mode: 0644]
notification-ex/image_item.h [new file with mode: 0644]
notification-ex/image_item_implementation.h [new file with mode: 0644]
notification-ex/item.h
notification-ex/item_factory.cc
notification-ex/time_item.cc [new file with mode: 0644]
notification-ex/time_item.h [new file with mode: 0644]
notification-ex/time_item_implementation.h [new file with mode: 0644]
unittest/CMakeLists.txt
unittest/src/test_chat_message_item.cc [new file with mode: 0644]
unittest/src/test_checkbox_item.cc [new file with mode: 0644]
unittest/src/test_icon_item.cc [new file with mode: 0644]
unittest/src/test_icon_text_item.cc [new file with mode: 0644]
unittest/src/test_image_item.cc [new file with mode: 0644]
unittest/src/test_time_item.cc [new file with mode: 0644]

index dc5b32b05f57903c2f556aab4eb3ded535a5b63b..4895eeddccdd37f36f7cc70ea47eec85bdeff589 100644 (file)
@@ -179,6 +179,7 @@ class EXPORT_API AbstractItem {
     Group,
     Entry,
     Progress,
+    Time,
     Custom,
   };
 
diff --git a/notification-ex/chat_message_item.cc b/notification-ex/chat_message_item.cc
new file mode 100644 (file)
index 0000000..e674709
--- /dev/null
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dlog.h>
+
+#include "notification-ex/chat_message_item.h"
+#include "notification-ex/chat_message_item_implementation.h"
+#include "notification-ex/item_factory.h"
+#include "notification-ex/exception.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#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_TIME_KEY "__CHATMESSAGE_TIME_KEY__"
+#define CHATMESSAGE_TYPE_KEY "__CHATMESSAGE_TYPE_KEY__"
+
+namespace notification {
+namespace item {
+
+ChatMessageItem::ChatMessageItem(std::string id, std::shared_ptr<TextItem> name,
+  std::shared_ptr<TextItem> text, std::shared_ptr<TextItem> data,
+  std::shared_ptr<TimeItem> time, Type type, std::shared_ptr<AbstractAction> action)
+  : AbstractItem(id, AbstractItem::ChatMessage, action),
+  impl_(new Impl(this, name, text, data, time, type)) {
+}
+
+ChatMessageItem::Impl::Impl(ChatMessageItem* parent,
+  std::shared_ptr<TextItem> name, std::shared_ptr<TextItem> text,
+  std::shared_ptr<TextItem> data, std::shared_ptr<TimeItem> time, Type type)
+  : parent_(parent), name_(name), text_(text), data_(data), time_(time), type_(type) {
+  LOGI("ChatMessageItem impl created");
+}
+
+Bundle ChatMessageItem::Serialize() {
+  Bundle b;
+  b = AbstractItem::Serialize();
+
+  b.Add(CHATMESSAGE_NAME_KEY,
+    reinterpret_cast<char*>(impl_->name_->Serialize().ToRaw().first.get()));
+  b.Add(CHATMESSAGE_TEXT_KEY,
+    reinterpret_cast<char*>(impl_->text_->Serialize().ToRaw().first.get()));
+  b.Add(CHATMESSAGE_DATA_KEY,
+    reinterpret_cast<char*>(impl_->data_->Serialize().ToRaw().first.get()));
+  b.Add(CHATMESSAGE_TIME_KEY,
+    reinterpret_cast<char*>(impl_->time_->Serialize().ToRaw().first.get()));
+  b.Add(CHATMESSAGE_TYPE_KEY, std::to_string((int)impl_->type_));
+  return b;
+}
+
+void ChatMessageItem::Deserialize(Bundle b) {
+  ItemFactory factory;
+
+  AbstractItem::Deserialize(b);
+
+  std::shared_ptr<AbstractItem> name = factory.CreateItem(AbstractItem::Text);
+  name.get()->Deserialize(Bundle(b.GetString(CHATMESSAGE_NAME_KEY)));
+  impl_->name_ = std::static_pointer_cast<TextItem>(name);
+
+  std::shared_ptr<AbstractItem> text = factory.CreateItem(AbstractItem::Text);
+  text.get()->Deserialize(Bundle(b.GetString(CHATMESSAGE_TEXT_KEY)));
+  impl_->text_ = std::static_pointer_cast<TextItem>(text);
+
+  std::shared_ptr<AbstractItem> data = factory.CreateItem(AbstractItem::Text);
+  data.get()->Deserialize(Bundle(b.GetString(CHATMESSAGE_DATA_KEY)));
+  impl_->data_ = std::static_pointer_cast<TextItem>(data);
+
+  std::shared_ptr<AbstractItem> time = factory.CreateItem(AbstractItem::Time);
+  time.get()->Deserialize(Bundle(b.GetString(CHATMESSAGE_TIME_KEY)));
+  impl_->time_ = std::static_pointer_cast<TimeItem>(time);
+
+  impl_->type_ = static_cast<Type>(std::stoi(b.GetString(CHATMESSAGE_TYPE_KEY)));
+}
+
+AbstractItem&  ChatMessageItem::FindByID(std::string id) {
+  if (GetId() == id)
+    return *this;
+
+  return ItemFactory::GetNullItem();
+}
+
+TextItem& ChatMessageItem::GetNameItem() const {
+  return *(impl_->name_);
+}
+
+TextItem& ChatMessageItem::GetTextItem() const {
+  return *(impl_->text_);
+
+}
+
+TextItem& ChatMessageItem::GetDataItem() const {
+  return *(impl_->data_);
+}
+
+TimeItem& ChatMessageItem::GetTimeItem() const {
+  return *(impl_->time_);
+}
+
+ChatMessageItem::Type ChatMessageItem::GetType() const {
+  return impl_->type_;
+}
+
+ChatMessageItem::~ChatMessageItem() = default;
+ChatMessageItem::Impl::~Impl() = default;
+
+}  // namespace item
+}  // namespace notification_ex
diff --git a/notification-ex/chat_message_item.h b/notification-ex/chat_message_item.h
new file mode 100644 (file)
index 0000000..e3234f6
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NOTIFICATION_EX_CHAT_MESSAGE_ITEM_H_
+#define NOTIFICATION_EX_CHAT_MESSAGE_ITEM_H_
+
+#include <time.h>
+
+#include <string>
+#include <memory>
+#include <list>
+
+#include "notification-ex/abstract_item.h"
+#include "notification-ex/text_item.h"
+#include "notification-ex/time_item.h"
+
+namespace notification {
+namespace item {
+
+class EXPORT_API ChatMessageItem : public AbstractItem {
+ public:
+  enum Type {
+    user,
+    sender,
+  };
+
+ public:
+  ChatMessageItem(std::string id, std::shared_ptr<TextItem> name,
+    std::shared_ptr<TextItem> text, std::shared_ptr<TextItem> data,
+    std::shared_ptr<TimeItem> time, Type type,
+    std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
+  virtual ~ChatMessageItem();
+
+  Bundle Serialize() override;
+  void Deserialize(Bundle b) override;
+  AbstractItem& FindByID(std::string id) override;
+  TextItem& GetNameItem() const;
+  TextItem& GetTextItem() const;
+  TextItem& GetDataItem() const;
+  TimeItem& GetTimeItem() const;
+  Type GetType() const;
+
+ private:
+  class Impl;
+  std::unique_ptr<Impl> impl_;
+};  // class ChatMessageItem
+
+}  // namespace item
+}  // nampace notification
+#endif  // NOTIFICATION_EX_CHAT_MESSAGE_ITEM_H_
diff --git a/notification-ex/chat_message_item_implementation.h b/notification-ex/chat_message_item_implementation.h
new file mode 100644 (file)
index 0000000..299a0a1
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NOTIFICATION_EX_CHAT_MESSAGE_ITEM_IMPLEMENTATION_H_
+#define NOTIFICATION_EX_CHAT_MESSAGE_ITEM_IMPLEMENTATION_H_
+
+#include <time.h>
+
+#include <string>
+#include <memory>
+#include <list>
+
+#include "notification-ex/chat_message_item.h"
+
+namespace notification {
+namespace item {
+
+class ChatMessageItem::Impl {
+ public:
+  virtual ~Impl();
+
+ private:
+  friend class ChatMessageItem;
+  Impl(ChatMessageItem* parent, std::shared_ptr<TextItem> name,
+    std::shared_ptr<TextItem> text, std::shared_ptr<TextItem> data,
+    std::shared_ptr<TimeItem> time, Type type);
+
+ private:
+  ChatMessageItem* parent_;
+  std::shared_ptr<TextItem> name_;
+  std::shared_ptr<TextItem> text_;
+  std::shared_ptr<TextItem> data_;
+  std::shared_ptr<TimeItem> time_;
+  Type type_;
+};
+
+}  // namespace item
+}  // nampace notification
+#endif  // NOTIFICATION_EX_CHAT_MESSAGE_ITEM_IMPLEMENTATION_H_
diff --git a/notification-ex/checkbox_item.cc b/notification-ex/checkbox_item.cc
new file mode 100644 (file)
index 0000000..c4e1e0c
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dlog.h>
+
+#include "notification-ex/checkbox_item.h"
+#include "notification-ex/checkbox_item_implementation.h"
+#include "notification-ex/item_factory.h"
+#include "notification-ex/exception.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "NOTIFICATION_EX"
+#define CHECKBOX_TITLE_KEY "__CHECKBOX_TITLE_KEY__"
+#define CHECKBOX_CHECKED_KEY "__CHECKBOX_CHECKED_KEY__"
+
+namespace notification {
+namespace item {
+
+CheckBoxItem::CheckBoxItem(std::string id, std::string title, bool checked,
+  std::shared_ptr<AbstractAction> action)
+  : AbstractItem(id, AbstractItem::CheckBox, action),
+  impl_(new Impl(this, title, checked)) {
+}
+
+CheckBoxItem::Impl::Impl(CheckBoxItem* parent, std::string title, bool checked)
+  : parent_(parent), title_(title), checked_(checked) {
+  LOGI("CheckBoxItem impl created");
+}
+
+Bundle CheckBoxItem::Serialize() {
+  Bundle b;
+
+  b = AbstractItem::Serialize();
+  b.Add(CHECKBOX_TITLE_KEY, impl_->title_);
+  b.Add(CHECKBOX_CHECKED_KEY, std::to_string(impl_->checked_));
+
+  return b;
+}
+
+void CheckBoxItem::Deserialize(Bundle b) {
+  AbstractItem::Deserialize(b);
+
+  impl_->title_ = b.GetString(CHECKBOX_TITLE_KEY);
+  impl_->checked_ = std::stoi(b.GetString(CHECKBOX_CHECKED_KEY));
+}
+
+AbstractItem& CheckBoxItem::FindByID(std::string id) {
+  if (GetId() == id)
+    return *this;
+
+  return ItemFactory::GetNullItem();
+}
+
+std::string CheckBoxItem::GetTitle(void) const {
+  return impl_->title_;
+}
+
+bool CheckBoxItem::IsChecked(void) const {
+  return impl_->checked_;
+}
+
+CheckBoxItem::~CheckBoxItem() = default;
+CheckBoxItem::Impl::~Impl() = default;
+
+}  // namespace item
+}  // namespace notification_ex
diff --git a/notification-ex/checkbox_item.h b/notification-ex/checkbox_item.h
new file mode 100644 (file)
index 0000000..79a6709
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NOTIFICATION_EX_CHECKBOX_ITEM_H_
+#define NOTIFICATION_EX_CHECKBOX_ITEM_H_
+
+#include <string>
+#include <memory>
+#include <list>
+
+#include "notification-ex/abstract_item.h"
+
+namespace notification {
+namespace item {
+
+class EXPORT_API CheckBoxItem : public AbstractItem {
+ public:
+  CheckBoxItem(std::string id, std::string title, bool checked = false,
+    std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
+  virtual ~CheckBoxItem();
+
+  Bundle Serialize() override;
+  void Deserialize(Bundle b) override;
+  AbstractItem& FindByID(std::string id) override;
+  std::string GetTitle() const;
+  bool IsChecked() const;
+
+private:
+  class Impl;
+  std::unique_ptr<Impl> impl_;
+};  // class CheckBoxItem
+
+}  // namespace item
+}  // nampace notification
+#endif  // NOTIFICATION_EX_CHECKBOX_ITEM_H_
diff --git a/notification-ex/checkbox_item_implementation.h b/notification-ex/checkbox_item_implementation.h
new file mode 100644 (file)
index 0000000..83de751
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NOTIFICATION_EX_CHECKBOX_ITEM_IMPLEMENTATION_H_
+#define NOTIFICATION_EX_CHECKBOX_ITEM_IMPLEMENTATION_H_
+
+#include <string>
+#include <memory>
+#include <list>
+
+#include "notification-ex/checkbox_item.h"
+
+namespace notification {
+namespace item {
+
+class CheckBoxItem::Impl {
+ public:
+  virtual ~Impl();
+
+ private:
+  friend class CheckBoxItem;
+  Impl(CheckBoxItem* parent, std::string title, bool checked);
+
+ private:
+  CheckBoxItem* parent_;
+  std::string title_;
+  bool checked_;
+};
+
+}  // namespace item
+}  // nampace notification
+#endif  // NOTIFICATION_EX_CHECKBOX_ITEM_IMPLEMENTATION_H_
diff --git a/notification-ex/icon_item.cc b/notification-ex/icon_item.cc
new file mode 100644 (file)
index 0000000..bef75b7
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dlog.h>
+
+#include "notification-ex/icon_item.h"
+#include "notification-ex/icon_item_implementation.h"
+#include "notification-ex/abstract_item.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "NOTIFICATION_EX"
+
+namespace notification {
+namespace item {
+
+IconItem::IconItem(std::string iconPath, std::shared_ptr<AbstractAction> action)
+  : ImageItem(iconPath, action) , impl_(new Impl(this, iconPath)) {
+}
+
+IconItem::IconItem(std::string id, std::string iconPath,
+  std::shared_ptr<AbstractAction> action)
+  : ImageItem(id, iconPath, action), impl_(new Impl(this, iconPath)) {
+}
+
+IconItem::Impl::Impl(IconItem* parent, std::string iconPath)
+  : parent_(parent), iconPath_(iconPath) {
+  LOGI("IconItem impl created");
+}
+
+IconItem::~IconItem() = default;
+IconItem::Impl::~Impl() = default;
+
+}  // namespace item
+}  // namespace notification_ex
+
diff --git a/notification-ex/icon_item.h b/notification-ex/icon_item.h
new file mode 100644 (file)
index 0000000..3b6a3eb
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NOTIFICATION_EX_ICON_ITEM_H_
+#define NOTIFICATION_EX_ICON_ITEM_H_
+
+#include <string>
+#include <memory>
+#include <list>
+
+#include "notification-ex/image_item.h"
+
+namespace notification {
+namespace item {
+
+class EXPORT_API IconItem : public ImageItem {
+ public:
+  IconItem(std::string iconPath,
+    std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
+  IconItem(std::string id, std::string iconPath,
+    std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
+  virtual ~IconItem();
+
+ private:
+  class Impl;
+  std::unique_ptr<Impl> impl_;
+};  // class IconItem
+
+}  // namespace item
+}  // nampace notification
+#endif  // NOTIFICATION_EX_ICON_ITEM_H_
diff --git a/notification-ex/icon_item_implementation.h b/notification-ex/icon_item_implementation.h
new file mode 100644 (file)
index 0000000..f80f539
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NOTIFICATION_EX_ICON_ITEM_IMPLEMENTATION_H_
+#define NOTIFICATION_EX_ICON_ITEM_IMPLEMENTATION_H_
+
+#include <string>
+#include <memory>
+#include <list>
+
+#include "notification-ex/icon_item.h"
+
+namespace notification {
+namespace item {
+
+class IconItem::Impl {
+ public:
+  virtual ~Impl();
+
+ private:
+  friend class IconItem;
+  Impl(IconItem* parent, std::string iconPath);
+
+ private:
+  IconItem* parent_;
+  std::string iconPath_;
+};
+
+}  // namespace item
+}  // nampace notification
+#endif  // NOTIFICATION_EX_ICON_ITEM_IMPLEMENTATION_H_
diff --git a/notification-ex/icon_text_item.cc b/notification-ex/icon_text_item.cc
new file mode 100644 (file)
index 0000000..9ba8833
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dlog.h>
+
+#include "notification-ex/icon_text_item.h"
+#include "notification-ex/icon_text_item_implementation.h"
+#include "notification-ex/item_factory.h"
+#include "notification-ex/exception.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "NOTIFICATION_EX"
+#define ICONTEXT_PATH_KEY "__ICONTEXT_PATH_KEY__"
+#define ICONTEXT_TITLE_KEY "__ICONTEXT_TITLE_KEY__"
+
+namespace notification {
+namespace item {
+
+IconTextItem::IconTextItem(std::string id, std::shared_ptr<IconItem> icon,
+  std::shared_ptr<TextItem> text, std::shared_ptr<AbstractAction> action)
+  : AbstractItem(AbstractItem::IconText, action),
+  impl_(new Impl(this, icon, text)) {
+}
+
+IconTextItem::Impl::Impl(IconTextItem* parent, std::shared_ptr<IconItem> icon,
+  std::shared_ptr<TextItem> text)
+  : parent_(parent), icon_(icon), text_(text) {
+  LOGI("IconTextItem impl created");
+}
+
+Bundle IconTextItem::Serialize() {
+  Bundle b;
+  b = AbstractItem::Serialize();
+
+  b.Add(ICONTEXT_PATH_KEY,
+    reinterpret_cast<char*>(impl_->icon_->Serialize().ToRaw().first.get()));
+  b.Add(ICONTEXT_TITLE_KEY,
+    reinterpret_cast<char*>(impl_->text_->Serialize().ToRaw().first.get()));
+  return b;
+}
+
+void IconTextItem::Deserialize(Bundle b) {
+  ItemFactory factory;
+
+  AbstractItem::Deserialize(b);
+
+  std::shared_ptr<AbstractItem> icon = factory.CreateItem(AbstractItem::Icon);
+  icon.get()->Deserialize(Bundle(b.GetString(ICONTEXT_PATH_KEY)));
+  impl_->icon_ = std::static_pointer_cast<IconItem>(icon);
+
+  std::shared_ptr<AbstractItem> text = factory.CreateItem(AbstractItem::Text);
+  text.get()->Deserialize(Bundle(b.GetString(ICONTEXT_TITLE_KEY)));
+  impl_->text_ = std::static_pointer_cast<TextItem>(text);
+}
+
+AbstractItem& IconTextItem::FindByID(std::string id) {
+  if (GetId() == id)
+    return *this;
+
+  return ItemFactory::GetNullItem();
+}
+
+IconItem& IconTextItem::GetIconItem() const {
+  return *(impl_->icon_);
+}
+
+TextItem& IconTextItem::GetTextItem() const {
+  return *(impl_->text_);
+}
+
+IconTextItem::~IconTextItem() = default;
+IconTextItem::Impl::~Impl() = default;
+
+}  // namespace item
+}  // namespace notification_ex
diff --git a/notification-ex/icon_text_item.h b/notification-ex/icon_text_item.h
new file mode 100644 (file)
index 0000000..7fca273
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NOTIFICATION_EX_ICON_TEXT_ITEM_H_
+#define NOTIFICATION_EX_ICON_TEXT_ITEM_H_
+
+#include <string>
+#include <memory>
+#include <list>
+
+#include "notification-ex/abstract_item.h"
+#include "notification-ex/icon_item.h"
+#include "notification-ex/text_item.h"
+
+namespace notification {
+namespace item {
+
+class EXPORT_API IconTextItem : public AbstractItem {
+ public:
+  IconTextItem(std::string id, std::shared_ptr<IconItem> icon,
+    std::shared_ptr<TextItem> text,
+    std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
+
+  virtual ~IconTextItem();
+
+  Bundle Serialize() override;
+  void Deserialize(Bundle b) override;
+  AbstractItem& FindByID(std::string id) override;
+  IconItem& GetIconItem() const;
+  TextItem& GetTextItem() const;
+
+ private:
+  class Impl;
+  std::unique_ptr<Impl> impl_;
+};  // class IconTextItem
+
+}  // namespace item
+}  // nampace notification
+#endif  // NOTIFICATION_EX_ICON_TEXT_ITEM_H_
diff --git a/notification-ex/icon_text_item_implementation.h b/notification-ex/icon_text_item_implementation.h
new file mode 100644 (file)
index 0000000..87e23bc
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NOTIFICATION_EX_ICON_TEXT_ITEM_IMPLEMENTATION_H_
+#define NOTIFICATION_EX_ICON_TEXT_ITEM_IMPLEMENTATION_H_
+
+#include <string>
+#include <memory>
+#include <list>
+
+#include "notification-ex/icon_text_item.h"
+
+namespace notification {
+namespace item {
+
+class IconTextItem::Impl {
+ public:
+  virtual ~Impl();
+
+ private:
+  friend class IconTextItem;
+  Impl(IconTextItem* parent, std::shared_ptr<IconItem> icon,
+    std::shared_ptr<TextItem> text);
+
+ private:
+  IconTextItem* parent_;
+  std::shared_ptr<IconItem> icon_;
+  std::shared_ptr<TextItem> text_;
+};
+
+}  // namespace item
+}  // nampace notification
+#endif  // NOTIFICATION_EX_ICON_TEXT_ITEM_IMPLEMENTATION_H_
diff --git a/notification-ex/image_item.cc b/notification-ex/image_item.cc
new file mode 100644 (file)
index 0000000..991f16c
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dlog.h>
+
+#include "notification-ex/image_item.h"
+#include "notification-ex/image_item_implementation.h"
+#include "notification-ex/item_factory.h"
+#include "notification-ex/exception.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "NOTIFICATION_EX"
+#define IMAGE_PATH_KEY "__IMAGE_PATH_KEY__"
+
+namespace notification {
+namespace item {
+
+ImageItem::ImageItem(std::string imagePath,
+  std::shared_ptr<AbstractAction> action)
+  : AbstractItem(AbstractItem::Image, action), impl_(new Impl(this, imagePath)) {
+}
+
+ImageItem::ImageItem(std::string id, std::string imagePath,
+  std::shared_ptr<AbstractAction> action)
+  : AbstractItem(id, AbstractItem::Image, action), impl_(new Impl(this, imagePath)) {
+}
+
+ImageItem::Impl::Impl(ImageItem* parent, std::string imagePath)
+  : parent_(parent), imagePath_(imagePath) {
+  LOGI("ImageItem impl created");
+}
+
+Bundle ImageItem::Serialize() {
+  Bundle b;
+  b = AbstractItem::Serialize();
+  b.Add(IMAGE_PATH_KEY, impl_->imagePath_);
+
+  return b;
+}
+
+void ImageItem::Deserialize(Bundle b) {
+  AbstractItem::Deserialize(b);
+
+  impl_->imagePath_ = b.GetString(IMAGE_PATH_KEY);
+}
+
+AbstractItem& ImageItem::FindByID(std::string id) {
+  if (GetId() == id)
+    return *this;
+
+  return ItemFactory::GetNullItem();
+}
+
+std::string ImageItem::GetImagePath() const {
+  return impl_->imagePath_;
+}
+
+ImageItem::~ImageItem() = default;
+ImageItem::Impl::~Impl() = default;
+
+
+}  // namespace item
+}  // namespace notification
diff --git a/notification-ex/image_item.h b/notification-ex/image_item.h
new file mode 100644 (file)
index 0000000..f2e1802
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NOTIFICATION_EX_IMAGE_ITEM_H_
+#define NOTIFICATION_EX_IMAGE_ITEM_H_
+
+#include <string>
+#include <memory>
+#include <list>
+
+#include "notification-ex/abstract_item.h"
+
+namespace notification {
+namespace item {
+
+class EXPORT_API ImageItem : public AbstractItem {
+ public:
+  ImageItem(std::string imagePath,
+    std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
+  ImageItem(std::string id, std::string imagePath,
+    std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
+  virtual ~ImageItem();
+
+  Bundle Serialize() override;
+  void Deserialize(Bundle b) override;
+  AbstractItem& FindByID(std::string id) override;
+  std::string GetImagePath() const;
+
+ private:
+  class Impl;
+  std::unique_ptr<Impl> impl_;
+};  //class ImageItem
+
+}  // namespace item
+}  // nampace notification
+#endif  // NOTIFICATION_EX_IMAGE_ITEM_H_
diff --git a/notification-ex/image_item_implementation.h b/notification-ex/image_item_implementation.h
new file mode 100644 (file)
index 0000000..80396f1
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NOTIFICATION_EX_IMAGE_ITEM_IMPLEMENTATION_H_
+#define NOTIFICATION_EX_IMAGE_ITEM_IMPLEMENTATION_H_
+
+#include <string>
+#include <memory>
+#include <list>
+
+#include "notification-ex/image_item.h"
+
+namespace notification {
+namespace item {
+
+class ImageItem::Impl {
+ public:
+  virtual ~Impl();
+
+ private:
+  friend class ImageItem;
+  Impl(ImageItem* parent, std::string imagePath);
+
+ private:
+  ImageItem* parent_;
+  std::string imagePath_;
+};
+
+}  // namespace item
+}  // nampace notification
+#endif  // NOTIFICATION_EX_IMAGE_ITEM_IMPLEMENTATION_H_
index 8582f4192bb3b8c2b6222414690f795e9ee77884..7e5f6a9b9662c140607958a9c122f4fa16d47ba0 100644 (file)
 namespace notification {
 namespace item {
 
-class EXPORT_API IconItem : public AbstractItem {
- public:
-  IconItem(std::string iconpath);
-  virtual ~IconItem();
-
-  Bundle Serialize() override;
-  void Deserialize(Bundle b) override;
-  AbstractItem& FindByID(std::string id) override;
-
- private:
-  std::string iconPath_ = nullptr;
-};  // class IconItem
-
-class EXPORT_API IconTextItem : public AbstractItem {
- public:
-  IconTextItem(std::string iconpath, std::string text);
-  virtual ~IconTextItem();
-
-  Bundle Serialize() override;
-  void Deserialize(Bundle b) override;
-  AbstractItem& FindByID(std::string id) override;
-  IconItem GetIconItem() const;
-  TextItem GetTextItem() const;
-
- private:
-  std::string iconPath_ = nullptr;
-  std::string text_ = nullptr;
-};  // class IconTextItem
-
-class EXPORT_API ImageItem : public AbstractItem {
- public:
-  ImageItem(std::string imagePath);
-  virtual ~ImageItem();
-
-  Bundle Serialize() override;
-  void Deserialize(Bundle b) override;
-  AbstractItem& FindByID(std::string id) override;
-  std::string GetImagePath() const;
-
- private:
-  std::string imagePath_ = nullptr;
-};  // class ImageItem
-
-class EXPORT_API CheckBoxItem : public AbstractItem {
- public:
-  CheckBoxItem(bool checked);
-  virtual ~CheckBoxItem();
-
-  Bundle Serialize() override;
-  void Deserialize(Bundle b) override;
-  AbstractItem& FindByID(std::string id) override;
-  bool IsChecked() const;
-
-private:
-  bool checked_ = false;
-};  // class CheckBoxItem
-
-class EXPORT_API ChatMessageItem : public AbstractItem {
- public:
-  enum Type {
-    user,
-    sender,
-  };
-
- public:
-  ChatMessageItem();
-  virtual ~ChatMessageItem();
-
-  Bundle Serialize() override;
-  void Deserialize(Bundle b) override;
-  AbstractItem& FindByID(std::string id) override;
-  TextItem GetTextItem() const;
-  TextItem GetDataItem() const;
-  time_t GetTimeItem() const;
-  Type GetType() const;
-};  // class ChatMessageItem
-
 class EXPORT_API CustomItem : public AbstractItem {
  public:
   CustomItem();
index 672bc983904b967ad180016b54a66df2ccd5cb8f..b3a90b155c6d298420f61a1d70ad37e668ecef74 100644 (file)
 #include "notification-ex/exception.h"
 #include "notification-ex/input_selector_item.h"
 #include "notification-ex/progress_item.h"
+#include "notification-ex/icon_item.h"
+#include "notification-ex/icon_text_item.h"
+#include "notification-ex/image_item.h"
+#include "notification-ex/checkbox_item.h"
+#include "notification-ex/chat_message_item.h"
+#include "notification-ex/time_item.h"
 
 #ifdef LOG_TAG
 #undef LOG_TAG
@@ -45,17 +51,17 @@ shared_ptr<AbstractItem> ItemFactory::CreateItem(AbstractItem::Type type) {
   case AbstractItem::Text :
     return make_shared<TextItem>("");
   case AbstractItem::Icon :
-    return make_shared<ButtonItem>("");
+    return make_shared<IconItem>("");
   case AbstractItem::Image :
-    return make_shared<ButtonItem>("");
+    return make_shared<ImageItem>("");
   case AbstractItem::Button :
     return make_shared<ButtonItem>("");
   case AbstractItem::ChatMessage :
-    return make_shared<ButtonItem>("");
+    return make_shared<ChatMessageItem>("", nullptr, nullptr, nullptr, nullptr, ChatMessageItem::Type::user);
   case AbstractItem::CheckBox :
-    return make_shared<ButtonItem>("");
+    return make_shared<CheckBoxItem>("", "");
   case AbstractItem::IconText :
-    return make_shared<ButtonItem>("");
+    return make_shared<IconTextItem>("", nullptr, nullptr);
   case AbstractItem::InputSelector :
     return make_shared<InputSelectorItem>();
   case AbstractItem::Group :
@@ -64,6 +70,8 @@ shared_ptr<AbstractItem> ItemFactory::CreateItem(AbstractItem::Type type) {
     return make_shared<EntryItem>("");
   case AbstractItem::Progress :
     return make_shared<ProgressItem>(0.0, 0.0, 0.0);
+  case AbstractItem::Time :
+    return make_shared<TimeItem>();
   case AbstractItem::Custom :
     return make_shared<ButtonItem>("");
   }
diff --git a/notification-ex/time_item.cc b/notification-ex/time_item.cc
new file mode 100644 (file)
index 0000000..e9b2616
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dlog.h>
+
+#include "notification-ex/time_item.h"
+#include "notification-ex/time_item_implementation.h"
+#include "notification-ex/item_factory.h"
+#include "notification-ex/exception.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "NOTIFICATION_EX"
+#define TIME_KEY "__TIME_KEY__"
+
+namespace notification {
+namespace item {
+
+TimeItem::TimeItem() : AbstractItem(AbstractItem::Time) {
+  time_t current_time;
+  time(&current_time);
+
+  impl_->time_ = current_time;
+}
+
+TimeItem::TimeItem(time_t time, std::shared_ptr<AbstractAction> action)
+  : AbstractItem(AbstractItem::Time, action), impl_(new Impl(this, time)) {
+}
+
+TimeItem::TimeItem(std::string id, time_t time,
+  std::shared_ptr<AbstractAction> action)
+  : AbstractItem(id, AbstractItem::Time, action), impl_(new Impl(this, time)) {
+}
+
+TimeItem::Impl::Impl(TimeItem* parent, time_t time)
+  : parent_(parent), time_(time) {
+  LOGI("TimeItem impl created");
+}
+
+Bundle TimeItem::Serialize() {
+  Bundle b;
+  struct tm* timeinfo;
+  char buf[80] = {0,};
+
+  b = AbstractItem::Serialize();
+
+  //timt_t to tm
+  timeinfo = localtime(&impl_->time_);
+  //tm to str
+  strftime (buf, sizeof(buf), "%s", timeinfo);
+  b.Add(TIME_KEY, std::string(buf));
+
+  return b;
+}
+
+void TimeItem::Deserialize(Bundle b) {
+  std::string time_s;
+  struct tm timeinfo;
+
+  AbstractItem::Deserialize(b);
+  time_s = b.GetString(TIME_KEY);
+
+  //str to tm
+  strptime(time_s.c_str(), "%s", &timeinfo);
+  //tm to time_t
+  impl_->time_ = mktime(&timeinfo);
+}
+
+AbstractItem& TimeItem::FindByID(std::string id) {
+  if (GetId() == id)
+    return *this;
+
+  return ItemFactory::GetNullItem();
+}
+
+time_t TimeItem::GetTime() const {
+  return impl_->time_;
+}
+
+TimeItem::~TimeItem() = default;
+TimeItem::Impl::~Impl() = default;
+
+}  // namespace item
+}  // namespace notification_ex
diff --git a/notification-ex/time_item.h b/notification-ex/time_item.h
new file mode 100644 (file)
index 0000000..c077e6a
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NOTIFICATION_EX_TIME_ITEM_H_
+#define NOTIFICATION_EX_TIME_ITEM_H_
+
+#include <time.h>
+
+#include <string>
+#include <memory>
+#include <list>
+
+#include "notification-ex/abstract_item.h"
+
+namespace notification {
+namespace item {
+
+class EXPORT_API TimeItem : public AbstractItem {
+ public:
+  TimeItem();
+  TimeItem(time_t time,
+    std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
+  TimeItem(std::string id, time_t time,
+    std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
+
+  virtual ~TimeItem();
+
+  Bundle Serialize() override;
+  void Deserialize(Bundle b) override;
+  AbstractItem& FindByID(std::string id) override;
+  time_t GetTime() const;
+
+ private:
+  class Impl;
+  std::unique_ptr<Impl> impl_;
+};  // class TimeItem
+
+}  // namespace item
+}  // nampace notification
+#endif  // NOTIFICATION_EX_TIME_ITEM_H_
diff --git a/notification-ex/time_item_implementation.h b/notification-ex/time_item_implementation.h
new file mode 100644 (file)
index 0000000..9637fde
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NOTIFICATION_EX_TIME_ITEM_IMPLEMENTATION_H_
+#define NOTIFICATION_EX_TIME_ITEM_IMPLEMENTATION_H_
+
+#include <time.h>
+
+#include <string>
+#include <memory>
+#include <list>
+
+#include "notification-ex/time_item.h"
+
+namespace notification {
+namespace item {
+
+class TimeItem::Impl {
+ public:
+  virtual ~Impl();
+
+ private:
+  friend class TimeItem;
+  Impl(TimeItem* parent, time_t time);
+
+ private:
+  TimeItem* parent_;
+  time_t time_;
+};
+
+}  // namespace item
+}  // nampace notification
+#endif  // NOTIFICATION_EX_TIME_ITEM_IMPLEMENTATION_H_
index 86f1a0eafd9c22d513ec370ad3406b0a8bf0a751..d56e3bd00d548e94d865f8d41a754803a0551286 100644 (file)
@@ -38,5 +38,3 @@ TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${notification-ex_unittests_LDFLAGS}
 )
 
 INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin/)
-
-
diff --git a/unittest/src/test_chat_message_item.cc b/unittest/src/test_chat_message_item.cc
new file mode 100644 (file)
index 0000000..2fcfd8a
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include "notification-ex/chat_message_item.h"
+#include "notification-ex/item_inflator.h"
+
+using namespace notification::item;
+
+class ChatMessageItemTest : public ::testing::Test {
+ public:
+  ChatMessageItem* item;
+  ChatMessageItem::Type type = ChatMessageItem::Type::user;
+  std::string id = "chatmessage_id";
+  time_t current_time;
+  virtual void SetUp() {
+    time(&current_time);
+
+    item = new ChatMessageItem(id,
+      std::make_shared<TextItem>("name_id", "name"),
+      std::make_shared<TextItem>("text_id", "text"),
+      std::make_shared<TextItem>("data_id", "data"),
+      std::make_shared<TimeItem>(current_time),type);
+  }
+  virtual void TearDown() {
+    delete item;
+  }
+};
+
+TEST_F(ChatMessageItemTest, create) {
+  EXPECT_NE(ChatMessageItemTest::item, nullptr);
+}
+
+TEST_F(ChatMessageItemTest, FindByID) {
+  AbstractItem& child = ChatMessageItemTest::item->FindByID(ChatMessageItemTest::id);
+  ChatMessageItem& message = static_cast<ChatMessageItem&>(child);
+  ASSERT_EQ(message.GetNameItem().GetContents(), "name");
+  ASSERT_EQ(message.GetTextItem().GetContents(), "text");
+  ASSERT_EQ(message.GetDataItem().GetContents(), "data");
+  ASSERT_EQ(message.GetType(), ChatMessageItemTest::type);
+}
+
+TEST_F(ChatMessageItemTest, FindByIDNullItemReturn) {
+  AbstractItem& child = ChatMessageItemTest::item->FindByID("not_existed_item");
+  ASSERT_EQ(child.GetType(), ChatMessageItem::NullObject);
+}
+
+TEST_F(ChatMessageItemTest, SerializeDeserialize) {
+  Bundle b = ChatMessageItemTest::item->Serialize();
+
+  //ChatMessageItemTest::item->Deserialize(b);
+  //ItemFactory factory;
+  //std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(factory, b);
+  //ASSERT_EQ(ChatMessageItemTest::item->GetType(), gen_item.get()->GetType());
+
+  //ChatMessageItem* gen_image = static_cast<ChatMessageItem*>(gen_item.get());
+  //ASSERT_EQ(ChatMessageItemTest::item->GetNameItem(), gen_image->GetNameItem());
+  //ASSERT_EQ(ChatMessageItemTest::item->GetTextItem(), gen_image->GetTextItem());
+  //ASSERT_EQ(ChatMessageItemTest::item->GetDataItem(), gen_image->GetDataItem());
+  //ASSERT_EQ(ChatMessageItemTest::item->GetType(), gen_image->GetType());
+}
diff --git a/unittest/src/test_checkbox_item.cc b/unittest/src/test_checkbox_item.cc
new file mode 100644 (file)
index 0000000..6fd38dd
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include "notification-ex/checkbox_item.h"
+#include "notification-ex/item_inflator.h"
+
+using namespace notification::item;
+
+class CheckBoxItemTest : public ::testing::Test {
+ public:
+  CheckBoxItem* item;
+  std::string id = "checkbox_id";
+  std::string title = "title";
+  bool isChecked = false;
+  virtual void SetUp() {
+    item = new CheckBoxItem(id, title, isChecked);
+  }
+  virtual void TearDown() {
+    delete item;
+  }
+};
+
+TEST_F(CheckBoxItemTest, create) {
+  EXPECT_NE(CheckBoxItemTest::item, nullptr);
+}
+
+TEST_F(CheckBoxItemTest, FindByID) {
+  AbstractItem& child = CheckBoxItemTest::item->FindByID(CheckBoxItemTest::id);
+  CheckBoxItem& checkbox = static_cast<CheckBoxItem&>(child);
+  ASSERT_EQ(checkbox.GetTitle(), CheckBoxItemTest::title);
+  ASSERT_EQ(checkbox.IsChecked(), CheckBoxItemTest::isChecked);
+}
+
+TEST_F(CheckBoxItemTest, FindByIDNullItemReturn) {
+  AbstractItem& child = CheckBoxItemTest::item->FindByID("not_existed_item");
+  ASSERT_EQ(child.GetType(), CheckBoxItem::NullObject);
+}
+
+TEST_F(CheckBoxItemTest, SerializeDeserialize) {
+  Bundle b = CheckBoxItemTest::item->Serialize();
+
+  ItemFactory factory;
+  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(factory, b);
+  ASSERT_EQ(CheckBoxItemTest::item->GetType(), gen_item.get()->GetType());
+
+  CheckBoxItem* gen_checkbox = static_cast<CheckBoxItem*>(gen_item.get());
+  ASSERT_EQ(CheckBoxItemTest::item->GetTitle(), gen_checkbox->GetTitle());
+}
diff --git a/unittest/src/test_icon_item.cc b/unittest/src/test_icon_item.cc
new file mode 100644 (file)
index 0000000..8deb06d
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include "notification-ex/icon_item.h"
+#include "notification-ex/item_inflator.h"
+
+using namespace notification::item;
+
+class IconItemTest : public ::testing::Test {
+ public:
+  IconItem* item;
+  std::string id = "icon_id";
+  virtual void SetUp() {
+    item = new IconItem(id, "icon_path");
+  }
+  virtual void TearDown() {
+    delete item;
+  }
+};
+
+TEST_F(IconItemTest, create) {
+  EXPECT_NE(IconItemTest::item, nullptr);
+}
+
+TEST_F(IconItemTest, FindByID) {
+  AbstractItem& child = IconItemTest::item->FindByID(IconItemTest::id);
+  IconItem& icon = static_cast<IconItem&>(child);
+  ASSERT_EQ(icon.GetImagePath(), "icon_path");
+}
+
+TEST_F(IconItemTest, FindByIDNullItemReturn) {
+  AbstractItem& child = IconItemTest::item->FindByID("not_existed_item");
+  ASSERT_EQ(child.GetType(), IconItem::NullObject);
+}
+
+TEST_F(IconItemTest, SerializeDeserialize) {
+  Bundle b = IconItemTest::item->Serialize();
+
+  ItemFactory factory;
+  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(factory, b);
+  ASSERT_EQ(IconItemTest::item->GetType(), gen_item.get()->GetType());
+
+  IconItem* gen_icon = static_cast<IconItem*>(gen_item.get());
+  ASSERT_EQ(IconItemTest::item->GetImagePath(), gen_icon->GetImagePath());
+}
diff --git a/unittest/src/test_icon_text_item.cc b/unittest/src/test_icon_text_item.cc
new file mode 100644 (file)
index 0000000..cc6d68b
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include "notification-ex/icon_text_item.h"
+#include "notification-ex/item_inflator.h"
+
+using namespace notification::item;
+
+class IconTextItemTest : public ::testing::Test {
+ public:
+  IconTextItem* item;
+  std::string id = "icontext_id";
+  virtual void SetUp() {
+    item = new IconTextItem(id,
+      std::make_shared<IconItem>("icon_id", "icon_path"),
+      std::make_shared<TextItem>("text_id", "title"));
+  }
+  virtual void TearDown() {
+    delete item;
+  }
+};
+
+TEST_F(IconTextItemTest, create) {
+  EXPECT_NE(IconTextItemTest::item, nullptr);
+}
+
+#if 0
+TEST_F(IconTextItemTest, FindByID) {
+  AbstractItem& child = IconTextItemTest::item->FindByID(IconTextItemTest::id);
+  IconTextItem& icontext = static_cast<IconTextItem&>(child);
+  ASSERT_EQ(icontext.GetIconItem().GetImagePath(), "icon_path");
+  ASSERT_EQ(icontext.GetTextItem().GetContents(), "title");
+}
+#endif
+
+TEST_F(IconTextItemTest, FindByIDNullItemReturn) {
+  AbstractItem& child = IconTextItemTest::item->FindByID("not_existed_item");
+  ASSERT_EQ(child.GetType(), IconItem::NullObject);
+}
+
+TEST_F(IconTextItemTest, SerializeDeserialize) {
+  Bundle b = IconTextItemTest::item->Serialize();
+
+  //ItemFactory factory;
+  //std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(factory, b);
+  //IconTextItem* gen_icon = static_cast<IconTextItem*>(gen_item.get());
+  //ASSERT_EQ(IconTextItemTest::item->GetIconItem(), gen_icon->GetIconItem());
+  //ASSERT_EQ(IconTextItemTest::item->GetTextItem(), gen_icon->GetTextItem());
+}
diff --git a/unittest/src/test_image_item.cc b/unittest/src/test_image_item.cc
new file mode 100644 (file)
index 0000000..42a5caa
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include "notification-ex/image_item.h"
+#include "notification-ex/item_inflator.h"
+
+using namespace notification::item;
+
+class ImageItemTest : public ::testing::Test {
+ public:
+  ImageItem* item;
+  std::string id = "image_id";
+  std::string imagePath = "image_path";
+  virtual void SetUp() {
+    item = new ImageItem(id, imagePath);
+  }
+  virtual void TearDown() {
+    delete item;
+  }
+};
+
+TEST_F(ImageItemTest, create) {
+  EXPECT_NE(ImageItemTest::item, nullptr);
+}
+
+TEST_F(ImageItemTest, FindByID) {
+  AbstractItem& child = ImageItemTest::item->FindByID(ImageItemTest::id);
+  ImageItem& image = static_cast<ImageItem&>(child);
+  ASSERT_EQ(image.GetImagePath(), ImageItemTest::imagePath);
+}
+
+TEST_F(ImageItemTest, FindByIDNullItemReturn) {
+  AbstractItem& child = ImageItemTest::item->FindByID("not_existed_item");
+  ASSERT_EQ(child.GetType(), ImageItem::NullObject);
+}
+
+TEST_F(ImageItemTest, SerializeDeserialize) {
+  Bundle b = ImageItemTest::item->Serialize();
+
+  ItemFactory factory;
+  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(factory, b);
+  ASSERT_EQ(ImageItemTest::item->GetType(), gen_item.get()->GetType());
+
+  ImageItem* gen_image = static_cast<ImageItem*>(gen_item.get());
+  ASSERT_EQ(ImageItemTest::item->GetImagePath(), gen_image->GetImagePath());
+}
diff --git a/unittest/src/test_time_item.cc b/unittest/src/test_time_item.cc
new file mode 100644 (file)
index 0000000..c8a2c86
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include "notification-ex/time_item.h"
+#include "notification-ex/item_inflator.h"
+
+using namespace notification::item;
+
+class TimeItemTest : public ::testing::Test {
+ public:
+  TimeItem* item;
+  time_t current_time;
+  std::string id = "time_id";
+  virtual void SetUp() {
+    time(&current_time);
+    item = new TimeItem(id, current_time);
+  }
+  virtual void TearDown() {
+    delete item;
+  }
+};
+
+TEST_F(TimeItemTest, create) {
+  EXPECT_NE(TimeItemTest::item, nullptr);
+}
+
+TEST_F(TimeItemTest, FindByID) {
+  AbstractItem& child = TimeItemTest::item->FindByID(TimeItemTest::id);
+  TimeItem& time_ = static_cast<TimeItem&>(child);
+  ASSERT_EQ(time_.GetTime(), TimeItemTest::current_time);
+}
+
+TEST_F(TimeItemTest, FindByIDNullItemReturn) {
+  AbstractItem& child = TimeItemTest::item->FindByID("not_existed_item");
+  ASSERT_EQ(child.GetType(), TimeItem::NullObject);
+}
+
+TEST_F(TimeItemTest, SerializeDeserialize) {
+  Bundle b = TimeItemTest::item->Serialize();
+
+  //ItemFactory factory;
+  //std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(factory, b);
+  //ASSERT_EQ(TimeItemTest::item->GetType(), gen_item.get()->GetType());
+
+  //TimeItem* gen_time = static_cast<TimeItem*>(gen_item.get());
+  //ASSERT_EQ(item.GetTime(), gen_time->GetTime());
+}