[Qt] Mock DeviceOrientation client for DRT
authordiegohcg@webkit.org <diegohcg@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 11 Dec 2010 18:49:09 +0000 (18:49 +0000)
committerdiegohcg@webkit.org <diegohcg@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 11 Dec 2010 18:49:09 +0000 (18:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=47490

Reviewed by Kenneth Rohde Christiansen.

WebCore:

* WebCore.pro:

WebKit/qt:

* WebCoreSupport/DeviceOrientationClientMockQt.cpp: Added.
(WebCore::DeviceOrientationClientMockQt::client):
(WebCore::DeviceOrientationClientMockQt::DeviceOrientationClientMockQt):
(WebCore::DeviceOrientationClientMockQt::~DeviceOrientationClientMockQt):
(WebCore::DeviceOrientationClientMockQt::setController):
(WebCore::DeviceOrientationClientMockQt::startUpdating):
(WebCore::DeviceOrientationClientMockQt::stopUpdating):
(WebCore::DeviceOrientationClientMockQt::lastOrientation):
(WebCore::DeviceOrientationClientMockQt::deviceOrientationControllerDestroyed):
(WebCore::DeviceOrientationClientMockQt::setOrientation):
* WebCoreSupport/DeviceOrientationClientMockQt.h: Added.
* WebCoreSupport/DeviceOrientationClientQt.cpp:
* WebCoreSupport/DeviceOrientationProviderQt.cpp:
(WebCore::DeviceOrientationProviderQt::DeviceOrientationProviderQt):
(WebCore::DeviceOrientationProviderQt::~DeviceOrientationProviderQt):
(WebCore::DeviceOrientationProviderQt::changeDeviceOrientation):
* WebCoreSupport/DeviceOrientationProviderQt.h:
* WebCoreSupport/DumpRenderTreeSupportQt.cpp:
(DumpRenderTreeSupportQt::activeMockDeviceOrientationClient):
(DumpRenderTreeSupportQt::removeMockDeviceOrientation):
(DumpRenderTreeSupportQt::setMockDeviceOrientation):
* WebCoreSupport/DumpRenderTreeSupportQt.h:

WebKitTools:

* DumpRenderTree/qt/DumpRenderTreeQt.cpp:
(WebCore::DumpRenderTree::DumpRenderTree):
(WebCore::DumpRenderTree::~DumpRenderTree):
* DumpRenderTree/qt/LayoutTestControllerQt.cpp:
(LayoutTestController::setMockDeviceOrientation):

LayoutTests:

* platform/qt/Skipped:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@73862 268f45cc-cd09-0410-ab3c-d52691b4dbfc

15 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/qt/Skipped
WebCore/ChangeLog
WebCore/WebCore.pro
WebKit/qt/ChangeLog
WebKit/qt/WebCoreSupport/DeviceOrientationClientMockQt.cpp [new file with mode: 0644]
WebKit/qt/WebCoreSupport/DeviceOrientationClientMockQt.h [new file with mode: 0644]
WebKit/qt/WebCoreSupport/DeviceOrientationClientQt.cpp
WebKit/qt/WebCoreSupport/DeviceOrientationProviderQt.cpp
WebKit/qt/WebCoreSupport/DeviceOrientationProviderQt.h
WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp
WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp
WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp

index bd1b8b8..66eea47 100644 (file)
@@ -1,3 +1,12 @@
+2010-10-11  Diego Gonzalez  <diegohcg@webkit.org>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        [Qt] Mock DeviceOrientation client for DRT
+        https://bugs.webkit.org/show_bug.cgi?id=47490
+
+        * platform/qt/Skipped:
+
 2010-12-11  Pavel Feldman  <pfeldman@chromium.org>
 
         Not reviewed. Update chromium test expectations.
index e36387c..04bec9e 100644 (file)
@@ -75,15 +75,6 @@ svg/webarchive
 # This test is for clients that choose to make the missing plugin indicator a button
 plugins/clicking-missing-plugin-fires-delegate.html
 
-# =========================================================================== #
-#       Feature not supported... yet
-# =========================================================================== #
-
-# This port doesn't support DeviceMotion or DeviceOrientation.
-fast/dom/DeviceMotion
-fast/dom/DeviceOrientation
-fast/dom/Window/window-properties-device-orientation.html
-
 # IndexedDB is not yet enabled.
 storage/indexeddb
 
@@ -3054,6 +3045,7 @@ fast/dom/row-inner-text.html
 fast/dom/setPrimitiveValue.html
 fast/dom/stripNullFromTextNodes.html
 fast/dom/wrapper-classes.html
+fast/dom/Window/window-properties-device-orientation.html
 fast/dynamic/002.html
 fast/dynamic/004.html
 fast/dynamic/006.html
index 7bf42b3..ca6a282 100644 (file)
@@ -1,3 +1,12 @@
+2010-10-11  Diego Gonzalez  <diegohcg@webkit.org>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        [Qt] Mock DeviceOrientation client for DRT
+        https://bugs.webkit.org/show_bug.cgi?id=47490
+
+        * WebCore.pro:
+
 2010-12-11  Joone Hur  <joone@kldp.org>
 
         Reviewed by Alexey Proskuryakov.
index e51e28b..7e97904 100644 (file)
@@ -3418,12 +3418,14 @@ contains(DEFINES, ENABLE_DEVICE_ORIENTATION=1) {
         ../WebKit/qt/WebCoreSupport/DeviceMotionClientQt.h \
         ../WebKit/qt/WebCoreSupport/DeviceMotionProviderQt.h \
         ../WebKit/qt/WebCoreSupport/DeviceOrientationClientQt.h \
+        ../WebKit/qt/WebCoreSupport/DeviceOrientationClientMockQt.h \
         ../WebKit/qt/WebCoreSupport/DeviceOrientationProviderQt.h \
         bindings/generic/RuntimeEnabledFeatures.h
     SOURCES += \
         ../WebKit/qt/WebCoreSupport/DeviceMotionClientQt.cpp \
         ../WebKit/qt/WebCoreSupport/DeviceMotionProviderQt.cpp \
         ../WebKit/qt/WebCoreSupport/DeviceOrientationClientQt.cpp \
+        ../WebKit/qt/WebCoreSupport/DeviceOrientationClientMockQt.cpp \
         ../WebKit/qt/WebCoreSupport/DeviceOrientationProviderQt.cpp \
         bindings/generic/RuntimeEnabledFeatures.cpp
 
index 964c484..ada1ee4 100644 (file)
@@ -1,3 +1,33 @@
+2010-10-11  Diego Gonzalez  <diegohcg@webkit.org>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        [Qt] Mock DeviceOrientation client for DRT
+        https://bugs.webkit.org/show_bug.cgi?id=47490
+
+        * WebCoreSupport/DeviceOrientationClientMockQt.cpp: Added.
+        (WebCore::DeviceOrientationClientMockQt::client):
+        (WebCore::DeviceOrientationClientMockQt::DeviceOrientationClientMockQt):
+        (WebCore::DeviceOrientationClientMockQt::~DeviceOrientationClientMockQt):
+        (WebCore::DeviceOrientationClientMockQt::setController):
+        (WebCore::DeviceOrientationClientMockQt::startUpdating):
+        (WebCore::DeviceOrientationClientMockQt::stopUpdating):
+        (WebCore::DeviceOrientationClientMockQt::lastOrientation):
+        (WebCore::DeviceOrientationClientMockQt::deviceOrientationControllerDestroyed):
+        (WebCore::DeviceOrientationClientMockQt::setOrientation):
+        * WebCoreSupport/DeviceOrientationClientMockQt.h: Added.
+        * WebCoreSupport/DeviceOrientationClientQt.cpp:
+        * WebCoreSupport/DeviceOrientationProviderQt.cpp:
+        (WebCore::DeviceOrientationProviderQt::DeviceOrientationProviderQt):
+        (WebCore::DeviceOrientationProviderQt::~DeviceOrientationProviderQt):
+        (WebCore::DeviceOrientationProviderQt::changeDeviceOrientation):
+        * WebCoreSupport/DeviceOrientationProviderQt.h:
+        * WebCoreSupport/DumpRenderTreeSupportQt.cpp:
+        (DumpRenderTreeSupportQt::activeMockDeviceOrientationClient):
+        (DumpRenderTreeSupportQt::removeMockDeviceOrientation):
+        (DumpRenderTreeSupportQt::setMockDeviceOrientation):
+        * WebCoreSupport/DumpRenderTreeSupportQt.h:
+
 2010-12-10  Krithigassree Sambamurthy  <krithigassree.sambamurthy@nokia.com>
 
         Reviewed by Joseph Pecoraro.
diff --git a/WebKit/qt/WebCoreSupport/DeviceOrientationClientMockQt.cpp b/WebKit/qt/WebCoreSupport/DeviceOrientationClientMockQt.cpp
new file mode 100644 (file)
index 0000000..81ddaa2
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+#include "config.h"
+#include "DeviceOrientationClientMockQt.h"
+
+#include "DeviceOrientation.h"
+#include "DeviceOrientationClientMock.h"
+#include "DeviceOrientationController.h"
+
+namespace WebCore {
+
+bool DeviceOrientationClientMockQt::mockIsActive = false;
+
+DeviceOrientationClientMockQt* DeviceOrientationClientMockQt::client()
+{
+    static DeviceOrientationClientMockQt* client = 0;
+    if (!client)
+        client = new DeviceOrientationClientMockQt;
+
+    return client;
+}
+
+DeviceOrientationClientMockQt::DeviceOrientationClientMockQt()
+    : m_clientMock(new DeviceOrientationClientMock())
+{
+    m_orientation = DeviceOrientation::create();
+}
+
+DeviceOrientationClientMockQt::~DeviceOrientationClientMockQt()
+{
+    delete m_clientMock;
+}
+
+void DeviceOrientationClientMockQt::setController(DeviceOrientationController* controller)
+{
+    m_clientMock->setController(m_controller);
+}
+
+void DeviceOrientationClientMockQt::startUpdating()
+{
+    m_clientMock->startUpdating();
+}
+
+void DeviceOrientationClientMockQt::stopUpdating()
+{
+    m_clientMock->stopUpdating();
+}
+
+DeviceOrientation* DeviceOrientationClientMockQt::lastOrientation() const
+{
+    return m_orientation.get();
+}
+
+void DeviceOrientationClientMockQt::deviceOrientationControllerDestroyed()
+{
+    delete this;
+}
+
+void DeviceOrientationClientMockQt::setOrientation(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma)
+{
+    m_orientation = DeviceOrientation::create(canProvideAlpha, alpha,
+            canProvideBeta, beta,
+            canProvideGamma, gamma);
+    m_clientMock->setOrientation(m_orientation);
+
+    emit mockOrientationChanged(m_orientation.get());
+}
+
+} // namespace WebCore
+
+#include "moc_DeviceOrientationClientMockQt.cpp"
diff --git a/WebKit/qt/WebCoreSupport/DeviceOrientationClientMockQt.h b/WebKit/qt/WebCoreSupport/DeviceOrientationClientMockQt.h
new file mode 100644 (file)
index 0000000..cc5913d
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+#ifndef DeviceOrientationClientMockQt_h
+#define DeviceOrientationClientMockQt_h
+
+#include "DeviceOrientationClient.h"
+#include "RefPtr.h"
+
+#include <QObject>
+
+namespace WebCore {
+
+class DeviceOrientation;
+class DeviceOrientationClientMock;
+class DeviceOrientationController;
+
+class DeviceOrientationClientMockQt : public QObject, public DeviceOrientationClient {
+    Q_OBJECT
+public:
+    static DeviceOrientationClientMockQt* client();
+    virtual ~DeviceOrientationClientMockQt();
+
+    virtual void setController(DeviceOrientationController*);
+    virtual void startUpdating();
+    virtual void stopUpdating();
+    virtual DeviceOrientation* lastOrientation() const;
+    virtual void deviceOrientationControllerDestroyed();
+    void setOrientation(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma);
+    static bool mockIsActive;
+
+Q_SIGNALS:
+    void mockOrientationChanged(DeviceOrientation*);
+
+private:
+    DeviceOrientationClientMockQt();
+
+    DeviceOrientationClientMock* m_clientMock;
+    DeviceOrientationController* m_controller;
+    RefPtr<DeviceOrientation> m_orientation;
+};
+
+} // namespace WebCore
+
+#endif // DeviceOrientationClientMockQt_h
index 1d0c6d1..01cbe73 100644 (file)
@@ -20,6 +20,7 @@
 #include "config.h"
 #include "DeviceOrientationClientQt.h"
 
+#include "DeviceOrientationClientMockQt.h"
 #include "DeviceOrientationController.h"
 #include "DeviceOrientationProviderQt.h"
 #include "qwebpage.h"
index 051eba0..a31930d 100644 (file)
 #include "config.h"
 #include "DeviceOrientationProviderQt.h"
 
+#include "DeviceOrientationClientMockQt.h"
+
 namespace WebCore {
 
 DeviceOrientationProviderQt::DeviceOrientationProviderQt()
 {
     m_rotation.addFilter(this);
     m_orientation = DeviceOrientation::create();
+
+    if (DeviceOrientationClientMockQt::mockIsActive)
+        activeClientMock();
 }
 
 DeviceOrientationProviderQt::~DeviceOrientationProviderQt()
 {
+    disconnect();
 }
 
 void DeviceOrientationProviderQt::start()
@@ -63,6 +69,16 @@ bool DeviceOrientationProviderQt::filter(QRotationReading* reading)
     return false;
 }
 
+void DeviceOrientationProviderQt::changeDeviceOrientation(DeviceOrientation* orientation)
+{
+    m_orientation = orientation;
+}
+
+void DeviceOrientationProviderQt::activeClientMock()
+{
+    connect(DeviceOrientationClientMockQt::client(), SIGNAL(mockOrientationChanged(DeviceOrientation*)), SLOT(changeDeviceOrientation(DeviceOrientation*)));
+}
+
 }
 
 #include "moc_DeviceOrientationProviderQt.cpp"
index 86c224e..e87937e 100644 (file)
@@ -48,7 +48,12 @@ public:
 Q_SIGNALS:
     void deviceOrientationChanged(DeviceOrientation*);
 
+public Q_SLOTS:
+    void changeDeviceOrientation(DeviceOrientation*);
+
 private:
+    void activeClientMock();
+
     RefPtr<DeviceOrientation> m_orientation;
     QRotationSensor m_rotation;
 };
