diff options
-rw-r--r-- | WebCore/platform/GeolocationService.cpp | 9 | ||||
-rw-r--r-- | WebCore/platform/GeolocationService.h | 3 | ||||
-rwxr-xr-x | WebCore/platform/MockGeolocationService.cpp | 4 | ||||
-rwxr-xr-x | WebCore/platform/MockGeolocationService.h | 6 | ||||
-rwxr-xr-x | WebKit/android/jni/MockGeolocation.cpp | 24 |
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[] = { |