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_constraint_space.h" | 5 #include "core/layout/ng/ng_constraint_space.h" |
6 | 6 |
7 #include "core/layout/ng/ng_constraint_space.h" | 7 #include "core/layout/ng/ng_constraint_space.h" |
8 #include "core/layout/ng/ng_layout_opportunity_iterator.h" | 8 #include "core/layout/ng/ng_layout_opportunity_iterator.h" |
9 #include "core/layout/ng/ng_physical_constraint_space.h" | 9 #include "core/layout/ng/ng_physical_constraint_space.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 NGConstraintSpace* ConstructConstraintSpace(NGWritingMode writing_mode, | 16 NGConstraintSpace* ConstructConstraintSpace(NGWritingMode writing_mode, |
17 NGDirection direction, | 17 NGDirection direction, |
18 NGPhysicalSize size) { | 18 NGPhysicalSize size) { |
19 return new NGConstraintSpace( | 19 return new NGConstraintSpace( |
20 writing_mode, direction, | 20 writing_mode, direction, |
21 new NGPhysicalConstraintSpace( | 21 new NGPhysicalConstraintSpace( |
22 size, /* fixed_width */ true, /* fixed_height */ false, | 22 size, size, /* fixed_width */ true, /* fixed_height */ false, |
23 /* width_direction_triggers_scrollbar */ true, | 23 /* width_direction_triggers_scrollbar */ true, |
24 /* height_direction_triggers_scrollbar */ false, FragmentNone, | 24 /* height_direction_triggers_scrollbar */ false, FragmentNone, |
25 FragmentColumn, /* is_new_fc */ false)); | 25 FragmentColumn, /* is_new_fc */ false)); |
26 } | 26 } |
27 | 27 |
28 TEST(NGConstraintSpaceTest, WritingMode) { | 28 TEST(NGConstraintSpaceTest, WritingMode) { |
29 NGPhysicalConstraintSpace* phy_space = new NGPhysicalConstraintSpace( | 29 NGPhysicalConstraintSpace* phy_space = new NGPhysicalConstraintSpace( |
| 30 NGPhysicalSize(LayoutUnit(200), LayoutUnit(100)), |
30 NGPhysicalSize(LayoutUnit(200), LayoutUnit(100)), /* fixed_width */ true, | 31 NGPhysicalSize(LayoutUnit(200), LayoutUnit(100)), /* fixed_width */ true, |
31 /* fixed_height */ false, /* width_direction_triggers_scrollbar */ true, | 32 /* fixed_height */ false, /* width_direction_triggers_scrollbar */ true, |
32 /* height_direction_triggers_scrollbar */ false, FragmentNone, | 33 /* height_direction_triggers_scrollbar */ false, FragmentNone, |
33 FragmentColumn, /* is_new_fc */ false); | 34 FragmentColumn, /* is_new_fc */ false); |
34 | 35 |
35 NGConstraintSpace* horz_space = | 36 NGConstraintSpace* horz_space = |
36 new NGConstraintSpace(HorizontalTopBottom, LeftToRight, phy_space); | 37 new NGConstraintSpace(HorizontalTopBottom, LeftToRight, phy_space); |
37 | 38 |
38 NGConstraintSpace* vert_space = | 39 NGConstraintSpace* vert_space = |
39 new NGConstraintSpace(VerticalRightLeft, LeftToRight, phy_space); | 40 new NGConstraintSpace(VerticalRightLeft, LeftToRight, phy_space); |
40 | 41 |
41 EXPECT_EQ(LayoutUnit(200), horz_space->ContainerSize().inline_size); | 42 EXPECT_EQ(LayoutUnit(200), horz_space->AvailableSize().inline_size); |
42 EXPECT_EQ(LayoutUnit(200), vert_space->ContainerSize().block_size); | 43 EXPECT_EQ(LayoutUnit(200), vert_space->AvailableSize().block_size); |
43 | 44 |
44 EXPECT_EQ(LayoutUnit(100), horz_space->ContainerSize().block_size); | 45 EXPECT_EQ(LayoutUnit(100), horz_space->AvailableSize().block_size); |
45 EXPECT_EQ(LayoutUnit(100), vert_space->ContainerSize().inline_size); | 46 EXPECT_EQ(LayoutUnit(100), vert_space->AvailableSize().inline_size); |
46 | 47 |
47 EXPECT_TRUE(horz_space->InlineTriggersScrollbar()); | 48 EXPECT_TRUE(horz_space->InlineTriggersScrollbar()); |
48 EXPECT_TRUE(vert_space->BlockTriggersScrollbar()); | 49 EXPECT_TRUE(vert_space->BlockTriggersScrollbar()); |
49 | 50 |
50 EXPECT_FALSE(horz_space->BlockTriggersScrollbar()); | 51 EXPECT_FALSE(horz_space->BlockTriggersScrollbar()); |
51 EXPECT_FALSE(vert_space->InlineTriggersScrollbar()); | 52 EXPECT_FALSE(vert_space->InlineTriggersScrollbar()); |
52 | 53 |
53 EXPECT_TRUE(horz_space->FixedInlineSize()); | 54 EXPECT_TRUE(horz_space->FixedInlineSize()); |
54 EXPECT_TRUE(vert_space->FixedBlockSize()); | 55 EXPECT_TRUE(vert_space->FixedBlockSize()); |
55 | 56 |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 space->AddExclusion(exclusion); | 281 space->AddExclusion(exclusion); |
281 | 282 |
282 auto* iterator = space->LayoutOpportunities(); | 283 auto* iterator = space->LayoutOpportunities(); |
283 | 284 |
284 EXPECT_EQ("0,0 600x100", OpportunityToString(iterator->Next())); | 285 EXPECT_EQ("0,0 600x100", OpportunityToString(iterator->Next())); |
285 EXPECT_EQ("(empty)", OpportunityToString(iterator->Next())); | 286 EXPECT_EQ("(empty)", OpportunityToString(iterator->Next())); |
286 } | 287 } |
287 | 288 |
288 } // namespace | 289 } // namespace |
289 } // namespace blink | 290 } // namespace blink |
OLD | NEW |