| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "config.h" | 5 #include "config.h" |
| 6 #include "public/web/WebNode.h" | 6 #include "public/web/WebNode.h" |
| 7 | 7 |
| 8 #include "core/testing/DummyPageHolder.h" | 8 #include "core/testing/DummyPageHolder.h" |
| 9 #include "public/web/WebElement.h" | 9 #include "public/web/WebElement.h" |
| 10 #include "public/web/WebElementCollection.h" | 10 #include "public/web/WebElementCollection.h" |
| 11 #include <gtest/gtest.h> | 11 #include <gtest/gtest.h> |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 using blink::Document; | |
| 16 using blink::DummyPageHolder; | |
| 17 using blink::IntSize; | |
| 18 | |
| 19 class WebNodeTest : public testing::Test { | 15 class WebNodeTest : public testing::Test { |
| 20 protected: | 16 protected: |
| 21 Document& document() { return m_pageHolder->document(); } | 17 Document& document() { return m_pageHolder->document(); } |
| 22 | 18 |
| 23 private: | 19 private: |
| 24 virtual void SetUp() OVERRIDE; | 20 virtual void SetUp() OVERRIDE; |
| 25 | 21 |
| 26 OwnPtr<DummyPageHolder> m_pageHolder; | 22 OwnPtr<DummyPageHolder> m_pageHolder; |
| 27 }; | 23 }; |
| 28 | 24 |
| 29 void WebNodeTest::SetUp() | 25 void WebNodeTest::SetUp() |
| 30 { | 26 { |
| 31 m_pageHolder = blink::DummyPageHolder::create(IntSize(800, 600)); | 27 m_pageHolder = DummyPageHolder::create(IntSize(800, 600)); |
| 32 } | 28 } |
| 33 | 29 |
| 34 TEST_F(WebNodeTest, GetElementsByHTMLTagName) | 30 TEST_F(WebNodeTest, GetElementsByHTMLTagName) |
| 35 { | 31 { |
| 36 document().documentElement()->setInnerHTML("<body><LABEL></LABEL><svg xmlns=
'http://www.w3.org/2000/svg'><label></label></svg></body>", ASSERT_NO_EXCEPTION)
; | 32 document().documentElement()->setInnerHTML("<body><LABEL></LABEL><svg xmlns=
'http://www.w3.org/2000/svg'><label></label></svg></body>", ASSERT_NO_EXCEPTION)
; |
| 37 WebNode node(document().documentElement()); | 33 WebNode node(document().documentElement()); |
| 38 // WebNode::getElementsByHTMLTagName returns only HTML elements. | 34 // WebNode::getElementsByHTMLTagName returns only HTML elements. |
| 39 WebElementCollection collection = node.getElementsByHTMLTagName("label"); | 35 WebElementCollection collection = node.getElementsByHTMLTagName("label"); |
| 40 EXPECT_EQ(1u, collection.length()); | 36 EXPECT_EQ(1u, collection.length()); |
| 41 EXPECT_TRUE(collection.firstItem().hasHTMLTagName("label")); | 37 EXPECT_TRUE(collection.firstItem().hasHTMLTagName("label")); |
| 42 // The argument should be lower-case. | 38 // The argument should be lower-case. |
| 43 collection = node.getElementsByHTMLTagName("LABEL"); | 39 collection = node.getElementsByHTMLTagName("LABEL"); |
| 44 EXPECT_EQ(0u, collection.length()); | 40 EXPECT_EQ(0u, collection.length()); |
| 45 } | 41 } |
| 46 | 42 |
| 47 } | 43 } |
| OLD | NEW |