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

Unified Diff: third_party/WebKit/Source/web/WebInputElementTest.cpp

Issue 2174303002: Move filtering logic in GetDataListSuggestions() to Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « third_party/WebKit/Source/web/WebInputElement.cpp ('k') | third_party/WebKit/Source/web/web.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/web/WebInputElementTest.cpp
diff --git a/third_party/WebKit/Source/web/WebInputElementTest.cpp b/third_party/WebKit/Source/web/WebInputElementTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5becf75e495a97dabe6b7e9d1d46bfe2c07c5c11
--- /dev/null
+++ b/third_party/WebKit/Source/web/WebInputElementTest.cpp
@@ -0,0 +1,70 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "public/web/WebInputElement.h"
+
+#include "core/html/HTMLInputElement.h"
+#include "core/testing/DummyPageHolder.h"
+#include "public/web/WebOptionElement.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace blink {
+
+class WebInputElementTest : public testing::Test {
+protected:
+ Document& document() { return m_pageHolder->document(); }
+ WebInputElement testElement()
+ {
+ Element* element = document().getElementById("test");
+ DCHECK(element);
+ return WebInputElement(toHTMLInputElement(element));
+ }
+
+private:
+ void SetUp() override
+ {
+ m_pageHolder = DummyPageHolder::create(IntSize(800, 600));
+ }
+
+ std::unique_ptr<DummyPageHolder> m_pageHolder;
vabr (Chromium) 2016/07/25 13:59:53 nit: #include <memory> for the unique_ptr?
+};
+
+TEST_F(WebInputElementTest, FilteredDataListOptionsNoList)
+{
+ document().documentElement()->setInnerHTML("<input id=test>", ASSERT_NO_EXCEPTION);
+ EXPECT_TRUE(testElement().filteredDataListOptions().isEmpty());
+
+ document().documentElement()->setInnerHTML("<input id=test list=dl1><datalist id=dl1></datalist>", ASSERT_NO_EXCEPTION);
+ EXPECT_TRUE(testElement().filteredDataListOptions().isEmpty());
+}
+
+TEST_F(WebInputElementTest, FilteredDataListOptionsPrefixed)
+{
+ document().documentElement()->setInnerHTML(
+ "<input id=test value=ABC list=dl2>"
+ "<datalist id=dl2>"
+ "<option>AbC DEF</option>"
+ "<option>VAX</option>"
+ "<option value=ghi>abc</option>"
+ "</datalist>", ASSERT_NO_EXCEPTION);
+ auto options = testElement().filteredDataListOptions();
+ EXPECT_EQ(1u, options.size());
+ EXPECT_EQ("AbC DEF", options[0].value().utf8());
+}
+
+TEST_F(WebInputElementTest, FilteredDataListOptionsForMultipleEmail)
+{
+ document().documentElement()->setInnerHTML(
+ "<input id=test value='foo@example.com, tkent' list=dl3 type=email multiple>"
+ "<datalist id=dl3>"
+ "<option>keishi@chromium.org</option>"
+ "<option>tkent@chromium.org</option>"
+ "</datalist>", ASSERT_NO_EXCEPTION);
+ auto options = testElement().filteredDataListOptions();
+ EXPECT_EQ(1u, options.size());
+ EXPECT_EQ("tkent@chromium.org", options[0].value().utf8());
+}
+
+} // namespace blink
+
« no previous file with comments | « third_party/WebKit/Source/web/WebInputElement.cpp ('k') | third_party/WebKit/Source/web/web.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698