OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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" |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 canvas.FillRect(gfx::Rect(0, 2, 2, 2), SK_ColorWHITE); | 460 canvas.FillRect(gfx::Rect(0, 2, 2, 2), SK_ColorWHITE); |
461 canvas.FillRect(gfx::Rect(2, 2, 2, 2), SK_ColorBLACK); | 461 canvas.FillRect(gfx::Rect(2, 2, 2, 2), SK_ColorBLACK); |
462 const SkBitmap& background = | 462 const SkBitmap& background = |
463 canvas.sk_canvas()->getDevice()->accessBitmap(false); | 463 canvas.sk_canvas()->getDevice()->accessBitmap(false); |
464 | 464 |
465 // Set the background and make sure we get back a copy. | 465 // Set the background and make sure we get back a copy. |
466 view->SetBackground(background); | 466 view->SetBackground(background); |
467 EXPECT_EQ(4, view->GetBackground().width()); | 467 EXPECT_EQ(4, view->GetBackground().width()); |
468 EXPECT_EQ(4, view->GetBackground().height()); | 468 EXPECT_EQ(4, view->GetBackground().height()); |
469 EXPECT_EQ(background.getSize(), view->GetBackground().getSize()); | 469 EXPECT_EQ(background.getSize(), view->GetBackground().getSize()); |
| 470 background.lockPixels(); |
| 471 view->GetBackground().lockPixels(); |
470 EXPECT_TRUE(0 == memcmp(background.getPixels(), | 472 EXPECT_TRUE(0 == memcmp(background.getPixels(), |
471 view->GetBackground().getPixels(), | 473 view->GetBackground().getPixels(), |
472 background.getSize())); | 474 background.getSize())); |
| 475 view->GetBackground().unlockPixels(); |
| 476 background.unlockPixels(); |
473 | 477 |
474 const IPC::Message* set_background = | 478 const IPC::Message* set_background = |
475 process_->sink().GetUniqueMessageMatching(ViewMsg_SetBackground::ID); | 479 process_->sink().GetUniqueMessageMatching(ViewMsg_SetBackground::ID); |
476 ASSERT_TRUE(set_background); | 480 ASSERT_TRUE(set_background); |
477 Tuple1<SkBitmap> sent_background; | 481 Tuple1<SkBitmap> sent_background; |
478 ViewMsg_SetBackground::Read(set_background, &sent_background); | 482 ViewMsg_SetBackground::Read(set_background, &sent_background); |
479 EXPECT_EQ(background.getSize(), sent_background.a.getSize()); | 483 EXPECT_EQ(background.getSize(), sent_background.a.getSize()); |
| 484 background.lockPixels(); |
| 485 sent_background.a.lockPixels(); |
480 EXPECT_TRUE(0 == memcmp(background.getPixels(), | 486 EXPECT_TRUE(0 == memcmp(background.getPixels(), |
481 sent_background.a.getPixels(), | 487 sent_background.a.getPixels(), |
482 background.getSize())); | 488 background.getSize())); |
| 489 sent_background.a.unlockPixels(); |
| 490 background.unlockPixels(); |
483 | 491 |
484 #if defined(OS_LINUX) || defined(USE_AURA) | 492 #if defined(OS_LINUX) || defined(USE_AURA) |
485 // See the comment above |InitAsChild(NULL)|. | 493 // See the comment above |InitAsChild(NULL)|. |
486 host_->SetView(NULL); | 494 host_->SetView(NULL); |
487 static_cast<content::RenderWidgetHostViewPort*>(view.release())->Destroy(); | 495 static_cast<content::RenderWidgetHostViewPort*>(view.release())->Destroy(); |
488 #endif | 496 #endif |
489 | 497 |
490 #else | 498 #else |
491 // TODO(port): Mac does not have gfx::Canvas. Maybe we can just change this | 499 // TODO(port): Mac does not have gfx::Canvas. Maybe we can just change this |
492 // test to use SkCanvas directly? | 500 // test to use SkCanvas directly? |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); | 782 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); |
775 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); | 783 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); |
776 SendInputEventACK(WebInputEvent::RawKeyDown, true); | 784 SendInputEventACK(WebInputEvent::RawKeyDown, true); |
777 | 785 |
778 // Wait long enough for first timeout and see if it fired. | 786 // Wait long enough for first timeout and see if it fired. |
779 MessageLoop::current()->PostDelayedTask( | 787 MessageLoop::current()->PostDelayedTask( |
780 FROM_HERE, MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(40)); | 788 FROM_HERE, MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(40)); |
781 MessageLoop::current()->Run(); | 789 MessageLoop::current()->Run(); |
782 EXPECT_TRUE(host_->unresponsive_timer_fired()); | 790 EXPECT_TRUE(host_->unresponsive_timer_fired()); |
783 } | 791 } |
OLD | NEW |