• 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_sorting_map.h"
21 #undef private
22 #undef protected
23 
24 using namespace testing::ext;
25 namespace OHOS {
26 namespace Notification {
27 class NotificationSortingTest : 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: Marshalling_00001
37  * @tc.desc: Test Marshalling parameters.
38  * @tc.type: FUNC
39  * @tc.require: issue
40  */
41 HWTEST_F(NotificationSortingTest, Marshalling_00001, Function | SmallTest | Level1)
42 {
43     NotificationSorting sorting;
44     Parcel parcel;
45     auto rrc = std::make_shared<NotificationSorting>(sorting);
46     EXPECT_EQ(rrc->Marshalling(parcel), true);
47 }
48 
49 /**
50  * @tc.name: Marshalling_00002
51  * @tc.desc: Test Marshalling parameters.
52  * @tc.type: FUNC
53  * @tc.require: issue
54  */
55 HWTEST_F(NotificationSortingTest, Marshalling_00002, Function | SmallTest | Level1)
56 {
57     NotificationSorting sorting;
58     Parcel parcel;
59     auto rrc = std::make_shared<NotificationSorting>(sorting);
60     rrc->SetKey("");
61     rrc->ReadFromParcel(parcel);
62     EXPECT_EQ(rrc->Marshalling(parcel), true);
63 }
64 
65 /**
66  * @tc.name: Unmarshalling_00001
67  * @tc.desc: Test Unmarshalling parameters.
68  * @tc.type: FUNC
69  * @tc.require: issue
70  */
71 HWTEST_F(NotificationSortingTest, Unmarshalling_001, Function | SmallTest | Level1)
72 {
73     NotificationSorting sorting;
74     bool unmarshalling = true;
75     Parcel parcel;
76     std::shared_ptr<NotificationSorting> result =
77     std::make_shared<NotificationSorting>(sorting);
78 
79     if (nullptr != result) {
80         if (nullptr == result->Unmarshalling(parcel)) {
81             unmarshalling = false;
82         }
83     }
84     EXPECT_EQ(unmarshalling, true);
85 }
86 
87 /**
88  * @tc.name: ReadFromParcel_00001
89  * @tc.desc: Test ReadFromParcel parameters.
90  * @tc.type: FUNC
91  * @tc.require: issueI5WBBH
92  */
93 HWTEST_F(NotificationSortingTest, ReadFromParcel_00001, Function | SmallTest | Level1)
94 {
95     Parcel parcel;
96     NotificationSorting sorting;
97     auto rrc = std::make_shared<NotificationSorting>(sorting);
98     EXPECT_EQ(rrc->ReadFromParcel(parcel), true);
99 }
100 
101 /**
102  * @tc.name: Dump_00001
103  * @tc.desc: Test Dump parameters.
104  * @tc.type: FUNC
105  * @tc.require: issue
106  */
107 HWTEST_F(NotificationSortingTest, Dump_00001, Function | SmallTest | Level1)
108 {
109     NotificationSorting sorting;
110     Parcel parcel;
111     std::string groupKeyOverride = "GroupKeyOverride";
112     std::string key = "Key";
113     int32_t importance = 10;
114     uint64_t ranking = 20;
115     int32_t visibleness =30;
116     bool isDisplayBadge = false;
117     bool isHiddenNotification = true;
118     auto rrc = std::make_shared<NotificationSorting>(sorting);
119     rrc->SetGroupKeyOverride(groupKeyOverride);
120     rrc->SetKey(key);
121     rrc->SetImportance(importance);
122     rrc->SetRanking(ranking);
123     rrc->SetVisiblenessOverride(visibleness);
124     rrc->SetDisplayBadge(isDisplayBadge);
125     rrc->SetHiddenNotification(isHiddenNotification);
126     std::string ret = "NotificationSorting{ key = Key, ranking = 20, "
127     "importance = 10, visiblenessOverride = 30, isDisplayBadge = false, "
128     "isHiddenNotification = true, groupKeyOverride = GroupKeyOverride, "
129     "slot = NotificationSlot{ id = OTHER, name = OTHER, description = , "
130     "type = 3, level = 1, isBypassDnd = false, visibleness = 3, sound = , "
131     "isLightEnabled = false, lightColor = 0, isVibrate = false, "
132     "vibration = , isShowBadge = true, enabled = true } }";
133     EXPECT_EQ(rrc->Dump(), ret);
134 }
135 }
136 }