• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2009 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 NET_BASE_MOCK_NETWORK_CHANGE_NOTIFIER_H_
6 #define NET_BASE_MOCK_NETWORK_CHANGE_NOTIFIER_H_
7 
8 #include "base/basictypes.h"
9 #include "net/base/network_change_notifier.h"
10 
11 namespace net {
12 
13 class MockNetworkChangeNotifier : public NetworkChangeNotifier {
14  public:
MockNetworkChangeNotifier()15   MockNetworkChangeNotifier() : observer_(NULL) {}
16 
~MockNetworkChangeNotifier()17   virtual ~MockNetworkChangeNotifier() {
18     CHECK(!observer_);
19   }
20 
NotifyIPAddressChange()21   void NotifyIPAddressChange() {
22     if (observer_)
23       observer_->OnIPAddressChanged();
24   }
25 
AddObserver(Observer * observer)26   virtual void AddObserver(Observer* observer) {
27     CHECK(!observer_);
28     observer_ = observer;
29   }
30 
RemoveObserver(Observer * observer)31   virtual void RemoveObserver(Observer* observer) {
32     CHECK(observer_ == observer);
33     observer_ = NULL;
34   }
35 
36  private:
37   Observer* observer_;
38 
39   DISALLOW_COPY_AND_ASSIGN(MockNetworkChangeNotifier);
40 };
41 
42 }  // namespace net
43 
44 #endif  // NET_BASE_MOCK_NETWORK_CHANGE_NOTIFIER_H_
45