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.
19 #include <gtest/gtest.h>
20 #include <gmock/gmock.h>
22 #include "notification-ex/visibility_action.h"
23 #include "notification-ex/action_inflator.h"
25 using namespace notification;
26 using namespace notification::item;
28 class VisibilityActionTest : public ::testing::Test {
30 VisibilityAction* visibility;
31 std::string id = "visibility_id";
32 std::string extra = "visibility_extra";
35 virtual void SetUp() {
36 visibility = new VisibilityAction(extra);
37 visibility->SetVisibility("visibility_id", visible);
39 virtual void TearDown() {
44 TEST_F(VisibilityActionTest, create) {
45 EXPECT_NE(VisibilityActionTest::visibility, nullptr);
48 TEST_F(VisibilityActionTest, IsLocal) {
49 ASSERT_EQ(VisibilityActionTest::visibility->IsLocal(), 1);
52 TEST_F(VisibilityActionTest, GetExtra) {
53 ASSERT_EQ(VisibilityActionTest::visibility->GetExtra(),
54 VisibilityActionTest::extra);
57 TEST_F(VisibilityActionTest, SerializeDeserialize) {
58 Bundle b = VisibilityActionTest::visibility->Serialize();
60 std::shared_ptr<AbstractAction> gen_action = ActionInflator::Create(b);
61 ASSERT_EQ(gen_action->GetType(), AbstractAction::Visibility);
63 auto gen_visibility_action =
64 std::static_pointer_cast<VisibilityAction>(gen_action);
65 EXPECT_NE(gen_visibility_action, nullptr);
66 ASSERT_EQ(gen_visibility_action->IsLocal(), true);
67 ASSERT_EQ(gen_visibility_action->GetExtra(), VisibilityActionTest::extra);
70 TEST_F(VisibilityActionTest, SetVisibility) {
71 VisibilityActionTest::visibility->SetVisibility("test_id", true);
72 Bundle b = VisibilityActionTest::visibility->Serialize();
74 std::shared_ptr<AbstractAction> gen_action = ActionInflator::Create(b);
75 ASSERT_EQ(gen_action->GetType(), AbstractAction::Visibility);
77 auto gen_visibility_action =
78 std::static_pointer_cast<VisibilityAction>(gen_action);
79 EXPECT_NE(gen_visibility_action, nullptr);
80 ASSERT_EQ(gen_visibility_action->IsLocal(), true);
81 ASSERT_EQ(gen_visibility_action->GetExtra(), VisibilityActionTest::extra);