Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(862)

Side by Side Diff: content/renderer/render_view_browsertest.cc

Issue 739993002: MacViews: Fix build errors related to NativeWebKeyboardEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix for Sadrul Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/public/browser/native_web_keyboard_event.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/bind.h" 6 #include "base/bind.h"
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/memory/shared_memory.h" 8 #include "base/memory/shared_memory.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "third_party/WebKit/public/platform/WebString.h" 45 #include "third_party/WebKit/public/platform/WebString.h"
46 #include "third_party/WebKit/public/platform/WebURLResponse.h" 46 #include "third_party/WebKit/public/platform/WebURLResponse.h"
47 #include "third_party/WebKit/public/web/WebDataSource.h" 47 #include "third_party/WebKit/public/web/WebDataSource.h"
48 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" 48 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h"
49 #include "third_party/WebKit/public/web/WebHistoryItem.h" 49 #include "third_party/WebKit/public/web/WebHistoryItem.h"
50 #include "third_party/WebKit/public/web/WebLocalFrame.h" 50 #include "third_party/WebKit/public/web/WebLocalFrame.h"
51 #include "third_party/WebKit/public/web/WebPerformance.h" 51 #include "third_party/WebKit/public/web/WebPerformance.h"
52 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" 52 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
53 #include "third_party/WebKit/public/web/WebView.h" 53 #include "third_party/WebKit/public/web/WebView.h"
54 #include "third_party/WebKit/public/web/WebWindowFeatures.h" 54 #include "third_party/WebKit/public/web/WebWindowFeatures.h"
55 #include "ui/events/event.h"
55 #include "ui/events/keycodes/keyboard_codes.h" 56 #include "ui/events/keycodes/keyboard_codes.h"
56 #include "ui/gfx/codec/jpeg_codec.h" 57 #include "ui/gfx/codec/jpeg_codec.h"
57 #include "ui/gfx/range/range.h" 58 #include "ui/gfx/range/range.h"
58 59
59 #if defined(USE_AURA)
60 #include "ui/events/event.h"
61 #endif
62
63 #if defined(USE_AURA) && defined(USE_X11) 60 #if defined(USE_AURA) && defined(USE_X11)
64 #include <X11/Xlib.h> 61 #include <X11/Xlib.h>
65 #include "ui/events/event_constants.h" 62 #include "ui/events/event_constants.h"
66 #include "ui/events/keycodes/keyboard_code_conversion.h" 63 #include "ui/events/keycodes/keyboard_code_conversion.h"
67 #include "ui/events/test/events_test_utils.h" 64 #include "ui/events/test/events_test_utils.h"
68 #include "ui/events/test/events_test_utils_x11.h" 65 #include "ui/events/test/events_test_utils_x11.h"
69 #endif 66 #endif
70 67
71 #if defined(USE_OZONE) 68 #if defined(USE_OZONE)
72 #include "ui/events/keycodes/keyboard_code_conversion.h" 69 #include "ui/events/keycodes/keyboard_code_conversion.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 if (length != 1) 177 if (length != 1)
181 return -1; 178 return -1;
182 179
183 // Create IPC messages from Windows messages and send them to our 180 // Create IPC messages from Windows messages and send them to our
184 // back-end. 181 // back-end.
185 // A keyboard event of Windows consists of three Windows messages: 182 // A keyboard event of Windows consists of three Windows messages:
186 // WM_KEYDOWN, WM_CHAR, and WM_KEYUP. 183 // WM_KEYDOWN, WM_CHAR, and WM_KEYUP.
187 // WM_KEYDOWN and WM_KEYUP sends virtual-key codes. On the other hand, 184 // WM_KEYDOWN and WM_KEYUP sends virtual-key codes. On the other hand,
188 // WM_CHAR sends a composed Unicode character. 185 // WM_CHAR sends a composed Unicode character.
189 MSG msg1 = { NULL, WM_KEYDOWN, key_code, 0 }; 186 MSG msg1 = { NULL, WM_KEYDOWN, key_code, 0 };
190 #if defined(USE_AURA)
191 ui::KeyEvent evt1(msg1); 187 ui::KeyEvent evt1(msg1);
192 NativeWebKeyboardEvent keydown_event(&evt1); 188 NativeWebKeyboardEvent keydown_event(evt1);
193 #else
194 NativeWebKeyboardEvent keydown_event(msg1);
195 #endif
196 SendNativeKeyEvent(keydown_event); 189 SendNativeKeyEvent(keydown_event);
197 190
198 MSG msg2 = { NULL, WM_CHAR, (*output)[0], 0 }; 191 MSG msg2 = { NULL, WM_CHAR, (*output)[0], 0 };
199 #if defined(USE_AURA)
200 ui::KeyEvent evt2(msg2); 192 ui::KeyEvent evt2(msg2);
201 NativeWebKeyboardEvent char_event(&evt2); 193 NativeWebKeyboardEvent char_event(evt2);
202 #else
203 NativeWebKeyboardEvent char_event(msg2);
204 #endif
205 SendNativeKeyEvent(char_event); 194 SendNativeKeyEvent(char_event);
206 195
207 MSG msg3 = { NULL, WM_KEYUP, key_code, 0 }; 196 MSG msg3 = { NULL, WM_KEYUP, key_code, 0 };
208 #if defined(USE_AURA)
209 ui::KeyEvent evt3(msg3); 197 ui::KeyEvent evt3(msg3);
210 NativeWebKeyboardEvent keyup_event(&evt3); 198 NativeWebKeyboardEvent keyup_event(evt3);
211 #else
212 NativeWebKeyboardEvent keyup_event(msg3);
213 #endif
214 SendNativeKeyEvent(keyup_event); 199 SendNativeKeyEvent(keyup_event);
215 200
216 return length; 201 return length;
217 #elif defined(USE_AURA) && defined(USE_X11) 202 #elif defined(USE_AURA) && defined(USE_X11)
218 // We ignore |layout|, which means we are only testing the layout of the 203 // We ignore |layout|, which means we are only testing the layout of the
219 // current locale. TODO(mazda): fix this to respect |layout|. 204 // current locale. TODO(mazda): fix this to respect |layout|.
220 CHECK(output); 205 CHECK(output);
221 const int flags = ConvertMockKeyboardModifier(modifiers); 206 const int flags = ConvertMockKeyboardModifier(modifiers);
222 207
223 ui::ScopedXI2Event xevent; 208 ui::ScopedXI2Event xevent;
224 xevent.InitKeyEvent(ui::ET_KEY_PRESSED, 209 xevent.InitKeyEvent(ui::ET_KEY_PRESSED,
225 static_cast<ui::KeyboardCode>(key_code), 210 static_cast<ui::KeyboardCode>(key_code),
226 flags); 211 flags);
227 ui::KeyEvent event1(xevent); 212 ui::KeyEvent event1(xevent);
228 NativeWebKeyboardEvent keydown_event(&event1); 213 NativeWebKeyboardEvent keydown_event(event1);
229 SendNativeKeyEvent(keydown_event); 214 SendNativeKeyEvent(keydown_event);
230 215
231 // X11 doesn't actually have native character events, but give the test 216 // X11 doesn't actually have native character events, but give the test
232 // what it wants. 217 // what it wants.
233 xevent.InitKeyEvent(ui::ET_KEY_PRESSED, 218 xevent.InitKeyEvent(ui::ET_KEY_PRESSED,
234 static_cast<ui::KeyboardCode>(key_code), 219 static_cast<ui::KeyboardCode>(key_code),
235 flags); 220 flags);
236 ui::KeyEvent event2(xevent); 221 ui::KeyEvent event2(xevent);
237 event2.set_character(GetCharacterFromKeyCode(event2.key_code(), 222 event2.set_character(GetCharacterFromKeyCode(event2.key_code(),
238 event2.flags())); 223 event2.flags()));
239 ui::KeyEventTestApi test_event2(&event2); 224 ui::KeyEventTestApi test_event2(&event2);
240 test_event2.set_is_char(true); 225 test_event2.set_is_char(true);
241 NativeWebKeyboardEvent char_event(&event2); 226 NativeWebKeyboardEvent char_event(event2);
242 SendNativeKeyEvent(char_event); 227 SendNativeKeyEvent(char_event);
243 228
244 xevent.InitKeyEvent(ui::ET_KEY_RELEASED, 229 xevent.InitKeyEvent(ui::ET_KEY_RELEASED,
245 static_cast<ui::KeyboardCode>(key_code), 230 static_cast<ui::KeyboardCode>(key_code),
246 flags); 231 flags);
247 ui::KeyEvent event3(xevent); 232 ui::KeyEvent event3(xevent);
248 NativeWebKeyboardEvent keyup_event(&event3); 233 NativeWebKeyboardEvent keyup_event(event3);
249 SendNativeKeyEvent(keyup_event); 234 SendNativeKeyEvent(keyup_event);
250 235
251 long c = GetCharacterFromKeyCode(static_cast<ui::KeyboardCode>(key_code), 236 long c = GetCharacterFromKeyCode(static_cast<ui::KeyboardCode>(key_code),
252 flags); 237 flags);
253 output->assign(1, static_cast<base::char16>(c)); 238 output->assign(1, static_cast<base::char16>(c));
254 return 1; 239 return 1;
255 #elif defined(USE_OZONE) 240 #elif defined(USE_OZONE)
256 const int flags = ConvertMockKeyboardModifier(modifiers); 241 const int flags = ConvertMockKeyboardModifier(modifiers);
257 242
258 ui::KeyEvent keydown_event(ui::ET_KEY_PRESSED, 243 ui::KeyEvent keydown_event(ui::ET_KEY_PRESSED,
259 static_cast<ui::KeyboardCode>(key_code), 244 static_cast<ui::KeyboardCode>(key_code),
260 flags); 245 flags);
261 NativeWebKeyboardEvent keydown_web_event(&keydown_event); 246 NativeWebKeyboardEvent keydown_web_event(keydown_event);
262 SendNativeKeyEvent(keydown_web_event); 247 SendNativeKeyEvent(keydown_web_event);
263 248
264 ui::KeyEvent char_event(keydown_event.GetCharacter(), 249 ui::KeyEvent char_event(keydown_event.GetCharacter(),
265 static_cast<ui::KeyboardCode>(key_code), 250 static_cast<ui::KeyboardCode>(key_code),
266 flags); 251 flags);
267 NativeWebKeyboardEvent char_web_event(&char_event); 252 NativeWebKeyboardEvent char_web_event(char_event);
268 SendNativeKeyEvent(char_web_event); 253 SendNativeKeyEvent(char_web_event);
269 254
270 ui::KeyEvent keyup_event(ui::ET_KEY_RELEASED, 255 ui::KeyEvent keyup_event(ui::ET_KEY_RELEASED,
271 static_cast<ui::KeyboardCode>(key_code), 256 static_cast<ui::KeyboardCode>(key_code),
272 flags); 257 flags);
273 NativeWebKeyboardEvent keyup_web_event(&keyup_event); 258 NativeWebKeyboardEvent keyup_web_event(keyup_event);
274 SendNativeKeyEvent(keyup_web_event); 259 SendNativeKeyEvent(keyup_web_event);
275 260
276 long c = GetCharacterFromKeyCode(static_cast<ui::KeyboardCode>(key_code), 261 long c = GetCharacterFromKeyCode(static_cast<ui::KeyboardCode>(key_code),
277 flags); 262 flags);
278 output->assign(1, static_cast<base::char16>(c)); 263 output->assign(1, static_cast<base::char16>(c));
279 return 1; 264 return 1;
280 #else 265 #else
281 NOTIMPLEMENTED(); 266 NOTIMPLEMENTED();
282 return L'\0'; 267 return L'\0';
283 #endif 268 #endif
(...skipping 2225 matching lines...) Expand 10 before | Expand all | Expand 10 after
2509 2494
2510 gfx::Size initial_size_; 2495 gfx::Size initial_size_;
2511 }; 2496 };
2512 2497
2513 TEST_F(RenderViewImplInitialSizeTest, InitialSize) { 2498 TEST_F(RenderViewImplInitialSizeTest, InitialSize) {
2514 ASSERT_EQ(initial_size_, view_->GetSize()); 2499 ASSERT_EQ(initial_size_, view_->GetSize());
2515 ASSERT_EQ(initial_size_, gfx::Size(view_->GetWebView()->size())); 2500 ASSERT_EQ(initial_size_, gfx::Size(view_->GetWebView()->size()));
2516 } 2501 }
2517 2502
2518 } // namespace content 2503 } // namespace content
OLDNEW
« no previous file with comments | « content/public/browser/native_web_keyboard_event.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698