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/flow/layers/platform_view_layer.h" |
6 | #include "flutter/flow/testing/layer_test.h" |
7 | #include "flutter/flow/testing/mock_layer.h" |
8 | #include "flutter/fml/macros.h" |
9 | #include "flutter/testing/mock_canvas.h" |
10 | |
11 | namespace flutter { |
12 | namespace testing { |
13 | |
14 | using PlatformViewLayerTest = LayerTest; |
15 | |
16 | TEST_F(PlatformViewLayerTest, NullViewEmbedderDoesntPrerollCompositeOrPaint) { |
17 | const SkPoint layer_offset = SkPoint::Make(0.0f, 0.0f); |
18 | const SkSize layer_size = SkSize::Make(8.0f, 8.0f); |
19 | const int64_t view_id = 0; |
20 | auto layer = |
21 | std::make_shared<PlatformViewLayer>(layer_offset, layer_size, view_id); |
22 | |
23 | layer->Preroll(preroll_context(), SkMatrix()); |
24 | EXPECT_FALSE(preroll_context()->has_platform_view); |
25 | EXPECT_EQ(layer->paint_bounds(), |
26 | SkRect::MakeSize(layer_size) |
27 | .makeOffset(layer_offset.fX, layer_offset.fY)); |
28 | EXPECT_TRUE(layer->needs_painting()); |
29 | #if defined(LEGACY_FUCHSIA_EMBEDDER) |
30 | EXPECT_TRUE(layer->needs_system_composite()); |
31 | #else |
32 | EXPECT_FALSE(layer->needs_system_composite()); |
33 | #endif // LEGACY_FUCHSIA_EMBEDDER |
34 | |
35 | layer->Paint(paint_context()); |
36 | EXPECT_EQ(paint_context().leaf_nodes_canvas, &mock_canvas()); |
37 | EXPECT_EQ(mock_canvas().draw_calls(), std::vector<MockCanvas::DrawCall>()); |
38 | } |
39 | |
40 | } // namespace testing |
41 | } // namespace flutter |
42 | |