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

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

Issue 341543002: Reland 176261: Fix for select PopupMenuList appearance in rtl mode with overlay-scrollbar enabled. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 6 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.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 df5d615d406639ff46c46d5f51e1cb42e0f023d3..bd2cbbdeca66b0f7623400d43c0b2530ad692ba3 100644
--- a/Source/web/tests/PopupMenuTest.cpp
+++ b/Source/web/tests/PopupMenuTest.cpp
@@ -33,6 +33,7 @@
#include "RuntimeEnabledFeatures.h"
#include "core/dom/Element.h"
#include "core/frame/FrameView.h"
+#include "core/frame/Settings.h"
#include "core/html/HTMLSelectElement.h"
#include "core/page/EventHandler.h"
#include "platform/KeyboardCodes.h"
@@ -40,6 +41,7 @@
#include "platform/PopupMenu.h"
#include "platform/PopupMenuClient.h"
#include "platform/graphics/Color.h"
+#include "platform/scroll/ScrollbarTheme.h"
#include "public/platform/Platform.h"
#include "public/platform/WebScreenInfo.h"
#include "public/platform/WebString.h"
@@ -57,6 +59,7 @@
#include "public/web/WebViewClient.h"
#include "v8.h"
#include "web/PopupContainer.h"
+#include "web/PopupListBox.h"
#include "web/PopupMenuChromium.h"
#include "web/WebLocalFrameImpl.h"
#include "web/WebPopupMenuImpl.h"
@@ -74,7 +77,7 @@ namespace {
class TestPopupMenuClient : public PopupMenuClient {
public:
// Item at index 0 is selected by default.
- TestPopupMenuClient() : m_selectIndex(0), m_node(0) { }
+ TestPopupMenuClient() : m_selectIndex(0), m_node(0), m_listSize(10) { }
virtual ~TestPopupMenuClient() {}
virtual void valueChanged(unsigned listIndex, bool fireEvents = true)
{
@@ -111,7 +114,7 @@ public:
virtual int clientInsetRight() const { return 0; }
virtual LayoutUnit clientPaddingLeft() const { return 0; }
virtual LayoutUnit clientPaddingRight() const { return 0; }
- virtual int listSize() const { return 10; }
+ virtual int listSize() const { return m_listSize; }
virtual int selectedIndex() const { return m_selectIndex; }
virtual void popupDidHide() { }
virtual bool itemIsSeparator(unsigned listIndex) const { return false; }
@@ -127,11 +130,13 @@ public:
void setDisabledIndex(unsigned index) { m_disabledIndexSet.insert(index); }
void setFocusedNode(Node* node) { m_node = node; }
+ void setListSize(int listSize) { m_listSize = listSize; }
private:
unsigned m_selectIndex;
std::set<unsigned> m_disabledIndexSet;
Node* m_node;
+ int m_listSize;
};
class TestWebWidgetClient : public WebWidgetClient {
@@ -498,4 +503,49 @@ TEST_F(SelectPopupMenuTest, SelectItemRemoveSelectOnClick)
EXPECT_STREQ("click", element.innerText().utf8().data());
}
+#if OS(ANDROID)
+TEST_F(SelectPopupMenuTest, DISABLED_PopupListBoxWithOverlayScrollbarEnabled)
+#else
+TEST_F(SelectPopupMenuTest, PopupListBoxWithOverlayScrollbarEnabled)
+#endif
+{
+ Settings::setMockScrollbarsEnabled(true);
+ RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(true);
+ EXPECT_TRUE(ScrollbarTheme::theme()->usesOverlayScrollbars());
+ registerMockedURLLoad("select_rtl.html");
+ loadFrame(mainFrame(), "select_rtl.html");
+
+ m_popupMenuClient.setFocusedNode(mainFrame()->frame()->document()->focusedElement());
+ m_popupMenuClient.setListSize(30);
+
+ showPopup();
+ PopupContainer* container = webView()->selectPopup();
+ PopupListBox* listBox = container->listBox();
+
+ EXPECT_EQ(container->width(), listBox->contentsSize().width() + 2);
+ Settings::setMockScrollbarsEnabled(false);
+ RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(false);
+ EXPECT_FALSE(ScrollbarTheme::theme()->usesOverlayScrollbars());
+}
+
+#if OS(ANDROID)
+TEST_F(SelectPopupMenuTest, DISABLED_PopupListBoxWithOverlayScrollbarDisabled)
+#else
+TEST_F(SelectPopupMenuTest, PopupListBoxWithOverlayScrollbarDisabled)
+#endif
+{
+ EXPECT_FALSE(ScrollbarTheme::theme()->usesOverlayScrollbars());
+ registerMockedURLLoad("select_rtl.html");
+ loadFrame(mainFrame(), "select_rtl.html");
+
+ m_popupMenuClient.setFocusedNode(mainFrame()->frame()->document()->focusedElement());
+ m_popupMenuClient.setListSize(30);
+
+ showPopup();
+ PopupContainer* container = webView()->selectPopup();
+ PopupListBox* listBox = container->listBox();
+
+ EXPECT_EQ(container->width(), listBox->contentsSize().width() + ScrollbarTheme::theme()->scrollbarThickness() + 2);
+}
+
} // namespace
« no previous file with comments | « Source/web/PopupListBox.cpp ('k') | Source/web/tests/data/popup/select_rtl.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698