2010-07-30  Steve Block  <steveblock@google.com>

        Reviewed by Steve Block.

        Add LayoutTestController methods to test DeviceOrientation
        https://bugs.webkit.org/show_bug.cgi?id=39589

        * fast/dom/DeviceOrientation/basic-operation-expected.txt: Added.
        * fast/dom/DeviceOrientation/basic-operation.html: Added.
        * fast/dom/DeviceOrientation/script-tests/basic-operation.js: Added.
        * platform/gtk/Skipped:
2010-07-30  Steve Block  <steveblock@google.com>

        Reviewed by Steve Block.

        Add LayoutTestController methods to test DeviceOrientation
        https://bugs.webkit.org/show_bug.cgi?id=39589

        This patch does not hook up the new LayoutTestController method to WebKit
        for any platform. This will be done in later patches.
        https://bugs.webkit.org/show_bug.cgi?id=43181 tracks this for Mac.

        Test: fast/dom/DeviceOrientation/basic-operation.html

        * Android.mk:
        * CMakeLists.txt:
        * GNUmakefile.am:
        * WebCore.exp.in:
        * WebCore.gypi:
        * WebCore.pro:
        * WebCore.vcproj/WebCore.vcproj:
        * WebCore.xcodeproj/project.pbxproj:
        * dom/DeviceOrientationClient.h:
        (WebCore::DeviceOrientationClient::~DeviceOrientationClient):
        * dom/DeviceOrientationController.cpp:
        (WebCore::DeviceOrientationController::DeviceOrientationController):
        * dom/DeviceOrientationEvent.cpp:
        * platform/mock/DeviceOrientationClientMock.cpp: Added.
        (WebCore::DeviceOrientationClientMock::DeviceOrientationClientMock):
        (WebCore::DeviceOrientationClientMock::setController):
        (WebCore::DeviceOrientationClientMock::startUpdating):
        (WebCore::DeviceOrientationClientMock::stopUpdating):
        (WebCore::DeviceOrientationClientMock::setOrientation):
        (WebCore::DeviceOrientationClientMock::timerFired):
        * platform/mock/DeviceOrientationClientMock.h: Added.
        (WebCore::DeviceOrientationClientMock::lastOrientation):
2010-07-30  Steve Block  <steveblock@google.com>

        Reviewed by Steve Block.

        Add LayoutTestController methods to test DeviceOrientation
        https://bugs.webkit.org/show_bug.cgi?id=39589

        * DumpRenderTree/LayoutTestController.cpp:
        (setMockDeviceOrientationCallback):
        (LayoutTestController::staticFunctions):
        * DumpRenderTree/LayoutTestController.h:
        * DumpRenderTree/chromium/LayoutTestController.cpp:
        (LayoutTestController::LayoutTestController):
        (LayoutTestController::setMockDeviceOrientation):
        * DumpRenderTree/chromium/LayoutTestController.h:
        * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
        (LayoutTestController::setMockDeviceOrientation):
        * DumpRenderTree/mac/LayoutTestControllerMac.mm:
        (LayoutTestController::setMockDeviceOrientation):
        * DumpRenderTree/qt/LayoutTestControllerQt.cpp:
        (LayoutTestController::setMockDeviceOrientation):
        * DumpRenderTree/qt/LayoutTestControllerQt.h:
        * DumpRenderTree/win/LayoutTestControllerWin.cpp:
        (LayoutTestController::setMockDeviceOrientation):
        * DumpRenderTree/wx/LayoutTestControllerWx.cpp:
        (LayoutTestController::setMockDeviceOrientation):
        * Scripts/build-webkit:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64356 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/Android.mk b/WebCore/Android.mk
index 280af55..f098d63 100644
--- a/WebCore/Android.mk
+++ b/WebCore/Android.mk
@@ -516,6 +516,7 @@
 	platform/image-decoders/gif/GIFImageDecoder.cpp \
 	platform/image-decoders/gif/GIFImageReader.cpp \
 	\
