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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 EXPECT_TRUE(inSameLine(positionWithAffinityInDOMTree(*one->firstChild(), 0), positionWithAffinityInDOMTree(*two->firstChild(), 0))); | 45 EXPECT_TRUE(inSameLine(positionWithAffinityInDOMTree(*one->firstChild(), 0), positionWithAffinityInDOMTree(*two->firstChild(), 0))); |
46 EXPECT_FALSE(inSameLine(positionWithAffinityInDOMTree(*one->firstChild(), 0) , positionWithAffinityInDOMTree(*five->firstChild(), 0))); | 46 EXPECT_FALSE(inSameLine(positionWithAffinityInDOMTree(*one->firstChild(), 0) , positionWithAffinityInDOMTree(*five->firstChild(), 0))); |
47 EXPECT_FALSE(inSameLine(positionWithAffinityInDOMTree(*two->firstChild(), 0) , positionWithAffinityInDOMTree(*four->firstChild(), 0))); | 47 EXPECT_FALSE(inSameLine(positionWithAffinityInDOMTree(*two->firstChild(), 0) , positionWithAffinityInDOMTree(*four->firstChild(), 0))); |
48 | 48 |
49 EXPECT_FALSE(inSameLine(positionWithAffinityInComposedTree(*one, 0), positio nWithAffinityInComposedTree(*two, 0))); | 49 EXPECT_FALSE(inSameLine(positionWithAffinityInComposedTree(*one, 0), positio nWithAffinityInComposedTree(*two, 0))); |
50 EXPECT_FALSE(inSameLine(positionWithAffinityInComposedTree(*one->firstChild( ), 0), positionWithAffinityInComposedTree(*two->firstChild(), 0))); | 50 EXPECT_FALSE(inSameLine(positionWithAffinityInComposedTree(*one->firstChild( ), 0), positionWithAffinityInComposedTree(*two->firstChild(), 0))); |
51 EXPECT_FALSE(inSameLine(positionWithAffinityInComposedTree(*one->firstChild( ), 0), positionWithAffinityInComposedTree(*five->firstChild(), 0))); | 51 EXPECT_FALSE(inSameLine(positionWithAffinityInComposedTree(*one->firstChild( ), 0), positionWithAffinityInComposedTree(*five->firstChild(), 0))); |
52 EXPECT_TRUE(inSameLine(positionWithAffinityInComposedTree(*two->firstChild() , 0), positionWithAffinityInComposedTree(*four->firstChild(), 0))); | 52 EXPECT_TRUE(inSameLine(positionWithAffinityInComposedTree(*two->firstChild() , 0), positionWithAffinityInComposedTree(*four->firstChild(), 0))); |
53 } | 53 } |
54 | 54 |
55 TEST_F(VisibleUnitsTest, localCaretRectOfPosition) | |
56 { | |
57 const char* bodyContent = "<p id='host'><b id='one'>1</b></p><b id='two'>22< /b>"; | |
58 const char* shadowContent = "<b id='two'>22</b><content select=#one></conten t><b id='three'>333</b>"; | |
59 setBodyContent(bodyContent); | |
60 setShadowContent(shadowContent); | |
61 updateLayoutAndStyleForPainting(); | |
62 | |
63 RefPtrWillBeRawPtr<Element> one = document().getElementById("one"); | |
64 | |
65 LayoutObject* layoutObjectFromDOMTree; | |
66 LayoutRect layoutRectFromDOMTree = localCaretRectOfPosition(Position(one, 0) , layoutObjectFromDOMTree); | |
67 | |
68 LayoutObject* layoutObjectFromComposedTree; | |
69 LayoutRect layoutRectFromComposedTree = localCaretRectOfPosition(PositionInC omposedTree(one, 0), layoutObjectFromComposedTree); | |
70 | |
yoichio
2015/08/25 10:07:09
Could you add expectation that LayoutRect and Layo
| |
71 EXPECT_EQ(layoutObjectFromDOMTree, layoutObjectFromComposedTree); | |
72 EXPECT_EQ(layoutRectFromDOMTree, layoutRectFromComposedTree); | |
73 } | |
74 | |
55 TEST_F(VisibleUnitsTest, mostBackwardCaretPositionAfterAnchor) | 75 TEST_F(VisibleUnitsTest, mostBackwardCaretPositionAfterAnchor) |
56 { | 76 { |
57 const char* bodyContent = "<p id='host'><b id='one'>1</b></p><b id='two'>22< /b>"; | 77 const char* bodyContent = "<p id='host'><b id='one'>1</b></p><b id='two'>22< /b>"; |
58 const char* shadowContent = "<b id='two'>22</b><content select=#one></conten t><b id='three'>333</b>"; | 78 const char* shadowContent = "<b id='two'>22</b><content select=#one></conten t><b id='three'>333</b>"; |
59 setBodyContent(bodyContent); | 79 setBodyContent(bodyContent); |
60 setShadowContent(shadowContent); | 80 setShadowContent(shadowContent); |
61 updateLayoutAndStyleForPainting(); | 81 updateLayoutAndStyleForPainting(); |
62 | 82 |
63 RefPtrWillBeRawPtr<Element> host = document().getElementById("host"); | 83 RefPtrWillBeRawPtr<Element> host = document().getElementById("host"); |
64 | 84 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 setBodyContent(bodyContent); | 119 setBodyContent(bodyContent); |
100 updateLayoutAndStyleForPainting(); | 120 updateLayoutAndStyleForPainting(); |
101 RefPtrWillBeRawPtr<Element> sample1 = document().getElementById("sample1"); | 121 RefPtrWillBeRawPtr<Element> sample1 = document().getElementById("sample1"); |
102 RefPtrWillBeRawPtr<Element> sample2 = document().getElementById("sample2"); | 122 RefPtrWillBeRawPtr<Element> sample2 = document().getElementById("sample2"); |
103 | 123 |
104 EXPECT_FALSE(rendersInDifferentPosition(Position::afterNode(sample1->firstCh ild()), Position(sample2->firstChild(), 0))); | 124 EXPECT_FALSE(rendersInDifferentPosition(Position::afterNode(sample1->firstCh ild()), Position(sample2->firstChild(), 0))); |
105 EXPECT_FALSE(rendersInDifferentPosition(Position::lastPositionInNode(sample1 ->firstChild()), Position(sample2->firstChild(), 0))); | 125 EXPECT_FALSE(rendersInDifferentPosition(Position::lastPositionInNode(sample1 ->firstChild()), Position(sample2->firstChild(), 0))); |
106 } | 126 } |
107 | 127 |
108 } // namespace blink | 128 } // namespace blink |
OLD | NEW |