| 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 "content/test/render_view_test.h" | 5 #include "content/test/render_view_test.h" |
| 6 | 6 |
| 7 #include "content/common/dom_storage_common.h" | 7 #include "content/common/dom_storage_common.h" |
| 8 #include "content/common/view_messages.h" | 8 #include "content/common/view_messages.h" |
| 9 #include "content/public/browser/native_web_keyboard_event.h" | 9 #include "content/public/browser/native_web_keyboard_event.h" |
| 10 #include "content/public/common/renderer_preferences.h" | 10 #include "content/public/common/renderer_preferences.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 platform_->PlatformUninitialize(); | 151 platform_->PlatformUninitialize(); |
| 152 platform_.reset(); | 152 platform_.reset(); |
| 153 params_.reset(); | 153 params_.reset(); |
| 154 command_line_.reset(); | 154 command_line_.reset(); |
| 155 } | 155 } |
| 156 | 156 |
| 157 int RenderViewTest::SendKeyEvent(MockKeyboard::Layout layout, | 157 int RenderViewTest::SendKeyEvent(MockKeyboard::Layout layout, |
| 158 int key_code, | 158 int key_code, |
| 159 MockKeyboard::Modifiers modifiers, | 159 MockKeyboard::Modifiers modifiers, |
| 160 std::wstring* output) { | 160 std::wstring* output) { |
| 161 #if defined(OS_WIN) | 161 #if defined(USE_AURA) |
| 162 NOTIMPLEMENTED(); |
| 163 return L'\0'; |
| 164 #elif defined(OS_WIN) |
| 162 // Retrieve the Unicode character for the given tuple (keyboard-layout, | 165 // Retrieve the Unicode character for the given tuple (keyboard-layout, |
| 163 // key-code, and modifiers). | 166 // key-code, and modifiers). |
| 164 // Exit when a keyboard-layout driver cannot assign a Unicode character to | 167 // Exit when a keyboard-layout driver cannot assign a Unicode character to |
| 165 // the tuple to prevent sending an invalid key code to the RenderView object. | 168 // the tuple to prevent sending an invalid key code to the RenderView object. |
| 166 CHECK(mock_keyboard_.get()); | 169 CHECK(mock_keyboard_.get()); |
| 167 CHECK(output); | 170 CHECK(output); |
| 168 int length = mock_keyboard_->GetCharacters(layout, key_code, modifiers, | 171 int length = mock_keyboard_->GetCharacters(layout, key_code, modifiers, |
| 169 output); | 172 output); |
| 170 if (length != 1) | 173 if (length != 1) |
| 171 return -1; | 174 return -1; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 182 | 185 |
| 183 MSG msg2 = { NULL, WM_CHAR, (*output)[0], 0 }; | 186 MSG msg2 = { NULL, WM_CHAR, (*output)[0], 0 }; |
| 184 NativeWebKeyboardEvent char_event(msg2); | 187 NativeWebKeyboardEvent char_event(msg2); |
| 185 SendNativeKeyEvent(char_event); | 188 SendNativeKeyEvent(char_event); |
| 186 | 189 |
| 187 MSG msg3 = { NULL, WM_KEYUP, key_code, 0 }; | 190 MSG msg3 = { NULL, WM_KEYUP, key_code, 0 }; |
| 188 NativeWebKeyboardEvent keyup_event(msg3); | 191 NativeWebKeyboardEvent keyup_event(msg3); |
| 189 SendNativeKeyEvent(keyup_event); | 192 SendNativeKeyEvent(keyup_event); |
| 190 | 193 |
| 191 return length; | 194 return length; |
| 192 #elif defined(OS_LINUX) && !defined(USE_AURA) | 195 #elif defined(OS_LINUX) |
| 193 // We ignore |layout|, which means we are only testing the layout of the | 196 // We ignore |layout|, which means we are only testing the layout of the |
| 194 // current locale. TODO(estade): fix this to respect |layout|. | 197 // current locale. TODO(estade): fix this to respect |layout|. |
| 195 std::vector<GdkEvent*> events; | 198 std::vector<GdkEvent*> events; |
| 196 ui::SynthesizeKeyPressEvents( | 199 ui::SynthesizeKeyPressEvents( |
| 197 NULL, static_cast<ui::KeyboardCode>(key_code), | 200 NULL, static_cast<ui::KeyboardCode>(key_code), |
| 198 modifiers & (MockKeyboard::LEFT_CONTROL | MockKeyboard::RIGHT_CONTROL), | 201 modifiers & (MockKeyboard::LEFT_CONTROL | MockKeyboard::RIGHT_CONTROL), |
| 199 modifiers & (MockKeyboard::LEFT_SHIFT | MockKeyboard::RIGHT_SHIFT), | 202 modifiers & (MockKeyboard::LEFT_SHIFT | MockKeyboard::RIGHT_SHIFT), |
| 200 modifiers & (MockKeyboard::LEFT_ALT | MockKeyboard::RIGHT_ALT), | 203 modifiers & (MockKeyboard::LEFT_ALT | MockKeyboard::RIGHT_ALT), |
| 201 &events); | 204 &events); |
| 202 | 205 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); | 344 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); |
| 342 impl->set_send_content_state_immediately(true); | 345 impl->set_send_content_state_immediately(true); |
| 343 } | 346 } |
| 344 | 347 |
| 345 WebKit::WebWidget* RenderViewTest::GetWebWidget() { | 348 WebKit::WebWidget* RenderViewTest::GetWebWidget() { |
| 346 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); | 349 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); |
| 347 return impl->webwidget(); | 350 return impl->webwidget(); |
| 348 } | 351 } |
| 349 | 352 |
| 350 } // namespace content | 353 } // namespace content |
| OLD | NEW |