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

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

Issue 1013303004: Fix issue on <select> style change when popup is visible (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed test expectation Created 5 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « Source/web/PopupMenuImpl.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 #include <gtest/gtest.h> 72 #include <gtest/gtest.h>
73 73
74 using namespace blink; 74 using namespace blink;
75 using blink::URLTestHelpers::toKURL; 75 using blink::URLTestHelpers::toKURL;
76 76
77 namespace { 77 namespace {
78 78
79 class TestPopupMenuClient : public PopupMenuClient { 79 class TestPopupMenuClient : public PopupMenuClient {
80 public: 80 public:
81 // Item at index 0 is selected by default. 81 // Item at index 0 is selected by default.
82 TestPopupMenuClient() : m_selectIndex(0), m_node(0), m_listSize(10) { } 82 TestPopupMenuClient() : m_selectIndex(0), m_node(0), m_listSize(10), m_index ToSelectOnCancel(-1) { }
83 virtual ~TestPopupMenuClient() { } 83 virtual ~TestPopupMenuClient() { }
84 virtual void valueChanged(unsigned listIndex, bool fireEvents = true) 84 virtual void valueChanged(unsigned listIndex, bool fireEvents = true)
85 { 85 {
86 m_selectIndex = listIndex; 86 m_selectIndex = listIndex;
87 if (m_node) { 87 if (m_node) {
88 HTMLSelectElement* select = toHTMLSelectElement(m_node); 88 HTMLSelectElement* select = toHTMLSelectElement(m_node);
89 select->optionSelectedByUser(select->listToOptionIndex(listIndex), f ireEvents); 89 select->optionSelectedByUser(select->listToOptionIndex(listIndex), f ireEvents);
90 } 90 }
91 } 91 }
92 virtual void selectionChanged(unsigned, bool) { } 92 virtual void selectionChanged(unsigned, bool) { }
(...skipping 17 matching lines...) Expand all
110 Font font(fontDescription); 110 Font font(fontDescription);
111 font.update(nullptr); 111 font.update(nullptr);
112 return PopupMenuStyle(Color::black, Color::white, font, true, false, Len gth(), TextDirection(), false /* has text direction override */); 112 return PopupMenuStyle(Color::black, Color::white, font, true, false, Len gth(), TextDirection(), false /* has text direction override */);
113 } 113 }
114 virtual PopupMenuStyle menuStyle() const { return itemStyle(0); } 114 virtual PopupMenuStyle menuStyle() const { return itemStyle(0); }
115 virtual LayoutUnit clientPaddingLeft() const { return 0; } 115 virtual LayoutUnit clientPaddingLeft() const { return 0; }
116 virtual LayoutUnit clientPaddingRight() const { return 0; } 116 virtual LayoutUnit clientPaddingRight() const { return 0; }
117 virtual int listSize() const { return m_listSize; } 117 virtual int listSize() const { return m_listSize; }
118 virtual int selectedIndex() const { return m_selectIndex; } 118 virtual int selectedIndex() const { return m_selectIndex; }
119 virtual void popupDidHide() { } 119 virtual void popupDidHide() { }
120 virtual void popupDidCancel()
121 {
122 if (m_indexToSelectOnCancel >= 0)
123 m_selectIndex = m_indexToSelectOnCancel;
124 }
120 virtual bool itemIsSeparator(unsigned listIndex) const { return false; } 125 virtual bool itemIsSeparator(unsigned listIndex) const { return false; }
121 virtual bool itemIsLabel(unsigned listIndex) const { return false; } 126 virtual bool itemIsLabel(unsigned listIndex) const { return false; }
122 virtual bool itemIsSelected(unsigned listIndex) const { return listIndex == m_selectIndex; } 127 virtual bool itemIsSelected(unsigned listIndex) const { return listIndex == m_selectIndex; }
123 virtual void setTextFromItem(unsigned listIndex) { } 128 virtual void provisionalSelectionChanged(unsigned listIndex) { m_indexToSele ctOnCancel = listIndex; }
124 virtual IntRect elementRectRelativeToViewport() const override { return IntR ect(); } 129 virtual IntRect elementRectRelativeToViewport() const override { return IntR ect(); }
125 virtual Element& ownerElement() const override { return *toElement(m_node); } 130 virtual Element& ownerElement() const override { return *toElement(m_node); }
126 virtual ComputedStyle* computedStyleForItem(Element& element) const override { return nullptr; } 131 virtual ComputedStyle* computedStyleForItem(Element& element) const override { return nullptr; }
127 132
128 virtual FontSelector* fontSelector() const { return 0; } 133 virtual FontSelector* fontSelector() const { return 0; }
129 virtual HostWindow* hostWindow() const { return 0; } 134 virtual HostWindow* hostWindow() const { return 0; }
130 135
131 virtual PassRefPtrWillBeRawPtr<Scrollbar> createScrollbar(ScrollableArea*, S crollbarOrientation, ScrollbarControlSize) { return nullptr; } 136 virtual PassRefPtrWillBeRawPtr<Scrollbar> createScrollbar(ScrollableArea*, S crollbarOrientation, ScrollbarControlSize) { return nullptr; }
132 137
133 void setDisabledIndex(unsigned index) { m_disabledIndexSet.insert(index); } 138 void setDisabledIndex(unsigned index) { m_disabledIndexSet.insert(index); }
134 void setFocusedNode(Node* node) { m_node = node; } 139 void setFocusedNode(Node* node) { m_node = node; }
135 void setListSize(int listSize) { m_listSize = listSize; } 140 void setListSize(int listSize) { m_listSize = listSize; }
136 141
137 private: 142 private:
138 unsigned m_selectIndex; 143 unsigned m_selectIndex;
139 std::set<unsigned> m_disabledIndexSet; 144 std::set<unsigned> m_disabledIndexSet;
140 Node* m_node; 145 Node* m_node;
141 int m_listSize; 146 int m_listSize;
147 int m_indexToSelectOnCancel;
142 }; 148 };
143 149
144 class TestWebWidgetClient : public WebWidgetClient { 150 class TestWebWidgetClient : public WebWidgetClient {
145 public: 151 public:
146 ~TestWebWidgetClient() { } 152 ~TestWebWidgetClient() { }
147 virtual WebRect windowRect() { return m_windowRect; } 153 virtual WebRect windowRect() { return m_windowRect; }
148 virtual void setWindowRect(const WebRect& rect) { m_windowRect = rect; } 154 virtual void setWindowRect(const WebRect& rect) { m_windowRect = rect; }
149 private: 155 private:
150 WebRect m_windowRect; 156 WebRect m_windowRect;
151 }; 157 };
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 ASSERT(menuList); 632 ASSERT(menuList);
627 menuList->showPopup(); 633 menuList->showPopup();
628 ASSERT(popupOpen()); 634 ASSERT(popupOpen());
629 PopupListBox* listBox = webView()->selectPopup()->listBox(); 635 PopupListBox* listBox = webView()->selectPopup()->listBox();
630 int ltrWidth = listBox->getRowBaseWidth(0); 636 int ltrWidth = listBox->getRowBaseWidth(0);
631 int rtlWidth = listBox->getRowBaseWidth(1); 637 int rtlWidth = listBox->getRowBaseWidth(1);
632 EXPECT_LT(rtlWidth, ltrWidth); 638 EXPECT_LT(rtlWidth, ltrWidth);
633 } 639 }
634 640
635 } // namespace 641 } // namespace
OLDNEW
« no previous file with comments | « Source/web/PopupMenuImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698