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

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

Issue 2701083002: Preserve handles visibility when modifying selection (Closed)
Patch Set: Added unit test Created 3 years, 9 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
« no previous file with comments | « third_party/WebKit/Source/core/editing/FrameSelection.cpp ('k') | 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 "core/editing/FrameSelection.h" 5 #include "core/editing/FrameSelection.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/dom/Element.h" 10 #include "core/dom/Element.h"
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 .setIsHandleVisible(true) 286 .setIsHandleVisible(true)
287 .build()); 287 .build());
288 EXPECT_TRUE(selection().isHandleVisible()); 288 EXPECT_TRUE(selection().isHandleVisible());
289 selection().selectAll(); 289 selection().selectAll();
290 EXPECT_TRUE(selection().isHandleVisible()) 290 EXPECT_TRUE(selection().isHandleVisible())
291 << "If handles were present before" 291 << "If handles were present before"
292 "selectAll. Then they should be present" 292 "selectAll. Then they should be present"
293 "after it."; 293 "after it.";
294 } 294 }
295 295
296 TEST_F(FrameSelectionTest, SetSelectedRangePreservesHandle) {
297 Text* text = appendTextNode("Hello, World!");
298 document().view()->updateAllLifecyclePhases();
299 selection().setSelection(
300 SelectionInDOMTree::Builder()
301 .setBaseAndExtent(Position(text, 0), Position(text, 5))
302 .setIsHandleVisible(false)
303 .build());
304 EXPECT_FALSE(selection().isHandleVisible());
yosin_UTC9 2017/03/16 01:10:26 nit: Since other test covers this, we don't need t
Tima Vaisburd 2017/03/16 02:02:29 Done.
305
306 selection().setSelectedRange(
307 EphemeralRange(Position(text, 0), Position(text, 12)),
308 VP_DEFAULT_AFFINITY, SelectionDirectionalMode::NonDirectional, 0);
309
310 EXPECT_FALSE(selection().isHandleVisible())
311 << "If handles weren't present before"
312 "setSelectedRange they shouldn't be present"
313 "after it.";
314
315 selection().setSelection(
316 SelectionInDOMTree::Builder()
317 .setBaseAndExtent(Position(text, 0), Position(text, 5))
318 .setIsHandleVisible(true)
319 .build());
320 EXPECT_TRUE(selection().isHandleVisible());
yosin_UTC9 2017/03/16 01:10:26 nit: Since other test covers this, we don't need t
Tima Vaisburd 2017/03/16 02:02:29 Done.
321
322 selection().setSelectedRange(
323 EphemeralRange(Position(text, 0), Position(text, 12)),
324 VP_DEFAULT_AFFINITY, SelectionDirectionalMode::NonDirectional, 0);
325
326 EXPECT_TRUE(selection().isHandleVisible())
327 << "If handles were present before"
328 "selectSetSelectedRange they should be present after it.";
329 }
330
296 } // namespace blink 331 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/FrameSelection.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698