5#include "flutter/shell/platform/fuchsia/flutter/rtree.h"
7#include "flutter/testing/testing.h"
15TEST(
RTree, searchNonOverlappingDrawnRectsNoIntersection) {
17 auto recorder = std::make_unique<SkPictureRecorder>();
18 auto recording_canvas =
23 rect_paint.setStyle(SkPaint::Style::kFill_Style);
28 recorder->finishRecordingAsPicture();
30 auto hits = rtree_factory.getInstance()->searchNonOverlappingDrawnRects(
32 ASSERT_TRUE(hits.empty());
35TEST(
RTree, searchNonOverlappingDrawnRectsSingleRectIntersection) {
37 auto recorder = std::make_unique<SkPictureRecorder>();
38 auto recording_canvas =
43 rect_paint.setStyle(SkPaint::Style::kFill_Style);
47 recording_canvas->drawRect(
SkRect::MakeLTRB(120, 120, 160, 160), rect_paint);
49 recorder->finishRecordingAsPicture();
51 auto hits = rtree_factory.getInstance()->searchNonOverlappingDrawnRects(
53 ASSERT_EQ(1UL, hits.size());
57TEST(
RTree, searchNonOverlappingDrawnRectsIgnoresNonDrawingRecords) {
59 auto recorder = std::make_unique<SkPictureRecorder>();
60 auto recording_canvas =
65 rect_paint.setStyle(SkPaint::Style::kFill_Style);
68 recording_canvas->translate(100, 100);
74 recorder->finishRecordingAsPicture();
77 ASSERT_EQ(3, rtree_factory.getInstance()->getCount());
79 auto hits = rtree_factory.getInstance()->searchNonOverlappingDrawnRects(
81 ASSERT_EQ(1UL, hits.size());
85TEST(
RTree, searchNonOverlappingDrawnRectsMultipleRectIntersection) {
87 auto recorder = std::make_unique<SkPictureRecorder>();
88 auto recording_canvas =
93 rect_paint.setStyle(SkPaint::Style::kFill_Style);
103 recording_canvas->drawRect(
SkRect::MakeLTRB(100, 100, 200, 200), rect_paint);
105 recording_canvas->drawRect(
SkRect::MakeLTRB(300, 100, 400, 200), rect_paint);
107 recorder->finishRecordingAsPicture();
109 auto hits = rtree_factory.getInstance()->searchNonOverlappingDrawnRects(
111 ASSERT_EQ(2UL, hits.size());
116TEST(
RTree, searchNonOverlappingDrawnRectsJoinRectsWhenIntersectedCase1) {
118 auto recorder = std::make_unique<SkPictureRecorder>();
119 auto recording_canvas =
124 rect_paint.setStyle(SkPaint::Style::kFill_Style);
138 recording_canvas->drawRect(
SkRect::MakeLTRB(100, 100, 150, 150), rect_paint);
140 recording_canvas->drawRect(
SkRect::MakeLTRB(125, 125, 175, 175), rect_paint);
142 recorder->finishRecordingAsPicture();
144 auto hits = rtree_factory.getInstance()->searchNonOverlappingDrawnRects(
146 ASSERT_EQ(3UL, hits.size());
152TEST(
RTree, searchNonOverlappingDrawnRectsJoinRectsWhenIntersectedCase2) {
154 auto recorder = std::make_unique<SkPictureRecorder>();
155 auto recording_canvas =
160 rect_paint.setStyle(SkPaint::Style::kFill_Style);
177 recording_canvas->drawRect(
SkRect::MakeLTRB(100, 100, 200, 200), rect_paint);
179 recording_canvas->drawRect(
SkRect::MakeLTRB(300, 100, 400, 200), rect_paint);
183 recording_canvas->drawRect(
SkRect::MakeLTRB(280, 100, 280, 320), rect_paint);
185 recorder->finishRecordingAsPicture();
187 auto hits = rtree_factory.getInstance()->searchNonOverlappingDrawnRects(
189 ASSERT_EQ(1UL, hits.size());
193TEST(
RTree, searchNonOverlappingDrawnRectsJoinRectsWhenIntersectedCase3) {
195 auto recorder = std::make_unique<SkPictureRecorder>();
196 auto recording_canvas =
201 rect_paint.setStyle(SkPaint::Style::kFill_Style);
219 recording_canvas->drawRect(
SkRect::MakeLTRB(100, 100, 200, 200), rect_paint);
221 recording_canvas->drawRect(
SkRect::MakeLTRB(300, 100, 400, 200), rect_paint);
223 recording_canvas->drawRect(
SkRect::MakeLTRB(500, 100, 600, 300), rect_paint);
227 recording_canvas->drawRect(
SkRect::MakeLTRB(280, 100, 280, 320), rect_paint);
229 recorder->finishRecordingAsPicture();
231 auto hits = rtree_factory.getInstance()->searchNonOverlappingDrawnRects(
233 ASSERT_EQ(2UL, hits.size());
static float next(float f)
constexpr SkColor4f kCyan
TEST(DisplayListComplexity, EmptyDisplayList)
static SkRect MakeIWH(int w, int h)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)