OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 6 #include "base/bind.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
10 #include "base/timer/timer.h" | 10 #include "base/timer/timer.h" |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
571 return reinterpret_cast<const WebInputEvent*>(data); | 571 return reinterpret_cast<const WebInputEvent*>(data); |
572 } | 572 } |
573 | 573 |
574 base::MessageLoopForUI message_loop_; | 574 base::MessageLoopForUI message_loop_; |
575 | 575 |
576 scoped_ptr<TestBrowserContext> browser_context_; | 576 scoped_ptr<TestBrowserContext> browser_context_; |
577 RenderWidgetHostProcess* process_; // Deleted automatically by the widget. | 577 RenderWidgetHostProcess* process_; // Deleted automatically by the widget. |
578 scoped_ptr<MockRenderWidgetHostDelegate> delegate_; | 578 scoped_ptr<MockRenderWidgetHostDelegate> delegate_; |
579 scoped_ptr<MockRenderWidgetHost> host_; | 579 scoped_ptr<MockRenderWidgetHost> host_; |
580 scoped_ptr<TestView> view_; | 580 scoped_ptr<TestView> view_; |
581 scoped_ptr<gfx::Screen> screen_; | |
582 bool handle_key_press_event_; | 581 bool handle_key_press_event_; |
583 bool handle_mouse_event_; | 582 bool handle_mouse_event_; |
584 double last_simulated_event_time_seconds_; | 583 double last_simulated_event_time_seconds_; |
585 double simulated_event_time_delta_seconds_; | 584 double simulated_event_time_delta_seconds_; |
585 #if defined(USE_AURA) | |
586 scoped_ptr<aura::TestScreen> screen_; | |
587 #endif | |
586 | 588 |
587 private: | 589 private: |
588 SyntheticWebTouchEvent touch_event_; | 590 SyntheticWebTouchEvent touch_event_; |
589 | 591 |
590 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostTest); | 592 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostTest); |
591 }; | 593 }; |
592 | 594 |
593 #if GTEST_HAS_PARAM_TEST | 595 #if GTEST_HAS_PARAM_TEST |
594 // RenderWidgetHostWithSourceTest ---------------------------------------------- | 596 // RenderWidgetHostWithSourceTest ---------------------------------------------- |
595 | 597 |
596 // This is for tests that are to be run for all source devices. | 598 // This is for tests that are to be run for all source devices. |
597 class RenderWidgetHostWithSourceTest | 599 class RenderWidgetHostWithSourceTest |
598 : public RenderWidgetHostTest, | 600 : public RenderWidgetHostTest, |
599 public testing::WithParamInterface<WebGestureDevice> {}; | 601 public testing::WithParamInterface<WebGestureDevice> {}; |
600 #endif // GTEST_HAS_PARAM_TEST | 602 #endif // GTEST_HAS_PARAM_TEST |
601 | 603 |
602 } // namespace | 604 } // namespace |
603 | 605 |
604 // ----------------------------------------------------------------------------- | 606 // ----------------------------------------------------------------------------- |
605 | 607 |
606 TEST_F(RenderWidgetHostTest, Resize) { | 608 TEST_F(RenderWidgetHostTest, Resize) { |
607 // The initial bounds is the empty rect, and the screen info hasn't been sent | 609 // The first resize will send over the initial screen info. |
608 // yet, so setting it to the same thing shouldn't send the resize message. | 610 host_->WasResized(); |
611 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); | |
sadrul
2015/04/10 22:58:30
ClearMessages() afterwards before the next block?
mlamouri (slow - plz ping)
2015/04/13 11:39:08
Done.
| |
612 | |
613 // The initial bounds is the empty rect, so setting it to the same thing | |
614 // shouldn't send the resize message. | |
609 view_->set_bounds(gfx::Rect()); | 615 view_->set_bounds(gfx::Rect()); |
610 host_->WasResized(); | 616 host_->WasResized(); |
611 EXPECT_FALSE(host_->resize_ack_pending_); | 617 EXPECT_FALSE(host_->resize_ack_pending_); |
612 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); | 618 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); |
613 | 619 |
614 // No resize ack if the physical backing gets set, but the view bounds are | 620 // No resize ack if the physical backing gets set, but the view bounds are |
615 // zero. | 621 // zero. |
616 view_->SetMockPhysicalBackingSize(gfx::Size(200, 200)); | 622 view_->SetMockPhysicalBackingSize(gfx::Size(200, 200)); |
617 host_->WasResized(); | 623 host_->WasResized(); |
618 EXPECT_FALSE(host_->resize_ack_pending_); | 624 EXPECT_FALSE(host_->resize_ack_pending_); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
712 EXPECT_FALSE(process_->sink().GetFirstMessageMatching(ViewMsg_Resize::ID)); | 718 EXPECT_FALSE(process_->sink().GetFirstMessageMatching(ViewMsg_Resize::ID)); |
713 | 719 |
714 // A different size should be sent again, however. | 720 // A different size should be sent again, however. |
715 view_->set_bounds(gfx::Rect(0, 0, 0, 31)); | 721 view_->set_bounds(gfx::Rect(0, 0, 0, 31)); |
716 host_->WasResized(); | 722 host_->WasResized(); |
717 EXPECT_FALSE(host_->resize_ack_pending_); | 723 EXPECT_FALSE(host_->resize_ack_pending_); |
718 EXPECT_EQ(gfx::Size(0, 31), host_->old_resize_params_->new_size); | 724 EXPECT_EQ(gfx::Size(0, 31), host_->old_resize_params_->new_size); |
719 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); | 725 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); |
720 } | 726 } |
721 | 727 |
728 // Test resize events with screen info changes. | |
729 TEST_F(RenderWidgetHostTest, ResizeScreenInfo) { | |
730 // The first resize will send over the initial screen info. | |
731 host_->WasResized(); | |
732 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); | |
733 | |
734 #if defined(USE_AURA) | |
735 screen_->SetDisplayRotation(gfx::Display::ROTATE_180); | |
736 #endif | |
737 host_->InvalidateScreenInfo(); | |
738 EXPECT_FALSE(host_->resize_ack_pending_); | |
739 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); | |
740 | |
741 #if defined(USE_AURA) | |
742 screen_->SetDisplayRotation(gfx::Display::ROTATE_90); | |
743 #endif | |
744 host_->InvalidateScreenInfo(); | |
745 EXPECT_FALSE(host_->resize_ack_pending_); | |
746 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); | |
747 } | |
748 | |
722 // Test for crbug.com/25097. If a renderer crashes between a resize and the | 749 // Test for crbug.com/25097. If a renderer crashes between a resize and the |
723 // corresponding update message, we must be sure to clear the resize ack logic. | 750 // corresponding update message, we must be sure to clear the resize ack logic. |
724 TEST_F(RenderWidgetHostTest, ResizeThenCrash) { | 751 TEST_F(RenderWidgetHostTest, ResizeThenCrash) { |
725 // Clear the first Resize message that carried screen info. | 752 // Clear the first Resize message that carried screen info. |
726 process_->sink().ClearMessages(); | 753 process_->sink().ClearMessages(); |
727 | 754 |
728 // Setting the bounds to a "real" rect should send out the notification. | 755 // Setting the bounds to a "real" rect should send out the notification. |
729 gfx::Rect original_size(0, 0, 100, 100); | 756 gfx::Rect original_size(0, 0, 100, 100); |
730 view_->set_bounds(original_size); | 757 view_->set_bounds(original_size); |
731 host_->WasResized(); | 758 host_->WasResized(); |
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1493 // Having an initial size set means that the size information had been sent | 1520 // Having an initial size set means that the size information had been sent |
1494 // with the reqiest to new up the RenderView and so subsequent WasResized | 1521 // with the reqiest to new up the RenderView and so subsequent WasResized |
1495 // calls should not result in new IPC (unless the size has actually changed). | 1522 // calls should not result in new IPC (unless the size has actually changed). |
1496 host_->WasResized(); | 1523 host_->WasResized(); |
1497 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); | 1524 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); |
1498 EXPECT_EQ(initial_size_, host_->old_resize_params_->new_size); | 1525 EXPECT_EQ(initial_size_, host_->old_resize_params_->new_size); |
1499 EXPECT_TRUE(host_->resize_ack_pending_); | 1526 EXPECT_TRUE(host_->resize_ack_pending_); |
1500 } | 1527 } |
1501 | 1528 |
1502 } // namespace content | 1529 } // namespace content |
OLD | NEW |