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/SurroundingText.h" | 6 #include "core/editing/SurroundingText.h" |
7 | 7 |
8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
9 #include "core/dom/Position.h" | 9 #include "core/dom/Position.h" |
10 #include "core/dom/Range.h" | 10 #include "core/dom/Range.h" |
11 #include "core/dom/Text.h" | 11 #include "core/dom/Text.h" |
12 #include "core/editing/VisibleSelection.h" | 12 #include "core/editing/VisibleSelection.h" |
13 #include "core/html/HTMLElement.h" | 13 #include "core/html/HTMLElement.h" |
14 #include "core/testing/DummyPageHolder.h" | 14 #include "core/testing/DummyPageHolder.h" |
15 #include <gtest/gtest.h> | 15 #include <gtest/gtest.h> |
16 | 16 |
17 using namespace blink; | 17 using namespace blink; |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 class SurroundingTextTest : public ::testing::Test { | 21 class SurroundingTextTest : public ::testing::Test { |
22 protected: | 22 protected: |
23 Document& document() const { return m_dummyPageHolder->document(); } | 23 Document& document() const { return m_dummyPageHolder->document(); } |
24 void setHTML(const String&); | 24 void setHTML(const String&); |
25 VisibleSelection select(int offset) { return select(offset, offset); } | 25 VisibleSelection select(int offset) { return select(offset, offset); } |
26 VisibleSelection select(int start, int end); | 26 VisibleSelection select(int start, int end); |
27 | 27 |
28 private: | 28 private: |
29 virtual void SetUp() OVERRIDE; | 29 virtual void SetUp() override; |
30 | 30 |
31 OwnPtr<DummyPageHolder> m_dummyPageHolder; | 31 OwnPtr<DummyPageHolder> m_dummyPageHolder; |
32 }; | 32 }; |
33 | 33 |
34 void SurroundingTextTest::SetUp() | 34 void SurroundingTextTest::SetUp() |
35 { | 35 { |
36 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600)); | 36 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600)); |
37 } | 37 } |
38 | 38 |
39 void SurroundingTextTest::setHTML(const String& content) | 39 void SurroundingTextTest::setHTML(const String& content) |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 VisibleSelection selection = select(0, 7); | 256 VisibleSelection selection = select(0, 7); |
257 SurroundingText surroundingText(*selection.firstRange(), 1337); | 257 SurroundingText surroundingText(*selection.firstRange(), 1337); |
258 | 258 |
259 EXPECT_EQ("This is outside of foo bar the selected node", surroundingTex
t.content().simplifyWhiteSpace()); | 259 EXPECT_EQ("This is outside of foo bar the selected node", surroundingTex
t.content().simplifyWhiteSpace()); |
260 EXPECT_EQ(20u, surroundingText.startOffsetInContent()); | 260 EXPECT_EQ(20u, surroundingText.startOffsetInContent()); |
261 EXPECT_EQ(27u, surroundingText.endOffsetInContent()); | 261 EXPECT_EQ(27u, surroundingText.endOffsetInContent()); |
262 } | 262 } |
263 } | 263 } |
264 | 264 |
265 } // anonymous namespace | 265 } // anonymous namespace |
OLD | NEW |