| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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 "web/ExternalPopupMenu.h" | 5 #include "web/ExternalPopupMenu.h" |
| 6 | 6 |
| 7 #include "core/HTMLNames.h" | 7 #include "core/HTMLNames.h" |
| 8 #include "core/dom/NodeComputedStyle.h" | 8 #include "core/dom/NodeComputedStyle.h" |
| 9 #include "core/frame/FrameHost.h" | 9 #include "core/frame/FrameHost.h" |
| 10 #include "core/frame/VisualViewport.h" | 10 #include "core/frame/VisualViewport.h" |
| 11 #include "core/html/HTMLSelectElement.h" | 11 #include "core/html/HTMLSelectElement.h" |
| 12 #include "core/layout/LayoutMenuList.h" | 12 #include "core/layout/LayoutMenuList.h" |
| 13 #include "core/page/Page.h" | 13 #include "core/page/Page.h" |
| 14 #include "core/testing/DummyPageHolder.h" | 14 #include "core/testing/DummyPageHolder.h" |
| 15 #include "platform/PopupMenu.h" | 15 #include "platform/PopupMenu.h" |
| 16 #include "platform/testing/URLTestHelpers.h" | 16 #include "platform/testing/URLTestHelpers.h" |
| 17 #include "public/platform/Platform.h" | 17 #include "public/platform/Platform.h" |
| 18 #include "public/platform/WebUnitTestSupport.h" | 18 #include "public/platform/WebURLLoaderMockFactory.h" |
| 19 #include "public/web/WebCache.h" |
| 19 #include "public/web/WebExternalPopupMenu.h" | 20 #include "public/web/WebExternalPopupMenu.h" |
| 20 #include "public/web/WebPopupMenuInfo.h" | 21 #include "public/web/WebPopupMenuInfo.h" |
| 21 #include "public/web/WebSettings.h" | 22 #include "public/web/WebSettings.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 23 #include "web/WebLocalFrameImpl.h" | 24 #include "web/WebLocalFrameImpl.h" |
| 24 #include "web/tests/FrameTestHelpers.h" | 25 #include "web/tests/FrameTestHelpers.h" |
| 25 | 26 |
| 26 namespace blink { | 27 namespace blink { |
| 27 | 28 |
| 28 class ExternalPopupMenuDisplayNoneItemsTest : public testing::Test { | 29 class ExternalPopupMenuDisplayNoneItemsTest : public testing::Test { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 ExternalPopupMenuTest() : m_baseURL("http://www.test.com") { } | 101 ExternalPopupMenuTest() : m_baseURL("http://www.test.com") { } |
| 101 | 102 |
| 102 protected: | 103 protected: |
| 103 void SetUp() override | 104 void SetUp() override |
| 104 { | 105 { |
| 105 m_helper.initialize(false, &m_webFrameClient, &m_webViewClient); | 106 m_helper.initialize(false, &m_webFrameClient, &m_webViewClient); |
| 106 webView()->setUseExternalPopupMenus(true); | 107 webView()->setUseExternalPopupMenus(true); |
| 107 } | 108 } |
| 108 void TearDown() override | 109 void TearDown() override |
| 109 { | 110 { |
| 110 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); | 111 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); |
| 112 WebCache::clear(); |
| 111 } | 113 } |
| 112 | 114 |
| 113 void registerMockedURLLoad(const std::string& fileName) | 115 void registerMockedURLLoad(const std::string& fileName) |
| 114 { | 116 { |
| 115 URLTestHelpers::registerMockedURLLoad(URLTestHelpers::toKURL(m_baseURL +
fileName), WebString::fromUTF8(fileName.c_str()), WebString::fromUTF8("popup/")
, WebString::fromUTF8("text/html")); | 117 URLTestHelpers::registerMockedURLLoad(URLTestHelpers::toKURL(m_baseURL +
fileName), WebString::fromUTF8(fileName.c_str()), WebString::fromUTF8("popup/")
, WebString::fromUTF8("text/html")); |
| 116 } | 118 } |
| 117 | 119 |
| 118 void loadFrame(const std::string& fileName) | 120 void loadFrame(const std::string& fileName) |
| 119 { | 121 { |
| 120 FrameTestHelpers::loadFrame(mainFrame(), m_baseURL + fileName); | 122 FrameTestHelpers::loadFrame(mainFrame(), m_baseURL + fileName); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 ASSERT_TRUE(select->popupIsVisible()); | 212 ASSERT_TRUE(select->popupIsVisible()); |
| 211 | 213 |
| 212 WebExternalPopupMenuClient* client = static_cast<ExternalPopupMenu*>(select-
>popup()); | 214 WebExternalPopupMenuClient* client = static_cast<ExternalPopupMenu*>(select-
>popup()); |
| 213 WebVector<int> indices; | 215 WebVector<int> indices; |
| 214 client->didAcceptIndices(indices); | 216 client->didAcceptIndices(indices); |
| 215 EXPECT_FALSE(select->popupIsVisible()); | 217 EXPECT_FALSE(select->popupIsVisible()); |
| 216 EXPECT_EQ(-1, select->selectedIndex()); | 218 EXPECT_EQ(-1, select->selectedIndex()); |
| 217 } | 219 } |
| 218 | 220 |
| 219 } // namespace blink | 221 } // namespace blink |
| OLD | NEW |