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 "core/editing/EditingUtilities.h" | 5 #include "core/editing/EditingUtilities.h" |
6 | 6 |
7 #include "core/dom/StaticNodeList.h" | 7 #include "core/dom/StaticNodeList.h" |
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 TEST_F(EditingUtilitiesTest, directionOfEnclosingBlock) { | 14 TEST_F(EditingUtilitiesTest, directionOfEnclosingBlock) { |
15 const char* bodyContent = | 15 const char* bodyContent = |
16 "<p id='host'><b id='one'></b><b id='two'>22</b></p>"; | 16 "<p id='host'><b id='one'></b><b id='two'>22</b></p>"; |
17 const char* shadowContent = | 17 const char* shadowContent = |
18 "<content select=#two></content><p dir=rtl><content " | 18 "<content select=#two></content><p dir=rtl><content " |
19 "select=#one></content><p>"; | 19 "select=#one></content><p>"; |
20 setBodyContent(bodyContent); | 20 setBodyContent(bodyContent); |
21 setShadowContent(shadowContent, "host"); | 21 setShadowContent(shadowContent, "host"); |
22 Node* one = document().getElementById("one"); | 22 Node* one = document().getElementById("one"); |
23 | 23 |
24 EXPECT_EQ(LTR, directionOfEnclosingBlock(Position(one, 0))); | 24 EXPECT_EQ(TextDirection::Ltr, directionOfEnclosingBlock(Position(one, 0))); |
25 EXPECT_EQ(RTL, directionOfEnclosingBlock(PositionInFlatTree(one, 0))); | 25 EXPECT_EQ(TextDirection::Rtl, |
| 26 directionOfEnclosingBlock(PositionInFlatTree(one, 0))); |
26 } | 27 } |
27 | 28 |
28 TEST_F(EditingUtilitiesTest, firstEditablePositionAfterPositionInRoot) { | 29 TEST_F(EditingUtilitiesTest, firstEditablePositionAfterPositionInRoot) { |
29 const char* bodyContent = | 30 const char* bodyContent = |
30 "<p id='host' contenteditable><b id='one'>1</b><b id='two'>22</b></p>"; | 31 "<p id='host' contenteditable><b id='one'>1</b><b id='two'>22</b></p>"; |
31 const char* shadowContent = | 32 const char* shadowContent = |
32 "<content select=#two></content><content select=#one></content><b " | 33 "<content select=#two></content><content select=#one></content><b " |
33 "id='three'>333</b>"; | 34 "id='three'>333</b>"; |
34 setBodyContent(bodyContent); | 35 setBodyContent(bodyContent); |
35 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host"); | 36 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host"); |
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 PositionMoveType::BackwardDeletion)); | 898 PositionMoveType::BackwardDeletion)); |
898 EXPECT_EQ(Position(node, 2), | 899 EXPECT_EQ(Position(node, 2), |
899 previousPositionOf(Position(node, 3), | 900 previousPositionOf(Position(node, 3), |
900 PositionMoveType::BackwardDeletion)); | 901 PositionMoveType::BackwardDeletion)); |
901 EXPECT_EQ(Position(node, 0), | 902 EXPECT_EQ(Position(node, 0), |
902 previousPositionOf(Position(node, 1), | 903 previousPositionOf(Position(node, 1), |
903 PositionMoveType::BackwardDeletion)); | 904 PositionMoveType::BackwardDeletion)); |
904 } | 905 } |
905 | 906 |
906 } // namespace blink | 907 } // namespace blink |
OLD | NEW |