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 "base/mac/scoped_nsautorelease_pool.h" | 7 #include "base/mac/scoped_nsautorelease_pool.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "content/browser/browser_thread_impl.h" | 9 #include "content/browser/browser_thread_impl.h" |
10 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 10 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 cocoa_test_event_utils::KeyEventWithKeyCode(53, 27, NSKeyDown, 0)]; | 303 cocoa_test_event_utils::KeyEventWithKeyCode(53, 27, NSKeyDown, 0)]; |
304 observer.Wait(); | 304 observer.Wait(); |
305 EXPECT_TRUE([rwhv_mac_->cocoa_view() suppressNextEscapeKeyUp]); | 305 EXPECT_TRUE([rwhv_mac_->cocoa_view() suppressNextEscapeKeyUp]); |
306 | 306 |
307 // Escape key up on the parent should clear |suppressNextEscapeKeyUp|. | 307 // Escape key up on the parent should clear |suppressNextEscapeKeyUp|. |
308 [rwhv_mac_->cocoa_view() keyEvent: | 308 [rwhv_mac_->cocoa_view() keyEvent: |
309 cocoa_test_event_utils::KeyEventWithKeyCode(53, 27, NSKeyUp, 0)]; | 309 cocoa_test_event_utils::KeyEventWithKeyCode(53, 27, NSKeyUp, 0)]; |
310 EXPECT_FALSE([rwhv_mac_->cocoa_view() suppressNextEscapeKeyUp]); | 310 EXPECT_FALSE([rwhv_mac_->cocoa_view() suppressNextEscapeKeyUp]); |
311 } | 311 } |
312 | 312 |
| 313 // Test that command accelerators which destroy the fullscreen window |
| 314 // don't crash when forwarded via the window's responder machinery. |
| 315 TEST_F(RenderWidgetHostViewMacTest, AcceleratorDestroy) { |
| 316 // Use our own RWH since we need to destroy it. |
| 317 MockRenderWidgetHostDelegate delegate; |
| 318 TestBrowserContext browser_context; |
| 319 MockRenderProcessHost* process_host = |
| 320 new MockRenderProcessHost(&browser_context); |
| 321 // Owned by its |cocoa_view()|. |
| 322 RenderWidgetHostImpl* rwh = new RenderWidgetHostImpl( |
| 323 &delegate, process_host, MSG_ROUTING_NONE); |
| 324 RenderWidgetHostViewMac* view = static_cast<RenderWidgetHostViewMac*>( |
| 325 RenderWidgetHostView::CreateViewForWidget(rwh)); |
| 326 |
| 327 view->InitAsFullscreen(rwhv_mac_); |
| 328 |
| 329 WindowedNotificationObserver observer( |
| 330 NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, |
| 331 Source<RenderWidgetHost>(rwh)); |
| 332 |
| 333 // Command-ESC will destroy the view, while the window is still in |
| 334 // |-performKeyEquivalent:|. There are other cases where this can |
| 335 // happen, Command-ESC is the easiest to trigger. |
| 336 [[view->cocoa_view() window] performKeyEquivalent: |
| 337 cocoa_test_event_utils::KeyEventWithKeyCode( |
| 338 53, 27, NSKeyDown, NSCommandKeyMask)]; |
| 339 observer.Wait(); |
| 340 } |
| 341 |
313 TEST_F(RenderWidgetHostViewMacTest, GetFirstRectForCharacterRangeCaretCase) { | 342 TEST_F(RenderWidgetHostViewMacTest, GetFirstRectForCharacterRangeCaretCase) { |
314 const string16 kDummyString = UTF8ToUTF16("hogehoge"); | 343 const string16 kDummyString = UTF8ToUTF16("hogehoge"); |
315 const size_t kDummyOffset = 0; | 344 const size_t kDummyOffset = 0; |
316 | 345 |
317 gfx::Rect caret_rect(10, 11, 0, 10); | 346 gfx::Rect caret_rect(10, 11, 0, 10); |
318 ui::Range caret_range(0, 0); | 347 ui::Range caret_range(0, 0); |
319 | 348 |
320 NSRect rect; | 349 NSRect rect; |
321 NSRange actual_range; | 350 NSRange actual_range; |
322 rwhv_mac_->SelectionChanged(kDummyString, kDummyOffset, caret_range); | 351 rwhv_mac_->SelectionChanged(kDummyString, kDummyOffset, caret_range); |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 // |SetActive()| shoud not focus if view is not first responder. | 703 // |SetActive()| shoud not focus if view is not first responder. |
675 EXPECT_CALL(*rwh, Focus()).Times(0); | 704 EXPECT_CALL(*rwh, Focus()).Times(0); |
676 view->SetActive(true); | 705 view->SetActive(true); |
677 testing::Mock::VerifyAndClearExpectations(rwh); | 706 testing::Mock::VerifyAndClearExpectations(rwh); |
678 | 707 |
679 // Clean up. | 708 // Clean up. |
680 rwh->Shutdown(); | 709 rwh->Shutdown(); |
681 } | 710 } |
682 | 711 |
683 } // namespace content | 712 } // namespace content |
OLD | NEW |