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

Side by Side Diff: Source/core/editing/VisibleSelectionTest.cpp

Issue 1097063003: Oilpan: fix build after r194270. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: adjust asserts Created 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "config.h" 5 #include "config.h"
6 #include "core/editing/VisibleSelection.h" 6 #include "core/editing/VisibleSelection.h"
7 7
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 #include "core/dom/Range.h" 9 #include "core/dom/Range.h"
10 #include "core/dom/Text.h" 10 #include "core/dom/Text.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 const char* shadowContent = "<a><span id='s4'>44</span><content select=#two> </content><span id='s5'>55</span><content select=#one></content><span id='s6'>66 </span></a>"; 92 const char* shadowContent = "<a><span id='s4'>44</span><content select=#two> </content><span id='s5'>55</span><content select=#one></content><span id='s6'>66 </span></a>";
93 setBodyContent(bodyContent); 93 setBodyContent(bodyContent);
94 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent); 94 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent);
95 95
96 RefPtrWillBeRawPtr<Element> body = document().body(); 96 RefPtrWillBeRawPtr<Element> body = document().body();
97 RefPtrWillBeRawPtr<Element> host = body->querySelector("#host", ASSERT_NO_EX CEPTION); 97 RefPtrWillBeRawPtr<Element> host = body->querySelector("#host", ASSERT_NO_EX CEPTION);
98 RefPtrWillBeRawPtr<Element> one = body->querySelector("#one", ASSERT_NO_EXCE PTION); 98 RefPtrWillBeRawPtr<Element> one = body->querySelector("#one", ASSERT_NO_EXCE PTION);
99 RefPtrWillBeRawPtr<Element> two = body->querySelector("#two", ASSERT_NO_EXCE PTION); 99 RefPtrWillBeRawPtr<Element> two = body->querySelector("#two", ASSERT_NO_EXCE PTION);
100 RefPtrWillBeRawPtr<Element> six = shadowRoot->querySelector("#s6", ASSERT_NO _EXCEPTION); 100 RefPtrWillBeRawPtr<Element> six = shadowRoot->querySelector("#s6", ASSERT_NO _EXCEPTION);
101 101
102 ASSERT_UNUSED(two, two);
103 (void)six;
104
102 VisibleSelection selection(Position::firstPositionInNode(one.get()), Positio n::lastPositionInNode(shadowRoot.get())); 105 VisibleSelection selection(Position::firstPositionInNode(one.get()), Positio n::lastPositionInNode(shadowRoot.get()));
103 106
104 EXPECT_EQ(Position(host.get(), Position::PositionIsBeforeAnchor), selection. start()); 107 EXPECT_EQ(Position(host.get(), Position::PositionIsBeforeAnchor), selection. start());
105 EXPECT_EQ(Position(one->firstChild(), 0, Position::PositionIsOffsetInAnchor) , selection.end()); 108 EXPECT_EQ(Position(one->firstChild(), 0, Position::PositionIsOffsetInAnchor) , selection.end());
106 } 109 }
107 110
108 TEST_F(VisibleSelectionTest, ShadowDistributedNodes) 111 TEST_F(VisibleSelectionTest, ShadowDistributedNodes)
109 { 112 {
110 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</ b>33</p>"; 113 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</ b>33</p>";
111 const char* shadowContent = "<a><span id='s4'>44</span><content select=#two> </content><span id='s5'>55</span><content select=#one></content><span id='s6'>66 </span></a>"; 114 const char* shadowContent = "<a><span id='s4'>44</span><content select=#two> </content><span id='s5'>55</span><content select=#one></content><span id='s6'>66 </span></a>";
112 setBodyContent(bodyContent); 115 setBodyContent(bodyContent);
113 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent); 116 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent);
114 117
115 RefPtrWillBeRawPtr<Element> body = document().body(); 118 RefPtrWillBeRawPtr<Element> body = document().body();
116 RefPtrWillBeRawPtr<Element> host = body->querySelector("#host", ASSERT_NO_EX CEPTION); 119 RefPtrWillBeRawPtr<Element> host = body->querySelector("#host", ASSERT_NO_EX CEPTION);
117 RefPtrWillBeRawPtr<Element> one = body->querySelector("#one", ASSERT_NO_EXCE PTION); 120 RefPtrWillBeRawPtr<Element> one = body->querySelector("#one", ASSERT_NO_EXCE PTION);
118 RefPtrWillBeRawPtr<Element> two = body->querySelector("#two", ASSERT_NO_EXCE PTION); 121 RefPtrWillBeRawPtr<Element> two = body->querySelector("#two", ASSERT_NO_EXCE PTION);
119 RefPtrWillBeRawPtr<Element> five = shadowRoot->querySelector("#s5", ASSERT_N O_EXCEPTION); 122 RefPtrWillBeRawPtr<Element> five = shadowRoot->querySelector("#s5", ASSERT_N O_EXCEPTION);
120 123
124 ASSERT_UNUSED(host, host);
125 ASSERT_UNUSED(five, five);
126
121 VisibleSelection selection(Position::firstPositionInNode(one.get()), Positio n::lastPositionInNode(two.get())); 127 VisibleSelection selection(Position::firstPositionInNode(one.get()), Positio n::lastPositionInNode(two.get()));
122 128
123 EXPECT_EQ(Position(one->firstChild(), 0, Position::PositionIsOffsetInAnchor) , selection.start()); 129 EXPECT_EQ(Position(one->firstChild(), 0, Position::PositionIsOffsetInAnchor) , selection.start());
124 EXPECT_EQ(Position(two->firstChild(), 2, Position::PositionIsOffsetInAnchor) , selection.end()); 130 EXPECT_EQ(Position(two->firstChild(), 2, Position::PositionIsOffsetInAnchor) , selection.end());
125 } 131 }
126 132
127 TEST_F(VisibleSelectionTest, ShadowNested) 133 TEST_F(VisibleSelectionTest, ShadowNested)
128 { 134 {
129 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</ b>33</p>"; 135 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</ b>33</p>";
130 const char* shadowContent = "<a><span id='s4'>44</span><content select=#two> </content><span id='s5'>55</span><content select=#one></content><span id='s6'>66 </span></a>"; 136 const char* shadowContent = "<a><span id='s4'>44</span><content select=#two> </content><span id='s5'>55</span><content select=#one></content><span id='s6'>66 </span></a>";
131 const char* shadowContent2 = "<span id='s7'>77</span><content></content><spa n id='s8'>88</span>"; 137 const char* shadowContent2 = "<span id='s7'>77</span><content></content><spa n id='s8'>88</span>";
132 setBodyContent(bodyContent); 138 setBodyContent(bodyContent);
133 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent); 139 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent);
134 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot2 = createShadowRootForElementWithI DAndSetInnerHTML(*shadowRoot, "s5", shadowContent2); 140 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot2 = createShadowRootForElementWithI DAndSetInnerHTML(*shadowRoot, "s5", shadowContent2);
135 141
136 RefPtrWillBeRawPtr<Element> body = document().body(); 142 RefPtrWillBeRawPtr<Element> body = document().body();
137 RefPtrWillBeRawPtr<Element> host = body->querySelector("#host", ASSERT_NO_EX CEPTION); 143 RefPtrWillBeRawPtr<Element> host = body->querySelector("#host", ASSERT_NO_EX CEPTION);
138 RefPtrWillBeRawPtr<Element> one = body->querySelector("#one", ASSERT_NO_EXCE PTION); 144 RefPtrWillBeRawPtr<Element> one = body->querySelector("#one", ASSERT_NO_EXCE PTION);
139 RefPtrWillBeRawPtr<Element> two = body->querySelector("#two", ASSERT_NO_EXCE PTION); 145 RefPtrWillBeRawPtr<Element> two = body->querySelector("#two", ASSERT_NO_EXCE PTION);
140 RefPtrWillBeRawPtr<Element> host2 = shadowRoot->querySelector("#host2", ASSE RT_NO_EXCEPTION); 146 RefPtrWillBeRawPtr<Element> host2 = shadowRoot->querySelector("#host2", ASSE RT_NO_EXCEPTION);
141 RefPtrWillBeRawPtr<Element> eight = shadowRoot2->querySelector("#s8", ASSERT _NO_EXCEPTION); 147 RefPtrWillBeRawPtr<Element> eight = shadowRoot2->querySelector("#s8", ASSERT _NO_EXCEPTION);
142 148
149 ASSERT_UNUSED(two, two);
150 ASSERT_UNUSED(eight, eight);
151 (void)host2;
152
143 VisibleSelection selection(Position::firstPositionInNode(one.get()), Positio n::lastPositionInNode(shadowRoot2.get())); 153 VisibleSelection selection(Position::firstPositionInNode(one.get()), Positio n::lastPositionInNode(shadowRoot2.get()));
144 154
145 EXPECT_EQ(Position(host.get(), Position::PositionIsBeforeAnchor), selection. start()); 155 EXPECT_EQ(Position(host.get(), Position::PositionIsBeforeAnchor), selection. start());
146 EXPECT_EQ(Position(one->firstChild(), 0, Position::PositionIsOffsetInAnchor) , selection.end()); 156 EXPECT_EQ(Position(one->firstChild(), 0, Position::PositionIsOffsetInAnchor) , selection.end());
147 } 157 }
148 158
149 TEST_F(VisibleSelectionTest, WordGranularity) 159 TEST_F(VisibleSelectionTest, WordGranularity)
150 { 160 {
151 setBodyContent(LOREM_IPSUM); 161 setBodyContent(LOREM_IPSUM);
152 162
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 selection.expandUsingGranularity(WordGranularity); 238 selection.expandUsingGranularity(WordGranularity);
229 239
230 RefPtrWillBeRawPtr<Range> range = selection.firstRange(); 240 RefPtrWillBeRawPtr<Range> range = selection.firstRange();
231 EXPECT_EQ(0, range->startOffset()); 241 EXPECT_EQ(0, range->startOffset());
232 EXPECT_EQ(11, range->endOffset()); 242 EXPECT_EQ(11, range->endOffset());
233 EXPECT_EQ("Lorem ipsum", range->text()); 243 EXPECT_EQ("Lorem ipsum", range->text());
234 } 244 }
235 } 245 }
236 246
237 } // namespace blink 247 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698