| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "config.h" | 5 #include "config.h" |
| 6 #include "core/editing/FrameSelection.h" | 6 #include "core/editing/FrameSelection.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 8 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
| 10 #include "core/dom/Element.h" | 10 #include "core/dom/Element.h" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 // "Foo| Bar Baz," | 160 // "Foo| Bar Baz," |
| 161 EXPECT_TRUE(selection().selectWordAroundPosition(VisiblePosition(Position(te
xt, 3)))); | 161 EXPECT_TRUE(selection().selectWordAroundPosition(VisiblePosition(Position(te
xt, 3)))); |
| 162 EXPECT_EQ_SELECTED_TEXT("Foo"); | 162 EXPECT_EQ_SELECTED_TEXT("Foo"); |
| 163 // "Foo Bar | Baz," | 163 // "Foo Bar | Baz," |
| 164 EXPECT_FALSE(selection().selectWordAroundPosition(VisiblePosition(Position(t
ext, 13)))); | 164 EXPECT_FALSE(selection().selectWordAroundPosition(VisiblePosition(Position(t
ext, 13)))); |
| 165 // "Foo Bar Baz|," | 165 // "Foo Bar Baz|," |
| 166 EXPECT_TRUE(selection().selectWordAroundPosition(VisiblePosition(Position(te
xt, 22)))); | 166 EXPECT_TRUE(selection().selectWordAroundPosition(VisiblePosition(Position(te
xt, 22)))); |
| 167 EXPECT_EQ_SELECTED_TEXT("Baz"); | 167 EXPECT_EQ_SELECTED_TEXT("Baz"); |
| 168 } | 168 } |
| 169 | 169 |
| 170 /* |
| 170 // Test for MoveRangeSelectionExtent with the default CharacterGranularityStrate
gy | 171 // Test for MoveRangeSelectionExtent with the default CharacterGranularityStrate
gy |
| 171 TEST_F(FrameSelectionTest, MoveRangeSelectionExtentCharacter) | 172 TEST_F(FrameSelectionTest, MoveRangeSelectionExtentCharacter) |
| 172 { | 173 { |
| 173 // "Foo Bar Baz," | 174 // "Foo Bar Baz," |
| 174 RefPtrWillBeRawPtr<Text> text = appendTextNode("Foo Bar Baz,"); | 175 RefPtrWillBeRawPtr<Text> text = appendTextNode("Foo Bar Baz,"); |
| 175 // "Foo B|a>r Baz," (| means start and > means end). | 176 // "Foo B|a>r Baz," (| means start and > means end). |
| 176 selection().setSelection(VisibleSelection(Position(text, 5), Position(text,
6))); | 177 selection().setSelection(VisibleSelection(Position(text, 5), Position(text,
6))); |
| 177 EXPECT_EQ_SELECTED_TEXT("a"); | 178 EXPECT_EQ_SELECTED_TEXT("a"); |
| 178 // "Foo B|ar B>az," with the Character granularity. | 179 // "Foo B|ar B>az," with the Character granularity. |
| 179 selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 1))); | 180 selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 1))); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 // "abcdef |ghij> kl mnopqr stuvwx yzab," | 295 // "abcdef |ghij> kl mnopqr stuvwx yzab," |
| 295 selection().setSelection(VisibleSelection(Position(text, 7), Position(text,
11))); | 296 selection().setSelection(VisibleSelection(Position(text, 7), Position(text,
11))); |
| 296 EXPECT_EQ_SELECTED_TEXT("ghij"); | 297 EXPECT_EQ_SELECTED_TEXT("ghij"); |
| 297 // "abcdef< |ghij kl mnopqr stuvwx yzab," | 298 // "abcdef< |ghij kl mnopqr stuvwx yzab," |
| 298 selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 6))); | 299 selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 6))); |
| 299 EXPECT_EQ_SELECTED_TEXT(" "); | 300 EXPECT_EQ_SELECTED_TEXT(" "); |
| 300 // "abcde<f |ghij kl mnopqr stuvwx yzab," | 301 // "abcde<f |ghij kl mnopqr stuvwx yzab," |
| 301 selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 5))); | 302 selection().moveRangeSelectionExtent(VisiblePosition(Position(text, 5))); |
| 302 EXPECT_EQ_SELECTED_TEXT("abcdef "); | 303 EXPECT_EQ_SELECTED_TEXT("abcdef "); |
| 303 } | 304 } |
| 305 */ |
| 304 | 306 |
| 305 TEST_F(FrameSelectionTest, MoveRangeSelectionTest) | 307 TEST_F(FrameSelectionTest, MoveRangeSelectionTest) |
| 306 { | 308 { |
| 307 // "Foo Bar Baz," | 309 // "Foo Bar Baz," |
| 308 RefPtrWillBeRawPtr<Text> text = appendTextNode("Foo Bar Baz,"); | 310 RefPtrWillBeRawPtr<Text> text = appendTextNode("Foo Bar Baz,"); |
| 309 // Itinitializes with "Foo B|a>r Baz," (| means start and > means end). | 311 // Itinitializes with "Foo B|a>r Baz," (| means start and > means end). |
| 310 selection().setSelection(VisibleSelection(Position(text, 5), Position(text,
6))); | 312 selection().setSelection(VisibleSelection(Position(text, 5), Position(text,
6))); |
| 311 EXPECT_EQ_SELECTED_TEXT("a"); | 313 EXPECT_EQ_SELECTED_TEXT("a"); |
| 312 | 314 |
| 313 // "Foo B|ar B>az," with the Character granularity. | 315 // "Foo B|ar B>az," with the Character granularity. |
| 314 selection().moveRangeSelection(VisiblePosition(Position(text, 5)), VisiblePo
sition(Position(text, 9)), CharacterGranularity); | 316 selection().moveRangeSelection(VisiblePosition(Position(text, 5)), VisiblePo
sition(Position(text, 9)), CharacterGranularity); |
| 315 EXPECT_EQ_SELECTED_TEXT("ar B"); | 317 EXPECT_EQ_SELECTED_TEXT("ar B"); |
| 316 // "Foo B|ar B>az," with the Word granularity. | 318 // "Foo B|ar B>az," with the Word granularity. |
| 317 selection().moveRangeSelection(VisiblePosition(Position(text, 5)), VisiblePo
sition(Position(text, 9)), WordGranularity); | 319 selection().moveRangeSelection(VisiblePosition(Position(text, 5)), VisiblePo
sition(Position(text, 9)), WordGranularity); |
| 318 EXPECT_EQ_SELECTED_TEXT("Bar Baz"); | 320 EXPECT_EQ_SELECTED_TEXT("Bar Baz"); |
| 319 // "Fo<o B|ar Baz," with the Character granularity. | 321 // "Fo<o B|ar Baz," with the Character granularity. |
| 320 selection().moveRangeSelection(VisiblePosition(Position(text, 5)), VisiblePo
sition(Position(text, 2)), CharacterGranularity); | 322 selection().moveRangeSelection(VisiblePosition(Position(text, 5)), VisiblePo
sition(Position(text, 2)), CharacterGranularity); |
| 321 EXPECT_EQ_SELECTED_TEXT("o B"); | 323 EXPECT_EQ_SELECTED_TEXT("o B"); |
| 322 // "Fo<o B|ar Baz," with the Word granularity. | 324 // "Fo<o B|ar Baz," with the Word granularity. |
| 323 selection().moveRangeSelection(VisiblePosition(Position(text, 5)), VisiblePo
sition(Position(text, 2)), WordGranularity); | 325 selection().moveRangeSelection(VisiblePosition(Position(text, 5)), VisiblePo
sition(Position(text, 2)), WordGranularity); |
| 324 EXPECT_EQ_SELECTED_TEXT("Foo Bar"); | 326 EXPECT_EQ_SELECTED_TEXT("Foo Bar"); |
| 325 } | 327 } |
| 326 } | 328 } |
| OLD | NEW |