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_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 210 |
211 class FakeRenderWidgetHostViewAura : public RenderWidgetHostViewAura { | 211 class FakeRenderWidgetHostViewAura : public RenderWidgetHostViewAura { |
212 public: | 212 public: |
213 FakeRenderWidgetHostViewAura(RenderWidgetHost* widget, | 213 FakeRenderWidgetHostViewAura(RenderWidgetHost* widget, |
214 bool is_guest_view_hack) | 214 bool is_guest_view_hack) |
215 : RenderWidgetHostViewAura(widget, is_guest_view_hack), | 215 : RenderWidgetHostViewAura(widget, is_guest_view_hack), |
216 has_resize_lock_(false) {} | 216 has_resize_lock_(false) {} |
217 | 217 |
218 ~FakeRenderWidgetHostViewAura() override {} | 218 ~FakeRenderWidgetHostViewAura() override {} |
219 | 219 |
220 scoped_ptr<ResizeLock> CreateResizeLock(bool defer_compositor_lock) override { | 220 scoped_ptr<ResizeLock> DelegatedFrameHostCreateResizeLock( |
| 221 bool defer_compositor_lock) override { |
221 gfx::Size desired_size = window()->bounds().size(); | 222 gfx::Size desired_size = window()->bounds().size(); |
222 return scoped_ptr<ResizeLock>( | 223 return scoped_ptr<ResizeLock>( |
223 new FakeResizeLock(desired_size, defer_compositor_lock)); | 224 new FakeResizeLock(desired_size, defer_compositor_lock)); |
224 } | 225 } |
225 | 226 |
| 227 bool DelegatedFrameCanCreateResizeLock() const override { return true; } |
| 228 |
226 void RunOnCompositingDidCommit() { | 229 void RunOnCompositingDidCommit() { |
227 GetDelegatedFrameHost()->OnCompositingDidCommitForTesting( | 230 GetDelegatedFrameHost()->OnCompositingDidCommitForTesting( |
228 window()->GetHost()->compositor()); | 231 window()->GetHost()->compositor()); |
229 } | 232 } |
230 | 233 |
231 bool ShouldCreateResizeLock() override { | 234 void InterceptCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request) { |
232 return GetDelegatedFrameHost()->ShouldCreateResizeLockForTesting(); | |
233 } | |
234 | |
235 void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request) override { | |
236 last_copy_request_ = request.Pass(); | 235 last_copy_request_ = request.Pass(); |
237 if (last_copy_request_->has_texture_mailbox()) { | 236 if (last_copy_request_->has_texture_mailbox()) { |
238 // Give the resulting texture a size. | 237 // Give the resulting texture a size. |
239 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper(); | 238 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper(); |
240 GLuint texture = gl_helper->ConsumeMailboxToTexture( | 239 GLuint texture = gl_helper->ConsumeMailboxToTexture( |
241 last_copy_request_->texture_mailbox().mailbox(), | 240 last_copy_request_->texture_mailbox().mailbox(), |
242 last_copy_request_->texture_mailbox().sync_point()); | 241 last_copy_request_->texture_mailbox().sync_point()); |
243 gl_helper->ResizeTexture(texture, window()->bounds().size()); | 242 gl_helper->ResizeTexture(texture, window()->bounds().size()); |
244 gl_helper->DeleteTexture(texture); | 243 gl_helper->DeleteTexture(texture); |
245 } | 244 } |
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1136 EXPECT_EQ(blink::WebTouchPoint::StateMoved, | 1135 EXPECT_EQ(blink::WebTouchPoint::StateMoved, |
1137 view_->touch_event_->touches[0].state); | 1136 view_->touch_event_->touches[0].state); |
1138 | 1137 |
1139 view_->OnTouchEvent(&release); | 1138 view_->OnTouchEvent(&release); |
1140 EXPECT_TRUE(release.synchronous_handling_disabled()); | 1139 EXPECT_TRUE(release.synchronous_handling_disabled()); |
1141 EXPECT_EQ(nullptr, view_->touch_event_); | 1140 EXPECT_EQ(nullptr, view_->touch_event_); |
1142 } | 1141 } |
1143 | 1142 |
1144 TEST_F(RenderWidgetHostViewAuraTest, PhysicalBackingSizeWithScale) { | 1143 TEST_F(RenderWidgetHostViewAuraTest, PhysicalBackingSizeWithScale) { |
1145 view_->InitAsChild(NULL); | 1144 view_->InitAsChild(NULL); |
| 1145 |
1146 aura::client::ParentWindowWithContext( | 1146 aura::client::ParentWindowWithContext( |
1147 view_->GetNativeView(), | 1147 view_->GetNativeView(), |
1148 parent_view_->GetNativeView()->GetRootWindow(), | 1148 parent_view_->GetNativeView()->GetRootWindow(), |
1149 gfx::Rect()); | 1149 gfx::Rect()); |
1150 sink_->ClearMessages(); | 1150 sink_->ClearMessages(); |
1151 view_->SetSize(gfx::Size(100, 100)); | 1151 view_->SetSize(gfx::Size(100, 100)); |
1152 EXPECT_EQ("100x100", view_->GetPhysicalBackingSize().ToString()); | 1152 EXPECT_EQ("100x100", view_->GetPhysicalBackingSize().ToString()); |
1153 EXPECT_EQ(1u, sink_->message_count()); | 1153 EXPECT_EQ(1u, sink_->message_count()); |
1154 EXPECT_EQ(ViewMsg_Resize::ID, sink_->GetMessageAt(0)->type()); | 1154 EXPECT_EQ(ViewMsg_Resize::ID, sink_->GetMessageAt(0)->type()); |
1155 { | 1155 { |
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2035 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAuraCopyRequestTest); | 2035 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAuraCopyRequestTest); |
2036 }; | 2036 }; |
2037 | 2037 |
2038 TEST_F(RenderWidgetHostViewAuraCopyRequestTest, DestroyedAfterCopyRequest) { | 2038 TEST_F(RenderWidgetHostViewAuraCopyRequestTest, DestroyedAfterCopyRequest) { |
2039 base::RunLoop run_loop; | 2039 base::RunLoop run_loop; |
2040 | 2040 |
2041 gfx::Rect view_rect(100, 100); | 2041 gfx::Rect view_rect(100, 100); |
2042 scoped_ptr<cc::CopyOutputRequest> request; | 2042 scoped_ptr<cc::CopyOutputRequest> request; |
2043 | 2043 |
2044 view_->InitAsChild(NULL); | 2044 view_->InitAsChild(NULL); |
| 2045 view_->GetDelegatedFrameHost()->SetRequestCopyOfOutputCallbackForTesting( |
| 2046 base::Bind(&FakeRenderWidgetHostViewAura::InterceptCopyOfOutput, |
| 2047 base::Unretained(view_))); |
2045 aura::client::ParentWindowWithContext( | 2048 aura::client::ParentWindowWithContext( |
2046 view_->GetNativeView(), | 2049 view_->GetNativeView(), |
2047 parent_view_->GetNativeView()->GetRootWindow(), | 2050 parent_view_->GetNativeView()->GetRootWindow(), |
2048 gfx::Rect()); | 2051 gfx::Rect()); |
2049 view_->SetSize(view_rect.size()); | 2052 view_->SetSize(view_rect.size()); |
2050 view_->Show(); | 2053 view_->Show(); |
2051 | 2054 |
2052 scoped_ptr<FakeFrameSubscriber> frame_subscriber(new FakeFrameSubscriber( | 2055 scoped_ptr<FakeFrameSubscriber> frame_subscriber(new FakeFrameSubscriber( |
2053 view_rect.size(), | 2056 view_rect.size(), |
2054 base::Bind(&RenderWidgetHostViewAuraCopyRequestTest::CallbackMethod, | 2057 base::Bind(&RenderWidgetHostViewAuraCopyRequestTest::CallbackMethod, |
(...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3150 view_->OnScrollEvent(&scroll); | 3153 view_->OnScrollEvent(&scroll); |
3151 | 3154 |
3152 input_event = GetInputEventFromMessage(*sink_->GetMessageAt(0)); | 3155 input_event = GetInputEventFromMessage(*sink_->GetMessageAt(0)); |
3153 wheel_event = static_cast<const WebMouseWheelEvent*>(input_event); | 3156 wheel_event = static_cast<const WebMouseWheelEvent*>(input_event); |
3154 // Check if the canScroll set to true when ctrl-touchpad-scroll is generated | 3157 // Check if the canScroll set to true when ctrl-touchpad-scroll is generated |
3155 // from scroll event. | 3158 // from scroll event. |
3156 EXPECT_TRUE(wheel_event->canScroll); | 3159 EXPECT_TRUE(wheel_event->canScroll); |
3157 } | 3160 } |
3158 | 3161 |
3159 } // namespace content | 3162 } // namespace content |
OLD | NEW |