| 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_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" |
| 11 #include "content/browser/renderer_host/test_render_view_host.h" | 11 #include "content/browser/renderer_host/test_render_view_host.h" |
| 12 #include "content/common/view_messages.h" | 12 #include "content/common/view_messages.h" |
| 13 #include "content/public/browser/content_browser_client.h" | 13 #include "content/public/browser/content_browser_client.h" |
| 14 #include "content/public/browser/notification_details.h" | 14 #include "content/public/browser/notification_details.h" |
| 15 #include "content/public/browser/notification_observer.h" | 15 #include "content/public/browser/notification_observer.h" |
| 16 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/notification_registrar.h" |
| 17 #include "content/public/browser/notification_source.h" | 17 #include "content/public/browser/notification_source.h" |
| 18 #include "content/public/browser/notification_types.h" | 18 #include "content/public/browser/notification_types.h" |
| 19 #include "content/test/test_browser_context.h" | 19 #include "content/test/test_browser_context.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 21 #include "ui/base/keycodes/keyboard_codes.h" | 21 #include "ui/base/keycodes/keyboard_codes.h" |
| 22 #include "ui/gfx/canvas_skia.h" | 22 #include "ui/gfx/canvas_skia.h" |
| 23 | 23 |
| 24 #if defined(USE_AURA) |
| 25 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
| 26 #endif |
| 27 |
| 24 using base::TimeDelta; | 28 using base::TimeDelta; |
| 25 | 29 |
| 26 using content::BrowserThreadImpl; | 30 using content::BrowserThreadImpl; |
| 27 | 31 |
| 28 using WebKit::WebInputEvent; | 32 using WebKit::WebInputEvent; |
| 29 using WebKit::WebMouseWheelEvent; | 33 using WebKit::WebMouseWheelEvent; |
| 30 | 34 |
| 31 namespace gfx { | 35 namespace gfx { |
| 32 class Size; | 36 class Size; |
| 33 } | 37 } |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 | 423 |
| 420 // Reset the view so we can exit the test cleanly. | 424 // Reset the view so we can exit the test cleanly. |
| 421 host_->SetView(view_.get()); | 425 host_->SetView(view_.get()); |
| 422 } | 426 } |
| 423 | 427 |
| 424 // Tests setting custom background | 428 // Tests setting custom background |
| 425 TEST_F(RenderWidgetHostTest, Background) { | 429 TEST_F(RenderWidgetHostTest, Background) { |
| 426 #if !defined(OS_MACOSX) | 430 #if !defined(OS_MACOSX) |
| 427 scoped_ptr<RenderWidgetHostView> view( | 431 scoped_ptr<RenderWidgetHostView> view( |
| 428 content::GetContentClient()->browser()->CreateViewForWidget(host_.get())); | 432 content::GetContentClient()->browser()->CreateViewForWidget(host_.get())); |
| 433 #if defined(USE_AURA) |
| 434 // TODO(derat): Call this on all platforms: http://crbug.com/102450. |
| 435 static_cast<RenderWidgetHostViewAura*>(view.get())->InitAsChild(); |
| 436 #endif |
| 429 host_->SetView(view.get()); | 437 host_->SetView(view.get()); |
| 430 | 438 |
| 431 // Create a checkerboard background to test with. | 439 // Create a checkerboard background to test with. |
| 432 gfx::CanvasSkia canvas(4, 4, true); | 440 gfx::CanvasSkia canvas(4, 4, true); |
| 433 canvas.FillRect(SK_ColorBLACK, gfx::Rect(0, 0, 2, 2)); | 441 canvas.FillRect(SK_ColorBLACK, gfx::Rect(0, 0, 2, 2)); |
| 434 canvas.FillRect(SK_ColorWHITE, gfx::Rect(2, 0, 2, 2)); | 442 canvas.FillRect(SK_ColorWHITE, gfx::Rect(2, 0, 2, 2)); |
| 435 canvas.FillRect(SK_ColorWHITE, gfx::Rect(0, 2, 2, 2)); | 443 canvas.FillRect(SK_ColorWHITE, gfx::Rect(0, 2, 2, 2)); |
| 436 canvas.FillRect(SK_ColorBLACK, gfx::Rect(2, 2, 2, 2)); | 444 canvas.FillRect(SK_ColorBLACK, gfx::Rect(2, 2, 2, 2)); |
| 437 const SkBitmap& background = | 445 const SkBitmap& background = |
| 438 canvas.sk_canvas()->getDevice()->accessBitmap(false); | 446 canvas.sk_canvas()->getDevice()->accessBitmap(false); |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 // Start it again to ensure it still works. | 745 // Start it again to ensure it still works. |
| 738 EXPECT_FALSE(host_->unresponsive_timer_fired()); | 746 EXPECT_FALSE(host_->unresponsive_timer_fired()); |
| 739 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); | 747 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); |
| 740 | 748 |
| 741 // Wait long enough for first timeout and see if it fired. | 749 // Wait long enough for first timeout and see if it fired. |
| 742 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 750 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 743 new MessageLoop::QuitTask(), 10); | 751 new MessageLoop::QuitTask(), 10); |
| 744 MessageLoop::current()->Run(); | 752 MessageLoop::current()->Run(); |
| 745 EXPECT_TRUE(host_->unresponsive_timer_fired()); | 753 EXPECT_TRUE(host_->unresponsive_timer_fired()); |
| 746 } | 754 } |
| OLD | NEW |