Chromium Code Reviews| Index: content/renderer/screen_orientation/mock_screen_orientation_controller.cc |
| diff --git a/content/renderer/screen_orientation/mock_screen_orientation_controller.cc b/content/renderer/screen_orientation/mock_screen_orientation_controller.cc |
| index bbff907dda565e8793d8b3539f8bbe4f78feb353..0527458331ee10713d1a51bb609952e65e155d0e 100644 |
| --- a/content/renderer/screen_orientation/mock_screen_orientation_controller.cc |
| +++ b/content/renderer/screen_orientation/mock_screen_orientation_controller.cc |
| @@ -7,12 +7,14 @@ |
| #include "base/bind.h" |
| #include "base/logging.h" |
| #include "base/message_loop/message_loop.h" |
| +#include "content/renderer/render_view_impl.h" |
| #include "third_party/WebKit/public/platform/WebScreenOrientationListener.h" |
| namespace content { |
| MockScreenOrientationController::MockScreenOrientationController() |
| - : current_lock_(blink::WebScreenOrientationLockDefault), |
| + : RenderViewObserver(NULL), |
| + current_lock_(blink::WebScreenOrientationLockDefault), |
| device_orientation_(blink::WebScreenOrientationPortraitPrimary), |
| current_orientation_(blink::WebScreenOrientationPortraitPrimary), |
| listener_(NULL) { |
| @@ -30,6 +32,9 @@ void MockScreenOrientationController::SetListener( |
| } |
| void MockScreenOrientationController::ResetData() { |
| + if (render_view_impl()) |
| + render_view_impl()->RemoveObserver(this); |
| + |
| current_lock_ = blink::WebScreenOrientationLockDefault; |
| device_orientation_ = blink::WebScreenOrientationPortraitPrimary; |
| current_orientation_ = blink::WebScreenOrientationPortraitPrimary; |
| @@ -64,7 +69,15 @@ void MockScreenOrientationController::ResetLockSync() { |
| } |
| void MockScreenOrientationController::UpdateDeviceOrientation( |
| + RenderView* render_view, |
| blink::WebScreenOrientationType orientation) { |
| + if (this->render_view()) { |
| + // Make sure that render_view_ did not change during test. |
| + assert(this->render_view() == render_view); |
|
jochen (gone - plz use gerrit)
2014/06/03 12:52:25
DCHECK_EQ
ostap
2014/06/03 15:32:32
Done.
|
| + } else { |
| + SetRenderView(render_view); |
| + } |
| + |
| if (device_orientation_ == orientation) |
| return; |
| device_orientation_ = orientation; |
| @@ -73,11 +86,18 @@ void MockScreenOrientationController::UpdateDeviceOrientation( |
| UpdateScreenOrientation(orientation); |
| } |
| +RenderViewImpl* MockScreenOrientationController::render_view_impl() const { |
| + return static_cast<RenderViewImpl*>(render_view()); |
| +} |
| + |
| void MockScreenOrientationController::UpdateScreenOrientation( |
| blink::WebScreenOrientationType orientation) { |
| if (current_orientation_ == orientation) |
| return; |
| current_orientation_ = orientation; |
| + if (render_view_impl()) |
| + render_view_impl()->SetScreenOrientationForTesting(orientation); |
| + |
| if (listener_) |
| listener_->didChangeScreenOrientation(current_orientation_); |
| } |
| @@ -124,4 +144,7 @@ MockScreenOrientationController::SuitableOrientationForCurrentLock() { |
| } |
| } |
| +void MockScreenOrientationController::OnDestruct() { |
| +} |
| + |
| } // namespace content |