• 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 NotificationSortingMapTest : 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: SetKey_00001
37  * @tc.desc: Test SetKey parameters.
38  * @tc.type: FUNC
39  * @tc.require: issue
40  */
41 HWTEST_F(NotificationSortingMapTest, SetKey_00001, Function | SmallTest | Level1)
42 {
43     std::vector<NotificationSorting> sortingList;
44     std::string key = "Key";
45     auto rrc = std::make_shared<NotificationSortingMap>(sortingList);
46     NotificationSorting sorting;
47     rrc->SetNotificationSorting(sortingList);
48     EXPECT_EQ(rrc->GetNotificationSorting(key, sorting), false);
49 }
50 
51 /**
52  * @tc.name: Marshalling_00001
53  * @tc.desc: Test Marshalling parameters.
54  * @tc.type: FUNC
55  * @tc.require: issue
56  */
57 HWTEST_F(NotificationSortingMapTest, Marshalling_00001, Function | SmallTest | Level1)
58 {
59     std::vector<NotificationSorting> sortingList;
60     Parcel parcel;
61     auto rrc = std::make_shared<NotificationSortingMap>(sortingList);
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(NotificationSortingMapTest, Unmarshalling_001, Function | SmallTest | Level1)
72 {
73     std::vector<NotificationSorting> sortingList;
74     bool unmarshalling = true;
75     Parcel parcel;
76     std::shared_ptr<NotificationSortingMap> result =
77     std::make_shared<NotificationSortingMap>(sortingList);
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: Dump_00001
89  * @tc.desc: Test Dump parameters.
90  * @tc.type: FUNC
91  * @tc.require: issue
92  */
93 HWTEST_F(NotificationSortingMapTest, Dump_00001, Function | SmallTest | Level1)
94 {
95     std::vector<NotificationSorting> sortingList;
96     std::string key = "Key";
97     auto rrc = std::make_shared<NotificationSortingMap>(sortingList);
98     rrc->SetKey(key);
99     std::string ret = "NotificationSortingMap{ sortedkey = [Key, ] }";
100     EXPECT_EQ(rrc->Dump(), ret);
101 }
102 }
103 }