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

Side by Side 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, 4 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "public/web/WebInputElement.h"
6
7 #include "core/html/HTMLInputElement.h"
8 #include "core/testing/DummyPageHolder.h"
9 #include "public/web/WebOptionElement.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace blink {
13
14 class WebInputElementTest : public testing::Test {
15 protected:
16 Document& document() { return m_pageHolder->document(); }
17 WebInputElement testElement()
18 {
19 Element* element = document().getElementById("test");
20 DCHECK(element);
21 return WebInputElement(toHTMLInputElement(element));
22 }
23
24 private:
25 void SetUp() override
26 {
27 m_pageHolder = DummyPageHolder::create(IntSize(800, 600));
28 }
29
30 std::unique_ptr<DummyPageHolder> m_pageHolder;
vabr (Chromium) 2016/07/25 13:59:53 nit: #include <memory> for the unique_ptr?
31 };
32
33 TEST_F(WebInputElementTest, FilteredDataListOptionsNoList)
34 {
35 document().documentElement()->setInnerHTML("<input id=test>", ASSERT_NO_EXCE PTION);
36 EXPECT_TRUE(testElement().filteredDataListOptions().isEmpty());
37
38 document().documentElement()->setInnerHTML("<input id=test list=dl1><datalis t id=dl1></datalist>", ASSERT_NO_EXCEPTION);
39 EXPECT_TRUE(testElement().filteredDataListOptions().isEmpty());
40 }
41
42 TEST_F(WebInputElementTest, FilteredDataListOptionsPrefixed)
43 {
44 document().documentElement()->setInnerHTML(
45 "<input id=test value=ABC list=dl2>"
46 "<datalist id=dl2>"
47 "<option>AbC DEF</option>"
48 "<option>VAX</option>"
49 "<option value=ghi>abc</option>"
50 "</datalist>", ASSERT_NO_EXCEPTION);
51 auto options = testElement().filteredDataListOptions();
52 EXPECT_EQ(1u, options.size());
53 EXPECT_EQ("AbC DEF", options[0].value().utf8());
54 }
55
56 TEST_F(WebInputElementTest, FilteredDataListOptionsForMultipleEmail)
57 {
58 document().documentElement()->setInnerHTML(
59 "<input id=test value='foo@example.com, tkent' list=dl3 type=email multi ple>"
60 "<datalist id=dl3>"
61 "<option>keishi@chromium.org</option>"
62 "<option>tkent@chromium.org</option>"
63 "</datalist>", ASSERT_NO_EXCEPTION);
64 auto options = testElement().filteredDataListOptions();
65 EXPECT_EQ(1u, options.size());
66 EXPECT_EQ("tkent@chromium.org", options[0].value().utf8());
67 }
68
69 } // namespace blink
70
OLDNEW
« 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