2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include <gtest/gtest.h>
18 #include <gmock/gmock.h>
20 #include "notification-ex/text_item.h"
21 #include "notification-ex/item_inflator.h"
23 using namespace notification;
24 using namespace notification::item;
28 class TexttItemTest : public ::testing::Test {
30 virtual void SetUp() {
32 virtual void TearDown() {
36 TEST_F(TexttItemTest, FindByID) {
37 TextItem item("text_id", "contents", "hyperlink");
39 AbstractItem& child = item.FindByID("text_id");
40 TextItem& btn = static_cast<TextItem&>(child);
41 ASSERT_EQ(btn.GetContents(), "contents");
44 TEST_F(TexttItemTest, FindByIDNullItemReturn) {
45 TextItem item("text_id", "contents", "hyperlink");
47 AbstractItem& child = item.FindByID("not_existed_item");
48 ASSERT_EQ(child.GetType(), TextItem::NullObject);
51 TEST_F(TexttItemTest, SerializeDeserializeGetContents) {
52 TextItem item("text_id", "contents");
53 Bundle b = item.Serialize();
54 std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
55 ASSERT_EQ(gen_item->GetType(), item.GetType());
57 auto gen_text = std::static_pointer_cast<TextItem>(gen_item);
58 ASSERT_EQ(item.GetContents(), gen_text->GetContents());
61 TEST_F(TexttItemTest, SetContentsGetContents) {
62 TextItem item("text_id", "contents");
63 ASSERT_EQ(item.GetContents(), "contents");
65 item.SetContents("changed");
66 ASSERT_EQ(item.GetContents(), "changed");
69 TEST_F(TexttItemTest, GetHyperLink) {
70 TextItem item("text_id", "contents");
71 ASSERT_TRUE(item.GetHyperLink().empty());
73 TextItem item2("text_id", "contents", "hyperlink2");
74 ASSERT_EQ(item2.GetHyperLink(), "hyperlink2");