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/ng_units.h" |
6 | 6 |
7 #include "platform/text/TextDirection.h" | 7 #include "platform/text/TextDirection.h" |
8 #include "core/layout/ng/ng_writing_mode.h" | 8 #include "core/layout/ng/ng_writing_mode.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 inner_size); | 62 inner_size); |
63 EXPECT_EQ(LayoutUnit(30), offset.left); | 63 EXPECT_EQ(LayoutUnit(30), offset.left); |
64 EXPECT_EQ(LayoutUnit(315), offset.top); | 64 EXPECT_EQ(LayoutUnit(315), offset.top); |
65 | 65 |
66 offset = logical_offset.ConvertToPhysical(SidewaysLeftRight, RTL, outer_size, | 66 offset = logical_offset.ConvertToPhysical(SidewaysLeftRight, RTL, outer_size, |
67 inner_size); | 67 inner_size); |
68 EXPECT_EQ(LayoutUnit(30), offset.left); | 68 EXPECT_EQ(LayoutUnit(30), offset.left); |
69 EXPECT_EQ(LayoutUnit(20), offset.top); | 69 EXPECT_EQ(LayoutUnit(20), offset.top); |
70 } | 70 } |
71 | 71 |
| 72 // Ideally, this would be tested by NGBoxStrut::ConvertToPhysical, but |
| 73 // this has not been implemented yet. |
| 74 TEST(NGUnitsTest, ConvertPhysicalStrutToLogical) { |
| 75 LayoutUnit left{5}, right{10}, top{15}, bottom{20}; |
| 76 NGPhysicalBoxStrut physical{left, right, top, bottom}; |
| 77 |
| 78 NGBoxStrut logical = physical.ConvertToLogical(HorizontalTopBottom, LTR); |
| 79 EXPECT_EQ(left, logical.inline_start); |
| 80 EXPECT_EQ(top, logical.block_start); |
| 81 |
| 82 logical = physical.ConvertToLogical(HorizontalTopBottom, RTL); |
| 83 EXPECT_EQ(right, logical.inline_start); |
| 84 EXPECT_EQ(top, logical.block_start); |
| 85 |
| 86 logical = physical.ConvertToLogical(VerticalLeftRight, LTR); |
| 87 EXPECT_EQ(top, logical.inline_start); |
| 88 EXPECT_EQ(left, logical.block_start); |
| 89 |
| 90 logical = physical.ConvertToLogical(VerticalLeftRight, RTL); |
| 91 EXPECT_EQ(bottom, logical.inline_start); |
| 92 EXPECT_EQ(left, logical.block_start); |
| 93 |
| 94 logical = physical.ConvertToLogical(VerticalRightLeft, LTR); |
| 95 EXPECT_EQ(top, logical.inline_start); |
| 96 EXPECT_EQ(right, logical.block_start); |
| 97 |
| 98 logical = physical.ConvertToLogical(VerticalRightLeft, RTL); |
| 99 EXPECT_EQ(bottom, logical.inline_start); |
| 100 EXPECT_EQ(right, logical.block_start); |
| 101 } |
| 102 |
72 } // namespace | 103 } // namespace |
73 | 104 |
74 } // namespace blink | 105 } // namespace blink |
OLD | NEW |