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 SetSurfaceColor(const RSColor& color);
35     void RegisterNode(std::shared_ptr<RSNode> node);
36 
37     // overrides gtest functions
38     static void SetUpTestCase();
39     static void TearDownTestCase();
40     void SetUp() override final;
41     void TearDown() override final;
42 
43     // user functions
BeforeEach()44     virtual void BeforeEach() {};
AfterEach()45     virtual void AfterEach() {};
46 
47 private:
48     std::string GetImageSavePath(const std::string path);
49 
50     bool shouldRunTest_ = true;
51     Vector4f surfaceBounds_;
52     std::vector<std::shared_ptr<RSNode>> nodes_;
53     static uint32_t imageWriteId_;
54     std::string imageSavePath_ = "";
55 };
56 } // namespace Rosen
57 } // namespace OHOS
58 
59 #endif // RS_GRAPHIC_TEST_H
60