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 #ifndef OHOS_RENDER_3D_3D_WIDGET_ADAPTER_TEST_H
17 #define OHOS_RENDER_3D_3D_WIDGET_ADAPTER_TEST_H
18 
19 #include <gtest/gtest.h>
20 #include <memory>
21 
22 #include "i_engine.h"
23 #include "widget_adapter.h"
24 
25 namespace OHOS::Render3D {
26 class WidgetAdapter3DTest : public testing::Test {
27 public:
28     static void SetUpTestCase();
29     static void TearDownTestCase();
30     void SetUp() override;
31     void TearDown() override;
32 };
33 
34 class EngineTest : public IEngine {
35 public:
36     EngineTest() = default;
37     ~EngineTest() = default;
38     void Clone(IEngine *proto) override{};
39     bool LoadEngineLib() override;
40     bool InitEngine(EGLContext eglContext, const PlatformData &data) override;
41     void DeInitEngine() override{};
42     void UnloadEngineLib() override{};
43 
44     void InitializeScene(uint32_t key) override;
45     void SetupCameraViewPort(uint32_t width, uint32_t height) override;
46     void SetupCameraTransform(
47         const Position &position, const Vec3 &lookAt, const Vec3 &up, const Quaternion &rotation) override;
48     void SetupCameraViewProjection(float zNear, float zFar, float fovDegrees) override;
49 
50     void LoadSceneModel(const std::string &modelPath) override;
51     void LoadEnvModel(const std::string &modelPath, BackgroundType type) override;
52     void UnloadSceneModel() override{};
53     void UnloadEnvModel() override{};
54 
55     void OnTouchEvent(const PointerEvent &event) override;
56     void OnWindowChange(const TextureInfo &textureInfo) override;
57 
58     void DrawFrame() override{};
59 
60     void UpdateGeometries(const std::vector<std::shared_ptr<Geometry>> &shapes) override;
61     void UpdateGLTFAnimations(const std::vector<std::shared_ptr<GLTFAnimation>> &animations) override;
62     void UpdateLights(const std::vector<std::shared_ptr<Light>> &lights) override;
63     void UpdateCustomRender(const std::shared_ptr<CustomRenderDescriptor> &customRender) override;
64     void UpdateShaderPath(const std::string &shaderPath) override;
65     void UpdateImageTexturePaths(const std::vector<std::string> &imageTextures) override;
66     void UpdateShaderInputBuffer(const std::shared_ptr<ShaderInputBuffer> &shaderInputBuffer) override;
67 
68     bool NeedsRepaint() override;
69 
70 #if defined(MULTI_ECS_UPDATE_AT_ONCE) && (MULTI_ECS_UPDATE_AT_ONCE == 1)
71     void DeferDraw() override{};
72     void DrawMultiEcs(const std::unordered_map<void *, void *> &ecss) override{};
73 #endif
74 };
75 }  // namespace OHOS::Render3D
76 #endif  // OHOS_RENDER_3D_3D_WIDGET_ADAPTER_TEST_H
77