Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: third_party/WebKit/Source/core/editing/VisibleUnitsTest.cpp

Issue 2126743002: Make previousPositionOf() to handle yet another no previous position case (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-07-06T16:42:17 Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/editing/VisibleUnits.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/VisibleUnits.h" 5 #include "core/editing/VisibleUnits.h"
6 6
7 #include "core/dom/Text.h" 7 #include "core/dom/Text.h"
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 #include "core/html/HTMLTextFormControlElement.h" 10 #include "core/html/HTMLTextFormControlElement.h"
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 1041
1042 // In case of each line has one character, VisiblePosition are: 1042 // In case of each line has one character, VisiblePosition are:
1043 // [C,Dn] [C,Up] [B, Dn] [B, Up] 1043 // [C,Dn] [C,Up] [B, Dn] [B, Up]
1044 // A A A A| 1044 // A A A A|
1045 // B B| |B B 1045 // B B| |B B
1046 // |C C C C 1046 // |C C C C
1047 EXPECT_EQ(PositionWithAffinity(Position(sample, 1)), previousPositionOf(crea teVisiblePosition(Position(sample, 2))).toPositionWithAffinity()); 1047 EXPECT_EQ(PositionWithAffinity(Position(sample, 1)), previousPositionOf(crea teVisiblePosition(Position(sample, 2))).toPositionWithAffinity());
1048 EXPECT_EQ(PositionWithAffinity(Position(sample, 1)), previousPositionOf(crea teVisiblePosition(Position(sample, 2), TextAffinity::Upstream)).toPositionWithAf finity()); 1048 EXPECT_EQ(PositionWithAffinity(Position(sample, 1)), previousPositionOf(crea teVisiblePosition(Position(sample, 2), TextAffinity::Upstream)).toPositionWithAf finity());
1049 } 1049 }
1050 1050
1051 TEST_F(VisibleUnitsTest, previousPositionOfNoPreviousPosition)
1052 {
1053 setBodyContent(
1054 "<span contenteditable='true'>"
1055 "<span> </span>"
1056 " " // This whitespace causes no previous position.
1057 "<div id='anchor'> bar</div>"
1058 "</span>");
1059 const Position position(document().getElementById("anchor")->firstChild(), 1 );
1060 EXPECT_EQ(Position(), previousPositionOf(createVisiblePosition(position)).de epEquivalent());
1061 }
1062
1051 TEST_F(VisibleUnitsTest, rendersInDifferentPositionAfterAnchor) 1063 TEST_F(VisibleUnitsTest, rendersInDifferentPositionAfterAnchor)
1052 { 1064 {
1053 const char* bodyContent = "<p id='sample'>00</p>"; 1065 const char* bodyContent = "<p id='sample'>00</p>";
1054 setBodyContent(bodyContent); 1066 setBodyContent(bodyContent);
1055 Element* sample = document().getElementById("sample"); 1067 Element* sample = document().getElementById("sample");
1056 1068
1057 EXPECT_FALSE(rendersInDifferentPosition(Position(), Position())); 1069 EXPECT_FALSE(rendersInDifferentPosition(Position(), Position()));
1058 EXPECT_FALSE(rendersInDifferentPosition(Position(), Position::afterNode(samp le))) 1070 EXPECT_FALSE(rendersInDifferentPosition(Position(), Position::afterNode(samp le)))
1059 << "if one of position is null, the reuslt is false."; 1071 << "if one of position is null, the reuslt is false.";
1060 EXPECT_FALSE(rendersInDifferentPosition(Position::afterNode(sample), Positio n(sample, 1))); 1072 EXPECT_FALSE(rendersInDifferentPosition(Position::afterNode(sample), Positio n(sample, 1)));
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1303 { 1315 {
1304 // Repro case of crbug.com/584030 1316 // Repro case of crbug.com/584030
1305 const char* bodyContent = "<button><rt><script>document.designMode = 'on'</s cript></rt></button>"; 1317 const char* bodyContent = "<button><rt><script>document.designMode = 'on'</s cript></rt></button>";
1306 setBodyContent(bodyContent); 1318 setBodyContent(bodyContent);
1307 1319
1308 Node* button = document().querySelector("button", ASSERT_NO_EXCEPTION); 1320 Node* button = document().querySelector("button", ASSERT_NO_EXCEPTION);
1309 EXPECT_TRUE(endsOfNodeAreVisuallyDistinctPositions(button)); 1321 EXPECT_TRUE(endsOfNodeAreVisuallyDistinctPositions(button));
1310 } 1322 }
1311 1323
1312 } // namespace blink 1324 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/VisibleUnits.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698