+	platform/mock/DeviceOrientationClientMock.cpp \
 	platform/mock/GeolocationServiceMock.cpp \
 	platform/mock/SpeechInputClientMock.cpp \
 	\
diff --git a/WebCore/CMakeLists.txt b/WebCore/CMakeLists.txt
index bf91cf8..8f4d542 100644
--- a/WebCore/CMakeLists.txt
+++ b/WebCore/CMakeLists.txt
@@ -1275,6 +1275,7 @@
     platform/image-decoders/jpeg/JPEGImageDecoder.cpp
     platform/image-decoders/png/PNGImageDecoder.cpp
 
+    platform/mock/DeviceOrientationClientMock.cpp
     platform/mock/GeolocationServiceMock.cpp
 
     platform/network/AuthenticationChallengeBase.cpp
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index ac9ede7..fe33ea0 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,39 @@
+2010-07-30  Steve Block  <steveblock@google.com>
+
+        Reviewed by Steve Block.
+
+        Add LayoutTestController methods to test DeviceOrientation
+        https://bugs.webkit.org/show_bug.cgi?id=39589
+
+        This patch does not hook up the new LayoutTestController method to WebKit
+        for any platform. This will be done in later patches.
+        https://bugs.webkit.org/show_bug.cgi?id=43181 tracks this for Mac.
+
+        Test: fast/dom/DeviceOrientation/basic-operation.html
+
+        * Android.mk:
+        * CMakeLists.txt:
+        * GNUmakefile.am:
+        * WebCore.exp.in:
+        * WebCore.gypi:
+        * WebCore.pro:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * dom/DeviceOrientationClient.h:
+        (WebCore::DeviceOrientationClient::~DeviceOrientationClient):
+        * dom/DeviceOrientationController.cpp:
+        (WebCore::DeviceOrientationController::DeviceOrientationController):
+        * dom/DeviceOrientationEvent.cpp:
+        * platform/mock/DeviceOrientationClientMock.cpp: Added.
+        (WebCore::DeviceOrientationClientMock::DeviceOrientationClientMock):
+        (WebCore::DeviceOrientationClientMock::setController):
+        (WebCore::DeviceOrientationClientMock::startUpdating):
+        (WebCore::DeviceOrientationClientMock::stopUpdating):
+        (WebCore::DeviceOrientationClientMock::setOrientation):
+        (WebCore::DeviceOrientationClientMock::timerFired):
+        * platform/mock/DeviceOrientationClientMock.h: Added.
+        (WebCore::DeviceOrientationClientMock::lastOrientation):
+
 2010-07-30  Satish Sampath  <satish@chromium.org>
 
         Reviewed by Jeremy Orlow.
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index effa220..c3e9b4a 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -1897,6 +1897,8 @@
 	WebCore/platform/Logging.h \
 	WebCore/platform/MIMETypeRegistry.cpp \
 	WebCore/platform/MIMETypeRegistry.h \
+	WebCore/platform/mock/DeviceOrientationClientMock.cpp \
+	WebCore/platform/mock/DeviceOrientationClientMock.h \
 	WebCore/platform/mock/GeolocationServiceMock.cpp \
 	WebCore/platform/mock/GeolocationServiceMock.h \
 	WebCore/platform/mock/SpeechInputClientMock.cpp \
diff --git a/WebCore/WebCore.exp.in b/WebCore/WebCore.exp.in
index 0c137c9..4262d81 100644
--- a/WebCore/WebCore.exp.in
+++ b/WebCore/WebCore.exp.in
@@ -402,6 +402,7 @@
 __ZN7WebCore16jsStringSlowCaseEPN3JSC9ExecStateERNS0_9WeakGCMapIPNS_10StringImplEPNS0_8JSStringEEES5_
 __ZN7WebCore17CredentialStorage3getERKNS_15ProtectionSpaceE
 __ZN7WebCore17DOMImplementation14isTextMIMETypeERKNS_6StringE
