Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(528)

Side by Side Diff: content/test/mock_geolocation.cc

Issue 10070012: Geolocation support for chromedriver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/test/mock_geolocation.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/test/mock_geolocation.h"
6
7 #include "base/logging.h"
8 #include "content/browser/geolocation/arbitrator_dependency_factories_for_test.h "
9 #include "content/browser/geolocation/location_arbitrator.h"
10 #include "content/browser/geolocation/mock_location_provider.h"
11 #include "content/common/geoposition.h"
12
13 namespace content {
14
15 MockGeolocation::MockGeolocation() {
16 dependency_factory_ =
17 new GeolocationArbitratorDependencyFactoryWithLocationProvider(
18 &NewAutoSuccessMockLocationProvider);
19 }
20
21 MockGeolocation::~MockGeolocation() {
22 }
23
24 void MockGeolocation::Setup() {
25 GeolocationArbitrator::SetDependencyFactoryForTest(
26 dependency_factory_.get());
27 }
28
29 void MockGeolocation::TearDown() {
30 GeolocationArbitrator::SetDependencyFactoryForTest(NULL);
31 }
32
33 void MockGeolocation::GetCurrentPosition(double* latitude,
34 double* longitude) const {
35 *latitude = MockLocationProvider::instance_->position_.latitude;
36 *longitude = MockLocationProvider::instance_->position_.longitude;
37 }
38
39 void MockGeolocation::SetCurrentPosition(double latitude, double longitude) {
40 Geoposition geoposition;
41 geoposition.latitude = latitude;
42 geoposition.longitude = longitude;
43 geoposition.accuracy = 0;
44 geoposition.error_code = Geoposition::ERROR_CODE_NONE;
45 // Webkit compares the timestamp to wall clock time, so we need
46 // it to be contemporary.
47 geoposition.timestamp = base::Time::Now();
48 DCHECK(geoposition.IsValidFix());
49
50 MockLocationProvider::instance_->HandlePositionChanged(geoposition);
51 }
52
53 } // namespace content
OLDNEW
« no previous file with comments | « content/test/mock_geolocation.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698