76b0006a224d949192433cf5dcaa528a2910b014
[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 tizen_base;
24 using namespace notification;
25 using namespace notification::item;
26
27 namespace {
28
29 class EntryItemTest : public ::testing::Test {
30  public:
31   virtual void SetUp() {}
32   virtual void TearDown() {}
33 };
34
35 TEST_F(EntryItemTest, FindByID) {
36   EntryItem item("entry_id");
37
38   AbstractItem& child = item.FindByID("entry_id");
39   EntryItem& btn = static_cast<EntryItem&>(child);
40   ASSERT_EQ(btn.GetId(), "entry_id");
41 }
42
43 TEST_F(EntryItemTest, FindByIDNullItemReturn) {
44   EntryItem item("entry_id");
45
46   AbstractItem& child = item.FindByID("not_existed_item");
47   ASSERT_EQ(child.GetType(), EntryItem::NullObject);
48 }
49
50 TEST_F(EntryItemTest, SerializeDeserialize) {
51   EntryItem item("entry_id");
52
53   Bundle b = item.Serialize();
54   std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
55   ASSERT_EQ(gen_item->GetType(), item.GetType());
56
57   auto gen_effect = std::static_pointer_cast<EntryItem>(gen_item);
58   ASSERT_EQ(item.GetId(), gen_effect->GetId());
59 }
60
61 TEST_F(EntryItemTest, SetTextGetText) {
62   EntryItem item("entry_id");
63   item.SetText("test");
64
65   ASSERT_EQ(item.GetText(), "test");
66 }
67
68 TEST_F(EntryItemTest, GetTextLimit) {
69   EntryItem item("entry_id");
70
71   ASSERT_EQ(item.GetTextLimit(), 160);
72 }
73
74 }  // namespace