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..27418e286096b3560dc3dbd9af75a72369a4ba71 100644 |
--- a/content/renderer/screen_orientation/mock_screen_orientation_controller.cc |
+++ b/content/renderer/screen_orientation/mock_screen_orientation_controller.cc |
@@ -7,6 +7,7 @@ |
#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 { |
@@ -15,7 +16,8 @@ MockScreenOrientationController::MockScreenOrientationController() |
: current_lock_(blink::WebScreenOrientationLockDefault), |
device_orientation_(blink::WebScreenOrientationPortraitPrimary), |
current_orientation_(blink::WebScreenOrientationPortraitPrimary), |
- listener_(NULL) { |
+ listener_(NULL), |
+ render_view_(NULL) { |
// Since MockScreenOrientationController is held by LazyInstance reference, |
// add this ref for it. |
AddRef(); |
@@ -64,7 +66,12 @@ void MockScreenOrientationController::ResetLockSync() { |
} |
void MockScreenOrientationController::UpdateDeviceOrientation( |
+ RenderView* render_view, |
blink::WebScreenOrientationType orientation) { |
+ // Make sure that render_view_ did not change during test. |
+ assert(!render_view_ || render_view_ == render_view); |
+ render_view_ = render_view; |
+ |
if (device_orientation_ == orientation) |
return; |
device_orientation_ = orientation; |
@@ -78,6 +85,9 @@ void MockScreenOrientationController::UpdateScreenOrientation( |
if (current_orientation_ == orientation) |
return; |
current_orientation_ = orientation; |
+ if (render_view_) |
+ static_cast<RenderViewImpl*>(render_view_) |
+ ->SetScreenOrientationForTesting(orientation); |
if (listener_) |
listener_->didChangeScreenOrientation(current_orientation_); |
} |
@@ -124,4 +134,8 @@ MockScreenOrientationController::SuitableOrientationForCurrentLock() { |
} |
} |
+void MockScreenOrientationController::ResetRenderView() { |
+ render_view_ = 0; |
+} |
+ |
} // namespace content |