Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(734)

Side by Side Diff: third_party/WebKit/Source/core/dom/TreeScopeTest.cpp

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "core/dom/TreeScope.h" 5 #include "core/dom/TreeScope.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/dom/shadow/ShadowRoot.h" 9 #include "core/dom/shadow/ShadowRoot.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 TEST(TreeScopeTest, CommonAncestorOfSameTrees) 14 TEST(TreeScopeTest, CommonAncestorOfSameTrees)
15 { 15 {
16 RefPtrWillBeRawPtr<Document> document = Document::create(); 16 RawPtr<Document> document = Document::create();
17 EXPECT_EQ(document.get(), document->commonAncestorTreeScope(*document)); 17 EXPECT_EQ(document.get(), document->commonAncestorTreeScope(*document));
18 18
19 RefPtrWillBeRawPtr<Element> html = document->createElement("html", nullAtom, ASSERT_NO_EXCEPTION); 19 RawPtr<Element> html = document->createElement("html", nullAtom, ASSERT_NO_E XCEPTION);
20 document->appendChild(html, ASSERT_NO_EXCEPTION); 20 document->appendChild(html, ASSERT_NO_EXCEPTION);
21 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = html->createShadowRootInternal(S hadowRootType::V0, ASSERT_NO_EXCEPTION); 21 RawPtr<ShadowRoot> shadowRoot = html->createShadowRootInternal(ShadowRootTyp e::V0, ASSERT_NO_EXCEPTION);
22 EXPECT_EQ(shadowRoot.get(), shadowRoot->commonAncestorTreeScope(*shadowRoot) ); 22 EXPECT_EQ(shadowRoot.get(), shadowRoot->commonAncestorTreeScope(*shadowRoot) );
23 } 23 }
24 24
25 TEST(TreeScopeTest, CommonAncestorOfInclusiveTrees) 25 TEST(TreeScopeTest, CommonAncestorOfInclusiveTrees)
26 { 26 {
27 // document 27 // document
28 // | : Common ancestor is document. 28 // | : Common ancestor is document.
29 // shadowRoot 29 // shadowRoot
30 30
31 RefPtrWillBeRawPtr<Document> document = Document::create(); 31 RawPtr<Document> document = Document::create();
32 RefPtrWillBeRawPtr<Element> html = document->createElement("html", nullAtom, ASSERT_NO_EXCEPTION); 32 RawPtr<Element> html = document->createElement("html", nullAtom, ASSERT_NO_E XCEPTION);
33 document->appendChild(html, ASSERT_NO_EXCEPTION); 33 document->appendChild(html, ASSERT_NO_EXCEPTION);
34 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = html->createShadowRootInternal(S hadowRootType::V0, ASSERT_NO_EXCEPTION); 34 RawPtr<ShadowRoot> shadowRoot = html->createShadowRootInternal(ShadowRootTyp e::V0, ASSERT_NO_EXCEPTION);
35 35
36 EXPECT_EQ(document.get(), document->commonAncestorTreeScope(*shadowRoot)); 36 EXPECT_EQ(document.get(), document->commonAncestorTreeScope(*shadowRoot));
37 EXPECT_EQ(document.get(), shadowRoot->commonAncestorTreeScope(*document)); 37 EXPECT_EQ(document.get(), shadowRoot->commonAncestorTreeScope(*document));
38 } 38 }
39 39
40 TEST(TreeScopeTest, CommonAncestorOfSiblingTrees) 40 TEST(TreeScopeTest, CommonAncestorOfSiblingTrees)
41 { 41 {
42 // document 42 // document
43 // / \ : Common ancestor is document. 43 // / \ : Common ancestor is document.
44 // A B 44 // A B
45 45
46 RefPtrWillBeRawPtr<Document> document = Document::create(); 46 RawPtr<Document> document = Document::create();
47 RefPtrWillBeRawPtr<Element> html = document->createElement("html", nullAtom, ASSERT_NO_EXCEPTION); 47 RawPtr<Element> html = document->createElement("html", nullAtom, ASSERT_NO_E XCEPTION);
48 document->appendChild(html, ASSERT_NO_EXCEPTION); 48 document->appendChild(html, ASSERT_NO_EXCEPTION);
49 RefPtrWillBeRawPtr<Element> head = document->createElement("head", nullAtom, ASSERT_NO_EXCEPTION); 49 RawPtr<Element> head = document->createElement("head", nullAtom, ASSERT_NO_E XCEPTION);
50 html->appendChild(head); 50 html->appendChild(head);
51 RefPtrWillBeRawPtr<Element> body = document->createElement("body", nullAtom, ASSERT_NO_EXCEPTION); 51 RawPtr<Element> body = document->createElement("body", nullAtom, ASSERT_NO_E XCEPTION);
52 html->appendChild(body); 52 html->appendChild(body);
53 53
54 RefPtrWillBeRawPtr<ShadowRoot> shadowRootA = head->createShadowRootInternal( ShadowRootType::V0, ASSERT_NO_EXCEPTION); 54 RawPtr<ShadowRoot> shadowRootA = head->createShadowRootInternal(ShadowRootTy pe::V0, ASSERT_NO_EXCEPTION);
55 RefPtrWillBeRawPtr<ShadowRoot> shadowRootB = body->createShadowRootInternal( ShadowRootType::V0, ASSERT_NO_EXCEPTION); 55 RawPtr<ShadowRoot> shadowRootB = body->createShadowRootInternal(ShadowRootTy pe::V0, ASSERT_NO_EXCEPTION);
56 56
57 EXPECT_EQ(document.get(), shadowRootA->commonAncestorTreeScope(*shadowRootB) ); 57 EXPECT_EQ(document.get(), shadowRootA->commonAncestorTreeScope(*shadowRootB) );
58 EXPECT_EQ(document.get(), shadowRootB->commonAncestorTreeScope(*shadowRootA) ); 58 EXPECT_EQ(document.get(), shadowRootB->commonAncestorTreeScope(*shadowRootA) );
59 } 59 }
60 60
61 TEST(TreeScopeTest, CommonAncestorOfTreesAtDifferentDepths) 61 TEST(TreeScopeTest, CommonAncestorOfTreesAtDifferentDepths)
62 { 62 {
63 // document 63 // document
64 // / \ : Common ancestor is document. 64 // / \ : Common ancestor is document.
65 // Y B 65 // Y B
66 // / 66 // /
67 // A 67 // A
68 68
69 RefPtrWillBeRawPtr<Document> document = Document::create(); 69 RawPtr<Document> document = Document::create();
70 RefPtrWillBeRawPtr<Element> html = document->createElement("html", nullAtom, ASSERT_NO_EXCEPTION); 70 RawPtr<Element> html = document->createElement("html", nullAtom, ASSERT_NO_E XCEPTION);
71 document->appendChild(html, ASSERT_NO_EXCEPTION); 71 document->appendChild(html, ASSERT_NO_EXCEPTION);
72 RefPtrWillBeRawPtr<Element> head = document->createElement("head", nullAtom, ASSERT_NO_EXCEPTION); 72 RawPtr<Element> head = document->createElement("head", nullAtom, ASSERT_NO_E XCEPTION);
73 html->appendChild(head); 73 html->appendChild(head);
74 RefPtrWillBeRawPtr<Element> body = document->createElement("body", nullAtom, ASSERT_NO_EXCEPTION); 74 RawPtr<Element> body = document->createElement("body", nullAtom, ASSERT_NO_E XCEPTION);
75 html->appendChild(body); 75 html->appendChild(body);
76 76
77 RefPtrWillBeRawPtr<ShadowRoot> shadowRootY = head->createShadowRootInternal( ShadowRootType::V0, ASSERT_NO_EXCEPTION); 77 RawPtr<ShadowRoot> shadowRootY = head->createShadowRootInternal(ShadowRootTy pe::V0, ASSERT_NO_EXCEPTION);
78 RefPtrWillBeRawPtr<ShadowRoot> shadowRootB = body->createShadowRootInternal( ShadowRootType::V0, ASSERT_NO_EXCEPTION); 78 RawPtr<ShadowRoot> shadowRootB = body->createShadowRootInternal(ShadowRootTy pe::V0, ASSERT_NO_EXCEPTION);
79 79
80 RefPtrWillBeRawPtr<Element> divInY = document->createElement("div", nullAtom , ASSERT_NO_EXCEPTION); 80 RawPtr<Element> divInY = document->createElement("div", nullAtom, ASSERT_NO_ EXCEPTION);
81 shadowRootY->appendChild(divInY); 81 shadowRootY->appendChild(divInY);
82 RefPtrWillBeRawPtr<ShadowRoot> shadowRootA = divInY->createShadowRootInterna l(ShadowRootType::V0, ASSERT_NO_EXCEPTION); 82 RawPtr<ShadowRoot> shadowRootA = divInY->createShadowRootInternal(ShadowRoot Type::V0, ASSERT_NO_EXCEPTION);
83 83
84 EXPECT_EQ(document.get(), shadowRootA->commonAncestorTreeScope(*shadowRootB) ); 84 EXPECT_EQ(document.get(), shadowRootA->commonAncestorTreeScope(*shadowRootB) );
85 EXPECT_EQ(document.get(), shadowRootB->commonAncestorTreeScope(*shadowRootA) ); 85 EXPECT_EQ(document.get(), shadowRootB->commonAncestorTreeScope(*shadowRootA) );
86 } 86 }
87 87
88 TEST(TreeScopeTest, CommonAncestorOfTreesInDifferentDocuments) 88 TEST(TreeScopeTest, CommonAncestorOfTreesInDifferentDocuments)
89 { 89 {
90 RefPtrWillBeRawPtr<Document> document1 = Document::create(); 90 RawPtr<Document> document1 = Document::create();
91 RefPtrWillBeRawPtr<Document> document2 = Document::create(); 91 RawPtr<Document> document2 = Document::create();
92 EXPECT_EQ(0, document1->commonAncestorTreeScope(*document2)); 92 EXPECT_EQ(0, document1->commonAncestorTreeScope(*document2));
93 EXPECT_EQ(0, document2->commonAncestorTreeScope(*document1)); 93 EXPECT_EQ(0, document2->commonAncestorTreeScope(*document1));
94 } 94 }
95 95
96 } // namespace blink 96 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698