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

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

Issue 2920733002: Rename VisibleSelection::end() to End() (Closed)
Patch Set: 2017-06-01T18:31:38 Created 3 years, 6 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/SelectionController.h" 5 #include "core/editing/SelectionController.h"
6 6
7 #include "core/editing/EditingTestBase.h" 7 #include "core/editing/EditingTestBase.h"
8 #include "core/editing/FrameSelection.h" 8 #include "core/editing/FrameSelection.h"
9 #include "core/frame/LocalFrameView.h" 9 #include "core/frame/LocalFrameView.h"
10 #include "core/frame/Settings.h" 10 #include "core/frame/Settings.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 // top to bottom 63 // top to bottom
64 SetNonDirectionalSelectionIfNeeded(SelectionInFlatTree::Builder() 64 SetNonDirectionalSelectionIfNeeded(SelectionInFlatTree::Builder()
65 .Collapse(PositionInFlatTree(top, 1)) 65 .Collapse(PositionInFlatTree(top, 1))
66 .Extend(PositionInFlatTree(bottom, 3)) 66 .Extend(PositionInFlatTree(bottom, 3))
67 .Build(), 67 .Build(),
68 kCharacterGranularity); 68 kCharacterGranularity);
69 EXPECT_EQ(Position(top, 1), VisibleSelectionInDOMTree().Base()); 69 EXPECT_EQ(Position(top, 1), VisibleSelectionInDOMTree().Base());
70 EXPECT_EQ(Position::BeforeNode(host), VisibleSelectionInDOMTree().Extent()); 70 EXPECT_EQ(Position::BeforeNode(host), VisibleSelectionInDOMTree().Extent());
71 EXPECT_EQ(Position(top, 1), VisibleSelectionInDOMTree().Start()); 71 EXPECT_EQ(Position(top, 1), VisibleSelectionInDOMTree().Start());
72 EXPECT_EQ(Position(top, 3), VisibleSelectionInDOMTree().end()); 72 EXPECT_EQ(Position(top, 3), VisibleSelectionInDOMTree().End());
73 73
74 EXPECT_EQ(PositionInFlatTree(top, 1), GetVisibleSelectionInFlatTree().Base()); 74 EXPECT_EQ(PositionInFlatTree(top, 1), GetVisibleSelectionInFlatTree().Base());
75 EXPECT_EQ(PositionInFlatTree(bottom, 3), 75 EXPECT_EQ(PositionInFlatTree(bottom, 3),
76 GetVisibleSelectionInFlatTree().Extent()); 76 GetVisibleSelectionInFlatTree().Extent());
77 EXPECT_EQ(PositionInFlatTree(top, 1), 77 EXPECT_EQ(PositionInFlatTree(top, 1),
78 GetVisibleSelectionInFlatTree().Start()); 78 GetVisibleSelectionInFlatTree().Start());
79 EXPECT_EQ(PositionInFlatTree(bottom, 3), 79 EXPECT_EQ(PositionInFlatTree(bottom, 3),
80 GetVisibleSelectionInFlatTree().end()); 80 GetVisibleSelectionInFlatTree().End());
81 81
82 // bottom to top 82 // bottom to top
83 SetNonDirectionalSelectionIfNeeded( 83 SetNonDirectionalSelectionIfNeeded(
84 SelectionInFlatTree::Builder() 84 SelectionInFlatTree::Builder()
85 .Collapse(PositionInFlatTree(bottom, 3)) 85 .Collapse(PositionInFlatTree(bottom, 3))
86 .Extend(PositionInFlatTree(top, 1)) 86 .Extend(PositionInFlatTree(top, 1))
87 .Build(), 87 .Build(),
88 kCharacterGranularity); 88 kCharacterGranularity);
89 EXPECT_EQ(Position(bottom, 3), VisibleSelectionInDOMTree().Base()); 89 EXPECT_EQ(Position(bottom, 3), VisibleSelectionInDOMTree().Base());
90 EXPECT_EQ(Position::BeforeNode(bottom->parentNode()), 90 EXPECT_EQ(Position::BeforeNode(bottom->parentNode()),
91 VisibleSelectionInDOMTree().Extent()); 91 VisibleSelectionInDOMTree().Extent());
92 EXPECT_EQ(Position(bottom, 0), VisibleSelectionInDOMTree().Start()); 92 EXPECT_EQ(Position(bottom, 0), VisibleSelectionInDOMTree().Start());
93 EXPECT_EQ(Position(bottom, 3), VisibleSelectionInDOMTree().end()); 93 EXPECT_EQ(Position(bottom, 3), VisibleSelectionInDOMTree().End());
94 94
95 EXPECT_EQ(PositionInFlatTree(bottom, 3), 95 EXPECT_EQ(PositionInFlatTree(bottom, 3),
96 GetVisibleSelectionInFlatTree().Base()); 96 GetVisibleSelectionInFlatTree().Base());
97 EXPECT_EQ(PositionInFlatTree(top, 1), 97 EXPECT_EQ(PositionInFlatTree(top, 1),
98 GetVisibleSelectionInFlatTree().Extent()); 98 GetVisibleSelectionInFlatTree().Extent());
99 EXPECT_EQ(PositionInFlatTree(top, 1), 99 EXPECT_EQ(PositionInFlatTree(top, 1),
100 GetVisibleSelectionInFlatTree().Start()); 100 GetVisibleSelectionInFlatTree().Start());
101 EXPECT_EQ(PositionInFlatTree(bottom, 3), 101 EXPECT_EQ(PositionInFlatTree(bottom, 3),
102 GetVisibleSelectionInFlatTree().end()); 102 GetVisibleSelectionInFlatTree().End());
103 } 103 }
104 104
105 TEST_F(SelectionControllerTest, setCaretAtHitTestResult) { 105 TEST_F(SelectionControllerTest, setCaretAtHitTestResult) {
106 const char* body_content = "<div id='sample' contenteditable>sample</div>"; 106 const char* body_content = "<div id='sample' contenteditable>sample</div>";
107 SetBodyContent(body_content); 107 SetBodyContent(body_content);
108 GetDocument().GetSettings()->SetScriptEnabled(true); 108 GetDocument().GetSettings()->SetScriptEnabled(true);
109 Element* script = GetDocument().createElement("script"); 109 Element* script = GetDocument().createElement("script");
110 script->setInnerHTML( 110 script->setInnerHTML(
111 "var sample = document.getElementById('sample');" 111 "var sample = document.getElementById('sample');"
112 "sample.addEventListener('onselectstart', " 112 "sample.addEventListener('onselectstart', "
(...skipping 15 matching lines...) Expand all
128 GetDocument().View()->UpdateAllLifecyclePhases(); 128 GetDocument().View()->UpdateAllLifecyclePhases();
129 129
130 // Hit "&nbsp;" in before pseudo element of "sample". 130 // Hit "&nbsp;" in before pseudo element of "sample".
131 SetCaretAtHitTestResult( 131 SetCaretAtHitTestResult(
132 GetFrame().GetEventHandler().HitTestResultAtPoint(IntPoint(10, 10))); 132 GetFrame().GetEventHandler().HitTestResultAtPoint(IntPoint(10, 10)));
133 133
134 EXPECT_TRUE(Selection().GetSelectionInDOMTree().IsNone()); 134 EXPECT_TRUE(Selection().GetSelectionInDOMTree().IsNone());
135 } 135 }
136 136
137 } // namespace blink 137 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698