[WK2] Support all attributes of GeolocationPosition
authorbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Oct 2012 19:10:18 +0000 (19:10 +0000)
committerbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Oct 2012 19:10:18 +0000 (19:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=98212

Patch by Benjamin Poulain <bpoulain@apple.com> on 2012-10-03
Reviewed by Sam Weinig.

Source/WebKit/mac:

Add an internal constructor for the sake of testing.
A similar API is used on iOS.

* WebView/WebGeolocationPosition.mm:
(-[WebGeolocationPosition initWithGeolocationPosition:]):

Source/WebKit2:

Add complete support for GeolocationPosition.

* Shared/WebGeolocationPosition.cpp:
(WebKit::WebGeolocationPosition::WebGeolocationPosition):
(WebKit::WebGeolocationPosition::Data::encode):
(WebKit::WebGeolocationPosition::Data::decode):
* Shared/WebGeolocationPosition.h:
(Data):
(WebKit::WebGeolocationPosition::create):
(WebKit::WebGeolocationPosition::canProvideAltitude):
(WebKit::WebGeolocationPosition::altitude):
(WebGeolocationPosition):
(WebKit::WebGeolocationPosition::canProvideAltitudeAccuracy):
(WebKit::WebGeolocationPosition::altitudeAccuracy):
(WebKit::WebGeolocationPosition::canProvideHeading):
(WebKit::WebGeolocationPosition::heading):
(WebKit::WebGeolocationPosition::canProvideSpeed):
(WebKit::WebGeolocationPosition::speed):
WebGeolocationPosition mirror the attributes of WebCore::GeolocationPosition.

* UIProcess/API/C/WKGeolocationPosition.cpp:
(WKGeolocationPositionCreate):
(WKGeolocationPositionCreate_b):
Add a new API exposing all the arguments.

* UIProcess/API/C/WKGeolocationPosition.h:
* WebProcess/Geolocation/WebGeolocationManager.cpp:
(WebKit::WebGeolocationManager::didChangePosition):

Tools:

Expand WebKitTestRunner and DumpRenderTree to test all the attributes
of GeolocationPosition.

* DumpRenderTree/TestRunner.cpp:
(setMockGeolocationPositionCallback):
* DumpRenderTree/TestRunner.h:
(TestRunner):
* DumpRenderTree/efl/TestRunnerEfl.cpp:
(TestRunner::setMockGeolocationPosition):
* DumpRenderTree/gtk/TestRunnerGtk.cpp:
(TestRunner::setMockGeolocationPosition):
* DumpRenderTree/mac/TestRunnerMac.mm:
(TestRunner::setMockGeolocationPosition):
* DumpRenderTree/win/TestRunnerWin.cpp:
(TestRunner::setMockGeolocationPosition):
* DumpRenderTree/wx/TestRunnerWx.cpp:
(TestRunner::setMockGeolocationPosition):
* WebKitTestRunner/GeolocationProviderMock.cpp:
(WTR::GeolocationProviderMock::setPosition):
* WebKitTestRunner/GeolocationProviderMock.h:
(GeolocationProviderMock):
* WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm:
(_platformTypeVariableDeclaration):
Use a proper constructor for the JSValueRef, it is an opaque type, we are not supposed
to build the pointer outself.
This is necessary to support optional JSValueRef properly.

* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::setMockGeolocationPosition):
* WebKitTestRunner/InjectedBundle/InjectedBundle.h:
(InjectedBundle):
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setMockGeolocationPosition):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
(TestRunner):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::setMockGeolocationPosition):
* WebKitTestRunner/TestController.h:
(TestController):
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveMessageFromInjectedBundle):

LayoutTests:

Add a new test for the exposed attributes. It is disabled everywhere else than
Mac because of the missing DRT features.

* fast/dom/Geolocation/coordinates-interface-attributes-expected.txt: Added.
* fast/dom/Geolocation/coordinates-interface-attributes.html: Added.
* platform/chromium/TestExpectations:
* platform/gtk/TestExpectations:
* platform/qt/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@130416 268f45cc-cd09-0410-ab3c-d52691b4dbfc

33 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/Geolocation/coordinates-interface-attributes-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/Geolocation/coordinates-interface-attributes.html [new file with mode: 0644]
LayoutTests/platform/chromium/TestExpectations
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/qt/TestExpectations
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebGeolocationPosition.mm
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebGeolocationPosition.cpp
Source/WebKit2/Shared/WebGeolocationPosition.h
Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.cpp
Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.h
Source/WebKit2/WebProcess/Geolocation/WebGeolocationManager.cpp
Tools/ChangeLog
Tools/DumpRenderTree/TestRunner.cpp
Tools/DumpRenderTree/TestRunner.h
Tools/DumpRenderTree/efl/TestRunnerEfl.cpp
Tools/DumpRenderTree/gtk/TestRunnerGtk.cpp
Tools/DumpRenderTree/mac/TestRunnerMac.mm
Tools/DumpRenderTree/win/TestRunnerWin.cpp
Tools/DumpRenderTree/wx/TestRunnerWx.cpp
Tools/WebKitTestRunner/GeolocationProviderMock.cpp
Tools/WebKitTestRunner/GeolocationProviderMock.h
Tools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm
Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestController.h
Tools/WebKitTestRunner/TestInvocation.cpp

index 5090d25..ce065a2 100644 (file)
@@ -1,3 +1,19 @@
+2012-10-03  Benjamin Poulain  <bpoulain@apple.com>
+
+        [WK2] Support all attributes of GeolocationPosition
+        https://bugs.webkit.org/show_bug.cgi?id=98212
+
+        Reviewed by Sam Weinig.
+
+        Add a new test for the exposed attributes. It is disabled everywhere else than
+        Mac because of the missing DRT features.
+
+        * fast/dom/Geolocation/coordinates-interface-attributes-expected.txt: Added.
+        * fast/dom/Geolocation/coordinates-interface-attributes.html: Added.
+        * platform/chromium/TestExpectations:
+        * platform/gtk/TestExpectations:
+        * platform/qt/TestExpectations:
+
 2012-10-04  Alpha Lam  <hclam@chromium.org>
 
         [skia] Drawing a subrect of bitmap image is misaligned
