blob: b690416dc7bfb6bdb3c8b79c54be3f85645922aa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_GEOLOCATION_MOCK_LOCATION_PROVIDER_H_
#define CHROME_BROWSER_GEOLOCATION_MOCK_LOCATION_PROVIDER_H_
#include "chrome/browser/geolocation/location_provider.h"
// Mock implementation of a location provider for testing.
class MockLocationProvider : public LocationProviderBase {
public:
MockLocationProvider();
virtual ~MockLocationProvider();
using LocationProviderBase::UpdateListeners;
using LocationProviderBase::InformListenersOfMovement;
// LocationProviderBase implementation.
virtual bool StartProvider();
virtual void GetPosition(Geoposition *position);
Geoposition position_;
int started_count_;
// Set when an instance of the mock is created via a factory function.
static MockLocationProvider* instance_;
DISALLOW_COPY_AND_ASSIGN(MockLocationProvider);
};
// Factory functions for the various sorts of mock location providers,
// for use with GeolocationArbitrator::SetProviderFactoryForTest (i.e.
// not intended for test code to use to get access to the mock, you can use
// MockLocationProvider::instance_ for this, or make a custom facotry method).
// Creates a mock location provider with no default behavior.
LocationProviderBase* NewMockLocationProvider();
// Creates a mock location provider that automatically notifies its
// listeners with a valid location when StartProvider is called.
LocationProviderBase* NewAutoSuccessMockLocationProvider();
// Creates a mock location provider that automatically notifies its
// listeners with an error when StartProvider is called.
LocationProviderBase* NewAutoFailMockLocationProvider();
#endif // CHROME_BROWSER_GEOLOCATION_MOCK_LOCATION_PROVIDER_H_
|