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 "chrome/browser/renderer_host/render_widget_host_view_mac.h" | 5 #include "chrome/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 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 8 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
9 #include "chrome/browser/ui/cocoa/test_event_utils.h" | 9 #include "chrome/browser/ui/cocoa/test_event_utils.h" |
10 #include "content/browser/browser_thread.h" | 10 #include "content/browser/browser_thread.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 // TestRenderWidgetHostView, so store its view and reset it back to the | 23 // TestRenderWidgetHostView, so store its view and reset it back to the |
24 // stored view in |TearDown()|. | 24 // stored view in |TearDown()|. |
25 old_rwhv_ = rvh()->view(); | 25 old_rwhv_ = rvh()->view(); |
26 | 26 |
27 // Owned by its |native_view()|, i.e. |rwhv_cocoa_|. | 27 // Owned by its |native_view()|, i.e. |rwhv_cocoa_|. |
28 rwhv_mac_ = new RenderWidgetHostViewMac(rvh()); | 28 rwhv_mac_ = new RenderWidgetHostViewMac(rvh()); |
29 rwhv_cocoa_.reset([rwhv_mac_->native_view() retain]); | 29 rwhv_cocoa_.reset([rwhv_mac_->native_view() retain]); |
30 } | 30 } |
31 virtual void TearDown() { | 31 virtual void TearDown() { |
32 // See comment in SetUp(). | 32 // See comment in SetUp(). |
33 rvh()->set_view(old_rwhv_); | 33 rvh()->SetView(old_rwhv_); |
34 | 34 |
35 // Make sure the rwhv_mac_ is gone once the superclass's |TearDown()| runs. | 35 // Make sure the rwhv_mac_ is gone once the superclass's |TearDown()| runs. |
36 rwhv_cocoa_.reset(); | 36 rwhv_cocoa_.reset(); |
37 pool_.Recycle(); | 37 pool_.Recycle(); |
38 MessageLoop::current()->RunAllPending(); | 38 MessageLoop::current()->RunAllPending(); |
39 pool_.Recycle(); | 39 pool_.Recycle(); |
40 | 40 |
41 RenderViewHostTestHarness::TearDown(); | 41 RenderViewHostTestHarness::TearDown(); |
42 } | 42 } |
43 protected: | 43 protected: |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 185 |
186 // A click on the accelerated view should focus the RWHVCocoa. | 186 // A click on the accelerated view should focus the RWHVCocoa. |
187 std::pair<NSEvent*, NSEvent*> clicks = | 187 std::pair<NSEvent*, NSEvent*> clicks = |
188 test_event_utils::MouseClickInView(accelerated_view, 1); | 188 test_event_utils::MouseClickInView(accelerated_view, 1); |
189 [rwhv_cocoa_.get() mouseDown:clicks.first]; | 189 [rwhv_cocoa_.get() mouseDown:clicks.first]; |
190 EXPECT_EQ(rwhv_cocoa_.get(), [window firstResponder]); | 190 EXPECT_EQ(rwhv_cocoa_.get(), [window firstResponder]); |
191 | 191 |
192 // Clean up. | 192 // Clean up. |
193 rwhv_mac_->DestroyFakePluginWindowHandle(accelerated_handle); | 193 rwhv_mac_->DestroyFakePluginWindowHandle(accelerated_handle); |
194 } | 194 } |
OLD | NEW |