1 // Copyright 2014 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.
5 #ifndef CHROME_BROWSER_LOCAL_DISCOVERY_WIFI_MOCK_WIFI_MANAGER_H_
6 #define CHROME_BROWSER_LOCAL_DISCOVERY_WIFI_MOCK_WIFI_MANAGER_H_
8 #include "base/observer_list.h"
9 #include "chrome/browser/local_discovery/wifi/wifi_manager.h"
10 #include "testing/gmock/include/gmock/gmock.h"
12 namespace local_discovery
{
16 class MockWifiManager
: public WifiManager
{
19 ~MockWifiManager() override
;
21 MOCK_METHOD0(Start
, void());
23 void GetSSIDList(const SSIDListCallback
& callback
) override
;
25 MOCK_METHOD0(GetSSIDListInternal
, void());
27 void CallSSIDListCallback(const std::vector
<NetworkProperties
>& networks
);
29 MOCK_METHOD0(RequestScan
, void());
31 void ConfigureAndConnectNetwork(
32 const std::string
& ssid
,
33 const WifiCredentials
& credentials
,
34 const SuccessCallback
& callback
) override
;
36 MOCK_METHOD2(ConfigureAndConnectNetworkInternal
,
37 void(const std::string
& ssid
, const std::string
& password
));
39 void CallConfigureAndConnectNetworkCallback(bool success
);
41 void ConnectToNetworkByID(const std::string
& internal_id
,
42 const SuccessCallback
& callback
) override
;
44 MOCK_METHOD1(ConnectToNetworkByIDInternal
,
45 void(const std::string
& internal_id
));
47 void CallConnectToNetworkByIDCallback(bool success
);
49 void RequestNetworkCredentials(
50 const std::string
& internal_id
,
51 const CredentialsCallback
& callback
) override
;
53 MOCK_METHOD1(RequestNetworkCredentialsInternal
,
54 void(const std::string
& internal_id
));
56 void CallRequestNetworkCredentialsCallback(bool success
,
57 const std::string
& ssid
,
58 const std::string
& password
);
60 void AddNetworkListObserver(NetworkListObserver
* observer
);
62 void RemoveNetworkListObserver(NetworkListObserver
* observer
);
64 void CallNetworkListObservers(const std::vector
<NetworkProperties
>& ssids
);
67 SSIDListCallback ssid_list_callback_
;
68 SuccessCallback configure_and_connect_network_callback_
;
69 SuccessCallback connect_by_id_callback_
;
70 CredentialsCallback credentials_callback_
;
71 base::ObserverList
<NetworkListObserver
> network_observers_
;
73 base::WeakPtrFactory
<MockWifiManager
> weak_factory_
;
76 class MockWifiManagerFactory
: public WifiManagerFactory
{
78 MockWifiManagerFactory();
79 ~MockWifiManagerFactory() override
;
81 scoped_ptr
<WifiManager
> CreateWifiManager() override
;
83 MockWifiManager
* GetLastCreatedWifiManager();
85 MOCK_METHOD0(WifiManagerCreated
, void());
88 MockWifiManager
* last_created_manager_
;
93 } // namespace local_discovery
95 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_WIFI_MOCK_WIFI_MANAGER_H_