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

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: Updated by review comments. 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..8270436701edf7c88d49fbc271d1ef0c9d16f137 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();
@@ -30,6 +32,7 @@ void MockScreenOrientationController::SetListener(
}
void MockScreenOrientationController::ResetData() {
+ render_view_ = 0;
current_lock_ = blink::WebScreenOrientationLockDefault;
device_orientation_ = blink::WebScreenOrientationPortraitPrimary;
current_orientation_ = blink::WebScreenOrientationPortraitPrimary;
@@ -64,7 +67,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);
jochen (gone - plz use gerrit) 2014/06/02 07:21:25 DCHECK
ostap 2014/06/03 00:11:54 Done.
+ render_view_ = render_view;
+
if (device_orientation_ == orientation)
return;
device_orientation_ = orientation;
@@ -78,6 +86,9 @@ void MockScreenOrientationController::UpdateScreenOrientation(
if (current_orientation_ == orientation)
return;
current_orientation_ = orientation;
+ if (render_view_)
jochen (gone - plz use gerrit) 2014/06/02 07:21:25 nit. add { } because of > 1line body
ostap 2014/06/03 00:11:54 Done.
+ static_cast<RenderViewImpl*>(render_view_)
jochen (gone - plz use gerrit) 2014/06/02 07:21:25 how can you guarantee that e.g. the render view di
ostap 2014/06/03 00:11:54 At previous patches I did call from ~RenderViewImp
+ ->SetScreenOrientationForTesting(orientation);
if (listener_)
listener_->didChangeScreenOrientation(current_orientation_);
}

Powered by Google App Engine
This is Rietveld 408576698