diff --git a/LayoutTests/fast/dom/Geolocation/coordinates-interface-attributes-expected.txt b/LayoutTests/fast/dom/Geolocation/coordinates-interface-attributes-expected.txt
new file mode 100644 (file)
index 0000000..d00c13f
--- /dev/null
@@ -0,0 +1,49 @@
+Test the attribute handling of the Coordinates interface
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS globalCoordinates.latitude is testSet[currentTestIndex][1][0]
+PASS globalCoordinates.longitude is testSet[currentTestIndex][1][1]
+PASS globalCoordinates.accuracy is testSet[currentTestIndex][1][2]
+PASS globalCoordinates.altitude is testSet[currentTestIndex][1][3]
+PASS globalCoordinates.altitudeAccuracy is testSet[currentTestIndex][1][4]
+PASS globalCoordinates.heading is testSet[currentTestIndex][1][5]
+PASS globalCoordinates.speed is testSet[currentTestIndex][1][6]
+
+PASS globalCoordinates.latitude is testSet[currentTestIndex][1][0]
+PASS globalCoordinates.longitude is testSet[currentTestIndex][1][1]
+PASS globalCoordinates.accuracy is testSet[currentTestIndex][1][2]
+PASS globalCoordinates.altitude is testSet[currentTestIndex][1][3]
+PASS globalCoordinates.altitudeAccuracy is testSet[currentTestIndex][1][4]
+PASS globalCoordinates.heading is testSet[currentTestIndex][1][5]
+PASS globalCoordinates.speed is testSet[currentTestIndex][1][6]
+
+PASS globalCoordinates.latitude is testSet[currentTestIndex][1][0]
+PASS globalCoordinates.longitude is testSet[currentTestIndex][1][1]
+PASS globalCoordinates.accuracy is testSet[currentTestIndex][1][2]
+PASS globalCoordinates.altitude is testSet[currentTestIndex][1][3]
+PASS globalCoordinates.altitudeAccuracy is testSet[currentTestIndex][1][4]
+PASS globalCoordinates.heading is testSet[currentTestIndex][1][5]
+PASS globalCoordinates.speed is testSet[currentTestIndex][1][6]
+
+PASS globalCoordinates.latitude is testSet[currentTestIndex][1][0]
+PASS globalCoordinates.longitude is testSet[currentTestIndex][1][1]
+PASS globalCoordinates.accuracy is testSet[currentTestIndex][1][2]
+PASS globalCoordinates.altitude is testSet[currentTestIndex][1][3]
+PASS globalCoordinates.altitudeAccuracy is testSet[currentTestIndex][1][4]
+PASS globalCoordinates.heading is testSet[currentTestIndex][1][5]
+PASS globalCoordinates.speed is testSet[currentTestIndex][1][6]
+
+PASS globalCoordinates.latitude is testSet[currentTestIndex][1][0]
+PASS globalCoordinates.longitude is testSet[currentTestIndex][1][1]
+PASS globalCoordinates.accuracy is testSet[currentTestIndex][1][2]
+PASS globalCoordinates.altitude is testSet[currentTestIndex][1][3]
+PASS globalCoordinates.altitudeAccuracy is testSet[currentTestIndex][1][4]
+PASS globalCoordinates.heading is testSet[currentTestIndex][1][5]
+PASS globalCoordinates.speed is testSet[currentTestIndex][1][6]
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/Geolocation/coordinates-interface-attributes.html b/LayoutTests/fast/dom/Geolocation/coordinates-interface-attributes.html
new file mode 100644 (file)
index 0000000..ff40113
--- /dev/null
@@ -0,0 +1,67 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+description("Test the attribute handling of the Coordinates interface");
+window.jsTestIsAsync = true;
+
+// Format: [Input], [Expected]
+// Input: latitude, longitude, accuracy, providesAltitude, altitude, providesAltitudeAccuracy, altitudeAccuracy, providesHeading, heading, providesSpeed, speed.
+// Expected: latitude, longitude, accuracy, altitude, altitudeAccuracy, heading, speed.
+var testSet = [
+    [[1, 2, 3], [1, 2, 3, null, null, null, null]],
+    [[2, 3, 4, undefined, undefined, undefined, 5], [2, 3, 4, null, null, null, 5]],
+    [[3, 4, 5, undefined, 6, undefined, 7], [3, 4, 5, null, 6, null, 7]],
+    [[4, 5, 6, undefined, 7, 8, 9], [4, 5, 6, null, 7, 8, 9]],
+    [[5, 6, 7, 8, 9, 10, 11], [5, 6, 7, 8, 9, 10, 11]],
+];
+
+var currentTestIndex = -1;
+var globalCoordinates = null;
+
+function runNextTest()
+{
+    ++currentTestIndex;
+    testRunner.setMockGeolocationPosition.apply(testRunner, testSet[currentTestIndex][0]);
+}
+
+function verifyResults()
+{
+    shouldBe('globalCoordinates.latitude', 'testSet[currentTestIndex][1][0]');
+    shouldBe('globalCoordinates.longitude', 'testSet[currentTestIndex][1][1]');
+    shouldBe('globalCoordinates.accuracy', 'testSet[currentTestIndex][1][2]');
+    shouldBe('globalCoordinates.altitude', 'testSet[currentTestIndex][1][3]');
+    shouldBe('globalCoordinates.altitudeAccuracy', 'testSet[currentTestIndex][1][4]');
+    shouldBe('globalCoordinates.heading', 'testSet[currentTestIndex][1][5]');
+    shouldBe('globalCoordinates.speed', 'testSet[currentTestIndex][1][6]');
+    debug('');
+}
+
+if (window.testRunner) {
+    testRunner.setGeolocationPermission(true);
+} else
+    debug('This test can not be without TestRunner.');
+
+var watchId = navigator.geolocation.watchPosition(function(position) {
+    globalCoordinates = position.coords;
+    verifyResults();
+
+    if (currentTestIndex + 1 === testSet.length) {
+        finishJSTest();
+        return;
+    }
+    runNextTest();
+}, function(e) {
+    debug("Error!: the error callback was called.");
+    finishJSTest();
+});
+
+runNextTest();
+
+</script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
index cb0c317..290a990 100644 (file)
@@ -188,6 +188,9 @@ webkit.org/b/88172 http/tests/media/video-buffered.html
 webkit.org/b/92942 fast/dom/Proximity
 webkit.org/b/92942 fast/events/constructors/device-proximity-event-constructor.html
 
