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 #include "message_parcel.h"
19 #include "net_mgr_log_wrapper.h"
20 #include "net_supplier_info.h"
21
22 namespace OHOS {
23 namespace NetManagerStandard {
24 using namespace testing::ext;
25 class NetSupplierInfoTest : public testing::Test {
26 public:
27 static void SetUpTestCase();
28 static void TearDownTestCase();
29 void SetUp();
30 void TearDown();
31 };
32
SetUpTestCase()33 void NetSupplierInfoTest::SetUpTestCase() {}
34
TearDownTestCase()35 void NetSupplierInfoTest::TearDownTestCase() {}
36
SetUp()37 void NetSupplierInfoTest::SetUp() {}
38
TearDown()39 void NetSupplierInfoTest::TearDown() {}
40
41 /**
42 * @tc.name: MarshallingTest001
43 * @tc.desc: Test NetSupplierInfo::Marshalling
44 * @tc.type: FUNC
45 */
46 HWTEST_F(NetSupplierInfoTest, MarshallingTest001, TestSize.Level1)
47 {
48 MessageParcel data;
49 sptr<NetSupplierInfo> info = nullptr;
50 bool bRet = NetSupplierInfo::Marshalling(data, info);
51 ASSERT_FALSE(bRet);
52 sptr<NetSupplierInfo> retInf = NetSupplierInfo::Unmarshalling(data);
53 ASSERT_EQ(retInf, nullptr);
54 }
55
56 /**
57 * @tc.name: MarshallingTest002
58 * @tc.desc: Test NetSupplierInfo::Marshalling
59 * @tc.type: FUNC
60 */
61 HWTEST_F(NetSupplierInfoTest, MarshallingTest002, TestSize.Level1)
62 {
63 MessageParcel data;
64 sptr<NetSupplierInfo> info = new (std::nothrow) NetSupplierInfo();
65 ASSERT_NE(info, nullptr);
66 bool bRet = info->Marshalling(data);
67 ASSERT_TRUE(bRet);
68 sptr<NetSupplierInfo> retInf = NetSupplierInfo::Unmarshalling(data);
69 ASSERT_NE(retInf, nullptr);
70 }
71
72 /**
73 * @tc.name: MarshallingTest003
74 * @tc.desc: Test NetSupplierInfo::Marshalling
75 * @tc.type: FUNC
76 */
77 HWTEST_F(NetSupplierInfoTest, MarshallingTest003, TestSize.Level1)
78 {
79 MessageParcel data;
80 NetSupplierInfo info;
81 bool bRet = info.Marshalling(data);
82 ASSERT_TRUE(bRet);
83 }
84
85 /**
86 * @tc.name: UnmarshallingTest001
87 * @tc.desc: Test NetSupplierInfo::UnmarshallingTest
88 * @tc.type: FUNC
89 */
90 HWTEST_F(NetSupplierInfoTest, UnmarshallingTest001, TestSize.Level1)
91 {
92 MessageParcel data;
93 sptr<NetSupplierInfo> info = new (std::nothrow) NetSupplierInfo();
94 ASSERT_NE(info, nullptr);
95 bool bRet = NetSupplierInfo::Marshalling(data, info);
96 ASSERT_TRUE(bRet == true);
97 sptr<NetSupplierInfo> retInf = NetSupplierInfo::Unmarshalling(data);
98 ASSERT_TRUE(retInf != nullptr);
99
100 bRet = info->Marshalling(data);
101 ASSERT_TRUE(bRet == true);
102 }
103
104 /**
105 * @tc.name: ToStringTest
106 * @tc.desc: Test NetSupplierInfo::ToString
107 * @tc.type: FUNC
108 */
109 HWTEST_F(NetSupplierInfoTest, ToStringTest, TestSize.Level1)
110 {
111 sptr<NetSupplierInfo> info = new (std::nothrow) NetSupplierInfo();
112 ASSERT_NE(info, nullptr);
113 std::string str = info->ToString("testTab");
114 NETMGR_LOG_D("NetSupplierInfoTest.ToString string is : [%{public}s]", str.c_str());
115 }
116 } // namespace NetManagerStandard
117 } // namespace OHOS
118