1 /*
2  * Copyright (c) 2024 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 #include "notification_check_request.h"
19 
20 using namespace testing::ext;
21 namespace OHOS {
22 namespace Notification {
23 class NotificationCheckRequestTest : public testing::Test {
24 public:
SetUpTestCase()25     static void SetUpTestCase() {}
TearDownTestCase()26     static void TearDownTestCase() {}
SetUp()27     void SetUp() {}
TearDown()28     void TearDown() {}
29 };
30 
31 /**
32  * @tc.name: SetContentType_00001
33  * @tc.desc: Test SetContentType.
34  * @tc.type: FUNC
35  * @tc.require: issue
36  */
37 HWTEST_F(NotificationCheckRequestTest, SetContentType_00001, Function | SmallTest | Level1)
38 {
39     NotificationCheckRequest checkRequest;
40     checkRequest.SetContentType(NotificationContent::Type::BASIC_TEXT);
41     EXPECT_EQ(NotificationContent::Type::BASIC_TEXT, checkRequest.GetContentType());
42 }
43 
44 /**
45  * @tc.name: SetSlotType_00001
46  * @tc.desc: Test SetSlotType.
47  * @tc.type: FUNC
48  * @tc.require: issue
49  */
50 HWTEST_F(NotificationCheckRequestTest, SetSlotType_00001, Function | SmallTest | Level1)
51 {
52     NotificationCheckRequest checkRequest;
53     checkRequest.SetSlotType(NotificationConstant::SlotType::LIVE_VIEW);
54     EXPECT_EQ(NotificationConstant::SlotType::LIVE_VIEW, checkRequest.GetSlotType());
55 }
56 
57 /**
58  * @tc.name: SetExtraKeys_00001
59  * @tc.desc: Test SetExtraKeys.
60  * @tc.type: FUNC
61  * @tc.require: issue
62  */
63 HWTEST_F(NotificationCheckRequestTest, SetExtraKeys_00001, Function | SmallTest | Level1)
64 {
65     NotificationCheckRequest checkRequest;
66     std::vector<std::string> vector;
67     vector.emplace_back("test1");
68     checkRequest.SetExtraKeys(vector);
69     auto getVector = checkRequest.GetExtraKeys();
70     EXPECT_EQ(1, getVector.size());
71 }
72 
73 /**
74  * @tc.name: SetUid_00001
75  * @tc.desc: Test SetUid.
76  * @tc.type: FUNC
77  * @tc.require: issue
78  */
79 HWTEST_F(NotificationCheckRequestTest, SetUid_00001, Function | SmallTest | Level1)
80 {
81     NotificationCheckRequest checkRequest;
82     checkRequest.SetUid(1);
83     EXPECT_EQ(1, checkRequest.GetUid());
84 }
85 
86 /**
87  * @tc.name: Marshalling_00001
88  * @tc.desc: Test Marshalling.
89  * @tc.type: FUNC
90  * @tc.require: issue
91  */
92 HWTEST_F(NotificationCheckRequestTest, Marshalling_00001, Function | SmallTest | Level1)
93 {
94     Parcel parcel;
95     NotificationCheckRequest checkRequest;
96     std::vector<std::string> vector;
97     vector.emplace_back("test1");
98     checkRequest.SetExtraKeys(vector);
99     EXPECT_EQ(true, checkRequest.Marshalling(parcel));
100     EXPECT_NE(checkRequest.Unmarshalling(parcel), nullptr);
101 }
102 }
103 }
104