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/VisiblePosition.h" | 5 #include "core/editing/VisiblePosition.h" |
6 | 6 |
7 #include "core/editing/EditingTestBase.h" | 7 #include "core/editing/EditingTestBase.h" |
8 #include "core/editing/VisibleUnits.h" | 8 #include "core/editing/VisibleUnits.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
(...skipping 18 matching lines...) Expand all Loading... | |
29 EXPECT_EQ(Position(one->firstChild(), 0), createVisiblePosition(Position(one , 0)).deepEquivalent()); | 29 EXPECT_EQ(Position(one->firstChild(), 0), createVisiblePosition(Position(one , 0)).deepEquivalent()); |
30 EXPECT_EQ(Position(one->firstChild(), 2), canonicalPositionOf(Position(two, 0))); | 30 EXPECT_EQ(Position(one->firstChild(), 2), canonicalPositionOf(Position(two, 0))); |
31 EXPECT_EQ(Position(one->firstChild(), 2), createVisiblePosition(Position(two , 0)).deepEquivalent()); | 31 EXPECT_EQ(Position(one->firstChild(), 2), createVisiblePosition(Position(two , 0)).deepEquivalent()); |
32 | 32 |
33 EXPECT_EQ(PositionInFlatTree(five->firstChild(), 2), canonicalPositionOf(Pos itionInFlatTree(one, 0))); | 33 EXPECT_EQ(PositionInFlatTree(five->firstChild(), 2), canonicalPositionOf(Pos itionInFlatTree(one, 0))); |
34 EXPECT_EQ(PositionInFlatTree(five->firstChild(), 2), createVisiblePosition(P ositionInFlatTree(one, 0)).deepEquivalent()); | 34 EXPECT_EQ(PositionInFlatTree(five->firstChild(), 2), createVisiblePosition(P ositionInFlatTree(one, 0)).deepEquivalent()); |
35 EXPECT_EQ(PositionInFlatTree(four->firstChild(), 2), canonicalPositionOf(Pos itionInFlatTree(two, 0))); | 35 EXPECT_EQ(PositionInFlatTree(four->firstChild(), 2), canonicalPositionOf(Pos itionInFlatTree(two, 0))); |
36 EXPECT_EQ(PositionInFlatTree(four->firstChild(), 2), createVisiblePosition(P ositionInFlatTree(two, 0)).deepEquivalent()); | 36 EXPECT_EQ(PositionInFlatTree(four->firstChild(), 2), createVisiblePosition(P ositionInFlatTree(two, 0)).deepEquivalent()); |
37 } | 37 } |
38 | 38 |
39 #if DCHECK_IS_ON() | |
40 | |
41 TEST_F(VisiblePositionTest, NullIsValid) | |
42 { | |
43 EXPECT_TRUE(VisiblePosition().isValid()); | |
44 } | |
45 | |
46 TEST_F(VisiblePositionTest, NonNullIsValidInCleanTree) | |
47 { | |
48 setBodyContent("<p>one</p>"); | |
49 | |
50 Element* paragraph = document().querySelector("p"); | |
51 Position position(paragraph->firstChild(), 1); | |
52 EXPECT_TRUE(createVisiblePosition(position).isValid()); | |
53 } | |
54 | |
55 TEST_F(VisiblePositionTest, NonNullInvalidatedAfterMutation) | |
56 { | |
57 setBodyContent("<p>one</p>"); | |
58 | |
59 Element* paragraph = document().querySelector("p"); | |
60 Position position(paragraph->firstChild(), 1); | |
61 VisiblePosition nullVisiblePosition; | |
62 VisiblePosition nonNullVisiblePosition = createVisiblePosition(position); | |
63 | |
64 Element* div = document().createElement("div", ASSERT_NO_EXCEPTION); | |
65 document().body()->appendChild(div); | |
66 | |
67 EXPECT_TRUE(nullVisiblePosition.isValid()); | |
68 EXPECT_FALSE(nonNullVisiblePosition.isValid()); | |
69 } | |
70 | |
71 #endif | |
yosin_UTC9
2016/09/20 13:55:51
Let's check "display" property change.
Not sure ab
Xiaocheng
2016/09/21 06:31:49
Done.
| |
72 | |
39 } // namespace blink | 73 } // namespace blink |
OLD | NEW |