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

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

Issue 1675163002: Rename ComposedTree to FlatTree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wip Created 4 years, 10 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/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 15 matching lines...) Expand all
26 void didChangeVisibleSelection() final { ++m_callCounter; } 26 void didChangeVisibleSelection() final { ++m_callCounter; }
27 27
28 int m_callCounter = 0; 28 int m_callCounter = 0;
29 }; 29 };
30 30
31 } // namespace 31 } // namespace
32 32
33 class SelectionAdjusterTest : public EditingTestBase { 33 class SelectionAdjusterTest : public EditingTestBase {
34 }; 34 };
35 35
36 TEST_F(SelectionAdjusterTest, adjustSelectionInComposedTree) 36 TEST_F(SelectionAdjusterTest, adjustSelectionInFlatTree)
37 { 37 {
38 setBodyContent("<div id=sample>foo</div>"); 38 setBodyContent("<div id=sample>foo</div>");
39 MockVisibleSelectionChangeObserver selectionObserver; 39 MockVisibleSelectionChangeObserver selectionObserver;
40 VisibleSelectionInComposedTree selectionInComposedTree; 40 VisibleSelectionInFlatTree selectionInFlatTree;
41 selectionInComposedTree.setChangeObserver(selectionObserver); 41 selectionInFlatTree.setChangeObserver(selectionObserver);
42 42
43 Node* const sample = document().getElementById("sample"); 43 Node* const sample = document().getElementById("sample");
44 Node* const foo = sample->firstChild(); 44 Node* const foo = sample->firstChild();
45 // Select "foo" 45 // Select "foo"
46 VisibleSelection selection(Position(foo, 0), Position(foo, 3)); 46 VisibleSelection selection(Position(foo, 0), Position(foo, 3));
47 SelectionAdjuster::adjustSelectionInComposedTree(&selectionInComposedTree, s election); 47 SelectionAdjuster::adjustSelectionInFlatTree(&selectionInFlatTree, selection );
48 EXPECT_EQ(PositionInComposedTree(foo, 0), selectionInComposedTree.start()); 48 EXPECT_EQ(PositionInFlatTree(foo, 0), selectionInFlatTree.start());
49 EXPECT_EQ(PositionInComposedTree(foo, 3), selectionInComposedTree.end()); 49 EXPECT_EQ(PositionInFlatTree(foo, 3), selectionInFlatTree.end());
50 EXPECT_EQ(1, selectionObserver.callCounter()) << "adjustSelectionInComposedT ree() should call didChangeVisibleSelection()"; 50 EXPECT_EQ(1, selectionObserver.callCounter()) << "adjustSelectionInFlatTree( ) should call didChangeVisibleSelection()";
51 } 51 }
52 52
53 TEST_F(SelectionAdjusterTest, adjustSelectionInDOMTree) 53 TEST_F(SelectionAdjusterTest, adjustSelectionInDOMTree)
54 { 54 {
55 setBodyContent("<div id=sample>foo</div>"); 55 setBodyContent("<div id=sample>foo</div>");
56 MockVisibleSelectionChangeObserver selectionObserver; 56 MockVisibleSelectionChangeObserver selectionObserver;
57 VisibleSelection selection; 57 VisibleSelection selection;
58 selection.setChangeObserver(selectionObserver); 58 selection.setChangeObserver(selectionObserver);
59 59
60 Node* const sample = document().getElementById("sample"); 60 Node* const sample = document().getElementById("sample");
61 Node* const foo = sample->firstChild(); 61 Node* const foo = sample->firstChild();
62 // Select "foo" 62 // Select "foo"
63 VisibleSelectionInComposedTree selectionInComposedTree( 63 VisibleSelectionInFlatTree selectionInFlatTree(
64 PositionInComposedTree(foo, 0), 64 PositionInFlatTree(foo, 0),
65 PositionInComposedTree(foo, 3)); 65 PositionInFlatTree(foo, 3));
66 SelectionAdjuster::adjustSelectionInDOMTree(&selection, selectionInComposedT ree); 66 SelectionAdjuster::adjustSelectionInDOMTree(&selection, selectionInFlatTree) ;
67 EXPECT_EQ(Position(foo, 0), selection.start()); 67 EXPECT_EQ(Position(foo, 0), selection.start());
68 EXPECT_EQ(Position(foo, 3), selection.end()); 68 EXPECT_EQ(Position(foo, 3), selection.end());
69 EXPECT_EQ(1, selectionObserver.callCounter()) << "adjustSelectionInDOMTree() should call didChangeVisibleSelection()"; 69 EXPECT_EQ(1, selectionObserver.callCounter()) << "adjustSelectionInDOMTree() should call didChangeVisibleSelection()";
70 } 70 }
71 71
72 } // namespace blink 72 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698