OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "web/ExternalPopupMenu.h" | 5 #include "web/ExternalPopupMenu.h" |
6 | 6 |
7 #include "core/HTMLNames.h" | 7 #include "core/HTMLNames.h" |
8 #include "core/dom/NodeComputedStyle.h" | 8 #include "core/dom/NodeComputedStyle.h" |
9 #include "core/frame/FrameHost.h" | 9 #include "core/frame/FrameHost.h" |
10 #include "core/frame/VisualViewport.h" | 10 #include "core/frame/VisualViewport.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 mainFrame()->frame()->document()->getElementById("select")); | 151 mainFrame()->frame()->document()->getElementById("select")); |
152 LayoutMenuList* menuList = toLayoutMenuList(select->layoutObject()); | 152 LayoutMenuList* menuList = toLayoutMenuList(select->layoutObject()); |
153 ASSERT_TRUE(menuList); | 153 ASSERT_TRUE(menuList); |
154 | 154 |
155 VisualViewport& visualViewport = | 155 VisualViewport& visualViewport = |
156 webView()->page()->frameHost().visualViewport(); | 156 webView()->page()->frameHost().visualViewport(); |
157 | 157 |
158 IntRect rectInDocument = menuList->absoluteBoundingBoxRect(); | 158 IntRect rectInDocument = menuList->absoluteBoundingBoxRect(); |
159 | 159 |
160 webView()->setPageScaleFactor(2); | 160 webView()->setPageScaleFactor(2); |
161 IntPoint scrollDelta(20, 30); | 161 ScrollOffset scrollDelta(20, 30); |
162 visualViewport.move(scrollDelta); | 162 visualViewport.move(scrollDelta); |
163 | 163 |
164 select->showPopup(); | 164 select->showPopup(); |
165 | 165 |
166 EXPECT_EQ(rectInDocument.x() - scrollDelta.x(), client().shownBounds().x); | 166 EXPECT_EQ(rectInDocument.x() - scrollDelta.width(), client().shownBounds().x); |
167 EXPECT_EQ(rectInDocument.y() - scrollDelta.y(), client().shownBounds().y); | 167 EXPECT_EQ(rectInDocument.y() - scrollDelta.height(), |
| 168 client().shownBounds().y); |
168 } | 169 } |
169 | 170 |
170 TEST_F(ExternalPopupMenuTest, DidAcceptIndex) { | 171 TEST_F(ExternalPopupMenuTest, DidAcceptIndex) { |
171 registerMockedURLLoad("select.html"); | 172 registerMockedURLLoad("select.html"); |
172 loadFrame("select.html"); | 173 loadFrame("select.html"); |
173 | 174 |
174 HTMLSelectElement* select = toHTMLSelectElement( | 175 HTMLSelectElement* select = toHTMLSelectElement( |
175 mainFrame()->frame()->document()->getElementById("select")); | 176 mainFrame()->frame()->document()->getElementById("select")); |
176 LayoutMenuList* menuList = toLayoutMenuList(select->layoutObject()); | 177 LayoutMenuList* menuList = toLayoutMenuList(select->layoutObject()); |
177 ASSERT_TRUE(menuList); | 178 ASSERT_TRUE(menuList); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 224 |
224 WebExternalPopupMenuClient* client = | 225 WebExternalPopupMenuClient* client = |
225 static_cast<ExternalPopupMenu*>(select->popup()); | 226 static_cast<ExternalPopupMenu*>(select->popup()); |
226 WebVector<int> indices; | 227 WebVector<int> indices; |
227 client->didAcceptIndices(indices); | 228 client->didAcceptIndices(indices); |
228 EXPECT_FALSE(select->popupIsVisible()); | 229 EXPECT_FALSE(select->popupIsVisible()); |
229 EXPECT_EQ(-1, select->selectedIndex()); | 230 EXPECT_EQ(-1, select->selectedIndex()); |
230 } | 231 } |
231 | 232 |
232 } // namespace blink | 233 } // namespace blink |
OLD | NEW |