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 |
+ |