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

Side by Side Diff: third_party/WebKit/Source/core/editing/PositionTest.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 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/editing/Position.h" 5 #include "core/editing/Position.h"
6 6
7 #include "core/editing/EditingTestBase.h" 7 #include "core/editing/EditingTestBase.h"
8 8
9 namespace blink { 9 namespace blink {
10 10
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 EXPECT_EQ(p2, PositionInFlatTree::inParentAfterNode(*p2).nodeAsRangeLastNode ()); 66 EXPECT_EQ(p2, PositionInFlatTree::inParentAfterNode(*p2).nodeAsRangeLastNode ());
67 EXPECT_EQ(t3, PositionInFlatTree::inParentAfterNode(*p3).nodeAsRangeLastNode ()); 67 EXPECT_EQ(t3, PositionInFlatTree::inParentAfterNode(*p3).nodeAsRangeLastNode ());
68 EXPECT_EQ(t3, PositionInFlatTree::afterNode(p3).nodeAsRangeLastNode()); 68 EXPECT_EQ(t3, PositionInFlatTree::afterNode(p3).nodeAsRangeLastNode());
69 } 69 }
70 70
71 TEST_F(PositionTest, NodeAsRangeLastNodeShadow) 71 TEST_F(PositionTest, NodeAsRangeLastNodeShadow)
72 { 72 {
73 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</ b>33</p>"; 73 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</ b>33</p>";
74 const char* shadowContent = "<a id='a'><content select=#two></content><conte nt select=#one></content></a>"; 74 const char* shadowContent = "<a id='a'><content select=#two></content><conte nt select=#one></content></a>";
75 setBodyContent(bodyContent); 75 setBodyContent(bodyContent);
76 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); 76 RawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
77 77
78 Node* host = document().getElementById("host"); 78 Node* host = document().getElementById("host");
79 Node* n1 = document().getElementById("one"); 79 Node* n1 = document().getElementById("one");
80 Node* n2 = document().getElementById("two"); 80 Node* n2 = document().getElementById("two");
81 Node* t0 = EditingStrategy::firstChild(*host); 81 Node* t0 = EditingStrategy::firstChild(*host);
82 Node* t1 = EditingStrategy::firstChild(*n1); 82 Node* t1 = EditingStrategy::firstChild(*n1);
83 Node* t2 = EditingStrategy::firstChild(*n2); 83 Node* t2 = EditingStrategy::firstChild(*n2);
84 Node* t3 = EditingStrategy::lastChild(*host); 84 Node* t3 = EditingStrategy::lastChild(*host);
85 Node* a = shadowRoot->getElementById("a"); 85 Node* a = shadowRoot->getElementById("a");
86 86
87 EXPECT_EQ(t0, Position::inParentBeforeNode(*n1).nodeAsRangeLastNode()); 87 EXPECT_EQ(t0, Position::inParentBeforeNode(*n1).nodeAsRangeLastNode());
88 EXPECT_EQ(t1, Position::inParentBeforeNode(*n2).nodeAsRangeLastNode()); 88 EXPECT_EQ(t1, Position::inParentBeforeNode(*n2).nodeAsRangeLastNode());
89 EXPECT_EQ(t1, Position::inParentAfterNode(*n1).nodeAsRangeLastNode()); 89 EXPECT_EQ(t1, Position::inParentAfterNode(*n1).nodeAsRangeLastNode());
90 EXPECT_EQ(t2, Position::inParentAfterNode(*n2).nodeAsRangeLastNode()); 90 EXPECT_EQ(t2, Position::inParentAfterNode(*n2).nodeAsRangeLastNode());
91 EXPECT_EQ(t3, Position::afterNode(host).nodeAsRangeLastNode()); 91 EXPECT_EQ(t3, Position::afterNode(host).nodeAsRangeLastNode());
92 92
93 EXPECT_EQ(t2, PositionInFlatTree::inParentBeforeNode(*n1).nodeAsRangeLastNod e()); 93 EXPECT_EQ(t2, PositionInFlatTree::inParentBeforeNode(*n1).nodeAsRangeLastNod e());
94 EXPECT_EQ(a, PositionInFlatTree::inParentBeforeNode(*n2).nodeAsRangeLastNode ()); 94 EXPECT_EQ(a, PositionInFlatTree::inParentBeforeNode(*n2).nodeAsRangeLastNode ());
95 EXPECT_EQ(t1, PositionInFlatTree::inParentAfterNode(*n1).nodeAsRangeLastNode ()); 95 EXPECT_EQ(t1, PositionInFlatTree::inParentAfterNode(*n1).nodeAsRangeLastNode ());
96 EXPECT_EQ(t2, PositionInFlatTree::inParentAfterNode(*n2).nodeAsRangeLastNode ()); 96 EXPECT_EQ(t2, PositionInFlatTree::inParentAfterNode(*n2).nodeAsRangeLastNode ());
97 EXPECT_EQ(t1, PositionInFlatTree::afterNode(host).nodeAsRangeLastNode()); 97 EXPECT_EQ(t1, PositionInFlatTree::afterNode(host).nodeAsRangeLastNode());
98 } 98 }
99 99
100 TEST_F(PositionTest, ToPositionInFlatTreeWithActiveInsertionPoint) 100 TEST_F(PositionTest, ToPositionInFlatTreeWithActiveInsertionPoint)
101 { 101 {
102 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>"; 102 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>";
103 const char* shadowContent = "<a id='a'><content select=#one id='content'></c ontent><content></content></a>"; 103 const char* shadowContent = "<a id='a'><content select=#one id='content'></c ontent><content></content></a>";
104 setBodyContent(bodyContent); 104 setBodyContent(bodyContent);
105 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); 105 RawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
106 RefPtrWillBeRawPtr<Element> anchor = shadowRoot->getElementById("a"); 106 RawPtr<Element> anchor = shadowRoot->getElementById("a");
107 107
108 EXPECT_EQ(PositionInFlatTree(anchor.get(), 0), toPositionInFlatTree(Position (anchor.get(), 0))); 108 EXPECT_EQ(PositionInFlatTree(anchor.get(), 0), toPositionInFlatTree(Position (anchor.get(), 0)));
109 EXPECT_EQ(PositionInFlatTree(anchor.get(), 1), toPositionInFlatTree(Position (anchor.get(), 1))); 109 EXPECT_EQ(PositionInFlatTree(anchor.get(), 1), toPositionInFlatTree(Position (anchor.get(), 1)));
110 EXPECT_EQ(PositionInFlatTree(anchor, PositionAnchorType::AfterChildren), toP ositionInFlatTree(Position(anchor.get(), 2))); 110 EXPECT_EQ(PositionInFlatTree(anchor, PositionAnchorType::AfterChildren), toP ositionInFlatTree(Position(anchor.get(), 2)));
111 } 111 }
112 112
113 TEST_F(PositionTest, ToPositionInFlatTreeWithInactiveInsertionPoint) 113 TEST_F(PositionTest, ToPositionInFlatTreeWithInactiveInsertionPoint)
114 { 114 {
115 const char* bodyContent = "<p id='p'><content></content></p>"; 115 const char* bodyContent = "<p id='p'><content></content></p>";
116 setBodyContent(bodyContent); 116 setBodyContent(bodyContent);
117 RefPtrWillBeRawPtr<Element> anchor = document().getElementById("p"); 117 RawPtr<Element> anchor = document().getElementById("p");
118 118
119 EXPECT_EQ(PositionInFlatTree(anchor.get(), 0), toPositionInFlatTree(Position (anchor.get(), 0))); 119 EXPECT_EQ(PositionInFlatTree(anchor.get(), 0), toPositionInFlatTree(Position (anchor.get(), 0)));
120 EXPECT_EQ(PositionInFlatTree(anchor, PositionAnchorType::AfterChildren), toP ositionInFlatTree(Position(anchor.get(), 1))); 120 EXPECT_EQ(PositionInFlatTree(anchor, PositionAnchorType::AfterChildren), toP ositionInFlatTree(Position(anchor.get(), 1)));
121 } 121 }
122 122
123 // This test comes from "editing/style/block-style-progress-crash.html". 123 // This test comes from "editing/style/block-style-progress-crash.html".
124 TEST_F(PositionTest, ToPositionInFlatTreeWithNotDistributed) 124 TEST_F(PositionTest, ToPositionInFlatTreeWithNotDistributed)
125 { 125 {
126 setBodyContent("<progress id=sample>foo</progress>"); 126 setBodyContent("<progress id=sample>foo</progress>");
127 Element* sample = document().getElementById("sample"); 127 Element* sample = document().getElementById("sample");
128 128
129 EXPECT_EQ(PositionInFlatTree(sample, PositionAnchorType::AfterChildren), toP ositionInFlatTree(Position(sample, 0))); 129 EXPECT_EQ(PositionInFlatTree(sample, PositionAnchorType::AfterChildren), toP ositionInFlatTree(Position(sample, 0)));
130 } 130 }
131 131
132 TEST_F(PositionTest, ToPositionInFlatTreeWithShadowRoot) 132 TEST_F(PositionTest, ToPositionInFlatTreeWithShadowRoot)
133 { 133 {
134 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>"; 134 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>";
135 const char* shadowContent = "<a><content select=#one></content></a>"; 135 const char* shadowContent = "<a><content select=#one></content></a>";
136 setBodyContent(bodyContent); 136 setBodyContent(bodyContent);
137 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); 137 RawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
138 RefPtrWillBeRawPtr<Element> host = document().getElementById("host"); 138 RawPtr<Element> host = document().getElementById("host");
139 139
140 EXPECT_EQ(PositionInFlatTree(host.get(), 0), toPositionInFlatTree(Position(s hadowRoot.get(), 0))); 140 EXPECT_EQ(PositionInFlatTree(host.get(), 0), toPositionInFlatTree(Position(s hadowRoot.get(), 0)));
141 EXPECT_EQ(PositionInFlatTree(host.get(), PositionAnchorType::AfterChildren), toPositionInFlatTree(Position(shadowRoot.get(), 1))); 141 EXPECT_EQ(PositionInFlatTree(host.get(), PositionAnchorType::AfterChildren), toPositionInFlatTree(Position(shadowRoot.get(), 1)));
142 } 142 }
143 143
144 TEST_F(PositionTest, ToPositionInFlatTreeWithShadowRootContainingSingleContent) 144 TEST_F(PositionTest, ToPositionInFlatTreeWithShadowRootContainingSingleContent)
145 { 145 {
146 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>"; 146 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>";
147 const char* shadowContent = "<content select=#one></content>"; 147 const char* shadowContent = "<content select=#one></content>";
148 setBodyContent(bodyContent); 148 setBodyContent(bodyContent);
149 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); 149 RawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
150 RefPtrWillBeRawPtr<Element> host = document().getElementById("host"); 150 RawPtr<Element> host = document().getElementById("host");
151 151
152 EXPECT_EQ(PositionInFlatTree(host.get(), 0), toPositionInFlatTree(Position(s hadowRoot.get(), 0))); 152 EXPECT_EQ(PositionInFlatTree(host.get(), 0), toPositionInFlatTree(Position(s hadowRoot.get(), 0)));
153 EXPECT_EQ(PositionInFlatTree(host.get(), PositionAnchorType::AfterChildren), toPositionInFlatTree(Position(shadowRoot.get(), 1))); 153 EXPECT_EQ(PositionInFlatTree(host.get(), PositionAnchorType::AfterChildren), toPositionInFlatTree(Position(shadowRoot.get(), 1)));
154 } 154 }
155 155
156 TEST_F(PositionTest, ToPositionInFlatTreeWithEmptyShadowRoot) 156 TEST_F(PositionTest, ToPositionInFlatTreeWithEmptyShadowRoot)
157 { 157 {
158 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>"; 158 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>";
159 const char* shadowContent = ""; 159 const char* shadowContent = "";
160 setBodyContent(bodyContent); 160 setBodyContent(bodyContent);
161 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); 161 RawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
162 RefPtrWillBeRawPtr<Element> host = document().getElementById("host"); 162 RawPtr<Element> host = document().getElementById("host");
163 163
164 EXPECT_EQ(PositionInFlatTree(host, PositionAnchorType::AfterChildren), toPos itionInFlatTree(Position(shadowRoot.get(), 0))); 164 EXPECT_EQ(PositionInFlatTree(host, PositionAnchorType::AfterChildren), toPos itionInFlatTree(Position(shadowRoot.get(), 0)));
165 } 165 }
166 166
167 } // namespace blink 167 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/PositionIterator.h ('k') | third_party/WebKit/Source/core/editing/Selection.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698