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

Side by Side Diff: third_party/WebKit/Source/web/ExternalPopupMenuTest.cpp

Issue 2654933003: platform/testing/{URL|Unit}TestHelpers improvements (Closed)
Patch Set: header changes Created 3 years, 10 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
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 "core/HTMLNames.h" 8 #include "core/HTMLNames.h"
8 #include "core/dom/NodeComputedStyle.h" 9 #include "core/dom/NodeComputedStyle.h"
9 #include "core/frame/FrameHost.h" 10 #include "core/frame/FrameHost.h"
10 #include "core/frame/VisualViewport.h" 11 #include "core/frame/VisualViewport.h"
11 #include "core/html/HTMLSelectElement.h" 12 #include "core/html/HTMLSelectElement.h"
12 #include "core/layout/LayoutMenuList.h" 13 #include "core/layout/LayoutMenuList.h"
13 #include "core/page/Page.h" 14 #include "core/page/Page.h"
14 #include "core/testing/DummyPageHolder.h" 15 #include "core/testing/DummyPageHolder.h"
15 #include "platform/PopupMenu.h" 16 #include "platform/PopupMenu.h"
16 #include "platform/testing/URLTestHelpers.h" 17 #include "platform/testing/URLTestHelpers.h"
18 #include "platform/testing/UnitTestHelpers.h"
17 #include "public/platform/Platform.h" 19 #include "public/platform/Platform.h"
18 #include "public/platform/WebURLLoaderMockFactory.h" 20 #include "public/platform/WebURLLoaderMockFactory.h"
19 #include "public/web/WebCache.h" 21 #include "public/web/WebCache.h"
20 #include "public/web/WebExternalPopupMenu.h" 22 #include "public/web/WebExternalPopupMenu.h"
21 #include "public/web/WebPopupMenuInfo.h" 23 #include "public/web/WebPopupMenuInfo.h"
22 #include "public/web/WebSettings.h" 24 #include "public/web/WebSettings.h"
23 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
24 #include "web/WebLocalFrameImpl.h" 26 #include "web/WebLocalFrameImpl.h"
25 #include "web/tests/FrameTestHelpers.h" 27 #include "web/tests/FrameTestHelpers.h"
26 #include <memory>
27 28
28 namespace blink { 29 namespace blink {
29 30
30 class ExternalPopupMenuDisplayNoneItemsTest : public testing::Test { 31 class ExternalPopupMenuDisplayNoneItemsTest : public ::testing::Test {
31 public: 32 public:
32 ExternalPopupMenuDisplayNoneItemsTest() {} 33 ExternalPopupMenuDisplayNoneItemsTest() {}
33 34
34 protected: 35 protected:
35 void SetUp() override { 36 void SetUp() override {
36 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600)); 37 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600));
37 HTMLSelectElement* element = 38 HTMLSelectElement* element =
38 HTMLSelectElement::create(m_dummyPageHolder->document()); 39 HTMLSelectElement::create(m_dummyPageHolder->document());
39 // Set the 4th an 5th items to have "display: none" property 40 // Set the 4th an 5th items to have "display: none" property
40 element->setInnerHTML( 41 element->setInnerHTML(
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 public: 91 public:
91 WebRect shownBounds() const { return m_shownBounds; } 92 WebRect shownBounds() const { return m_shownBounds; }
92 93
93 private: 94 private:
94 WebRect m_shownBounds; 95 WebRect m_shownBounds;
95 }; 96 };
96 WebRect m_shownBounds; 97 WebRect m_shownBounds;
97 MockWebExternalPopupMenu m_mockWebExternalPopupMenu; 98 MockWebExternalPopupMenu m_mockWebExternalPopupMenu;
98 }; 99 };
99 100
100 class ExternalPopupMenuTest : public testing::Test { 101 class ExternalPopupMenuTest : public ::testing::Test {
101 public: 102 public:
102 ExternalPopupMenuTest() : m_baseURL("http://www.test.com") {} 103 ExternalPopupMenuTest() : m_baseURL("http://www.test.com") {}
103 104
104 protected: 105 protected:
105 void SetUp() override { 106 void SetUp() override {
106 m_helper.initialize(false, &m_webFrameClient, &m_webViewClient); 107 m_helper.initialize(false, &m_webFrameClient, &m_webViewClient);
107 webView()->setUseExternalPopupMenus(true); 108 webView()->setUseExternalPopupMenus(true);
108 } 109 }
109 void TearDown() override { 110 void TearDown() override {
110 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); 111 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs();
111 WebCache::clear(); 112 WebCache::clear();
112 } 113 }
113 114
114 void registerMockedURLLoad(const std::string& fileName) { 115 void registerMockedURLLoad(const std::string& fileName) {
115 URLTestHelpers::registerMockedURLLoad( 116 URLTestHelpers::registerMockedURLLoadFromBase(
116 URLTestHelpers::toKURL(m_baseURL + fileName), 117 WebString::fromUTF8(m_baseURL), testing::webTestDataPath("popup"),
117 WebString::fromUTF8(fileName.c_str()), WebString::fromUTF8("popup/"), 118 WebString::fromUTF8(fileName), WebString::fromUTF8("text/html"));
118 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);
123 webView()->resize(WebSize(800, 600)); 123 webView()->resize(WebSize(800, 600));
124 webView()->updateAllLifecyclePhases(); 124 webView()->updateAllLifecyclePhases();
125 } 125 }
126 126
127 WebViewImpl* webView() const { return m_helper.webView(); } 127 WebViewImpl* webView() const { return m_helper.webView(); }
128 const ExternalPopupMenuWebFrameClient& client() const { 128 const ExternalPopupMenuWebFrameClient& client() const {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/testing/data/white-1x1.png ('k') | third_party/WebKit/Source/web/LinkHighlightImplTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698