Flutter Engine
The Flutter Engine
surface_frame_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#define FML_USED_ON_EMBEDDER
6
7#include "flutter/flow/surface_frame.h"
8#include "flutter/testing/testing.h"
9
10namespace flutter {
11
12TEST(FlowTest, SurfaceFrameDoesNotSubmitInDtor) {
13 SurfaceFrame::FramebufferInfo framebuffer_info;
14 auto callback = [](const SurfaceFrame&, DlCanvas*) {
15 EXPECT_FALSE(true);
16 return true;
17 };
18 auto surface_frame = std::make_unique<SurfaceFrame>(
19 /*surface=*/nullptr,
20 /*framebuffer_info=*/framebuffer_info,
21 /*submit_callback=*/callback,
22 /*frame_size=*/SkISize::Make(800, 600));
23 surface_frame.reset();
24}
25
26TEST(FlowTest, SurfaceFrameDoesNotHaveEmptyCanvas) {
27 SurfaceFrame::FramebufferInfo framebuffer_info;
28 auto callback = [](const SurfaceFrame&, DlCanvas*) { return true; };
30 /*surface=*/nullptr,
31 /*framebuffer_info=*/framebuffer_info,
32 /*submit_callback=*/callback,
33 /*frame_size=*/SkISize::Make(800, 600),
34 /*context_result=*/nullptr,
35 /*display_list_fallback=*/true);
36
37 EXPECT_FALSE(frame.Canvas()->GetLocalClipBounds().isEmpty());
38 EXPECT_FALSE(frame.Canvas()->QuickReject(SkRect::MakeLTRB(10, 10, 50, 50)));
39}
40
41TEST(FlowTest, SurfaceFrameDoesNotPrepareRtree) {
42 SurfaceFrame::FramebufferInfo framebuffer_info;
43 auto callback = [](const SurfaceFrame&, DlCanvas*) { return true; };
44 auto surface_frame = std::make_unique<SurfaceFrame>(
45 /*surface=*/nullptr,
46 /*framebuffer_info=*/framebuffer_info,
47 /*submit_callback=*/callback,
48 /*frame_size=*/SkISize::Make(800, 600),
49 /*context_result=*/nullptr,
50 /*display_list_fallback=*/true);
51 surface_frame->Canvas()->DrawRect(SkRect::MakeWH(100, 100), DlPaint());
52 EXPECT_FALSE(surface_frame->BuildDisplayList()->has_rtree());
53}
54
55} // namespace flutter
Developer-facing API for rendering anything within the engine.
Definition: dl_canvas.h:38
double frame
Definition: examples.cpp:31
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
TEST(FrameTimingsRecorderTest, RecordVsync)
flutter::DlPaint DlPaint
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
Definition: SkRect.h:646