2010-12-10 John Knottenbelt <jknotten@chromium.org>

        Reviewed by Steve Block.

        [Chromium] Implement mocks for client-based geolocation
        https://bugs.webkit.org/show_bug.cgi?id=46895

        * WebKit.gyp:
        * public/WebGeolocationClientMock.h: Added.
        (WebKit::WebGeolocationClientMock::~WebGeolocationClientMock):
        (WebKit::WebGeolocationClientMock::WebGeolocationClientMock):
        * src/WebGeolocationClientMock.cpp: Added.
        (WebKit::WebGeolocationClientMock::create):
        (WebKit::WebGeolocationClientMock::initialize):
        (WebKit::WebGeolocationClientMock::reset):
        (WebKit::WebGeolocationClientMock::setMockGeolocationPosition):
        (WebKit::WebGeolocationClientMock::setMockGeolocationError):
        (WebKit::WebGeolocationClientMock::setMockGeolocationPermission):
        (WebKit::WebGeolocationClientMock::resetMock):
        (WebKit::WebGeolocationClientMock::startUpdating):
        (WebKit::WebGeolocationClientMock::stopUpdating):
        (WebKit::WebGeolocationClientMock::setEnableHighAccuracy):
        (WebKit::WebGeolocationClientMock::geolocationDestroyed):
        (WebKit::WebGeolocationClientMock::setController):
        (WebKit::WebGeolocationClientMock::lastPosition):
        (WebKit::WebGeolocationClientMock::requestPermission):
        (WebKit::WebGeolocationClientMock::cancelPermissionRequest):
        * src/WebGeolocationServiceMock.cpp:
2010-12-10  John Knottenbelt  <jknotten@chromium.org>

        Reviewed by Steve Block.

        [Chromium] Implement mocks for client-based geolocation
        https://bugs.webkit.org/show_bug.cgi?id=46895

        * DumpRenderTree/chromium/LayoutTestController.cpp:
        (LayoutTestController::setGeolocationPermission):
        (LayoutTestController::setMockGeolocationPosition):
        (LayoutTestController::setMockGeolocationError):
        * DumpRenderTree/chromium/LayoutTestController.h:
        * DumpRenderTree/chromium/WebViewHost.cpp:
        (WebViewHost::geolocationClient):
        (WebViewHost::geolocationClientMock):
        (WebViewHost::reset):
        * DumpRenderTree/chromium/WebViewHost.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73745 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 4a1481a0
