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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac_unittest.mm

Issue 1923023002: [Mac] Pressing unsupported key should not generate keyevents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months 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/browser/renderer_host/render_widget_host_view_mac.mm ('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 "content/browser/renderer_host/render_widget_host_view_mac.h" 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h"
6 6
7 #include <Cocoa/Cocoa.h> 7 #include <Cocoa/Cocoa.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 [view->cocoa_view() keyEvent: 411 [view->cocoa_view() keyEvent:
412 cocoa_test_event_utils::KeyEventWithKeyCode( 412 cocoa_test_event_utils::KeyEventWithKeyCode(
413 0x58, 'x', NSKeyDown, NSControlKeyMask)]; 413 0x58, 'x', NSKeyDown, NSControlKeyMask)];
414 EXPECT_EQ(2U, process_host->sink().message_count()); 414 EXPECT_EQ(2U, process_host->sink().message_count());
415 EXPECT_EQ("RawKeyDown Char", GetInputMessageTypes(process_host)); 415 EXPECT_EQ("RawKeyDown Char", GetInputMessageTypes(process_host));
416 416
417 // Clean up. 417 // Clean up.
418 host->ShutdownAndDestroyWidget(true); 418 host->ShutdownAndDestroyWidget(true);
419 } 419 }
420 420
421 // Test that invalid |keyCode| shouldn't generate key events.
422 // https://crbug.com/601964
423 TEST_F(RenderWidgetHostViewMacTest, InvalidKeyCode) {
424 TestBrowserContext browser_context;
425 MockRenderProcessHost* process_host =
426 new MockRenderProcessHost(&browser_context);
427 process_host->Init();
428 MockRenderWidgetHostDelegate delegate;
429 int32_t routing_id = process_host->GetNextRoutingID();
430 MockRenderWidgetHostImpl* host =
431 new MockRenderWidgetHostImpl(&delegate, process_host, routing_id);
432 RenderWidgetHostViewMac* view = new RenderWidgetHostViewMac(host, false);
433
434 // Simulate "Convert" key on JIS PC keyboard, will generate a |NSFlagsChanged|
435 // NSEvent with |keyCode| == 0xFF.
436 process_host->sink().ClearMessages();
437 EXPECT_EQ(0U, process_host->sink().message_count());
438 [view->cocoa_view() keyEvent:cocoa_test_event_utils::KeyEventWithKeyCode(
439 0xFF, 0, NSFlagsChanged, 0)];
440 EXPECT_EQ(0U, process_host->sink().message_count());
441
442 // Clean up.
443 host->ShutdownAndDestroyWidget(true);
444 }
445
421 TEST_F(RenderWidgetHostViewMacTest, GetFirstRectForCharacterRangeCaretCase) { 446 TEST_F(RenderWidgetHostViewMacTest, GetFirstRectForCharacterRangeCaretCase) {
422 const base::string16 kDummyString = base::UTF8ToUTF16("hogehoge"); 447 const base::string16 kDummyString = base::UTF8ToUTF16("hogehoge");
423 const size_t kDummyOffset = 0; 448 const size_t kDummyOffset = 0;
424 449
425 gfx::Rect caret_rect(10, 11, 0, 10); 450 gfx::Rect caret_rect(10, 11, 0, 10);
426 gfx::Range caret_range(0, 0); 451 gfx::Range caret_range(0, 0);
427 ViewHostMsg_SelectionBounds_Params params; 452 ViewHostMsg_SelectionBounds_Params params;
428 453
429 NSRect rect; 454 NSRect rect;
430 NSRange actual_range; 455 NSRange actual_range;
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 EXPECT_EQ(1U, process_host_->sink().message_count()); 1251 EXPECT_EQ(1U, process_host_->sink().message_count());
1227 process_host_->sink().ClearMessages(); 1252 process_host_->sink().ClearMessages();
1228 } 1253 }
1229 1254
1230 // Clean up. 1255 // Clean up.
1231 host->ShutdownAndDestroyWidget(true); 1256 host->ShutdownAndDestroyWidget(true);
1232 } 1257 }
1233 1258
1234 1259
1235 } // namespace content 1260 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698