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/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" |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 EXPECT_TRUE(0 == memcmp(background.getPixels(), | 268 EXPECT_TRUE(0 == memcmp(background.getPixels(), |
269 view->background().getPixels(), | 269 view->background().getPixels(), |
270 background.getSize())); | 270 background.getSize())); |
271 | 271 |
272 #if defined(OS_WIN) | 272 #if defined(OS_WIN) |
273 // A message should have been dispatched telling the renderer about the new | 273 // A message should have been dispatched telling the renderer about the new |
274 // background. | 274 // background. |
275 const IPC::Message* set_background = | 275 const IPC::Message* set_background = |
276 process_->sink().GetUniqueMessageMatching(ViewMsg_SetBackground::ID); | 276 process_->sink().GetUniqueMessageMatching(ViewMsg_SetBackground::ID); |
277 ASSERT_TRUE(set_background); | 277 ASSERT_TRUE(set_background); |
278 SkBitmap sent_background; | 278 Tuple1<SkBitmap> sent_background; |
279 ViewMsg_SetBackground::Read(set_background, &sent_background); | 279 ViewMsg_SetBackground::Read(set_background, &sent_background); |
280 EXPECT_EQ(background.getSize(), sent_background.getSize()); | 280 EXPECT_EQ(background.getSize(), sent_background.a.getSize()); |
281 EXPECT_TRUE(0 == memcmp(background.getPixels(), | 281 EXPECT_TRUE(0 == memcmp(background.getPixels(), |
282 sent_background.getPixels(), | 282 sent_background.a.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 gfx::Canvas. 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? |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 | 370 |
371 // Now unhide. | 371 // Now unhide. |
372 process_->sink().ClearMessages(); | 372 process_->sink().ClearMessages(); |
373 host_->WasRestored(); | 373 host_->WasRestored(); |
374 EXPECT_FALSE(host_->is_hidden_); | 374 EXPECT_FALSE(host_->is_hidden_); |
375 | 375 |
376 // It should have sent out a restored message with a request to paint. | 376 // It should have sent out a restored message with a request to paint. |
377 const IPC::Message* restored = process_->sink().GetUniqueMessageMatching( | 377 const IPC::Message* restored = process_->sink().GetUniqueMessageMatching( |
378 ViewMsg_WasRestored::ID); | 378 ViewMsg_WasRestored::ID); |
379 ASSERT_TRUE(restored); | 379 ASSERT_TRUE(restored); |
380 bool needs_repaint; | 380 Tuple1<bool> needs_repaint; |
381 ViewMsg_WasRestored::Read(restored, &needs_repaint); | 381 ViewMsg_WasRestored::Read(restored, &needs_repaint); |
382 EXPECT_TRUE(needs_repaint); | 382 EXPECT_TRUE(needs_repaint.a); |
383 } | 383 } |
384 | 384 |
385 TEST_F(RenderWidgetHostTest, HandleKeyEventsWeSent) { | 385 TEST_F(RenderWidgetHostTest, HandleKeyEventsWeSent) { |
386 NativeWebKeyboardEvent key_event; | 386 NativeWebKeyboardEvent key_event; |
387 key_event.type = WebInputEvent::KeyDown; | 387 key_event.type = WebInputEvent::KeyDown; |
388 key_event.modifiers = WebInputEvent::ControlKey; | 388 key_event.modifiers = WebInputEvent::ControlKey; |
389 key_event.windowsKeyCode = base::VKEY_L; // non-null made up value. | 389 key_event.windowsKeyCode = base::VKEY_L; // non-null made up value. |
390 | 390 |
391 host_->ForwardKeyboardEvent(key_event); | 391 host_->ForwardKeyboardEvent(key_event); |
392 | 392 |
(...skipping 15 matching lines...) Expand all 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 |