7#include "gtest/gtest.h"
12using ::testing::Return;
15 *result_listener <<
"isn't equal to " << a;
23TEST(DisplayListPathBuilder, DefaultConstructor) {
27 EXPECT_TRUE(
path.IsEmpty());
28 EXPECT_TRUE(
path.GetBounds().IsEmpty());
30 EXPECT_EQ(
path.GetFillType(), DlPathFillType::kNonZero);
33TEST(DisplayListPathBuilder, SetFillType) {
38 EXPECT_EQ(
path.GetFillType(), DlPathFillType::kOdd);
41TEST(DisplayListPathBuilder, CopyPathDoesNotResetPath) {
49 EXPECT_FALSE(before_path.
IsEmpty());
51 EXPECT_NE(before_path,
DlPath());
52 EXPECT_EQ(before_path.
GetFillType(), DlPathFillType::kOdd);
56 EXPECT_FALSE(after_path.
IsEmpty());
58 EXPECT_NE(after_path,
DlPath());
59 EXPECT_EQ(after_path, before_path);
60 EXPECT_EQ(after_path.
GetFillType(), DlPathFillType::kOdd);
63TEST(DisplayListPathBuilder, TakePathResetsPath) {
71 EXPECT_FALSE(before_path.
IsEmpty());
73 EXPECT_NE(before_path,
DlPath());
74 EXPECT_EQ(before_path.
GetFillType(), DlPathFillType::kOdd);
78 EXPECT_TRUE(after_path.
IsEmpty());
80 EXPECT_EQ(after_path,
DlPath());
81 EXPECT_EQ(after_path.
GetFillType(), DlPathFillType::kNonZero);
84TEST(DisplayListPathBuilder, LineToInsertsMoveTo) {
89 ::testing::StrictMock<DlPathReceiverMock> mock_receiver;
92 ::testing::InSequence sequence;
98 path.Dispatch(mock_receiver);
101TEST(DisplayListPathBuilder, QuadToInsertsMoveTo) {
106 ::testing::StrictMock<DlPathReceiverMock> mock_receiver;
109 ::testing::InSequence sequence;
112 EXPECT_CALL(mock_receiver, QuadTo(
DlPoint(10, 10),
DlPoint(10, 0)));
115 path.Dispatch(mock_receiver);
118TEST(DisplayListPathBuilder, ConicToInsertsMoveTo) {
123 ::testing::StrictMock<DlPathReceiverMock> mock_receiver;
126 ::testing::InSequence sequence;
129 EXPECT_CALL(mock_receiver, ConicTo(
DlPoint(10, 10),
DlPoint(10, 0), 0.5f))
130 .WillOnce(Return(
true));
133 path.Dispatch(mock_receiver);
136TEST(DisplayListPathBuilder, CubicToInsertsMoveTo) {
141 ::testing::StrictMock<DlPathReceiverMock> mock_receiver;
144 ::testing::InSequence sequence;
147 EXPECT_CALL(mock_receiver,
151 path.Dispatch(mock_receiver);
154TEST(DisplayListPathBuilder, ConicWithNonPositiveWeightsInsertLineTo) {
160 std::numeric_limits<DlScalar>::quiet_NaN());
163 ::testing::StrictMock<DlPathReceiverMock> mock_receiver;
166 ::testing::InSequence sequence;
174 path.Dispatch(mock_receiver);
177TEST(DisplayListPathBuilder, ConicWithWeight1InsertsQuadTo) {
183 ::testing::StrictMock<DlPathReceiverMock> mock_receiver;
186 ::testing::InSequence sequence;
189 EXPECT_CALL(mock_receiver, QuadTo(
DlPoint(20, 10),
DlPoint(10, 20)));
192 path.Dispatch(mock_receiver);
195TEST(DisplayListPathBuilder, AddRect) {
200 ::testing::StrictMock<DlPathReceiverMock> mock_receiver;
203 ::testing::InSequence sequence;
210 EXPECT_CALL(mock_receiver,
Close());
213 path.Dispatch(mock_receiver);
216TEST(DisplayListPathBuilder, AddOval) {
221 ::testing::StrictMock<DlPathReceiverMock> mock_receiver;
224 ::testing::InSequence sequence;
228 EXPECT_CALL(mock_receiver, ConicTo(
DlPoint(30, 20),
DlPoint(20, 20), wt))
229 .WillOnce(Return(
true));
230 EXPECT_CALL(mock_receiver, ConicTo(
DlPoint(10, 20),
DlPoint(10, 15), wt))
231 .WillOnce(Return(
true));
232 EXPECT_CALL(mock_receiver, ConicTo(
DlPoint(10, 10),
DlPoint(20, 10), wt))
233 .WillOnce(Return(
true));
234 EXPECT_CALL(mock_receiver, ConicTo(
DlPoint(30, 10),
DlPoint(30, 15), wt))
235 .WillOnce(Return(
true));
236 EXPECT_CALL(mock_receiver,
Close());
239 path.Dispatch(mock_receiver);
242TEST(DisplayListPathBuilder, AddCircle) {
247 ::testing::StrictMock<DlPathReceiverMock> mock_receiver;
250 ::testing::InSequence sequence;
254 EXPECT_CALL(mock_receiver, ConicTo(
DlPoint(20, 20),
DlPoint(15, 20), wt))
255 .WillOnce(Return(
true));
256 EXPECT_CALL(mock_receiver, ConicTo(
DlPoint(10, 20),
DlPoint(10, 15), wt))
257 .WillOnce(Return(
true));
258 EXPECT_CALL(mock_receiver, ConicTo(
DlPoint(10, 10),
DlPoint(15, 10), wt))
259 .WillOnce(Return(
true));
260 EXPECT_CALL(mock_receiver, ConicTo(
DlPoint(20, 10),
DlPoint(20, 15), wt))
261 .WillOnce(Return(
true));
262 EXPECT_CALL(mock_receiver,
Close());
265 path.Dispatch(mock_receiver);
268TEST(DisplayListPathBuilder, AddRoundRect) {
272 .top_right =
DlSize(3, 13),
273 .bottom_left =
DlSize(4, 14),
274 .bottom_right =
DlSize(5, 15),
280 ::testing::StrictMock<DlPathReceiverMock> mock_receiver;
283 ::testing::InSequence sequence;
288 EXPECT_CALL(mock_receiver, ConicTo(
DlPoint(10, 10),
DlPoint(12, 10), wt))
289 .WillOnce(Return(
true));
291 EXPECT_CALL(mock_receiver, ConicTo(
DlPoint(100, 10),
DlPoint(100, 23), wt))
292 .WillOnce(Return(
true));
294 EXPECT_CALL(mock_receiver, ConicTo(
DlPoint(100, 100),
DlPoint(95, 100), wt))
295 .WillOnce(Return(
true));
297 EXPECT_CALL(mock_receiver, ConicTo(
DlPoint(10, 100),
DlPoint(10, 86), wt))
298 .WillOnce(Return(
true));
299 EXPECT_CALL(mock_receiver,
Close());
302 path.Dispatch(mock_receiver);
305TEST(DisplayListPathBuilder, AddRoundSuperellipse) {
309 .top_right =
DlSize(3, 13),
310 .bottom_left =
DlSize(4, 14),
311 .bottom_right =
DlSize(5, 15),
318 ::testing::StrictMock<DlPathReceiverMock> mock_receiver;
321 ::testing::InSequence sequence;
326 EXPECT_CALL(mock_receiver, ConicTo(PointEq(
DlPoint(94.8672, 9.99998)),
327 PointEq(
DlPoint(95.7708, 10.0493)),
328 ScalarEq(3.63127851)))
329 .WillOnce(Return(
true));
330 EXPECT_CALL(mock_receiver, ConicTo(PointEq(
DlPoint(96.6558, 10.0976)),
331 PointEq(
DlPoint(97.1856, 10.2338)),
332 ScalarEq(1.22087204)))
333 .WillOnce(Return(
true));
334 EXPECT_CALL(mock_receiver,
CubicTo(PointEq(
DlPoint(97.9096f, 10.367f)),
335 PointEq(
DlPoint(98.5976, 11.6373)),
336 PointEq(
DlPoint(99.1213, 13.8076))));
339 EXPECT_CALL(mock_receiver,
CubicTo(PointEq(
DlPoint(99.5784, 15.7987)),
340 PointEq(
DlPoint(99.8618, 18.4156)),
341 PointEq(
DlPoint(99.9232, 21.2114))));
342 EXPECT_CALL(mock_receiver, ConicTo(PointEq(
DlPoint(99.9636, 23.0102)),
343 PointEq(
DlPoint(99.9805, 25.6229)),
344 ScalarEq(1.17059147)))
345 .WillOnce(Return(
true));
346 EXPECT_CALL(mock_receiver,
347 ConicTo(PointEq(
DlPoint(100, 28.6213)),
348 PointEq(
DlPoint(100, 51.7857)), ScalarEq(2.12785244)))
349 .WillOnce(Return(
true));
352 EXPECT_CALL(mock_receiver, ConicTo(PointEq(
DlPoint(100, 78.514)),
353 PointEq(
DlPoint(99.9675, 81.9736)),
354 ScalarEq(2.12785244)))
355 .WillOnce(Return(
true));
356 EXPECT_CALL(mock_receiver, ConicTo(PointEq(
DlPoint(99.9393, 84.9882)),
357 PointEq(
DlPoint(99.872, 87.0638)),
358 ScalarEq(1.17059147)))
359 .WillOnce(Return(
true));
360 EXPECT_CALL(mock_receiver,
CubicTo(PointEq(
DlPoint(99.7697, 90.2897)),
361 PointEq(
DlPoint(99.2973, 93.3092)),
362 PointEq(
DlPoint(98.5355, 95.6066))));
365 EXPECT_CALL(mock_receiver,
CubicTo(PointEq(
DlPoint(97.6834, 98.0734)),
366 PointEq(
DlPoint(96.5625, 99.532)),
367 PointEq(
DlPoint(95.3799, 99.7131))));
368 EXPECT_CALL(mock_receiver, ConicTo(PointEq(
DlPoint(94.5196, 99.8799)),
369 PointEq(
DlPoint(93.1037, 99.9395)),
370 ScalarEq(1.16898668)))
371 .WillOnce(Return(
true));
372 EXPECT_CALL(mock_receiver,
373 ConicTo(PointEq(
DlPoint(91.6668, 100)),
374 PointEq(
DlPoint(50, 100)), ScalarEq(3.63127851)))
375 .WillOnce(Return(
true));
378 EXPECT_CALL(mock_receiver, ConicTo(PointEq(
DlPoint(16.6667, 100)),
379 PointEq(
DlPoint(15.5171, 99.9435)),
380 ScalarEq(3.63127851)))
381 .WillOnce(Return(
true));
382 EXPECT_CALL(mock_receiver, ConicTo(PointEq(
DlPoint(14.3843, 99.8879)),
383 PointEq(
DlPoint(13.6961, 99.7323)),
384 ScalarEq(1.16898668)))
385 .WillOnce(Return(
true));
386 EXPECT_CALL(mock_receiver,
CubicTo(PointEq(
DlPoint(12.75, 99.5632)),
387 PointEq(
DlPoint(11.8533, 98.2018)),
388 PointEq(
DlPoint(11.1716, 95.8995))));
391 EXPECT_CALL(mock_receiver,
CubicTo(PointEq(
DlPoint(10.5569, 93.7323)),
392 PointEq(
DlPoint(10.1777, 90.8822)),
393 PointEq(
DlPoint(10.0993, 87.8409))));
394 EXPECT_CALL(mock_receiver, ConicTo(PointEq(
DlPoint(10.0462, 85.8435)),
395 PointEq(
DlPoint(10.0244, 82.8947)),
396 ScalarEq(1.2416352)))
397 .WillOnce(Return(
true));
398 EXPECT_CALL(mock_receiver,
399 ConicTo(PointEq(
DlPoint(10, 79.594)),
400 PointEq(
DlPoint(10, 51.5385)), ScalarEq(1.77972043)))
401 .WillOnce(Return(
true));
404 EXPECT_CALL(mock_receiver, ConicTo(PointEq(
DlPoint(10, 27.4909)),
405 PointEq(
DlPoint(10.0122, 24.6616)),
406 ScalarEq(1.77972043)))
407 .WillOnce(Return(
true));
408 EXPECT_CALL(mock_receiver, ConicTo(PointEq(
DlPoint(10.0231, 22.1342)),
409 PointEq(
DlPoint(10.0496, 20.4221)),
410 ScalarEq(1.2416352)))
411 .WillOnce(Return(
true));
412 EXPECT_CALL(mock_receiver,
CubicTo(PointEq(
DlPoint(10.0888, 17.8153)),
413 PointEq(
DlPoint(10.2785, 15.3723)),
414 PointEq(
DlPoint(10.5858, 13.5147))));
417 EXPECT_CALL(mock_receiver,
CubicTo(PointEq(
DlPoint(10.9349, 11.5114)),
418 PointEq(
DlPoint(11.3936, 10.3388)),
419 PointEq(
DlPoint(11.8762, 10.2158))));
420 EXPECT_CALL(mock_receiver, ConicTo(PointEq(
DlPoint(12.2295, 10.0901)),
421 PointEq(
DlPoint(12.8195, 10.0455)),
422 ScalarEq(1.22087204)))
423 .WillOnce(Return(
true));
424 EXPECT_CALL(mock_receiver,
426 ScalarEq(3.63127851)))
427 .WillOnce(Return(
true));
429 EXPECT_CALL(mock_receiver,
LineTo(PointEq(
DlPoint(46, 10))));
430 EXPECT_CALL(mock_receiver,
Close());
433 path.Dispatch(mock_receiver);
436TEST(DisplayListPathBuilder, AddArcNoCenter) {
442 ::testing::StrictMock<DlPathReceiverMock> mock_receiver;
445 ::testing::InSequence sequence;
449 EXPECT_CALL(mock_receiver, ConicTo(
DlPoint(10, 20),
DlPoint(10, 15), wt))
450 .WillOnce(Return(
true));
453 path.Dispatch(mock_receiver);
456TEST(DisplayListPathBuilder, AddArcWithCenter) {
462 ::testing::StrictMock<DlPathReceiverMock> mock_receiver;
465 ::testing::InSequence sequence;
470 EXPECT_CALL(mock_receiver, ConicTo(
DlPoint(10, 20),
DlPoint(10, 15), wt))
471 .WillOnce(Return(
true));
473 EXPECT_CALL(mock_receiver,
Close());
476 path.Dispatch(mock_receiver);
479TEST(DisplayListPathBuilder, SimpleUnclosedPath) {
483 .QuadraticCurveTo({200, 200}, {300, 300})
484 .ConicCurveTo({200, 200}, {100, 100}, 0.75f)
485 .CubicCurveTo({300, 300}, {400, 400}, {500, 500})
488 ::testing::StrictMock<DlPathReceiverMock> mock_receiver;
491 ::testing::InSequence sequence;
495 EXPECT_CALL(mock_receiver, QuadTo(
DlPoint(200, 200),
DlPoint(300, 300)));
496 EXPECT_CALL(mock_receiver,
498 .WillOnce(Return(
true));
503 path.Dispatch(mock_receiver);
506TEST(DisplayListPathBuilder, SimpleClosedPath) {
510 .QuadraticCurveTo({200, 200}, {300, 300})
511 .ConicCurveTo({200, 200}, {100, 100}, 0.75f)
512 .CubicCurveTo({300, 300}, {400, 400}, {500, 500})
516 ::testing::StrictMock<DlPathReceiverMock> mock_receiver;
519 ::testing::InSequence sequence;
523 EXPECT_CALL(mock_receiver, QuadTo(
DlPoint(200, 200),
DlPoint(300, 300)));
524 EXPECT_CALL(mock_receiver,
526 .WillOnce(Return(
true));
530 EXPECT_CALL(mock_receiver,
Close());
533 path.Dispatch(mock_receiver);
536TEST(DisplayListPathBuilder, EvenOddAppendNonZeroStaysEvenOdd) {
550 even_odd_path_builder.
AddPath(non_zero_path_builder.TakePath());
553 EXPECT_EQ(
path.GetFillType(), DlPathFillType::kOdd);
556TEST(DisplayListPathBuilder, NonZeroAppendEvenOddAppendStaysNonZero) {
570 non_zero_path_builder.
AddPath(even_odd_path_builder.TakePath());
573 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
MATCHER_P(PointEq, p, "")
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
constexpr float kEhCloseEnough
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)