3
3
// found in the LICENSE file.
4
4
5
5
#include " flutter/testing/testing.h"
6
+ #include " impeller/aiks/aiks_playground.h"
6
7
#include " impeller/aiks/canvas.h"
8
+ #include " impeller/aiks/image.h"
7
9
#include " impeller/geometry/geometry_unittests.h"
10
+ #include " impeller/geometry/path_builder.h"
8
11
9
12
namespace impeller {
10
13
namespace testing {
11
14
12
- TEST (AiksTest, CanvasCTMCanBeUpdated) {
15
+ using AiksTest = AiksPlayground;
16
+
17
+ TEST_F (AiksTest, CanvasCTMCanBeUpdated) {
13
18
Canvas canvas;
14
19
Matrix identity;
15
20
ASSERT_MATRIX_NEAR (canvas.GetCurrentTransformation (), identity);
@@ -18,7 +23,7 @@ TEST(AiksTest, CanvasCTMCanBeUpdated) {
18
23
Matrix::MakeTranslation ({100.0 , 100.0 , 0.0 }));
19
24
}
20
25
21
- TEST (AiksTest, CanvasCanPushPopCTM) {
26
+ TEST_F (AiksTest, CanvasCanPushPopCTM) {
22
27
Canvas canvas;
23
28
ASSERT_EQ (canvas.GetSaveCount (), 1u );
24
29
ASSERT_EQ (canvas.Restore (), false );
@@ -34,5 +39,42 @@ TEST(AiksTest, CanvasCanPushPopCTM) {
34
39
Matrix::MakeTranslation ({100.0 , 100.0 , 0.0 }));
35
40
}
36
41
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
+
37
79
} // namespace testing
38
80
} // namespace impeller
0 commit comments