Apply gcov ON build
[platform/core/api/notification.git] / unittest / src / test_noti_ex_progress_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 <gmock/gmock.h>
18
19 #include "notification-ex/progress_item.h"
20 #include "notification-ex/item_inflator.h"
21
22 using namespace tizen_base;
23 using namespace notification;
24 using namespace notification::item;
25 using namespace std;
26
27 namespace {
28
29 class ProgressItemTest : public ::testing::Test {
30  protected:
31   void SetUp() override {}
32   void TearDown() override {}
33 };
34
35 TEST_F(ProgressItemTest, SerializeDeserializeGetTitle) {
36   ProgressItem item(1.0, 10.0, 100.0);
37   item.SetDefaultUnit("byte");
38   Bundle b = item.Serialize();
39   shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
40
41   auto gen_progress = std::static_pointer_cast<ProgressItem>(gen_item);
42   ASSERT_EQ(item.GetCurrent(), gen_progress->GetCurrent());
43   ASSERT_EQ(item.GetMin(), gen_progress->GetMin());
44   ASSERT_EQ(item.GetMax(), gen_progress->GetMax());
45   ASSERT_EQ(item.GetType(), gen_progress->GetType());
46   ASSERT_EQ(item.GetDefaultUnit(), gen_progress->GetDefaultUnit());
47
48   ASSERT_EQ(gen_progress->GetMin(), 1.0);
49   ASSERT_EQ(gen_progress->GetCurrent(), 10.0);
50   ASSERT_EQ(gen_progress->GetMax(), 100.0);
51   ASSERT_EQ(gen_progress->GetProgressType(), ProgressItem::Type::Default);
52   ASSERT_EQ(gen_progress->GetDefaultUnit(), "byte");
53 }
54
55 TEST_F(ProgressItemTest, SetGetProgressType) {
56   ProgressItem item(1.0, 10.0, 100.0);
57
58   ASSERT_EQ(item.GetProgressType(), ProgressItem::Type::Default);
59
60   item.SetProgressType(ProgressItem::Type::Pending);
61   ASSERT_EQ(item.GetProgressType(), ProgressItem::Type::Pending);
62 }
63
64 TEST_F(ProgressItemTest, SetGetUnit) {
65   ProgressItem item(1.0, 10.0, 100.0);
66   item.SetDefaultUnit("byte");
67
68   ASSERT_EQ(item.GetDefaultUnit(), "byte");
69 }
70
71 }  // namespace