#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"
nullptr, nullptr, nullptr, nullptr, ChatMessageItem::Type::user));
case AbstractItem::CheckBox :
return unique_ptr<AbstractItem>(new CheckBoxItem("", ""));
- case AbstractItem::IconText :
- return unique_ptr<AbstractItem>(new IconTextItem("", nullptr, nullptr));
case AbstractItem::InputSelector :
return unique_ptr<AbstractItem>(new InputSelectorItem());
case AbstractItem::Group :
+++ /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/factory_manager.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__"
-
-using namespace tizen_base;
-
-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(id, 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");
-}
-
-int IconTextItem::GetType() const {
- return AbstractItem::IconText;
-}
-
-Bundle IconTextItem::Serialize() const {
- 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) {
- AbstractItem::Deserialize(b);
-
- std::shared_ptr<AbstractItem> icon =
- FactoryManager::GetInst().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 =
- FactoryManager::GetInst().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;
-
- if (impl_->icon_->GetId() == id)
- return *(impl_->icon_);
-
- if (impl_->text_->GetId() == id)
- return *(impl_->text_);
-
- return FactoryManager::GetInst().GetNullItem();
-}
-
-AbstractItem& IconTextItem::FindByMainType(MainType type) {
- if (GetMainType() == type)
- return *this;
-
- if (impl_->icon_->GetMainType() == type)
- return *(impl_->icon_);
-
- if (impl_->text_->GetMainType() == type)
- return *(impl_->text_);
-
- return FactoryManager::GetInst().GetNullItem();
-}
-
-bool IconTextItem::IsItemTypeExist(int type) {
- if (GetType() == type)
- return true;
- return false;
-}
-
-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
+++ /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 {
-
-/**
- * @brief The class for IconTextItem type notification.
- * @details The class to make the notification with icon and text.
- * @since_tizen 5.5
- */
-class EXPORT_API IconTextItem : public AbstractItem {
- public:
- /**
- * @brief Constructor
- * @since_tizen 5.5
- * @param[in] id The IconTextItem id
- * @param[in] icon The icon of IconTextItem
- * @param[in] text The text of IconTextItem
- * @param[in] action The action for IconTextItem
- */
- IconTextItem(std::string id, std::shared_ptr<IconItem> icon,
- std::shared_ptr<TextItem> text,
- std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
-
- /**
- * @brief Destructor
- * @since_tizen 5.5
- */
- virtual ~IconTextItem();
-
- /**
- * @brief Serialize the data of IconTextItem.
- * @since_tizen 5.5
- * @return Bundle type data
- */
- tizen_base::Bundle Serialize() const override;
-
- /**
- * @brief Deserialize the serialized data.
- * @since_tizen 5.5
- * @param[in] b The serialized Bundle data
- */
- void Deserialize(tizen_base::Bundle b) override;
-
- /**
- * @brief Finds the AbstractItem using by notification item id.
- * @since_tizen 5.5
- * @param[in] id notification item id
- * @return AbstractItem object
- */
- AbstractItem& FindByID(std::string id) override;
-
- /**
- * @brief Finds the AbstractItem using by main type.
- * @since_tizen 5.5
- * @param[in] type The main type
- * @return AbstractItem object
- */
- AbstractItem& FindByMainType(MainType type) override;
-
- /**
- * @brief Checks the item type exist in this notification.
- * @since_tizen 5.5
- * @param[in] type notification item type
- * @return true if the item type exists
- */
- bool IsItemTypeExist(int type) override;
-
- /**
- * @brief Gets the type of IconTextItem.
- * @since_tizen 5.5
- * @return AbstractItem::Type::IconText
- */
- int GetType() const override;
-
- /**
- * @brief Gets the IconItem of IconTextItem.
- * @since_tizen 5.5
- * @return The IconItem object
- */
- IconItem& GetIconItem() const;
-
- /**
- * @brief Gets the TextItem of IconTextItem.
- * @since_tizen 5.5
- * @return The TextItem object
- */
- TextItem& GetTextItem() const;
-
- private:
- class Impl;
- std::unique_ptr<Impl> impl_;
-}; // class IconTextItem
-
-} // namespace item
-} // namespace 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
-} // namespace 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 <gtest/gtest.h>
-#include <gmock/gmock.h>
-
-#include "notification-ex/icon_text_item.h"
-#include "notification-ex/item_inflator.h"
-
-using namespace tizen_base;
-using namespace notification;
-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);
-}
-
-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");
-}
-
-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();
-
- std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
- auto gen_icon = std::static_pointer_cast<IconTextItem>(gen_item);
- ASSERT_EQ(IconTextItemTest::item->GetIconItem().GetImagePath(), gen_icon->GetIconItem().GetImagePath());
- ASSERT_EQ(IconTextItemTest::item->GetTextItem().GetContents(), gen_icon->GetTextItem().GetContents());
-}