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

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

Issue 2723133004: Get rid of redundant member variable SelectionEditor::m_logicalRange (Closed)
Patch Set: 2017-03-06T13:02:21 rebase 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 private: 49 private:
50 Persistent<Text> m_textNode; 50 Persistent<Text> m_textNode;
51 }; 51 };
52 52
53 Text* FrameSelectionTest::appendTextNode(const String& data) { 53 Text* FrameSelectionTest::appendTextNode(const String& data) {
54 Text* text = document().createTextNode(data); 54 Text* text = document().createTextNode(data);
55 document().body()->appendChild(text); 55 document().body()->appendChild(text);
56 return text; 56 return text;
57 } 57 }
58 58
59 TEST_F(FrameSelectionTest, FirstRange) {
60 setBodyContent("<div id=sample>0123456789</div>abc");
61 Element* const sample = document().getElementById("sample");
62 Node* const text = sample->firstChild();
63 selection().setSelectedRange(
64 EphemeralRange(Position(text, 3), Position(text, 6)), VP_DEFAULT_AFFINITY,
65 SelectionDirectionalMode::NonDirectional, 0);
66 sample->setAttribute(HTMLNames::styleAttr, "display:none");
67 // Move |VisibleSelection| before "abc".
68 updateAllLifecyclePhases();
69 Range* const range = selection().firstRange();
70 EXPECT_EQ(Position(sample->nextSibling(), 0), range->startPosition())
71 << "firstRagne() should return current selection value";
72 EXPECT_EQ(Position(sample->nextSibling(), 0), range->endPosition());
73 }
74
59 TEST_F(FrameSelectionTest, SetValidSelection) { 75 TEST_F(FrameSelectionTest, SetValidSelection) {
60 Text* text = appendTextNode("Hello, World!"); 76 Text* text = appendTextNode("Hello, World!");
61 document().view()->updateAllLifecyclePhases(); 77 document().view()->updateAllLifecyclePhases();
62 selection().setSelection( 78 selection().setSelection(
63 SelectionInDOMTree::Builder() 79 SelectionInDOMTree::Builder()
64 .setBaseAndExtent(Position(text, 0), Position(text, 5)) 80 .setBaseAndExtent(Position(text, 0), Position(text, 5))
65 .build()); 81 .build());
66 EXPECT_FALSE( 82 EXPECT_FALSE(
67 selection().computeVisibleSelectionInDOMTreeDeprecated().isNone()); 83 selection().computeVisibleSelectionInDOMTreeDeprecated().isNone());
68 } 84 }
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 .build()); 287 .build());
272 EXPECT_TRUE(selection().isHandleVisible()); 288 EXPECT_TRUE(selection().isHandleVisible());
273 selection().selectAll(); 289 selection().selectAll();
274 EXPECT_TRUE(selection().isHandleVisible()) 290 EXPECT_TRUE(selection().isHandleVisible())
275 << "If handles were present before" 291 << "If handles were present before"
276 "selectAll. Then they should be present" 292 "selectAll. Then they should be present"
277 "after it."; 293 "after it.";
278 } 294 }
279 295
280 } // namespace blink 296 } // 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