2010-12-10 John Knottenbelt <jknotten@chromium.org>
Reviewed by Steve Block.
[Chromium] Implement mocks for client-based geolocation
https://bugs.webkit.org/show_bug.cgi?id=46895
* WebKit.gyp:
* public/WebGeolocationClientMock.h: Added.
(WebKit::WebGeolocationClientMock::~WebGeolocationClientMock):
(WebKit::WebGeolocationClientMock::WebGeolocationClientMock):
* src/WebGeolocationClientMock.cpp: Added.
(WebKit::WebGeolocationClientMock::create):
(WebKit::WebGeolocationClientMock::initialize):
(WebKit::WebGeolocationClientMock::reset):
(WebKit::WebGeolocationClientMock::setMockGeolocationPosition):
(WebKit::WebGeolocationClientMock::setMockGeolocationError):
(WebKit::WebGeolocationClientMock::setMockGeolocationPermission):
(WebKit::WebGeolocationClientMock::resetMock):
(WebKit::WebGeolocationClientMock::startUpdating):
(WebKit::WebGeolocationClientMock::stopUpdating):
(WebKit::WebGeolocationClientMock::setEnableHighAccuracy):
(WebKit::WebGeolocationClientMock::geolocationDestroyed):
(WebKit::WebGeolocationClientMock::setController):
(WebKit::WebGeolocationClientMock::lastPosition):
(WebKit::WebGeolocationClientMock::requestPermission):
(WebKit::WebGeolocationClientMock::cancelPermissionRequest):
* src/WebGeolocationServiceMock.cpp:
2010-12-10 John Knottenbelt <jknotten@chromium.org>
Reviewed by Steve Block.
......
......@@ -174,6 +174,7 @@
'public/WebFormControlElement.h',
'public/WebFormElement.h',
'public/WebGeolocationClient.h',
'public/WebGeolocationClientMock.h',
'public/WebGeolocationController.h',
'public/WebGeolocationError.h',
'public/WebGeolocationPermissionRequest.h',
......@@ -451,6 +452,7 @@
'src/WebFrameImpl.cpp',
'src/WebFrameImpl.h',
'src/WebGeolocationController.cpp',
'src/WebGeolocationClientMock.cpp',
'src/WebGeolocationError.cpp',
'src/WebGeolocationPermissionRequest.cpp',
'src/WebGeolocationPermissionRequestManager.cpp',
......@@ -676,7 +678,6 @@
['"ENABLE_CLIENT_BASED_GEOLOCATION=1" in feature_defines', {
'sources/': [
['exclude', 'WebGeolocationService.*$'],
['include', 'WebGeolocationServiceMock.*'],
],
}, {
'sources/': [
......@@ -866,6 +867,11 @@
},
},
}],
['"ENABLE_CLIENT_BASED_GEOLOCATION=1" in feature_defines', {
'sources/': [
['exclude', 'WebGeolocationService.*$'],
],
}]
],
},
{
......
/*
* 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.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "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 WebGeolocationClientMock_h
#define WebGeolocationClientMock_h
#include "WebCommon.h"
#include "WebGeolocationClient.h"
#include "WebPrivateOwnPtr.h"
namespace WebCore {
class GeolocationClientMock;
}
namespace WebKit {
class WebGeolocationPosition;
class WebString;
class WebGeolocationClientMock : public WebGeolocationClient {
public:
WEBKIT_API static WebGeolocationClientMock* create();
~WebGeolocationClientMock() { reset(); }
WEBKIT_API void setPosition(double latitude, double longitude, double accuracy);
WEBKIT_API void setError(int errorCode, const WebString& message);
WEBKIT_API void setPermission(bool);
WEBKIT_API void resetMock();
virtual void startUpdating();
virtual void stopUpdating();
virtual void setEnableHighAccuracy(bool);
virtual void geolocationDestroyed();
virtual void setController(WebGeolocationController*);
virtual void requestPermission(const WebGeolocationPermissionRequest&);
virtual void cancelPermissionRequest(const WebGeolocationPermissionRequest&);
virtual bool lastPosition(WebGeolocationPosition& webPosition);
private:
WebGeolocationClientMock();
WEBKIT_API void reset();
WebPrivateOwnPtr<WebCore::GeolocationClientMock> m_clientMock;
};
}
#endif // WebGeolocationClientMock_h
/*
* 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.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "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 "WebGeolocationClientMock.h"
#include "CurrentTime.h"
#include "Geolocation.h"
#include "GeolocationClientMock.h"
#include "GeolocationError.h"
#include "GeolocationPosition.h"
#include "PositionError.h"
#include "WebGeolocationController.h"
#include "WebGeolocationError.h"
#include "WebGeolocationPermissionRequest.h"
#include "WebGeolocationPosition.h"
using namespace WebCore;
namespace WebKit {
WebGeolocationClientMock* WebGeolocationClientMock::create()
{
return new WebGeolocationClientMock();
}
void WebGeolocationClientMock::setPosition(double latitude, double longitude, double accuracy)
{
WebGeolocationPosition webPosition(currentTime(), latitude, longitude, accuracy,
false, 0, false, 0, false, 0, false, 0);
m_clientMock->setPosition(webPosition);
}
void WebGeolocationClientMock::setError(int errorCode, const WebString& message)
{
WebGeolocationError::Error code;
switch (errorCode) {
case PositionError::PERMISSION_DENIED:
code = WebGeolocationError::ErrorPermissionDenied;
break;
case PositionError::POSITION_UNAVAILABLE:
code = WebGeolocationError::ErrorPositionUnavailable;
break;
default:
ASSERT_NOT_REACHED();
return;
}
WebGeolocationError webError(code, message);
m_clientMock->setError(webError);
}
void WebGeolocationClientMock::setPermission(bool allowed)
{
m_clientMock->setPermission(allowed);
}
void WebGeolocationClientMock::resetMock()
{
m_clientMock->reset();
}
void WebGeolocationClientMock::startUpdating()
{
m_clientMock->startUpdating();
}
void WebGeolocationClientMock::stopUpdating()
{
m_clientMock->stopUpdating();
}
void WebGeolocationClientMock::setEnableHighAccuracy(bool accuracy)
{
m_clientMock->setEnableHighAccuracy(accuracy);
}
void WebGeolocationClientMock::geolocationDestroyed()
{
m_clientMock->geolocationDestroyed();
}
void WebGeolocationClientMock::setController(WebGeolocationController* controller)
{
m_clientMock->setController(controller->controller());
delete controller;
}
void WebGeolocationClientMock::requestPermission(const WebGeolocationPermissionRequest& request)
{
m_clientMock->requestPermission(request.geolocation());
}
void WebGeolocationClientMock::cancelPermissionRequest(const WebGeolocationPermissionRequest& request)
{
m_clientMock->cancelPermissionRequest(request.geolocation());
}
bool WebGeolocationClientMock::lastPosition(WebGeolocationPosition& webPosition)
{
RefPtr<GeolocationPosition> position = m_clientMock->lastPosition();
if (!position)
return false;
webPosition = position.release();
return true;
}
WebGeolocationClientMock::WebGeolocationClientMock()
{
m_clientMock.reset(new GeolocationClientMock());
}
void WebGeolocationClientMock::reset()
{
m_clientMock.reset(0);
}
} // WebKit
......@@ -41,39 +41,6 @@
#include <wtf/Vector.h>
#if ENABLE(GEOLOCATION)
#if ENABLE(CLIENT_BASED_GEOLOCATION)
// FIXME: Implement mock bindings for client-based geolocation. Ultimately
// move to another class and remove WebGeolocationService*.
namespace WebKit {
class WebGeolocationServiceMockClientBasedImpl : public WebGeolocationServiceMock {
};
WebGeolocationServiceMock* WebGeolocationServiceMock::createWebGeolocationServiceMock()
{
return new WebGeolocationServiceMockClientBasedImpl;
}
void WebGeolocationServiceMock::setMockGeolocationPermission(bool allowed)
{
// FIXME: Implement mock binding
}
void WebGeolocationServiceMock::setMockGeolocationPosition(double latitude, double longitude, double accuracy)
{
// FIXME: Implement mock binding
}
void WebGeolocationServiceMock::setMockGeolocationError(int errorCode, const WebString& message)
{
// FIXME: Implement mock binding
}
} // namespace WebKit
#else
using WebCore::Coordinates;
using WebCore::Frame;
using WebCore::Geolocation;
......@@ -272,6 +239,4 @@ void WebGeolocationServiceMockImpl::notifyPendingPermissions()
}
} // namespace WebKit
#endif // ENABLE(CLIENT_BASED_GEOLOCATION)
#endif // ENABLE(GEOLOCATION)
2010-12-10 John Knottenbelt <jknotten@chromium.org>
Reviewed by Steve Block.
[Chromium] Implement mocks for client-based geolocation
https://bugs.webkit.org/show_bug.cgi?id=46895
* DumpRenderTree/chromium/LayoutTestController.cpp:
(LayoutTestController::setGeolocationPermission):
(LayoutTestController::setMockGeolocationPosition):
(LayoutTestController::setMockGeolocationError):
* DumpRenderTree/chromium/LayoutTestController.h:
* DumpRenderTree/chromium/WebViewHost.cpp:
(WebViewHost::geolocationClient):
(WebViewHost::geolocationClientMock):
(WebViewHost::reset):
* DumpRenderTree/chromium/WebViewHost.h:
2010-12-10 Alejandro G. Castro <alex@igalia.com>
Reviewed by Martin Robinson.
......
......@@ -43,7 +43,11 @@
#include "WebDocument.h"
#include "WebElement.h"
#include "WebFrame.h"
#if ENABLE(CLIENT_BASED_GEOLOCATION)
#include "WebGeolocationClientMock.h"
#else
#include "WebGeolocationServiceMock.h"
#endif
#include "WebInputElement.h"
#include "WebKit.h"
#include "WebNotificationPresenter.h"
......@@ -1513,7 +1517,11 @@ void LayoutTestController::setGeolocationPermission(const CppArgumentList& argum
result->setNull();
if (arguments.size() < 1 || !arguments[0].isBool())
return;
#if ENABLE(CLIENT_BASED_GEOLOCATION)
m_shell->webViewHost()->geolocationClientMock()->setPermission(arguments[0].toBoolean());
#else
WebGeolocationServiceMock::setMockGeolocationPermission(arguments[0].toBoolean());
#endif
}
void LayoutTestController::setMockGeolocationPosition(const CppArgumentList& arguments, CppVariant* result)
......@@ -1521,7 +1529,11 @@ void LayoutTestController::setMockGeolocationPosition(const CppArgumentList& arg
result->setNull();
if (arguments.size() < 3 || !arguments[0].isNumber() || !arguments[1].isNumber() || !arguments[2].isNumber())
return;
#if ENABLE(CLIENT_BASED_GEOLOCATION)
m_shell->webViewHost()->geolocationClientMock()->setPosition(arguments[0].toDouble(), arguments[1].toDouble(), arguments[2].toDouble());
#else
WebGeolocationServiceMock::setMockGeolocationPosition(arguments[0].toDouble(), arguments[1].toDouble(), arguments[2].toDouble());
#endif
}
void LayoutTestController::setMockGeolocationError(const CppArgumentList& arguments, CppVariant* result)
......@@ -1529,7 +1541,11 @@ void LayoutTestController::setMockGeolocationError(const CppArgumentList& argume
result->setNull();
if (arguments.size() < 2 || !arguments[0].isNumber() || !arguments[1].isString())
return;
#if ENABLE(CLIENT_BASED_GEOLOCATION)
m_shell->webViewHost()->geolocationClientMock()->setError(arguments[0].toInt32(), cppVariantToWebString(arguments[1]));
#else
WebGeolocationServiceMock::setMockGeolocationError(arguments[0].toInt32(), cppVariantToWebString(arguments[1]));
#endif
}
void LayoutTestController::abortModal(const CppArgumentList& arguments, CppVariant* result)
......
......@@ -49,6 +49,7 @@
#include <wtf/OwnPtr.h>
namespace WebKit {
class WebGeolocationClientMock;
class WebSpeechInputController;
class WebSpeechInputControllerMock;
class WebSpeechInputListener;
......
......@@ -43,7 +43,11 @@
#include "WebDragData.h"
#include "WebElement.h"
#include "WebFrame.h"
#if ENABLE(CLIENT_BASED_GEOLOCATION)
#include "WebGeolocationClientMock.h"
#else
#include "WebGeolocationServiceMock.h"
#endif
#include "WebHistoryItem.h"
#include "WebNode.h"
#include "WebRange.h"
......@@ -571,10 +575,22 @@ WebNotificationPresenter* WebViewHost::notificationPresenter()
return m_shell->notificationPresenter();
}
#if !ENABLE(CLIENT_BASED_GEOLOCATION)
#if ENABLE(CLIENT_BASED_GEOLOCATION)
WebKit::WebGeolocationClient* WebViewHost::geolocationClient()
{
return geolocationClientMock();
}
WebKit::WebGeolocationClientMock* WebViewHost::geolocationClientMock()
{
if (!m_geolocationClientMock)
m_geolocationClientMock.set(WebGeolocationClientMock::create());
return m_geolocationClientMock.get();
}
#else
WebKit::WebGeolocationService* WebViewHost::geolocationService()
{
if (!m_geolocationServiceMock.get())
if (!m_geolocationServiceMock)
m_geolocationServiceMock.set(WebGeolocationServiceMock::createWebGeolocationServiceMock());
return m_geolocationServiceMock.get();
}
......@@ -1171,7 +1187,10 @@ void WebViewHost::reset()
m_editCommandName.clear();
m_editCommandValue.clear();
#if !ENABLE(CLIENT_BASED_GEOLOCATION)
#if ENABLE(CLIENT_BASED_GEOLOCATION)
if (m_geolocationClientMock.get())
m_geolocationClientMock->resetMock();
#else
m_geolocationServiceMock.clear();
#endif
......
......@@ -48,6 +48,8 @@ namespace WebKit {
class WebFrame;
class WebDeviceOrientationClient;
class WebDeviceOrientationClientMock;
class WebGeolocationClient;
class WebGeolocationClientMock;
class WebGeolocationServiceMock;
class WebSpeechInputController;
class WebSpeechInputControllerMock;
......@@ -137,7 +139,9 @@ class WebViewHost : public WebKit::WebViewClient, public WebKit::WebFrameClient,
virtual int historyForwardListCount();
virtual void postAccessibilityNotification(const WebKit::WebAccessibilityObject&, WebKit::WebAccessibilityNotification);
virtual WebKit::WebNotificationPresenter* notificationPresenter();
#if !ENABLE(CLIENT_BASED_GEOLOCATION)
#if ENABLE(CLIENT_BASED_GEOLOCATION)
virtual WebKit::WebGeolocationClient* geolocationClient();
#else
virtual WebKit::WebGeolocationService* geolocationService();
#endif
virtual WebKit::WebSpeechInputController* speechInputController(WebKit::WebSpeechInputListener*);
......@@ -206,6 +210,11 @@ class WebViewHost : public WebKit::WebViewClient, public WebKit::WebFrameClient,
WebKit::WebDeviceOrientationClientMock* deviceOrientationClientMock();
MockSpellCheck* mockSpellCheck();
#if ENABLE(CLIENT_BASED_GEOLOCATION)
// Geolocation client mocks for LayoutTestController
WebKit::WebGeolocationClientMock* geolocationClientMock();
#endif
private:
LayoutTestController* layoutTestController() const;
......@@ -307,8 +316,10 @@ private:
OwnPtr<WebKit::WebContextMenuData> m_lastContextMenuData;
#if !ENABLE(CLIENT_BASED_GEOLOCATION)
// Geolocation
#if ENABLE(CLIENT_BASED_GEOLOCATION)
OwnPtr<WebKit::WebGeolocationClientMock> m_geolocationClientMock;
#else
OwnPtr<WebKit::WebGeolocationServiceMock> m_geolocationServiceMock;
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment