1 | // Copyright 2013 The Flutter Authors. All rights reserved. |
---|---|
2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. |
4 | |
5 | #include "flutter/testing/mock_canvas.h" |
6 | |
7 | #include "flutter/testing/canvas_test.h" |
8 | #include "gtest/gtest.h" |
9 | |
10 | namespace flutter { |
11 | namespace testing { |
12 | |
13 | using MockCanvasTest = CanvasTest; |
14 | |
15 | #ifndef NDEBUG |
16 | TEST_F(MockCanvasTest, DrawRRectDies) { |
17 | EXPECT_DEATH_IF_SUPPORTED(mock_canvas().drawRRect(SkRRect(), SkPaint()), ""); |
18 | } |
19 | #endif |
20 | |
21 | TEST_F(MockCanvasTest, DrawCalls) { |
22 | const SkRect rect = SkRect::MakeWH(5.0f, 5.0f); |
23 | const SkPaint paint = SkPaint(SkColors::kGreen); |
24 | const auto expected_draw_calls = std::vector{ |
25 | MockCanvas::DrawCall{0, MockCanvas::DrawRectData{rect, paint}}}; |
26 | |
27 | mock_canvas().drawRect(rect, paint); |
28 | EXPECT_EQ(mock_canvas().draw_calls(), expected_draw_calls); |
29 | } |
30 | |
31 | } // namespace testing |
32 | } // namespace flutter |
33 |