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/VisibleUnits.h" | 6 #include "core/editing/VisibleUnits.h" |
7 | 7 |
8 #include "core/editing/EditingTestBase.h" | 8 #include "core/editing/EditingTestBase.h" |
9 #include "core/editing/VisiblePosition.h" | 9 #include "core/editing/VisiblePosition.h" |
10 | 10 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 RefPtrWillBeRawPtr<Element> one = document().getElementById("one"); | 67 RefPtrWillBeRawPtr<Element> one = document().getElementById("one"); |
68 RefPtrWillBeRawPtr<Element> two = document().getElementById("two"); | 68 RefPtrWillBeRawPtr<Element> two = document().getElementById("two"); |
69 | 69 |
70 EXPECT_EQ('2', characterAfter(createVisiblePositionInDOMTree(*one->firstChil
d(), 1))); | 70 EXPECT_EQ('2', characterAfter(createVisiblePositionInDOMTree(*one->firstChil
d(), 1))); |
71 EXPECT_EQ('5', characterAfter(createVisiblePositionInComposedTree(*one->firs
tChild(), 1))); | 71 EXPECT_EQ('5', characterAfter(createVisiblePositionInComposedTree(*one->firs
tChild(), 1))); |
72 | 72 |
73 EXPECT_EQ(0, characterAfter(createVisiblePositionInDOMTree(*two->firstChild(
), 2))); | 73 EXPECT_EQ(0, characterAfter(createVisiblePositionInDOMTree(*two->firstChild(
), 2))); |
74 EXPECT_EQ('1', characterAfter(createVisiblePositionInComposedTree(*two->firs
tChild(), 2))); | 74 EXPECT_EQ('1', characterAfter(createVisiblePositionInComposedTree(*two->firs
tChild(), 2))); |
75 } | 75 } |
76 | 76 |
| 77 TEST_F(VisibleUnitsTest, endOfDocument) |
| 78 { |
| 79 const char* bodyContent = "<a id=host><b id=one>1</b><b id=two>22</b></a>"; |
| 80 const char* shadowContent = "<p><content select=#two></content></p><p><conte
nt select=#one></content></p>"; |
| 81 setBodyContent(bodyContent); |
| 82 setShadowContent(shadowContent, "host"); |
| 83 updateLayoutAndStyleForPainting(); |
| 84 |
| 85 Element* one = document().getElementById("one"); |
| 86 Element* two = document().getElementById("two"); |
| 87 |
| 88 EXPECT_EQ(Position(two->firstChild(), 2), endOfDocument(createVisiblePositio
nInDOMTree(*one->firstChild(), 0)).deepEquivalent()); |
| 89 EXPECT_EQ(PositionInComposedTree(one->firstChild(), 1), endOfDocument(create
VisiblePositionInComposedTree(*one->firstChild(), 0)).deepEquivalent()); |
| 90 |
| 91 EXPECT_EQ(Position(two->firstChild(), 2), endOfDocument(createVisiblePositio
nInDOMTree(*two->firstChild(), 1)).deepEquivalent()); |
| 92 EXPECT_EQ(PositionInComposedTree(one->firstChild(), 1), endOfDocument(create
VisiblePositionInComposedTree(*two->firstChild(), 1)).deepEquivalent()); |
| 93 } |
| 94 |
77 TEST_F(VisibleUnitsTest, endOfParagraph) | 95 TEST_F(VisibleUnitsTest, endOfParagraph) |
78 { | 96 { |
79 const char* bodyContent = "<a id=host><b id=one>1</b><b id=two>22</b></a><b
id=three>333</b>"; | 97 const char* bodyContent = "<a id=host><b id=one>1</b><b id=two>22</b></a><b
id=three>333</b>"; |
80 const char* shadowContent = "<p><content select=#two></content></p><p><conte
nt select=#one></content></p>"; | 98 const char* shadowContent = "<p><content select=#two></content></p><p><conte
nt select=#one></content></p>"; |
81 setBodyContent(bodyContent); | 99 setBodyContent(bodyContent); |
82 setShadowContent(shadowContent, "host"); | 100 setShadowContent(shadowContent, "host"); |
83 updateLayoutAndStyleForPainting(); | 101 updateLayoutAndStyleForPainting(); |
84 | 102 |
85 Element* one = document().getElementById("one"); | 103 Element* one = document().getElementById("one"); |
86 Element* two = document().getElementById("two"); | 104 Element* two = document().getElementById("two"); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 setBodyContent(bodyContent); | 267 setBodyContent(bodyContent); |
250 updateLayoutAndStyleForPainting(); | 268 updateLayoutAndStyleForPainting(); |
251 RefPtrWillBeRawPtr<Element> sample1 = document().getElementById("sample1"); | 269 RefPtrWillBeRawPtr<Element> sample1 = document().getElementById("sample1"); |
252 RefPtrWillBeRawPtr<Element> sample2 = document().getElementById("sample2"); | 270 RefPtrWillBeRawPtr<Element> sample2 = document().getElementById("sample2"); |
253 | 271 |
254 EXPECT_FALSE(rendersInDifferentPosition(Position::afterNode(sample1->firstCh
ild()), Position(sample2->firstChild(), 0))); | 272 EXPECT_FALSE(rendersInDifferentPosition(Position::afterNode(sample1->firstCh
ild()), Position(sample2->firstChild(), 0))); |
255 EXPECT_FALSE(rendersInDifferentPosition(Position::lastPositionInNode(sample1
->firstChild()), Position(sample2->firstChild(), 0))); | 273 EXPECT_FALSE(rendersInDifferentPosition(Position::lastPositionInNode(sample1
->firstChild()), Position(sample2->firstChild(), 0))); |
256 } | 274 } |
257 | 275 |
258 } // namespace blink | 276 } // namespace blink |
OLD | NEW |