Flutter macOS Embedder
geometry_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 
6 
7 #include "gtest/gtest.h"
8 
9 namespace flutter {
10 
11 TEST(Point, SetsCoordinates) {
12  Point point(-30.0, 42.0);
13  EXPECT_DOUBLE_EQ(-30.0, point.x());
14  EXPECT_DOUBLE_EQ(42.0, point.y());
15 }
16 
17 TEST(Size, SetsDimensions) {
18  Size size(20.0, 42.0);
19  EXPECT_DOUBLE_EQ(20.0, size.width());
20  EXPECT_DOUBLE_EQ(42.0, size.height());
21 }
22 
23 TEST(Size, ClampsDimensionsPositive) {
24  Size size(-20.0, -42.0);
25  EXPECT_DOUBLE_EQ(0.0, size.width());
26  EXPECT_DOUBLE_EQ(0.0, size.height());
27 }
28 
29 TEST(Rect, SetsOriginAndSize) {
30  Point origin(-30.0, 42.0);
31  Size size(20.0, 22.0);
32  Rect rect(origin, size);
33  EXPECT_EQ(origin, rect.origin());
34  EXPECT_EQ(size, rect.size());
35 }
36 
37 TEST(Rect, ReturnsLTRB) {
38  Point origin(-30.0, 42.0);
39  Size size(20.0, 22.0);
40  Rect rect(origin, size);
41  EXPECT_DOUBLE_EQ(-30.0, rect.left());
42  EXPECT_DOUBLE_EQ(42.0, rect.top());
43  EXPECT_DOUBLE_EQ(-10.0, rect.right());
44  EXPECT_DOUBLE_EQ(64.0, rect.bottom());
45 }
46 
47 TEST(Rect, ReturnsWidthHeight) {
48  Point origin(-30.0, 42.0);
49  Size size(20.0, 22.0);
50  Rect rect(origin, size);
51  EXPECT_DOUBLE_EQ(20.0, rect.width());
52  EXPECT_DOUBLE_EQ(22.0, rect.height());
53 }
54 
55 } // namespace flutter
flutter::Rect::width
double width() const
Definition: geometry.h:67
flutter::TEST
TEST(BasicMessageChannelTest, Registration)
Definition: basic_message_channel_unittests.cc:58
geometry.h
flutter::Rect::origin
Point origin() const
Definition: geometry.h:69
flutter::Point::x
double x() const
Definition: geometry.h:20
flutter::Size::width
double width() const
Definition: geometry.h:42
flutter::Rect
Definition: geometry.h:56
flutter::Rect::left
double left() const
Definition: geometry.h:63
flutter::Size::height
double height() const
Definition: geometry.h:43
flutter::Rect::height
double height() const
Definition: geometry.h:68
flutter
Definition: AccessibilityBridgeMac.h:16
flutter::Rect::top
double top() const
Definition: geometry.h:64
flutter::Rect::bottom
double bottom() const
Definition: geometry.h:66
flutter::Rect::size
Size size() const
Definition: geometry.h:70
flutter::Point
Definition: geometry.h:13
flutter::Point::y
double y() const
Definition: geometry.h:21
flutter::Size
Definition: geometry.h:33
flutter::Rect::right
double right() const
Definition: geometry.h:65