+__ZN7WebCore17DeviceOrientation6createEbdbdbd
 __ZN7WebCore17GlyphPageTreeNode18treeGlyphPageCountEv
 __ZN7WebCore17HTMLPlugInElement11getNPObjectEv
 __ZN7WebCore17HistoryController26saveDocumentAndScrollStateEv
@@ -490,6 +491,8 @@
 __ZN7WebCore26contextMenuItemTagOpenLinkEv
 __ZN7WebCore26usesTestModeFocusRingColorEv
 __ZN7WebCore27CSSComputedStyleDeclarationC1EN3WTF10PassRefPtrINS_4NodeEEEbRKNS_6StringE
+__ZN7WebCore27DeviceOrientationClientMock14setOrientationEN3WTF10PassRefPtrINS_17DeviceOrientationEEE
+__ZN7WebCore27DeviceOrientationClientMockC1Ev
 __ZN7WebCore27applicationIsAdobeInstallerEv
 __ZN7WebCore27contextMenuItemTagShowFontsEv
 __ZN7WebCore27contextMenuItemTagUnderlineEv
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index 848aa11..660db9b 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -3012,6 +3012,8 @@
             'platform/Logging.h',
             'platform/MIMETypeRegistry.cpp',
             'platform/MIMETypeRegistry.h',
+            'platform/mock/DeviceOrientationClientMock.cpp',
+            'platform/mock/DeviceOrientationClientMock.h',
             'platform/mock/GeolocationServiceMock.cpp',
             'platform/mock/GeolocationServiceMock.h',
             'platform/mock/SpeechInputClientMock.cpp',
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index 65c285e..452b44a 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -912,6 +912,7 @@
     platform/LinkHash.cpp \
     platform/Logging.cpp \
     platform/MIMETypeRegistry.cpp \
+    platform/mock/DeviceOrientationClientMock.cpp \
     platform/mock/GeolocationServiceMock.cpp \
     platform/mock/SpeechInputClientMock.cpp \
     platform/network/AuthenticationChallengeBase.cpp \
@@ -1631,6 +1632,7 @@
     platform/FileChooser.h \
     platform/GeolocationService.h \
     platform/image-decoders/ImageDecoder.h \
+    platform/mock/DeviceOrientationClientMock.h \
     platform/mock/GeolocationServiceMock.h \
     platform/mock/SpeechInputClientMock.h \
     platform/graphics/BitmapImage.h \
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index 5855fa1..84cb2f9 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -28172,6 +28172,14 @@
 				Name="mock"

 				>

 				<File

+					RelativePath="..\platform\mock\DeviceOrientationClientMock.cpp"

+					>

+				</File>

+				<File

+					RelativePath="..\platform\mock\DeviceOrientationClientMock.h"

+					>

+				</File>

+				<File

 					RelativePath="..\platform\mock\GeolocationServiceMock.cpp"

 					>

 				</File>

diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index 6a3e101..c4cde72 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -1190,10 +1190,12 @@
 		54C50F7B0E801DF3009832A0 /* XMLDocumentParserLibxml2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 54C50F7A0E801DF3009832A0 /* XMLDocumentParserLibxml2.cpp */; };
 		550A0BC9085F6039007353D6 /* QualifiedName.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 550A0BC7085F6039007353D6 /* QualifiedName.cpp */; };
 		550A0BCA085F6039007353D6 /* QualifiedName.h in Headers */ = {isa = PBXBuildFile; fileRef = 550A0BC8085F6039007353D6 /* QualifiedName.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		590E1B4911E4EF4B0069F784 /* DeviceOrientation.h in Headers */ = {isa = PBXBuildFile; fileRef = 590E1B4811E4EF4B0069F784 /* DeviceOrientation.h */; };
+		590E1B4911E4EF4B0069F784 /* DeviceOrientation.h in Headers */ = {isa = PBXBuildFile; fileRef = 590E1B4811E4EF4B0069F784 /* DeviceOrientation.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		590E1B4B11E4EF700069F784 /* JSDeviceOrientationEventCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 590E1B4A11E4EF700069F784 /* JSDeviceOrientationEventCustom.cpp */; };
 		5913953B110758450083EC55 /* JNIBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 5913953A110758450083EC55 /* JNIBridge.h */; };
 		5913953D1107584E0083EC55 /* JNIBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5913953C1107584E0083EC55 /* JNIBridge.cpp */; };
