• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <gtest/gtest.h>
17 
18 #define private public
19 #define protected public
20 #include "notification_operation_info.h"
21 #undef private
22 #undef protected
23 
24 using namespace testing::ext;
25 namespace OHOS {
26 namespace Notification {
27 class NotificationOperationInfoTest : public testing::Test {
28 public:
SetUpTestCase()29     static void SetUpTestCase() {}
TearDownTestCase()30     static void TearDownTestCase() {}
SetUp()31     void SetUp() {}
TearDown()32     void TearDown() {}
33 };
34 
35 /**
36  * @tc.name: SetJumpType_0100
37  * @tc.desc: Test SetJumpType.
38  * @tc.type: FUNC
39  * @tc.require: issueI5WBBH
40  */
41 HWTEST_F(NotificationOperationInfoTest, SetJumpType_0100, Function | SmallTest | Level1)
42 {
43     NotificationOperationInfo notificationOperationInfo;
44     notificationOperationInfo.SetJumpType(1);
45     EXPECT_EQ(notificationOperationInfo.GetJumpType(), 1);
46 }
47 
48 /**
49  * @tc.name: SetBtnIndex_0100
50  * @tc.desc: Test SetBtnIndex.
51  * @tc.type: FUNC
52  * @tc.require: issueI5WBBH
53  */
54 HWTEST_F(NotificationOperationInfoTest, SetBtnIndex_0100, Function | SmallTest | Level1)
55 {
56     NotificationOperationInfo notificationOperationInfo;
57     notificationOperationInfo.SetBtnIndex(2);
58     EXPECT_EQ(notificationOperationInfo.GetBtnIndex(), 2);
59 }
60 
61 /**
62  * @tc.name: Dump_0100
63  * @tc.desc: Test Dump.
64  * @tc.type: FUNC
65  * @tc.require: issueI5WBBH
66  */
67 HWTEST_F(NotificationOperationInfoTest, Dump_0100, Function | SmallTest | Level1)
68 {
69     NotificationOperationInfo notificationOperationInfo;
70     std::string expString = "NotificationOperationInfo{ hashCode = hashCode, eventId = 1, actionName = actionName, " \
71     "operationType = 0, btnIndex = 2, jumpType = 1 }";
72     notificationOperationInfo.SetHashCode("hashCode");
73     notificationOperationInfo.SetEventId("1");
74     notificationOperationInfo.SetActionName("actionName");
75     notificationOperationInfo.SetOperationType(OperationType::DISTRIBUTE_OPERATION_JUMP);
76     notificationOperationInfo.SetJumpType(1);
77     notificationOperationInfo.SetBtnIndex(2);
78     EXPECT_EQ(notificationOperationInfo.Dump(), expString);
79 }
80 
81 /**
82  * @tc.name: Marshalling_0100
83  * @tc.desc: Test Marshalling.
84  * @tc.type: FUNC
85  * @tc.require: issueI5WBBH
86  */
87 HWTEST_F(NotificationOperationInfoTest, Marshalling_0100, Function | SmallTest | Level1)
88 {
89     Parcel parcel;
90     NotificationOperationInfo notificationOperationInfo;
91     notificationOperationInfo.SetHashCode("hashCode");
92     notificationOperationInfo.SetEventId("1");
93     notificationOperationInfo.SetActionName("actionName");
94     notificationOperationInfo.SetOperationType(OperationType::DISTRIBUTE_OPERATION_JUMP);
95     notificationOperationInfo.SetBtnIndex(2);
96     notificationOperationInfo.SetJumpType(1);
97     notificationOperationInfo.SetNotificationUdid("udid");
98     EXPECT_TRUE(notificationOperationInfo.Marshalling(parcel));
99     sptr<NotificationOperationInfo> ntfOperInfoRes = notificationOperationInfo.Unmarshalling(parcel);
100     EXPECT_NE(ntfOperInfoRes, nullptr);
101     EXPECT_EQ(ntfOperInfoRes->GetBtnIndex(), 2);
102     EXPECT_EQ(ntfOperInfoRes->GetJumpType(), 1);
103     EXPECT_EQ(ntfOperInfoRes->GetNotificationUdid(), "udid");
104 }
105 }
106 }