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

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: 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 d16bc74e38d484a85ae12d069d94b877f7bbdace..0b74481318dfe404d35f50bdce114f9450370248 100644
--- a/content/renderer/screen_orientation/mock_screen_orientation_controller.cc
+++ b/content/renderer/screen_orientation/mock_screen_orientation_controller.cc
@@ -5,6 +5,7 @@
#include "content/renderer/screen_orientation/mock_screen_orientation_controller.h"
#include "base/logging.h"
+#include "content/renderer/render_view_impl.h"
#include "third_party/WebKit/public/platform/WebScreenOrientationListener.h"
namespace content {
@@ -13,7 +14,8 @@ MockScreenOrientationController::MockScreenOrientationController()
: current_lock_(blink::WebScreenOrientationLockDefault),
device_orientation_(blink::WebScreenOrientationPortraitPrimary),
current_orientation_(blink::WebScreenOrientationPortraitPrimary),
- listener_(NULL) {
+ listener_(NULL),
+ render_view_(NULL) {
}
void MockScreenOrientationController::SetListener(
@@ -44,7 +46,15 @@ void MockScreenOrientationController::ResetLock() {
}
void MockScreenOrientationController::UpdateDeviceOrientation(
+ RenderView* render_view,
blink::WebScreenOrientationType orientation) {
+ if (render_view_) {
+ // Make sure that render_view_ did not change during test.
+ assert(render_view_ == render_view);
+ } else {
+ render_view_ = render_view;
+ }
mlamouri (slow - plz ping) 2014/05/28 13:45:20 I guess you can do: assert(!render_view_ || rend
ostap 2014/05/28 19:17:05 Done.
+
if (device_orientation_ == orientation)
return;
device_orientation_ = orientation;
@@ -58,6 +68,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_);
Inactive 2014/05/28 12:02:20 BTW, we should get rid of the old listener old in
}
@@ -104,4 +117,8 @@ MockScreenOrientationController::SuitableOrientationForCurrentLock() {
}
}
+void MockScreenOrientationController::ResetRenderView() {
+ render_view_ = 0;
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698