+		59309A1111F4AE5800250603 /* DeviceOrientationClientMock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 59309A1011F4AE5800250603 /* DeviceOrientationClientMock.cpp */; };
+		59309A1311F4AE6A00250603 /* DeviceOrientationClientMock.h in Headers */ = {isa = PBXBuildFile; fileRef = 59309A1211F4AE6A00250603 /* DeviceOrientationClientMock.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		596229781133EFD700DC4CBB /* GeolocationPositionCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 596229771133EFD700DC4CBB /* GeolocationPositionCache.cpp */; };
 		5962297A1133EFE200DC4CBB /* GeolocationPositionCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 596229791133EFE200DC4CBB /* GeolocationPositionCache.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		599E759011055A1F00D904FA /* Bridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 599E758F11055A1F00D904FA /* Bridge.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -1203,7 +1205,7 @@
 		59A86008119DAFA100DEF1EF /* JSDeviceOrientationEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 59A86007119DAFA100DEF1EF /* JSDeviceOrientationEvent.h */; };
 		59A8F1D411A69508001AC34A /* DeviceOrientationController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 59A8F1D311A69508001AC34A /* DeviceOrientationController.cpp */; };
 		59A8F1D611A69513001AC34A /* DeviceOrientationController.h in Headers */ = {isa = PBXBuildFile; fileRef = 59A8F1D511A69513001AC34A /* DeviceOrientationController.h */; };
-		59A8F1D811A69520001AC34A /* DeviceOrientationClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 59A8F1D711A69520001AC34A /* DeviceOrientationClient.h */; };
+		59A8F1D811A69520001AC34A /* DeviceOrientationClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 59A8F1D711A69520001AC34A /* DeviceOrientationClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		59A9E7B01104758800DFB4C1 /* JavaInstanceJSC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 59A9E7AF1104758800DFB4C1 /* JavaInstanceJSC.cpp */; };
 		59A9E7B21104759400DFB4C1 /* JavaInstanceJSC.h in Headers */ = {isa = PBXBuildFile; fileRef = 59A9E7B11104759400DFB4C1 /* JavaInstanceJSC.h */; };
 		59B597731108656B007159E8 /* BridgeJSC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 59B597721108656B007159E8 /* BridgeJSC.cpp */; };
