| 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 "base/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
| 6 #include "content/common/view_messages.h" | 6 #include "content/common/view_messages.h" |
| 7 #include "content/public/test/render_view_test.h" | 7 #include "content/public/test/render_view_test.h" |
| 8 #include "content/renderer/render_view_impl.h" | 8 #include "content/renderer/render_view_impl.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "third_party/WebKit/public/web/WebView.h" | 10 #include "third_party/WebKit/public/web/WebView.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 public: | 24 public: |
| 25 ExternalPopupMenuTest() {} | 25 ExternalPopupMenuTest() {} |
| 26 | 26 |
| 27 RenderViewImpl* view() { | 27 RenderViewImpl* view() { |
| 28 return static_cast<RenderViewImpl*>(view_); | 28 return static_cast<RenderViewImpl*>(view_); |
| 29 } | 29 } |
| 30 | 30 |
| 31 virtual void SetUp() { | 31 virtual void SetUp() { |
| 32 RenderViewTest::SetUp(); | 32 RenderViewTest::SetUp(); |
| 33 // We need to set this explictly as RenderMain is not run. | 33 // We need to set this explictly as RenderMain is not run. |
| 34 WebKit::WebView::setUseExternalPopupMenus(true); | 34 blink::WebView::setUseExternalPopupMenus(true); |
| 35 | 35 |
| 36 std::string html = "<select id='mySelect' onchange='selectChanged(this)'>" | 36 std::string html = "<select id='mySelect' onchange='selectChanged(this)'>" |
| 37 " <option>zero</option>" | 37 " <option>zero</option>" |
| 38 " <option selected='1'>one</option>" | 38 " <option selected='1'>one</option>" |
| 39 " <option>two</option>" | 39 " <option>two</option>" |
| 40 "</select>" | 40 "</select>" |
| 41 "<select id='myEmptySelect'>" | 41 "<select id='myEmptySelect'>" |
| 42 "</select>"; | 42 "</select>"; |
| 43 if (ShouldRemoveSelectOnChange()) { | 43 if (ShouldRemoveSelectOnChange()) { |
| 44 html += "<script>" | 44 html += "<script>" |
| 45 " function selectChanged(select) {" | 45 " function selectChanged(select) {" |
| 46 " select.parentNode.removeChild(select);" | 46 " select.parentNode.removeChild(select);" |
| 47 " }" | 47 " }" |
| 48 "</script>"; | 48 "</script>"; |
| 49 } | 49 } |
| 50 | 50 |
| 51 // Load the test page. | 51 // Load the test page. |
| 52 LoadHTML(html.c_str()); | 52 LoadHTML(html.c_str()); |
| 53 | 53 |
| 54 // Set a minimum size and give focus so simulated events work. | 54 // Set a minimum size and give focus so simulated events work. |
| 55 view()->webwidget()->resize(WebKit::WebSize(500, 500)); | 55 view()->webwidget()->resize(blink::WebSize(500, 500)); |
| 56 view()->webwidget()->setFocus(true); | 56 view()->webwidget()->setFocus(true); |
| 57 } | 57 } |
| 58 | 58 |
| 59 int GetSelectedIndex() { | 59 int GetSelectedIndex() { |
| 60 string16 script(ASCIIToUTF16(kSelectID)); | 60 string16 script(ASCIIToUTF16(kSelectID)); |
| 61 script.append(ASCIIToUTF16(".selectedIndex")); | 61 script.append(ASCIIToUTF16(".selectedIndex")); |
| 62 int selected_index = -1; | 62 int selected_index = -1; |
| 63 ExecuteJavaScriptAndReturnIntValue(script, &selected_index); | 63 ExecuteJavaScriptAndReturnIntValue(script, &selected_index); |
| 64 return selected_index; | 64 return selected_index; |
| 65 } | 65 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 139 |
| 140 // Select something, it causes the select to be removed from the page. | 140 // Select something, it causes the select to be removed from the page. |
| 141 view()->OnSelectPopupMenuItem(0); | 141 view()->OnSelectPopupMenuItem(0); |
| 142 | 142 |
| 143 // Just to check the soundness of the test, call SimulateElementClick again. | 143 // Just to check the soundness of the test, call SimulateElementClick again. |
| 144 // It should return false as the select has been removed. | 144 // It should return false as the select has been removed. |
| 145 EXPECT_FALSE(SimulateElementClick(kSelectID)); | 145 EXPECT_FALSE(SimulateElementClick(kSelectID)); |
| 146 } | 146 } |
| 147 | 147 |
| 148 } // namespace content | 148 } // namespace content |
| OLD | NEW |