| OLD | NEW |
| (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 | |
| OLD | NEW |