@@ -6966,6 +6968,8 @@
 		590E1B4A11E4EF700069F784 /* JSDeviceOrientationEventCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDeviceOrientationEventCustom.cpp; sourceTree = "<group>"; };
 		5913953A110758450083EC55 /* JNIBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JNIBridge.h; sourceTree = "<group>"; };
 		5913953C1107584E0083EC55 /* JNIBridge.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JNIBridge.cpp; sourceTree = "<group>"; };
+		59309A1011F4AE5800250603 /* DeviceOrientationClientMock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DeviceOrientationClientMock.cpp; path = mock/DeviceOrientationClientMock.cpp; sourceTree = "<group>"; };
+		59309A1211F4AE6A00250603 /* DeviceOrientationClientMock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DeviceOrientationClientMock.h; path = mock/DeviceOrientationClientMock.h; sourceTree = "<group>"; };
 		596229771133EFD700DC4CBB /* GeolocationPositionCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GeolocationPositionCache.cpp; sourceTree = "<group>"; };
 		596229791133EFE200DC4CBB /* GeolocationPositionCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeolocationPositionCache.h; sourceTree = "<group>"; };
 		599E758F11055A1F00D904FA /* Bridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Bridge.h; path = bridge/Bridge.h; sourceTree = "<group>"; };
@@ -12048,6 +12052,8 @@
 		59C77F101054591C00506104 /* mock */ = {
 			isa = PBXGroup;
 			children = (
+				59309A1211F4AE6A00250603 /* DeviceOrientationClientMock.h */,
+				59309A1011F4AE5800250603 /* DeviceOrientationClientMock.cpp */,
 				7535BC9212020CFF0037EC45 /* SpeechInputClientMock.cpp */,
 				7535BC9312020CFF0037EC45 /* SpeechInputClientMock.h */,
 			);
@@ -19874,6 +19880,7 @@
 				E1BE512E0CF6C512002EA959 /* XSLTUnicodeSort.h in Headers */,
 				97DD4D870FDF4D6E00ECF9A4 /* XSSAuditor.h in Headers */,
 				CE172E011136E8CE0062A533 /* ZoomMode.h in Headers */,
+				59309A1311F4AE6A00250603 /* DeviceOrientationClientMock.h in Headers */,
 				084D0E3D11F5816100081E1A /* SVGResources.h in Headers */,
 				084D0E3F11F5816100081E1A /* SVGResourcesCache.h in Headers */,
 				085B05C311FAE16C004D65F6 /* SVGResourcesCycleSolver.h in Headers */,
@@ -22273,6 +22280,7 @@
 				93F19B0508245E59001E9ABC /* XSLTProcessorLibxslt.cpp in Sources */,
 				E1BE512D0CF6C512002EA959 /* XSLTUnicodeSort.cpp in Sources */,
 				97DD4D860FDF4D6E00ECF9A4 /* XSSAuditor.cpp in Sources */,
+				59309A1111F4AE5800250603 /* DeviceOrientationClientMock.cpp in Sources */,
 				084D0E3C11F5816100081E1A /* SVGResources.cpp in Sources */,
 				084D0E3E11F5816100081E1A /* SVGResourcesCache.cpp in Sources */,
 				086A400611F6D6B7002CEC53 /* RenderSVGResourceContainer.cpp in Sources */,
diff --git a/WebCore/dom/DeviceOrientationClient.h b/WebCore/dom/DeviceOrientationClient.h
index 427412f..c969c95 100644
--- a/WebCore/dom/DeviceOrientationClient.h
+++ b/WebCore/dom/DeviceOrientationClient.h
@@ -29,15 +29,16 @@
 namespace WebCore {
 
 class DeviceOrientation;
+class DeviceOrientationController;
 
 class DeviceOrientationClient {
 public:
+    virtual ~DeviceOrientationClient() {}
+
+    virtual void setController(DeviceOrientationController*) = 0;
     virtual void startUpdating() = 0;
     virtual void stopUpdating() = 0;
     virtual DeviceOrientation* lastOrientation() const = 0;
-
-protected:
-    virtual ~DeviceOrientationClient() {}
 };
 
 } // namespace WebCore
diff --git a/WebCore/dom/DeviceOrientationController.cpp b/WebCore/dom/DeviceOrientationController.cpp
index a6a33f5..111577f 100644
--- a/WebCore/dom/DeviceOrientationController.cpp
+++ b/WebCore/dom/DeviceOrientationController.cpp
@@ -26,8 +26,6 @@
 #include "config.h"
 #include "DeviceOrientationController.h"
 
-#if ENABLE(DEVICE_ORIENTATION)
-
 #include "DeviceOrientation.h"
 #include "DeviceOrientationClient.h"
 #include "DeviceOrientationEvent.h"
@@ -39,6 +37,8 @@
     , m_client(client)
     , m_timer(this, &DeviceOrientationController::timerFired)
 {
+    ASSERT(m_client);
+    m_client->setController(this);
 }
 
 void DeviceOrientationController::timerFired(Timer<DeviceOrientationController>* timer)
@@ -105,5 +105,3 @@
 }
 
 } // namespace WebCore
