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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLTextFormControlElementTest.cpp

Issue 2345693005: Prune createVisiblePositionDeprecated from unit tests (Closed)
Patch Set: Created 4 years, 3 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/html/HTMLTextFormControlElement.h" 5 #include "core/html/HTMLTextFormControlElement.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/dom/Text.h" 8 #include "core/dom/Text.h"
9 #include "core/editing/FrameSelection.h" 9 #include "core/editing/FrameSelection.h"
10 #include "core/editing/Position.h" 10 #include "core/editing/Position.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 EXPECT_EQ(startLayoutCount, layoutCount()); 122 EXPECT_EQ(startLayoutCount, layoutCount());
123 newCaretRect = LayoutRect(frameSelection.absoluteCaretBounds()); 123 newCaretRect = LayoutRect(frameSelection.absoluteCaretBounds());
124 EXPECT_NE(oldCaretRect, newCaretRect); 124 EXPECT_NE(oldCaretRect, newCaretRect);
125 } 125 }
126 126
127 typedef Position (*PositionFunction)(const Position&); 127 typedef Position (*PositionFunction)(const Position&);
128 typedef VisiblePosition(*VisblePositionFunction)(const VisiblePosition&); 128 typedef VisiblePosition(*VisblePositionFunction)(const VisiblePosition&);
129 129
130 void testFunctionEquivalence(const Position& position, PositionFunction position Function, VisblePositionFunction visibleFunction) 130 void testFunctionEquivalence(const Position& position, PositionFunction position Function, VisblePositionFunction visibleFunction)
131 { 131 {
132 VisiblePosition visiblePosition = createVisiblePositionDeprecated(position); 132 VisiblePosition visiblePosition = createVisiblePosition(position);
133 VisiblePosition expected = visibleFunction(visiblePosition); 133 VisiblePosition expected = visibleFunction(visiblePosition);
134 VisiblePosition actual = createVisiblePositionDeprecated(positionFunction(po sition)); 134 VisiblePosition actual = createVisiblePosition(positionFunction(position));
135 EXPECT_EQ(expected.deepEquivalent(), actual.deepEquivalent()); 135 EXPECT_EQ(expected.deepEquivalent(), actual.deepEquivalent());
136 } 136 }
137 137
138 static VisiblePosition startOfWord(const VisiblePosition& position) 138 static VisiblePosition startOfWord(const VisiblePosition& position)
139 { 139 {
140 return startOfWord(position, LeftWordIfOnBoundary); 140 return startOfWord(position, LeftWordIfOnBoundary);
141 } 141 }
142 142
143 static VisiblePosition endOfWord(const VisiblePosition& position) 143 static VisiblePosition endOfWord(const VisiblePosition& position)
144 { 144 {
145 return endOfWord(position, RightWordIfOnBoundary); 145 return endOfWord(position, RightWordIfOnBoundary);
146 } 146 }
147 147
148 void testBoundary(Document& document, HTMLTextFormControlElement& textControl) 148 void testBoundary(Document& document, HTMLTextFormControlElement& textControl)
149 { 149 {
150 document.updateStyleAndLayout();
150 for (unsigned i = 0; i < textControl.innerEditorValue().length(); i++) { 151 for (unsigned i = 0; i < textControl.innerEditorValue().length(); i++) {
151 textControl.setSelectionRange(i, i); 152 textControl.setSelectionRange(i, i);
152 Position position = document.frame()->selection().start(); 153 Position position = document.frame()->selection().start();
153 SCOPED_TRACE(::testing::Message() << "offset " << position.computeEditin gOffset() << " of " << nodePositionAsStringForTesting(position.anchorNode()).asc ii().data()); 154 SCOPED_TRACE(::testing::Message() << "offset " << position.computeEditin gOffset() << " of " << nodePositionAsStringForTesting(position.anchorNode()).asc ii().data());
154 { 155 {
155 SCOPED_TRACE("HTMLTextFormControlElement::startOfWord"); 156 SCOPED_TRACE("HTMLTextFormControlElement::startOfWord");
156 testFunctionEquivalence(position, HTMLTextFormControlElement::startO fWord, startOfWord); 157 testFunctionEquivalence(position, HTMLTextFormControlElement::startO fWord, startOfWord);
157 } 158 }
158 { 159 {
159 SCOPED_TRACE("HTMLTextFormControlElement::endOfWord"); 160 SCOPED_TRACE("HTMLTextFormControlElement::endOfWord");
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 219
219 TEST_F(HTMLTextFormControlElementTest, IndexForPosition) 220 TEST_F(HTMLTextFormControlElementTest, IndexForPosition)
220 { 221 {
221 HTMLInputElement* input = toHTMLInputElement(document().getElementById("inpu t")); 222 HTMLInputElement* input = toHTMLInputElement(document().getElementById("inpu t"));
222 input->setValue("Hello"); 223 input->setValue("Hello");
223 HTMLElement* innerEditor = input->innerEditorElement(); 224 HTMLElement* innerEditor = input->innerEditorElement();
224 EXPECT_EQ(5, HTMLTextFormControlElement::indexForPosition(innerEditor, Posit ion(innerEditor, PositionAnchorType::AfterAnchor))); 225 EXPECT_EQ(5, HTMLTextFormControlElement::indexForPosition(innerEditor, Posit ion(innerEditor, PositionAnchorType::AfterAnchor)));
225 } 226 }
226 227
227 } // namespace blink 228 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/VisibleUnitsTest.cpp ('k') | third_party/WebKit/Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698