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