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 <gmock/gmock.h>
19 #include "notification-ex/progress_item.h"
20 #include "notification-ex/item_inflator.h"
22 using namespace tizen_base;
23 using namespace notification;
24 using namespace notification::item;
29 class ProgressItemTest : public ::testing::Test {
31 void SetUp() override {}
32 void TearDown() override {}
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);
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());
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");
55 TEST_F(ProgressItemTest, SetGetProgressType) {
56 ProgressItem item(1.0, 10.0, 100.0);
58 ASSERT_EQ(item.GetProgressType(), ProgressItem::Type::Default);
60 item.SetProgressType(ProgressItem::Type::Pending);
61 ASSERT_EQ(item.GetProgressType(), ProgressItem::Type::Pending);
64 TEST_F(ProgressItemTest, SetGetUnit) {
65 ProgressItem item(1.0, 10.0, 100.0);
66 item.SetDefaultUnit("byte");
68 ASSERT_EQ(item.GetDefaultUnit(), "byte");