OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <tuple> | 5 #include <tuple> |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "content/common/frame_messages.h" | 9 #include "content/common/frame_messages.h" |
10 #include "content/public/test/render_view_test.h" | 10 #include "content/public/test/render_view_test.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 " function selectChanged(select) {" | 53 " function selectChanged(select) {" |
54 " select.parentNode.removeChild(select);" | 54 " select.parentNode.removeChild(select);" |
55 " }" | 55 " }" |
56 "</script>"; | 56 "</script>"; |
57 } | 57 } |
58 | 58 |
59 // Load the test page. | 59 // Load the test page. |
60 LoadHTML(html.c_str()); | 60 LoadHTML(html.c_str()); |
61 | 61 |
62 // Set a minimum size and give focus so simulated events work. | 62 // Set a minimum size and give focus so simulated events work. |
63 view()->GetWidget()->webwidget()->resize(blink::WebSize(500, 500)); | 63 view()->GetWidget()->GetWebWidget()->resize(blink::WebSize(500, 500)); |
64 view()->GetWidget()->webwidget()->setFocus(true); | 64 view()->GetWidget()->GetWebWidget()->setFocus(true); |
65 } | 65 } |
66 | 66 |
67 int GetSelectedIndex() { | 67 int GetSelectedIndex() { |
68 base::string16 script(base::ASCIIToUTF16(kSelectID)); | 68 base::string16 script(base::ASCIIToUTF16(kSelectID)); |
69 script.append(base::ASCIIToUTF16(".selectedIndex")); | 69 script.append(base::ASCIIToUTF16(".selectedIndex")); |
70 int selected_index = -1; | 70 int selected_index = -1; |
71 ExecuteJavaScriptAndReturnIntValue(script, &selected_index); | 71 ExecuteJavaScriptAndReturnIntValue(script, &selected_index); |
72 return selected_index; | 72 return selected_index; |
73 } | 73 } |
74 | 74 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 " </optgroup>" | 169 " </optgroup>" |
170 " <option value='two'>two</option>" | 170 " <option value='two'>two</option>" |
171 " <option value='three'>three</option>" | 171 " <option value='three'>three</option>" |
172 " <option value='four'>four</option>" | 172 " <option value='four'>four</option>" |
173 " <option value='five'>five</option>" | 173 " <option value='five'>five</option>" |
174 "</select>"; | 174 "</select>"; |
175 // Load the test page. | 175 // Load the test page. |
176 LoadHTML(html.c_str()); | 176 LoadHTML(html.c_str()); |
177 | 177 |
178 // Set a minimum size and give focus so simulated events work. | 178 // Set a minimum size and give focus so simulated events work. |
179 view()->GetWidget()->webwidget()->resize(blink::WebSize(500, 500)); | 179 view()->GetWidget()->GetWebWidget()->resize(blink::WebSize(500, 500)); |
180 view()->GetWidget()->webwidget()->setFocus(true); | 180 view()->GetWidget()->GetWebWidget()->setFocus(true); |
181 } | 181 } |
182 | 182 |
183 }; | 183 }; |
184 | 184 |
185 TEST_F(ExternalPopupMenuDisplayNoneTest, SelectItem) { | 185 TEST_F(ExternalPopupMenuDisplayNoneTest, SelectItem) { |
186 IPC::TestSink& sink = render_thread_->sink(); | 186 IPC::TestSink& sink = render_thread_->sink(); |
187 | 187 |
188 // Click the text field once to show the popup. | 188 // Click the text field once to show the popup. |
189 EXPECT_TRUE(SimulateElementClick(kSelectID)); | 189 EXPECT_TRUE(SimulateElementClick(kSelectID)); |
190 | 190 |
191 // Read the message sent to browser to show the popup menu. | 191 // Read the message sent to browser to show the popup menu. |
192 const IPC::Message* message = | 192 const IPC::Message* message = |
193 sink.GetUniqueMessageMatching(FrameHostMsg_ShowPopup::ID); | 193 sink.GetUniqueMessageMatching(FrameHostMsg_ShowPopup::ID); |
194 ASSERT_TRUE(message != NULL); | 194 ASSERT_TRUE(message != NULL); |
195 std::tuple<FrameHostMsg_ShowPopup_Params> param; | 195 std::tuple<FrameHostMsg_ShowPopup_Params> param; |
196 FrameHostMsg_ShowPopup::Read(message, ¶m); | 196 FrameHostMsg_ShowPopup::Read(message, ¶m); |
197 // Number of items should match item count minus the number | 197 // Number of items should match item count minus the number |
198 // of "display: none" items. | 198 // of "display: none" items. |
199 ASSERT_EQ(5U, std::get<0>(param).popup_items.size()); | 199 ASSERT_EQ(5U, std::get<0>(param).popup_items.size()); |
200 | 200 |
201 // Select index 1 item. This should select item with index 2, | 201 // Select index 1 item. This should select item with index 2, |
202 // skipping the item with 'display: none' | 202 // skipping the item with 'display: none' |
203 frame()->OnSelectPopupMenuItem(1); | 203 frame()->OnSelectPopupMenuItem(1); |
204 | 204 |
205 EXPECT_EQ(2, GetSelectedIndex()); | 205 EXPECT_EQ(2, GetSelectedIndex()); |
206 } | 206 } |
207 | 207 |
208 } // namespace content | 208 } // namespace content |
OLD | NEW |