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

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

Issue 2374183004: Make non-null VisibleSelections creatable only by createVisibleSelection[Deprecated] (Closed)
Patch Set: Fix mac compile error Created 4 years, 2 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/SelectionAdjuster.h" 5 #include "core/editing/SelectionAdjuster.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
11 class SelectionAdjusterTest : public EditingTestBase { 11 class SelectionAdjusterTest : public EditingTestBase {
12 }; 12 };
13 13
14 TEST_F(SelectionAdjusterTest, adjustSelectionInFlatTree) 14 TEST_F(SelectionAdjusterTest, adjustSelectionInFlatTree)
15 { 15 {
16 setBodyContent("<div id=sample>foo</div>"); 16 setBodyContent("<div id=sample>foo</div>");
17 VisibleSelectionInFlatTree selectionInFlatTree; 17 VisibleSelectionInFlatTree selectionInFlatTree;
18 18
19 Node* const sample = document().getElementById("sample"); 19 Node* const sample = document().getElementById("sample");
20 Node* const foo = sample->firstChild(); 20 Node* const foo = sample->firstChild();
21 // Select "foo" 21 // Select "foo"
22 VisibleSelection selection(Position(foo, 0), Position(foo, 3)); 22 VisibleSelection selection = createVisibleSelectionDeprecated(Position(foo, 0), Position(foo, 3));
23 SelectionAdjuster::adjustSelectionInFlatTree(&selectionInFlatTree, selection ); 23 SelectionAdjuster::adjustSelectionInFlatTree(&selectionInFlatTree, selection );
24 EXPECT_EQ(PositionInFlatTree(foo, 0), selectionInFlatTree.start()); 24 EXPECT_EQ(PositionInFlatTree(foo, 0), selectionInFlatTree.start());
25 EXPECT_EQ(PositionInFlatTree(foo, 3), selectionInFlatTree.end()); 25 EXPECT_EQ(PositionInFlatTree(foo, 3), selectionInFlatTree.end());
26 } 26 }
27 27
28 TEST_F(SelectionAdjusterTest, adjustSelectionInDOMTree) 28 TEST_F(SelectionAdjusterTest, adjustSelectionInDOMTree)
29 { 29 {
30 setBodyContent("<div id=sample>foo</div>"); 30 setBodyContent("<div id=sample>foo</div>");
31 VisibleSelection selection; 31 VisibleSelection selection;
32 32
33 Node* const sample = document().getElementById("sample"); 33 Node* const sample = document().getElementById("sample");
34 Node* const foo = sample->firstChild(); 34 Node* const foo = sample->firstChild();
35 // Select "foo" 35 // Select "foo"
36 VisibleSelectionInFlatTree selectionInFlatTree( 36 VisibleSelectionInFlatTree selectionInFlatTree = createVisibleSelectionDepre cated(
37 PositionInFlatTree(foo, 0), 37 PositionInFlatTree(foo, 0),
38 PositionInFlatTree(foo, 3)); 38 PositionInFlatTree(foo, 3));
39 SelectionAdjuster::adjustSelectionInDOMTree(&selection, selectionInFlatTree) ; 39 SelectionAdjuster::adjustSelectionInDOMTree(&selection, selectionInFlatTree) ;
40 EXPECT_EQ(Position(foo, 0), selection.start()); 40 EXPECT_EQ(Position(foo, 0), selection.start());
41 EXPECT_EQ(Position(foo, 3), selection.end()); 41 EXPECT_EQ(Position(foo, 3), selection.end());
42 } 42 }
43 43
44 } // namespace blink 44 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698