OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/keyboard_codes.h" | 6 #include "base/keyboard_codes.h" |
7 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
8 #include "base/shared_memory.h" | 8 #include "base/shared_memory.h" |
9 #include "base/timer.h" | 9 #include "base/timer.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
11 #include "chrome/browser/renderer_host/backing_store.h" | 11 #include "chrome/browser/renderer_host/backing_store.h" |
12 #include "chrome/browser/renderer_host/render_widget_host_painting_observer.h" | 12 #include "chrome/browser/renderer_host/render_widget_host_painting_observer.h" |
13 #include "chrome/browser/renderer_host/test/test_render_view_host.h" | 13 #include "chrome/browser/renderer_host/test/test_render_view_host.h" |
14 #include "chrome/common/render_messages.h" | 14 #include "chrome/common/render_messages.h" |
15 #include "gfx/canvas_skia.h" | 15 #include "gfx/canvas.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 | 17 |
18 using base::TimeDelta; | 18 using base::TimeDelta; |
19 | 19 |
20 using WebKit::WebInputEvent; | 20 using WebKit::WebInputEvent; |
21 using WebKit::WebMouseWheelEvent; | 21 using WebKit::WebMouseWheelEvent; |
22 | 22 |
23 namespace gfx { | 23 namespace gfx { |
24 class Size; | 24 class Size; |
25 } | 25 } |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 } | 399 } |
400 | 400 |
401 // Tests setting custom background | 401 // Tests setting custom background |
402 TEST_F(RenderWidgetHostTest, Background) { | 402 TEST_F(RenderWidgetHostTest, Background) { |
403 #if defined(OS_WIN) || defined(OS_LINUX) | 403 #if defined(OS_WIN) || defined(OS_LINUX) |
404 scoped_ptr<RenderWidgetHostView> view( | 404 scoped_ptr<RenderWidgetHostView> view( |
405 RenderWidgetHostView::CreateViewForWidget(host_.get())); | 405 RenderWidgetHostView::CreateViewForWidget(host_.get())); |
406 host_->set_view(view.get()); | 406 host_->set_view(view.get()); |
407 | 407 |
408 // Create a checkerboard background to test with. | 408 // Create a checkerboard background to test with. |
409 gfx::CanvasSkia canvas(4, 4, true); | 409 gfx::Canvas canvas(4, 4, true); |
410 canvas.FillRectInt(SK_ColorBLACK, 0, 0, 2, 2); | 410 canvas.FillRectInt(SK_ColorBLACK, 0, 0, 2, 2); |
411 canvas.FillRectInt(SK_ColorWHITE, 2, 0, 2, 2); | 411 canvas.FillRectInt(SK_ColorWHITE, 2, 0, 2, 2); |
412 canvas.FillRectInt(SK_ColorWHITE, 0, 2, 2, 2); | 412 canvas.FillRectInt(SK_ColorWHITE, 0, 2, 2, 2); |
413 canvas.FillRectInt(SK_ColorBLACK, 2, 2, 2, 2); | 413 canvas.FillRectInt(SK_ColorBLACK, 2, 2, 2, 2); |
414 const SkBitmap& background = canvas.getDevice()->accessBitmap(false); | 414 const SkBitmap& background = canvas.getDevice()->accessBitmap(false); |
415 | 415 |
416 // Set the background and make sure we get back a copy. | 416 // Set the background and make sure we get back a copy. |
417 view->SetBackground(background); | 417 view->SetBackground(background); |
418 EXPECT_EQ(4, view->background().width()); | 418 EXPECT_EQ(4, view->background().width()); |
419 EXPECT_EQ(4, view->background().height()); | 419 EXPECT_EQ(4, view->background().height()); |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 // Start it again to ensure it still works. | 698 // Start it again to ensure it still works. |
699 EXPECT_FALSE(host_->unresponsive_timer_fired()); | 699 EXPECT_FALSE(host_->unresponsive_timer_fired()); |
700 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); | 700 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); |
701 | 701 |
702 // Wait long enough for first timeout and see if it fired. | 702 // Wait long enough for first timeout and see if it fired. |
703 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 703 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
704 new MessageLoop::QuitTask(), 10); | 704 new MessageLoop::QuitTask(), 10); |
705 MessageLoop::current()->Run(); | 705 MessageLoop::current()->Run(); |
706 EXPECT_TRUE(host_->unresponsive_timer_fired()); | 706 EXPECT_TRUE(host_->unresponsive_timer_fired()); |
707 } | 707 } |
OLD | NEW |