Group,
Entry,
Progress,
+ Time,
Custom,
};
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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_
--- /dev/null
+/*
+ * 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_
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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_
--- /dev/null
+/*
+ * 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_
--- /dev/null
+/*
+ * 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
+
--- /dev/null
+/*
+ * 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_
--- /dev/null
+/*
+ * 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_
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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_
--- /dev/null
+/*
+ * 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_
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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_
--- /dev/null
+/*
+ * 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_
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();
#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
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 :
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>("");
}
--- /dev/null
+/*
+ * 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(¤t_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
--- /dev/null
+/*
+ * 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_
--- /dev/null
+/*
+ * 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_
)
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin/)
-
-
--- /dev/null
+/*
+ * 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(¤t_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());
+}
--- /dev/null
+/*
+ * 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());
+}
--- /dev/null
+/*
+ * 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());
+}
--- /dev/null
+/*
+ * 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());
+}
--- /dev/null
+/*
+ * 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());
+}
--- /dev/null
+/*
+ * 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(¤t_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());
+}