1 /* 2 * Copyright (c) 2021 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 #ifndef DISPLAY_GFX_TEST_H 17 #define DISPLAY_GFX_TEST_H 18 #include "gtest/gtest.h" 19 #include "display_gfx.h" 20 #include "display_gralloc.h" 21 #include "display_type.h" 22 #include "display_test.h" 23 24 namespace { 25 class GfxTestBase { 26 public: ~GfxTestBase()27 virtual ~GfxTestBase() {} 28 29 protected: 30 void TestSetUp(); 31 void TestTearDown(); 32 void DeInitTestBuffer(); 33 void InitTestBuffer(); 34 int32_t GfxTestModuleInit(void); 35 int32_t GfxTestModuleDeinit(void); 36 IRect mSrcRect = { 0 }; 37 IRect mDstRect = { 0 }; 38 BufferHandle *mSrcBuffer = nullptr; 39 BufferHandle *mDstBuffer = nullptr; 40 BufferHandle *mSoftBlendBuffer = nullptr; 41 GrallocFuncs *mGrallocFuncs = nullptr; 42 GfxFuncs *mGfxFuncs = nullptr; 43 void *mGfxTestModule = nullptr; 44 }; 45 46 struct RotateParam { 47 TransformType transformType; 48 BlendType blendType; 49 int expectX; 50 int expectY; 51 }; 52 53 class GfxFillTest : public ::testing::TestWithParam<uint32_t>, public GfxTestBase { 54 protected: 55 void SetUp(); 56 void TearDown(); 57 int32_t FillRectTest(uint32_t testColor); 58 }; 59 60 class GfxRotateTest : public ::testing::TestWithParam<RotateParam>, public GfxTestBase { 61 protected: 62 void SetUp(); 63 void TearDown(); 64 int32_t RotateTest(RotateParam param); 65 }; 66 67 class GfxBlendTypeTest : public ::testing::TestWithParam<BlendType>, public GfxTestBase { 68 protected: 69 void SetUp(); 70 void TearDown(); 71 int32_t GfxBlitBlendTypeTest(BlendType type); 72 int32_t GfxBlitTest(const GfxFuncs &gfxFuncs, const GrallocFuncs &grallocFuncs, GfxOpt &opt); 73 }; 74 } 75 76 #endif // DISPLAY_GFX_TEST_H 77