+# Missing support in DRT for Geolocation's Coordinate attributes.
+webkit.org/b/98212 fast/dom/Geolocation/coordinates-interface-attributes.html [ Failure ]
+
 # -----------------------------------------------------------------
 # WONTFIX TESTS
 # -----------------------------------------------------------------
index 41e7c59..4b05c3e 100644 (file)
@@ -1367,6 +1367,9 @@ webkit.org/b/98306 css3/flexbox/flexbox-baseline.html [ Failure Missing ]
 
 webkit.org/b/49142 fast/regions/style-scoped-in-flow-override-region-styling-multiple-regions.html [ ImageOnlyFailure ]
 
+# Missing support in DRT for Geolocation's Coordinate attributes.
+fast/dom/Geolocation/coordinates-interface-attributes.html [ Failure ]
+
 #////////////////////////////////////////////////////////////////////////////////////////
 # End of Tests failing
 #////////////////////////////////////////////////////////////////////////////////////////
index a19f499..73d4aa7 100644 (file)
@@ -544,6 +544,9 @@ http/tests/security/contentSecurityPolicy/1.1
 fast/dom/Proximity
 fast/events/constructors/device-proximity-event-constructor.html
 
+# Missing support in DRT for Geolocation's Coordinate attributes.
+fast/dom/Geolocation/coordinates-interface-attributes.html
+
 # =========================================================================== #
 #       Drag and Drop Support in DRT.                                         #
 # =========================================================================== #
index 76d80a0..b92035c 100644 (file)
@@ -1,3 +1,16 @@
+2012-10-03  Benjamin Poulain  <bpoulain@apple.com>
+
+        [WK2] Support all attributes of GeolocationPosition
+        https://bugs.webkit.org/show_bug.cgi?id=98212
+
+        Reviewed by Sam Weinig.
+
+        Add an internal constructor for the sake of testing.
+        A similar API is used on iOS.
+
+        * WebView/WebGeolocationPosition.mm:
+        (-[WebGeolocationPosition initWithGeolocationPosition:]):
+
 2012-10-04  Simon Fraser  <simon.fraser@apple.com>
 
         Standardize on "flush" terminology for compositing layer flushing/syncing
index 6467caa..7725062 100644 (file)
@@ -71,6 +71,15 @@ GeolocationPosition* core(WebGeolocationPosition *position)
     return self;
 }
 
+- (id)initWithGeolocationPosition:(PassRefPtr<GeolocationPosition>)coreGeolocationPosition
+{
+    self = [super init];
+    if (!self)
+        return nil;
+    _internal = [[WebGeolocationPositionInternal alloc] initWithCoreGeolocationPosition:coreGeolocationPosition];
+    return self;
+}
+
 - (void)dealloc
 {
     [_internal release];
index f5785b9..d169953 100644 (file)
@@ -1,3 +1,39 @@
+2012-10-03  Benjamin Poulain  <bpoulain@apple.com>
+
+        [WK2] Support all attributes of GeolocationPosition
+        https://bugs.webkit.org/show_bug.cgi?id=98212
+
+        Reviewed by Sam Weinig.
+
+        Add complete support for GeolocationPosition.
+
+        * Shared/WebGeolocationPosition.cpp:
+        (WebKit::WebGeolocationPosition::WebGeolocationPosition):
+        (WebKit::WebGeolocationPosition::Data::encode):
+        (WebKit::WebGeolocationPosition::Data::decode):
+        * Shared/WebGeolocationPosition.h:
+        (Data):
+        (WebKit::WebGeolocationPosition::create):
+        (WebKit::WebGeolocationPosition::canProvideAltitude):
+        (WebKit::WebGeolocationPosition::altitude):
+        (WebGeolocationPosition):
+        (WebKit::WebGeolocationPosition::canProvideAltitudeAccuracy):
+        (WebKit::WebGeolocationPosition::altitudeAccuracy):
+        (WebKit::WebGeolocationPosition::canProvideHeading):
+        (WebKit::WebGeolocationPosition::heading):
+        (WebKit::WebGeolocationPosition::canProvideSpeed):
+        (WebKit::WebGeolocationPosition::speed):
+        WebGeolocationPosition mirror the attributes of WebCore::GeolocationPosition.
+
+        * UIProcess/API/C/WKGeolocationPosition.cpp:
+        (WKGeolocationPositionCreate):
+        (WKGeolocationPositionCreate_b):
+        Add a new API exposing all the arguments.
+
+        * UIProcess/API/C/WKGeolocationPosition.h:
+        * WebProcess/Geolocation/WebGeolocationManager.cpp:
+        (WebKit::WebGeolocationManager::didChangePosition):
+
 2012-10-04  Simon Fraser  <simon.fraser@apple.com>
 
         Standardize on "flush" terminology for compositing layer flushing/syncing
index 01fdfb8..c9e36fa 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 
 namespace WebKit {
 
-WebGeolocationPosition::WebGeolocationPosition(double timestamp, double latitude, double longitude, double accuracy)
+WebGeolocationPosition::WebGeolocationPosition(double timestamp, double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed)
 {
     m_data.timestamp = timestamp;
     m_data.latitude = latitude;
     m_data.longitude = longitude;
     m_data.accuracy = accuracy;
+    m_data.canProvideAltitude = providesAltitude;
+    m_data.altitude = altitude;
+    m_data.canProvideAltitudeAccuracy = providesAltitudeAccuracy;
+    m_data.altitudeAccuracy = altitudeAccuracy;
+    m_data.canProvideHeading = providesHeading;
+    m_data.heading = heading;
+    m_data.canProvideSpeed = providesSpeed;
+    m_data.speed = speed;
 }
 
 WebGeolocationPosition::~WebGeolocationPosition()
@@ -45,12 +53,15 @@ WebGeolocationPosition::~WebGeolocationPosition()
 
 void WebGeolocationPosition::Data::encode(CoreIPC::ArgumentEncoder* encoder) const
 {
-    encoder->encode(CoreIPC::In(timestamp, latitude, longitude, accuracy));
+    encoder->encode(CoreIPC::In(timestamp, latitude, longitude, accuracy, canProvideAltitude, altitude, canProvideAltitudeAccuracy, altitudeAccuracy, canProvideHeading, heading));
+    encoder->encode(CoreIPC::In(canProvideSpeed, speed));
 }
 
 bool WebGeolocationPosition::Data::decode(CoreIPC::ArgumentDecoder* decoder, Data& data)
 {
-    return decoder->decode(CoreIPC::Out(data.timestamp, data.latitude, data.longitude, data.accuracy));
+    if (!decoder->decode(CoreIPC::Out(data.timestamp, data.latitude, data.longitude, data.accuracy, data.canProvideAltitude, data.altitude, data.canProvideAltitudeAccuracy, data.altitudeAccuracy, data.canProvideHeading, data.heading)))
+        return false;
+    return decoder->decode(CoreIPC::Out(data.canProvideSpeed, data.speed));
 }
 
 } // namespace WebKit
index 6b268fb..a87bb06 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -45,11 +45,21 @@ public:
         double latitude;
         double longitude;
         double accuracy;
+
+        double altitude;
+        double altitudeAccuracy;
+        double heading;
+        double speed;
+
+        bool canProvideAltitude;
+        bool canProvideAltitudeAccuracy;
+        bool canProvideHeading;
+        bool canProvideSpeed;
     };
 
