OLD | NEW |
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 17 matching lines...) Expand all Loading... |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 | 32 |
33 #include "core/dom/Element.h" | 33 #include "core/dom/Element.h" |
34 #include "core/frame/FrameView.h" | 34 #include "core/frame/FrameView.h" |
35 #include "core/frame/Settings.h" | 35 #include "core/frame/Settings.h" |
36 #include "core/html/HTMLSelectElement.h" | 36 #include "core/html/HTMLSelectElement.h" |
37 #include "core/page/EventHandler.h" | 37 #include "core/page/EventHandler.h" |
| 38 #include "core/rendering/RenderMenuList.h" |
38 #include "platform/KeyboardCodes.h" | 39 #include "platform/KeyboardCodes.h" |
39 #include "platform/PlatformMouseEvent.h" | 40 #include "platform/PlatformMouseEvent.h" |
40 #include "platform/PopupMenu.h" | 41 #include "platform/PopupMenu.h" |
41 #include "platform/PopupMenuClient.h" | 42 #include "platform/PopupMenuClient.h" |
42 #include "platform/RuntimeEnabledFeatures.h" | 43 #include "platform/RuntimeEnabledFeatures.h" |
43 #include "platform/graphics/Color.h" | 44 #include "platform/graphics/Color.h" |
44 #include "platform/scroll/ScrollbarTheme.h" | 45 #include "platform/scroll/ScrollbarTheme.h" |
45 #include "public/platform/Platform.h" | 46 #include "public/platform/Platform.h" |
46 #include "public/platform/WebScreenInfo.h" | 47 #include "public/platform/WebScreenInfo.h" |
47 #include "public/platform/WebString.h" | 48 #include "public/platform/WebString.h" |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 m_popupMenuClient.setFocusedNode(mainFrame()->frame()->document()->focusedEl
ement()); | 542 m_popupMenuClient.setFocusedNode(mainFrame()->frame()->document()->focusedEl
ement()); |
542 m_popupMenuClient.setListSize(30); | 543 m_popupMenuClient.setListSize(30); |
543 | 544 |
544 showPopup(); | 545 showPopup(); |
545 PopupContainer* container = webView()->selectPopup(); | 546 PopupContainer* container = webView()->selectPopup(); |
546 PopupListBox* listBox = container->listBox(); | 547 PopupListBox* listBox = container->listBox(); |
547 | 548 |
548 EXPECT_EQ(container->width(), listBox->contentsSize().width() + ScrollbarThe
me::theme()->scrollbarThickness() + 2); | 549 EXPECT_EQ(container->width(), listBox->contentsSize().width() + ScrollbarThe
me::theme()->scrollbarThickness() + 2); |
549 } | 550 } |
550 | 551 |
| 552 class SelectPopupMenuStyleTest : public testing::Test { |
| 553 public: |
| 554 SelectPopupMenuStyleTest() |
| 555 : baseURL("http://www.test.com/") |
| 556 { |
| 557 } |
| 558 |
| 559 protected: |
| 560 virtual void SetUp() OVERRIDE |
| 561 { |
| 562 m_helper.initialize(false, 0, &m_webviewClient); |
| 563 } |
| 564 |
| 565 virtual void TearDown() OVERRIDE |
| 566 { |
| 567 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); |
| 568 } |
| 569 |
| 570 // Returns true if there currently is a select popup in the WebView. |
| 571 bool popupOpen() const { return webView()->selectPopup(); } |
| 572 |
| 573 void registerMockedURLLoad(const std::string& fileName) |
| 574 { |
| 575 URLTestHelpers::registerMockedURLLoad(toKURL(baseURL + fileName), WebStr
ing::fromUTF8(fileName.c_str()), WebString::fromUTF8("popup/"), WebString::fromU
TF8("text/html")); |
| 576 } |
| 577 |
| 578 void loadFrame(WebFrame* frame, const std::string& fileName) |
| 579 { |
| 580 FrameTestHelpers::loadFrame(frame, baseURL + fileName); |
| 581 } |
| 582 |
| 583 WebViewImpl* webView() const { return m_helper.webViewImpl(); } |
| 584 WebLocalFrameImpl* mainFrame() const { return m_helper.webViewImpl()->mainFr
ameImpl(); } |
| 585 |
| 586 protected: |
| 587 PopupTestWebViewClient m_webviewClient; |
| 588 RefPtr<PopupMenu> m_popupMenu; |
| 589 std::string baseURL; |
| 590 |
| 591 private: |
| 592 FrameTestHelpers::WebViewHelper m_helper; |
| 593 }; |
| 594 |
| 595 #if OS(MACOSX) || OS(ANDROID) |
| 596 TEST_F(SelectPopupMenuStyleTest, DISABLED_PopupListBoxRTLRowWidth) |
| 597 #else |
| 598 TEST_F(SelectPopupMenuStyleTest, PopupListBoxRTLRowWidth) |
| 599 #endif |
| 600 { |
| 601 registerMockedURLLoad("select_rtl_width.html"); |
| 602 loadFrame(mainFrame(), "select_rtl_width.html"); |
| 603 HTMLSelectElement* select = toHTMLSelectElement(mainFrame()->frame()->docume
nt()->focusedElement()); |
| 604 RenderMenuList* menuList = toRenderMenuList(select->renderer()); |
| 605 ASSERT(menuList); |
| 606 menuList->showPopup(); |
| 607 ASSERT(popupOpen()); |
| 608 PopupListBox* listBox = webView()->selectPopup()->listBox(); |
| 609 int ltrWidth = listBox->getRowBaseWidth(0); |
| 610 int rtlWidth = listBox->getRowBaseWidth(1); |
| 611 EXPECT_LT(rtlWidth, ltrWidth); |
| 612 } |
| 613 |
551 } // namespace | 614 } // namespace |
OLD | NEW |