| 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 | 6 |
| 7 #include "core/editing/EditingStrategy.h" | 7 #include "core/editing/EditingStrategy.h" |
| 8 | 8 |
| 9 #include "core/editing/EditingTestBase.h" | 9 #include "core/editing/EditingTestBase.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 class EditingStrategyTest : public EditingTestBase { | 13 class EditingStrategyTest : public EditingTestBase { |
| 14 }; | 14 }; |
| 15 | 15 |
| 16 TEST_F(EditingStrategyTest, caretMaxOffset) | 16 TEST_F(EditingStrategyTest, caretMaxOffset) |
| 17 { | 17 { |
| 18 const char* bodyContent = "<p id='host'>00<b id='one'>1</b><b id='two'>22</b
>333</p>"; | 18 const char* bodyContent = "<p id='host'>00<b id='one'>1</b><b id='two'>22</b
>333</p>"; |
| 19 const char* shadowContent = "<content select=#two></content><content select=
#one></content>"; | 19 const char* shadowContent = "<content select=#two></content><content select=
#one></content>"; |
| 20 setBodyContent(bodyContent); | 20 setBodyContent(bodyContent); |
| 21 setShadowContent(shadowContent); | 21 setShadowContent(shadowContent, "host"); |
| 22 Node* host = document().getElementById("host"); | 22 Node* host = document().getElementById("host"); |
| 23 Node* one = document().getElementById("one"); | 23 Node* one = document().getElementById("one"); |
| 24 Node* two = document().getElementById("two"); | 24 Node* two = document().getElementById("two"); |
| 25 | 25 |
| 26 EXPECT_EQ(4, EditingStrategy::caretMaxOffset(*host)); | 26 EXPECT_EQ(4, EditingStrategy::caretMaxOffset(*host)); |
| 27 EXPECT_EQ(1, EditingStrategy::caretMaxOffset(*one)); | 27 EXPECT_EQ(1, EditingStrategy::caretMaxOffset(*one)); |
| 28 EXPECT_EQ(1, EditingStrategy::caretMaxOffset(*one->firstChild())); | 28 EXPECT_EQ(1, EditingStrategy::caretMaxOffset(*one->firstChild())); |
| 29 EXPECT_EQ(2, EditingStrategy::caretMaxOffset(*two->firstChild())); | 29 EXPECT_EQ(2, EditingStrategy::caretMaxOffset(*two->firstChild())); |
| 30 | 30 |
| 31 EXPECT_EQ(2, EditingInComposedTreeStrategy::caretMaxOffset(*host)); | 31 EXPECT_EQ(2, EditingInComposedTreeStrategy::caretMaxOffset(*host)); |
| 32 EXPECT_EQ(1, EditingInComposedTreeStrategy::caretMaxOffset(*one)); | 32 EXPECT_EQ(1, EditingInComposedTreeStrategy::caretMaxOffset(*one)); |
| 33 EXPECT_EQ(1, EditingInComposedTreeStrategy::caretMaxOffset(*one->firstChild(
))); | 33 EXPECT_EQ(1, EditingInComposedTreeStrategy::caretMaxOffset(*one->firstChild(
))); |
| 34 EXPECT_EQ(2, EditingInComposedTreeStrategy::caretMaxOffset(*two->firstChild(
))); | 34 EXPECT_EQ(2, EditingInComposedTreeStrategy::caretMaxOffset(*two->firstChild(
))); |
| 35 } | 35 } |
| 36 | 36 |
| 37 } // namespace blink | 37 } // namespace blink |
| OLD | NEW |