network_portal_detector_test_impl.h revision a1401311d1ab56c4ed0a474bd38c108f75cb0cd9
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 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 private:
40  typedef std::string NetworkId;
41  typedef base::hash_map<NetworkId, CaptivePortalState> CaptivePortalStateMap;
42
43
44  ObserverList<Observer> observers_;
45  scoped_ptr<NetworkState> default_network_;
46  CaptivePortalStateMap portal_state_map_;
47
48  DISALLOW_COPY_AND_ASSIGN(NetworkPortalDetectorTestImpl);
49};
50
51}  // namespace chromeos
52
53#endif  // CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_TEST_IMPL_H_
54