WebGeolocationClientMock.cpp [plain text]
#include "config.h"
#include "WebGeolocationClientMock.h"
#include <wtf/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);
}
int WebGeolocationClientMock::numberOfPendingPermissionRequests() const
{
return m_clientMock->numberOfPendingPermissionRequests();
}
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);
}
}