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

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

Issue 1123563003: Improving direction-based selection strategy. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Removing anonymous namespace and marking functions static instead. Created 5 years, 6 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 | « Source/core/editing/FrameSelection.cpp ('k') | Source/core/editing/GranularityStrategy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/FrameSelectionTest.cpp
diff --git a/Source/core/editing/FrameSelectionTest.cpp b/Source/core/editing/FrameSelectionTest.cpp
index 54bd4d02d634b461740cfc14f3c24cd45c981891..d6bbfb0dc58cc1566cbb188a5674e55f24339094 100644
--- a/Source/core/editing/FrameSelectionTest.cpp
+++ b/Source/core/editing/FrameSelectionTest.cpp
@@ -10,7 +10,6 @@
#include "core/dom/Element.h"
#include "core/dom/Text.h"
#include "core/frame/FrameView.h"
-#include "core/frame/Settings.h"
#include "core/html/HTMLBodyElement.h"
#include "core/html/HTMLDocument.h"
#include "core/testing/DummyPageHolder.h"
@@ -167,141 +166,6 @@ TEST_F(FrameSelectionTest, SelectWordAroundPosition)
EXPECT_EQ_SELECTED_TEXT("Baz");
}
-// Test for MoveRangeSelectionExtent with the default CharacterGranularityStrategy
-TEST_F(FrameSelectionTest, MoveRangeSelectionExtentCharacter)
-{
- // "Foo Bar Baz,"
- RefPtrWillBeRawPtr<Text> text = appendTextNode("Foo Bar Baz,");
- // "Foo B|a>r Baz," (| means start and > means end).
- selection().setSelection(VisibleSelection(Position(text, 5), Position(text, 6)));
- EXPECT_EQ_SELECTED_TEXT("a");
- // "Foo B|ar B>az," with the Character granularity.
- selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 1)));
- EXPECT_EQ_SELECTED_TEXT("oo B");
-}
-
-// Test for MoveRangeSelectionExtent with DirectionGranularityStrategy
-TEST_F(FrameSelectionTest, MoveRangeSelectionExtentDirection)
-{
- RefPtrWillBeRawPtr<Text> text = document().createTextNode("abcdef ghij kl mnopqr stuvwx yzab,");
- document().body()->appendChild(text);
- dummyPageHolder().frame().settings()->setSelectionStrategy(SelectionStrategy::Direction);
-
- // "abcdef ghij kl mno|p>qr stuvwx yzab," (| means start and > means end).
- selection().setSelection(VisibleSelection(Position(text, 18), Position(text, 19)));
- EXPECT_EQ_SELECTED_TEXT("p");
- // "abcdef ghij kl mno|pq>r stuvwx yzab," - expand selection using character granularity
- // until the end of the word is reached.
- selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 20)));
- EXPECT_EQ_SELECTED_TEXT("pq");
- // "abcdef ghij kl mno|pqr> stuvwx yzab,"
- selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 21)));
- EXPECT_EQ_SELECTED_TEXT("pqr");
- // "abcdef ghij kl mno|pqr >stuvwx yzab," - confirm selection doesn't
- // jump over the beginning of the word.
- selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 22)));
- EXPECT_EQ_SELECTED_TEXT("pqr ");
- // "abcdef ghij kl mno|pqr s>tuvwx yzab," - confirm selection switches to word granularity.
- selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 23)));
- EXPECT_EQ_SELECTED_TEXT("pqr stuvwx");
- // "abcdef ghij kl mno|pqr stu>vwx yzab," - selection stays the same.
- selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 25)));
- EXPECT_EQ_SELECTED_TEXT("pqr stuvwx");
- // "abcdef ghij kl mno|pqr stuvwx yz>ab," - next word.
- selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 31)));
- EXPECT_EQ_SELECTED_TEXT("pqr stuvwx yzab");
- // "abcdef ghij kl mno|pqr stuvwx y>zab," - move back one character -
- // confirm switch to character granularity.
- selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 30)));
- EXPECT_EQ_SELECTED_TEXT("pqr stuvwx y");
- // "abcdef ghij kl mno|pqr stuvwx yz>ab," - stay in character granularity
- // if the user moves the position within the word.
- selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 31)));
- EXPECT_EQ_SELECTED_TEXT("pqr stuvwx yz");
- // "abcdef ghij kl mno|pqr stuvwx >yzab,"
- selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 29)));
- EXPECT_EQ_SELECTED_TEXT("pqr stuvwx ");
- // "abcdef ghij kl mno|pqr stuvwx >yzab," - it's possible to get a move when
- // position doesn't change. It shouldn't affect anything.
- selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 29)));
- EXPECT_EQ_SELECTED_TEXT("pqr stuvwx ");
- // "abcdef ghij kl mno|pqr stuvwx y>zab,"
- selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 30)));
- EXPECT_EQ_SELECTED_TEXT("pqr stuvwx y");
- // "abcdef ghij kl mno|pqr stuv>wx yzab,"
- selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 26)));
- EXPECT_EQ_SELECTED_TEXT("pqr stuv");
- // "abcdef ghij kl mno|pqr stuvw>x yzab,"
- selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 27)));
- EXPECT_EQ_SELECTED_TEXT("pqr stuvw");
- // "abcdef ghij kl mno|pqr stuvwx y>zab," - switch to word granularity
- // after expanding beyond the word boundary
- selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 30)));
- EXPECT_EQ_SELECTED_TEXT("pqr stuvwx yzab");
- // "abcdef ghij kl mn<o|pqr stuvwx yzab," - over to the other side of the base
- // - stay in character granularity until the beginning of the word is passed.
- selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 17)));
- EXPECT_EQ_SELECTED_TEXT("o");
- // "abcdef ghij kl m<no|pqr stuvwx yzab,"
- selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 16)));
- EXPECT_EQ_SELECTED_TEXT("no");
- // "abcdef ghij kl <mno|pqr stuvwx yzab,"
- selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 15)));
- EXPECT_EQ_SELECTED_TEXT("mno");
- // "abcdef ghij kl mn<o|pqr stuvwx yzab,"
- selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 17)));
- EXPECT_EQ_SELECTED_TEXT("o");
- // "abcdef ghij k<l mno|pqr stuvwx yzab," - switch to word granularity
- selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 13)));
- EXPECT_EQ_SELECTED_TEXT("kl mno");
- // "abcd<ef ghij kl mno|pqr stuvwx yzab,"
- selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 4)));
- EXPECT_EQ_SELECTED_TEXT("abcdef ghij kl mno");
- // "abcde<f ghij kl mno|pqr stuvwx yzab," - decrease selection -
- // switch back to character granularity.
- selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 5)));
- EXPECT_EQ_SELECTED_TEXT("f ghij kl mno");
- // "abcdef ghij kl mn<o|pqr stuvwx yzab,"
- selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 17)));
- EXPECT_EQ_SELECTED_TEXT("o");
- // "abcdef ghij kl m<no|pqr stuvwx yzab,"
- selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 16)));
- EXPECT_EQ_SELECTED_TEXT("no");
- // "abcdef ghij k<l mno|pqr stuvwx yzab,"
- selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 13)));
- EXPECT_EQ_SELECTED_TEXT("kl mno");
-
- // Make sure we switch to word granularity right away when starting on a
- // word boundary and extending.
- // "abcdef ghij kl |mnopqr >stuvwx yzab," (| means start and > means end).
- selection().setSelection(VisibleSelection(Position(text, 15), Position(text, 22)));
- EXPECT_EQ_SELECTED_TEXT("mnopqr ");
- // "abcdef ghij kl |mnopqr s>tuvwx yzab,"
- selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 23)));
- EXPECT_EQ_SELECTED_TEXT("mnopqr stuvwx");
-
- // Make sure we start in character granularity when moving extent over to the other
- // side of the base.
- // "abcdef| ghij> kl mnopqr stuvwx yzab," (| means start and > means end).
- selection().setSelection(VisibleSelection(Position(text, 6), Position(text, 11)));
- EXPECT_EQ_SELECTED_TEXT(" ghij");
- // "abcde<f| ghij kl mnopqr stuvwx yzab,"
- selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 5)));
- EXPECT_EQ_SELECTED_TEXT("f");
-
- // Make sure we switch to word granularity when moving over to the other
- // side of the base and then passing over the word boundary.
- // "abcdef |ghij> kl mnopqr stuvwx yzab,"
- selection().setSelection(VisibleSelection(Position(text, 7), Position(text, 11)));
- EXPECT_EQ_SELECTED_TEXT("ghij");
- // "abcdef< |ghij kl mnopqr stuvwx yzab,"
- selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 6)));
- EXPECT_EQ_SELECTED_TEXT(" ");
- // "abcde<f |ghij kl mnopqr stuvwx yzab,"
- selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 5)));
- EXPECT_EQ_SELECTED_TEXT("abcdef ");
-}
-
TEST_F(FrameSelectionTest, MoveRangeSelectionTest)
{
// "Foo Bar Baz,"
« no previous file with comments | « Source/core/editing/FrameSelection.cpp ('k') | Source/core/editing/GranularityStrategy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698