• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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,
68         TestingPathDirection dir = TestingPathDirection::CW_DIRECTION) {}
69 
AddPath(const TestingPath & src)70     virtual void AddPath(const TestingPath& src) {}
71 
MoveTo(float xs,float ys)72     virtual void MoveTo(float xs, float ys) {}
LineTo(float xs,float ys)73     virtual void LineTo(float xs, float ys) {}
74     virtual void AddCircle(
75         float dx, float dy, float radius, TestingPathDirection dir = TestingPathDirection::CW_DIRECTION)
76     {}
Reset()77     virtual void Reset() {}
Close()78     virtual void Close() {}
QuadTo(float ctrlPtX,float ctrlPtY,float endPtX,float endPtY)79     virtual void QuadTo(float ctrlPtX, float ctrlPtY, float endPtX, float endPtY) {}
ArcTo(float x1,float y1,float x2,float y2,float radius)80     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)81     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)82     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)83     virtual void ArcTo(const TestingPoint& pt1, const TestingPoint& pt2, float startAngle, float sweepAngle) {}
84 
CubicTo(float ctrlPt1X,float ctrlPt1Y,float ctrlPt2X,float ctrlPt2Y,float endPtX,float endPtY)85     virtual void CubicTo(float ctrlPt1X, float ctrlPt1Y, float ctrlPt2X, float ctrlPt2Y, float endPtX, float endPtY) {}
86 
Offset(float dx,float dy)87     virtual void Offset(float dx, float dy) {}
AddPoly(const std::vector<TestingPoint> & points,int count,bool close)88     virtual void AddPoly(const std::vector<TestingPoint>& points, int count, bool close) {}
Op(const TestingPath & path1,TestingPath & path2,TestingPathOp op)89     virtual bool Op(const TestingPath& path1, TestingPath& path2, TestingPathOp op)
90     {
91         return true;
92     }
93     virtual void AddOval(const TestingRect& oval, PathDirection dir = PathDirection::CW_DIRECTION) {}
94 
BuildFromSVGString(const std::string & str)95     virtual bool BuildFromSVGString(const std::string& str)
96     {
97         return true;
98     }
99 
GetBounds()100     virtual TestingRect GetBounds()
101     {
102         return {};
103     }
SetFillStyle(TestingPathFillType fillStyle)104     virtual void SetFillStyle(TestingPathFillType fillStyle) {}
105 
IsValid()106     virtual bool IsValid() const
107     {
108         return false;
109     }
110 
GetLength(bool forceClosed)111     virtual float GetLength(bool forceClosed) const
112     {
113         return 0;
114     }
115 
GetPositionAndTangent(float distance,TestingPoint & position,TestingPoint & tangent,bool forceClosed)116     virtual bool GetPositionAndTangent(
117         float distance, TestingPoint& position, TestingPoint& tangent, bool forceClosed) const
118     {
119         return false;
120     }
121 
Transform(const TestingMatrix & matrix)122     virtual void Transform(const TestingMatrix& matrix) {}
123 
ConvertToSVGString()124     virtual std::string ConvertToSVGString()
125     {
126         return "";
127     }
128 
TransformWithPerspectiveClip(const TestingMatrix & matrix,TestingPath * dst,bool applyPerspectiveClip)129     virtual void TransformWithPerspectiveClip(const TestingMatrix& matrix, TestingPath* dst,
130         bool applyPerspectiveClip) {}
131 
Dump(std::string & out)132     void Dump(std::string& out) const
133     {
134         return;
135     }
136 };
137 } // namespace OHOS::Ace::Testing
138 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_PATH_H
139