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

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

Issue 2712223002: Get rid of redundant functions updateIfNeeded() in FrameSelection and SelectionEditor (Closed)
Patch Set: 2017-02-27T11:10:27 Remove updateIfNeeded() from FrameSeleciton.h 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
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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 .setIsHandleVisible(true) 235 .setIsHandleVisible(true)
236 .build()); 236 .build());
237 EXPECT_TRUE(selection().isHandleVisible()); 237 EXPECT_TRUE(selection().isHandleVisible());
238 selection().selectAll(); 238 selection().selectAll();
239 EXPECT_TRUE(selection().isHandleVisible()) 239 EXPECT_TRUE(selection().isHandleVisible())
240 << "If handles were present before" 240 << "If handles were present before"
241 "selectAll. Then they should be present" 241 "selectAll. Then they should be present"
242 "after it."; 242 "after it.";
243 } 243 }
244 244
245 TEST_F(FrameSelectionTest, updateIfNeededAndFrameCaret) {
246 setBodyContent("<style id=sample></style>");
247 document().setDesignMode("on");
248 updateAllLifecyclePhases();
249 Element* sample = document().getElementById("sample");
250 selection().setSelection(
251 SelectionInDOMTree::Builder().collapse(Position(sample, 0)).build());
252 EXPECT_EQ(Position(document().body(), 0),
253 selection().computeVisibleSelectionInDOMTreeDeprecated().start());
254 EXPECT_EQ(selection().computeVisibleSelectionInDOMTreeDeprecated().start(),
255 caretPosition().position());
256 document().body()->remove();
257 EXPECT_EQ(Position(),
258 selection().computeVisibleSelectionInDOMTreeDeprecated().start())
259 << "Selection has been removed by BODY.remove().";
260 EXPECT_EQ(selection().computeVisibleSelectionInDOMTreeDeprecated().start(),
261 caretPosition().position());
262 document().updateStyleAndLayout();
263 selection().updateIfNeeded();
264
265 EXPECT_EQ(Position(),
266 selection().computeVisibleSelectionInDOMTreeDeprecated().start())
267 << "selection().updateIfNeeded() does nothing.";
268 EXPECT_EQ(selection().computeVisibleSelectionInDOMTreeDeprecated().start(),
269 caretPosition().position());
270 }
271
272 } // namespace blink 245 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/FrameSelection.cpp ('k') | third_party/WebKit/Source/core/editing/SelectionEditor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698