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/icon_text_item.h"
21 #include "notification-ex/item_inflator.h"
23 using namespace notification;
24 using namespace notification::item;
26 class IconTextItemTest : public ::testing::Test {
29 std::string id = "icontext_id";
30 virtual void SetUp() {
31 item = new IconTextItem(id,
32 std::make_shared<IconItem>("icon_id", "icon_path"),
33 std::make_shared<TextItem>("text_id", "title"));
35 virtual void TearDown() {
40 TEST_F(IconTextItemTest, create) {
41 EXPECT_NE(IconTextItemTest::item, nullptr);
44 TEST_F(IconTextItemTest, FindByID) {
45 AbstractItem& child = IconTextItemTest::item->FindByID(IconTextItemTest::id);
46 IconTextItem& icontext = static_cast<IconTextItem&>(child);
47 ASSERT_EQ(icontext.GetIconItem().GetImagePath(), "icon_path");
48 ASSERT_EQ(icontext.GetTextItem().GetContents(), "title");
51 TEST_F(IconTextItemTest, FindByIDNullItemReturn) {
52 AbstractItem& child = IconTextItemTest::item->FindByID("not_existed_item");
53 ASSERT_EQ(child.GetType(), IconItem::NullObject);
56 TEST_F(IconTextItemTest, SerializeDeserialize) {
57 Bundle b = IconTextItemTest::item->Serialize();
59 std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
60 auto gen_icon = std::static_pointer_cast<IconTextItem>(gen_item);
61 ASSERT_EQ(IconTextItemTest::item->GetIconItem().GetImagePath(), gen_icon->GetIconItem().GetImagePath());
62 ASSERT_EQ(IconTextItemTest::item->GetTextItem().GetContents(), gen_icon->GetTextItem().GetContents());