7#include "gtest/gtest.h"
12using ::testing::Return;
18TEST(DisplayListPathBuilder, DefaultConstructor) {
22 EXPECT_TRUE(
path.IsEmpty());
23 EXPECT_TRUE(
path.GetBounds().IsEmpty());
25 EXPECT_EQ(
path.GetFillType(), DlPathFillType::kNonZero);
28TEST(DisplayListPathBuilder, SetFillType) {
33 EXPECT_EQ(
path.GetFillType(), DlPathFillType::kOdd);
36TEST(DisplayListPathBuilder, CopyPathDoesNotResetPath) {
44 EXPECT_FALSE(before_path.
IsEmpty());
46 EXPECT_NE(before_path,
DlPath());
47 EXPECT_EQ(before_path.
GetFillType(), DlPathFillType::kOdd);
51 EXPECT_FALSE(after_path.
IsEmpty());
53 EXPECT_NE(after_path,
DlPath());
54 EXPECT_EQ(after_path, before_path);
55 EXPECT_EQ(after_path.
GetFillType(), DlPathFillType::kOdd);
58TEST(DisplayListPathBuilder, TakePathResetsPath) {
66 EXPECT_FALSE(before_path.
IsEmpty());
68 EXPECT_NE(before_path,
DlPath());
69 EXPECT_EQ(before_path.
GetFillType(), DlPathFillType::kOdd);
73 EXPECT_TRUE(after_path.
IsEmpty());
75 EXPECT_EQ(after_path,
DlPath());
76 EXPECT_EQ(after_path.
GetFillType(), DlPathFillType::kNonZero);
79TEST(DisplayListPathBuilder, LineToInsertsMoveTo) {
84 ::testing::StrictMock<DlPathReceiverMock> mock_receiver;
87 ::testing::InSequence sequence;
93 path.Dispatch(mock_receiver);
96TEST(DisplayListPathBuilder, QuadToInsertsMoveTo) {
101 ::testing::StrictMock<DlPathReceiverMock> mock_receiver;
104 ::testing::InSequence sequence;
107 EXPECT_CALL(mock_receiver, QuadTo(
DlPoint(10, 10),
DlPoint(10, 0)));
110 path.Dispatch(mock_receiver);
113TEST(DisplayListPathBuilder, ConicToInsertsMoveTo) {
118 ::testing::StrictMock<DlPathReceiverMock> mock_receiver;
121 ::testing::InSequence sequence;
124 EXPECT_CALL(mock_receiver, ConicTo(
DlPoint(10, 10),
DlPoint(10, 0), 0.5f))
125 .WillOnce(Return(
true));
128 path.Dispatch(mock_receiver);
131TEST(DisplayListPathBuilder, CubicToInsertsMoveTo) {
136 ::testing::StrictMock<DlPathReceiverMock> mock_receiver;
139 ::testing::InSequence sequence;
142 EXPECT_CALL(mock_receiver,
146 path.Dispatch(mock_receiver);
149TEST(DisplayListPathBuilder, ConicWithNonPositiveWeightsInsertLineTo) {
155 std::numeric_limits<DlScalar>::quiet_NaN());
158 ::testing::StrictMock<DlPathReceiverMock> mock_receiver;
161 ::testing::InSequence sequence;
169 path.Dispatch(mock_receiver);
172TEST(DisplayListPathBuilder, ConicWithWeight1InsertsQuadTo) {
178 ::testing::StrictMock<DlPathReceiverMock> mock_receiver;
181 ::testing::InSequence sequence;
184 EXPECT_CALL(mock_receiver, QuadTo(
DlPoint(20, 10),
DlPoint(10, 20)));
187 path.Dispatch(mock_receiver);
190TEST(DisplayListPathBuilder, AddRect) {
195 ::testing::StrictMock<DlPathReceiverMock> mock_receiver;
198 ::testing::InSequence sequence;
205 EXPECT_CALL(mock_receiver,
Close());
208 path.Dispatch(mock_receiver);
211TEST(DisplayListPathBuilder, AddOval) {
216 ::testing::StrictMock<DlPathReceiverMock> mock_receiver;
219 ::testing::InSequence sequence;
223 EXPECT_CALL(mock_receiver, ConicTo(
DlPoint(30, 20),
DlPoint(20, 20), wt))
224 .WillOnce(Return(
true));
225 EXPECT_CALL(mock_receiver, ConicTo(
DlPoint(10, 20),
DlPoint(10, 15), wt))
226 .WillOnce(Return(
true));
227 EXPECT_CALL(mock_receiver, ConicTo(
DlPoint(10, 10),
DlPoint(20, 10), wt))
228 .WillOnce(Return(
true));
229 EXPECT_CALL(mock_receiver, ConicTo(
DlPoint(30, 10),
DlPoint(30, 15), wt))
230 .WillOnce(Return(
true));
231 EXPECT_CALL(mock_receiver,
Close());
234 path.Dispatch(mock_receiver);
237TEST(DisplayListPathBuilder, AddCircle) {
242 ::testing::StrictMock<DlPathReceiverMock> mock_receiver;
245 ::testing::InSequence sequence;
249 EXPECT_CALL(mock_receiver, ConicTo(
DlPoint(20, 20),
DlPoint(15, 20), wt))
250 .WillOnce(Return(
true));
251 EXPECT_CALL(mock_receiver, ConicTo(
DlPoint(10, 20),
DlPoint(10, 15), wt))
252 .WillOnce(Return(
true));
253 EXPECT_CALL(mock_receiver, ConicTo(
DlPoint(10, 10),
DlPoint(15, 10), wt))
254 .WillOnce(Return(
true));
255 EXPECT_CALL(mock_receiver, ConicTo(
DlPoint(20, 10),
DlPoint(20, 15), wt))
256 .WillOnce(Return(
true));
257 EXPECT_CALL(mock_receiver,
Close());
260 path.Dispatch(mock_receiver);
263TEST(DisplayListPathBuilder, AddRoundRect) {
267 .top_right =
DlSize(3, 13),
268 .bottom_left =
DlSize(4, 14),
269 .bottom_right =
DlSize(5, 15),
275 ::testing::StrictMock<DlPathReceiverMock> mock_receiver;
278 ::testing::InSequence sequence;
283 EXPECT_CALL(mock_receiver, ConicTo(
DlPoint(10, 10),
DlPoint(12, 10), wt))
284 .WillOnce(Return(
true));
286 EXPECT_CALL(mock_receiver, ConicTo(
DlPoint(100, 10),
DlPoint(100, 23), wt))
287 .WillOnce(Return(
true));
289 EXPECT_CALL(mock_receiver, ConicTo(
DlPoint(100, 100),
DlPoint(95, 100), wt))
290 .WillOnce(Return(
true));
292 EXPECT_CALL(mock_receiver, ConicTo(
DlPoint(10, 100),
DlPoint(10, 86), wt))
293 .WillOnce(Return(
true));
294 EXPECT_CALL(mock_receiver,
Close());
297 path.Dispatch(mock_receiver);
300TEST(DisplayListPathBuilder, AddRoundSuperellipse) {
304 .top_right =
DlSize(3, 13),
305 .bottom_left =
DlSize(4, 14),
306 .bottom_right =
DlSize(5, 15),
313 ::testing::StrictMock<DlPathReceiverMock> mock_receiver;
316 ::testing::InSequence sequence;
319 EXPECT_CALL(mock_receiver,
CubicTo(PointEq(
DlPoint(97.3149f, 9.99998f)),
320 PointEq(
DlPoint(95.8867f, 9.99486f)),
321 PointEq(
DlPoint(97.1856f, 10.2338f))));
322 EXPECT_CALL(mock_receiver,
CubicTo(PointEq(
DlPoint(97.9096f, 10.367f)),
323 PointEq(
DlPoint(98.5976f, 11.6373f)),
324 PointEq(
DlPoint(99.1213f, 13.8076f))));
325 EXPECT_CALL(mock_receiver,
CubicTo(PointEq(
DlPoint(99.5784f, 15.7987f)),
326 PointEq(
DlPoint(99.8618f, 18.4156f)),
327 PointEq(
DlPoint(99.9232f, 21.2114f))));
328 EXPECT_CALL(mock_receiver,
CubicTo(PointEq(
DlPoint(100.011f, 25.1954f)),
329 PointEq(
DlPoint(100.0f, 29.7897f)),
330 PointEq(
DlPoint(100.0f, 51.7857f))));
331 EXPECT_CALL(mock_receiver,
CubicTo(PointEq(
DlPoint(100.0f, 77.1657f)),
332 PointEq(
DlPoint(100.018f, 82.4668f)),
333 PointEq(
DlPoint(99.872f, 87.0638f))));
334 EXPECT_CALL(mock_receiver,
CubicTo(PointEq(
DlPoint(99.7697f, 90.2897f)),
335 PointEq(
DlPoint(99.2973f, 93.3092f)),
336 PointEq(
DlPoint(98.5355f, 95.6066f))));
337 EXPECT_CALL(mock_receiver,
CubicTo(PointEq(
DlPoint(97.6834f, 98.0734f)),
338 PointEq(
DlPoint(96.5625f, 99.532f)),
339 PointEq(
DlPoint(95.3799f, 99.7131f))));
340 EXPECT_CALL(mock_receiver,
CubicTo(PointEq(
DlPoint(93.4105f, 100.015f)),
341 PointEq(
DlPoint(93.4217f, 100.0f)),
342 PointEq(
DlPoint(50.0f, 100.0f))));
343 EXPECT_CALL(mock_receiver,
CubicTo(PointEq(
DlPoint(15.2626f, 100.0f)),
344 PointEq(
DlPoint(15.2716f, 100.014f)),
345 PointEq(
DlPoint(13.6961f, 99.7323f))));
346 EXPECT_CALL(mock_receiver,
CubicTo(PointEq(
DlPoint(12.75f, 99.5632f)),
347 PointEq(
DlPoint(11.8533f, 98.2018f)),
348 PointEq(
DlPoint(11.1716f, 95.8995f))));
349 EXPECT_CALL(mock_receiver,
CubicTo(PointEq(
DlPoint(10.5569f, 93.7323f)),
350 PointEq(
DlPoint(10.1777f, 90.8822f)),
351 PointEq(
DlPoint(10.0993f, 87.8409f))));
352 EXPECT_CALL(mock_receiver,
CubicTo(PointEq(
DlPoint(9.98623f, 83.4541f)),
353 PointEq(
DlPoint(10.0f, 78.5304f)),
354 PointEq(
DlPoint(10.0f, 51.5385f))));
355 EXPECT_CALL(mock_receiver,
CubicTo(PointEq(
DlPoint(10.0f, 28.4025f)),
356 PointEq(
DlPoint(9.99311f, 24.1822f)),
357 PointEq(
DlPoint(10.0496f, 20.4221f))));
358 EXPECT_CALL(mock_receiver,
CubicTo(PointEq(
DlPoint(10.0888f, 17.8153f)),
359 PointEq(
DlPoint(10.2785f, 15.3723f)),
360 PointEq(
DlPoint(10.5858f, 13.5147f))));
361 EXPECT_CALL(mock_receiver,
CubicTo(PointEq(
DlPoint(10.9349f, 11.5114f)),
362 PointEq(
DlPoint(11.3936f, 10.3388f)),
363 PointEq(
DlPoint(11.8762f, 10.2158f))));
364 EXPECT_CALL(mock_receiver,
CubicTo(PointEq(
DlPoint(12.7422f, 9.99527f)),
365 PointEq(
DlPoint(11.79f, 10.0f)),
366 PointEq(
DlPoint(46.0f, 10.0f))));
368 EXPECT_CALL(mock_receiver,
Close());
371 path.Dispatch(mock_receiver);
374TEST(DisplayListPathBuilder, AddArcNoCenter) {
380 ::testing::StrictMock<DlPathReceiverMock> mock_receiver;
383 ::testing::InSequence sequence;
387 EXPECT_CALL(mock_receiver, ConicTo(
DlPoint(10, 20),
DlPoint(10, 15), wt))
388 .WillOnce(Return(
true));
391 path.Dispatch(mock_receiver);
394TEST(DisplayListPathBuilder, AddArcWithCenter) {
400 ::testing::StrictMock<DlPathReceiverMock> mock_receiver;
403 ::testing::InSequence sequence;
408 EXPECT_CALL(mock_receiver, ConicTo(
DlPoint(10, 20),
DlPoint(10, 15), wt))
409 .WillOnce(Return(
true));
411 EXPECT_CALL(mock_receiver,
Close());
414 path.Dispatch(mock_receiver);
417TEST(DisplayListPathBuilder, SimpleUnclosedPath) {
421 .QuadraticCurveTo({200, 200}, {300, 300})
422 .ConicCurveTo({200, 200}, {100, 100}, 0.75f)
423 .CubicCurveTo({300, 300}, {400, 400}, {500, 500})
426 ::testing::StrictMock<DlPathReceiverMock> mock_receiver;
429 ::testing::InSequence sequence;
433 EXPECT_CALL(mock_receiver, QuadTo(
DlPoint(200, 200),
DlPoint(300, 300)));
434 EXPECT_CALL(mock_receiver,
436 .WillOnce(Return(
true));
441 path.Dispatch(mock_receiver);
444TEST(DisplayListPathBuilder, SimpleClosedPath) {
448 .QuadraticCurveTo({200, 200}, {300, 300})
449 .ConicCurveTo({200, 200}, {100, 100}, 0.75f)
450 .CubicCurveTo({300, 300}, {400, 400}, {500, 500})
454 ::testing::StrictMock<DlPathReceiverMock> mock_receiver;
457 ::testing::InSequence sequence;
461 EXPECT_CALL(mock_receiver, QuadTo(
DlPoint(200, 200),
DlPoint(300, 300)));
462 EXPECT_CALL(mock_receiver,
464 .WillOnce(Return(
true));
468 EXPECT_CALL(mock_receiver,
Close());
471 path.Dispatch(mock_receiver);
474TEST(DisplayListPathBuilder, EvenOddAppendNonZeroStaysEvenOdd) {
488 even_odd_path_builder.
AddPath(non_zero_path_builder.TakePath());
491 EXPECT_EQ(
path.GetFillType(), DlPathFillType::kOdd);
494TEST(DisplayListPathBuilder, NonZeroAppendEvenOddAppendStaysNonZero) {
508 non_zero_path_builder.
AddPath(even_odd_path_builder.TakePath());
511 EXPECT_EQ(
path.GetFillType(), DlPathFillType::kNonZero);
DlPathBuilder & AddRoundSuperellipse(const DlRoundSuperellipse &rse)
Append a closed rounded super-ellipse contour to the path.
DlPathBuilder & LineTo(DlPoint p2)
Draw a line from the current point to the indicated point p2.
DlPathBuilder & AddPath(const DlPath &path)
Append the provided path to this path as if the commands used to construct it were repeated on this p...
DlPathBuilder & MoveTo(DlPoint p2)
Start a new contour that will originate at the indicated point p2.
const DlPath CopyPath()
Returns the path constructed by this path builder so far and retains all current geometry to continue...
DlPathBuilder & SetFillType(DlPathFillType fill_type)
Set the fill type that should be used to determine the interior of this path to the indicated |fill_t...
const DlPath TakePath()
Returns the path constructed by this path builder and resets its internal state to the default state ...
DlPathBuilder & ConicCurveTo(DlPoint cp, DlPoint p2, DlScalar weight)
Draw a conic curve (a rational quadratic bezier curve) from the current point to the indicated point ...
DlPathBuilder & AddCircle(DlPoint center, DlScalar radius)
Append a closed circular contour to the path centered on the provided point at the provided radius.
DlPathBuilder & AddRect(const DlRect &rect)
Append a closed rectangular contour to the path.
DlPathBuilder & AddRoundRect(const DlRoundRect &round_rect)
Append a closed rounded rect contour to the path.
DlPathBuilder & QuadraticCurveTo(DlPoint cp, DlPoint p2)
Draw a quadratic bezier curve from the current point to the indicated point p2, using the indicated p...
DlPathBuilder & AddArc(const DlRect &bounds, DlDegrees start, DlDegrees sweep, bool use_center=false)
Append an arc contour to the path which:
DlPathBuilder & AddOval(const DlRect &bounds)
Append a closed elliptical contour to the path inscribed in the provided bounds.
DlPathBuilder & CubicCurveTo(DlPoint cp1, DlPoint cp2, DlPoint p2)
Draw a cubic bezier curve from the current point to the indicated point p2, using the indicated point...
DlRect GetBounds() const override
DlPathFillType GetFillType() const override
TEST(NativeAssetsManagerTest, NoAvailableAssets)
impeller::Degrees DlDegrees
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
constexpr float kSqrt2Over2
void MoveTo(PathBuilder *builder, Scalar x, Scalar y)
void LineTo(PathBuilder *builder, Scalar x, Scalar y)
void CubicTo(PathBuilder *builder, Scalar x1, Scalar y1, Scalar x2, Scalar y2, Scalar x3, Scalar y3)
void Close(PathBuilder *builder)
static RoundRect MakeRectRadii(const Rect &rect, const RoundingRadii &radii)
static RoundSuperellipse MakeRectRadii(const Rect &rect, const RoundingRadii &radii)
constexpr bool IsEmpty() const
Returns true if either of the width or height are 0, negative, or NaN.
static constexpr TRect MakeLTRB(Type left, Type top, Type right, Type bottom)