Improve unit TCs
[platform/core/api/notification.git] / unittest / src / test_entry_item.cc
1 /*
2  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include <gtest/gtest.h>
18 #include <gmock/gmock.h>
19
20 #include "notification-ex/entry_item.h"
21 #include "notification-ex/item_inflator.h"
22
23 using namespace notification;
24 using namespace notification::item;
25
26 namespace {
27
28 class EntryItemTest : public ::testing::Test {
29  public:
30   virtual void SetUp() {}
31   virtual void TearDown() {}
32 };
33
34 TEST_F(EntryItemTest, FindByID) {
35   EntryItem item("entry_id");
36
37   AbstractItem& child = item.FindByID("entry_id");
38   EntryItem& btn = static_cast<EntryItem&>(child);
39   ASSERT_EQ(btn.GetId(), "entry_id");
40 }
41
42 TEST_F(EntryItemTest, FindByIDNullItemReturn) {
43   EntryItem item("entry_id");
44
45   AbstractItem& child = item.FindByID("not_existed_item");
46   ASSERT_EQ(child.GetType(), EntryItem::NullObject);
47 }
48
49 TEST_F(EntryItemTest, SerializeDeserialize) {
50   EntryItem item("entry_id");
51   Bundle b = item.Serialize();
52   std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
53   ASSERT_EQ(gen_item->GetType(), item.GetType());
54
55   auto gen_effect = std::static_pointer_cast<EntryItem>(gen_item);
56   ASSERT_EQ(item.GetId(), gen_effect->GetId());
57 }
58
59 TEST_F(EntryItemTest, SetTextGetText) {
60   EntryItem item("entry_id");
61   item.SetText("test");
62
63   ASSERT_EQ(item.GetText(), "test");
64 }
65
66 TEST_F(EntryItemTest, GetTextLimit) {
67   EntryItem item("entry_id");
68
69   ASSERT_EQ(item.GetTextLimit(), 160);
70 }
71
72 }  // namespace