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/Position.h" | 5 #include "core/editing/Position.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 PositionTest : public EditingTestBase {}; | 11 class PositionTest : public EditingTestBase {}; |
12 | 12 |
13 TEST_F(PositionTest, IsEquivalent) { | 13 TEST_F(PositionTest, IsEquivalent) { |
14 SetBodyContent("<a id=sample>0<b>1</b>2</a>"); | 14 SetBodyContent("<a id=sample>0<b>1</b>2</a>"); |
15 | 15 |
16 Element* sample = GetDocument().getElementById("sample"); | 16 Element* sample = GetDocument().getElementById("sample"); |
17 | 17 |
18 EXPECT_TRUE(Position(sample, 0).IsEquivalent(Position(sample, 0))); | 18 EXPECT_TRUE(Position(sample, 0).IsEquivalent(Position(sample, 0))); |
19 | 19 |
20 EXPECT_TRUE( | 20 EXPECT_TRUE( |
21 Position(sample, 0).IsEquivalent(Position::FirstPositionInNode(sample))); | 21 Position(sample, 0).IsEquivalent(Position::FirstPositionInNode(*sample))); |
22 EXPECT_TRUE(Position(sample, 0).IsEquivalent( | 22 EXPECT_TRUE(Position(sample, 0).IsEquivalent( |
23 Position::BeforeNode(*sample->firstChild()))); | 23 Position::BeforeNode(*sample->firstChild()))); |
24 EXPECT_TRUE(Position(sample, 1).IsEquivalent( | 24 EXPECT_TRUE(Position(sample, 1).IsEquivalent( |
25 Position::AfterNode(*sample->firstChild()))); | 25 Position::AfterNode(*sample->firstChild()))); |
26 EXPECT_TRUE(Position(sample, 1).IsEquivalent( | 26 EXPECT_TRUE(Position(sample, 1).IsEquivalent( |
27 Position::BeforeNode(*sample->firstChild()->nextSibling()))); | 27 Position::BeforeNode(*sample->firstChild()->nextSibling()))); |
28 EXPECT_TRUE(Position(sample, 2).IsEquivalent( | 28 EXPECT_TRUE(Position(sample, 2).IsEquivalent( |
29 Position::BeforeNode(*sample->lastChild()))); | 29 Position::BeforeNode(*sample->lastChild()))); |
30 EXPECT_TRUE(Position(sample, 3).IsEquivalent( | 30 EXPECT_TRUE(Position(sample, 3).IsEquivalent( |
31 Position::AfterNode(*sample->lastChild()))); | 31 Position::AfterNode(*sample->lastChild()))); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 const char* shadow_content = ""; | 222 const char* shadow_content = ""; |
223 SetBodyContent(body_content); | 223 SetBodyContent(body_content); |
224 ShadowRoot* shadow_root = SetShadowContent(shadow_content, "host"); | 224 ShadowRoot* shadow_root = SetShadowContent(shadow_content, "host"); |
225 Element* host = GetDocument().getElementById("host"); | 225 Element* host = GetDocument().getElementById("host"); |
226 | 226 |
227 EXPECT_EQ(PositionInFlatTree(host, PositionAnchorType::kAfterChildren), | 227 EXPECT_EQ(PositionInFlatTree(host, PositionAnchorType::kAfterChildren), |
228 ToPositionInFlatTree(Position(shadow_root, 0))); | 228 ToPositionInFlatTree(Position(shadow_root, 0))); |
229 } | 229 } |
230 | 230 |
231 } // namespace blink | 231 } // namespace blink |
OLD | NEW |