1 /* 2 * Copyright (C) 2023 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 <fstream> 18 #include "parcel.h" 19 20 using namespace testing::ext; 21 namespace OHOS { 22 namespace Multimedia { 23 static const size_t SIZE_TEST = 0; 24 class MockParcelTest : public testing::Test { 25 public: MockParcelTest()26 MockParcelTest() {} ~MockParcelTest()27 ~MockParcelTest() {} 28 }; 29 30 /** 31 * @tc.name: GetDataCapacity001 32 * @tc.desc: test GetDataCapacity 33 * @tc.type: FUNC 34 */ 35 HWTEST_F(MockParcelTest, GetDataCapacity001, TestSize.Level3) 36 { 37 GTEST_LOG_(INFO) << "MockParcelTest: GetDataCapacity001 start"; 38 Parcel parcel; 39 size_t gd = parcel.GetDataCapacity(); 40 ASSERT_EQ(gd, 0); 41 GTEST_LOG_(INFO) << "MockParcelTest: GetDataCapacity001 end"; 42 } 43 44 /** 45 * @tc.name: SetDataCapacity001 46 * @tc.desc: test SetDataCapacity 47 * @tc.type: FUNC 48 */ 49 HWTEST_F(MockParcelTest, SetDataCapacity001, TestSize.Level3) 50 { 51 GTEST_LOG_(INFO) << "MockParcelTest: SetDataCapacity001 start"; 52 Parcel parcel; 53 size_t newCapacity = 3; 54 bool setdc = parcel.SetDataCapacity(newCapacity); 55 ASSERT_EQ(setdc, false); 56 GTEST_LOG_(INFO) << "MockParcelTest: SetDataCapacity001 end"; 57 } 58 59 /** 60 * @tc.name: WriteUnpadBuffer001 61 * @tc.desc: test WriteUnpadBuffer 62 * @tc.type: FUNC 63 */ 64 HWTEST_F(MockParcelTest, WriteUnpadBuffer001, TestSize.Level3) 65 { 66 GTEST_LOG_(INFO) << "MockParcelTest: WriteUnpadBuffer001 start"; 67 Parcel parcel; 68 void *data = nullptr; 69 size_t size = 7; 70 bool wub = parcel.WriteUnpadBuffer(data, size); 71 ASSERT_EQ(wub, false); 72 GTEST_LOG_(INFO) << "MockParcelTest: WriteUnpadBuffer001 end"; 73 } 74 75 /** 76 * @tc.name: WriteInt32001 77 * @tc.desc: test WriteInt32 78 * @tc.type: FUNC 79 */ 80 HWTEST_F(MockParcelTest, WriteInt32001, TestSize.Level3) 81 { 82 GTEST_LOG_(INFO) << "MockParcelTest: WriteInt32001 start"; 83 Parcel parcel; 84 int32_t value = 0; 85 bool writein = parcel.WriteInt32(value); 86 ASSERT_EQ(writein, false); 87 GTEST_LOG_(INFO) << "MockParcelTest: WriteInt32001 end"; 88 } 89 90 /** 91 * @tc.name: ReadBuffer001 92 * @tc.desc: test ReadBuffer 93 * @tc.type: FUNC 94 */ 95 HWTEST_F(MockParcelTest, ReadBuffer001, TestSize.Level3) 96 { 97 GTEST_LOG_(INFO) << "MockParcelTest: ReadBuffer001 start"; 98 Parcel parcel; 99 size_t length = 6; 100 const uint8_t *rbuffer = parcel.ReadBuffer(length); 101 ASSERT_EQ(rbuffer, nullptr); 102 GTEST_LOG_(INFO) << "MockParcelTest: ReadBuffer001 end"; 103 } 104 } // namespace Multimedia 105 } // namespace OHOS