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