1 /*
2 * Copyright (c) 2025 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 #include "ethernet_device_info.h"
18
19 #include "netmgr_ext_log_wrapper.h"
20 #include "parcel.h"
21 #include "refbase.h"
22
23 #ifdef GTEST_API_
24 #define private public
25 #define protected public
26 #endif
27
28 namespace OHOS {
29 namespace NetManagerStandard {
30 namespace {
31 using namespace testing::ext;
32 }
33
34 class EthernetDeviceInfoTest : public testing::Test {
35 public:
36 static void SetUpTestCase();
37 static void TearDownTestCase();
38 void SetUp();
39 void TearDown();
40 };
41
SetUpTestCase()42 void EthernetDeviceInfoTest::SetUpTestCase() {};
43
TearDownTestCase()44 void EthernetDeviceInfoTest::TearDownTestCase() {};
45
SetUp()46 void EthernetDeviceInfoTest::SetUp() {};
47
TearDown()48 void EthernetDeviceInfoTest::TearDown() {};
49
50 HWTEST_F(EthernetDeviceInfoTest, MarshallingTest001, TestSize.Level1)
51 {
52 EthernetDeviceInfo devInfo;
53 Parcel parcel;
54 EXPECT_TRUE(devInfo.Marshalling(parcel));
55 }
56
57 HWTEST_F(EthernetDeviceInfoTest, UnmarshallingTest001, TestSize.Level1)
58 {
59 EthernetDeviceInfo devInfo;
60 Parcel parcel;
61 std::string testStr = "test";
62 int32_t testInt32 = 0;
63 EXPECT_EQ(devInfo.Unmarshalling(parcel), nullptr);
64 parcel.WriteString(testStr);
65 EXPECT_EQ(devInfo.Unmarshalling(parcel), nullptr);
66 parcel.WriteString(testStr);
67 parcel.WriteString(testStr);
68 EXPECT_EQ(devInfo.Unmarshalling(parcel), nullptr);
69 parcel.WriteString(testStr);
70 parcel.WriteString(testStr);
71 parcel.WriteInt32(testInt32);
72 EXPECT_EQ(devInfo.Unmarshalling(parcel), nullptr);
73 parcel.WriteString(testStr);
74 parcel.WriteString(testStr);
75 parcel.WriteInt32(testInt32);
76 parcel.WriteString(testStr);
77 EXPECT_EQ(devInfo.Unmarshalling(parcel), nullptr);
78 parcel.WriteString(testStr);
79 parcel.WriteString(testStr);
80 parcel.WriteInt32(testInt32);
81 parcel.WriteString(testStr);
82 parcel.WriteString(testStr);
83 EXPECT_EQ(devInfo.Unmarshalling(parcel), nullptr);
84 parcel.WriteString(testStr);
85 parcel.WriteString(testStr);
86 parcel.WriteInt32(testInt32);
87 parcel.WriteString(testStr);
88 parcel.WriteString(testStr);
89 parcel.WriteString(testStr);
90 EXPECT_EQ(devInfo.Unmarshalling(parcel), nullptr);
91 parcel.WriteString(testStr);
92 parcel.WriteString(testStr);
93 parcel.WriteInt32(testInt32);
94 parcel.WriteString(testStr);
95 parcel.WriteString(testStr);
96 parcel.WriteString(testStr);
97 parcel.WriteString(testStr);
98 EXPECT_NE(devInfo.Unmarshalling(parcel), nullptr);
99 }
100 }
101 }
102