summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--WebCore/platform/GeolocationService.cpp9
-rw-r--r--WebCore/platform/GeolocationService.h3
-rwxr-xr-xWebCore/platform/MockGeolocationService.cpp4
-rwxr-xr-xWebCore/platform/MockGeolocationService.h6
-rwxr-xr-xWebKit/android/jni/MockGeolocation.cpp24
5 files changed, 12 insertions, 34 deletions
diff --git a/WebCore/platform/GeolocationService.cpp b/WebCore/platform/GeolocationService.cpp
index 454538e..4fd678b 100644
--- a/WebCore/platform/GeolocationService.cpp
+++ b/WebCore/platform/GeolocationService.cpp
@@ -48,16 +48,9 @@ GeolocationService* GeolocationService::create(GeolocationServiceClient* client)
return (*s_factoryFunction)(client);
}
-void GeolocationService::setMockPosition(PassRefPtr<Geoposition> position)
+void GeolocationService::useMock()
{
s_factoryFunction = &MockGeolocationService::create;
- MockGeolocationService::setPosition(position);
-}
-
-void GeolocationService::setMockError(PassRefPtr<PositionError> error)
-{
- s_factoryFunction = &MockGeolocationService::create;
- MockGeolocationService::setError(error);
}
GeolocationService::GeolocationService(GeolocationServiceClient* client)
diff --git a/WebCore/platform/GeolocationService.h b/WebCore/platform/GeolocationService.h
index 3084aad..a99523f 100644
--- a/WebCore/platform/GeolocationService.h
+++ b/WebCore/platform/GeolocationService.h
@@ -60,8 +60,7 @@ public:
void positionChanged();
void errorOccurred();
- static void setMockPosition(PassRefPtr<Geoposition>);
- static void setMockError(PassRefPtr<PositionError>);
+ static void useMock();
protected:
GeolocationService(GeolocationServiceClient*);
diff --git a/WebCore/platform/MockGeolocationService.cpp b/WebCore/platform/MockGeolocationService.cpp
index 515bd97..72d85ef 100755
--- a/WebCore/platform/MockGeolocationService.cpp
+++ b/WebCore/platform/MockGeolocationService.cpp
@@ -60,6 +60,7 @@ MockGeolocationService::~MockGeolocationService()
void MockGeolocationService::setPosition(PassRefPtr<Geoposition> position)
{
initStatics();
+ GeolocationService::useMock();
*s_lastPosition = position;
*s_lastError = 0;
makeGeolocationCallbackFromAllInstances();
@@ -68,6 +69,7 @@ void MockGeolocationService::setPosition(PassRefPtr<Geoposition> position)
void MockGeolocationService::setError(PassRefPtr<PositionError> error)
{
initStatics();
+ GeolocationService::useMock();
*s_lastError = error;
*s_lastPosition = 0;
makeGeolocationCallbackFromAllInstances();
@@ -81,7 +83,7 @@ bool MockGeolocationService::startUpdating(PositionOptions*)
void MockGeolocationService::timerFired(Timer<MockGeolocationService>* timer)
{
- if (timer != &m_timer) ASSERT(0);
+ ASSERT_UNUSED(timer, timer == &m_timer);
makeGeolocationCallback();
}
diff --git a/WebCore/platform/MockGeolocationService.h b/WebCore/platform/MockGeolocationService.h
index eb92cbc..2f190e6 100755
--- a/WebCore/platform/MockGeolocationService.h
+++ b/WebCore/platform/MockGeolocationService.h
@@ -63,12 +63,12 @@ class MockGeolocationService : public GeolocationService {
static void initStatics();
static void cleanUpStatics();
- static RefPtr<Geoposition>* s_lastPosition;
- static RefPtr<PositionError>* s_lastError;
-
typedef HashSet<MockGeolocationService*> MockGeolocationServiceSet;
static MockGeolocationServiceSet* s_instances;
+ static RefPtr<Geoposition>* s_lastPosition;
+ static RefPtr<PositionError>* s_lastError;
+
Timer<MockGeolocationService> m_timer;
};
diff --git a/WebKit/android/jni/MockGeolocation.cpp b/WebKit/android/jni/MockGeolocation.cpp
index 2f6ca60..8c5f966 100755
--- a/WebKit/android/jni/MockGeolocation.cpp
+++ b/WebKit/android/jni/MockGeolocation.cpp
@@ -30,10 +30,10 @@
#include <JNIHelp.h>
#include "Coordinates.h"
-#include "GeolocationService.h"
#include "Geoposition.h"
#include "JavaSharedClient.h"
#include "jni_utility.h"
+#include "MockGeolocationService.h"
#include "PositionError.h"
#include "WebCoreJni.h"
#include <wtf/CurrentTime.h>
@@ -54,31 +54,15 @@ static void setPosition(JNIEnv* env, jobject, double latitude, double longitude,
false, 0.0, // heading
false, 0.0); // speed
RefPtr<Geoposition> position = Geoposition::create(coordinates.release(), WTF::currentTime());
- GeolocationService::setMockPosition(position.release());
+ MockGeolocationService::setPosition(position.release());
}
static void setError(JNIEnv* env, jobject, int code, jstring message)
{
- PositionError::ErrorCode codeEnum;
- switch (code) {
- case PositionError::UNKNOWN_ERROR:
- codeEnum = PositionError::UNKNOWN_ERROR;
- break;
- case PositionError::PERMISSION_DENIED:
- codeEnum = PositionError::PERMISSION_DENIED;
- break;
- case PositionError::POSITION_UNAVAILABLE:
- codeEnum = PositionError::POSITION_UNAVAILABLE;
- break;
- case PositionError::TIMEOUT:
- codeEnum = PositionError::TIMEOUT;
- break;
- default:
- ASSERT(false);
- }
+ PositionError::ErrorCode codeEnum = static_cast<PositionError::ErrorCode>(code);
String messageString = to_string(env, message);
RefPtr<PositionError> error = PositionError::create(codeEnum, messageString);
- GeolocationService::setMockError(error.release());
+ MockGeolocationService::setError(error.release());
}
static JNINativeMethod gMockGeolocationMethods[] = {