Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Unified Diff: third_party/WebKit/Source/core/editing/SurroundingTextTest.cpp

Issue 2907963002: [Smart Text] Make SurroundingText work for input elements (Closed)
Patch Set: Added test Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/editing/SurroundingTextTest.cpp
diff --git a/third_party/WebKit/Source/core/editing/SurroundingTextTest.cpp b/third_party/WebKit/Source/core/editing/SurroundingTextTest.cpp
index acb6dfce1e28e4d368833cf0285fb1618bbfaf80..6742cf730ddc00438c1023a6652fcf5d4d4970f7 100644
--- a/third_party/WebKit/Source/core/editing/SurroundingTextTest.cpp
+++ b/third_party/WebKit/Source/core/editing/SurroundingTextTest.cpp
@@ -4,15 +4,16 @@
#include "core/editing/SurroundingText.h"
+#include <memory>
#include "core/dom/Document.h"
#include "core/dom/Range.h"
#include "core/dom/Text.h"
#include "core/editing/Position.h"
#include "core/editing/VisibleSelection.h"
#include "core/html/HTMLElement.h"
+#include "core/html/TextControlElement.h"
#include "core/testing/DummyPageHolder.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include <memory>
namespace blink {
@@ -276,4 +277,21 @@ TEST_F(SurroundingTextTest, TreeRangeSelection) {
}
}
+TEST_F(SurroundingTextTest, TextAreaSelection) {
+ SetHTML(String("<textarea id='selection'>abc def ghi</textarea>"));
+
+ TextControlElement* text_ctrl =
+ (TextControlElement*)GetDocument().getElementById("selection");
+
+ text_ctrl->SetSelectionRange(4, 7);
+ VisibleSelection selection = CreateVisibleSelection(text_ctrl->Selection());
+
+ SurroundingText surrounding_text(
+ *CreateRange(FirstEphemeralRangeOf(selection)), 10);
+
+ EXPECT_EQ("abc def ghi", surrounding_text.Content().SimplifyWhiteSpace());
+ EXPECT_EQ(4u, surrounding_text.StartOffsetInContent());
+ EXPECT_EQ(7u, surrounding_text.EndOffsetInContent());
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698