2 * Copyright (c) 2010, Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #include "WebGeolocationClientMock.h"
34 #include "CurrentTime.h"
35 #include "Geolocation.h"
36 #include "GeolocationClientMock.h"
37 #include "GeolocationError.h"
38 #include "GeolocationPosition.h"
39 #include "PositionError.h"
40 #include "WebGeolocationController.h"
41 #include "WebGeolocationError.h"
42 #include "WebGeolocationPermissionRequest.h"
43 #include "WebGeolocationPosition.h"
45 using namespace WebCore;
49 WebGeolocationClientMock* WebGeolocationClientMock::create()
51 return new WebGeolocationClientMock();
54 void WebGeolocationClientMock::setPosition(double latitude, double longitude, double accuracy)
56 WebGeolocationPosition webPosition(currentTime(), latitude, longitude, accuracy,
57 false, 0, false, 0, false, 0, false, 0);
58 m_clientMock->setPosition(webPosition);
61 void WebGeolocationClientMock::setError(int errorCode, const WebString& message)
63 WebGeolocationError::Error code;
65 case PositionError::PERMISSION_DENIED:
66 code = WebGeolocationError::ErrorPermissionDenied;
68 case PositionError::POSITION_UNAVAILABLE:
69 code = WebGeolocationError::ErrorPositionUnavailable;
76 WebGeolocationError webError(code, message);
77 m_clientMock->setError(webError);
80 void WebGeolocationClientMock::setPermission(bool allowed)
82 m_clientMock->setPermission(allowed);
85 int WebGeolocationClientMock::numberOfPendingPermissionRequests() const
87 return m_clientMock->numberOfPendingPermissionRequests();
90 void WebGeolocationClientMock::resetMock()
92 m_clientMock->reset();
95 void WebGeolocationClientMock::startUpdating()
97 m_clientMock->startUpdating();
100 void WebGeolocationClientMock::stopUpdating()
102 m_clientMock->stopUpdating();
105 void WebGeolocationClientMock::setEnableHighAccuracy(bool accuracy)
107 m_clientMock->setEnableHighAccuracy(accuracy);
110 void WebGeolocationClientMock::geolocationDestroyed()
112 m_clientMock->geolocationDestroyed();
115 void WebGeolocationClientMock::setController(WebGeolocationController* controller)
117 m_clientMock->setController(controller->controller());
121 void WebGeolocationClientMock::requestPermission(const WebGeolocationPermissionRequest& request)
123 m_clientMock->requestPermission(request.geolocation());
126 void WebGeolocationClientMock::cancelPermissionRequest(const WebGeolocationPermissionRequest& request)
128 m_clientMock->cancelPermissionRequest(request.geolocation());
131 bool WebGeolocationClientMock::lastPosition(WebGeolocationPosition& webPosition)
133 RefPtr<GeolocationPosition> position = m_clientMock->lastPosition();
137 webPosition = position.release();
141 WebGeolocationClientMock::WebGeolocationClientMock()
143 m_clientMock.reset(new GeolocationClientMock());
146 void WebGeolocationClientMock::reset()
148 m_clientMock.reset(0);