Logo Search packages:      
Sourcecode: chromium-browser version File versions  Download package


// 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.


#include "chrome/browser/geolocation/location_provider.h"
#include "googleurl/src/gurl.h"

// Mock implementation of a location provider for testing.
class MockLocationProvider : public LocationProviderBase {
  virtual ~MockLocationProvider();

  using LocationProviderBase::UpdateListeners;
  using LocationProviderBase::InformListenersOfMovement;

  // LocationProviderBase implementation.
  virtual bool StartProvider();
  virtual void GetPosition(Geoposition* position);
  virtual void OnPermissionGranted(const GURL& requesting_frame);

  Geoposition position_;
  int started_count_;
  GURL permission_granted_url_;

  // Set when an instance of the mock is created via a factory function.
  static MockLocationProvider* instance_;


// 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();
// Similar to NewAutoSuccessMockLocationProvider but mimicks the behavior of
// the Network Location provider, in deferring making location updates until
// a permission request has been confirmed.
LocationProviderBase* NewAutoSuccessMockNetworkLocationProvider();


Generated by  Doxygen 1.6.0   Back to index