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/dom/shadow/FlatTreeTraversal.h" | 5 #include "core/dom/shadow/FlatTreeTraversal.h" |
6 | 6 |
7 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 7 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
9 #include "core/dom/Element.h" | 9 #include "core/dom/Element.h" |
10 #include "core/dom/Node.h" | 10 #include "core/dom/Node.h" |
11 #include "core/dom/NodeTraversal.h" | 11 #include "core/dom/NodeTraversal.h" |
12 #include "core/dom/shadow/ShadowRoot.h" | 12 #include "core/dom/shadow/ShadowRoot.h" |
13 #include "core/frame/FrameView.h" | 13 #include "core/frame/FrameView.h" |
14 #include "core/html/HTMLDocument.h" | 14 #include "core/html/HTMLDocument.h" |
15 #include "core/html/HTMLElement.h" | 15 #include "core/html/HTMLElement.h" |
16 #include "core/testing/DummyPageHolder.h" | 16 #include "core/testing/DummyPageHolder.h" |
17 #include "platform/geometry/IntSize.h" | 17 #include "platform/geometry/IntSize.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "wtf/Compiler.h" | 19 #include "wtf/Compiler.h" |
20 #include "wtf/OwnPtr.h" | |
21 #include "wtf/StdLibExtras.h" | 20 #include "wtf/StdLibExtras.h" |
22 #include "wtf/Vector.h" | 21 #include "wtf/Vector.h" |
| 22 #include <memory> |
23 | 23 |
24 namespace blink { | 24 namespace blink { |
25 | 25 |
26 class FlatTreeTraversalTest : public ::testing::Test { | 26 class FlatTreeTraversalTest : public ::testing::Test { |
27 protected: | 27 protected: |
28 HTMLDocument& document() const; | 28 HTMLDocument& document() const; |
29 | 29 |
30 // Sets |mainHTML| to BODY element with |innerHTML| property and attaches | 30 // Sets |mainHTML| to BODY element with |innerHTML| property and attaches |
31 // shadow root to child with |shadowHTML|, then update distribution for | 31 // shadow root to child with |shadowHTML|, then update distribution for |
32 // calling member functions in |FlatTreeTraversal|. | 32 // calling member functions in |FlatTreeTraversal|. |
33 void setupSampleHTML(const char* mainHTML, const char* shadowHTML, unsigned)
; | 33 void setupSampleHTML(const char* mainHTML, const char* shadowHTML, unsigned)
; |
34 | 34 |
35 void setupDocumentTree(const char* mainHTML); | 35 void setupDocumentTree(const char* mainHTML); |
36 | 36 |
37 void attachV0ShadowRoot(Element& shadowHost, const char* shadowInnerHTML); | 37 void attachV0ShadowRoot(Element& shadowHost, const char* shadowInnerHTML); |
38 void attachOpenShadowRoot(Element& shadowHost, const char* shadowInnerHTML); | 38 void attachOpenShadowRoot(Element& shadowHost, const char* shadowInnerHTML); |
39 | 39 |
40 private: | 40 private: |
41 void SetUp() override; | 41 void SetUp() override; |
42 | 42 |
43 Persistent<HTMLDocument> m_document; | 43 Persistent<HTMLDocument> m_document; |
44 OwnPtr<DummyPageHolder> m_dummyPageHolder; | 44 std::unique_ptr<DummyPageHolder> m_dummyPageHolder; |
45 }; | 45 }; |
46 | 46 |
47 void FlatTreeTraversalTest::SetUp() | 47 void FlatTreeTraversalTest::SetUp() |
48 { | 48 { |
49 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600)); | 49 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600)); |
50 m_document = toHTMLDocument(&m_dummyPageHolder->document()); | 50 m_document = toHTMLDocument(&m_dummyPageHolder->document()); |
51 DCHECK(m_document); | 51 DCHECK(m_document); |
52 } | 52 } |
53 | 53 |
54 HTMLDocument& FlatTreeTraversalTest::document() const | 54 HTMLDocument& FlatTreeTraversalTest::document() const |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 | 562 |
563 EXPECT_EQ(d11, FlatTreeTraversal::parent(*d111)); | 563 EXPECT_EQ(d11, FlatTreeTraversal::parent(*d111)); |
564 EXPECT_EQ(d11, FlatTreeTraversal::parent(*d112)); | 564 EXPECT_EQ(d11, FlatTreeTraversal::parent(*d112)); |
565 EXPECT_EQ(d11, FlatTreeTraversal::parent(*d2)); | 565 EXPECT_EQ(d11, FlatTreeTraversal::parent(*d2)); |
566 EXPECT_EQ(d11, FlatTreeTraversal::parent(*d14)); | 566 EXPECT_EQ(d11, FlatTreeTraversal::parent(*d14)); |
567 EXPECT_EQ(nullptr, FlatTreeTraversal::parent(*d3)); | 567 EXPECT_EQ(nullptr, FlatTreeTraversal::parent(*d3)); |
568 EXPECT_EQ(nullptr, FlatTreeTraversal::parent(*d4)); | 568 EXPECT_EQ(nullptr, FlatTreeTraversal::parent(*d4)); |
569 } | 569 } |
570 | 570 |
571 } // namespace blink | 571 } // namespace blink |
OLD | NEW |