| 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 "core/editing/SurroundingText.h" | 5 #include "core/editing/SurroundingText.h" |
| 6 | 6 |
| 7 #include <memory> |
| 7 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 8 #include "core/dom/Range.h" | 9 #include "core/dom/Range.h" |
| 9 #include "core/dom/Text.h" | 10 #include "core/dom/Text.h" |
| 10 #include "core/editing/Position.h" | 11 #include "core/editing/Position.h" |
| 11 #include "core/editing/VisibleSelection.h" | 12 #include "core/editing/VisibleSelection.h" |
| 12 #include "core/html/HTMLElement.h" | 13 #include "core/html/HTMLElement.h" |
| 13 #include "core/testing/DummyPageHolder.h" | 14 #include "core/testing/DummyPageHolder.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include <memory> | |
| 16 | 16 |
| 17 namespace blink { | 17 namespace blink { |
| 18 | 18 |
| 19 class SurroundingTextTest : public ::testing::Test { | 19 class SurroundingTextTest : public ::testing::Test { |
| 20 protected: | 20 protected: |
| 21 Document& document() const { return m_dummyPageHolder->document(); } | 21 Document& document() const { return m_dummyPageHolder->document(); } |
| 22 void setHTML(const String&); | 22 void setHTML(const String&); |
| 23 VisibleSelection select(int offset) { return select(offset, offset); } | 23 VisibleSelection select(int offset) { return select(offset, offset); } |
| 24 VisibleSelection select(int start, int end); | 24 VisibleSelection select(int start, int end); |
| 25 | 25 |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 SurroundingText surroundingText(*firstRangeOf(selection), 1337); | 259 SurroundingText surroundingText(*firstRangeOf(selection), 1337); |
| 260 | 260 |
| 261 EXPECT_EQ("This is outside of foo bar the selected node", | 261 EXPECT_EQ("This is outside of foo bar the selected node", |
| 262 surroundingText.content().simplifyWhiteSpace()); | 262 surroundingText.content().simplifyWhiteSpace()); |
| 263 EXPECT_EQ(20u, surroundingText.startOffsetInContent()); | 263 EXPECT_EQ(20u, surroundingText.startOffsetInContent()); |
| 264 EXPECT_EQ(27u, surroundingText.endOffsetInContent()); | 264 EXPECT_EQ(27u, surroundingText.endOffsetInContent()); |
| 265 } | 265 } |
| 266 } | 266 } |
| 267 | 267 |
| 268 } // namespace blink | 268 } // namespace blink |
| OLD | NEW |