Title: [120814] trunk/Source/WebCore
Revision
120814
Author
[email protected]
Date
2012-06-20 03:36:50 -0700 (Wed, 20 Jun 2012)

Log Message

Adds DeviceMotionClientMock
https://bugs.webkit.org/show_bug.cgi?id=89220

Patch by Amy Ousterhout <[email protected]> on 2012-06-20
Reviewed by Steve Block.

No new tests because DeviceMotionClientMock is designed to enable future testing and cannot be tested in itself.

Adds DeviceMotionClientMock in WebCore to enable testing of DeviceMotion once it is fully implemented in WebKit.
This addition was originally included in https://bugs.webkit.org/show_bug.cgi?id=89197 but was split into a separate patch for easier review.

* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.gypi:
* platform/mock/DeviceMotionClientMock.cpp: Added.
(WebCore):
(WebCore::DeviceMotionClientMock::DeviceMotionClientMock):
(WebCore::DeviceMotionClientMock::setController):
(WebCore::DeviceMotionClientMock::startUpdating):
(WebCore::DeviceMotionClientMock::stopUpdating):
(WebCore::DeviceMotionClientMock::setMotion):
(WebCore::DeviceMotionClientMock::timerFired):
* platform/mock/DeviceMotionClientMock.h: Added.
(WebCore):
(DeviceMotionClientMock):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/CMakeLists.txt (120813 => 120814)


--- trunk/Source/WebCore/CMakeLists.txt	2012-06-20 09:58:22 UTC (rev 120813)
+++ trunk/Source/WebCore/CMakeLists.txt	2012-06-20 10:36:50 UTC (rev 120814)
@@ -1250,6 +1250,7 @@
     platform/graphics/transforms/TransformState.cpp
     platform/graphics/transforms/TranslateTransformOperation.cpp
 
+    platform/mock/DeviceMotionClientMock.cpp
     platform/mock/DeviceOrientationClientMock.cpp
     platform/mock/GeolocationClientMock.cpp
     platform/mock/ScrollbarThemeMock.cpp

Modified: trunk/Source/WebCore/ChangeLog (120813 => 120814)


--- trunk/Source/WebCore/ChangeLog	2012-06-20 09:58:22 UTC (rev 120813)
+++ trunk/Source/WebCore/ChangeLog	2012-06-20 10:36:50 UTC (rev 120814)
@@ -1,3 +1,31 @@
+2012-06-20  Amy Ousterhout  <[email protected]>
+
+        Adds DeviceMotionClientMock
+        https://bugs.webkit.org/show_bug.cgi?id=89220
+
+        Reviewed by Steve Block.
+
+        No new tests because DeviceMotionClientMock is designed to enable future testing and cannot be tested in itself.
+
+        Adds DeviceMotionClientMock in WebCore to enable testing of DeviceMotion once it is fully implemented in WebKit.
+        This addition was originally included in https://bugs.webkit.org/show_bug.cgi?id=89197 but was split into a separate patch for easier review.
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * Target.pri:
+        * WebCore.gypi:
+        * platform/mock/DeviceMotionClientMock.cpp: Added.
+        (WebCore):
+        (WebCore::DeviceMotionClientMock::DeviceMotionClientMock):
+        (WebCore::DeviceMotionClientMock::setController):
+        (WebCore::DeviceMotionClientMock::startUpdating):
+        (WebCore::DeviceMotionClientMock::stopUpdating):
+        (WebCore::DeviceMotionClientMock::setMotion):
+        (WebCore::DeviceMotionClientMock::timerFired):
+        * platform/mock/DeviceMotionClientMock.h: Added.
+        (WebCore):
+        (DeviceMotionClientMock):
+
 2012-06-19  Vivek Galatage  <[email protected]>
 
         Web Inspector: Clicking "Clear all profiles" while ongoing recording should reset the ProfileLauncherView

Modified: trunk/Source/WebCore/GNUmakefile.list.am (120813 => 120814)


--- trunk/Source/WebCore/GNUmakefile.list.am	2012-06-20 09:58:22 UTC (rev 120813)
+++ trunk/Source/WebCore/GNUmakefile.list.am	2012-06-20 10:36:50 UTC (rev 120814)
@@ -3479,6 +3479,8 @@
 	Source/WebCore/platform/mediastream/gstreamer/DeprecatedPeerConnectionHandler.cpp \
 	Source/WebCore/platform/mediastream/gstreamer/MediaStreamCenterGStreamer.cpp \
 	Source/WebCore/platform/mediastream/gstreamer/MediaStreamCenterGStreamer.h \
+	Source/WebCore/platform/mock/DeviceMotionClientMock.cpp \
+	Source/WebCore/platform/mock/DeviceMotionClientMock.h \
 	Source/WebCore/platform/mock/DeviceOrientationClientMock.cpp \
 	Source/WebCore/platform/mock/DeviceOrientationClientMock.h \
 	Source/WebCore/platform/mock/GeolocationClientMock.cpp \

Modified: trunk/Source/WebCore/Target.pri (120813 => 120814)


--- trunk/Source/WebCore/Target.pri	2012-06-20 09:58:22 UTC (rev 120813)
+++ trunk/Source/WebCore/Target.pri	2012-06-20 10:36:50 UTC (rev 120814)
@@ -1164,6 +1164,7 @@
     platform/MemoryPressureHandler.cpp \
     platform/MemoryUsageSupport.cpp \
     platform/MIMETypeRegistry.cpp \
