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 "buffer_info_adapter_impl.h" 19 #undef private 20 21 using namespace testing; 22 using namespace testing::ext; 23 using namespace OHOS::NWeb; 24 25 class BufferInfoAdapterImplTest : public ::testing::Test { 26 protected: SetUp()27 void SetUp() override {} TearDown()28 void TearDown() override {} 29 }; 30 31 /** 32 * @tc.name: GetPresentationTimeUs_ShouldReturnPresentationTimeUs_WhenCalled 33 * @tc.number: BufferInfoAdapterImplTest_001 34 * @tc.desc: Test GetPresentationTimeUs method of BufferInfoAdapterImpl class 35 */ 36 HWTEST_F(BufferInfoAdapterImplTest, 37 GetPresentationTimeUs_ShouldReturnPresentationTimeUs_WhenCalled, TestSize.Level0) 38 { 39 BufferInfoAdapterImpl bufferInfoAdapterImpl; 40 int64_t presentationTimeUs = 1234567890; 41 bufferInfoAdapterImpl.SetPresentationTimeUs(presentationTimeUs); 42 EXPECT_EQ(bufferInfoAdapterImpl.GetPresentationTimeUs(), presentationTimeUs); 43 } 44 45 /** 46 * @tc.name: GetSize_ShouldReturnSize_WhenCalled 47 * @tc.number: BufferInfoAdapterImplTest_002 48 * @tc.desc: Test GetSize method of BufferInfoAdapterImpl class 49 */ 50 HWTEST_F(BufferInfoAdapterImplTest, 51 GetSize_ShouldReturnSize_WhenCalled, TestSize.Level0) 52 { 53 BufferInfoAdapterImpl bufferInfoAdapterImpl; 54 int32_t size = 1024; 55 bufferInfoAdapterImpl.SetSize(size); 56 EXPECT_EQ(bufferInfoAdapterImpl.GetSize(), size); 57 } 58 59 /** 60 * @tc.name: GetOffset_ShouldReturnOffset_WhenCalled 61 * @tc.number: BufferInfoAdapterImplTest_003 62 * @tc.desc: Test GetOffset method of BufferInfoAdapterImpl class 63 */ 64 HWTEST_F(BufferInfoAdapterImplTest, 65 GetOffset_ShouldReturnOffset_WhenCalled, TestSize.Level0) 66 { 67 BufferInfoAdapterImpl bufferInfoAdapterImpl; 68 int32_t offset = 512; 69 bufferInfoAdapterImpl.SetOffset(offset); 70 EXPECT_EQ(bufferInfoAdapterImpl.GetOffset(), offset); 71 }