Home | History | Annotate | Download | only in net
      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 "chromeos/network/portal_detector/network_portal_detector.h"
     16 
     17 namespace chromeos {
     18 
     19 class NetworkPortalDetectorTestImpl : public NetworkPortalDetector {
     20  public:
     21   NetworkPortalDetectorTestImpl();
     22   virtual ~NetworkPortalDetectorTestImpl();
     23 
     24   void SetDefaultNetworkForTesting(const std::string& guid);
     25   void SetDetectionResultsForTesting(const std::string& guid,
     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 std::string& service_path) OVERRIDE;
     35   virtual bool IsEnabled() OVERRIDE;
     36   virtual void Enable(bool start_detection) OVERRIDE;
     37   virtual bool StartDetectionIfIdle() OVERRIDE;
     38 
     39   virtual void SetStrategy(PortalDetectorStrategy::StrategyId id) OVERRIDE;
     40 
     41   PortalDetectorStrategy::StrategyId strategy_id() const {
     42     return strategy_id_;
     43   }
     44 
     45  private:
     46   typedef std::string NetworkId;
     47   typedef base::hash_map<NetworkId, CaptivePortalState> CaptivePortalStateMap;
     48 
     49   ObserverList<Observer> observers_;
     50   scoped_ptr<NetworkState> default_network_;
     51   CaptivePortalStateMap portal_state_map_;
     52   PortalDetectorStrategy::StrategyId strategy_id_;
     53 
     54   DISALLOW_COPY_AND_ASSIGN(NetworkPortalDetectorTestImpl);
     55 };
     56 
     57 }  // namespace chromeos
     58 
     59 #endif  // CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_TEST_IMPL_H_
     60