| Index: chrome/browser/extensions/api/gcd_private/gcd_private_apitest.cc
|
| diff --git a/chrome/browser/extensions/api/gcd_private/gcd_private_apitest.cc b/chrome/browser/extensions/api/gcd_private/gcd_private_apitest.cc
|
| index f6dfaacd090483e207f5f9ed2ce8894facb499f4..328e068bf3532c3854b23b9f2e2dc91d63df02b8 100644
|
| --- a/chrome/browser/extensions/api/gcd_private/gcd_private_apitest.cc
|
| +++ b/chrome/browser/extensions/api/gcd_private/gcd_private_apitest.cc
|
| @@ -10,6 +10,7 @@
|
| #include "chrome/browser/extensions/extension_apitest.h"
|
| #include "chrome/browser/extensions/extension_service.h"
|
| #include "chrome/browser/local_discovery/gcd_api_flow.h"
|
| +#include "chrome/browser/local_discovery/wifi/mock_wifi_manager.h"
|
| #include "chrome/common/extensions/api/mdns.h"
|
| #include "extensions/common/switches.h"
|
| #include "net/url_request/test_url_fetcher_factory.h"
|
| @@ -21,6 +22,8 @@
|
|
|
| namespace api = extensions::api;
|
|
|
| +using testing::Invoke;
|
| +
|
| namespace {
|
|
|
| const char kCloudPrintResponse[] =
|
| @@ -232,6 +235,29 @@ class GcdPrivateAPITest : public ExtensionApiTest {
|
| "ddchlicdkolnonkihahngkmmmjnjlkkf");
|
| }
|
|
|
| +#if defined(ENABLE_WIFI_BOOTSTRAPPING)
|
| + virtual void OnCreateWifiManager() {
|
| + wifi_manager_ = wifi_manager_factory_.GetLastCreatedWifiManager();
|
| +
|
| + EXPECT_CALL(*wifi_manager_, Start());
|
| +
|
| + EXPECT_CALL(*wifi_manager_,
|
| + RequestNetworkCredentialsInternal("SuccessNetwork"))
|
| + .WillOnce(Invoke(this, &GcdPrivateAPITest::RespondToNetwork));
|
| +
|
| + EXPECT_CALL(*wifi_manager_,
|
| + RequestNetworkCredentialsInternal("FailureNetwork"))
|
| + .WillOnce(Invoke(this, &GcdPrivateAPITest::RespondToNetwork));
|
| + }
|
| +
|
| + void RespondToNetwork(const std::string& network) {
|
| + bool success = (network == "SuccessNetwork");
|
| +
|
| + wifi_manager_->CallRequestNetworkCredentialsCallback(
|
| + success, network, success ? "SuccessPass" : "");
|
| + }
|
| +#endif
|
| +
|
| protected:
|
| FakeGCDApiFlowFactory api_flow_factory_;
|
| net::URLFetcherImplFactory url_fetcher_impl_factory_;
|
| @@ -241,6 +267,11 @@ class GcdPrivateAPITest : public ExtensionApiTest {
|
| scoped_refptr<local_discovery::TestServiceDiscoveryClient>
|
| test_service_discovery_client_;
|
| #endif // ENABLE_MDNS
|
| +
|
| +#if defined(ENABLE_WIFI_BOOTSTRAPPING)
|
| + local_discovery::wifi::MockWifiManagerFactory wifi_manager_factory_;
|
| + local_discovery::wifi::MockWifiManager* wifi_manager_;
|
| +#endif
|
| };
|
|
|
| IN_PROC_BROWSER_TEST_F(GcdPrivateAPITest, GetCloudList) {
|
| @@ -319,4 +350,24 @@ IN_PROC_BROWSER_TEST_F(GcdPrivateAPITest, SendQuery) {
|
|
|
| #endif // ENABLE_MDNS
|
|
|
| +#if defined(ENABLE_WIFI_BOOTSTRAPPING)
|
| +
|
| +IN_PROC_BROWSER_TEST_F(GcdPrivateAPITest, WifiMessage) {
|
| + EXPECT_TRUE(RunExtensionSubtest("gcd_private/api", "wifi_message.html"));
|
| +}
|
| +
|
| +IN_PROC_BROWSER_TEST_F(GcdPrivateAPITest, WifiPasswords) {
|
| +// TODO(noamsml): Win Dbg has a workaround that makes RunExtensionSubtest
|
| +// always return true without actually running the test. Remove when fixed.
|
| +// See http://crbug.com/177163 for details.
|
| +#if !defined(OS_WIN) || defined(NDEBUG)
|
| + EXPECT_CALL(wifi_manager_factory_, WifiManagerCreated())
|
| + .WillOnce(Invoke(this, &GcdPrivateAPITest::OnCreateWifiManager));
|
| +#endif
|
| +
|
| + EXPECT_TRUE(RunExtensionSubtest("gcd_private/api", "wifi_password.html"));
|
| +}
|
| +
|
| +#endif // ENABLE_WIFI_BOOTSTRAPPING
|
| +
|
| } // namespace
|
|
|