Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2657)

Unified Diff: content/renderer/screen_orientation/mock_screen_orientation_controller.cc

Issue 302553007: Call RenderViewImpl::SetScreenOrientationForTesting to make sure that events are not sent when orie… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove change in render_view_impl.cc Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698