index f18894d..754b20a 100644 (file)
@@ -29,6 +29,8 @@
 #include "ContextMenu.h"
 #include "ContextMenuClientQt.h"
 #include "ContextMenuController.h"
+#include "DeviceOrientation.h"
+#include "DeviceOrientationClientMockQt.h"
 #include "Editor.h"
 #include "EditorClientQt.h"
 #include "Element.h"
@@ -693,6 +695,28 @@ QString DumpRenderTreeSupportQt::viewportAsText(QWebPage* page, const QSize& ava
     return res;
 }
 
+void DumpRenderTreeSupportQt::activeMockDeviceOrientationClient(bool b)
+{
+#if ENABLE(DEVICE_ORIENTATION)
+    DeviceOrientationClientMockQt::mockIsActive = b;
+#endif
+}
+
+void DumpRenderTreeSupportQt::removeMockDeviceOrientation()
+{
+#if ENABLE(DEVICE_ORIENTATION)
+    DeviceOrientationClientMockQt* client = DeviceOrientationClientMockQt::client();
+    delete client;
+#endif
+}
+
+void DumpRenderTreeSupportQt::setMockDeviceOrientation(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma)
+{
+#if ENABLE(DEVICE_ORIENTATION)
+    DeviceOrientationClientMockQt::client()->setOrientation(canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma);
+#endif
+}
+
 void DumpRenderTreeSupportQt::setMockGeolocationPosition(double latitude, double longitude, double accuracy)
 {
 #if ENABLE(GEOLOCATION)
index 184d822..e08d962 100644 (file)
@@ -94,6 +94,10 @@ public:
     static void removeWhiteListAccessFromOrigin(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains);
     static void resetOriginAccessWhiteLists();
 
+    static void activeMockDeviceOrientationClient(bool b);
+    static void removeMockDeviceOrientation();
+    static void setMockDeviceOrientation(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma);
+
     static void setMockGeolocationPosition(double latitude, double longitude, double accuracy);
     static void setMockGeolocationError(int errorCode, const QString& message);
 
index 7ee5666..bf11a01 100644 (file)
@@ -1,3 +1,16 @@
+2010-10-11  Diego Gonzalez  <diegohcg@webkit.org>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        [Qt] Mock DeviceOrientation client for DRT
+        https://bugs.webkit.org/show_bug.cgi?id=47490
+
+        * DumpRenderTree/qt/DumpRenderTreeQt.cpp:
+        (WebCore::DumpRenderTree::DumpRenderTree):
+        (WebCore::DumpRenderTree::~DumpRenderTree):
+        * DumpRenderTree/qt/LayoutTestControllerQt.cpp:
+        (LayoutTestController::setMockDeviceOrientation):
+
 2010-12-11  Philippe Normand  <pnormand@igalia.com>
 
         Reviewed by Gustavo Noronha Silva.
index c287152..4f87472 100644 (file)
@@ -420,7 +420,7 @@ DumpRenderTree::DumpRenderTree()
         setGraphicsBased(true);
 
     DumpRenderTreeSupportQt::overwritePluginDirectories();
-
+    DumpRenderTreeSupportQt::activeMockDeviceOrientationClient(true);
     QWebSettings::enablePersistentStorage(m_persistentStoragePath);
 
     m_networkAccessManager = new NetworkAccessManager(this);
@@ -496,6 +496,7 @@ DumpRenderTree::~DumpRenderTree()
 {
     delete m_mainView;
     delete m_stdin;
+    DumpRenderTreeSupportQt::removeMockDeviceOrientation();
 }
 
 static void clearHistory(QWebPage* page)
index 9e6efc0..2d00c3e 100644 (file)
@@ -750,8 +750,7 @@ void LayoutTestController::setEditingBehavior(const QString& editingBehavior)
 
 void LayoutTestController::setMockDeviceOrientation(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma)
 {
-    // FIXME: Implement for DeviceOrientation layout tests.
-    // See https://bugs.webkit.org/show_bug.cgi?id=30335.
+    DumpRenderTreeSupportQt::setMockDeviceOrientation(canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma);
 }
 
 void LayoutTestController::setGeolocationPermission(bool allow)