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

Unified Diff: third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp

Issue 2200833007: Change return value of FrameSelection::modify() to prevent unnecessary window scrolling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-08-05T13:02:14 Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/editing/FrameSelection.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp
diff --git a/third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp b/third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp
index c4473e3b63d7bb1d1820d0663113dfb84a3fccc2..1659362fa901a5366159e58a869e5b1d9e984f8b 100644
--- a/third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp
+++ b/third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp
@@ -178,6 +178,24 @@ TEST_F(FrameSelectionTest, ModifyExtendWithFlatTree)
EXPECT_EQ(PositionInFlatTree(two, 3), visibleSelectionInFlatTree().end());
}
+TEST_F(FrameSelectionTest, ModifyWithUserTriggered)
+{
+ setBodyContent("<div id=sample>abc</div>");
+ Element* sample = document().getElementById("sample");
+ const Position endOfText(sample->firstChild(), 3);
+ selection().setSelection(VisibleSelection(endOfText));
+
+ EXPECT_FALSE(selection().modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity, NotUserTriggered))
+ << "Selection.modify() returns false for non-user-triggered call when selection isn't modified.";
+ EXPECT_EQ(endOfText, selection().start())
+ << "Selection isn't modified";
+
+ EXPECT_TRUE(selection().modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity, UserTriggered))
+ << "Selection.modify() returns true for user-triggered call";
+ EXPECT_EQ(endOfText, selection().start())
+ << "Selection isn't modified";
+}
+
TEST_F(FrameSelectionTest, MoveRangeSelectionTest)
{
// "Foo Bar Baz,"
« no previous file with comments | « third_party/WebKit/Source/core/editing/FrameSelection.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698