| 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 "config.h" | 5 #include "config.h" |
| 6 #include "core/dom/shadow/ComposedTreeTraversal.h" | 6 #include "core/dom/shadow/ComposedTreeTraversal.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 8 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
| 10 #include "core/dom/Element.h" | 10 #include "core/dom/Element.h" |
| 11 #include "core/dom/Node.h" | 11 #include "core/dom/Node.h" |
| 12 #include "core/dom/NodeTraversal.h" | 12 #include "core/dom/NodeTraversal.h" |
| 13 #include "core/dom/shadow/ShadowRoot.h" | 13 #include "core/dom/shadow/ShadowRoot.h" |
| 14 #include "core/frame/FrameView.h" | 14 #include "core/frame/FrameView.h" |
| 15 #include "core/html/HTMLDocument.h" | 15 #include "core/html/HTMLDocument.h" |
| 16 #include "core/html/HTMLElement.h" | 16 #include "core/html/HTMLElement.h" |
| 17 #include "core/testing/DummyPageHolder.h" | 17 #include "core/testing/DummyPageHolder.h" |
| 18 #include "platform/geometry/IntSize.h" | 18 #include "platform/geometry/IntSize.h" |
| 19 #include "wtf/Compiler.h" | 19 #include "wtf/Compiler.h" |
| 20 #include "wtf/OwnPtr.h" | 20 #include "wtf/OwnPtr.h" |
| 21 #include "wtf/PassRefPtr.h" | 21 #include "wtf/PassRefPtr.h" |
| 22 #include "wtf/RefPtr.h" | 22 #include "wtf/RefPtr.h" |
| 23 #include "wtf/StdLibExtras.h" | 23 #include "wtf/StdLibExtras.h" |
| 24 #include "wtf/Vector.h" | 24 #include "wtf/Vector.h" |
| 25 #include "wtf/testing/WTFTestHelpers.h" | 25 #include "wtf/testing/WTFTestHelpers.h" |
| 26 #include <gtest/gtest.h> | 26 #include <gtest/gtest.h> |
| 27 | 27 |
| 28 using namespace blink; | 28 namespace blink { |
| 29 | |
| 30 namespace { | |
| 31 | 29 |
| 32 class ComposedTreeTraversalTest : public ::testing::Test { | 30 class ComposedTreeTraversalTest : public ::testing::Test { |
| 33 protected: | 31 protected: |
| 34 HTMLDocument& document() const; | 32 HTMLDocument& document() const; |
| 35 | 33 |
| 36 // Sets |mainHTML| to BODY element with |innerHTML| property and attaches | 34 // Sets |mainHTML| to BODY element with |innerHTML| property and attaches |
| 37 // shadow root to child with |shadowHTML|, then update distribution for | 35 // shadow root to child with |shadowHTML|, then update distribution for |
| 38 // calling member functions in |ComposedTreeTraversal|. | 36 // calling member functions in |ComposedTreeTraversal|. |
| 39 void setupSampleHTML(const char* mainHTML, const char* shadowHTML, unsigned)
; | 37 void setupSampleHTML(const char* mainHTML, const char* shadowHTML, unsigned)
; |
| 40 | 38 |
| 41 private: | 39 private: |
| 42 virtual void SetUp() override; | 40 void SetUp() override; |
| 43 | 41 |
| 44 HTMLDocument* m_document; | 42 HTMLDocument* m_document; |
| 45 OwnPtr<DummyPageHolder> m_dummyPageHolder; | 43 OwnPtr<DummyPageHolder> m_dummyPageHolder; |
| 46 }; | 44 }; |
| 47 | 45 |
| 48 void ComposedTreeTraversalTest::SetUp() | 46 void ComposedTreeTraversalTest::SetUp() |
| 49 { | 47 { |
| 50 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600)); | 48 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600)); |
| 51 m_document = toHTMLDocument(&m_dummyPageHolder->document()); | 49 m_document = toHTMLDocument(&m_dummyPageHolder->document()); |
| 52 ASSERT(m_document); | 50 ASSERT(m_document); |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 EXPECT_EQ(nullptr, ComposedTreeTraversal::lastWithin(*m2)); | 318 EXPECT_EQ(nullptr, ComposedTreeTraversal::lastWithin(*m2)); |
| 321 EXPECT_EQ(*m2, ComposedTreeTraversal::lastWithinOrSelf(*m2)); | 319 EXPECT_EQ(*m2, ComposedTreeTraversal::lastWithinOrSelf(*m2)); |
| 322 | 320 |
| 323 EXPECT_EQ(s11->firstChild(), ComposedTreeTraversal::lastWithin(*s11)); | 321 EXPECT_EQ(s11->firstChild(), ComposedTreeTraversal::lastWithin(*s11)); |
| 324 EXPECT_EQ(*s11->firstChild(), ComposedTreeTraversal::lastWithinOrSelf(*s11))
; | 322 EXPECT_EQ(*s11->firstChild(), ComposedTreeTraversal::lastWithinOrSelf(*s11))
; |
| 325 | 323 |
| 326 EXPECT_EQ(m10->firstChild(), ComposedTreeTraversal::lastWithin(*s12)); | 324 EXPECT_EQ(m10->firstChild(), ComposedTreeTraversal::lastWithin(*s12)); |
| 327 EXPECT_EQ(*m10->firstChild(), ComposedTreeTraversal::lastWithinOrSelf(*s12))
; | 325 EXPECT_EQ(*m10->firstChild(), ComposedTreeTraversal::lastWithinOrSelf(*s12))
; |
| 328 } | 326 } |
| 329 | 327 |
| 330 } // namespace | 328 } // namespace blink |
| OLD | NEW |