33// found in the LICENSE file.
44
55#include " flutter/testing/testing.h"
6+ #include " impeller/aiks/aiks_playground.h"
67#include " impeller/aiks/canvas.h"
8+ #include " impeller/aiks/image.h"
79#include " impeller/geometry/geometry_unittests.h"
10+ #include " impeller/geometry/path_builder.h"
811
912namespace impeller {
1013namespace testing {
1114
12- TEST (AiksTest, CanvasCTMCanBeUpdated) {
15+ using AiksTest = AiksPlayground;
16+
17+ TEST_F (AiksTest, CanvasCTMCanBeUpdated) {
1318 Canvas canvas;
1419 Matrix identity;
1520 ASSERT_MATRIX_NEAR (canvas.GetCurrentTransformation (), identity);
@@ -18,7 +23,7 @@ TEST(AiksTest, CanvasCTMCanBeUpdated) {
1823 Matrix::MakeTranslation ({100.0 , 100.0 , 0.0 }));
1924}
2025
21- TEST (AiksTest, CanvasCanPushPopCTM) {
26+ TEST_F (AiksTest, CanvasCanPushPopCTM) {
2227 Canvas canvas;
2328 ASSERT_EQ (canvas.GetSaveCount (), 1u );
2429 ASSERT_EQ (canvas.Restore (), false );
@@ -34,5 +39,42 @@ TEST(AiksTest, CanvasCanPushPopCTM) {
3439 Matrix::MakeTranslation ({100.0 , 100.0 , 0.0 }));
3540}
3641
42+ TEST_F (AiksTest, CanRenderColoredRect) {
43+ Canvas canvas;
44+ Paint paint;
45+ paint.color = Color::Red ();
46+ canvas.DrawPath (PathBuilder{}
47+ .AddRect (Rect::MakeXYWH (100.0 , 100.0 , 100.0 , 100.0 ))
48+ .CreatePath (),
49+ paint);
50+ // ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
51+ }
52+
53+ TEST_F (AiksTest, CanRenderImage) {
54+ Canvas canvas;
55+ Paint paint;
56+ auto image = std::make_shared<Image>(CreateTextureForFixture (" kalimba.jpg" ));
57+ paint.color = Color::Red ();
58+ canvas.DrawImage (image, Point::MakeXY (100.0 , 100.0 ), paint);
59+ ASSERT_TRUE (OpenPlaygroundHere (canvas.EndRecordingAsPicture ()));
60+ }
61+
62+ TEST_F (AiksTest, CanRenderImageRect) {
63+ Canvas canvas;
64+ Paint paint;
65+ auto image = std::make_shared<Image>(CreateTextureForFixture (" kalimba.jpg" ));
66+ auto source_rect = IRect::MakeSize (image->GetSize ());
67+
68+ // Render the bottom right quarter of the source image in a stretched rect.
69+ source_rect.size .width /= 2 ;
70+ source_rect.size .height /= 2 ;
71+ source_rect.origin .x += source_rect.size .width ;
72+ source_rect.origin .y += source_rect.size .height ;
73+
74+ canvas.DrawImageRect (image, source_rect, Rect::MakeXYWH (100 , 100 , 600 , 600 ),
75+ paint);
76+ // ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
77+ }
78+
3779} // namespace testing
3880} // namespace impeller
0 commit comments