| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "core/layout/ng/ng_units.h" | |
| 6 | |
| 7 #include "testing/gtest/include/gtest/gtest.h" | |
| 8 | |
| 9 namespace blink { | |
| 10 | |
| 11 namespace { | |
| 12 | |
| 13 // Ideally, this would be tested by NGBoxStrut::ConvertToPhysical, but | |
| 14 // this has not been implemented yet. | |
| 15 TEST(NGUnitsTest, ConvertPhysicalStrutToLogical) { | |
| 16 LayoutUnit left{5}, right{10}, top{15}, bottom{20}; | |
| 17 NGPhysicalBoxStrut physical{left, right, top, bottom}; | |
| 18 | |
| 19 NGBoxStrut logical = | |
| 20 physical.ConvertToLogical(kHorizontalTopBottom, TextDirection::kLtr); | |
| 21 EXPECT_EQ(left, logical.inline_start); | |
| 22 EXPECT_EQ(top, logical.block_start); | |
| 23 | |
| 24 logical = | |
| 25 physical.ConvertToLogical(kHorizontalTopBottom, TextDirection::kRtl); | |
| 26 EXPECT_EQ(right, logical.inline_start); | |
| 27 EXPECT_EQ(top, logical.block_start); | |
| 28 | |
| 29 logical = physical.ConvertToLogical(kVerticalLeftRight, TextDirection::kLtr); | |
| 30 EXPECT_EQ(top, logical.inline_start); | |
| 31 EXPECT_EQ(left, logical.block_start); | |
| 32 | |
| 33 logical = physical.ConvertToLogical(kVerticalLeftRight, TextDirection::kRtl); | |
| 34 EXPECT_EQ(bottom, logical.inline_start); | |
| 35 EXPECT_EQ(left, logical.block_start); | |
| 36 | |
| 37 logical = physical.ConvertToLogical(kVerticalRightLeft, TextDirection::kLtr); | |
| 38 EXPECT_EQ(top, logical.inline_start); | |
| 39 EXPECT_EQ(right, logical.block_start); | |
| 40 | |
| 41 logical = physical.ConvertToLogical(kVerticalRightLeft, TextDirection::kRtl); | |
| 42 EXPECT_EQ(bottom, logical.inline_start); | |
| 43 EXPECT_EQ(right, logical.block_start); | |
| 44 } | |
| 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 | |
| 63 | |
| 64 } // namespace blink | |
| OLD | NEW |