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 "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "chrome/test/testing_profile.h" | 10 #include "chrome/test/testing_profile.h" |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 class MockPaintingObserver : public NotificationObserver { | 212 class MockPaintingObserver : public NotificationObserver { |
213 public: | 213 public: |
214 void WidgetDidReceivePaintAtSizeAck(RenderWidgetHost* host, | 214 void WidgetDidReceivePaintAtSizeAck(RenderWidgetHost* host, |
215 int tag, | 215 int tag, |
216 const gfx::Size& size) { | 216 const gfx::Size& size) { |
217 host_ = reinterpret_cast<MockRenderWidgetHost*>(host); | 217 host_ = reinterpret_cast<MockRenderWidgetHost*>(host); |
218 tag_ = tag; | 218 tag_ = tag; |
219 size_ = size; | 219 size_ = size; |
220 } | 220 } |
221 | 221 |
222 void Observe(NotificationType type, | 222 void Observe(int type, |
223 const NotificationSource& source, | 223 const NotificationSource& source, |
224 const NotificationDetails& details) { | 224 const NotificationDetails& details) { |
225 if (type == | 225 if (type == |
226 NotificationType::RENDER_WIDGET_HOST_DID_RECEIVE_PAINT_AT_SIZE_ACK) { | 226 content::NOTIFICATION_RENDER_WIDGET_HOST_DID_RECEIVE_PAINT_AT_SIZE_ACK)
{ |
227 RenderWidgetHost::PaintAtSizeAckDetails* size_ack_details = | 227 RenderWidgetHost::PaintAtSizeAckDetails* size_ack_details = |
228 Details<RenderWidgetHost::PaintAtSizeAckDetails>(details).ptr(); | 228 Details<RenderWidgetHost::PaintAtSizeAckDetails>(details).ptr(); |
229 WidgetDidReceivePaintAtSizeAck( | 229 WidgetDidReceivePaintAtSizeAck( |
230 Source<RenderWidgetHost>(source).ptr(), | 230 Source<RenderWidgetHost>(source).ptr(), |
231 size_ack_details->tag, | 231 size_ack_details->tag, |
232 size_ack_details->size); | 232 size_ack_details->size); |
233 } | 233 } |
234 } | 234 } |
235 | 235 |
236 MockRenderWidgetHost* host() const { return host_; } | 236 MockRenderWidgetHost* host() const { return host_; } |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 const int kPaintAtSizeTag = 42; | 567 const int kPaintAtSizeTag = 42; |
568 host_->PaintAtSize(TransportDIB::GetFakeHandleForTest(), kPaintAtSizeTag, | 568 host_->PaintAtSize(TransportDIB::GetFakeHandleForTest(), kPaintAtSizeTag, |
569 gfx::Size(40, 60), gfx::Size(20, 30)); | 569 gfx::Size(40, 60), gfx::Size(20, 30)); |
570 EXPECT_TRUE( | 570 EXPECT_TRUE( |
571 process_->sink().GetUniqueMessageMatching(ViewMsg_PaintAtSize::ID)); | 571 process_->sink().GetUniqueMessageMatching(ViewMsg_PaintAtSize::ID)); |
572 | 572 |
573 NotificationRegistrar registrar; | 573 NotificationRegistrar registrar; |
574 MockPaintingObserver observer; | 574 MockPaintingObserver observer; |
575 registrar.Add( | 575 registrar.Add( |
576 &observer, | 576 &observer, |
577 NotificationType::RENDER_WIDGET_HOST_DID_RECEIVE_PAINT_AT_SIZE_ACK, | 577 content::NOTIFICATION_RENDER_WIDGET_HOST_DID_RECEIVE_PAINT_AT_SIZE_ACK, |
578 Source<RenderWidgetHost>(host_.get())); | 578 Source<RenderWidgetHost>(host_.get())); |
579 | 579 |
580 host_->OnMsgPaintAtSizeAck(kPaintAtSizeTag, gfx::Size(20, 30)); | 580 host_->OnMsgPaintAtSizeAck(kPaintAtSizeTag, gfx::Size(20, 30)); |
581 EXPECT_EQ(host_.get(), observer.host()); | 581 EXPECT_EQ(host_.get(), observer.host()); |
582 EXPECT_EQ(kPaintAtSizeTag, observer.tag()); | 582 EXPECT_EQ(kPaintAtSizeTag, observer.tag()); |
583 EXPECT_EQ(20, observer.size().width()); | 583 EXPECT_EQ(20, observer.size().width()); |
584 EXPECT_EQ(30, observer.size().height()); | 584 EXPECT_EQ(30, observer.size().height()); |
585 } | 585 } |
586 | 586 |
587 TEST_F(RenderWidgetHostTest, HandleKeyEventsWeSent) { | 587 TEST_F(RenderWidgetHostTest, HandleKeyEventsWeSent) { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 // Start it again to ensure it still works. | 728 // Start it again to ensure it still works. |
729 EXPECT_FALSE(host_->unresponsive_timer_fired()); | 729 EXPECT_FALSE(host_->unresponsive_timer_fired()); |
730 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); | 730 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); |
731 | 731 |
732 // Wait long enough for first timeout and see if it fired. | 732 // Wait long enough for first timeout and see if it fired. |
733 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 733 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
734 new MessageLoop::QuitTask(), 10); | 734 new MessageLoop::QuitTask(), 10); |
735 MessageLoop::current()->Run(); | 735 MessageLoop::current()->Run(); |
736 EXPECT_TRUE(host_->unresponsive_timer_fired()); | 736 EXPECT_TRUE(host_->unresponsive_timer_fired()); |
737 } | 737 } |
OLD | NEW |