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.h" | 9 #include "content/browser/browser_thread.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/notification_details.h" | 14 #include "content/public/browser/notification_details.h" |
14 #include "content/public/browser/notification_observer.h" | 15 #include "content/public/browser/notification_observer.h" |
15 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/notification_registrar.h" |
16 #include "content/public/browser/notification_source.h" | 17 #include "content/public/browser/notification_source.h" |
17 #include "content/public/browser/notification_types.h" | 18 #include "content/public/browser/notification_types.h" |
18 #include "content/public/browser/content_browser_client.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 using base::TimeDelta; | 24 using base::TimeDelta; |
25 | 25 |
26 using WebKit::WebInputEvent; | 26 using WebKit::WebInputEvent; |
27 using WebKit::WebMouseWheelEvent; | 27 using WebKit::WebMouseWheelEvent; |
28 | 28 |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 | 421 |
422 // Tests setting custom background | 422 // Tests setting custom background |
423 TEST_F(RenderWidgetHostTest, Background) { | 423 TEST_F(RenderWidgetHostTest, Background) { |
424 #if !defined(OS_MACOSX) | 424 #if !defined(OS_MACOSX) |
425 scoped_ptr<RenderWidgetHostView> view( | 425 scoped_ptr<RenderWidgetHostView> view( |
426 content::GetContentClient()->browser()->CreateViewForWidget(host_.get())); | 426 content::GetContentClient()->browser()->CreateViewForWidget(host_.get())); |
427 host_->SetView(view.get()); | 427 host_->SetView(view.get()); |
428 | 428 |
429 // Create a checkerboard background to test with. | 429 // Create a checkerboard background to test with. |
430 gfx::CanvasSkia canvas(4, 4, true); | 430 gfx::CanvasSkia canvas(4, 4, true); |
431 canvas.FillRectInt(SK_ColorBLACK, 0, 0, 2, 2); | 431 canvas.FillRect(SK_ColorBLACK, gfx::Rect(0, 0, 2, 2)); |
432 canvas.FillRectInt(SK_ColorWHITE, 2, 0, 2, 2); | 432 canvas.FillRect(SK_ColorWHITE, gfx::Rect(2, 0, 2, 2)); |
433 canvas.FillRectInt(SK_ColorWHITE, 0, 2, 2, 2); | 433 canvas.FillRect(SK_ColorWHITE, gfx::Rect(0, 2, 2, 2)); |
434 canvas.FillRectInt(SK_ColorBLACK, 2, 2, 2, 2); | 434 canvas.FillRect(SK_ColorBLACK, gfx::Rect(2, 2, 2, 2)); |
435 const SkBitmap& background = | 435 const SkBitmap& background = |
436 canvas.sk_canvas()->getDevice()->accessBitmap(false); | 436 canvas.sk_canvas()->getDevice()->accessBitmap(false); |
437 | 437 |
438 // Set the background and make sure we get back a copy. | 438 // Set the background and make sure we get back a copy. |
439 view->SetBackground(background); | 439 view->SetBackground(background); |
440 EXPECT_EQ(4, view->background().width()); | 440 EXPECT_EQ(4, view->background().width()); |
441 EXPECT_EQ(4, view->background().height()); | 441 EXPECT_EQ(4, view->background().height()); |
442 EXPECT_EQ(background.getSize(), view->background().getSize()); | 442 EXPECT_EQ(background.getSize(), view->background().getSize()); |
443 EXPECT_TRUE(0 == memcmp(background.getPixels(), | 443 EXPECT_TRUE(0 == memcmp(background.getPixels(), |
444 view->background().getPixels(), | 444 view->background().getPixels(), |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 // Start it again to ensure it still works. | 735 // Start it again to ensure it still works. |
736 EXPECT_FALSE(host_->unresponsive_timer_fired()); | 736 EXPECT_FALSE(host_->unresponsive_timer_fired()); |
737 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); | 737 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); |
738 | 738 |
739 // Wait long enough for first timeout and see if it fired. | 739 // Wait long enough for first timeout and see if it fired. |
740 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 740 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
741 new MessageLoop::QuitTask(), 10); | 741 new MessageLoop::QuitTask(), 10); |
742 MessageLoop::current()->Run(); | 742 MessageLoop::current()->Run(); |
743 EXPECT_TRUE(host_->unresponsive_timer_fired()); | 743 EXPECT_TRUE(host_->unresponsive_timer_fired()); |
744 } | 744 } |
OLD | NEW |