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 "public/web/WebNode.h" | 5 #include "public/web/WebNode.h" |
6 | 6 |
7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
8 #include "core/dom/Element.h" | 8 #include "core/dom/Element.h" |
9 #include "core/testing/DummyPageHolder.h" | 9 #include "core/testing/DummyPageHolder.h" |
10 #include "public/web/WebElement.h" | 10 #include "public/web/WebElement.h" |
11 #include "public/web/WebElementCollection.h" | 11 #include "public/web/WebElementCollection.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include <memory> |
13 | 14 |
14 namespace blink { | 15 namespace blink { |
15 | 16 |
16 class WebNodeTest : public testing::Test { | 17 class WebNodeTest : public testing::Test { |
17 protected: | 18 protected: |
18 Document& document() | 19 Document& document() |
19 { | 20 { |
20 return m_pageHolder->document(); | 21 return m_pageHolder->document(); |
21 } | 22 } |
22 | 23 |
23 void setInnerHTML(const String& html) | 24 void setInnerHTML(const String& html) |
24 { | 25 { |
25 document().documentElement()->setInnerHTML(html, ASSERT_NO_EXCEPTION); | 26 document().documentElement()->setInnerHTML(html, ASSERT_NO_EXCEPTION); |
26 } | 27 } |
27 | 28 |
28 WebNode root() | 29 WebNode root() |
29 { | 30 { |
30 return WebNode(document().documentElement()); | 31 return WebNode(document().documentElement()); |
31 } | 32 } |
32 | 33 |
33 private: | 34 private: |
34 void SetUp() override; | 35 void SetUp() override; |
35 | 36 |
36 OwnPtr<DummyPageHolder> m_pageHolder; | 37 std::unique_ptr<DummyPageHolder> m_pageHolder; |
37 }; | 38 }; |
38 | 39 |
39 void WebNodeTest::SetUp() | 40 void WebNodeTest::SetUp() |
40 { | 41 { |
41 m_pageHolder = DummyPageHolder::create(IntSize(800, 600)); | 42 m_pageHolder = DummyPageHolder::create(IntSize(800, 600)); |
42 } | 43 } |
43 | 44 |
44 TEST_F(WebNodeTest, QuerySelectorMatches) | 45 TEST_F(WebNodeTest, QuerySelectorMatches) |
45 { | 46 { |
46 setInnerHTML("<div id=x><span class=a></span></div>"); | 47 setInnerHTML("<div id=x><span class=a></span></div>"); |
(...skipping 22 matching lines...) Expand all Loading... |
69 // WebNode::getElementsByHTMLTagName returns only HTML elements. | 70 // WebNode::getElementsByHTMLTagName returns only HTML elements. |
70 WebElementCollection collection = root().getElementsByHTMLTagName("label"); | 71 WebElementCollection collection = root().getElementsByHTMLTagName("label"); |
71 EXPECT_EQ(1u, collection.length()); | 72 EXPECT_EQ(1u, collection.length()); |
72 EXPECT_TRUE(collection.firstItem().hasHTMLTagName("label")); | 73 EXPECT_TRUE(collection.firstItem().hasHTMLTagName("label")); |
73 // The argument should be lower-case. | 74 // The argument should be lower-case. |
74 collection = root().getElementsByHTMLTagName("LABEL"); | 75 collection = root().getElementsByHTMLTagName("LABEL"); |
75 EXPECT_EQ(0u, collection.length()); | 76 EXPECT_EQ(0u, collection.length()); |
76 } | 77 } |
77 | 78 |
78 } // namespace blink | 79 } // namespace blink |
OLD | NEW |