• 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 "message_user.h"
21 #undef private
22 #undef protected
23 
24 using namespace testing::ext;
25 namespace OHOS {
26 namespace Notification {
27 class MessageUserTest : 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: FromJson_00001
37  * @tc.desc: Test FromJson parameters.
38  * @tc.type: FUNC
39  * @tc.require: issue
40  */
41 HWTEST_F(MessageUserTest, FromJson_00001, Function | SmallTest | Level1)
42 {
43     sptr<MessageUser> messageUser = nullptr;
44     nlohmann::json jsonObject;
45     EXPECT_EQ(messageUser ->FromJson(jsonObject), nullptr);
46 }
47 
48 /**
49  * @tc.name: Unmarshalling_00001
50  * @tc.desc: Test Unmarshalling parameters.
51  * @tc.type: FUNC
52  * @tc.require: issue
53  */
54 HWTEST_F(MessageUserTest, Unmarshalling_001, Function | SmallTest | Level1)
55 {
56     bool unmarshalling = true;
57     Parcel parcel;
58     std::shared_ptr<MessageUser> result = std::make_shared<MessageUser>();
59 
60     if (nullptr != result) {
61         if (nullptr == result->Unmarshalling(parcel)) {
62             unmarshalling = false;
63         }
64     }
65     EXPECT_EQ(unmarshalling, false);
66 }
67 
68 /**
69  * @tc.name: ReadFromParcel_00001
70  * @tc.desc: Test ReadFromParcel parameters.
71  * @tc.type: FUNC
72  * @tc.require: issue
73  */
74 HWTEST_F(MessageUserTest, ReadFromParcel_00001, Function | SmallTest | Level1)
75 {
76     MessageUser messageUser;
77     Parcel parcel;
78 
79     EXPECT_EQ(messageUser.ReadFromParcel(parcel), false);
80 }
81 
82 /**
83  * @tc.name: ReadFromParcel_00002
84  * @tc.desc: Test ReadFromParcel parameters.
85  * @tc.type: FUNC
86  * @tc.require: issue
87  */
88 HWTEST_F(MessageUserTest, ReadFromParcel_00002, Function | SmallTest | Level1)
89 {
90     MessageUser messageUser;
91     Parcel parcel;
92     int32_t empty = 10;
93 
94     parcel.WriteInt32(empty);
95     EXPECT_EQ(messageUser.ReadFromParcel(parcel), false);
96 }
97 }
98 }