forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
surface_frame_unittests.cc
55 lines (47 loc) · 1.88 KB
/
surface_frame_unittests.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// 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.
#define FML_USED_ON_EMBEDDER
#include "flutter/flow/surface_frame.h"
#include "flutter/testing/testing.h"
namespace flutter {
TEST(FlowTest, SurfaceFrameDoesNotSubmitInDtor) {
SurfaceFrame::FramebufferInfo framebuffer_info;
auto callback = [](const SurfaceFrame&, DlCanvas*) {
EXPECT_FALSE(true);
return true;
};
auto surface_frame = std::make_unique<SurfaceFrame>(
/*surface=*/nullptr,
/*framebuffer_info=*/framebuffer_info,
/*submit_callback=*/callback,
/*frame_size=*/SkISize::Make(800, 600));
surface_frame.reset();
}
TEST(FlowTest, SurfaceFrameDoesNotHaveEmptyCanvas) {
SurfaceFrame::FramebufferInfo framebuffer_info;
auto callback = [](const SurfaceFrame&, DlCanvas*) { return true; };
SurfaceFrame frame(
/*surface=*/nullptr,
/*framebuffer_info=*/framebuffer_info,
/*submit_callback=*/callback,
/*frame_size=*/SkISize::Make(800, 600),
/*context_result=*/nullptr,
/*display_list_fallback=*/true);
EXPECT_FALSE(frame.Canvas()->GetLocalClipBounds().isEmpty());
EXPECT_FALSE(frame.Canvas()->QuickReject(SkRect::MakeLTRB(10, 10, 50, 50)));
}
TEST(FlowTest, SurfaceFrameDoesNotPrepareRtree) {
SurfaceFrame::FramebufferInfo framebuffer_info;
auto callback = [](const SurfaceFrame&, DlCanvas*) { return true; };
auto surface_frame = std::make_unique<SurfaceFrame>(
/*surface=*/nullptr,
/*framebuffer_info=*/framebuffer_info,
/*submit_callback=*/callback,
/*frame_size=*/SkISize::Make(800, 600),
/*context_result=*/nullptr,
/*display_list_fallback=*/true);
surface_frame->Canvas()->DrawRect(SkRect::MakeWH(100, 100), DlPaint());
EXPECT_FALSE(surface_frame->BuildDisplayList()->has_rtree());
}
} // namespace flutter