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

Side by Side Diff: Source/web/PopupMenuTest.cpp

Issue 517043003: Move Frame to the Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Back out non-Oilpan experiment + tidy up by adding frame() ref accessors Created 6 years, 3 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 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 public: 183 public:
184 SelectPopupMenuTest() 184 SelectPopupMenuTest()
185 : baseURL("http://www.test.com/") 185 : baseURL("http://www.test.com/")
186 { 186 {
187 } 187 }
188 188
189 protected: 189 protected:
190 virtual void SetUp() 190 virtual void SetUp()
191 { 191 {
192 m_helper.initialize(false, 0, &m_webviewClient); 192 m_helper.initialize(false, 0, &m_webviewClient);
193 m_popupMenu = adoptRef(new PopupMenuChromium(*mainFrame()->frame(), &m_p opupMenuClient)); 193 m_popupMenu = adoptRefWillBeNoop(new PopupMenuChromium(*mainFrame()->fra me(), &m_popupMenuClient));
194 } 194 }
195 195
196 virtual void TearDown() 196 virtual void TearDown()
197 { 197 {
198 m_popupMenu = nullptr;
199 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); 198 Platform::current()->unitTestSupport()->unregisterAllMockedURLs();
200 } 199 }
201 200
202 // Returns true if there currently is a select popup in the WebView. 201 // Returns true if there currently is a select popup in the WebView.
203 bool popupOpen() const { return webView()->selectPopup(); } 202 bool popupOpen() const { return webView()->selectPopup(); }
204 203
205 int selectedIndex() const { return m_popupMenuClient.selectedIndex(); } 204 int selectedIndex() const { return m_popupMenuClient.selectedIndex(); }
206 205
207 void showPopup() 206 void showPopup()
208 { 207 {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 { 258 {
260 FrameTestHelpers::loadFrame(frame, baseURL + fileName); 259 FrameTestHelpers::loadFrame(frame, baseURL + fileName);
261 } 260 }
262 261
263 WebViewImpl* webView() const { return m_helper.webViewImpl(); } 262 WebViewImpl* webView() const { return m_helper.webViewImpl(); }
264 WebLocalFrameImpl* mainFrame() const { return m_helper.webViewImpl()->mainFr ameImpl(); } 263 WebLocalFrameImpl* mainFrame() const { return m_helper.webViewImpl()->mainFr ameImpl(); }
265 264
266 protected: 265 protected:
267 PopupTestWebViewClient m_webviewClient; 266 PopupTestWebViewClient m_webviewClient;
268 TestPopupMenuClient m_popupMenuClient; 267 TestPopupMenuClient m_popupMenuClient;
269 RefPtr<PopupMenu> m_popupMenu; 268 RefPtrWillBePersistent<PopupMenu> m_popupMenu;
270 std::string baseURL; 269 std::string baseURL;
271 270
272 private: 271 private:
273 FrameTestHelpers::WebViewHelper m_helper; 272 FrameTestHelpers::WebViewHelper m_helper;
274 }; 273 };
275 274
276 // Tests that show/hide and repeats. Select popups are reused in web pages when 275 // Tests that show/hide and repeats. Select popups are reused in web pages when
277 // they are reopened, that what this is testing. 276 // they are reopened, that what this is testing.
278 TEST_F(SelectPopupMenuTest, ShowThenHide) 277 TEST_F(SelectPopupMenuTest, ShowThenHide)
279 { 278 {
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 void loadFrame(WebFrame* frame, const std::string& fileName) 576 void loadFrame(WebFrame* frame, const std::string& fileName)
578 { 577 {
579 FrameTestHelpers::loadFrame(frame, baseURL + fileName); 578 FrameTestHelpers::loadFrame(frame, baseURL + fileName);
580 } 579 }
581 580
582 WebViewImpl* webView() const { return m_helper.webViewImpl(); } 581 WebViewImpl* webView() const { return m_helper.webViewImpl(); }
583 WebLocalFrameImpl* mainFrame() const { return m_helper.webViewImpl()->mainFr ameImpl(); } 582 WebLocalFrameImpl* mainFrame() const { return m_helper.webViewImpl()->mainFr ameImpl(); }
584 583
585 protected: 584 protected:
586 PopupTestWebViewClient m_webviewClient; 585 PopupTestWebViewClient m_webviewClient;
587 RefPtr<PopupMenu> m_popupMenu;
588 std::string baseURL; 586 std::string baseURL;
589 587
590 private: 588 private:
591 FrameTestHelpers::WebViewHelper m_helper; 589 FrameTestHelpers::WebViewHelper m_helper;
592 }; 590 };
593 591
594 #if OS(MACOSX) || OS(ANDROID) 592 #if OS(MACOSX) || OS(ANDROID)
595 TEST_F(SelectPopupMenuStyleTest, DISABLED_PopupListBoxRTLRowWidth) 593 TEST_F(SelectPopupMenuStyleTest, DISABLED_PopupListBoxRTLRowWidth)
596 #else 594 #else
597 TEST_F(SelectPopupMenuStyleTest, PopupListBoxRTLRowWidth) 595 TEST_F(SelectPopupMenuStyleTest, PopupListBoxRTLRowWidth)
598 #endif 596 #endif
599 { 597 {
600 registerMockedURLLoad("select_rtl_width.html"); 598 registerMockedURLLoad("select_rtl_width.html");
601 loadFrame(mainFrame(), "select_rtl_width.html"); 599 loadFrame(mainFrame(), "select_rtl_width.html");
602 HTMLSelectElement* select = toHTMLSelectElement(mainFrame()->frame()->docume nt()->focusedElement()); 600 HTMLSelectElement* select = toHTMLSelectElement(mainFrame()->frame()->docume nt()->focusedElement());
603 RenderMenuList* menuList = toRenderMenuList(select->renderer()); 601 RenderMenuList* menuList = toRenderMenuList(select->renderer());
604 ASSERT(menuList); 602 ASSERT(menuList);
605 menuList->showPopup(); 603 menuList->showPopup();
606 ASSERT(popupOpen()); 604 ASSERT(popupOpen());
607 PopupListBox* listBox = webView()->selectPopup()->listBox(); 605 PopupListBox* listBox = webView()->selectPopup()->listBox();
608 int ltrWidth = listBox->getRowBaseWidth(0); 606 int ltrWidth = listBox->getRowBaseWidth(0);
609 int rtlWidth = listBox->getRowBaseWidth(1); 607 int rtlWidth = listBox->getRowBaseWidth(1);
610 EXPECT_LT(rtlWidth, ltrWidth); 608 EXPECT_LT(rtlWidth, ltrWidth);
611 } 609 }
612 610
613 } // namespace 611 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698