network_portal_detector_test_impl.h revision 8bcbed890bc3ce4d7a057a8f32cab53fa534672e
1// Copyright 2013 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#ifndef CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_TEST_IMPL_H_ 6#define CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_TEST_IMPL_H_ 7 8#include <string> 9 10#include "base/basictypes.h" 11#include "base/compiler_specific.h" 12#include "base/containers/hash_tables.h" 13#include "base/memory/scoped_ptr.h" 14#include "base/observer_list.h" 15#include "chrome/browser/chromeos/net/network_portal_detector.h" 16 17namespace chromeos { 18 19class NetworkPortalDetectorTestImpl : public NetworkPortalDetector { 20 public: 21 NetworkPortalDetectorTestImpl(); 22 virtual ~NetworkPortalDetectorTestImpl(); 23 24 void SetDefaultNetworkPathForTesting(const std::string& service_path); 25 void SetDetectionResultsForTesting(const std::string& service_path, 26 const CaptivePortalState& state); 27 void NotifyObserversForTesting(); 28 29 // NetworkPortalDetector implementation: 30 virtual void AddObserver(Observer* observer) OVERRIDE; 31 virtual void AddAndFireObserver(Observer* observer) OVERRIDE; 32 virtual void RemoveObserver(Observer* observer) OVERRIDE; 33 virtual CaptivePortalState GetCaptivePortalState( 34 const chromeos::NetworkState* network) OVERRIDE; 35 virtual bool IsEnabled() OVERRIDE; 36 virtual void Enable(bool start_detection) OVERRIDE; 37 virtual bool StartDetectionIfIdle() OVERRIDE; 38 virtual void EnableLazyDetection() OVERRIDE; 39 virtual void DisableLazyDetection() OVERRIDE; 40 41 private: 42 typedef std::string NetworkId; 43 typedef base::hash_map<NetworkId, CaptivePortalState> CaptivePortalStateMap; 44 45 46 ObserverList<Observer> observers_; 47 scoped_ptr<NetworkState> default_network_; 48 CaptivePortalStateMap portal_state_map_; 49 50 DISALLOW_COPY_AND_ASSIGN(NetworkPortalDetectorTestImpl); 51}; 52 53} // namespace chromeos 54 55#endif // CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_TEST_IMPL_H_ 56