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

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

Issue 2706403008: [LayoutNG] Implement ComputeMinAndMaxContentSizes for inline (Closed)
Patch Set: cbiesinger review 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
Index: third_party/WebKit/Source/core/layout/ng/ng_inline_node_test.cc
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_inline_node_test.cc b/third_party/WebKit/Source/core/layout/ng/ng_inline_node_test.cc
index 2568b2c89c1da8751a37afd83551a26eaebd3b9a..031605191cb1e817ebb66c6e576b8f3b5890cdeb 100644
--- a/third_party/WebKit/Source/core/layout/ng/ng_inline_node_test.cc
+++ b/third_party/WebKit/Source/core/layout/ng/ng_inline_node_test.cc
@@ -4,6 +4,7 @@
#include "core/layout/ng/ng_inline_node.h"
+#include "core/layout/LayoutTestHelper.h"
#include "core/layout/ng/ng_constraint_space.h"
#include "core/layout/ng/ng_constraint_space_builder.h"
#include "core/layout/ng/ng_fragment_builder.h"
@@ -54,15 +55,27 @@ class NGInlineNodeForTest : public NGInlineNode {
is_bidi_enabled_ = true;
NGInlineNode::SegmentText();
}
+
+ using NGInlineNode::ShapeText;
};
-class NGInlineNodeTest : public ::testing::Test {
+class NGInlineNodeTest : public RenderingTest {
protected:
void SetUp() override {
+ RenderingTest::SetUp();
style_ = ComputedStyle::create();
style_->font().update(nullptr);
}
+ void setAhemToStyle() {
+ // Get Ahem from document. Loading "Ahem.woff" using |createTestFont| fails
+ // on linux_chromium_asan_rel_ng.
+ loadAhem();
+ setBodyInnerHTML("<div id=t style='font:10px Ahem'></div>");
+ LayoutObject* layout_object = getLayoutObjectByElementId("t");
+ style_->setFont(layout_object->style()->font());
+ }
+
void CreateLine(NGInlineNode* node,
Vector<RefPtr<const NGPhysicalTextFragment>>* fragments_out) {
NGConstraintSpace* constraint_space =
@@ -191,6 +204,7 @@ TEST_F(NGInlineNodeTest, SegmentBidiIsolate) {
TEST_F(NGInlineNodeTest, CreateLineBidiIsolate) {
RefPtr<ComputedStyle> style = ComputedStyle::create();
style->setLineHeight(Length(1, Fixed));
+ style->font().update(nullptr);
NGInlineNodeForTest* node = CreateBidiIsolateNode(style.get());
Vector<RefPtr<const NGPhysicalTextFragment>> fragments;
CreateLine(node, &fragments);
@@ -202,4 +216,31 @@ TEST_F(NGInlineNodeTest, CreateLineBidiIsolate) {
TEST_TEXT_FRAGMENT(fragments[4], node, 8u, 22u, 28u, TextDirection::kLtr);
}
+TEST_F(NGInlineNodeTest, MinAndMaxContentSizes) {
+ setAhemToStyle();
+ NGInlineNodeForTest* node = new NGInlineNodeForTest(style_.get());
+ node->Append("AB CDE", style_.get());
+ node->ShapeText();
+ MinAndMaxContentSizes sizes = node->ComputeMinAndMaxContentSizes();
+ // TODO(kojii): min_content should be 20, but is 30 until NGLineBuilder
+ // implements trailing spaces correctly.
+ EXPECT_EQ(30, sizes.min_content);
+ EXPECT_EQ(60, sizes.max_content);
+}
+
+TEST_F(NGInlineNodeTest, MinAndMaxContentSizesElementBoundary) {
+ setAhemToStyle();
+ NGInlineNodeForTest* node = new NGInlineNodeForTest(style_.get());
+ node->Append("A B", style_.get());
+ node->Append("C D", style_.get());
+ node->ShapeText();
+ MinAndMaxContentSizes sizes = node->ComputeMinAndMaxContentSizes();
+ // |min_content| should be the width of "BC" because there is an element
+ // boundary between "B" and "C" but no break opportunities.
+ // TODO(kojii): min_content should be 20, but is 30 until NGLineBuilder
+ // implements trailing spaces correctly.
+ EXPECT_EQ(30, sizes.min_content);
+ EXPECT_EQ(60, sizes.max_content);
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_inline_node.cc ('k') | third_party/WebKit/Source/core/layout/ng/ng_line_builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698