-
-#endif // ENABLE(DEVICE_ORIENTATION)
diff --git a/WebCore/dom/DeviceOrientationEvent.cpp b/WebCore/dom/DeviceOrientationEvent.cpp
index 992b6ce..932cb75 100644
--- a/WebCore/dom/DeviceOrientationEvent.cpp
+++ b/WebCore/dom/DeviceOrientationEvent.cpp
@@ -28,8 +28,6 @@
 
 #include "DeviceOrientation.h"
 
-#if ENABLE(DEVICE_ORIENTATION)
-
 namespace WebCore {
 
 DeviceOrientationEvent::~DeviceOrientationEvent()
@@ -57,5 +55,3 @@
 }
 
 } // namespace WebCore
-
-#endif // ENABLE(DEVICE_ORIENTATION)
diff --git a/WebCore/platform/mock/DeviceOrientationClientMock.cpp b/WebCore/platform/mock/DeviceOrientationClientMock.cpp
new file mode 100644
index 0000000..c2c9316
--- /dev/null
+++ b/WebCore/platform/mock/DeviceOrientationClientMock.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DeviceOrientationClientMock.h"
+
+#include "DeviceOrientationController.h"
+
+namespace WebCore {
+
+DeviceOrientationClientMock::DeviceOrientationClientMock()
+    : m_controller(0)
+    , m_timer(this, &DeviceOrientationClientMock::timerFired)
+    , m_isUpdating(false)
+{
+}
+
+void DeviceOrientationClientMock::setController(DeviceOrientationController* controller)
+{
+    m_controller = controller;
+    ASSERT(m_controller);
+}
+
+void DeviceOrientationClientMock::startUpdating()
+{
+    m_isUpdating = true;
+}
+
+void DeviceOrientationClientMock::stopUpdating()
+{
+    m_isUpdating = false;
+    m_timer.stop();
+}
+
+void DeviceOrientationClientMock::setOrientation(PassRefPtr<DeviceOrientation> orientation)
+{
+    m_orientation = orientation;
+    if (m_isUpdating && !m_timer.isActive())
+        m_timer.startOneShot(0);
+}
+
+void DeviceOrientationClientMock::timerFired(Timer<DeviceOrientationClientMock>* timer)
+{
+    ASSERT_UNUSED(timer, timer == &m_timer);
+    m_timer.stop();
+    m_controller->didChangeDeviceOrientation(m_orientation.get());
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/mock/DeviceOrientationClientMock.h b/WebCore/platform/mock/DeviceOrientationClientMock.h
new file mode 100644
index 0000000..6691130
--- /dev/null
+++ b/WebCore/platform/mock/DeviceOrientationClientMock.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DeviceOrientationClientMock_h
+#define DeviceOrientationClientMock_h
+
+#include "DeviceOrientation.h"
+#include "DeviceOrientationClient.h"
+#include "Timer.h"
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class DeviceOrientationController;
+
+// A mock implementation of DeviceOrientationClient used to test the feature in
+// DumpRenderTree. Embedders should should configure the Page object to use this
+// client when running DumpRenderTree.
+class DeviceOrientationClientMock : public DeviceOrientationClient {
+public:
+    DeviceOrientationClientMock();
+
+    // DeviceOrientationClient
+    virtual void setController(DeviceOrientationController*);
+    virtual void startUpdating();
+    virtual void stopUpdating();
+    virtual DeviceOrientation* lastOrientation() const { return m_orientation.get(); }
+
+    void setOrientation(PassRefPtr<DeviceOrientation>);
+
+private:
+    void timerFired(Timer<DeviceOrientationClientMock>*);
+
+    RefPtr<DeviceOrientation> m_orientation;
+    DeviceOrientationController* m_controller;
+    Timer<DeviceOrientationClientMock> m_timer;
+    bool m_isUpdating;
+};
+
+} // namespace WebCore
+
+#endif // DeviceOrientationClientMock_h