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

Side by Side Diff: third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp

Issue 1675163002: Rename ComposedTree to FlatTree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wip Created 4 years, 10 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/editing/FrameSelection.h" 5 #include "core/editing/FrameSelection.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/Text.h" 10 #include "core/dom/Text.h"
(...skipping 12 matching lines...) Expand all
23 #include "wtf/RefPtr.h" 23 #include "wtf/RefPtr.h"
24 #include "wtf/StdLibExtras.h" 24 #include "wtf/StdLibExtras.h"
25 25
26 namespace blink { 26 namespace blink {
27 27
28 class FrameSelectionTest : public EditingTestBase { 28 class FrameSelectionTest : public EditingTestBase {
29 protected: 29 protected:
30 void setSelection(const VisibleSelection&); 30 void setSelection(const VisibleSelection&);
31 FrameSelection& selection() const; 31 FrameSelection& selection() const;
32 const VisibleSelection& visibleSelectionInDOMTree() const { return selection ().selection(); } 32 const VisibleSelection& visibleSelectionInDOMTree() const { return selection ().selection(); }
33 const VisibleSelectionInComposedTree& visibleSelectionInComposedTree() const { return selection().selectionInComposedTree(); } 33 const VisibleSelectionInFlatTree& visibleSelectionInFlatTree() const { retur n selection().selectionInFlatTree(); }
34 34
35 PassRefPtrWillBeRawPtr<Text> appendTextNode(const String& data); 35 PassRefPtrWillBeRawPtr<Text> appendTextNode(const String& data);
36 int layoutCount() const { return dummyPageHolder().frameView().layoutCount() ; } 36 int layoutCount() const { return dummyPageHolder().frameView().layoutCount() ; }
37 37
38 private: 38 private:
39 RefPtrWillBePersistent<Text> m_textNode; 39 RefPtrWillBePersistent<Text> m_textNode;
40 }; 40 };
41 41
42 void FrameSelectionTest::setSelection(const VisibleSelection& newSelection) 42 void FrameSelectionTest::setSelection(const VisibleSelection& newSelection)
43 { 43 {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 const char* shadowContent = "<span id=bottom>bottom</span>"; 183 const char* shadowContent = "<span id=bottom>bottom</span>";
184 setBodyContent(bodyContent); 184 setBodyContent(bodyContent);
185 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); 185 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
186 updateLayoutAndStyleForPainting(); 186 updateLayoutAndStyleForPainting();
187 187
188 Node* top = document().getElementById("top")->firstChild(); 188 Node* top = document().getElementById("top")->firstChild();
189 Node* bottom = shadowRoot->getElementById("bottom")->firstChild(); 189 Node* bottom = shadowRoot->getElementById("bottom")->firstChild();
190 Node* host = document().getElementById("host"); 190 Node* host = document().getElementById("host");
191 191
192 // top to bottom 192 // top to bottom
193 selection().setNonDirectionalSelectionIfNeeded(VisibleSelectionInComposedTre e(PositionInComposedTree(top, 1), PositionInComposedTree(bottom, 3)), CharacterG ranularity); 193 selection().setNonDirectionalSelectionIfNeeded(VisibleSelectionInFlatTree(Po sitionInFlatTree(top, 1), PositionInFlatTree(bottom, 3)), CharacterGranularity);
194 EXPECT_EQ(Position(top, 1), visibleSelectionInDOMTree().base()); 194 EXPECT_EQ(Position(top, 1), visibleSelectionInDOMTree().base());
195 EXPECT_EQ(Position::beforeNode(host), visibleSelectionInDOMTree().extent()); 195 EXPECT_EQ(Position::beforeNode(host), visibleSelectionInDOMTree().extent());
196 EXPECT_EQ(Position(top, 1), visibleSelectionInDOMTree().start()); 196 EXPECT_EQ(Position(top, 1), visibleSelectionInDOMTree().start());
197 EXPECT_EQ(Position(top, 3), visibleSelectionInDOMTree().end()); 197 EXPECT_EQ(Position(top, 3), visibleSelectionInDOMTree().end());
198 198
199 EXPECT_EQ(PositionInComposedTree(top, 1), visibleSelectionInComposedTree().b ase()); 199 EXPECT_EQ(PositionInFlatTree(top, 1), visibleSelectionInFlatTree().base());
200 EXPECT_EQ(PositionInComposedTree(bottom, 3), visibleSelectionInComposedTree( ).extent()); 200 EXPECT_EQ(PositionInFlatTree(bottom, 3), visibleSelectionInFlatTree().extent ());
201 EXPECT_EQ(PositionInComposedTree(top, 1), visibleSelectionInComposedTree().s tart()); 201 EXPECT_EQ(PositionInFlatTree(top, 1), visibleSelectionInFlatTree().start());
202 EXPECT_EQ(PositionInComposedTree(bottom, 3), visibleSelectionInComposedTree( ).end()); 202 EXPECT_EQ(PositionInFlatTree(bottom, 3), visibleSelectionInFlatTree().end()) ;
203 203
204 // bottom to top 204 // bottom to top
205 selection().setNonDirectionalSelectionIfNeeded(VisibleSelectionInComposedTre e(PositionInComposedTree(bottom, 3), PositionInComposedTree(top, 1)), CharacterG ranularity); 205 selection().setNonDirectionalSelectionIfNeeded(VisibleSelectionInFlatTree(Po sitionInFlatTree(bottom, 3), PositionInFlatTree(top, 1)), CharacterGranularity);
206 EXPECT_EQ(Position(bottom, 3), visibleSelectionInDOMTree().base()); 206 EXPECT_EQ(Position(bottom, 3), visibleSelectionInDOMTree().base());
207 EXPECT_EQ(Position::beforeNode(bottom->parentNode()), visibleSelectionInDOMT ree().extent()); 207 EXPECT_EQ(Position::beforeNode(bottom->parentNode()), visibleSelectionInDOMT ree().extent());
208 EXPECT_EQ(Position(bottom, 0), visibleSelectionInDOMTree().start()); 208 EXPECT_EQ(Position(bottom, 0), visibleSelectionInDOMTree().start());
209 EXPECT_EQ(Position(bottom, 3), visibleSelectionInDOMTree().end()); 209 EXPECT_EQ(Position(bottom, 3), visibleSelectionInDOMTree().end());
210 210
211 EXPECT_EQ(PositionInComposedTree(bottom, 3), visibleSelectionInComposedTree( ).base()); 211 EXPECT_EQ(PositionInFlatTree(bottom, 3), visibleSelectionInFlatTree().base() );
212 EXPECT_EQ(PositionInComposedTree(top, 1), visibleSelectionInComposedTree().e xtent()); 212 EXPECT_EQ(PositionInFlatTree(top, 1), visibleSelectionInFlatTree().extent()) ;
213 EXPECT_EQ(PositionInComposedTree(top, 1), visibleSelectionInComposedTree().s tart()); 213 EXPECT_EQ(PositionInFlatTree(top, 1), visibleSelectionInFlatTree().start());
214 EXPECT_EQ(PositionInComposedTree(bottom, 3), visibleSelectionInComposedTree( ).end()); 214 EXPECT_EQ(PositionInFlatTree(bottom, 3), visibleSelectionInFlatTree().end()) ;
215 } 215 }
216 216
217 TEST_F(FrameSelectionTest, SelectAllWithUnselectableRoot) 217 TEST_F(FrameSelectionTest, SelectAllWithUnselectableRoot)
218 { 218 {
219 RefPtrWillBeRawPtr<Element> select = document().createElement("select", ASSE RT_NO_EXCEPTION); 219 RefPtrWillBeRawPtr<Element> select = document().createElement("select", ASSE RT_NO_EXCEPTION);
220 document().replaceChild(select.get(), document().documentElement()); 220 document().replaceChild(select.get(), document().documentElement());
221 selection().selectAll(); 221 selection().selectAll();
222 EXPECT_TRUE(selection().isNone()) << "Nothing should be selected if the cont ent of the documentElement is not selctable."; 222 EXPECT_TRUE(selection().isNone()) << "Nothing should be selected if the cont ent of the documentElement is not selctable.";
223 } 223 }
224 224
225 } // namespace blink 225 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698