1 /* 2 * Copyright (c) 2024 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 RS_GRAPHIC_TEST_H 17 #define RS_GRAPHIC_TEST_H 18 19 #include "common/rs_color.h" 20 #include "common/rs_rect.h" 21 #include "rs_graphic_rootnode.h" 22 #include "rs_graphic_test_ext.h" 23 #include "ui/rs_canvas_node.h" 24 #include "ui/rs_surface_node.h" 25 26 namespace OHOS { 27 namespace Rosen { 28 class RSGraphicRootNode; 29 class RSGraphicTest : public testing::Test { 30 public: 31 std::shared_ptr<RSGraphicRootNode> GetRootNode() const; 32 Vector2f GetScreenSize() const; 33 void SetSurfaceBounds(const Vector4f& bounds); 34 void SetScreenSurfaceBounds(const Vector4f& bounds); 35 void SetSurfaceColor(const RSColor& color); 36 void RegisterNode(std::shared_ptr<RSNode> node); 37 void StartUIAnimation(); 38 void SetScreenSize(float width, float height); 39 40 // overrides gtest functions 41 static void SetUpTestCase(); 42 static void TearDownTestCase(); 43 void SetUp() override final; 44 void TearDown() override final; 45 46 // user functions BeforeEach()47 virtual void BeforeEach() {}; AfterEach()48 virtual void AfterEach() {}; 49 50 void AddFileRenderNodeTreeToNode(std::shared_ptr<RSNode> node, const std::string& filePath); 51 void PlaybackRecover(const std::string& filePath, float pauseTimeStamp); 52 void PlaybackStop(); 53 private: 54 std::string GetImageSavePath(const std::string path); 55 bool IsSingleTest(); 56 UIPoint GetScreenCapacity(const std::string testCase); 57 UIPoint GetPos(int id, int cl); 58 bool WaitOtherTest(); 59 void TestCaseCapture(bool isScreenshot); 60 61 bool shouldRunTest_ = true; 62 Vector4f surfaceBounds_; 63 std::vector<std::shared_ptr<RSNode>> nodes_; 64 static uint32_t imageWriteId_; 65 std::string imageSavePath_ = ""; 66 }; 67 } // namespace Rosen 68 } // namespace OHOS 69 70 #endif // RS_GRAPHIC_TEST_H 71