OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/layout/ng/ng_units.h" | 5 #include "core/layout/ng/geometry/ng_box_strut.h" |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 namespace blink { | 9 namespace blink { |
10 | 10 |
11 namespace { | 11 namespace { |
12 | 12 |
13 // Ideally, this would be tested by NGBoxStrut::ConvertToPhysical, but | 13 // Ideally, this would be tested by NGBoxStrut::ConvertToPhysical, but |
14 // this has not been implemented yet. | 14 // this has not been implemented yet. |
15 TEST(NGUnitsTest, ConvertPhysicalStrutToLogical) { | 15 TEST(NGGeometryUnitsTest, ConvertPhysicalStrutToLogical) { |
16 LayoutUnit left{5}, right{10}, top{15}, bottom{20}; | 16 LayoutUnit left{5}, right{10}, top{15}, bottom{20}; |
17 NGPhysicalBoxStrut physical{left, right, top, bottom}; | 17 NGPhysicalBoxStrut physical{left, right, top, bottom}; |
18 | 18 |
19 NGBoxStrut logical = | 19 NGBoxStrut logical = |
20 physical.ConvertToLogical(kHorizontalTopBottom, TextDirection::kLtr); | 20 physical.ConvertToLogical(kHorizontalTopBottom, TextDirection::kLtr); |
21 EXPECT_EQ(left, logical.inline_start); | 21 EXPECT_EQ(left, logical.inline_start); |
22 EXPECT_EQ(top, logical.block_start); | 22 EXPECT_EQ(top, logical.block_start); |
23 | 23 |
24 logical = | 24 logical = |
25 physical.ConvertToLogical(kHorizontalTopBottom, TextDirection::kRtl); | 25 physical.ConvertToLogical(kHorizontalTopBottom, TextDirection::kRtl); |
(...skipping 10 matching lines...) Expand all Loading... |
36 | 36 |
37 logical = physical.ConvertToLogical(kVerticalRightLeft, TextDirection::kLtr); | 37 logical = physical.ConvertToLogical(kVerticalRightLeft, TextDirection::kLtr); |
38 EXPECT_EQ(top, logical.inline_start); | 38 EXPECT_EQ(top, logical.inline_start); |
39 EXPECT_EQ(right, logical.block_start); | 39 EXPECT_EQ(right, logical.block_start); |
40 | 40 |
41 logical = physical.ConvertToLogical(kVerticalRightLeft, TextDirection::kRtl); | 41 logical = physical.ConvertToLogical(kVerticalRightLeft, TextDirection::kRtl); |
42 EXPECT_EQ(bottom, logical.inline_start); | 42 EXPECT_EQ(bottom, logical.inline_start); |
43 EXPECT_EQ(right, logical.block_start); | 43 EXPECT_EQ(right, logical.block_start); |
44 } | 44 } |
45 | 45 |
46 TEST(NGUnitsTest, ShrinkToFit) { | |
47 MinAndMaxContentSizes sizes; | |
48 | |
49 sizes.min_content = LayoutUnit(100); | |
50 sizes.max_content = LayoutUnit(200); | |
51 EXPECT_EQ(LayoutUnit(200), sizes.ShrinkToFit(LayoutUnit(300))); | |
52 | |
53 sizes.min_content = LayoutUnit(100); | |
54 sizes.max_content = LayoutUnit(300); | |
55 EXPECT_EQ(LayoutUnit(200), sizes.ShrinkToFit(LayoutUnit(200))); | |
56 | |
57 sizes.min_content = LayoutUnit(200); | |
58 sizes.max_content = LayoutUnit(300); | |
59 EXPECT_EQ(LayoutUnit(200), sizes.ShrinkToFit(LayoutUnit(100))); | |
60 } | |
61 | |
62 } // namespace | 46 } // namespace |
63 | 47 |
64 } // namespace blink | 48 } // namespace blink |
OLD | NEW |