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

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

Issue 2455223002: Fix LayoutTableSectionTest test cases which called a method on nil. (Closed)
Patch Set: fix bad merge Created 4 years, 1 month 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
« no previous file with comments | « testing/buildbot/chromium.fyi.json ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/LayoutTableSection.h" 5 #include "core/layout/LayoutTableSection.h"
6 6
7 #include "core/layout/LayoutTestHelper.h" 7 #include "core/layout/LayoutTestHelper.h"
8 8
9 namespace blink { 9 namespace blink {
10 10
11 namespace { 11 namespace {
12 12
13 using LayoutTableSectionTest = RenderingTest; 13 using LayoutTableSectionTest = RenderingTest;
14 14
15 TEST_F(LayoutTableSectionTest, 15 TEST_F(LayoutTableSectionTest,
16 BackgroundIsKnownToBeOpaqueWithLayerAndCollapsedBorder) { 16 BackgroundIsKnownToBeOpaqueWithLayerAndCollapsedBorder) {
17 setBodyInnerHTML( 17 setBodyInnerHTML(
18 "<table style='border-collapse: collapse'>" 18 "<table style='border-collapse: collapse'>"
19 " <thead style='will-change: transform; background-color: blue'>" 19 " <thead id='section' style='will-change: transform; background-color: "
20 "blue'>"
20 " <tr><td>Cell</td></tr>" 21 " <tr><td>Cell</td></tr>"
21 " </thead>" 22 " </thead>"
22 "</table>"); 23 "</table>");
23 24
24 LayoutTableSection* section = toLayoutTableSection( 25 LayoutTableSection* section =
25 document().body()->firstChild()->firstChild()->layoutObject()); 26 toLayoutTableSection(getLayoutObjectByElementId("section"));
27 EXPECT_TRUE(section);
26 EXPECT_FALSE( 28 EXPECT_FALSE(
27 section->backgroundIsKnownToBeOpaqueInRect(LayoutRect(0, 0, 1, 1))); 29 section->backgroundIsKnownToBeOpaqueInRect(LayoutRect(0, 0, 1, 1)));
28 } 30 }
29 31
30 TEST_F(LayoutTableSectionTest, BackgroundIsKnownToBeOpaqueWithBorderSpacing) { 32 TEST_F(LayoutTableSectionTest, BackgroundIsKnownToBeOpaqueWithBorderSpacing) {
31 setBodyInnerHTML( 33 setBodyInnerHTML(
32 "<table style='border-spacing: 10px'>" 34 "<table style='border-spacing: 10px'>"
33 " <thead style='background-color: blue'>" 35 " <thead id='section' style='background-color: blue'>"
34 " <tr><td>Cell</td></tr>" 36 " <tr><td>Cell</td></tr>"
35 " </thead>" 37 " </thead>"
36 "</table>"); 38 "</table>");
37 39
38 LayoutTableSection* section = toLayoutTableSection( 40 LayoutTableSection* section =
39 document().body()->firstChild()->firstChild()->layoutObject()); 41 toLayoutTableSection(getLayoutObjectByElementId("section"));
42 EXPECT_TRUE(section);
40 EXPECT_FALSE( 43 EXPECT_FALSE(
41 section->backgroundIsKnownToBeOpaqueInRect(LayoutRect(0, 0, 1, 1))); 44 section->backgroundIsKnownToBeOpaqueInRect(LayoutRect(0, 0, 1, 1)));
42 } 45 }
43 46
44 TEST_F(LayoutTableSectionTest, BackgroundIsKnownToBeOpaqueWithEmptyCell) { 47 TEST_F(LayoutTableSectionTest, BackgroundIsKnownToBeOpaqueWithEmptyCell) {
45 setBodyInnerHTML( 48 setBodyInnerHTML(
46 "<table style='border-spacing: 10px'>" 49 "<table style='border-spacing: 10px'>"
47 " <thead style='background-color: blue'>" 50 " <thead id='section' style='background-color: blue'>"
48 " <tr><td>Cell</td></tr>" 51 " <tr><td>Cell</td></tr>"
49 " <tr><td>Cell</td><td>Cell</td></tr>" 52 " <tr><td>Cell</td><td>Cell</td></tr>"
50 " </thead>" 53 " </thead>"
51 "</table>"); 54 "</table>");
52 55
53 LayoutTableSection* section = toLayoutTableSection( 56 LayoutTableSection* section =
54 document().body()->firstChild()->firstChild()->layoutObject()); 57 toLayoutTableSection(getLayoutObjectByElementId("section"));
58 EXPECT_TRUE(section);
55 EXPECT_FALSE( 59 EXPECT_FALSE(
56 section->backgroundIsKnownToBeOpaqueInRect(LayoutRect(0, 0, 1, 1))); 60 section->backgroundIsKnownToBeOpaqueInRect(LayoutRect(0, 0, 1, 1)));
57 } 61 }
58 62
59 TEST_F(LayoutTableSectionTest, EmptySectionDirtiedRows) { 63 TEST_F(LayoutTableSectionTest, EmptySectionDirtiedRows) {
60 setBodyInnerHTML( 64 setBodyInnerHTML(
61 "<table style='border: 100px solid red'>" 65 "<table style='border: 100px solid red'>"
62 " <thead id='section'></thead>" 66 " <thead id='section'></thead>"
63 "</table>"); 67 "</table>");
64 68
65 LayoutTableSection* section = 69 LayoutTableSection* section =
66 toLayoutTableSection(getLayoutObjectByElementId("section")); 70 toLayoutTableSection(getLayoutObjectByElementId("section"));
71 EXPECT_TRUE(section);
67 CellSpan cellSpan = section->dirtiedRows(LayoutRect(50, 50, 100, 100)); 72 CellSpan cellSpan = section->dirtiedRows(LayoutRect(50, 50, 100, 100));
68 EXPECT_EQ(0u, cellSpan.start()); 73 EXPECT_EQ(0u, cellSpan.start());
69 EXPECT_EQ(0u, cellSpan.end()); 74 EXPECT_EQ(0u, cellSpan.end());
70 } 75 }
71 76
72 TEST_F(LayoutTableSectionTest, EmptySectionDirtiedEffectiveColumns) { 77 TEST_F(LayoutTableSectionTest, EmptySectionDirtiedEffectiveColumns) {
73 setBodyInnerHTML( 78 setBodyInnerHTML(
74 "<table style='border: 100px solid red'>" 79 "<table style='border: 100px solid red'>"
75 " <thead id='section'></thead>" 80 " <thead id='section'></thead>"
76 "</table>"); 81 "</table>");
77 82
78 LayoutTableSection* section = 83 LayoutTableSection* section =
79 toLayoutTableSection(getLayoutObjectByElementId("section")); 84 toLayoutTableSection(getLayoutObjectByElementId("section"));
85 EXPECT_TRUE(section);
80 CellSpan cellSpan = 86 CellSpan cellSpan =
81 section->dirtiedEffectiveColumns(LayoutRect(50, 50, 100, 100)); 87 section->dirtiedEffectiveColumns(LayoutRect(50, 50, 100, 100));
82 // The table has at least 1 column even if there is no cell. 88 // The table has at least 1 column even if there is no cell.
83 EXPECT_EQ(1u, section->table()->numEffectiveColumns()); 89 EXPECT_EQ(1u, section->table()->numEffectiveColumns());
84 EXPECT_EQ(1u, cellSpan.start()); 90 EXPECT_EQ(1u, cellSpan.start());
85 EXPECT_EQ(1u, cellSpan.end()); 91 EXPECT_EQ(1u, cellSpan.end());
86 } 92 }
87 93
88 } // anonymous namespace 94 } // anonymous namespace
89 95
90 } // namespace blink 96 } // namespace blink
OLDNEW
« no previous file with comments | « testing/buildbot/chromium.fyi.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698