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

Unified Diff: Source/web/tests/PopupMenuTest.cpp

Issue 451983004: Fix rtl text shifting in PopupListBox (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/web/PopupListBox.cpp ('k') | Source/web/tests/data/popup/select_rtl_width.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/tests/PopupMenuTest.cpp
diff --git a/Source/web/tests/PopupMenuTest.cpp b/Source/web/tests/PopupMenuTest.cpp
index bd6529420968b31002e4da5e4564182da7601ee0..ed65f440defa6f0cd89afbe34b1aa1e52989345f 100644
--- a/Source/web/tests/PopupMenuTest.cpp
+++ b/Source/web/tests/PopupMenuTest.cpp
@@ -35,6 +35,7 @@
#include "core/frame/Settings.h"
#include "core/html/HTMLSelectElement.h"
#include "core/page/EventHandler.h"
+#include "core/rendering/RenderMenuList.h"
#include "platform/KeyboardCodes.h"
#include "platform/PlatformMouseEvent.h"
#include "platform/PopupMenu.h"
@@ -548,4 +549,66 @@ TEST_F(SelectPopupMenuTest, PopupListBoxWithOverlayScrollbarDisabled)
EXPECT_EQ(container->width(), listBox->contentsSize().width() + ScrollbarTheme::theme()->scrollbarThickness() + 2);
}
+class SelectPopupMenuStyleTest : public testing::Test {
+public:
+ SelectPopupMenuStyleTest()
+ : baseURL("http://www.test.com/")
+ {
+ }
+
+protected:
+ virtual void SetUp() OVERRIDE
+ {
+ m_helper.initialize(false, 0, &m_webviewClient);
+ }
+
+ virtual void TearDown() OVERRIDE
+ {
+ Platform::current()->unitTestSupport()->unregisterAllMockedURLs();
+ }
+
+ // Returns true if there currently is a select popup in the WebView.
+ bool popupOpen() const { return webView()->selectPopup(); }
+
+ void registerMockedURLLoad(const std::string& fileName)
+ {
+ URLTestHelpers::registerMockedURLLoad(toKURL(baseURL + fileName), WebString::fromUTF8(fileName.c_str()), WebString::fromUTF8("popup/"), WebString::fromUTF8("text/html"));
+ }
+
+ void loadFrame(WebFrame* frame, const std::string& fileName)
+ {
+ FrameTestHelpers::loadFrame(frame, baseURL + fileName);
+ }
+
+ WebViewImpl* webView() const { return m_helper.webViewImpl(); }
+ WebLocalFrameImpl* mainFrame() const { return m_helper.webViewImpl()->mainFrameImpl(); }
+
+protected:
+ PopupTestWebViewClient m_webviewClient;
+ RefPtr<PopupMenu> m_popupMenu;
+ std::string baseURL;
+
+private:
+ FrameTestHelpers::WebViewHelper m_helper;
+};
+
+#if OS(MACOSX) || OS(ANDROID)
+TEST_F(SelectPopupMenuStyleTest, DISABLED_PopupListBoxRTLRowWidth)
+#else
+TEST_F(SelectPopupMenuStyleTest, PopupListBoxRTLRowWidth)
+#endif
+{
+ registerMockedURLLoad("select_rtl_width.html");
+ loadFrame(mainFrame(), "select_rtl_width.html");
+ HTMLSelectElement* select = toHTMLSelectElement(mainFrame()->frame()->document()->focusedElement());
+ RenderMenuList* menuList = toRenderMenuList(select->renderer());
+ ASSERT(menuList);
+ menuList->showPopup();
+ ASSERT(popupOpen());
+ PopupListBox* listBox = webView()->selectPopup()->listBox();
+ int ltrWidth = listBox->getRowBaseWidth(0);
+ int rtlWidth = listBox->getRowBaseWidth(1);
+ EXPECT_LT(rtlWidth, ltrWidth);
+}
+
} // namespace
« no previous file with comments | « Source/web/PopupListBox.cpp ('k') | Source/web/tests/data/popup/select_rtl_width.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698