Index: Source/modules/screen_orientation/testing/ScreenOrientationClientMock.cpp |
diff --git a/Source/modules/screen_orientation/testing/ScreenOrientationClientMock.cpp b/Source/modules/screen_orientation/testing/ScreenOrientationClientMock.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..fe4cd4eab3c2516aed2f5efaf724aaf6693d7f01 |
--- /dev/null |
+++ b/Source/modules/screen_orientation/testing/ScreenOrientationClientMock.cpp |
@@ -0,0 +1,67 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "config.h" |
+#include "ScreenOrientationClientMock.h" |
+ |
+#include "modules/screen_orientation/ScreenOrientationController.h" |
+ |
+namespace WebCore { |
+ |
+ScreenOrientationClientMock::ScreenOrientationClientMock() |
+ : m_controllerTimer(this, &ScreenOrientationClientMock::controllerTimerFired) |
+ , m_controller(0) |
+ , m_orientation(OrientationPortraitPrimary) |
+ , m_lockedOrientations(0) |
+{ |
+} |
+ |
+ScreenOrientationClientMock::~ScreenOrientationClientMock() |
+{ |
+} |
+ |
+void ScreenOrientationClientMock::setController(ScreenOrientationController* controller) |
+{ |
+ ASSERT(controller && !m_controller); |
+ m_controller = controller; |
+} |
+ |
+void ScreenOrientationClientMock::setScreenOrientation(ScreenOrientationValue orientation) |
+{ |
+ if (orientation == m_orientation) |
+ return; |
+ |
+ if (!m_lockedOrientations || m_lockedOrientations & orientation) { |
+ m_orientation = orientation; |
+ asyncUpdateController(); |
+ } |
+} |
+ |
+void ScreenOrientationClientMock::asyncUpdateController() |
+{ |
+ ASSERT(m_controller); |
+ if (!m_controllerTimer.isActive()) |
+ m_controllerTimer.startOneShot(0); |
+} |
+ |
+void ScreenOrientationClientMock::controllerTimerFired(Timer<ScreenOrientationClientMock>* timer) |
+{ |
+ ASSERT_UNUSED(timer, timer == &m_controllerTimer); |
+ ASSERT(m_controller); |
+ |
+ m_controller->orientationChanged(m_orientation); |
+} |
+ |
+bool ScreenOrientationClientMock::lockOrientation(ScreenOrientationValues orientations) |
+{ |
+ m_lockedOrientations = orientations; |
mlamouri (slow - plz ping)
2014/02/10 18:20:57
Shouldn't you change the screen orientation asynch
Inactive
2014/02/10 22:25:24
You are right, I fixed it in a later iteration, bu
|
+ return true; |
+} |
+ |
+void ScreenOrientationClientMock::unlockOrientation() |
+{ |
+ m_lockedOrientations = 0; |
+} |
+ |
+} // namespace WebCore |