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 #define private public 18 #include "ohos_buffer_adapter_impl.h" 19 #undef private 20 21 using namespace testing; 22 using namespace testing::ext; 23 using namespace OHOS::NWeb; 24 25 class OhosBufferAdapterImplTest : public ::testing::Test { 26 protected: SetUp()27 void SetUp() override {} TearDown()28 void TearDown() override {} 29 }; 30 31 /** 32 * @tc.name: GetAddr_ShouldReturnAddr_WhenCalled 33 * @tc.number: OhosBufferAdapterImplTest_001 34 * @tc.desc: Test GetAddr method of OhosBufferAdapterImpl class 35 */ 36 HWTEST_F(OhosBufferAdapterImplTest, 37 GetAddr_ShouldReturnAddr_WhenCalled, TestSize.Level0) 38 { 39 std::unique_ptr<uint8_t[]> addr = std::make_unique<uint8_t[]>(1024); 40 OhosBufferAdapterImpl ohosBufferAdapterImpl; 41 ohosBufferAdapterImpl.SetAddr(addr.get()); 42 EXPECT_EQ(addr.get(), ohosBufferAdapterImpl.GetAddr()); 43 } 44 45 /** 46 * @tc.name: GetBufferSize_ShouldReturnBufferSize_WhenCalled 47 * @tc.number: OhosBufferAdapterImplTest_002 48 * @tc.desc: Test GetBufferSize method of OhosBufferAdapterImpl class 49 */ 50 HWTEST_F(OhosBufferAdapterImplTest, 51 GetBufferSize_ShouldReturnBufferSize_WhenCalled, TestSize.Level0) 52 { 53 OhosBufferAdapterImpl ohosBufferAdapterImpl; 54 uint32_t bufferSize = 2048; 55 ohosBufferAdapterImpl.SetBufferSize(bufferSize); 56 EXPECT_EQ(ohosBufferAdapterImpl.GetBufferSize(), bufferSize); 57 }