Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(624)

Unified Diff: third_party/WebKit/Source/core/layout/ng/ng_units_test.cc

Issue 2723023003: Revert of [LayoutNG] Move remaining ng_units structs to their own files (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_units.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/ng/ng_units_test.cc
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_units_test.cc b/third_party/WebKit/Source/core/layout/ng/ng_units_test.cc
new file mode 100644
index 0000000000000000000000000000000000000000..cd9b9318b3fbb81ef1e469b3ed1c429ddc5ddcd7
--- /dev/null
+++ b/third_party/WebKit/Source/core/layout/ng/ng_units_test.cc
@@ -0,0 +1,64 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/layout/ng/ng_units.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace blink {
+
+namespace {
+
+// Ideally, this would be tested by NGBoxStrut::ConvertToPhysical, but
+// this has not been implemented yet.
+TEST(NGUnitsTest, ConvertPhysicalStrutToLogical) {
+ LayoutUnit left{5}, right{10}, top{15}, bottom{20};
+ NGPhysicalBoxStrut physical{left, right, top, bottom};
+
+ NGBoxStrut logical =
+ physical.ConvertToLogical(kHorizontalTopBottom, TextDirection::kLtr);
+ EXPECT_EQ(left, logical.inline_start);
+ EXPECT_EQ(top, logical.block_start);
+
+ logical =
+ physical.ConvertToLogical(kHorizontalTopBottom, TextDirection::kRtl);
+ EXPECT_EQ(right, logical.inline_start);
+ EXPECT_EQ(top, logical.block_start);
+
+ logical = physical.ConvertToLogical(kVerticalLeftRight, TextDirection::kLtr);
+ EXPECT_EQ(top, logical.inline_start);
+ EXPECT_EQ(left, logical.block_start);
+
+ logical = physical.ConvertToLogical(kVerticalLeftRight, TextDirection::kRtl);
+ EXPECT_EQ(bottom, logical.inline_start);
+ EXPECT_EQ(left, logical.block_start);
+
+ logical = physical.ConvertToLogical(kVerticalRightLeft, TextDirection::kLtr);
+ EXPECT_EQ(top, logical.inline_start);
+ EXPECT_EQ(right, logical.block_start);
+
+ logical = physical.ConvertToLogical(kVerticalRightLeft, TextDirection::kRtl);
+ EXPECT_EQ(bottom, logical.inline_start);
+ EXPECT_EQ(right, logical.block_start);
+}
+
+TEST(NGUnitsTest, ShrinkToFit) {
+ MinAndMaxContentSizes sizes;
+
+ sizes.min_content = LayoutUnit(100);
+ sizes.max_content = LayoutUnit(200);
+ EXPECT_EQ(LayoutUnit(200), sizes.ShrinkToFit(LayoutUnit(300)));
+
+ sizes.min_content = LayoutUnit(100);
+ sizes.max_content = LayoutUnit(300);
+ EXPECT_EQ(LayoutUnit(200), sizes.ShrinkToFit(LayoutUnit(200)));
+
+ sizes.min_content = LayoutUnit(200);
+ sizes.max_content = LayoutUnit(300);
+ EXPECT_EQ(LayoutUnit(200), sizes.ShrinkToFit(LayoutUnit(100)));
+}
+
+} // namespace
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_units.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698