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

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

Issue 2809983002: Fix g_k_* symbols after blink rename. (Closed)
Patch Set: Created 3 years, 8 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
11 namespace blink { 11 namespace blink {
12 12
13 namespace { 13 namespace {
14 14
15 class LayoutTextTest : public RenderingTest { 15 class LayoutTextTest : public RenderingTest {
16 public: 16 public:
17 void SetBasicBody(const char* message) { 17 void SetBasicBody(const char* message) {
18 SetBodyInnerHTML(String::Format( 18 SetBodyInnerHTML(String::Format(
19 "<div id='target' style='font-size: 10px;'>%s</div>", message)); 19 "<div id='target' style='font-size: 10px;'>%s</div>", message));
20 } 20 }
21 21
22 LayoutText* GetBasicText() { 22 LayoutText* GetBasicText() {
23 return ToLayoutText(GetLayoutObjectByElementId("target")->SlowFirstChild()); 23 return ToLayoutText(GetLayoutObjectByElementId("target")->SlowFirstChild());
24 } 24 }
25 }; 25 };
26 26
27 const char* g_k_taco_text = "Los Compadres Taco Truck"; 27 const char kTacoText[] = "Los Compadres Taco Truck";
28 28
29 } // namespace 29 } // namespace
30 30
31 TEST_F(LayoutTextTest, WidthZeroFromZeroLength) { 31 TEST_F(LayoutTextTest, WidthZeroFromZeroLength) {
32 SetBasicBody(g_k_taco_text); 32 SetBasicBody(kTacoText);
33 ASSERT_EQ(0, GetBasicText()->Width(0u, 0u, LayoutUnit(), TextDirection::kLtr, 33 ASSERT_EQ(0, GetBasicText()->Width(0u, 0u, LayoutUnit(), TextDirection::kLtr,
34 false)); 34 false));
35 } 35 }
36 36
37 TEST_F(LayoutTextTest, WidthMaxFromZeroLength) { 37 TEST_F(LayoutTextTest, WidthMaxFromZeroLength) {
38 SetBasicBody(g_k_taco_text); 38 SetBasicBody(kTacoText);
39 ASSERT_EQ(0, GetBasicText()->Width(std::numeric_limits<unsigned>::max(), 0u, 39 ASSERT_EQ(0, GetBasicText()->Width(std::numeric_limits<unsigned>::max(), 0u,
40 LayoutUnit(), TextDirection::kLtr, false)); 40 LayoutUnit(), TextDirection::kLtr, false));
41 } 41 }
42 42
43 TEST_F(LayoutTextTest, WidthZeroFromMaxLength) { 43 TEST_F(LayoutTextTest, WidthZeroFromMaxLength) {
44 SetBasicBody(g_k_taco_text); 44 SetBasicBody(kTacoText);
45 float width = GetBasicText()->Width(0u, std::numeric_limits<unsigned>::max(), 45 float width = GetBasicText()->Width(0u, std::numeric_limits<unsigned>::max(),
46 LayoutUnit(), TextDirection::kLtr, false); 46 LayoutUnit(), TextDirection::kLtr, false);
47 // Width may vary by platform and we just want to make sure it's something 47 // Width may vary by platform and we just want to make sure it's something
48 // roughly reasonable. 48 // roughly reasonable.
49 ASSERT_GE(width, 100.f); 49 ASSERT_GE(width, 100.f);
50 ASSERT_LE(width, 160.f); 50 ASSERT_LE(width, 160.f);
51 } 51 }
52 52
53 TEST_F(LayoutTextTest, WidthMaxFromMaxLength) { 53 TEST_F(LayoutTextTest, WidthMaxFromMaxLength) {
54 SetBasicBody(g_k_taco_text); 54 SetBasicBody(kTacoText);
55 ASSERT_EQ(0, GetBasicText()->Width(std::numeric_limits<unsigned>::max(), 55 ASSERT_EQ(0, GetBasicText()->Width(std::numeric_limits<unsigned>::max(),
56 std::numeric_limits<unsigned>::max(), 56 std::numeric_limits<unsigned>::max(),
57 LayoutUnit(), TextDirection::kLtr, false)); 57 LayoutUnit(), TextDirection::kLtr, false));
58 } 58 }
59 59
60 TEST_F(LayoutTextTest, WidthWithHugeLengthAvoidsOverflow) { 60 TEST_F(LayoutTextTest, WidthWithHugeLengthAvoidsOverflow) {
61 // The test case from http://crbug.com/647820 uses a 288-length string, so for 61 // The test case from http://crbug.com/647820 uses a 288-length string, so for
62 // posterity we follow that closely. 62 // posterity we follow that closely.
63 SetBodyInnerHTML( 63 SetBodyInnerHTML(
64 "<div " 64 "<div "
(...skipping 23 matching lines...) Expand all
88 SetBasicBody("x"); 88 SetBasicBody("x");
89 // Width may vary by platform and we just want to make sure it's something 89 // Width may vary by platform and we just want to make sure it's something
90 // roughly reasonable. 90 // roughly reasonable.
91 const float width = 91 const float width =
92 GetBasicText()->Width(0u, 2u, LayoutUnit(), TextDirection::kLtr, false); 92 GetBasicText()->Width(0u, 2u, LayoutUnit(), TextDirection::kLtr, false);
93 ASSERT_GE(width, 4.f); 93 ASSERT_GE(width, 4.f);
94 ASSERT_LE(width, 20.f); 94 ASSERT_LE(width, 20.f);
95 } 95 }
96 96
97 } // namespace blink 97 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698