Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 | 8 |
| 9 #include "base/mac/mac_util.h" | 9 #include "base/mac/mac_util.h" |
| 10 #include "base/mac/scoped_nsautorelease_pool.h" | 10 #include "base/mac/scoped_nsautorelease_pool.h" |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 | 324 |
| 325 // Command-ESC will destroy the view, while the window is still in | 325 // Command-ESC will destroy the view, while the window is still in |
| 326 // |-performKeyEquivalent:|. There are other cases where this can | 326 // |-performKeyEquivalent:|. There are other cases where this can |
| 327 // happen, Command-ESC is the easiest to trigger. | 327 // happen, Command-ESC is the easiest to trigger. |
| 328 [[view->cocoa_view() window] performKeyEquivalent: | 328 [[view->cocoa_view() window] performKeyEquivalent: |
| 329 cocoa_test_event_utils::KeyEventWithKeyCode( | 329 cocoa_test_event_utils::KeyEventWithKeyCode( |
| 330 53, 27, NSKeyDown, NSCommandKeyMask)]; | 330 53, 27, NSKeyDown, NSCommandKeyMask)]; |
| 331 observer.Wait(); | 331 observer.Wait(); |
| 332 } | 332 } |
| 333 | 333 |
| 334 // Test that NSEvent of non-printable character won't generate keypress event | |
| 335 // http://crbug.com/459089 | |
| 336 TEST_F(RenderWidgetHostViewMacTest, FilterNonPrintableCharacter) { | |
| 337 TestBrowserContext browser_context; | |
| 338 MockRenderProcessHost* process_host = | |
| 339 new MockRenderProcessHost(&browser_context); | |
| 340 process_host->Init(); | |
| 341 MockRenderWidgetHostDelegate delegate; | |
| 342 int32 routing_id = process_host->GetNextRoutingID(); | |
| 343 MockRenderWidgetHostImpl* host = | |
| 344 new MockRenderWidgetHostImpl(&delegate, process_host, routing_id); | |
| 345 RenderWidgetHostViewMac* view = new RenderWidgetHostViewMac(host, false); | |
| 346 | |
| 347 // Simulate ctrl+delete (fn+ctrl+backspace), will produce a non-printable | |
| 348 // private use character | |
| 349 process_host->sink().ClearMessages(); | |
| 350 [view->cocoa_view() keyEvent: | |
| 351 cocoa_test_event_utils::KeyEventWithKeyCode( | |
| 352 117, 0xf728, NSKeyDown, NSControlKeyMask)]; | |
| 353 EXPECT_EQ(1U, process_host->sink().message_count()); | |
|
dtapuska
2015/11/23 14:42:08
It's unclear to me how this message_count increase
| |
| 354 | |
| 355 // Simulate a printable char, should generate keypress event | |
| 356 process_host->sink().ClearMessages(); | |
| 357 [view->cocoa_view() keyEvent: | |
| 358 cocoa_test_event_utils::KeyEventWithKeyCode( | |
| 359 0x78, 'x', NSKeyDown, NSControlKeyMask)]; | |
| 360 EXPECT_EQ(2U, process_host->sink().message_count()); | |
| 361 | |
| 362 // Clean up. | |
| 363 host->Shutdown(); | |
| 364 } | |
| 365 | |
| 334 TEST_F(RenderWidgetHostViewMacTest, GetFirstRectForCharacterRangeCaretCase) { | 366 TEST_F(RenderWidgetHostViewMacTest, GetFirstRectForCharacterRangeCaretCase) { |
| 335 const base::string16 kDummyString = base::UTF8ToUTF16("hogehoge"); | 367 const base::string16 kDummyString = base::UTF8ToUTF16("hogehoge"); |
| 336 const size_t kDummyOffset = 0; | 368 const size_t kDummyOffset = 0; |
| 337 | 369 |
| 338 gfx::Rect caret_rect(10, 11, 0, 10); | 370 gfx::Rect caret_rect(10, 11, 0, 10); |
| 339 gfx::Range caret_range(0, 0); | 371 gfx::Range caret_range(0, 0); |
| 340 ViewHostMsg_SelectionBounds_Params params; | 372 ViewHostMsg_SelectionBounds_Params params; |
| 341 | 373 |
| 342 NSRect rect; | 374 NSRect rect; |
| 343 NSRange actual_range; | 375 NSRange actual_range; |
| (...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1055 EXPECT_EQ(1U, process_host_->sink().message_count()); | 1087 EXPECT_EQ(1U, process_host_->sink().message_count()); |
| 1056 process_host_->sink().ClearMessages(); | 1088 process_host_->sink().ClearMessages(); |
| 1057 } | 1089 } |
| 1058 | 1090 |
| 1059 // Clean up. | 1091 // Clean up. |
| 1060 host->Shutdown(); | 1092 host->Shutdown(); |
| 1061 } | 1093 } |
| 1062 | 1094 |
| 1063 | 1095 |
| 1064 } // namespace content | 1096 } // namespace content |
| OLD | NEW |