-    static PassRefPtr<WebGeolocationPosition> create(double timestamp, double latitude, double longitude, double accuracy)
+    static PassRefPtr<WebGeolocationPosition> create(double timestamp, double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed)
     {
-        return adoptRef(new WebGeolocationPosition(timestamp, latitude, longitude, accuracy));
+        return adoptRef(new WebGeolocationPosition(timestamp, latitude, longitude, accuracy, providesAltitude, altitude, providesAltitudeAccuracy, altitudeAccuracy, providesHeading, heading, providesSpeed, speed));
     }
 
     virtual ~WebGeolocationPosition();
@@ -59,10 +69,22 @@ public:
     double longitude() const { return m_data.longitude; }
     double accuracy() const { return m_data.accuracy; }
 
+    bool canProvideAltitude() const { return m_data.canProvideAltitude; }
+    double altitude() const { return m_data.altitude; }
+
+    bool canProvideAltitudeAccuracy() const { return m_data.canProvideAltitudeAccuracy; }
+    double altitudeAccuracy() const { return m_data.altitudeAccuracy; }
+
+    bool canProvideHeading() const { return m_data.canProvideHeading; }
+    double heading() const { return m_data.heading; }
+
+    bool canProvideSpeed() const { return m_data.canProvideSpeed; }
+    double speed() const { return m_data.speed; }
+
     const Data& data() const { return m_data; }
 
 private:
-    WebGeolocationPosition(double timestamp, double latitude, double longitude, double accuracy);
+    WebGeolocationPosition(double timestamp, double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed);
 
     virtual Type type() const { return APIType; }
 
index 99195c7..5d94f3e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -38,6 +38,11 @@ WKTypeID WKGeolocationPositionGetTypeID()
 
 WKGeolocationPositionRef WKGeolocationPositionCreate(double timestamp, double latitude, double longitude, double accuracy)
 {
-    RefPtr<WebGeolocationPosition> position = WebGeolocationPosition::create(timestamp, latitude, longitude, accuracy);
+    return WKGeolocationPositionCreate_b(timestamp, latitude, longitude, accuracy, false, 0., false, 0., false, 0., false, 0.);
+}
+
+WKGeolocationPositionRef WKGeolocationPositionCreate_b(double timestamp, double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed)
+{
+    RefPtr<WebGeolocationPosition> position = WebGeolocationPosition::create(timestamp, latitude, longitude, accuracy, providesAltitude, altitude, providesAltitudeAccuracy, altitudeAccuracy, providesHeading, heading, providesSpeed, speed);
     return toAPI(position.release().leakRef());
 }
index 85183fd..4727e97 100644 (file)
@@ -35,6 +35,7 @@ extern "C" {
 WK_EXPORT WKTypeID WKGeolocationPositionGetTypeID();
 
 WK_EXPORT WKGeolocationPositionRef WKGeolocationPositionCreate(double timestamp, double latitude, double longitude, double accuracy);
+WK_EXPORT WKGeolocationPositionRef WKGeolocationPositionCreate_b(double timestamp, double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed);
 
 #ifdef __cplusplus
 }
