Title: [120744] trunk/Source/WebCore
Revision
120744
Author
[email protected]
Date
2012-06-19 12:27:48 -0700 (Tue, 19 Jun 2012)

Log Message

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

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

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.

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

* 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 (120743 => 120744)


--- trunk/Source/WebCore/CMakeLists.txt	2012-06-19 19:22:21 UTC (rev 120743)
+++ trunk/Source/WebCore/CMakeLists.txt	2012-06-19 19:27:48 UTC (rev 120744)
@@ -1247,6 +1247,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 (120743 => 120744)


--- trunk/Source/WebCore/ChangeLog	2012-06-19 19:22:21 UTC (rev 120743)
+++ trunk/Source/WebCore/ChangeLog	2012-06-19 19:27:48 UTC (rev 120744)
@@ -1,3 +1,31 @@
+2012-06-19  Amy Ousterhout  <[email protected]>
+
+        Adds DeviceMotionClientMock
+        https://bugs.webkit.org/show_bug.cgi?id=89220
+
+        Reviewed by Steve Block.
+
+        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.
+
+        No new tests because DeviceMotionClientMock is designed to enable future testing and cannot be tested in itself.
+
+        * 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  Alexandre Elias  <[email protected]>
 
         Fix link error with fillWithEmptyClients

Modified: trunk/Source/WebCore/GNUmakefile.list.am (120743 => 120744)


--- trunk/Source/WebCore/GNUmakefile.list.am	2012-06-19 19:22:21 UTC (rev 120743)
+++ trunk/Source/WebCore/GNUmakefile.list.am	2012-06-19 19:27:48 UTC (rev 120744)
@@ -3475,6 +3475,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 (120743 => 120744)


--- trunk/Source/WebCore/Target.pri	2012-06-19 19:22:21 UTC (rev 120743)
+++ trunk/Source/WebCore/Target.pri	2012-06-19 19:27:48 UTC (rev 120744)
@@ -1163,6 +1163,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 \
@@ -2219,6 +2220,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 (120743 => 120744)


--- trunk/Source/WebCore/WebCore.gypi	2012-06-19 19:22:21 UTC (rev 120743)
+++ trunk/Source/WebCore/WebCore.gypi	2012-06-19 19:27:48 UTC (rev 120744)
@@ -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/DeviceMotion.h',
+            'dom/DeviceMotionClient.h',
             'dom/DeviceOrientation.h',
             'dom/DeviceOrientationClient.h',
             'dom/Document.h',
@@ -4338,6 +4341,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 => 120744)


--- trunk/Source/WebCore/platform/mock/DeviceMotionClientMock.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/mock/DeviceMotionClientMock.cpp	2012-06-19 19:27:48 UTC (rev 120744)
@@ -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 => 120744)


--- trunk/Source/WebCore/platform/mock/DeviceMotionClientMock.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/mock/DeviceMotionClientMock.h	2012-06-19 19:27:48 UTC (rev 120744)
@@ -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