| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/html/HTMLTableRowElement.h" | 5 #include "core/html/HTMLTableRowElement.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/html/HTMLParagraphElement.h" | 8 #include "core/html/HTMLParagraphElement.h" |
| 9 #include "core/html/HTMLTableElement.h" | 9 #include "core/html/HTMLTableElement.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 using namespace blink; | 14 using namespace blink; |
| 15 | 15 |
| 16 // rowIndex | 16 // rowIndex |
| 17 // https://html.spec.whatwg.org/multipage/tables.html#dom-tr-rowindex | 17 // https://html.spec.whatwg.org/multipage/tables.html#dom-tr-rowindex |
| 18 | 18 |
| 19 TEST(HTMLTableRowElementTest, rowIndex_notInTable) | 19 TEST(HTMLTableRowElementTest, rowIndex_notInTable) |
| 20 { | 20 { |
| 21 RefPtrWillBeRawPtr<Document> document = Document::create(); | 21 RawPtr<Document> document = Document::create(); |
| 22 RefPtrWillBeRawPtr<HTMLTableRowElement> row = | 22 RawPtr<HTMLTableRowElement> row = |
| 23 HTMLTableRowElement::create(*document); | 23 HTMLTableRowElement::create(*document); |
| 24 EXPECT_EQ(-1, row->rowIndex()) | 24 EXPECT_EQ(-1, row->rowIndex()) |
| 25 << "rows not in tables should have row index -1"; | 25 << "rows not in tables should have row index -1"; |
| 26 } | 26 } |
| 27 | 27 |
| 28 TEST(HTMLTableRowElementTest, rowIndex_directChildOfTable) | 28 TEST(HTMLTableRowElementTest, rowIndex_directChildOfTable) |
| 29 { | 29 { |
| 30 RefPtrWillBeRawPtr<Document> document = Document::create(); | 30 RawPtr<Document> document = Document::create(); |
| 31 RefPtrWillBeRawPtr<HTMLTableElement> table = | 31 RawPtr<HTMLTableElement> table = |
| 32 HTMLTableElement::create(*document); | 32 HTMLTableElement::create(*document); |
| 33 RefPtrWillBeRawPtr<HTMLTableRowElement> row = | 33 RawPtr<HTMLTableRowElement> row = |
| 34 HTMLTableRowElement::create(*document); | 34 HTMLTableRowElement::create(*document); |
| 35 table->appendChild(row); | 35 table->appendChild(row); |
| 36 EXPECT_EQ(0, row->rowIndex()) | 36 EXPECT_EQ(0, row->rowIndex()) |
| 37 << "rows that are direct children of a table should have a row index"; | 37 << "rows that are direct children of a table should have a row index"; |
| 38 } | 38 } |
| 39 | 39 |
| 40 TEST(HTMLTableRowElementTest, rowIndex_inUnrelatedElementInTable) | 40 TEST(HTMLTableRowElementTest, rowIndex_inUnrelatedElementInTable) |
| 41 { | 41 { |
| 42 RefPtrWillBeRawPtr<Document> document = Document::create(); | 42 RawPtr<Document> document = Document::create(); |
| 43 RefPtrWillBeRawPtr<HTMLTableElement> table = | 43 RawPtr<HTMLTableElement> table = |
| 44 HTMLTableElement::create(*document); | 44 HTMLTableElement::create(*document); |
| 45 // Almost any element will do; what's pertinent is that this is not | 45 // Almost any element will do; what's pertinent is that this is not |
| 46 // THEAD, TBODY or TFOOT. | 46 // THEAD, TBODY or TFOOT. |
| 47 RefPtrWillBeRawPtr<HTMLParagraphElement> paragraph = | 47 RawPtr<HTMLParagraphElement> paragraph = |
| 48 HTMLParagraphElement::create(*document); | 48 HTMLParagraphElement::create(*document); |
| 49 RefPtrWillBeRawPtr<HTMLTableRowElement> row = | 49 RawPtr<HTMLTableRowElement> row = |
| 50 HTMLTableRowElement::create(*document); | 50 HTMLTableRowElement::create(*document); |
| 51 table->appendChild(paragraph); | 51 table->appendChild(paragraph); |
| 52 paragraph->appendChild(row); | 52 paragraph->appendChild(row); |
| 53 EXPECT_EQ(-1, row->rowIndex()) | 53 EXPECT_EQ(-1, row->rowIndex()) |
| 54 << "rows in a table, but within an unrelated element, should have " | 54 << "rows in a table, but within an unrelated element, should have " |
| 55 << "row index -1"; | 55 << "row index -1"; |
| 56 } | 56 } |
| 57 | 57 |
| 58 } // namespace | 58 } // namespace |
| OLD | NEW |