summaryrefslogtreecommitdiff
path: root/Tools/TestWebKitAPI/Tests/WebKit2/Geolocation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/TestWebKitAPI/Tests/WebKit2/Geolocation.cpp')
-rw-r--r--Tools/TestWebKitAPI/Tests/WebKit2/Geolocation.cpp55
1 files changed, 37 insertions, 18 deletions
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/Geolocation.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/Geolocation.cpp
index bf7a93726..90fd37937 100644
--- a/Tools/TestWebKitAPI/Tests/WebKit2/Geolocation.cpp
+++ b/Tools/TestWebKitAPI/Tests/WebKit2/Geolocation.cpp
@@ -24,10 +24,14 @@
*/
#include "config.h"
+
+#if WK_HAVE_C_SPI
+
#include "PlatformUtilities.h"
#include "PlatformWebView.h"
#include "Test.h"
-#include <WebKit2/WKRetainPtr.h>
+#include <WebKit/WKContextPrivate.h>
+#include <WebKit/WKRetainPtr.h>
#include <string.h>
#include <vector>
@@ -103,7 +107,7 @@ void decidePolicyForGeolocationPermissionRequestCallBack(WKPageRef page, WKFrame
void setupGeolocationProvider(WKContextRef context, void *clientInfo)
{
WKGeolocationProviderV1 providerCallback;
- memset(&providerCallback, 0, sizeof(WKGeolocationProvider));
+ memset(&providerCallback, 0, sizeof(WKGeolocationProviderV1));
providerCallback.base.version = 1;
providerCallback.base.clientInfo = clientInfo;
@@ -209,14 +213,9 @@ TEST(WebKit2, GeolocationBasicWithHighAccuracy)
// Geolocation start without High Accuracy, then requires High Accuracy.
struct GeolocationTransitionToHighAccuracyStateTracker : GeolocationStateTracker {
- bool finishedFirstStep;
- bool finished;
-
- GeolocationTransitionToHighAccuracyStateTracker()
- : finishedFirstStep(false)
- , finished(false)
- {
- }
+ bool finishedFirstStep { false };
+ bool enabledHighAccuracy { false };
+ bool finished { false };
virtual void eventsChanged()
{
@@ -230,11 +229,19 @@ struct GeolocationTransitionToHighAccuracyStateTracker : GeolocationStateTracker
break;
case 3:
EXPECT_EQ(GeolocationEvent::EnableHighAccuracy, events[2]);
+ enabledHighAccuracy = true;
+ break;
+ case 4:
+ EXPECT_EQ(GeolocationEvent::DisableHighAccuracy, events[3]);
+ break;
+ case 5:
+ EXPECT_EQ(GeolocationEvent::StopUpdating, events[4]);
finished = true;
break;
default:
EXPECT_TRUE(false);
finishedFirstStep = true;
+ enabledHighAccuracy = true;
finished = true;
}
}
@@ -243,6 +250,7 @@ struct GeolocationTransitionToHighAccuracyStateTracker : GeolocationStateTracker
TEST(WebKit2, GeolocationTransitionToHighAccuracy)
{
WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());
+ WKContextSetMaximumNumberOfProcesses(context.get(), 1);
GeolocationTransitionToHighAccuracyStateTracker stateTracker;
setupGeolocationProvider(context.get(), &stateTracker);
@@ -257,19 +265,20 @@ TEST(WebKit2, GeolocationTransitionToHighAccuracy)
setupView(highAccuracyWebView);
WKRetainPtr<WKURLRef> highAccuracyURL(AdoptWK, Util::createURLForResource("geolocationWatchPositionWithHighAccuracy", "html"));
WKPageLoadURL(highAccuracyWebView.page(), highAccuracyURL.get());
+ Util::run(&stateTracker.enabledHighAccuracy);
+
+ WKRetainPtr<WKURLRef> resetUrl = adoptWK(WKURLCreateWithUTF8CString("about:blank"));
+ WKPageLoadURL(highAccuracyWebView.page(), resetUrl.get());
+ Util::run(&stateTracker.enabledHighAccuracy);
+ WKPageLoadURL(lowAccuracyWebView.page(), resetUrl.get());
Util::run(&stateTracker.finished);
}
// Geolocation start with High Accuracy, then should fall back to low accuracy.
struct GeolocationTransitionToLowAccuracyStateTracker : GeolocationStateTracker {
- bool finishedFirstStep;
- bool finished;
-
- GeolocationTransitionToLowAccuracyStateTracker()
- : finishedFirstStep(false)
- , finished(false)
- {
- }
+ bool finishedFirstStep { false };
+ bool disabledHighAccuracy { false };
+ bool finished { false };
virtual void eventsChanged()
{
@@ -283,11 +292,16 @@ struct GeolocationTransitionToLowAccuracyStateTracker : GeolocationStateTracker
break;
case 3:
EXPECT_EQ(GeolocationEvent::DisableHighAccuracy, events[2]);
+ disabledHighAccuracy = true;
+ break;
+ case 4:
+ EXPECT_EQ(GeolocationEvent::StopUpdating, events[3]);
finished = true;
break;
default:
EXPECT_TRUE(false);
finishedFirstStep = true;
+ disabledHighAccuracy = true;
finished = true;
}
}
@@ -301,6 +315,7 @@ static void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef us
TEST(WebKit2, GeolocationTransitionToLowAccuracy)
{
WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());
+ WKContextSetMaximumNumberOfProcesses(context.get(), 1);
GeolocationTransitionToLowAccuracyStateTracker stateTracker;
setupGeolocationProvider(context.get(), &stateTracker);
@@ -331,7 +346,11 @@ TEST(WebKit2, GeolocationTransitionToLowAccuracy)
WKRetainPtr<WKURLRef> resetUrl = adoptWK(WKURLCreateWithUTF8CString("about:blank"));
WKPageLoadURL(highAccuracyWebView.page(), resetUrl.get());
+ Util::run(&stateTracker.disabledHighAccuracy);
+ WKPageLoadURL(lowAccuracyWebView.page(), resetUrl.get());
Util::run(&stateTracker.finished);
}
} // namespace TestWebKitAPI
+
+#endif