1 /*
2  * Copyright (c) 2022-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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_PATH_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_PATH_H
18 
19 #include <vector>
20 
21 #include "testing_matrix.h"
22 #include "testing_point.h"
23 #include "testing_rect.h"
24 #include "testing_round_rect.h"
25 
26 namespace OHOS::Ace::Testing {
27 enum class TestingPathDirection {
28     CW_DIRECTION,
29     CCW_DIRECTION,
30 };
31 
32 enum class TestingPathFillType {
33     WINDING,
34     EVENTODD,
35     INVERSE_WINDING,
36     INVERSE_EVENTODD,
37 };
38 
39 enum class TestingPathOp {
40     DIFFERENCE,
41     INTERSECT,
42     UNION,
43     XOR,
44     REVERSE_DIFFERENCE,
45 };
46 
47 enum class PathDirection {
48     CW_DIRECTION,
49     CCW_DIRECTION,
50 };
51 class TestingPath {
52 public:
53     TestingPath() = default;
54     virtual ~TestingPath() = default;
55 
AddArc(TestingRect oval,float startAngle,float sweepAngle)56     virtual void AddArc(TestingRect oval, float startAngle, float sweepAngle) {}
57     virtual void AddRect(const TestingRect& rect, TestingPathDirection dir = TestingPathDirection::CW_DIRECTION) {}
58 
59     virtual void AddRect(
60         float left, float top, float right, float bottom, TestingPathDirection dir = TestingPathDirection::CW_DIRECTION)
61     {}
62 
63     virtual void AddRoundRect(const TestingRect& rect, float xRadius, float yRadius,
64         TestingPathDirection dir = TestingPathDirection::CW_DIRECTION)
65     {}
66 
67     virtual void AddRoundRect(const TestingRoundRect& roundRect, PathDirection dir = PathDirection::CW_DIRECTION) {}
68 
AddPath(const TestingPath & src)69     virtual void AddPath(const TestingPath& src) {}
70 
MoveTo(float xs,float ys)71     virtual void MoveTo(float xs, float ys) {}
LineTo(float xs,float ys)72     virtual void LineTo(float xs, float ys) {}
73     virtual void AddCircle(
74         float dx, float dy, float radius, TestingPathDirection dir = TestingPathDirection::CW_DIRECTION)
75     {}
Reset()76     virtual void Reset() {}
Close()77     virtual void Close() {}
QuadTo(float ctrlPtX,float ctrlPtY,float endPtX,float endPtY)78     virtual void QuadTo(float ctrlPtX, float ctrlPtY, float endPtX, float endPtY) {}
ArcTo(float x1,float y1,float x2,float y2,float radius)79     virtual void ArcTo(float x1, float y1, float x2, float y2, float radius) {}
ArcTo(float rx,float ry,float angle,TestingPathDirection direction,float endX,float endY)80     virtual void ArcTo(float rx, float ry, float angle, TestingPathDirection direction, float endX, float endY) {}
ArcTo(float pt1X,float pt1Y,float pt2X,float pt2Y,float startAngle,float sweepAngle)81     virtual void ArcTo(float pt1X, float pt1Y, float pt2X, float pt2Y, float startAngle, float sweepAngle) {}
ArcTo(const TestingPoint & pt1,const TestingPoint & pt2,float startAngle,float sweepAngle)82     virtual void ArcTo(const TestingPoint& pt1, const TestingPoint& pt2, float startAngle, float sweepAngle) {}
83 
CubicTo(float ctrlPt1X,float ctrlPt1Y,float ctrlPt2X,float ctrlPt2Y,float endPtX,float endPtY)84     virtual void CubicTo(float ctrlPt1X, float ctrlPt1Y, float ctrlPt2X, float ctrlPt2Y, float endPtX, float endPtY) {}
Offset(float dx,float dy)85     virtual void Offset(float dx, float dy) {}
AddPoly(const std::vector<TestingPoint> & points,int count,bool close)86     virtual void AddPoly(const std::vector<TestingPoint>& points, int count, bool close) {}
Op(const TestingPath & path1,TestingPath & path2,TestingPathOp op)87     virtual bool Op(const TestingPath& path1, TestingPath& path2, TestingPathOp op)
88     {
89         return true;
90     }
91     virtual void AddOval(const TestingRect& oval, PathDirection dir = PathDirection::CW_DIRECTION) {}
92 
BuildFromSVGString(const std::string & str)93     virtual bool BuildFromSVGString(const std::string& str)
94     {
95         return true;
96     }
97 
GetBounds()98     virtual TestingRect GetBounds()
99     {
100         return {};
101     }
SetFillStyle(TestingPathFillType fillStyle)102     virtual void SetFillStyle(TestingPathFillType fillStyle) {}
103 
IsValid()104     virtual bool IsValid() const
105     {
106         return false;
107     }
108 
GetLength(bool forceClosed)109     virtual float GetLength(bool forceClosed) const
110     {
111         return 0;
112     }
113 
GetPositionAndTangent(float distance,TestingPoint & position,TestingPoint & tangent,bool forceClosed)114     virtual bool GetPositionAndTangent(
115         float distance, TestingPoint& position, TestingPoint& tangent, bool forceClosed) const
116     {
117         return false;
118     }
119 
Transform(const TestingMatrix & matrix)120     virtual void Transform(const TestingMatrix& matrix) {}
121 
ConvertToSVGString()122     virtual std::string ConvertToSVGString()
123     {
124         return "";
125     }
126 };
127 } // namespace OHOS::Ace::Testing
128 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_PATH_H
129