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) | |
yoichio
2015/08/25 05:24:31
What does this test test?
yosin_UTC9
2015/08/25 09:23:48
Checks DOM tree version and composed tree version
yosin_UTC9
2015/08/25 09:46:08
Oops, my brain was damaged.
I put expectation into
| |
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 } | |
64 | |
55 TEST_F(VisibleUnitsTest, mostBackwardCaretPositionAfterAnchor) | 65 TEST_F(VisibleUnitsTest, mostBackwardCaretPositionAfterAnchor) |
56 { | 66 { |
57 const char* bodyContent = "<p id='host'><b id='one'>1</b></p><b id='two'>22< /b>"; | 67 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>"; | 68 const char* shadowContent = "<b id='two'>22</b><content select=#one></conten t><b id='three'>333</b>"; |
59 setBodyContent(bodyContent); | 69 setBodyContent(bodyContent); |
60 setShadowContent(shadowContent); | 70 setShadowContent(shadowContent); |
61 updateLayoutAndStyleForPainting(); | 71 updateLayoutAndStyleForPainting(); |
62 | 72 |
63 RefPtrWillBeRawPtr<Element> host = document().getElementById("host"); | 73 RefPtrWillBeRawPtr<Element> one = document().getElementById("one"); |
64 | 74 |
65 EXPECT_EQ(Position::lastPositionInNode(host.get()), mostForwardCaretPosition (Position::afterNode(host.get()))); | 75 LayoutObject* layoutObjectFromDOMTree; |
66 EXPECT_EQ(PositionInComposedTree::lastPositionInNode(host.get()), mostForwar dCaretPosition(PositionInComposedTree::afterNode(host.get()))); | 76 LayoutRect layoutRectFromDOMTree = localCaretRectOfPosition(Position(one, 0) , layoutObjectFromDOMTree); |
77 | |
78 LayoutObject* layoutObjectFromComposedTree; | |
79 LayoutRect layoutRectFromComposedTree = localCaretRectOfPosition(PositionInC omposedTree(one, 0), layoutObjectFromComposedTree); | |
80 | |
81 EXPECT_EQ(layoutObjectFromDOMTree, layoutObjectFromComposedTree); | |
82 EXPECT_EQ(layoutRectFromDOMTree, layoutRectFromComposedTree); | |
67 } | 83 } |
68 | 84 |
69 TEST_F(VisibleUnitsTest, mostForwardCaretPositionAfterAnchor) | 85 TEST_F(VisibleUnitsTest, mostForwardCaretPositionAfterAnchor) |
70 { | 86 { |
71 const char* bodyContent = "<p id='host'><b id='one'>1</b></p>"; | 87 const char* bodyContent = "<p id='host'><b id='one'>1</b></p>"; |
72 const char* shadowContent = "<b id='two'>22</b><content select=#one></conten t><b id='three'>333</b>"; | 88 const char* shadowContent = "<b id='two'>22</b><content select=#one></conten t><b id='three'>333</b>"; |
73 setBodyContent(bodyContent); | 89 setBodyContent(bodyContent); |
74 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent); | 90 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent); |
75 updateLayoutAndStyleForPainting(); | 91 updateLayoutAndStyleForPainting(); |
76 | 92 |
(...skipping 22 matching lines...) Expand all Loading... | |
99 setBodyContent(bodyContent); | 115 setBodyContent(bodyContent); |
100 updateLayoutAndStyleForPainting(); | 116 updateLayoutAndStyleForPainting(); |
101 RefPtrWillBeRawPtr<Element> sample1 = document().getElementById("sample1"); | 117 RefPtrWillBeRawPtr<Element> sample1 = document().getElementById("sample1"); |
102 RefPtrWillBeRawPtr<Element> sample2 = document().getElementById("sample2"); | 118 RefPtrWillBeRawPtr<Element> sample2 = document().getElementById("sample2"); |
103 | 119 |
104 EXPECT_FALSE(rendersInDifferentPosition(Position::afterNode(sample1->firstCh ild()), Position(sample2->firstChild(), 0))); | 120 EXPECT_FALSE(rendersInDifferentPosition(Position::afterNode(sample1->firstCh ild()), Position(sample2->firstChild(), 0))); |
105 EXPECT_FALSE(rendersInDifferentPosition(Position::lastPositionInNode(sample1 ->firstChild()), Position(sample2->firstChild(), 0))); | 121 EXPECT_FALSE(rendersInDifferentPosition(Position::lastPositionInNode(sample1 ->firstChild()), Position(sample2->firstChild(), 0))); |
106 } | 122 } |
107 | 123 |
108 } // namespace blink | 124 } // namespace blink |
OLD | NEW |