network_portal_detector_test_impl.h revision f8ee788a64d60abd8f2d742a5fdedde054ecd910
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 const std::string& guid); 26 void SetDetectionResultsForTesting(const std::string& service_path, 27 const CaptivePortalState& state); 28 void NotifyObserversForTesting(); 29 30 // NetworkPortalDetector implementation: 31 virtual void AddObserver(Observer* observer) OVERRIDE; 32 virtual void AddAndFireObserver(Observer* observer) OVERRIDE; 33 virtual void RemoveObserver(Observer* observer) OVERRIDE; 34 virtual CaptivePortalState GetCaptivePortalState( 35 const std::string& service_path) OVERRIDE; 36 virtual bool IsEnabled() OVERRIDE; 37 virtual void Enable(bool start_detection) OVERRIDE; 38 virtual bool StartDetectionIfIdle() OVERRIDE; 39 40 virtual void SetStrategy(PortalDetectorStrategy::StrategyId id) OVERRIDE; 41 42 PortalDetectorStrategy::StrategyId strategy_id() const { 43 return strategy_id_; 44 } 45 46 private: 47 typedef std::string NetworkId; 48 typedef base::hash_map<NetworkId, CaptivePortalState> CaptivePortalStateMap; 49 50 ObserverList<Observer> observers_; 51 scoped_ptr<NetworkState> default_network_; 52 CaptivePortalStateMap portal_state_map_; 53 PortalDetectorStrategy::StrategyId strategy_id_; 54 55 DISALLOW_COPY_AND_ASSIGN(NetworkPortalDetectorTestImpl); 56}; 57 58} // namespace chromeos 59 60#endif // CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_TEST_IMPL_H_ 61