Chromium Code Reviews| Index: Source/core/editing/FrameSelectionTest.cpp |
| diff --git a/Source/core/editing/FrameSelectionTest.cpp b/Source/core/editing/FrameSelectionTest.cpp |
| index 54bd4d02d634b461740cfc14f3c24cd45c981891..9f2d071c36fe5a843bd101209038b35ca428f4dc 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" |
| @@ -34,6 +33,7 @@ protected: |
| void setSelection(const VisibleSelection&); |
| FrameSelection& selection() const; |
| PassRefPtrWillBeRawPtr<Text> appendTextNode(const String& data); |
| + void setInnerHTML(const char*); |
| int layoutCount() const { return m_dummyPageHolder->frameView().layoutCount(); } |
| private: |
| @@ -122,6 +122,7 @@ TEST_F(FrameSelectionTest, InvalidateCaretRect) |
| TEST_F(FrameSelectionTest, PaintCaretShouldNotLayout) |
| { |
| RefPtrWillBeRawPtr<Text> text = appendTextNode("Hello, World!"); |
| + // TODO: Do I need this? |
|
leviw_travelin_and_unemployed
2015/06/03 22:29:47
It'd be apparent quickly (at least on Debug) if yo
mfomitchev
2015/06/05 17:38:39
Sorry, this was a reminder for myself to check som
|
| document().view()->updateLayoutAndStyleForPainting(); |
| document().body()->setContentEditable("true", ASSERT_NO_EXCEPTION); |
| @@ -167,141 +168,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," |