Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(424)

Side by Side Diff: content/browser/renderer_host/render_widget_host_unittest.cc

Issue 14779010: Don't expect ack for ViewMsg_OnResize if backing size is empty (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Keep short_circuit_size_update condition Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/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_impl.h" 9 #include "content/browser/browser_thread_impl.h"
10 #include "content/browser/renderer_host/backing_store.h" 10 #include "content/browser/renderer_host/backing_store.h"
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 } 485 }
486 486
487 // TestView -------------------------------------------------------------------- 487 // TestView --------------------------------------------------------------------
488 488
489 // This test view allows us to specify the size, and keep track of acked 489 // This test view allows us to specify the size, and keep track of acked
490 // touch-events. 490 // touch-events.
491 class TestView : public TestRenderWidgetHostView { 491 class TestView : public TestRenderWidgetHostView {
492 public: 492 public:
493 explicit TestView(RenderWidgetHostImpl* rwh) 493 explicit TestView(RenderWidgetHostImpl* rwh)
494 : TestRenderWidgetHostView(rwh), 494 : TestRenderWidgetHostView(rwh),
495 acked_event_count_(0) { 495 acked_event_count_(0),
496 use_fake_physical_backing_size_(false) {
496 } 497 }
497 498
498 // Sets the bounds returned by GetViewBounds. 499 // Sets the bounds returned by GetViewBounds.
499 void set_bounds(const gfx::Rect& bounds) { 500 void set_bounds(const gfx::Rect& bounds) {
500 bounds_ = bounds; 501 bounds_ = bounds;
501 } 502 }
502 503
503 const WebTouchEvent& acked_event() const { return acked_event_; } 504 const WebTouchEvent& acked_event() const { return acked_event_; }
504 int acked_event_count() const { return acked_event_count_; } 505 int acked_event_count() const { return acked_event_count_; }
505 void ClearAckedEvent() { 506 void ClearAckedEvent() {
506 acked_event_.type = WebKit::WebInputEvent::Undefined; 507 acked_event_.type = WebKit::WebInputEvent::Undefined;
507 acked_event_count_ = 0; 508 acked_event_count_ = 0;
508 } 509 }
509 510
510 const WebMouseWheelEvent& unhandled_wheel_event() const { 511 const WebMouseWheelEvent& unhandled_wheel_event() const {
511 return unhandled_wheel_event_; 512 return unhandled_wheel_event_;
512 } 513 }
513 514
515 void SetMockPhysicalBackingSize(const gfx::Size& mock_physical_backing_size) {
516 use_fake_physical_backing_size_ = true;
517 mock_physical_backing_size_ = mock_physical_backing_size;
518 }
519 void ClearMockPhysicalBackingSize() {
520 use_fake_physical_backing_size_ = false;
521 }
522
514 // RenderWidgetHostView override. 523 // RenderWidgetHostView override.
515 virtual gfx::Rect GetViewBounds() const OVERRIDE { 524 virtual gfx::Rect GetViewBounds() const OVERRIDE {
516 return bounds_; 525 return bounds_;
517 } 526 }
518 virtual void ProcessAckedTouchEvent(const WebTouchEvent& touch, 527 virtual void ProcessAckedTouchEvent(const WebTouchEvent& touch,
519 InputEventAckState ack_result) OVERRIDE { 528 InputEventAckState ack_result) OVERRIDE {
520 acked_event_ = touch; 529 acked_event_ = touch;
521 ++acked_event_count_; 530 ++acked_event_count_;
522 } 531 }
523 virtual void UnhandledWheelEvent(const WebMouseWheelEvent& event) OVERRIDE { 532 virtual void UnhandledWheelEvent(const WebMouseWheelEvent& event) OVERRIDE {
524 unhandled_wheel_event_ = event; 533 unhandled_wheel_event_ = event;
525 } 534 }
535 virtual gfx::Size GetPhysicalBackingSize() const OVERRIDE {
536 if (use_fake_physical_backing_size_)
537 return mock_physical_backing_size_;
538 return TestRenderWidgetHostView::GetPhysicalBackingSize();
539 }
526 540
527 protected: 541 protected:
528 WebMouseWheelEvent unhandled_wheel_event_; 542 WebMouseWheelEvent unhandled_wheel_event_;
529 WebTouchEvent acked_event_; 543 WebTouchEvent acked_event_;
530 int acked_event_count_; 544 int acked_event_count_;
531 gfx::Rect bounds_; 545 gfx::Rect bounds_;
546 bool use_fake_physical_backing_size_;
547 gfx::Size mock_physical_backing_size_;
532 548
533 DISALLOW_COPY_AND_ASSIGN(TestView); 549 DISALLOW_COPY_AND_ASSIGN(TestView);
534 }; 550 };
535 551
536 // MockRenderWidgetHostDelegate -------------------------------------------- 552 // MockRenderWidgetHostDelegate --------------------------------------------
537 553
538 class MockRenderWidgetHostDelegate : public RenderWidgetHostDelegate { 554 class MockRenderWidgetHostDelegate : public RenderWidgetHostDelegate {
539 public: 555 public:
540 MockRenderWidgetHostDelegate() 556 MockRenderWidgetHostDelegate()
541 : prehandle_keyboard_event_(false), 557 : prehandle_keyboard_event_(false),
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 880
865 TEST_F(RenderWidgetHostTest, Resize) { 881 TEST_F(RenderWidgetHostTest, Resize) {
866 // The initial bounds is the empty rect, so setting it to the same thing 882 // The initial bounds is the empty rect, so setting it to the same thing
867 // should do nothing. 883 // should do nothing.
868 view_->set_bounds(gfx::Rect()); 884 view_->set_bounds(gfx::Rect());
869 host_->WasResized(); 885 host_->WasResized();
870 EXPECT_FALSE(host_->resize_ack_pending_); 886 EXPECT_FALSE(host_->resize_ack_pending_);
871 EXPECT_EQ(gfx::Size(), host_->in_flight_size_); 887 EXPECT_EQ(gfx::Size(), host_->in_flight_size_);
872 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); 888 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID));
873 889
874 // Setting the bounds to a "real" rect should send out the notification. 890 // Setting the bounds to a "real" rect should send out the notification,
891 // but should not expect ack for empty physical backing size.
875 gfx::Rect original_size(0, 0, 100, 100); 892 gfx::Rect original_size(0, 0, 100, 100);
876 process_->sink().ClearMessages(); 893 process_->sink().ClearMessages();
877 view_->set_bounds(original_size); 894 view_->set_bounds(original_size);
895 view_->SetMockPhysicalBackingSize(gfx::Size());
896 host_->WasResized();
897 EXPECT_FALSE(host_->resize_ack_pending_);
898 EXPECT_EQ(original_size.size(), host_->in_flight_size_);
899 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID));
900
901 // Setting the bounds to a "real" rect should send out the notification.
902 process_->sink().ClearMessages();
903 view_->ClearMockPhysicalBackingSize();
878 host_->WasResized(); 904 host_->WasResized();
879 EXPECT_TRUE(host_->resize_ack_pending_); 905 EXPECT_TRUE(host_->resize_ack_pending_);
880 EXPECT_EQ(original_size.size(), host_->in_flight_size_); 906 EXPECT_EQ(original_size.size(), host_->in_flight_size_);
881 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); 907 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID));
882 908
883 // Send out a update that's not a resize ack. This should not clean the 909 // Send out a update that's not a resize ack. This should not clean the
884 // resize ack pending flag. 910 // resize ack pending flag.
885 ViewHostMsg_UpdateRect_Params params; 911 ViewHostMsg_UpdateRect_Params params;
886 process_->InitUpdateRectParams(&params); 912 process_->InitUpdateRectParams(&params);
887 host_->OnUpdateRect(params); 913 host_->OnUpdateRect(params);
(...skipping 2957 matching lines...) Expand 10 before | Expand all | Expand 10 after
3845 EXPECT_EQ(1U, process_->sink().message_count()); 3871 EXPECT_EQ(1U, process_->sink().message_count());
3846 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( 3872 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(
3847 InputMsg_HandleInputEvent::ID)); 3873 InputMsg_HandleInputEvent::ID));
3848 process_->sink().ClearMessages(); 3874 process_->sink().ClearMessages();
3849 3875
3850 // Check that the correct unhandled wheel event was received. 3876 // Check that the correct unhandled wheel event was received.
3851 EXPECT_EQ(view_->unhandled_wheel_event().deltaY, -5); 3877 EXPECT_EQ(view_->unhandled_wheel_event().deltaY, -5);
3852 } 3878 }
3853 3879
3854 } // namespace content 3880 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698