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 "mock/app_common_mock.hh"
20 #include "mock/test_fixture.hh"
21 #include "notification-ex/event_info_internal.h"
23 using namespace tizen_base;
24 using namespace notification;
29 virtual public ::testing::NiceMock<AppCommonMock> {};
32 class EventInfoTest : public TestFixture {
34 EventInfoTest() : TestFixture(std::make_unique<::Mocks>()) {}
36 void SetUp() override {}
37 void TearDown() override {}
40 TEST_F(EventInfoTest, SerializeDeserialize) {
41 EventInfo info(EventInfo::Get, "test", "channel", "id");
42 Bundle b = info.Serialize();
43 EventInfo serialized(b);
44 ASSERT_EQ(serialized.GetEventType(), info.GetEventType());
45 ASSERT_EQ(serialized.GetOwner(), info.GetOwner());
46 ASSERT_EQ(serialized.GetChannel(), info.GetChannel());
47 ASSERT_EQ(serialized.GetItemId(), info.GetItemId());
48 ASSERT_EQ(serialized.GetUid(), info.GetUid());
51 TEST_F(EventInfoTest, GetString) {
52 ASSERT_EQ(EventInfo::GetString(EventInfo::Post), "Post");
53 ASSERT_EQ(EventInfo::GetString(EventInfo::Update), "Update");
54 ASSERT_EQ(EventInfo::GetString(EventInfo::Delete), "Delete");
55 ASSERT_EQ(EventInfo::GetString(EventInfo::Get), "Get");
58 TEST_F(EventInfoTest, GetSetEventType) {
59 EventInfo info(EventInfo::Get, "test", "channel", "id");
60 info.SetEventType(EventInfo::Post);
61 int type = info.GetEventType();
62 EXPECT_EQ(type, EventInfo::Post);
65 TEST_F(EventInfoTest, GetSetValidOwner) {
66 EventInfo info(EventInfo::Get, "test", "channel", "id");
67 info.SetValidatedOwner("testowner");
68 std::string owner = info.GetValidatedOwner();
69 EXPECT_STREQ(owner.c_str(), "testowner");
72 TEST_F(EventInfoTest, GetSetUid) {
73 EventInfo info(EventInfo::Get, "test", "channel", "id");
75 uid_t my_uid = info.GetUid();
76 EXPECT_EQ(my_uid, 5001);
79 TEST_F(EventInfoTest, GetSetValidUid) {
80 EventInfo info(EventInfo::Get, "test", "channel", "id");
81 info.SetValidatedUid(5001);
82 uid_t my_uid = info.GetValidatedUid();
83 EXPECT_EQ(my_uid, 5001);
86 TEST_F(EventInfoTest, GetSetError) {
87 EventInfo info(EventInfo::Get, "test", "channel", "id");
88 info.SetError(NotificationError::ERROR_NONE);
89 NotificationError err = info.GetError();
90 EXPECT_EQ(err, NotificationError::ERROR_NONE);