index 482f267..2aec5a7 100644 (file)
@@ -80,7 +80,7 @@ void WebGeolocationManager::unregisterWebPage(WebPage* page)
 void WebGeolocationManager::didChangePosition(const WebGeolocationPosition::Data& data)
 {
 #if ENABLE(GEOLOCATION)
-    RefPtr<GeolocationPosition> position = GeolocationPosition::create(data.timestamp, data.latitude, data.longitude, data.accuracy);
+    RefPtr<GeolocationPosition> position = GeolocationPosition::create(data.timestamp, data.latitude, data.longitude, data.accuracy, data.canProvideAltitude, data.altitude, data.canProvideAltitudeAccuracy, data.altitudeAccuracy, data.canProvideHeading, data.heading, data.canProvideSpeed, data.speed);
 
     Vector<RefPtr<WebPage> > webPageCopy;
     copyToVector(m_pageSet, webPageCopy);
index 1d0d2ea..ffb12dd 100644 (file)
@@ -1,3 +1,53 @@
+2012-10-03  Benjamin Poulain  <bpoulain@apple.com>
+
+        [WK2] Support all attributes of GeolocationPosition
+        https://bugs.webkit.org/show_bug.cgi?id=98212
+
+        Reviewed by Sam Weinig.
+
+        Expand WebKitTestRunner and DumpRenderTree to test all the attributes
+        of GeolocationPosition.
+
+        * DumpRenderTree/TestRunner.cpp:
+        (setMockGeolocationPositionCallback):
+        * DumpRenderTree/TestRunner.h:
+        (TestRunner):
+        * DumpRenderTree/efl/TestRunnerEfl.cpp:
+        (TestRunner::setMockGeolocationPosition):
+        * DumpRenderTree/gtk/TestRunnerGtk.cpp:
+        (TestRunner::setMockGeolocationPosition):
+        * DumpRenderTree/mac/TestRunnerMac.mm:
+        (TestRunner::setMockGeolocationPosition):
+        * DumpRenderTree/win/TestRunnerWin.cpp:
+        (TestRunner::setMockGeolocationPosition):
+        * DumpRenderTree/wx/TestRunnerWx.cpp:
+        (TestRunner::setMockGeolocationPosition):
+        * WebKitTestRunner/GeolocationProviderMock.cpp:
+        (WTR::GeolocationProviderMock::setPosition):
+        * WebKitTestRunner/GeolocationProviderMock.h:
+        (GeolocationProviderMock):
+        * WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm:
+        (_platformTypeVariableDeclaration):
+        Use a proper constructor for the JSValueRef, it is an opaque type, we are not supposed
+        to build the pointer outself.
+        This is necessary to support optional JSValueRef properly.
+
+        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+        (WTR::InjectedBundle::setMockGeolocationPosition):
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.h:
+        (InjectedBundle):
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::setMockGeolocationPosition):
+        * WebKitTestRunner/InjectedBundle/TestRunner.h:
+        (TestRunner):
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::setMockGeolocationPosition):
+        * WebKitTestRunner/TestController.h:
+        (TestController):
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
+
 2012-10-04  Raphael Kubo da Costa  <raphael.kubo.da.costa@intel.com>
 
         Make the Xvfb driver recognize `X' as a valid X server binary.
index 9f7a7c1..12a194d 100644 (file)
@@ -1087,10 +1087,40 @@ static JSValueRef setMockGeolocationPositionCallback(JSContextRef context, JSObj
     if (argumentCount < 3)
         return JSValueMakeUndefined(context);
 
+    double latitude = JSValueToNumber(context, arguments[0], 0);
+    double longitude = JSValueToNumber(context, arguments[1], 0);
+    double accuracy = JSValueToNumber(context, arguments[2], 0);
+
+    bool canProvideAltitude = false;
+    double altitude = 0.;
+    if (argumentCount > 3 && !JSValueIsUndefined(context, arguments[3])) {
+        canProvideAltitude = true;
+        altitude = JSValueToNumber(context, arguments[3], 0);
+    }
+
+    bool canProvideAltitudeAccuracy = false;
+    double altitudeAccuracy = 0.;
+    if (argumentCount > 4 && !JSValueIsUndefined(context, arguments[4])) {
+        canProvideAltitudeAccuracy = true;
+        altitudeAccuracy = JSValueToNumber(context, arguments[4], 0);
+    }
+
+    bool canProvideHeading = false;
+    double heading = 0.;
+    if (argumentCount > 5 && !JSValueIsUndefined(context, arguments[5])) {
+        canProvideHeading = true;
+        heading = JSValueToNumber(context, arguments[5], 0);
+    }
+
+    bool canProvideSpeed = false;
+    double speed = 0.;
+    if (argumentCount > 6 && !JSValueIsUndefined(context, arguments[6])) {
+        canProvideSpeed = true;
+        speed = JSValueToNumber(context, arguments[6], 0);
+    }
+
     TestRunner* controller = reinterpret_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
-    controller->setMockGeolocationPosition(JSValueToNumber(context, arguments[0], NULL),  // latitude
-                                           JSValueToNumber(context, arguments[1], NULL),  // longitude
-                                           JSValueToNumber(context, arguments[2], NULL));  // accuracy
+    controller->setMockGeolocationPosition(latitude, longitude, accuracy, canProvideAltitude, altitude, canProvideAltitudeAccuracy, altitudeAccuracy, canProvideHeading, heading, canProvideSpeed, speed);
 
     return JSValueMakeUndefined(context);
 }
index edd0dfd..745c969 100644 (file)
@@ -100,7 +100,7 @@ public:
     void setAutomaticLinkDetectionEnabled(bool flag);
     void setMainFrameIsFirstResponder(bool flag);
     void setMockDeviceOrientation(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma);
-    void setMockGeolocationPosition(double latitude, double longitude, double accuracy);
+    void setMockGeolocationPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed);
     void setMockGeolocationPositionUnavailableError(JSStringRef message);
     void addMockSpeechInputResult(JSStringRef result, double confidence, JSStringRef language);
     void setMockSpeechInputDumpRect(bool flag);
index cfb3302..8fc926a 100644 (file)
@@ -372,7 +372,7 @@ void TestRunner::setMockDeviceOrientation(bool, double, bool, double, bool, doub
     notImplemented();
 }
 
-void TestRunner::setMockGeolocationPosition(double, double, double)
+void TestRunner::setMockGeolocationPosition(double, double, double, bool, double, bool, double, bool, double, bool, double)
 {
     // FIXME: Implement for Geolocation layout tests.
     // See https://bugs.webkit.org/show_bug.cgi?id=28264.
index 1dc8199..6c9e11f 100644 (file)
@@ -437,7 +437,7 @@ void TestRunner::setMockDeviceOrientation(bool canProvideAlpha, double alpha, bo
     // See https://bugs.webkit.org/show_bug.cgi?id=30335.
 }
 
-void TestRunner::setMockGeolocationPosition(double latitude, double longitude, double accuracy)
+void TestRunner::setMockGeolocationPosition(double latitude, double longitude, double accuracy, bool, double, bool, double, bool, double, bool, double)
 {
     WebKitWebView* view = WEBKIT_WEB_VIEW(g_slist_nth_data(webViewList, 0));
     if (!view)
index 1a0a04d..81a1665 100644 (file)
@@ -42,6 +42,7 @@
 #import <JavaScriptCore/JSRetainPtr.h>
 #import <JavaScriptCore/JSStringRef.h>
 #import <JavaScriptCore/JSStringRefCF.h>
+#import <WebCore/GeolocationPosition.h>
 #import <WebKit/DOMDocument.h>
 #import <WebKit/DOMElement.h>
 #import <WebKit/WebApplicationCache.h>
 
 @end
 
+@interface WebGeolocationPosition (Internal)
+- (id)initWithGeolocationPosition:(PassRefPtr<WebCore::GeolocationPosition>)coreGeolocationPosition;
+@end
+
 TestRunner::~TestRunner()
 {
 }
@@ -472,9 +477,16 @@ void TestRunner::setMockDeviceOrientation(bool canProvideAlpha, double alpha, bo
     [orientation release];
 }
 
-void TestRunner::setMockGeolocationPosition(double latitude, double longitude, double accuracy)
+void TestRunner::setMockGeolocationPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed)
 {
-    WebGeolocationPosition *position = [[WebGeolocationPosition alloc] initWithTimestamp:currentTime() latitude:latitude longitude:longitude accuracy:accuracy];
+    WebGeolocationPosition *position = nil;
+    if (!providesAltitude && !providesAltitudeAccuracy && !providesHeading && !providesSpeed) {
+        // Test the exposed API.
+        position = [[WebGeolocationPosition alloc] initWithTimestamp:currentTime() latitude:latitude longitude:longitude accuracy:accuracy];
+    } else {
+        RefPtr<WebCore::GeolocationPosition> coreGeolocationPosition = WebCore::GeolocationPosition::create(currentTime(), latitude, longitude, accuracy, providesAltitude, altitude, providesAltitudeAccuracy, altitudeAccuracy, providesHeading, heading, providesSpeed, speed);
+        position = [[WebGeolocationPosition alloc] initWithGeolocationPosition:(coreGeolocationPosition.release())];
+    }
     [[MockGeolocationProvider shared] setPosition:position];
     [position release];
 }
index c4400fd..93e637d 100644 (file)
@@ -414,7 +414,7 @@ void TestRunner::setMockDeviceOrientation(bool canProvideAlpha, double alpha, bo
     // See https://bugs.webkit.org/show_bug.cgi?id=30335.
 }
 
-void TestRunner::setMockGeolocationPosition(double latitude, double longitude, double accuracy)
+void TestRunner::setMockGeolocationPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed)
 {
     // FIXME: Implement for Geolocation layout tests.
     // See https://bugs.webkit.org/show_bug.cgi?id=28264.
index e780cfe..874aa67 100644 (file)
@@ -333,7 +333,7 @@ void TestRunner::setMockDeviceOrientation(bool canProvideAlpha, double alpha, bo
     // See https://bugs.webkit.org/show_bug.cgi?id=30335.
 }
 
-void TestRunner::setMockGeolocationPosition(double latitude, double longitude, double accuracy)
+void TestRunner::setMockGeolocationPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed)
 {
     // FIXME: Implement for Geolocation layout tests.
     // See https://bugs.webkit.org/show_bug.cgi?id=28264.
index a5b6b65..7fa0bdb 100644 (file)
@@ -58,9 +58,9 @@ GeolocationProviderMock::GeolocationProviderMock(WKContextRef context)
     WKGeolocationManagerSetProvider(m_geolocationManager, &providerCallback);
 }
 
-void GeolocationProviderMock::setPosition(double latitude, double longitude, double accuracy)
+void GeolocationProviderMock::setPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed)
 {
-    m_position.adopt(WKGeolocationPositionCreate(currentTime(), latitude, longitude, accuracy));
+    m_position.adopt(WKGeolocationPositionCreate_b(currentTime(), latitude, longitude, accuracy, providesAltitude, altitude, providesAltitudeAccuracy, altitudeAccuracy, providesHeading, heading, providesSpeed, speed));
 
     m_hasError = false;
     m_errorMessage.clear();
index 4a06f08..1ebf67d 100644 (file)
@@ -34,7 +34,7 @@ class GeolocationProviderMock {
 public:
     GeolocationProviderMock(WKContextRef);
 
-    void setPosition(double latitude, double longitude, double accuracy);
+    void setPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed);
     void setPositionUnavailableError(WKStringRef errorMessage);
 
     void startUpdating(WKGeolocationManagerRef);
index f2da640..4429283 100644 (file)
@@ -465,7 +465,11 @@ sub _platformTypeVariableDeclaration
     );
 
     my $nullValue = "0";
-    $nullValue = "$platformType()" if defined $nonPointerTypes{$platformType} && $platformType ne "double";
+    if ($platformType eq "JSValueRef") {
+        $nullValue = "JSValueMakeUndefined(context)";
+    } elsif (defined $nonPointerTypes{$platformType} && $platformType ne "double") {
+        $nullValue = "$platformType()";
+    }
 
     $platformType .= "*" unless defined $nonPointerTypes{$platformType};
 
index 6efd78e..ed9d975 100644 (file)
@@ -180,7 +180,7 @@ module WTR {
 
         // Geolocation
         void setGeolocationPermission(in boolean value);
-        void setMockGeolocationPosition(in double latitude, in double longitude, in double accuracy);
+        void setMockGeolocationPosition(in double latitude, in double longitude, in double accuracy, in [Optional=DefaultIsUndefined] object altitude, in [Optional] object altitudeAccuracy, in [Optional] object heading, in [Optional] object speed);
         void setMockGeolocationPositionUnavailableError(in DOMString errorMessage);
 
         boolean callShouldCloseOnWebView();
index 4b012c8..226e57a 100644 (file)
@@ -369,7 +369,7 @@ void InjectedBundle::setGeolocationPermission(bool enabled)
     WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get());
 }
 
-void InjectedBundle::setMockGeolocationPosition(double latitude, double longitude, double accuracy)
+void InjectedBundle::setMockGeolocationPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed)
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetMockGeolocationPosition"));
 
@@ -387,6 +387,38 @@ void InjectedBundle::setMockGeolocationPosition(double latitude, double longitud
     WKRetainPtr<WKDoubleRef> accuracyWK(AdoptWK, WKDoubleCreate(accuracy));
     WKDictionaryAddItem(messageBody.get(), accuracyKeyWK.get(), accuracyWK.get());
 
+    WKRetainPtr<WKStringRef> providesAltitudeKeyWK(AdoptWK, WKStringCreateWithUTF8CString("providesAltitude"));
+    WKRetainPtr<WKBooleanRef> providesAltitudeWK(AdoptWK, WKBooleanCreate(providesAltitude));
+    WKDictionaryAddItem(messageBody.get(), providesAltitudeKeyWK.get(), providesAltitudeWK.get());
+
+    WKRetainPtr<WKStringRef> altitudeKeyWK(AdoptWK, WKStringCreateWithUTF8CString("altitude"));
+    WKRetainPtr<WKDoubleRef> altitudeWK(AdoptWK, WKDoubleCreate(altitude));
+    WKDictionaryAddItem(messageBody.get(), altitudeKeyWK.get(), altitudeWK.get());
+
+    WKRetainPtr<WKStringRef> providesAltitudeAccuracyKeyWK(AdoptWK, WKStringCreateWithUTF8CString("providesAltitudeAccuracy"));
+    WKRetainPtr<WKBooleanRef> providesAltitudeAccuracyWK(AdoptWK, WKBooleanCreate(providesAltitudeAccuracy));
+    WKDictionaryAddItem(messageBody.get(), providesAltitudeAccuracyKeyWK.get(), providesAltitudeAccuracyWK.get());
+
+    WKRetainPtr<WKStringRef> altitudeAccuracyKeyWK(AdoptWK, WKStringCreateWithUTF8CString("altitudeAccuracy"));
+    WKRetainPtr<WKDoubleRef> altitudeAccuracyWK(AdoptWK, WKDoubleCreate(altitudeAccuracy));
+    WKDictionaryAddItem(messageBody.get(), altitudeAccuracyKeyWK.get(), altitudeAccuracyWK.get());
+
+    WKRetainPtr<WKStringRef> providesHeadingKeyWK(AdoptWK, WKStringCreateWithUTF8CString("providesHeading"));
+    WKRetainPtr<WKBooleanRef> providesHeadingWK(AdoptWK, WKBooleanCreate(providesHeading));
+    WKDictionaryAddItem(messageBody.get(), providesHeadingKeyWK.get(), providesHeadingWK.get());
+
+    WKRetainPtr<WKStringRef> headingKeyWK(AdoptWK, WKStringCreateWithUTF8CString("heading"));
+    WKRetainPtr<WKDoubleRef> headingWK(AdoptWK, WKDoubleCreate(heading));
+    WKDictionaryAddItem(messageBody.get(), headingKeyWK.get(), headingWK.get());
+
+    WKRetainPtr<WKStringRef> providesSpeedKeyWK(AdoptWK, WKStringCreateWithUTF8CString("providesSpeed"));
+    WKRetainPtr<WKBooleanRef> providesSpeedWK(AdoptWK, WKBooleanCreate(providesSpeed));
+    WKDictionaryAddItem(messageBody.get(), providesSpeedKeyWK.get(), providesSpeedWK.get());
+
+    WKRetainPtr<WKStringRef> speedKeyWK(AdoptWK, WKStringCreateWithUTF8CString("speed"));
+    WKRetainPtr<WKDoubleRef> speedWK(AdoptWK, WKDoubleCreate(speed));
+    WKDictionaryAddItem(messageBody.get(), speedKeyWK.get(), speedWK.get());
+
     WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get());
 }
 
index e296142..44bbcc1 100644 (file)
@@ -92,7 +92,7 @@ public:
 
     // Geolocation.
     void setGeolocationPermission(bool);
-    void setMockGeolocationPosition(double latitude, double longitude, double accuracy);
+    void setMockGeolocationPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed);
     void setMockGeolocationPositionUnavailableError(WKStringRef errorMessage);
 
 private:
index c2fd342..dc2f2e2 100644 (file)
@@ -780,9 +780,40 @@ void TestRunner::setGeolocationPermission(bool enabled)
     InjectedBundle::shared().setGeolocationPermission(enabled);
 }
 
-void TestRunner::setMockGeolocationPosition(double latitude, double longitude, double accuracy)
+void TestRunner::setMockGeolocationPosition(double latitude, double longitude, double accuracy, JSValueRef jsAltitude, JSValueRef jsAltitudeAccuracy, JSValueRef jsHeading, JSValueRef jsSpeed)
 {
-    InjectedBundle::shared().setMockGeolocationPosition(latitude, longitude, accuracy);
+    WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page());
+    JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame);
+
+    bool providesAltitude = false;
+    double altitude = 0.;
+    if (!JSValueIsUndefined(context, jsAltitude)) {
+        providesAltitude = true;
+        altitude = JSValueToNumber(context, jsAltitude, 0);
+    }
+
+    bool providesAltitudeAccuracy = false;
+    double altitudeAccuracy = 0.;
+    if (!JSValueIsUndefined(context, jsAltitudeAccuracy)) {
+        providesAltitudeAccuracy = true;
+        altitudeAccuracy = JSValueToNumber(context, jsAltitudeAccuracy, 0);
+    }
+
+    bool providesHeading = false;
+    double heading = 0.;
+    if (!JSValueIsUndefined(context, jsHeading)) {
+        providesHeading = true;
+        heading = JSValueToNumber(context, jsHeading, 0);
+    }
+
+    bool providesSpeed = false;
+    double speed = 0.;
+    if (!JSValueIsUndefined(context, jsSpeed)) {
+        providesSpeed = true;
+        speed = JSValueToNumber(context, jsSpeed, 0);
+    }
+
+    InjectedBundle::shared().setMockGeolocationPosition(latitude, longitude, accuracy, providesAltitude, altitude, providesAltitudeAccuracy, altitudeAccuracy, providesHeading, heading, providesSpeed, speed);
 }
 
 void TestRunner::setMockGeolocationPositionUnavailableError(JSStringRef message)
index 8458943..0d5e360 100644 (file)
@@ -251,7 +251,7 @@ public:
 
     // Geolocation.
     void setGeolocationPermission(bool);
-    void setMockGeolocationPosition(double latitude, double longitude, double accuracy);
+    void setMockGeolocationPosition(double latitude, double longitude, double accuracy, JSValueRef altitude, JSValueRef altitudeAccuracy, JSValueRef heading, JSValueRef speed);
     void setMockGeolocationPositionUnavailableError(JSStringRef message);
 
     JSRetainPtr<JSStringRef> platformName();
index 0a2788b..a4a00ed 100644 (file)
@@ -1005,9 +1005,9 @@ void TestController::setGeolocationPermission(bool enabled)
     decidePolicyForGeolocationPermissionRequestIfPossible();
 }
 
-void TestController::setMockGeolocationPosition(double latitude, double longitude, double accuracy)
+void TestController::setMockGeolocationPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed)
 {
-    m_geolocationProvider->setPosition(latitude, longitude, accuracy);
+    m_geolocationProvider->setPosition(latitude, longitude, accuracy, providesAltitude, altitude, providesAltitudeAccuracy, altitudeAccuracy, providesHeading, heading, providesSpeed, speed);
 }
 
 void TestController::setMockGeolocationPositionUnavailableError(WKStringRef errorMessage)
index 53e1a21..d7111c5 100644 (file)
@@ -69,7 +69,7 @@ public:
 
     // Geolocation.
     void setGeolocationPermission(bool);
-    void setMockGeolocationPosition(double latitude, double longitude, double accuracy);
+    void setMockGeolocationPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed);
     void setMockGeolocationPositionUnavailableError(WKStringRef errorMessage);
     void handleGeolocationPermissionRequest(WKGeolocationPermissionRequestRef);
 
index 9ca75ae..14ba4d3 100644 (file)
@@ -371,7 +371,39 @@ void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef messageName
         WKDoubleRef accuracyWK = static_cast<WKDoubleRef>(WKDictionaryGetItemForKey(messageBodyDictionary, accuracyKeyWK.get()));
         double accuracy = WKDoubleGetValue(accuracyWK);
 
-        TestController::shared().setMockGeolocationPosition(latitude, longitude, accuracy);
+        WKRetainPtr<WKStringRef> providesAltitudeKeyWK(AdoptWK, WKStringCreateWithUTF8CString("providesAltitude"));
+        WKBooleanRef providesAltitudeWK = static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(messageBodyDictionary, providesAltitudeKeyWK.get()));
+        bool providesAltitude = WKBooleanGetValue(providesAltitudeWK);
+
+        WKRetainPtr<WKStringRef> altitudeKeyWK(AdoptWK, WKStringCreateWithUTF8CString("altitude"));
+        WKDoubleRef altitudeWK = static_cast<WKDoubleRef>(WKDictionaryGetItemForKey(messageBodyDictionary, altitudeKeyWK.get()));
+        double altitude = WKDoubleGetValue(altitudeWK);
+
+        WKRetainPtr<WKStringRef> providesAltitudeAccuracyKeyWK(AdoptWK, WKStringCreateWithUTF8CString("providesAltitudeAccuracy"));
+        WKBooleanRef providesAltitudeAccuracyWK = static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(messageBodyDictionary, providesAltitudeAccuracyKeyWK.get()));
+        bool providesAltitudeAccuracy = WKBooleanGetValue(providesAltitudeAccuracyWK);
+
+        WKRetainPtr<WKStringRef> altitudeAccuracyKeyWK(AdoptWK, WKStringCreateWithUTF8CString("altitudeAccuracy"));
+        WKDoubleRef altitudeAccuracyWK = static_cast<WKDoubleRef>(WKDictionaryGetItemForKey(messageBodyDictionary, altitudeAccuracyKeyWK.get()));
+        double altitudeAccuracy = WKDoubleGetValue(altitudeAccuracyWK);
+
+        WKRetainPtr<WKStringRef> providesHeadingKeyWK(AdoptWK, WKStringCreateWithUTF8CString("providesHeading"));
+        WKBooleanRef providesHeadingWK = static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(messageBodyDictionary, providesHeadingKeyWK.get()));
+        bool providesHeading = WKBooleanGetValue(providesHeadingWK);
+
+        WKRetainPtr<WKStringRef> headingKeyWK(AdoptWK, WKStringCreateWithUTF8CString("heading"));
+        WKDoubleRef headingWK = static_cast<WKDoubleRef>(WKDictionaryGetItemForKey(messageBodyDictionary, headingKeyWK.get()));
+        double heading = WKDoubleGetValue(headingWK);
+
+        WKRetainPtr<WKStringRef> providesSpeedKeyWK(AdoptWK, WKStringCreateWithUTF8CString("providesSpeed"));
+        WKBooleanRef providesSpeedWK = static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(messageBodyDictionary, providesSpeedKeyWK.get()));
+        bool providesSpeed = WKBooleanGetValue(providesSpeedWK);
+
+        WKRetainPtr<WKStringRef> speedKeyWK(AdoptWK, WKStringCreateWithUTF8CString("speed"));
+        WKDoubleRef speedWK = static_cast<WKDoubleRef>(WKDictionaryGetItemForKey(messageBodyDictionary, speedKeyWK.get()));
+        double speed = WKDoubleGetValue(speedWK);
+
+        TestController::shared().setMockGeolocationPosition(latitude, longitude, accuracy, providesAltitude, altitude, providesAltitudeAccuracy, altitudeAccuracy, providesHeading, heading, providesSpeed, speed);
         return;
     }