| 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 <memory> | 7 #include <memory> |
| 8 #include "core/HTMLNames.h" | 8 #include "core/HTMLNames.h" |
| 9 #include "core/dom/NodeComputedStyle.h" | 9 #include "core/dom/NodeComputedStyle.h" |
| 10 #include "core/frame/FrameHost.h" | 10 #include "core/frame/FrameHost.h" |
| 11 #include "core/frame/VisualViewport.h" | 11 #include "core/frame/VisualViewport.h" |
| 12 #include "core/html/HTMLSelectElement.h" | 12 #include "core/html/HTMLSelectElement.h" |
| 13 #include "core/layout/LayoutMenuList.h" | 13 #include "core/layout/LayoutMenuList.h" |
| 14 #include "core/page/Page.h" | 14 #include "core/page/Page.h" |
| 15 #include "core/testing/DummyPageHolder.h" | 15 #include "core/testing/DummyPageHolder.h" |
| 16 #include "platform/PopupMenu.h" | 16 #include "platform/PopupMenu.h" |
| 17 #include "platform/testing/URLTestHelpers.h" | 17 #include "platform/testing/URLTestHelpers.h" |
| 18 #include "platform/testing/UnitTestHelpers.h" | 18 #include "platform/testing/UnitTestHelpers.h" |
| 19 #include "public/platform/Platform.h" | 19 #include "public/platform/Platform.h" |
| 20 #include "public/platform/WebCache.h" | |
| 21 #include "public/platform/WebURLLoaderMockFactory.h" | 20 #include "public/platform/WebURLLoaderMockFactory.h" |
| 22 #include "public/web/WebExternalPopupMenu.h" | 21 #include "public/web/WebExternalPopupMenu.h" |
| 23 #include "public/web/WebPopupMenuInfo.h" | 22 #include "public/web/WebPopupMenuInfo.h" |
| 24 #include "public/web/WebSettings.h" | 23 #include "public/web/WebSettings.h" |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 26 #include "web/WebLocalFrameImpl.h" | 25 #include "web/WebLocalFrameImpl.h" |
| 27 #include "web/tests/FrameTestHelpers.h" | 26 #include "web/tests/FrameTestHelpers.h" |
| 28 | 27 |
| 29 namespace blink { | 28 namespace blink { |
| 30 | 29 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 class ExternalPopupMenuTest : public ::testing::Test { | 100 class ExternalPopupMenuTest : public ::testing::Test { |
| 102 public: | 101 public: |
| 103 ExternalPopupMenuTest() : m_baseURL("http://www.test.com") {} | 102 ExternalPopupMenuTest() : m_baseURL("http://www.test.com") {} |
| 104 | 103 |
| 105 protected: | 104 protected: |
| 106 void SetUp() override { | 105 void SetUp() override { |
| 107 m_helper.initialize(false, &m_webFrameClient, &m_webViewClient); | 106 m_helper.initialize(false, &m_webFrameClient, &m_webViewClient); |
| 108 webView()->setUseExternalPopupMenus(true); | 107 webView()->setUseExternalPopupMenus(true); |
| 109 } | 108 } |
| 110 void TearDown() override { | 109 void TearDown() override { |
| 111 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); | 110 Platform::current() |
| 112 WebCache::clear(); | 111 ->getURLLoaderMockFactory() |
| 112 ->unregisterAllURLsAndClearMemoryCache(); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void registerMockedURLLoad(const std::string& fileName) { | 115 void registerMockedURLLoad(const std::string& fileName) { |
| 116 URLTestHelpers::registerMockedURLLoadFromBase( | 116 URLTestHelpers::registerMockedURLLoadFromBase( |
| 117 WebString::fromUTF8(m_baseURL), testing::webTestDataPath("popup"), | 117 WebString::fromUTF8(m_baseURL), testing::webTestDataPath("popup"), |
| 118 WebString::fromUTF8(fileName), WebString::fromUTF8("text/html")); | 118 WebString::fromUTF8(fileName), WebString::fromUTF8("text/html")); |
| 119 } | 119 } |
| 120 | 120 |
| 121 void loadFrame(const std::string& fileName) { | 121 void loadFrame(const std::string& fileName) { |
| 122 FrameTestHelpers::loadFrame(mainFrame(), m_baseURL + fileName); | 122 FrameTestHelpers::loadFrame(mainFrame(), m_baseURL + fileName); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 | 228 |
| 229 WebExternalPopupMenuClient* client = | 229 WebExternalPopupMenuClient* client = |
| 230 static_cast<ExternalPopupMenu*>(select->popup()); | 230 static_cast<ExternalPopupMenu*>(select->popup()); |
| 231 WebVector<int> indices; | 231 WebVector<int> indices; |
| 232 client->didAcceptIndices(indices); | 232 client->didAcceptIndices(indices); |
| 233 EXPECT_FALSE(select->popupIsVisible()); | 233 EXPECT_FALSE(select->popupIsVisible()); |
| 234 EXPECT_EQ(-1, select->selectedIndex()); | 234 EXPECT_EQ(-1, select->selectedIndex()); |
| 235 } | 235 } |
| 236 | 236 |
| 237 } // namespace blink | 237 } // namespace blink |
| OLD | NEW |