| 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 "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "chrome/browser/renderer_host/backing_store.h" | 10 #include "chrome/browser/renderer_host/backing_store.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 unhandled_keyboard_event_called_(false) { | 127 unhandled_keyboard_event_called_(false) { |
| 128 } | 128 } |
| 129 | 129 |
| 130 // Tests that make sure we ignore keyboard event acknowledgments to events we | 130 // Tests that make sure we ignore keyboard event acknowledgments to events we |
| 131 // didn't send work by making sure we didn't call UnhandledKeyboardEvent(). | 131 // didn't send work by making sure we didn't call UnhandledKeyboardEvent(). |
| 132 bool unhandled_keyboard_event_called() const { | 132 bool unhandled_keyboard_event_called() const { |
| 133 return unhandled_keyboard_event_called_; | 133 return unhandled_keyboard_event_called_; |
| 134 } | 134 } |
| 135 | 135 |
| 136 protected: | 136 protected: |
| 137 virtual void UnhandledKeyboardEvent(const WebKeyboardEvent& event) { | 137 virtual void UnhandledKeyboardEvent(const NativeWebKeyboardEvent& event) { |
| 138 unhandled_keyboard_event_called_ = true; | 138 unhandled_keyboard_event_called_ = true; |
| 139 } | 139 } |
| 140 | 140 |
| 141 private: | 141 private: |
| 142 bool unhandled_keyboard_event_called_; | 142 bool unhandled_keyboard_event_called_; |
| 143 }; | 143 }; |
| 144 | 144 |
| 145 // RenderWidgetHostTest -------------------------------------------------------- | 145 // RenderWidgetHostTest -------------------------------------------------------- |
| 146 | 146 |
| 147 class RenderWidgetHostTest : public testing::Test { | 147 class RenderWidgetHostTest : public testing::Test { |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 // It should have sent out a restored message with a request to paint. | 320 // It should have sent out a restored message with a request to paint. |
| 321 const IPC::Message* restored = process_->sink().GetUniqueMessageMatching( | 321 const IPC::Message* restored = process_->sink().GetUniqueMessageMatching( |
| 322 ViewMsg_WasRestored::ID); | 322 ViewMsg_WasRestored::ID); |
| 323 ASSERT_TRUE(restored); | 323 ASSERT_TRUE(restored); |
| 324 bool needs_repaint; | 324 bool needs_repaint; |
| 325 ViewMsg_WasRestored::Read(restored, &needs_repaint); | 325 ViewMsg_WasRestored::Read(restored, &needs_repaint); |
| 326 EXPECT_TRUE(needs_repaint); | 326 EXPECT_TRUE(needs_repaint); |
| 327 } | 327 } |
| 328 | 328 |
| 329 TEST_F(RenderWidgetHostTest, HandleKeyEventsWeSent) { | 329 TEST_F(RenderWidgetHostTest, HandleKeyEventsWeSent) { |
| 330 WebKeyboardEvent key_event; | 330 NativeWebKeyboardEvent key_event; |
| 331 key_event.type = WebInputEvent::KEY_DOWN; | 331 key_event.type = WebInputEvent::KEY_DOWN; |
| 332 key_event.modifiers = WebInputEvent::CTRL_KEY; | 332 key_event.modifiers = WebInputEvent::CTRL_KEY; |
| 333 key_event.windows_key_code = base::VKEY_L; // non-null made up value. | 333 key_event.windows_key_code = base::VKEY_L; // non-null made up value. |
| 334 | 334 |
| 335 host_->ForwardKeyboardEvent(key_event); | 335 host_->ForwardKeyboardEvent(key_event); |
| 336 | 336 |
| 337 // Make sure we sent the input event to the renderer. | 337 // Make sure we sent the input event to the renderer. |
| 338 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( | 338 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( |
| 339 ViewMsg_HandleInputEvent::ID)); | 339 ViewMsg_HandleInputEvent::ID)); |
| 340 process_->sink().ClearMessages(); | 340 process_->sink().ClearMessages(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 353 // Send a simulated, unrequested key response. We should ignore this. | 353 // Send a simulated, unrequested key response. We should ignore this. |
| 354 scoped_ptr<IPC::Message> response( | 354 scoped_ptr<IPC::Message> response( |
| 355 new ViewHostMsg_HandleInputEvent_ACK(0)); | 355 new ViewHostMsg_HandleInputEvent_ACK(0)); |
| 356 response->WriteInt(WebInputEvent::KEY_DOWN); | 356 response->WriteInt(WebInputEvent::KEY_DOWN); |
| 357 response->WriteBool(false); | 357 response->WriteBool(false); |
| 358 host_->OnMessageReceived(*response); | 358 host_->OnMessageReceived(*response); |
| 359 | 359 |
| 360 EXPECT_FALSE(host_->unhandled_keyboard_event_called()); | 360 EXPECT_FALSE(host_->unhandled_keyboard_event_called()); |
| 361 } | 361 } |
| 362 | 362 |
| OLD | NEW |