| // Copyright 2013 The Flutter Authors. All rights reserved. | |
| // Use of this source code is governed by a BSD-style license that can be | |
| // found in the LICENSE file. | |
| #include "flutter/flow/layers/platform_view_layer.h" | |
| #include "flutter/flow/testing/layer_test.h" | |
| #include "flutter/flow/testing/mock_layer.h" | |
| #include "flutter/fml/macros.h" | |
| #include "flutter/testing/mock_canvas.h" | |
| namespace flutter { | |
| namespace testing { | |
| using PlatformViewLayerTest = LayerTest; | |
| TEST_F(PlatformViewLayerTest, NullViewEmbedderDoesntPrerollCompositeOrPaint) { | |
| const SkPoint layer_offset = SkPoint::Make(0.0f, 0.0f); | |
| const SkSize layer_size = SkSize::Make(8.0f, 8.0f); | |
| const int64_t view_id = 0; | |
| auto layer = | |
| std::make_shared<PlatformViewLayer>(layer_offset, layer_size, view_id); | |
| layer->Preroll(preroll_context(), SkMatrix()); | |
| EXPECT_FALSE(preroll_context()->has_platform_view); | |
| EXPECT_EQ(layer->paint_bounds(), | |
| SkRect::MakeSize(layer_size) | |
| .makeOffset(layer_offset.fX, layer_offset.fY)); | |
| EXPECT_TRUE(layer->needs_painting()); | |
| #if defined(LEGACY_FUCHSIA_EMBEDDER) | |
| EXPECT_TRUE(layer->needs_system_composite()); | |
| #else | |
| EXPECT_FALSE(layer->needs_system_composite()); | |
| #endif // LEGACY_FUCHSIA_EMBEDDER | |
| layer->Paint(paint_context()); | |
| EXPECT_EQ(paint_context().leaf_nodes_canvas, &mock_canvas()); | |
| EXPECT_EQ(mock_canvas().draw_calls(), std::vector<MockCanvas::DrawCall>()); | |
| } | |
| } // namespace testing | |
| } // namespace flutter |