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_item.h"
21 #include "notification-ex/item_inflator.h"
23 using namespace notification;
24 using namespace notification::item;
26 class IconItemTest : public ::testing::Test {
29 std::string id = "icon_id";
30 virtual void SetUp() {
31 item = new IconItem(id, "icon_path");
33 virtual void TearDown() {
38 TEST_F(IconItemTest, create) {
39 EXPECT_NE(IconItemTest::item, nullptr);
42 TEST_F(IconItemTest, FindByID) {
43 AbstractItem& child = IconItemTest::item->FindByID(IconItemTest::id);
44 IconItem& icon = static_cast<IconItem&>(child);
45 ASSERT_EQ(icon.GetImagePath(), "icon_path");
48 TEST_F(IconItemTest, FindByIDNullItemReturn) {
49 AbstractItem& child = IconItemTest::item->FindByID("not_existed_item");
50 ASSERT_EQ(child.GetType(), IconItem::NullObject);
53 TEST_F(IconItemTest, SerializeDeserialize) {
54 Bundle b = IconItemTest::item->Serialize();
56 std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
57 ASSERT_EQ(IconItemTest::item->GetType(), gen_item->GetType());
59 auto gen_icon = std::static_pointer_cast<IconItem>(gen_item);
60 ASSERT_EQ(IconItemTest::item->GetImagePath(), gen_icon->GetImagePath());