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 "config.h" | 5 #include "config.h" |
6 #include "web/ExternalPopupMenu.h" | 6 #include "web/ExternalPopupMenu.h" |
7 | 7 |
8 #include "core/HTMLNames.h" | 8 #include "core/HTMLNames.h" |
9 #include "core/frame/FrameHost.h" | 9 #include "core/frame/FrameHost.h" |
10 #include "core/frame/PinchViewport.h" | 10 #include "core/frame/PinchViewport.h" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 189 |
190 TEST_F(ExternalPopupMenuTest, PopupAccountsForPinchViewportOffset) | 190 TEST_F(ExternalPopupMenuTest, PopupAccountsForPinchViewportOffset) |
191 { | 191 { |
192 registerMockedURLLoad("select_mid_screen.html"); | 192 registerMockedURLLoad("select_mid_screen.html"); |
193 loadFrame("select_mid_screen.html"); | 193 loadFrame("select_mid_screen.html"); |
194 | 194 |
195 webView()->resize(WebSize(100, 100)); | 195 webView()->resize(WebSize(100, 100)); |
196 webView()->layout(); | 196 webView()->layout(); |
197 | 197 |
198 HTMLSelectElement* select = toHTMLSelectElement(mainFrame()->frame()->docume
nt()->getElementById("select")); | 198 HTMLSelectElement* select = toHTMLSelectElement(mainFrame()->frame()->docume
nt()->getElementById("select")); |
199 LayoutMenuList* menuList = toLayoutMenuList(select->renderer()); | 199 LayoutMenuList* menuList = toLayoutMenuList(select->layoutObject()); |
200 ASSERT_TRUE(menuList); | 200 ASSERT_TRUE(menuList); |
201 | 201 |
202 PinchViewport& pinchViewport = webView()->page()->frameHost().pinchViewport(
); | 202 PinchViewport& pinchViewport = webView()->page()->frameHost().pinchViewport(
); |
203 | 203 |
204 IntRect rectInDocument = menuList->absoluteBoundingBoxRect(); | 204 IntRect rectInDocument = menuList->absoluteBoundingBoxRect(); |
205 | 205 |
206 webView()->setPageScaleFactor(2); | 206 webView()->setPageScaleFactor(2); |
207 IntPoint scrollDelta(20, 30); | 207 IntPoint scrollDelta(20, 30); |
208 pinchViewport.move(scrollDelta); | 208 pinchViewport.move(scrollDelta); |
209 | 209 |
210 menuList->showPopup(); | 210 menuList->showPopup(); |
211 | 211 |
212 EXPECT_EQ(rectInDocument.x() - scrollDelta.x(), client().shownBounds().x); | 212 EXPECT_EQ(rectInDocument.x() - scrollDelta.x(), client().shownBounds().x); |
213 EXPECT_EQ(rectInDocument.y() - scrollDelta.y(), client().shownBounds().y); | 213 EXPECT_EQ(rectInDocument.y() - scrollDelta.y(), client().shownBounds().y); |
214 } | 214 } |
215 | 215 |
216 TEST_F(ExternalPopupMenuTest, DidAcceptIndex) | 216 TEST_F(ExternalPopupMenuTest, DidAcceptIndex) |
217 { | 217 { |
218 registerMockedURLLoad("select.html"); | 218 registerMockedURLLoad("select.html"); |
219 loadFrame("select.html"); | 219 loadFrame("select.html"); |
220 | 220 |
221 HTMLSelectElement* select = toHTMLSelectElement(mainFrame()->frame()->docume
nt()->getElementById("select")); | 221 HTMLSelectElement* select = toHTMLSelectElement(mainFrame()->frame()->docume
nt()->getElementById("select")); |
222 LayoutMenuList* menuList = toLayoutMenuList(select->renderer()); | 222 LayoutMenuList* menuList = toLayoutMenuList(select->layoutObject()); |
223 ASSERT_TRUE(menuList); | 223 ASSERT_TRUE(menuList); |
224 | 224 |
225 menuList->showPopup(); | 225 menuList->showPopup(); |
226 ASSERT_TRUE(menuList->popupIsVisible()); | 226 ASSERT_TRUE(menuList->popupIsVisible()); |
227 | 227 |
228 WebExternalPopupMenuClient* client = static_cast<ExternalPopupMenu*>(menuLis
t->popup()); | 228 WebExternalPopupMenuClient* client = static_cast<ExternalPopupMenu*>(menuLis
t->popup()); |
229 client->didAcceptIndex(2); | 229 client->didAcceptIndex(2); |
230 EXPECT_FALSE(menuList->popupIsVisible()); | 230 EXPECT_FALSE(menuList->popupIsVisible()); |
231 ASSERT_STREQ("2", menuList->text().utf8().data()); | 231 ASSERT_STREQ("2", menuList->text().utf8().data()); |
232 EXPECT_EQ(2, select->selectedIndex()); | 232 EXPECT_EQ(2, select->selectedIndex()); |
233 } | 233 } |
234 | 234 |
235 TEST_F(ExternalPopupMenuTest, DidAcceptIndices) | 235 TEST_F(ExternalPopupMenuTest, DidAcceptIndices) |
236 { | 236 { |
237 registerMockedURLLoad("select.html"); | 237 registerMockedURLLoad("select.html"); |
238 loadFrame("select.html"); | 238 loadFrame("select.html"); |
239 | 239 |
240 HTMLSelectElement* select = toHTMLSelectElement(mainFrame()->frame()->docume
nt()->getElementById("select")); | 240 HTMLSelectElement* select = toHTMLSelectElement(mainFrame()->frame()->docume
nt()->getElementById("select")); |
241 LayoutMenuList* menuList = toLayoutMenuList(select->renderer()); | 241 LayoutMenuList* menuList = toLayoutMenuList(select->layoutObject()); |
242 ASSERT_TRUE(menuList); | 242 ASSERT_TRUE(menuList); |
243 | 243 |
244 menuList->showPopup(); | 244 menuList->showPopup(); |
245 ASSERT_TRUE(menuList->popupIsVisible()); | 245 ASSERT_TRUE(menuList->popupIsVisible()); |
246 | 246 |
247 WebExternalPopupMenuClient* client = static_cast<ExternalPopupMenu*>(menuLis
t->popup()); | 247 WebExternalPopupMenuClient* client = static_cast<ExternalPopupMenu*>(menuLis
t->popup()); |
248 int indices[] = { 2 }; | 248 int indices[] = { 2 }; |
249 WebVector<int> indicesVector(indices, 1); | 249 WebVector<int> indicesVector(indices, 1); |
250 client->didAcceptIndices(indicesVector); | 250 client->didAcceptIndices(indicesVector); |
251 EXPECT_FALSE(menuList->popupIsVisible()); | 251 EXPECT_FALSE(menuList->popupIsVisible()); |
252 EXPECT_STREQ("2", menuList->text().utf8().data()); | 252 EXPECT_STREQ("2", menuList->text().utf8().data()); |
253 EXPECT_EQ(2, select->selectedIndex()); | 253 EXPECT_EQ(2, select->selectedIndex()); |
254 } | 254 } |
255 | 255 |
256 TEST_F(ExternalPopupMenuTest, DidAcceptIndicesClearSelect) | 256 TEST_F(ExternalPopupMenuTest, DidAcceptIndicesClearSelect) |
257 { | 257 { |
258 registerMockedURLLoad("select.html"); | 258 registerMockedURLLoad("select.html"); |
259 loadFrame("select.html"); | 259 loadFrame("select.html"); |
260 | 260 |
261 HTMLSelectElement* select = toHTMLSelectElement(mainFrame()->frame()->docume
nt()->getElementById("select")); | 261 HTMLSelectElement* select = toHTMLSelectElement(mainFrame()->frame()->docume
nt()->getElementById("select")); |
262 LayoutMenuList* menuList = toLayoutMenuList(select->renderer()); | 262 LayoutMenuList* menuList = toLayoutMenuList(select->layoutObject()); |
263 ASSERT_TRUE(menuList); | 263 ASSERT_TRUE(menuList); |
264 | 264 |
265 menuList->showPopup(); | 265 menuList->showPopup(); |
266 ASSERT_TRUE(menuList->popupIsVisible()); | 266 ASSERT_TRUE(menuList->popupIsVisible()); |
267 | 267 |
268 WebExternalPopupMenuClient* client = static_cast<ExternalPopupMenu*>(menuLis
t->popup()); | 268 WebExternalPopupMenuClient* client = static_cast<ExternalPopupMenu*>(menuLis
t->popup()); |
269 WebVector<int> indices; | 269 WebVector<int> indices; |
270 client->didAcceptIndices(indices); | 270 client->didAcceptIndices(indices); |
271 EXPECT_FALSE(menuList->popupIsVisible()); | 271 EXPECT_FALSE(menuList->popupIsVisible()); |
272 EXPECT_EQ(-1, select->selectedIndex()); | 272 EXPECT_EQ(-1, select->selectedIndex()); |
273 } | 273 } |
274 | 274 |
275 } // namespace | 275 } // namespace |
OLD | NEW |