Flutter Engine
The Flutter Engine
dl_geometry_types_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/display_list/geometry/dl_geometry_types.h"
6#include "gtest/gtest.h"
7
8namespace flutter {
9namespace testing {
10
11TEST(DisplayListGeometryTypes, PointConversion) {
12 SkPoint sk_p = SkPoint::Make(1.0f, 2.0f);
13 DlPoint dl_p = DlPoint(1.0f, 2.0f);
14
15 EXPECT_EQ(sk_p, ToSkPoint(dl_p));
16 EXPECT_EQ(ToDlPoint(sk_p), dl_p);
17
18 sk_p = SkPoint::Make(1.0f, 2.0f);
19 dl_p = DlPoint(1.0f, 3.0f);
20
21 EXPECT_NE(sk_p, ToSkPoint(dl_p));
22 EXPECT_NE(ToDlPoint(sk_p), dl_p);
23}
24
25TEST(DisplayListGeometryTypes, RectConversion) {
26 SkRect sk_r = SkRect::MakeLTRB(1.0f, 2.0f, 3.0f, 4.0f);
27 DlRect dl_r = DlRect::MakeLTRB(1.0f, 2.0f, 3.0f, 4.0f);
28
29 EXPECT_EQ(sk_r, ToSkRect(dl_r));
30 EXPECT_EQ(ToDlRect(sk_r), dl_r);
31
32 sk_r = SkRect::MakeLTRB(1.0f, 2.0f, 3.0f, 4.0f);
33 dl_r = DlRect::MakeLTRB(1.0f, 2.0f, 3.0f, 5.0f);
34
35 EXPECT_NE(sk_r, ToSkRect(dl_r));
36 EXPECT_NE(ToDlRect(sk_r), dl_r);
37}
38
39TEST(DisplayListGeometryTypes, ISizeConversion) {
40 SkISize sk_s = SkISize::Make(1.0f, 2.0f);
41 DlISize dl_s = DlISize(1.0f, 2.0f);
42
43 EXPECT_EQ(sk_s, ToSkISize(dl_s));
44 EXPECT_EQ(ToDlISize(sk_s), dl_s);
45
46 sk_s = SkISize::Make(1.0f, 2.0f);
47 dl_s = DlISize(1.0f, 3.0f);
48
49 EXPECT_NE(sk_s, ToSkISize(dl_s));
50 EXPECT_NE(ToDlISize(sk_s), dl_s);
51}
52
53} // namespace testing
54} // namespace flutter
TEST(DisplayListComplexity, EmptyDisplayList)
const SkPoint & ToSkPoint(const DlPoint &point)
const DlISize & ToDlISize(const SkISize &size)
const DlPoint & ToDlPoint(const SkPoint &point)
impeller::ISize32 DlISize
impeller::Point DlPoint
const DlRect & ToDlRect(const SkRect &rect)
const SkRect & ToSkRect(const DlRect &rect)
const SkISize & ToSkISize(const DlISize &size)
Definition: SkSize.h:16
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20
static constexpr SkPoint Make(float x, float y)
Definition: SkPoint_impl.h:173
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
Definition: SkRect.h:646
static constexpr TRect MakeLTRB(Type left, Type top, Type right, Type bottom)
Definition: rect.h:129