OLD | NEW |
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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 WebKeyboardEvent keyEvent; | 233 WebKeyboardEvent keyEvent; |
234 keyEvent.windowsKeyCode = keyCode; | 234 keyEvent.windowsKeyCode = keyCode; |
235 keyEvent.type = eventType; | 235 keyEvent.type = eventType; |
236 webView()->handleInputEvent(keyEvent); | 236 webView()->handleInputEvent(keyEvent); |
237 } | 237 } |
238 | 238 |
239 // Simulates a mouse event on the select popup. | 239 // Simulates a mouse event on the select popup. |
240 void simulateLeftMouseDownEvent(const IntPoint& point) | 240 void simulateLeftMouseDownEvent(const IntPoint& point) |
241 { | 241 { |
242 PlatformMouseEvent mouseEvent(point, point, LeftButton, PlatformEvent::M
ousePressed, | 242 PlatformMouseEvent mouseEvent(point, point, LeftButton, PlatformEvent::M
ousePressed, |
243 1, false, false, false, false, 0); | 243 1, false, false, false, false, PlatformMouseEvent::RealOrIndistingui
shable, 0); |
244 webView()->selectPopup()->handleMouseDownEvent(mouseEvent); | 244 webView()->selectPopup()->handleMouseDownEvent(mouseEvent); |
245 } | 245 } |
246 void simulateLeftMouseUpEvent(const IntPoint& point) | 246 void simulateLeftMouseUpEvent(const IntPoint& point) |
247 { | 247 { |
248 PlatformMouseEvent mouseEvent(point, point, LeftButton, PlatformEvent::M
ouseReleased, | 248 PlatformMouseEvent mouseEvent(point, point, LeftButton, PlatformEvent::M
ouseReleased, |
249 1, false, false, false, false, 0); | 249 1, false, false, false, false, PlatformMouseEvent::RealOrIndistingui
shable, 0); |
250 webView()->selectPopup()->handleMouseReleaseEvent(mouseEvent); | 250 webView()->selectPopup()->handleMouseReleaseEvent(mouseEvent); |
251 } | 251 } |
252 | 252 |
253 void registerMockedURLLoad(const std::string& fileName) | 253 void registerMockedURLLoad(const std::string& fileName) |
254 { | 254 { |
255 URLTestHelpers::registerMockedURLLoad(toKURL(baseURL + fileName), WebStr
ing::fromUTF8(fileName.c_str()), WebString::fromUTF8("popup/"), WebString::fromU
TF8("text/html")); | 255 URLTestHelpers::registerMockedURLLoad(toKURL(baseURL + fileName), WebStr
ing::fromUTF8(fileName.c_str()), WebString::fromUTF8("popup/"), WebString::fromU
TF8("text/html")); |
256 } | 256 } |
257 | 257 |
258 void loadFrame(WebFrame* frame, const std::string& fileName) | 258 void loadFrame(WebFrame* frame, const std::string& fileName) |
259 { | 259 { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 // leaves the seleted item unchanged. | 361 // leaves the seleted item unchanged. |
362 TEST_F(SelectPopupMenuTest, MouseOverItemClickOutside) | 362 TEST_F(SelectPopupMenuTest, MouseOverItemClickOutside) |
363 { | 363 { |
364 showPopup(); | 364 showPopup(); |
365 | 365 |
366 int menuItemHeight = webView()->selectPopup()->menuItemHeight(); | 366 int menuItemHeight = webView()->selectPopup()->menuItemHeight(); |
367 // menuItemHeight * 1.5 means the Y position on the item at index 1. | 367 // menuItemHeight * 1.5 means the Y position on the item at index 1. |
368 IntPoint row1Point(2, menuItemHeight * 1.5); | 368 IntPoint row1Point(2, menuItemHeight * 1.5); |
369 // Simulate the mouse moving over the first item. | 369 // Simulate the mouse moving over the first item. |
370 PlatformMouseEvent mouseEvent(row1Point, row1Point, NoButton, PlatformEvent:
:MouseMoved, | 370 PlatformMouseEvent mouseEvent(row1Point, row1Point, NoButton, PlatformEvent:
:MouseMoved, |
371 1, false, false, false, false, 0); | 371 1, false, false, false, false, PlatformMouseEvent::RealOrIndistinguishab
le, 0); |
372 webView()->selectPopup()->handleMouseMoveEvent(mouseEvent); | 372 webView()->selectPopup()->handleMouseMoveEvent(mouseEvent); |
373 | 373 |
374 // Click outside the popup. | 374 // Click outside the popup. |
375 simulateLeftMouseDownEvent(IntPoint(1000, 1000)); | 375 simulateLeftMouseDownEvent(IntPoint(1000, 1000)); |
376 | 376 |
377 // Popup should have closed and item 0 should still be selected. | 377 // Popup should have closed and item 0 should still be selected. |
378 EXPECT_FALSE(popupOpen()); | 378 EXPECT_FALSE(popupOpen()); |
379 EXPECT_EQ(0, selectedIndex()); | 379 EXPECT_EQ(0, selectedIndex()); |
380 } | 380 } |
381 | 381 |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 ASSERT(menuList); | 604 ASSERT(menuList); |
605 menuList->showPopup(); | 605 menuList->showPopup(); |
606 ASSERT(popupOpen()); | 606 ASSERT(popupOpen()); |
607 PopupListBox* listBox = webView()->selectPopup()->listBox(); | 607 PopupListBox* listBox = webView()->selectPopup()->listBox(); |
608 int ltrWidth = listBox->getRowBaseWidth(0); | 608 int ltrWidth = listBox->getRowBaseWidth(0); |
609 int rtlWidth = listBox->getRowBaseWidth(1); | 609 int rtlWidth = listBox->getRowBaseWidth(1); |
610 EXPECT_LT(rtlWidth, ltrWidth); | 610 EXPECT_LT(rtlWidth, ltrWidth); |
611 } | 611 } |
612 | 612 |
613 } // namespace | 613 } // namespace |
OLD | NEW |