| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 | 70 |
| 71 // Simple screen position client to test coordinate system conversion. | 71 // Simple screen position client to test coordinate system conversion. |
| 72 class TestScreenPositionClient | 72 class TestScreenPositionClient |
| 73 : public aura::client::ScreenPositionClient { | 73 : public aura::client::ScreenPositionClient { |
| 74 public: | 74 public: |
| 75 TestScreenPositionClient() {} | 75 TestScreenPositionClient() {} |
| 76 virtual ~TestScreenPositionClient() {} | 76 virtual ~TestScreenPositionClient() {} |
| 77 | 77 |
| 78 // aura::client::ScreenPositionClient overrides: | 78 // aura::client::ScreenPositionClient overrides: |
| 79 virtual void ConvertPointToScreen(const aura::Window* window, | 79 virtual void ConvertPointToScreen(const aura::Window* window, |
| 80 gfx::Point* point) OVERRIDE { | 80 gfx::Point* point) override { |
| 81 point->Offset(-1, -1); | 81 point->Offset(-1, -1); |
| 82 } | 82 } |
| 83 | 83 |
| 84 virtual void ConvertPointFromScreen(const aura::Window* window, | 84 virtual void ConvertPointFromScreen(const aura::Window* window, |
| 85 gfx::Point* point) OVERRIDE { | 85 gfx::Point* point) override { |
| 86 point->Offset(1, 1); | 86 point->Offset(1, 1); |
| 87 } | 87 } |
| 88 | 88 |
| 89 virtual void ConvertHostPointToScreen(aura::Window* window, | 89 virtual void ConvertHostPointToScreen(aura::Window* window, |
| 90 gfx::Point* point) OVERRIDE { | 90 gfx::Point* point) override { |
| 91 ConvertPointToScreen(window, point); | 91 ConvertPointToScreen(window, point); |
| 92 } | 92 } |
| 93 | 93 |
| 94 virtual void SetBounds(aura::Window* window, | 94 virtual void SetBounds(aura::Window* window, |
| 95 const gfx::Rect& bounds, | 95 const gfx::Rect& bounds, |
| 96 const gfx::Display& display) OVERRIDE { | 96 const gfx::Display& display) override { |
| 97 } | 97 } |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 class TestOverscrollDelegate : public OverscrollControllerDelegate { | 100 class TestOverscrollDelegate : public OverscrollControllerDelegate { |
| 101 public: | 101 public: |
| 102 explicit TestOverscrollDelegate(RenderWidgetHostView* view) | 102 explicit TestOverscrollDelegate(RenderWidgetHostView* view) |
| 103 : view_(view), | 103 : view_(view), |
| 104 current_mode_(OVERSCROLL_NONE), | 104 current_mode_(OVERSCROLL_NONE), |
| 105 completed_mode_(OVERSCROLL_NONE), | 105 completed_mode_(OVERSCROLL_NONE), |
| 106 delta_x_(0.f), | 106 delta_x_(0.f), |
| 107 delta_y_(0.f) {} | 107 delta_y_(0.f) {} |
| 108 | 108 |
| 109 virtual ~TestOverscrollDelegate() {} | 109 virtual ~TestOverscrollDelegate() {} |
| 110 | 110 |
| 111 OverscrollMode current_mode() const { return current_mode_; } | 111 OverscrollMode current_mode() const { return current_mode_; } |
| 112 OverscrollMode completed_mode() const { return completed_mode_; } | 112 OverscrollMode completed_mode() const { return completed_mode_; } |
| 113 float delta_x() const { return delta_x_; } | 113 float delta_x() const { return delta_x_; } |
| 114 float delta_y() const { return delta_y_; } | 114 float delta_y() const { return delta_y_; } |
| 115 | 115 |
| 116 void Reset() { | 116 void Reset() { |
| 117 current_mode_ = OVERSCROLL_NONE; | 117 current_mode_ = OVERSCROLL_NONE; |
| 118 completed_mode_ = OVERSCROLL_NONE; | 118 completed_mode_ = OVERSCROLL_NONE; |
| 119 delta_x_ = delta_y_ = 0.f; | 119 delta_x_ = delta_y_ = 0.f; |
| 120 } | 120 } |
| 121 | 121 |
| 122 private: | 122 private: |
| 123 // Overridden from OverscrollControllerDelegate: | 123 // Overridden from OverscrollControllerDelegate: |
| 124 virtual gfx::Rect GetVisibleBounds() const OVERRIDE { | 124 virtual gfx::Rect GetVisibleBounds() const override { |
| 125 return view_->IsShowing() ? view_->GetViewBounds() : gfx::Rect(); | 125 return view_->IsShowing() ? view_->GetViewBounds() : gfx::Rect(); |
| 126 } | 126 } |
| 127 | 127 |
| 128 virtual bool OnOverscrollUpdate(float delta_x, float delta_y) OVERRIDE { | 128 virtual bool OnOverscrollUpdate(float delta_x, float delta_y) override { |
| 129 delta_x_ = delta_x; | 129 delta_x_ = delta_x; |
| 130 delta_y_ = delta_y; | 130 delta_y_ = delta_y; |
| 131 return true; | 131 return true; |
| 132 } | 132 } |
| 133 | 133 |
| 134 virtual void OnOverscrollComplete(OverscrollMode overscroll_mode) OVERRIDE { | 134 virtual void OnOverscrollComplete(OverscrollMode overscroll_mode) override { |
| 135 EXPECT_EQ(current_mode_, overscroll_mode); | 135 EXPECT_EQ(current_mode_, overscroll_mode); |
| 136 completed_mode_ = overscroll_mode; | 136 completed_mode_ = overscroll_mode; |
| 137 current_mode_ = OVERSCROLL_NONE; | 137 current_mode_ = OVERSCROLL_NONE; |
| 138 } | 138 } |
| 139 | 139 |
| 140 virtual void OnOverscrollModeChange(OverscrollMode old_mode, | 140 virtual void OnOverscrollModeChange(OverscrollMode old_mode, |
| 141 OverscrollMode new_mode) OVERRIDE { | 141 OverscrollMode new_mode) override { |
| 142 EXPECT_EQ(current_mode_, old_mode); | 142 EXPECT_EQ(current_mode_, old_mode); |
| 143 current_mode_ = new_mode; | 143 current_mode_ = new_mode; |
| 144 delta_x_ = delta_y_ = 0.f; | 144 delta_x_ = delta_y_ = 0.f; |
| 145 } | 145 } |
| 146 | 146 |
| 147 RenderWidgetHostView* view_; | 147 RenderWidgetHostView* view_; |
| 148 OverscrollMode current_mode_; | 148 OverscrollMode current_mode_; |
| 149 OverscrollMode completed_mode_; | 149 OverscrollMode completed_mode_; |
| 150 float delta_x_; | 150 float delta_x_; |
| 151 float delta_y_; | 151 float delta_y_; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 167 window_->AddObserver(this); | 167 window_->AddObserver(this); |
| 168 } | 168 } |
| 169 virtual ~TestWindowObserver() { | 169 virtual ~TestWindowObserver() { |
| 170 if (window_) | 170 if (window_) |
| 171 window_->RemoveObserver(this); | 171 window_->RemoveObserver(this); |
| 172 } | 172 } |
| 173 | 173 |
| 174 bool destroyed() const { return destroyed_; } | 174 bool destroyed() const { return destroyed_; } |
| 175 | 175 |
| 176 // aura::WindowObserver overrides: | 176 // aura::WindowObserver overrides: |
| 177 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE { | 177 virtual void OnWindowDestroyed(aura::Window* window) override { |
| 178 CHECK_EQ(window, window_); | 178 CHECK_EQ(window, window_); |
| 179 destroyed_ = true; | 179 destroyed_ = true; |
| 180 window_ = NULL; | 180 window_ = NULL; |
| 181 } | 181 } |
| 182 | 182 |
| 183 private: | 183 private: |
| 184 // Window that we're observing, or NULL if it's been destroyed. | 184 // Window that we're observing, or NULL if it's been destroyed. |
| 185 aura::Window* window_; | 185 aura::Window* window_; |
| 186 | 186 |
| 187 // Was |window_| destroyed? | 187 // Was |window_| destroyed? |
| 188 bool destroyed_; | 188 bool destroyed_; |
| 189 | 189 |
| 190 DISALLOW_COPY_AND_ASSIGN(TestWindowObserver); | 190 DISALLOW_COPY_AND_ASSIGN(TestWindowObserver); |
| 191 }; | 191 }; |
| 192 | 192 |
| 193 class FakeFrameSubscriber : public RenderWidgetHostViewFrameSubscriber { | 193 class FakeFrameSubscriber : public RenderWidgetHostViewFrameSubscriber { |
| 194 public: | 194 public: |
| 195 FakeFrameSubscriber(gfx::Size size, base::Callback<void(bool)> callback) | 195 FakeFrameSubscriber(gfx::Size size, base::Callback<void(bool)> callback) |
| 196 : size_(size), callback_(callback) {} | 196 : size_(size), callback_(callback) {} |
| 197 | 197 |
| 198 virtual bool ShouldCaptureFrame(const gfx::Rect& damage_rect, | 198 virtual bool ShouldCaptureFrame(const gfx::Rect& damage_rect, |
| 199 base::TimeTicks present_time, | 199 base::TimeTicks present_time, |
| 200 scoped_refptr<media::VideoFrame>* storage, | 200 scoped_refptr<media::VideoFrame>* storage, |
| 201 DeliverFrameCallback* callback) OVERRIDE { | 201 DeliverFrameCallback* callback) override { |
| 202 *storage = media::VideoFrame::CreateFrame(media::VideoFrame::YV12, | 202 *storage = media::VideoFrame::CreateFrame(media::VideoFrame::YV12, |
| 203 size_, | 203 size_, |
| 204 gfx::Rect(size_), | 204 gfx::Rect(size_), |
| 205 size_, | 205 size_, |
| 206 base::TimeDelta()); | 206 base::TimeDelta()); |
| 207 *callback = base::Bind(&FakeFrameSubscriber::CallbackMethod, callback_); | 207 *callback = base::Bind(&FakeFrameSubscriber::CallbackMethod, callback_); |
| 208 return true; | 208 return true; |
| 209 } | 209 } |
| 210 | 210 |
| 211 static void CallbackMethod(base::Callback<void(bool)> callback, | 211 static void CallbackMethod(base::Callback<void(bool)> callback, |
| 212 base::TimeTicks timestamp, | 212 base::TimeTicks timestamp, |
| 213 bool success) { | 213 bool success) { |
| 214 callback.Run(success); | 214 callback.Run(success); |
| 215 } | 215 } |
| 216 | 216 |
| 217 private: | 217 private: |
| 218 gfx::Size size_; | 218 gfx::Size size_; |
| 219 base::Callback<void(bool)> callback_; | 219 base::Callback<void(bool)> callback_; |
| 220 }; | 220 }; |
| 221 | 221 |
| 222 class FakeRenderWidgetHostViewAura : public RenderWidgetHostViewAura { | 222 class FakeRenderWidgetHostViewAura : public RenderWidgetHostViewAura { |
| 223 public: | 223 public: |
| 224 FakeRenderWidgetHostViewAura(RenderWidgetHost* widget) | 224 FakeRenderWidgetHostViewAura(RenderWidgetHost* widget) |
| 225 : RenderWidgetHostViewAura(widget), has_resize_lock_(false) {} | 225 : RenderWidgetHostViewAura(widget), has_resize_lock_(false) {} |
| 226 | 226 |
| 227 virtual ~FakeRenderWidgetHostViewAura() {} | 227 virtual ~FakeRenderWidgetHostViewAura() {} |
| 228 | 228 |
| 229 virtual scoped_ptr<ResizeLock> CreateResizeLock( | 229 virtual scoped_ptr<ResizeLock> CreateResizeLock( |
| 230 bool defer_compositor_lock) OVERRIDE { | 230 bool defer_compositor_lock) override { |
| 231 gfx::Size desired_size = window()->bounds().size(); | 231 gfx::Size desired_size = window()->bounds().size(); |
| 232 return scoped_ptr<ResizeLock>( | 232 return scoped_ptr<ResizeLock>( |
| 233 new FakeResizeLock(desired_size, defer_compositor_lock)); | 233 new FakeResizeLock(desired_size, defer_compositor_lock)); |
| 234 } | 234 } |
| 235 | 235 |
| 236 void RunOnCompositingDidCommit() { | 236 void RunOnCompositingDidCommit() { |
| 237 GetDelegatedFrameHost()->OnCompositingDidCommitForTesting( | 237 GetDelegatedFrameHost()->OnCompositingDidCommitForTesting( |
| 238 window()->GetHost()->compositor()); | 238 window()->GetHost()->compositor()); |
| 239 } | 239 } |
| 240 | 240 |
| 241 virtual bool ShouldCreateResizeLock() OVERRIDE { | 241 virtual bool ShouldCreateResizeLock() override { |
| 242 return GetDelegatedFrameHost()->ShouldCreateResizeLockForTesting(); | 242 return GetDelegatedFrameHost()->ShouldCreateResizeLockForTesting(); |
| 243 } | 243 } |
| 244 | 244 |
| 245 virtual void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request) | 245 virtual void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request) |
| 246 OVERRIDE { | 246 override { |
| 247 last_copy_request_ = request.Pass(); | 247 last_copy_request_ = request.Pass(); |
| 248 if (last_copy_request_->has_texture_mailbox()) { | 248 if (last_copy_request_->has_texture_mailbox()) { |
| 249 // Give the resulting texture a size. | 249 // Give the resulting texture a size. |
| 250 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper(); | 250 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper(); |
| 251 GLuint texture = gl_helper->ConsumeMailboxToTexture( | 251 GLuint texture = gl_helper->ConsumeMailboxToTexture( |
| 252 last_copy_request_->texture_mailbox().mailbox(), | 252 last_copy_request_->texture_mailbox().mailbox(), |
| 253 last_copy_request_->texture_mailbox().sync_point()); | 253 last_copy_request_->texture_mailbox().sync_point()); |
| 254 gl_helper->ResizeTexture(texture, window()->bounds().size()); | 254 gl_helper->ResizeTexture(texture, window()->bounds().size()); |
| 255 gl_helper->DeleteTexture(texture); | 255 gl_helper->DeleteTexture(texture); |
| 256 } | 256 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 285 scoped_ptr<cc::CopyOutputRequest> last_copy_request_; | 285 scoped_ptr<cc::CopyOutputRequest> last_copy_request_; |
| 286 }; | 286 }; |
| 287 | 287 |
| 288 // A layout manager that always resizes a child to the root window size. | 288 // A layout manager that always resizes a child to the root window size. |
| 289 class FullscreenLayoutManager : public aura::LayoutManager { | 289 class FullscreenLayoutManager : public aura::LayoutManager { |
| 290 public: | 290 public: |
| 291 explicit FullscreenLayoutManager(aura::Window* owner) : owner_(owner) {} | 291 explicit FullscreenLayoutManager(aura::Window* owner) : owner_(owner) {} |
| 292 virtual ~FullscreenLayoutManager() {} | 292 virtual ~FullscreenLayoutManager() {} |
| 293 | 293 |
| 294 // Overridden from aura::LayoutManager: | 294 // Overridden from aura::LayoutManager: |
| 295 virtual void OnWindowResized() OVERRIDE { | 295 virtual void OnWindowResized() override { |
| 296 aura::Window::Windows::const_iterator i; | 296 aura::Window::Windows::const_iterator i; |
| 297 for (i = owner_->children().begin(); i != owner_->children().end(); ++i) { | 297 for (i = owner_->children().begin(); i != owner_->children().end(); ++i) { |
| 298 (*i)->SetBounds(gfx::Rect()); | 298 (*i)->SetBounds(gfx::Rect()); |
| 299 } | 299 } |
| 300 } | 300 } |
| 301 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE { | 301 virtual void OnWindowAddedToLayout(aura::Window* child) override { |
| 302 child->SetBounds(gfx::Rect()); | 302 child->SetBounds(gfx::Rect()); |
| 303 } | 303 } |
| 304 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE {} | 304 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) override {} |
| 305 virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE {} | 305 virtual void OnWindowRemovedFromLayout(aura::Window* child) override {} |
| 306 virtual void OnChildWindowVisibilityChanged(aura::Window* child, | 306 virtual void OnChildWindowVisibilityChanged(aura::Window* child, |
| 307 bool visible) OVERRIDE {} | 307 bool visible) override {} |
| 308 virtual void SetChildBounds(aura::Window* child, | 308 virtual void SetChildBounds(aura::Window* child, |
| 309 const gfx::Rect& requested_bounds) OVERRIDE { | 309 const gfx::Rect& requested_bounds) override { |
| 310 SetChildBoundsDirect(child, gfx::Rect(owner_->bounds().size())); | 310 SetChildBoundsDirect(child, gfx::Rect(owner_->bounds().size())); |
| 311 } | 311 } |
| 312 | 312 |
| 313 private: | 313 private: |
| 314 aura::Window* owner_; | 314 aura::Window* owner_; |
| 315 DISALLOW_COPY_AND_ASSIGN(FullscreenLayoutManager); | 315 DISALLOW_COPY_AND_ASSIGN(FullscreenLayoutManager); |
| 316 }; | 316 }; |
| 317 | 317 |
| 318 class MockWindowObserver : public aura::WindowObserver { | 318 class MockWindowObserver : public aura::WindowObserver { |
| 319 public: | 319 public: |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 | 620 |
| 621 private: | 621 private: |
| 622 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAuraOverscrollTest); | 622 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAuraOverscrollTest); |
| 623 }; | 623 }; |
| 624 | 624 |
| 625 class RenderWidgetHostViewAuraShutdownTest | 625 class RenderWidgetHostViewAuraShutdownTest |
| 626 : public RenderWidgetHostViewAuraTest { | 626 : public RenderWidgetHostViewAuraTest { |
| 627 public: | 627 public: |
| 628 RenderWidgetHostViewAuraShutdownTest() {} | 628 RenderWidgetHostViewAuraShutdownTest() {} |
| 629 | 629 |
| 630 virtual void TearDown() OVERRIDE { | 630 virtual void TearDown() override { |
| 631 // No TearDownEnvironment here, we do this explicitly during the test. | 631 // No TearDownEnvironment here, we do this explicitly during the test. |
| 632 } | 632 } |
| 633 | 633 |
| 634 private: | 634 private: |
| 635 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAuraShutdownTest); | 635 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAuraShutdownTest); |
| 636 }; | 636 }; |
| 637 | 637 |
| 638 // Checks that a fullscreen view has the correct show-state and receives the | 638 // Checks that a fullscreen view has the correct show-state and receives the |
| 639 // focus. | 639 // focus. |
| 640 TEST_F(RenderWidgetHostViewAuraTest, FocusFullscreen) { | 640 TEST_F(RenderWidgetHostViewAuraTest, FocusFullscreen) { |
| (...skipping 2207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2848 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); | 2848 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); |
| 2849 | 2849 |
| 2850 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, | 2850 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, |
| 2851 blink::WebGestureDeviceTouchscreen); | 2851 blink::WebGestureDeviceTouchscreen); |
| 2852 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 2852 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
| 2853 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); | 2853 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); |
| 2854 EXPECT_EQ(3U, sink_->message_count()); | 2854 EXPECT_EQ(3U, sink_->message_count()); |
| 2855 } | 2855 } |
| 2856 | 2856 |
| 2857 } // namespace content | 2857 } // namespace content |
| OLD | NEW |