| OLD | NEW |
| 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/SelectionAdjuster.h" | 5 #include "core/editing/SelectionAdjuster.h" |
| 6 | 6 |
| 7 #include "core/editing/EditingTestBase.h" | 7 #include "core/editing/EditingTestBase.h" |
| 8 | 8 |
| 9 namespace blink { | 9 namespace blink { |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 EXPECT_EQ(PositionInFlatTree(foo, 3), selectionInFlatTree.end()); | 24 EXPECT_EQ(PositionInFlatTree(foo, 3), selectionInFlatTree.end()); |
| 25 } | 25 } |
| 26 | 26 |
| 27 TEST_F(SelectionAdjusterTest, adjustSelectionInDOMTree) { | 27 TEST_F(SelectionAdjusterTest, adjustSelectionInDOMTree) { |
| 28 setBodyContent("<div id=sample>foo</div>"); | 28 setBodyContent("<div id=sample>foo</div>"); |
| 29 VisibleSelection selection; | 29 VisibleSelection selection; |
| 30 | 30 |
| 31 Node* const sample = document().getElementById("sample"); | 31 Node* const sample = document().getElementById("sample"); |
| 32 Node* const foo = sample->firstChild(); | 32 Node* const foo = sample->firstChild(); |
| 33 // Select "foo" | 33 // Select "foo" |
| 34 VisibleSelectionInFlatTree selectionInFlatTree = createVisibleSelection( | 34 VisibleSelectionInFlatTree selectionInFlatTree = |
| 35 PositionInFlatTree(foo, 0), PositionInFlatTree(foo, 3)); | 35 createVisibleSelection(SelectionInFlatTree::Builder() |
| 36 .collapse(PositionInFlatTree(foo, 0)) |
| 37 .extend(PositionInFlatTree(foo, 3)) |
| 38 .build()); |
| 36 SelectionAdjuster::adjustSelectionInDOMTree(&selection, selectionInFlatTree); | 39 SelectionAdjuster::adjustSelectionInDOMTree(&selection, selectionInFlatTree); |
| 37 EXPECT_EQ(Position(foo, 0), selection.start()); | 40 EXPECT_EQ(Position(foo, 0), selection.start()); |
| 38 EXPECT_EQ(Position(foo, 3), selection.end()); | 41 EXPECT_EQ(Position(foo, 3), selection.end()); |
| 39 } | 42 } |
| 40 | 43 |
| 41 } // namespace blink | 44 } // namespace blink |
| OLD | NEW |