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/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 } | 425 } |
426 | 426 |
427 // Tests setting custom background | 427 // Tests setting custom background |
428 TEST_F(RenderWidgetHostTest, Background) { | 428 TEST_F(RenderWidgetHostTest, Background) { |
429 #if defined(OS_WIN) || defined(OS_LINUX) | 429 #if defined(OS_WIN) || defined(OS_LINUX) |
430 scoped_ptr<RenderWidgetHostView> view( | 430 scoped_ptr<RenderWidgetHostView> view( |
431 RenderWidgetHostView::CreateViewForWidget(host_.get())); | 431 RenderWidgetHostView::CreateViewForWidget(host_.get())); |
432 host_->set_view(view.get()); | 432 host_->set_view(view.get()); |
433 | 433 |
434 // Create a checkerboard background to test with. | 434 // Create a checkerboard background to test with. |
435 gfx::CanvasSkia canvas(4, 4, true); | 435 gfx::CanvasSkia canvas; |
| 436 ASSERT_TRUE(canvas.Init(4, 4, true)); |
436 canvas.FillRectInt(SK_ColorBLACK, 0, 0, 2, 2); | 437 canvas.FillRectInt(SK_ColorBLACK, 0, 0, 2, 2); |
437 canvas.FillRectInt(SK_ColorWHITE, 2, 0, 2, 2); | 438 canvas.FillRectInt(SK_ColorWHITE, 2, 0, 2, 2); |
438 canvas.FillRectInt(SK_ColorWHITE, 0, 2, 2, 2); | 439 canvas.FillRectInt(SK_ColorWHITE, 0, 2, 2, 2); |
439 canvas.FillRectInt(SK_ColorBLACK, 2, 2, 2, 2); | 440 canvas.FillRectInt(SK_ColorBLACK, 2, 2, 2, 2); |
440 const SkBitmap& background = canvas.getDevice()->accessBitmap(false); | 441 const SkBitmap& background = |
| 442 canvas.skia_canvas()->getDevice()->accessBitmap(false); |
441 | 443 |
442 // Set the background and make sure we get back a copy. | 444 // Set the background and make sure we get back a copy. |
443 view->SetBackground(background); | 445 view->SetBackground(background); |
444 EXPECT_EQ(4, view->background().width()); | 446 EXPECT_EQ(4, view->background().width()); |
445 EXPECT_EQ(4, view->background().height()); | 447 EXPECT_EQ(4, view->background().height()); |
446 EXPECT_EQ(background.getSize(), view->background().getSize()); | 448 EXPECT_EQ(background.getSize(), view->background().getSize()); |
447 EXPECT_TRUE(0 == memcmp(background.getPixels(), | 449 EXPECT_TRUE(0 == memcmp(background.getPixels(), |
448 view->background().getPixels(), | 450 view->background().getPixels(), |
449 background.getSize())); | 451 background.getSize())); |
450 | 452 |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 // Start it again to ensure it still works. | 729 // Start it again to ensure it still works. |
728 EXPECT_FALSE(host_->unresponsive_timer_fired()); | 730 EXPECT_FALSE(host_->unresponsive_timer_fired()); |
729 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); | 731 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); |
730 | 732 |
731 // Wait long enough for first timeout and see if it fired. | 733 // Wait long enough for first timeout and see if it fired. |
732 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 734 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
733 new MessageLoop::QuitTask(), 10); | 735 new MessageLoop::QuitTask(), 10); |
734 MessageLoop::current()->Run(); | 736 MessageLoop::current()->Run(); |
735 EXPECT_TRUE(host_->unresponsive_timer_fired()); | 737 EXPECT_TRUE(host_->unresponsive_timer_fired()); |
736 } | 738 } |
OLD | NEW |