OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "config.h" | 5 #include "config.h" |
6 #include "core/editing/EditingUtilities.h" | 6 #include "core/editing/EditingUtilities.h" |
7 | 7 |
8 #include "core/editing/EditingTestBase.h" | 8 #include "core/editing/EditingTestBase.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
11 | 11 |
12 class EditingUtilitiesTest : public EditingTestBase { | 12 class EditingUtilitiesTest : public EditingTestBase { |
13 }; | 13 }; |
14 | 14 |
| 15 TEST_F(EditingUtilitiesTest, enclosingNodeOfType) |
| 16 { |
| 17 const char* bodyContent = "<p id='host'><b id='one'>11</b></p>"; |
| 18 const char* shadowContent = "<content select=#two></content><div id='three'>
<content select=#one></div></content>"; |
| 19 setBodyContent(bodyContent); |
| 20 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent); |
| 21 updateLayoutAndStyleForPainting(); |
| 22 Node* host = document().getElementById("host"); |
| 23 Node* one = document().getElementById("one"); |
| 24 Node* three = shadowRoot->getElementById("three"); |
| 25 |
| 26 EXPECT_EQ(host, enclosingNodeOfType(Position(one, 0), isBlock)); |
| 27 EXPECT_EQ(three, enclosingNodeOfType(PositionInComposedTree(one, 0), isBlock
)); |
| 28 } |
| 29 |
15 TEST_F(EditingUtilitiesTest, NextNodeIndex) | 30 TEST_F(EditingUtilitiesTest, NextNodeIndex) |
16 { | 31 { |
17 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</
b>33</p>"; | 32 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</
b>33</p>"; |
18 const char* shadowContent = "<content select=#two></content><content select=
#one></content>"; | 33 const char* shadowContent = "<content select=#two></content><content select=
#one></content>"; |
19 setBodyContent(bodyContent); | 34 setBodyContent(bodyContent); |
20 setShadowContent(shadowContent); | 35 setShadowContent(shadowContent); |
21 Node* host = document().getElementById("host"); | 36 Node* host = document().getElementById("host"); |
22 Node* two = document().getElementById("two"); | 37 Node* two = document().getElementById("two"); |
23 | 38 |
24 EXPECT_EQ(Position(host, 3), nextPositionOf(Position(two, 2), PositionMoveTy
pe::CodePoint)); | 39 EXPECT_EQ(Position(host, 3), nextPositionOf(Position(two, 2), PositionMoveTy
pe::CodePoint)); |
25 EXPECT_EQ(PositionInComposedTree(host, 1), nextPositionOf(PositionInComposed
Tree(two, 2), PositionMoveType::CodePoint)); | 40 EXPECT_EQ(PositionInComposedTree(host, 1), nextPositionOf(PositionInComposed
Tree(two, 2), PositionMoveType::CodePoint)); |
26 } | 41 } |
27 | 42 |
28 TEST_F(EditingUtilitiesTest, NextVisuallyDistinctCandidate) | 43 TEST_F(EditingUtilitiesTest, NextVisuallyDistinctCandidate) |
29 { | 44 { |
30 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</
b><b id='three'>33</b></p>"; | 45 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</
b><b id='three'>33</b></p>"; |
31 const char* shadowContent = "<content select=#two></content><content select=
#one></content><content select=#three></content>"; | 46 const char* shadowContent = "<content select=#two></content><content select=
#one></content><content select=#three></content>"; |
32 setBodyContent(bodyContent); | 47 setBodyContent(bodyContent); |
33 setShadowContent(shadowContent); | 48 setShadowContent(shadowContent); |
34 updateLayoutAndStyleForPainting(); | 49 updateLayoutAndStyleForPainting(); |
35 Node* one = document().getElementById("one"); | 50 Node* one = document().getElementById("one"); |
36 Node* two = document().getElementById("two"); | 51 Node* two = document().getElementById("two"); |
37 Node* three = document().getElementById("three"); | 52 Node* three = document().getElementById("three"); |
38 | 53 |
39 EXPECT_EQ(Position(two->firstChild(), 1), nextVisuallyDistinctCandidate(Posi
tion(one, 1))); | 54 EXPECT_EQ(Position(two->firstChild(), 1), nextVisuallyDistinctCandidate(Posi
tion(one, 1))); |
40 EXPECT_EQ(PositionInComposedTree(three->firstChild(), 1), nextVisuallyDistin
ctCandidate(PositionInComposedTree(one, 1))); | 55 EXPECT_EQ(PositionInComposedTree(three->firstChild(), 1), nextVisuallyDistin
ctCandidate(PositionInComposedTree(one, 1))); |
41 } | 56 } |
42 | 57 |
43 } // namespace blink | 58 } // namespace blink |
OLD | NEW |