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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutTextTest.cpp

Issue 2405633002: Reformat comments in core/layout (Closed)
Patch Set: Created 4 years, 2 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 unified diff | Download patch
OLDNEW
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/LayoutText.h" 5 #include "core/layout/LayoutText.h"
6 6
7 #include "core/layout/LayoutTestHelper.h" 7 #include "core/layout/LayoutTestHelper.h"
8 #include "core/layout/line/InlineTextBox.h" 8 #include "core/layout/line/InlineTextBox.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 25 matching lines...) Expand all
36 TEST_F(LayoutTextTest, WidthMaxFromZeroLength) { 36 TEST_F(LayoutTextTest, WidthMaxFromZeroLength) {
37 setBasicBody(kTacoText); 37 setBasicBody(kTacoText);
38 ASSERT_EQ(0, getBasicText()->width(std::numeric_limits<unsigned>::max(), 0u, 38 ASSERT_EQ(0, getBasicText()->width(std::numeric_limits<unsigned>::max(), 0u,
39 LayoutUnit(), LTR, false)); 39 LayoutUnit(), LTR, false));
40 } 40 }
41 41
42 TEST_F(LayoutTextTest, WidthZeroFromMaxLength) { 42 TEST_F(LayoutTextTest, WidthZeroFromMaxLength) {
43 setBasicBody(kTacoText); 43 setBasicBody(kTacoText);
44 float width = getBasicText()->width(0u, std::numeric_limits<unsigned>::max(), 44 float width = getBasicText()->width(0u, std::numeric_limits<unsigned>::max(),
45 LayoutUnit(), LTR, false); 45 LayoutUnit(), LTR, false);
46 // Width may vary by platform and we just want to make sure it's something rou ghly reasonable. 46 // Width may vary by platform and we just want to make sure it's something
47 // roughly reasonable.
47 ASSERT_GE(width, 100.f); 48 ASSERT_GE(width, 100.f);
48 ASSERT_LE(width, 160.f); 49 ASSERT_LE(width, 160.f);
49 } 50 }
50 51
51 TEST_F(LayoutTextTest, WidthMaxFromMaxLength) { 52 TEST_F(LayoutTextTest, WidthMaxFromMaxLength) {
52 setBasicBody(kTacoText); 53 setBasicBody(kTacoText);
53 ASSERT_EQ(0, getBasicText()->width(std::numeric_limits<unsigned>::max(), 54 ASSERT_EQ(0, getBasicText()->width(std::numeric_limits<unsigned>::max(),
54 std::numeric_limits<unsigned>::max(), 55 std::numeric_limits<unsigned>::max(),
55 LayoutUnit(), LTR, false)); 56 LayoutUnit(), LTR, false));
56 } 57 }
57 58
58 TEST_F(LayoutTextTest, WidthWithHugeLengthAvoidsOverflow) { 59 TEST_F(LayoutTextTest, WidthWithHugeLengthAvoidsOverflow) {
59 // The test case from http://crbug.com/647820 uses a 288-length string, so for posterity we follow that closely. 60 // The test case from http://crbug.com/647820 uses a 288-length string, so for
61 // posterity we follow that closely.
60 setBodyInnerHTML( 62 setBodyInnerHTML(
61 "<div " 63 "<div "
62 "id='target'>" 64 "id='target'>"
63 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" 65 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
64 "xxxx" 66 "xxxx"
65 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" 67 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
66 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" 68 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
67 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" 69 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
68 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" 70 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
69 "</div>"); 71 "</div>");
70 // Width may vary by platform and we just want to make sure it's something rou ghly reasonable. 72 // Width may vary by platform and we just want to make sure it's something
73 // roughly reasonable.
71 float width = 74 float width =
72 getBasicText()->width(23u, 4294967282u, LayoutUnit(2.59375), RTL, false); 75 getBasicText()->width(23u, 4294967282u, LayoutUnit(2.59375), RTL, false);
73 ASSERT_GE(width, 100.f); 76 ASSERT_GE(width, 100.f);
74 ASSERT_LE(width, 300.f); 77 ASSERT_LE(width, 300.f);
75 } 78 }
76 79
77 TEST_F(LayoutTextTest, WidthFromBeyondLength) { 80 TEST_F(LayoutTextTest, WidthFromBeyondLength) {
78 setBasicBody("x"); 81 setBasicBody("x");
79 ASSERT_EQ(0u, getBasicText()->width(1u, 1u, LayoutUnit(), LTR, false)); 82 ASSERT_EQ(0u, getBasicText()->width(1u, 1u, LayoutUnit(), LTR, false));
80 } 83 }
81 84
82 TEST_F(LayoutTextTest, WidthLengthBeyondLength) { 85 TEST_F(LayoutTextTest, WidthLengthBeyondLength) {
83 setBasicBody("x"); 86 setBasicBody("x");
84 // Width may vary by platform and we just want to make sure it's something rou ghly reasonable. 87 // Width may vary by platform and we just want to make sure it's something
88 // roughly reasonable.
85 float width = getBasicText()->width(0u, 2u, LayoutUnit(), LTR, false); 89 float width = getBasicText()->width(0u, 2u, LayoutUnit(), LTR, false);
86 ASSERT_GE(width, 4.f); 90 ASSERT_GE(width, 4.f);
87 ASSERT_LE(width, 20.f); 91 ASSERT_LE(width, 20.f);
88 } 92 }
89 93
90 } // namespace blink 94 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698