| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/shared_memory.h" | 7 #include "base/shared_memory.h" |
| 8 #include "base/timer.h" | 8 #include "base/timer.h" |
| 9 #include "content/browser/browser_thread.h" | 9 #include "content/browser/browser_thread.h" |
| 10 #include "content/browser/content_browser_client.h" | 10 #include "content/browser/content_browser_client.h" |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 content::NOTIFICATION_RENDER_WIDGET_HOST_DID_RECEIVE_PAINT_AT_SIZE_ACK, | 570 content::NOTIFICATION_RENDER_WIDGET_HOST_DID_RECEIVE_PAINT_AT_SIZE_ACK, |
| 571 Source<RenderWidgetHost>(host_.get())); | 571 Source<RenderWidgetHost>(host_.get())); |
| 572 | 572 |
| 573 host_->OnMsgPaintAtSizeAck(kPaintAtSizeTag, gfx::Size(20, 30)); | 573 host_->OnMsgPaintAtSizeAck(kPaintAtSizeTag, gfx::Size(20, 30)); |
| 574 EXPECT_EQ(host_.get(), observer.host()); | 574 EXPECT_EQ(host_.get(), observer.host()); |
| 575 EXPECT_EQ(kPaintAtSizeTag, observer.tag()); | 575 EXPECT_EQ(kPaintAtSizeTag, observer.tag()); |
| 576 EXPECT_EQ(20, observer.size().width()); | 576 EXPECT_EQ(20, observer.size().width()); |
| 577 EXPECT_EQ(30, observer.size().height()); | 577 EXPECT_EQ(30, observer.size().height()); |
| 578 } | 578 } |
| 579 | 579 |
| 580 TEST_F(RenderWidgetHostTest, HandleKeyEventsWeSent) { | 580 // Fails on Linux Aura, see http://crbug.com/100344 |
| 581 #if defined(USE_AURA) && !defined(OS_WIN) |
| 582 #define MAYBE_HandleKeyEventsWeSent FAILS_HandleKeyEventsWeSent |
| 583 #else |
| 584 #define MAYBE_HandleKeyEventsWeSent HandleKeyEventsWeSent |
| 585 #endif |
| 586 TEST_F(RenderWidgetHostTest, MAYBE_HandleKeyEventsWeSent) { |
| 581 // Simulate a keyboard event. | 587 // Simulate a keyboard event. |
| 582 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); | 588 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); |
| 583 | 589 |
| 584 // Make sure we sent the input event to the renderer. | 590 // Make sure we sent the input event to the renderer. |
| 585 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( | 591 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( |
| 586 ViewMsg_HandleInputEvent::ID)); | 592 ViewMsg_HandleInputEvent::ID)); |
| 587 process_->sink().ClearMessages(); | 593 process_->sink().ClearMessages(); |
| 588 | 594 |
| 589 // Send the simulated response from the renderer back. | 595 // Send the simulated response from the renderer back. |
| 590 SendInputEventACK(WebInputEvent::RawKeyDown, false); | 596 SendInputEventACK(WebInputEvent::RawKeyDown, false); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 607 // Make sure we sent the input event to the renderer. | 613 // Make sure we sent the input event to the renderer. |
| 608 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( | 614 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( |
| 609 ViewMsg_HandleInputEvent::ID)); | 615 ViewMsg_HandleInputEvent::ID)); |
| 610 process_->sink().ClearMessages(); | 616 process_->sink().ClearMessages(); |
| 611 | 617 |
| 612 // Send the simulated response from the renderer back. | 618 // Send the simulated response from the renderer back. |
| 613 SendInputEventACK(WebInputEvent::RawKeyDown, true); | 619 SendInputEventACK(WebInputEvent::RawKeyDown, true); |
| 614 EXPECT_FALSE(host_->unhandled_keyboard_event_called()); | 620 EXPECT_FALSE(host_->unhandled_keyboard_event_called()); |
| 615 } | 621 } |
| 616 | 622 |
| 617 TEST_F(RenderWidgetHostTest, PreHandleRawKeyDownEvent) { | 623 // Fails on Linux Aura, see http://crbug.com/100345 |
| 624 #if defined(USE_AURA) && !defined(OS_WIN) |
| 625 #define MAYBE_PreHandleRawKeyDownEvent FAILS_PreHandleRawKeyDownEvent |
| 626 #else |
| 627 #define MAYBE_PreHandleRawKeyDownEvent PreHandleRawKeyDownEvent |
| 628 #endif |
| 629 TEST_F(RenderWidgetHostTest, MAYBE_PreHandleRawKeyDownEvent) { |
| 618 // Simluate the situation that the browser handled the key down event during | 630 // Simluate the situation that the browser handled the key down event during |
| 619 // pre-handle phrase. | 631 // pre-handle phrase. |
| 620 host_->set_prehandle_keyboard_event(true); | 632 host_->set_prehandle_keyboard_event(true); |
| 621 process_->sink().ClearMessages(); | 633 process_->sink().ClearMessages(); |
| 622 | 634 |
| 623 // Simulate a keyboard event. | 635 // Simulate a keyboard event. |
| 624 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); | 636 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); |
| 625 | 637 |
| 626 EXPECT_TRUE(host_->prehandle_keyboard_event_called()); | 638 EXPECT_TRUE(host_->prehandle_keyboard_event_called()); |
| 627 EXPECT_EQ(WebInputEvent::RawKeyDown, host_->prehandle_keyboard_event_type()); | 639 EXPECT_EQ(WebInputEvent::RawKeyDown, host_->prehandle_keyboard_event_type()); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 // Start it again to ensure it still works. | 733 // Start it again to ensure it still works. |
| 722 EXPECT_FALSE(host_->unresponsive_timer_fired()); | 734 EXPECT_FALSE(host_->unresponsive_timer_fired()); |
| 723 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); | 735 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); |
| 724 | 736 |
| 725 // Wait long enough for first timeout and see if it fired. | 737 // Wait long enough for first timeout and see if it fired. |
| 726 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 738 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 727 new MessageLoop::QuitTask(), 10); | 739 new MessageLoop::QuitTask(), 10); |
| 728 MessageLoop::current()->Run(); | 740 MessageLoop::current()->Run(); |
| 729 EXPECT_TRUE(host_->unresponsive_timer_fired()); | 741 EXPECT_TRUE(host_->unresponsive_timer_fired()); |
| 730 } | 742 } |
| OLD | NEW |