+    platform/mock/DeviceMotionClientMock.cpp \
     platform/mock/DeviceOrientationClientMock.cpp \
     platform/mock/GeolocationClientMock.cpp \
     platform/mock/ScrollbarThemeMock.cpp \
@@ -2221,6 +2222,7 @@
     platform/FileSystem.h \
     platform/HistogramSupport.h \
     platform/image-decoders/ImageDecoder.h \
+    platform/mock/DeviceMotionClientMock.h \
     platform/mock/DeviceOrientationClientMock.h \
     platform/mock/GeolocationClientMock.cpp \
     platform/mock/ScrollbarThemeMock.h \

Modified: trunk/Source/WebCore/WebCore.gypi (120813 => 120814)


--- trunk/Source/WebCore/WebCore.gypi	2012-06-20 09:58:22 UTC (rev 120813)
+++ trunk/Source/WebCore/WebCore.gypi	2012-06-20 10:36:50 UTC (rev 120814)
@@ -456,6 +456,7 @@
             'platform/mediastream/chromium/PeerConnection00Handler.cpp',
             'platform/mediastream/chromium/PeerConnection00HandlerInternal.cpp',
             'platform/mediastream/chromium/PeerConnection00HandlerInternal.h',
+            'platform/mock/DeviceMotionClientMock.h',
             'platform/mock/DeviceOrientationClientMock.h',
             'platform/mock/GeolocationClientMock.h',
             'platform/network/AuthenticationChallengeBase.h',
@@ -622,6 +623,8 @@
             'dom/ContextFeatures.cpp',
             'dom/DOMImplementation.h',
             'dom/DOMTimeStamp.h',
+            'dom/DeviceMotionClient.h',
+            'dom/DeviceMotionData.h',
             'dom/DeviceOrientation.h',
             'dom/DeviceOrientationClient.h',
             'dom/Document.h',
@@ -4342,6 +4345,7 @@
             'platform/mac/WebCoreView.m',
             'platform/mac/WebFontCache.mm',
             'platform/mac/WidgetMac.mm',
+            'platform/mock/DeviceMotionClientMock.cpp',
             'platform/mock/DeviceOrientationClientMock.cpp',
             'platform/mock/GeolocationClientMock.cpp',
             'platform/mock/ScrollbarThemeMock.cpp',

Added: trunk/Source/WebCore/platform/mock/DeviceMotionClientMock.cpp (0 => 120814)


--- trunk/Source/WebCore/platform/mock/DeviceMotionClientMock.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/mock/DeviceMotionClientMock.cpp	2012-06-20 10:36:50 UTC (rev 120814)
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2012 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 "DeviceMotionClientMock.h"
+
+#include "DeviceMotionController.h"
+
+namespace WebCore {
+
+DeviceMotionClientMock::DeviceMotionClientMock()
+    : m_controller(0)
+    , m_timer(this, &DeviceMotionClientMock::timerFired)
+    , m_isUpdating(false)
+{
+}
+
+void DeviceMotionClientMock::setController(DeviceMotionController* controller)
+{
+    ASSERT(!m_controller);
+    m_controller = controller;
+    ASSERT(m_controller);
+}
+
+void DeviceMotionClientMock::startUpdating()
+{
+    m_isUpdating = true;
+}
+
+void DeviceMotionClientMock::stopUpdating()
+{
+    m_isUpdating = false;
+    m_timer.stop();
+}
+
+void DeviceMotionClientMock::setMotion(PassRefPtr<DeviceMotionData> motion)
+{
+    m_motion = motion;
+    if (m_isUpdating && !m_timer.isActive())
+        m_timer.startOneShot(0);
+}
+
+void DeviceMotionClientMock::timerFired(Timer<DeviceMotionClientMock>* timer)
+{
+    ASSERT_UNUSED(timer, timer == &m_timer);
+    m_timer.stop();
+    m_controller->didChangeDeviceMotion(m_motion.get());
+}
+
+} // namespace WebCore

Added: trunk/Source/WebCore/platform/mock/DeviceMotionClientMock.h (0 => 120814)


--- trunk/Source/WebCore/platform/mock/DeviceMotionClientMock.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/mock/DeviceMotionClientMock.h	2012-06-20 10:36:50 UTC (rev 120814)
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2012 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 DeviceMotionClientMock_h
+#define DeviceMotionClientMock_h
+
+#include "DeviceMotionClient.h"
+#include "DeviceMotionData.h"
+#include "Timer.h"
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class DeviceMotionController;
+
+// A mock implementation of DeviceMotionClient used to test the feature in
+// DumpRenderTree. Embedders should should configure the Page object to use this
+// client when running DumpRenderTree.
+class DeviceMotionClientMock : public DeviceMotionClient {
+public:
+    DeviceMotionClientMock();
+
+    // DeviceMotionClient
+    virtual void setController(DeviceMotionController*) OVERRIDE;
+    virtual void startUpdating() OVERRIDE;
+    virtual void stopUpdating() OVERRIDE;
+    virtual DeviceMotionData* lastMotion() const OVERRIDE { return m_motion.get(); }
+    // mock is owned by the testing framework, which should handle deletion
+    virtual void deviceMotionControllerDestroyed() OVERRIDE { }
+
+    void setMotion(PassRefPtr<DeviceMotionData>);
+
+private:
+    void timerFired(Timer<DeviceMotionClientMock>*);
+
+    RefPtr<DeviceMotionData> m_motion;
+    DeviceMotionController* m_controller;
+    Timer<DeviceMotionClientMock> m_timer;
+    bool m_isUpdating;
+};
+
+} // namespace WebCore
+
+#endif // DeviceMotionClientMock_h
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to