| 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" |
| 11 #include "core/dom/Text.h" | 11 #include "core/dom/Text.h" |
| 12 #include "core/frame/FrameView.h" | 12 #include "core/frame/FrameView.h" |
| 13 #include "core/html/HTMLBodyElement.h" | 13 #include "core/html/HTMLBodyElement.h" |
| 14 #include "core/html/HTMLDocument.h" | 14 #include "core/html/HTMLDocument.h" |
| 15 #include "core/testing/DummyPageHolder.h" | 15 #include "core/testing/DummyPageHolder.h" |
| 16 #include "wtf/OwnPtr.h" | 16 #include "wtf/OwnPtr.h" |
| 17 #include "wtf/PassRefPtr.h" | 17 #include "wtf/PassRefPtr.h" |
| 18 #include "wtf/RefPtr.h" | 18 #include "wtf/RefPtr.h" |
| 19 #include "wtf/StdLibExtras.h" | 19 #include "wtf/StdLibExtras.h" |
| 20 #include "wtf/testing/WTFTestHelpers.h" | 20 #include "wtf/testing/WTFTestHelpers.h" |
| 21 #include <gtest/gtest.h> | 21 #include <gtest/gtest.h> |
| 22 | 22 |
| 23 using namespace blink; | 23 namespace blink { |
| 24 | |
| 25 namespace { | |
| 26 | 24 |
| 27 class FrameSelectionTest : public ::testing::Test { | 25 class FrameSelectionTest : public ::testing::Test { |
| 28 protected: | 26 protected: |
| 29 virtual void SetUp() override; | 27 void SetUp() override; |
| 30 | 28 |
| 31 DummyPageHolder& dummyPageHolder() const { return *m_dummyPageHolder; } | 29 DummyPageHolder& dummyPageHolder() const { return *m_dummyPageHolder; } |
| 32 HTMLDocument& document() const; | 30 HTMLDocument& document() const; |
| 33 void setSelection(const VisibleSelection&); | 31 void setSelection(const VisibleSelection&); |
| 34 FrameSelection& selection() const; | 32 FrameSelection& selection() const; |
| 35 PassRefPtrWillBeRawPtr<Text> appendTextNode(const String& data); | 33 PassRefPtrWillBeRawPtr<Text> appendTextNode(const String& data); |
| 36 int layoutCount() const { return m_dummyPageHolder->frameView().layoutCount(
); } | 34 int layoutCount() const { return m_dummyPageHolder->frameView().layoutCount(
); } |
| 37 | 35 |
| 38 private: | 36 private: |
| 39 OwnPtr<DummyPageHolder> m_dummyPageHolder; | 37 OwnPtr<DummyPageHolder> m_dummyPageHolder; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 // "Foo B|ar B>az," with the Word granularity. | 178 // "Foo B|ar B>az," with the Word granularity. |
| 181 selection().moveRangeSelection(VisiblePosition(Position(text, 5)), VisiblePo
sition(Position(text, 9)), WordGranularity); | 179 selection().moveRangeSelection(VisiblePosition(Position(text, 5)), VisiblePo
sition(Position(text, 9)), WordGranularity); |
| 182 EXPECT_EQ_SELECTED_TEXT("Bar Baz"); | 180 EXPECT_EQ_SELECTED_TEXT("Bar Baz"); |
| 183 // "Fo<o B|ar Baz," with the Character granularity. | 181 // "Fo<o B|ar Baz," with the Character granularity. |
| 184 selection().moveRangeSelection(VisiblePosition(Position(text, 5)), VisiblePo
sition(Position(text, 2)), CharacterGranularity); | 182 selection().moveRangeSelection(VisiblePosition(Position(text, 5)), VisiblePo
sition(Position(text, 2)), CharacterGranularity); |
| 185 EXPECT_EQ_SELECTED_TEXT("o B"); | 183 EXPECT_EQ_SELECTED_TEXT("o B"); |
| 186 // "Fo<o B|ar Baz," with the Word granularity. | 184 // "Fo<o B|ar Baz," with the Word granularity. |
| 187 selection().moveRangeSelection(VisiblePosition(Position(text, 5)), VisiblePo
sition(Position(text, 2)), WordGranularity); | 185 selection().moveRangeSelection(VisiblePosition(Position(text, 5)), VisiblePo
sition(Position(text, 2)), WordGranularity); |
| 188 EXPECT_EQ_SELECTED_TEXT("Foo Bar"); | 186 EXPECT_EQ_SELECTED_TEXT("Foo Bar"); |
| 189 } | 187 } |
| 190 } | 188 |
| 189 } // namespace blink |
| OLD | NEW |