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

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: 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 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 509
510 // RenderWidgetHostView override. 510 // RenderWidgetHostView override.
511 virtual gfx::Rect GetViewBounds() const OVERRIDE { 511 virtual gfx::Rect GetViewBounds() const OVERRIDE {
512 return bounds_; 512 return bounds_;
513 } 513 }
514 virtual void ProcessAckedTouchEvent(const WebTouchEvent& touch, 514 virtual void ProcessAckedTouchEvent(const WebTouchEvent& touch,
515 InputEventAckState ack_result) OVERRIDE { 515 InputEventAckState ack_result) OVERRIDE {
516 acked_event_ = touch; 516 acked_event_ = touch;
517 ++acked_event_count_; 517 ++acked_event_count_;
518 } 518 }
519 virtual gfx::Size GetPhysicalBackingSize() const OVERRIDE {
520 if (use_custom_physical_backing_size_)
521 return custom_physical_backing_size_;
522 return TestRenderWidgetHostView::GetPhysicalBackingSize();
523 }
524
525 void SetCustomPhysicalBackingSize(const gfx::Size& physical_backing_size) {
526 use_custom_physical_backing_size_ = true;
527 custom_physical_backing_size_ = physical_backing_size;
528 }
529
530 void ClearCustomPhysicalBackingSize() {
531 use_custom_physical_backing_size_ = false;
532 }
519 533
520 protected: 534 protected:
521 WebTouchEvent acked_event_; 535 WebTouchEvent acked_event_;
522 int acked_event_count_; 536 int acked_event_count_;
523 gfx::Rect bounds_; 537 gfx::Rect bounds_;
538 bool use_custom_physical_backing_size_;
539 gfx::Size custom_physical_backing_size_;
524 540
525 DISALLOW_COPY_AND_ASSIGN(TestView); 541 DISALLOW_COPY_AND_ASSIGN(TestView);
526 }; 542 };
527 543
528 // MockRenderWidgetHostDelegate -------------------------------------------- 544 // MockRenderWidgetHostDelegate --------------------------------------------
529 545
530 class MockRenderWidgetHostDelegate : public RenderWidgetHostDelegate { 546 class MockRenderWidgetHostDelegate : public RenderWidgetHostDelegate {
531 public: 547 public:
532 MockRenderWidgetHostDelegate() 548 MockRenderWidgetHostDelegate()
533 : prehandle_keyboard_event_(false), 549 : prehandle_keyboard_event_(false),
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 872
857 TEST_F(RenderWidgetHostTest, Resize) { 873 TEST_F(RenderWidgetHostTest, Resize) {
858 // The initial bounds is the empty rect, so setting it to the same thing 874 // The initial bounds is the empty rect, so setting it to the same thing
859 // should do nothing. 875 // should do nothing.
860 view_->set_bounds(gfx::Rect()); 876 view_->set_bounds(gfx::Rect());
861 host_->WasResized(); 877 host_->WasResized();
862 EXPECT_FALSE(host_->resize_ack_pending_); 878 EXPECT_FALSE(host_->resize_ack_pending_);
863 EXPECT_EQ(gfx::Size(), host_->in_flight_size_); 879 EXPECT_EQ(gfx::Size(), host_->in_flight_size_);
864 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); 880 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID));
865 881
866 // Setting the bounds to a "real" rect should send out the notification. 882 // Setting the bounds to a "real" rect should send out the notification,
883 // but should not expect ack for empty physical backing size.
867 gfx::Rect original_size(0, 0, 100, 100); 884 gfx::Rect original_size(0, 0, 100, 100);
868 process_->sink().ClearMessages(); 885 process_->sink().ClearMessages();
869 view_->set_bounds(original_size); 886 view_->set_bounds(original_size);
887 view_->SetCustomPhysicalBackingSize(gfx::Size());
888 host_->WasResized();
889 EXPECT_FALSE(host_->resize_ack_pending_);
890 EXPECT_EQ(original_size.size(), host_->in_flight_size_);
891 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID));
892
893 // Setting the bounds to a "real" rect should send out the notification.
894 process_->sink().ClearMessages();
895 view_->ClearCustomPhysicalBackingSize();
870 host_->WasResized(); 896 host_->WasResized();
871 EXPECT_TRUE(host_->resize_ack_pending_); 897 EXPECT_TRUE(host_->resize_ack_pending_);
872 EXPECT_EQ(original_size.size(), host_->in_flight_size_); 898 EXPECT_EQ(original_size.size(), host_->in_flight_size_);
873 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); 899 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID));
874 900
875 // Send out a update that's not a resize ack. This should not clean the 901 // Send out a update that's not a resize ack. This should not clean the
876 // resize ack pending flag. 902 // resize ack pending flag.
877 ViewHostMsg_UpdateRect_Params params; 903 ViewHostMsg_UpdateRect_Params params;
878 process_->InitUpdateRectParams(&params); 904 process_->InitUpdateRectParams(&params);
879 host_->OnUpdateRect(params); 905 host_->OnUpdateRect(params);
(...skipping 2930 matching lines...) Expand 10 before | Expand all | Expand 10 after
3810 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3836 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3811 3837
3812 // Since the overscroll mode has been reset, the next scroll update events 3838 // Since the overscroll mode has been reset, the next scroll update events
3813 // should reach the renderer. 3839 // should reach the renderer.
3814 SimulateGestureScrollUpdateEvent(-20, 0, 0); 3840 SimulateGestureScrollUpdateEvent(-20, 0, 0);
3815 EXPECT_EQ(1U, process_->sink().message_count()); 3841 EXPECT_EQ(1U, process_->sink().message_count());
3816 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3842 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3817 } 3843 }
3818 3844
3819 } // namespace content 3845 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698