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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 SelectPopupMenuTest() | 180 SelectPopupMenuTest() |
181 : baseURL("http://www.test.com/") | 181 : baseURL("http://www.test.com/") |
182 { | 182 { |
183 } | 183 } |
184 | 184 |
185 protected: | 185 protected: |
186 virtual void SetUp() | 186 virtual void SetUp() |
187 { | 187 { |
188 m_webView = toWebViewImpl(WebView::create(&m_webviewClient)); | 188 m_webView = toWebViewImpl(WebView::create(&m_webviewClient)); |
189 m_webView->initializeMainFrame(&m_webFrameClient); | 189 m_webView->initializeMainFrame(&m_webFrameClient); |
190 m_popupMenu = adoptRef(new PopupMenuChromium(*static_cast<WebFrameImpl*>
(m_webView->mainFrame())->frame(), &m_popupMenuClient)); | 190 m_popupMenu = adoptRef(new PopupMenuChromium(*toWebFrameImpl(m_webView->
mainFrame())->frame(), &m_popupMenuClient)); |
191 } | 191 } |
192 | 192 |
193 virtual void TearDown() | 193 virtual void TearDown() |
194 { | 194 { |
195 m_popupMenu = 0; | 195 m_popupMenu = 0; |
196 m_webView->close(); | 196 m_webView->close(); |
197 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); | 197 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); |
198 } | 198 } |
199 | 199 |
200 // Returns true if there currently is a select popup in the WebView. | 200 // Returns true if there currently is a select popup in the WebView. |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 EXPECT_EQ(2, selectedIndex()); | 400 EXPECT_EQ(2, selectedIndex()); |
401 } | 401 } |
402 | 402 |
403 TEST_F(SelectPopupMenuTest, DISABLED_SelectItemEventFire) | 403 TEST_F(SelectPopupMenuTest, DISABLED_SelectItemEventFire) |
404 { | 404 { |
405 registerMockedURLLoad("select_event.html"); | 405 registerMockedURLLoad("select_event.html"); |
406 m_webView->settings()->setJavaScriptEnabled(true); | 406 m_webView->settings()->setJavaScriptEnabled(true); |
407 loadFrame(m_webView->mainFrame(), "select_event.html"); | 407 loadFrame(m_webView->mainFrame(), "select_event.html"); |
408 serveRequests(); | 408 serveRequests(); |
409 | 409 |
410 m_popupMenuClient.setFocusedNode(static_cast<WebFrameImpl*>(m_webView->mainF
rame())->frameView()->frame()->document()->focusedElement()); | 410 m_popupMenuClient.setFocusedNode(toWebFrameImpl(m_webView->mainFrame())->fra
meView()->frame()->document()->focusedElement()); |
411 | 411 |
412 showPopup(); | 412 showPopup(); |
413 | 413 |
414 int menuItemHeight = m_webView->selectPopup()->menuItemHeight(); | 414 int menuItemHeight = m_webView->selectPopup()->menuItemHeight(); |
415 // menuItemHeight * 0.5 means the Y position on the item at index 0. | 415 // menuItemHeight * 0.5 means the Y position on the item at index 0. |
416 IntPoint row1Point(2, menuItemHeight * 0.5); | 416 IntPoint row1Point(2, menuItemHeight * 0.5); |
417 simulateLeftMouseDownEvent(row1Point); | 417 simulateLeftMouseDownEvent(row1Point); |
418 simulateLeftMouseUpEvent(row1Point); | 418 simulateLeftMouseUpEvent(row1Point); |
419 | 419 |
420 WebElement element = m_webView->mainFrame()->document().getElementById("mess
age"); | 420 WebElement element = m_webView->mainFrame()->document().getElementById("mess
age"); |
(...skipping 24 matching lines...) Expand all Loading... |
445 EXPECT_STREQ("upclickchangeupclick", element.innerText().utf8().data()); | 445 EXPECT_STREQ("upclickchangeupclick", element.innerText().utf8().data()); |
446 } | 446 } |
447 | 447 |
448 TEST_F(SelectPopupMenuTest, FLAKY_SelectItemKeyEvent) | 448 TEST_F(SelectPopupMenuTest, FLAKY_SelectItemKeyEvent) |
449 { | 449 { |
450 registerMockedURLLoad("select_event.html"); | 450 registerMockedURLLoad("select_event.html"); |
451 m_webView->settings()->setJavaScriptEnabled(true); | 451 m_webView->settings()->setJavaScriptEnabled(true); |
452 loadFrame(m_webView->mainFrame(), "select_event.html"); | 452 loadFrame(m_webView->mainFrame(), "select_event.html"); |
453 serveRequests(); | 453 serveRequests(); |
454 | 454 |
455 m_popupMenuClient.setFocusedNode(static_cast<WebFrameImpl*>(m_webView->mainF
rame())->frameView()->frame()->document()->focusedElement()); | 455 m_popupMenuClient.setFocusedNode(toWebFrameImpl(m_webView->mainFrame())->fra
meView()->frame()->document()->focusedElement()); |
456 | 456 |
457 showPopup(); | 457 showPopup(); |
458 | 458 |
459 // Siumulate to choose the item at index 1 with keyboard. | 459 // Siumulate to choose the item at index 1 with keyboard. |
460 simulateKeyDownEvent(VKEY_DOWN); | 460 simulateKeyDownEvent(VKEY_DOWN); |
461 simulateKeyDownEvent(VKEY_DOWN); | 461 simulateKeyDownEvent(VKEY_DOWN); |
462 simulateKeyDownEvent(VKEY_RETURN); | 462 simulateKeyDownEvent(VKEY_RETURN); |
463 | 463 |
464 WebElement element = m_webView->mainFrame()->document().getElementById("mess
age"); | 464 WebElement element = m_webView->mainFrame()->document().getElementById("mess
age"); |
465 // We only can see change event but no other mouse related events. | 465 // We only can see change event but no other mouse related events. |
466 EXPECT_STREQ("change", element.innerText().utf8().data()); | 466 EXPECT_STREQ("change", element.innerText().utf8().data()); |
467 } | 467 } |
468 | 468 |
469 TEST_F(SelectPopupMenuTest, SelectItemRemoveSelectOnChange) | 469 TEST_F(SelectPopupMenuTest, SelectItemRemoveSelectOnChange) |
470 { | 470 { |
471 // Make sure no crash, even if select node is removed on 'change' event hand
ler. | 471 // Make sure no crash, even if select node is removed on 'change' event hand
ler. |
472 registerMockedURLLoad("select_event_remove_on_change.html"); | 472 registerMockedURLLoad("select_event_remove_on_change.html"); |
473 m_webView->settings()->setJavaScriptEnabled(true); | 473 m_webView->settings()->setJavaScriptEnabled(true); |
474 loadFrame(m_webView->mainFrame(), "select_event_remove_on_change.html"); | 474 loadFrame(m_webView->mainFrame(), "select_event_remove_on_change.html"); |
475 serveRequests(); | 475 serveRequests(); |
476 | 476 |
477 m_popupMenuClient.setFocusedNode(static_cast<WebFrameImpl*>(m_webView->mainF
rame())->frameView()->frame()->document()->focusedElement()); | 477 m_popupMenuClient.setFocusedNode(toWebFrameImpl(m_webView->mainFrame())->fra
meView()->frame()->document()->focusedElement()); |
478 | 478 |
479 showPopup(); | 479 showPopup(); |
480 | 480 |
481 int menuItemHeight = m_webView->selectPopup()->menuItemHeight(); | 481 int menuItemHeight = m_webView->selectPopup()->menuItemHeight(); |
482 // menuItemHeight * 1.5 means the Y position on the item at index 1. | 482 // menuItemHeight * 1.5 means the Y position on the item at index 1. |
483 IntPoint row1Point(2, menuItemHeight * 1.5); | 483 IntPoint row1Point(2, menuItemHeight * 1.5); |
484 simulateLeftMouseDownEvent(row1Point); | 484 simulateLeftMouseDownEvent(row1Point); |
485 simulateLeftMouseUpEvent(row1Point); | 485 simulateLeftMouseUpEvent(row1Point); |
486 | 486 |
487 WebElement element = m_webView->mainFrame()->document().getElementById("mess
age"); | 487 WebElement element = m_webView->mainFrame()->document().getElementById("mess
age"); |
488 EXPECT_STREQ("change", element.innerText().utf8().data()); | 488 EXPECT_STREQ("change", element.innerText().utf8().data()); |
489 } | 489 } |
490 | 490 |
491 TEST_F(SelectPopupMenuTest, SelectItemRemoveSelectOnClick) | 491 TEST_F(SelectPopupMenuTest, SelectItemRemoveSelectOnClick) |
492 { | 492 { |
493 // Make sure no crash, even if select node is removed on 'click' event handl
er. | 493 // Make sure no crash, even if select node is removed on 'click' event handl
er. |
494 registerMockedURLLoad("select_event_remove_on_click.html"); | 494 registerMockedURLLoad("select_event_remove_on_click.html"); |
495 m_webView->settings()->setJavaScriptEnabled(true); | 495 m_webView->settings()->setJavaScriptEnabled(true); |
496 loadFrame(m_webView->mainFrame(), "select_event_remove_on_click.html"); | 496 loadFrame(m_webView->mainFrame(), "select_event_remove_on_click.html"); |
497 serveRequests(); | 497 serveRequests(); |
498 | 498 |
499 m_popupMenuClient.setFocusedNode(static_cast<WebFrameImpl*>(m_webView->mainF
rame())->frameView()->frame()->document()->focusedElement()); | 499 m_popupMenuClient.setFocusedNode(toWebFrameImpl(m_webView->mainFrame())->fra
meView()->frame()->document()->focusedElement()); |
500 | 500 |
501 showPopup(); | 501 showPopup(); |
502 | 502 |
503 int menuItemHeight = m_webView->selectPopup()->menuItemHeight(); | 503 int menuItemHeight = m_webView->selectPopup()->menuItemHeight(); |
504 // menuItemHeight * 1.5 means the Y position on the item at index 1. | 504 // menuItemHeight * 1.5 means the Y position on the item at index 1. |
505 IntPoint row1Point(2, menuItemHeight * 1.5); | 505 IntPoint row1Point(2, menuItemHeight * 1.5); |
506 simulateLeftMouseDownEvent(row1Point); | 506 simulateLeftMouseDownEvent(row1Point); |
507 simulateLeftMouseUpEvent(row1Point); | 507 simulateLeftMouseUpEvent(row1Point); |
508 | 508 |
509 WebElement element = m_webView->mainFrame()->document().getElementById("mess
age"); | 509 WebElement element = m_webView->mainFrame()->document().getElementById("mess
age"); |
510 EXPECT_STREQ("click", element.innerText().utf8().data()); | 510 EXPECT_STREQ("click", element.innerText().utf8().data()); |
511 } | 511 } |
512 | 512 |
513 } // namespace | 513 } // namespace |
OLD | NEW |