Bug 39081 - [chromium] Adds supports for layout tests using GeolocationServiceMock
Summary: [chromium] Adds supports for layout tests using GeolocationServiceMock
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-13 13:06 PDT by Marcus Bulach
Modified: 2010-05-19 10:51 PDT (History)
7 users (show)

See Also:


Attachments
Patch (14.35 KB, patch)
2010-05-13 13:12 PDT, Marcus Bulach
no flags Details | Formatted Diff | Diff
Patch (14.39 KB, patch)
2010-05-14 08:29 PDT, Marcus Bulach
no flags Details | Formatted Diff | Diff
Patch (14.27 KB, patch)
2010-05-18 05:08 PDT, Marcus Bulach
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marcus Bulach 2010-05-13 13:06:29 PDT
Adds supports for layout tests using GeolocationServiceMock.
Allows injection of GeolocationServiceMock factory.
Comment 1 Marcus Bulach 2010-05-13 13:12:28 PDT
Created attachment 56011 [details]
Patch
Comment 2 Marcus Bulach 2010-05-13 13:15:25 PDT
hi steve, sorry to keep bothering you, but would you mind taking a look at this patch? take your time, this is low priority.. ;) 
thanks!
Comment 3 Steve Block 2010-05-14 02:09:34 PDT
Comment on attachment 56011 [details]
Patch

Can you explain why this is needed? As far as I can see, GeolocationServiceChromiumMock is an intermediate that sits between the existing GeolocationServiceMock and the Geolocation object. Does this class exist solely to add the extra calls to GeolocationServiceChromium::startUpdating()/stopUpdating()?

It looks like GeolocationServiceChromiumMock is mostly boilerplate - could it be reduced by having it inherit from GeolocationServiceMock, rather than owning an instance?

> diff --git a/WebCore/platform/GeolocationService.cpp b/WebCore/platform/GeolocationService.cpp
> +void GeolocationService::useMockFactory(FactoryFunction f)
> +{
> +    s_mockFactoryFunction = f;
> +    useMock();
>  }
So we need to call useMock() here, as it's called from setPosition and setError? Would a better name for this function then be 'setCustomMock'?
Comment 4 Marcus Bulach 2010-05-14 08:29:09 PDT
Created attachment 56071 [details]
Patch
Comment 5 Marcus Bulach 2010-05-14 08:42:19 PDT
thanks for the quick reply, Steve!
replies inline:

(In reply to comment #3)
> (From update of attachment 56011 [details])
> Can you explain why this is needed? As far as I can see, GeolocationServiceChromiumMock is an intermediate that sits between the existing GeolocationServiceMock and the Geolocation object. Does this class exist solely to add the extra calls to GeolocationServiceChromium::startUpdating()/stopUpdating()?
> 
> It looks like GeolocationServiceChromiumMock is mostly boilerplate - could it be reduced by having it inherit from GeolocationServiceMock, rather than owning an instance?

sorry, I tried to keep the minimalistic comment style here, but obviously it needs some clarifications.. :) let me know what's the best way to add (ChangeLog? inline comments?)
anyways: there are extensive comments on the other side:
http://codereview.chromium.org/2094003/diff/5001/6001

basically: there are a few layers up in the embedder that require a GeolocationServiceChromium (for getBridgeId() / attachBridgeIfNeeded).

hence, the simplest way seemed to extend that expected object/interface, and delegate the calls to GeolocationServiceMock as appropriate..

so yes, it's just an intermediary proxy that sits between Geolocation and the embedder. it's all boiler plate code to adapt what the embedder expects to what the mock provides, and to inject in a Geolocation object.

> 
> > diff --git a/WebCore/platform/GeolocationService.cpp b/WebCore/platform/GeolocationService.cpp
> > +void GeolocationService::useMockFactory(FactoryFunction f)
> > +{
> > +    s_mockFactoryFunction = f;
> > +    useMock();
> >  }
> So we need to call useMock() here, as it's called from setPosition and setError? Would a better name for this function then be 'setCustomMock'?

renamed to setCustomMockFactory, and moved the "useMock()" call from here to higher up.
Comment 6 Steve Block 2010-05-18 03:34:51 PDT
Comment on attachment 56071 [details]
Patch

> so yes, it's just an intermediary proxy that sits between Geolocation and the embedder. it's all boiler plate code to adapt
>  what the embedder expects to what the mock provides, and to inject in a Geolocation object.
OK, got it, thanks

WebKit/chromium/src/WebGeolocationServiceMock.cpp:124
 +  void WebGeolocationServiceMock::useGeolocationServiceMock()
Do you need this method? The existing GeolocationServiceMock simply calls GeolocationService::useMock() from setPosition() and setError(). Could we do similarly and call setCustomMockFactory() from setMockGeolocationPosition() and setMockGeolocationError()? Is the additional call to GeolocationService::useMock() required?
Comment 7 Marcus Bulach 2010-05-18 05:08:05 PDT
Created attachment 56363 [details]
Patch
Comment 8 Marcus Bulach 2010-05-18 05:12:20 PDT
(In reply to comment #6)
> (From update of attachment 56071 [details])
> > so yes, it's just an intermediary proxy that sits between Geolocation and the embedder. it's all boiler plate code to adapt
> >  what the embedder expects to what the mock provides, and to inject in a Geolocation object.
> OK, got it, thanks
> 
> WebKit/chromium/src/WebGeolocationServiceMock.cpp:124
>  +  void WebGeolocationServiceMock::useGeolocationServiceMock()
> Do you need this method? The existing GeolocationServiceMock simply calls GeolocationService::useMock() from setPosition() and setError(). Could we do similarly and call setCustomMockFactory() from setMockGeolocationPosition() and setMockGeolocationError()? Is the additional call to GeolocationService::useMock() required?

hehe, yeah, tricky trade off between less API surface versus number of calls..

anyways: followed your suggestions, removed the method, and added calls to setCustomMockFactory() on both setMockGeolocationPosition/Error.

another look please?
Comment 9 WebKit Commit Bot 2010-05-19 10:38:17 PDT
Comment on attachment 56363 [details]
Patch

Clearing flags on attachment: 56363

Committed r59772: <http://trac.webkit.org/changeset/59772>
Comment 10 WebKit Commit Bot 2010-05-19 10:38:22 PDT
All reviewed patches have been landed.  Closing bug.
Comment 11 WebKit Review Bot 2010-05-19 10:51:10 PDT
http://trac.webkit.org/changeset/59772 might have broken Qt Windows 32-bit Release