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

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: Now ResetMockScreenOrientationForTesting() is called on every layout test finish, so replaced DCHEC… Created 6 years, 6 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..f0b1a6df4e5e3aead135ead6b4870b10cf85a06e 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.
+ DCHECK_EQ(this->render_view(), render_view);
+ } else {
+ Observe(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
« no previous file with comments | « content/renderer/screen_orientation/mock_screen_orientation_controller.h ('k') | content/test/layouttest_support.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698