| 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 "app/gfx/chrome_canvas.h" | 5 #include "app/gfx/canvas.h" |
| 6 #include "base/basictypes.h" | 6 #include "base/basictypes.h" |
| 7 #include "base/keyboard_codes.h" | 7 #include "base/keyboard_codes.h" |
| 8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
| 9 #include "base/shared_memory.h" | 9 #include "base/shared_memory.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/test_render_view_host.h" | 12 #include "chrome/browser/renderer_host/test_render_view_host.h" |
| 13 #include "chrome/common/render_messages.h" | 13 #include "chrome/common/render_messages.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 } | 246 } |
| 247 | 247 |
| 248 // Tests setting custom background | 248 // Tests setting custom background |
| 249 TEST_F(RenderWidgetHostTest, Background) { | 249 TEST_F(RenderWidgetHostTest, Background) { |
| 250 #if defined(OS_WIN) || defined(OS_LINUX) | 250 #if defined(OS_WIN) || defined(OS_LINUX) |
| 251 scoped_ptr<RenderWidgetHostView> view( | 251 scoped_ptr<RenderWidgetHostView> view( |
| 252 RenderWidgetHostView::CreateViewForWidget(host_.get())); | 252 RenderWidgetHostView::CreateViewForWidget(host_.get())); |
| 253 host_->set_view(view.get()); | 253 host_->set_view(view.get()); |
| 254 | 254 |
| 255 // Create a checkerboard background to test with. | 255 // Create a checkerboard background to test with. |
| 256 ChromeCanvas canvas(4, 4, true); | 256 gfx::Canvas canvas(4, 4, true); |
| 257 canvas.FillRectInt(SK_ColorBLACK, 0, 0, 2, 2); | 257 canvas.FillRectInt(SK_ColorBLACK, 0, 0, 2, 2); |
| 258 canvas.FillRectInt(SK_ColorWHITE, 2, 0, 2, 2); | 258 canvas.FillRectInt(SK_ColorWHITE, 2, 0, 2, 2); |
| 259 canvas.FillRectInt(SK_ColorWHITE, 0, 2, 2, 2); | 259 canvas.FillRectInt(SK_ColorWHITE, 0, 2, 2, 2); |
| 260 canvas.FillRectInt(SK_ColorBLACK, 2, 2, 2, 2); | 260 canvas.FillRectInt(SK_ColorBLACK, 2, 2, 2, 2); |
| 261 const SkBitmap& background = canvas.getDevice()->accessBitmap(false); | 261 const SkBitmap& background = canvas.getDevice()->accessBitmap(false); |
| 262 | 262 |
| 263 // Set the background and make sure we get back a copy. | 263 // Set the background and make sure we get back a copy. |
| 264 view->SetBackground(background); | 264 view->SetBackground(background); |
| 265 EXPECT_EQ(4, view->background().width()); | 265 EXPECT_EQ(4, view->background().width()); |
| 266 EXPECT_EQ(4, view->background().height()); | 266 EXPECT_EQ(4, view->background().height()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 281 EXPECT_TRUE(0 == memcmp(background.getPixels(), | 281 EXPECT_TRUE(0 == memcmp(background.getPixels(), |
| 282 sent_background.getPixels(), | 282 sent_background.getPixels(), |
| 283 background.getSize())); | 283 background.getSize())); |
| 284 #else | 284 #else |
| 285 // TODO(port): When custom backgrounds are implemented for other ports, this | 285 // TODO(port): When custom backgrounds are implemented for other ports, this |
| 286 // test should work (assuming the background must still be copied into the | 286 // test should work (assuming the background must still be copied into the |
| 287 // renderer -- if not, then maybe the test doesn't apply?). | 287 // renderer -- if not, then maybe the test doesn't apply?). |
| 288 #endif | 288 #endif |
| 289 | 289 |
| 290 #else | 290 #else |
| 291 // TODO(port): Mac does not have ChromeCanvas. Maybe we can just change this | 291 // TODO(port): Mac does not have gfx::Canvas. Maybe we can just change this |
| 292 // test to use SkCanvas directly? | 292 // test to use SkCanvas directly? |
| 293 #endif | 293 #endif |
| 294 | 294 |
| 295 // TODO(aa): It would be nice to factor out the painting logic so that we | 295 // TODO(aa): It would be nice to factor out the painting logic so that we |
| 296 // could test that, but it appears that would mean painting everything twice | 296 // could test that, but it appears that would mean painting everything twice |
| 297 // since windows HDC structures are opaque. | 297 // since windows HDC structures are opaque. |
| 298 } | 298 } |
| 299 | 299 |
| 300 // Tests getting the backing store with the renderer not setting repaint ack | 300 // Tests getting the backing store with the renderer not setting repaint ack |
| 301 // flags. | 301 // flags. |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 TEST_F(RenderWidgetHostTest, IgnoreKeyEventsWeDidntSend) { | 408 TEST_F(RenderWidgetHostTest, IgnoreKeyEventsWeDidntSend) { |
| 409 // Send a simulated, unrequested key response. We should ignore this. | 409 // Send a simulated, unrequested key response. We should ignore this. |
| 410 scoped_ptr<IPC::Message> response( | 410 scoped_ptr<IPC::Message> response( |
| 411 new ViewHostMsg_HandleInputEvent_ACK(0)); | 411 new ViewHostMsg_HandleInputEvent_ACK(0)); |
| 412 response->WriteInt(WebInputEvent::KeyDown); | 412 response->WriteInt(WebInputEvent::KeyDown); |
| 413 response->WriteBool(false); | 413 response->WriteBool(false); |
| 414 host_->OnMessageReceived(*response); | 414 host_->OnMessageReceived(*response); |
| 415 | 415 |
| 416 EXPECT_FALSE(host_->unhandled_keyboard_event_called()); | 416 EXPECT_FALSE(host_->unhandled_keyboard_event_called()); |
| 417 } | 417 } |
| OLD | NEW |