diff options
author | mef@chromium.org <mef@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-25 03:19:16 +0000 |
---|---|---|
committer | mef@chromium.org <mef@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-25 03:19:16 +0000 |
commit | 665e48d9d8a8a1b54f9526291aad6f1c68ca85e4 (patch) | |
tree | 63feefb0fee924403768cb633e6fe39771ab3f32 /components/wifi/wifi_test.cc | |
parent | 7c7e56a09fb925d83d8af43e8b943c7706dbc9c5 (diff) | |
download | chromium_src-665e48d9d8a8a1b54f9526291aad6f1c68ca85e4.zip chromium_src-665e48d9d8a8a1b54f9526291aad6f1c68ca85e4.tar.gz chromium_src-665e48d9d8a8a1b54f9526291aad6f1c68ca85e4.tar.bz2 |
Ignore ERROR_ADDRESS_NOT_ASSOCIATED from IpReleaseAddress in WiFiService::ResetDHCP.
It is reported on Win 8.1 running on MS Surface Pro after connection to factory-reset Chromecast device.
BUG=366582
Review URL: https://codereview.chromium.org/250223002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266117 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/wifi/wifi_test.cc')
-rw-r--r-- | components/wifi/wifi_test.cc | 55 |
1 files changed, 35 insertions, 20 deletions
diff --git a/components/wifi/wifi_test.cc b/components/wifi/wifi_test.cc index d88232f..ac7522b 100644 --- a/components/wifi/wifi_test.cc +++ b/components/wifi/wifi_test.cc @@ -13,6 +13,7 @@ #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" +#include "base/run_loop.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_split.h" #include "base/strings/string_util.h" @@ -52,11 +53,27 @@ class WiFiTest { base::MessageLoop::current()->Quit(); } + void OnNetworksChanged( + const WiFiService::NetworkGuidList& network_guid_list) { + VLOG(0) << "Networks Changed: " << network_guid_list[0]; + base::DictionaryValue properties; + std::string error; + wifi_service_->GetProperties(network_guid_list[0], &properties, &error); + VLOG(0) << error << ":\n" << properties; + } + + void OnNetworkListChanged( + const WiFiService::NetworkGuidList& network_guid_list) { + VLOG(0) << "Network List Changed: " << network_guid_list.size(); + } + #if defined(OS_MACOSX) // Without this there will be a mem leak on osx. base::mac::ScopedNSAutoreleasePool scoped_pool_; #endif + scoped_ptr<WiFiService> wifi_service_; + // Need AtExitManager to support AsWeakPtr (in NetLog). base::AtExitManager exit_manager_; @@ -111,17 +128,14 @@ bool WiFiTest::ParseCommandLine(int argc, const char* argv[]) { MessageBoxA(NULL, __FUNCTION__, "Debug Me!", MB_OK); #endif -#if defined(OS_WIN) || defined(OS_MACOSX) - scoped_ptr<WiFiService> wifi_service(WiFiService::Create()); -#else - scoped_ptr<WiFiService> wifi_service(WiFiService::CreateForTest()); -#endif + base::MessageLoopForIO loop; - wifi_service->Initialize(NULL); + wifi_service_.reset(WiFiService::Create()); + wifi_service_->Initialize(loop.message_loop_proxy()); if (parsed_command_line.HasSwitch("list")) { base::ListValue network_list; - wifi_service->GetVisibleNetworks(std::string(), &network_list); + wifi_service_->GetVisibleNetworks(std::string(), &network_list); VLOG(0) << network_list; return true; } @@ -130,7 +144,7 @@ bool WiFiTest::ParseCommandLine(int argc, const char* argv[]) { if (network_guid.length() > 0) { base::DictionaryValue properties; std::string error; - wifi_service->GetProperties(network_guid, &properties, &error); + wifi_service_->GetProperties(network_guid, &properties, &error); VLOG(0) << error << ":\n" << properties; return true; } @@ -159,10 +173,8 @@ bool WiFiTest::ParseCommandLine(int argc, const char* argv[]) { std::string new_network_guid; properties->SetString("WiFi.SSID", network_guid); VLOG(0) << "Creating Network: " << *properties; - wifi_service->CreateNetwork(false, - properties.Pass(), - &new_network_guid, - &error); + wifi_service_->CreateNetwork( + false, properties.Pass(), &new_network_guid, &error); VLOG(0) << error << ":\n" << new_network_guid; return true; } @@ -173,12 +185,17 @@ bool WiFiTest::ParseCommandLine(int argc, const char* argv[]) { std::string error; if (!properties->empty()) { VLOG(0) << "Using connect properties: " << *properties; - wifi_service->SetProperties(network_guid, - properties.Pass(), - &error); + wifi_service_->SetProperties(network_guid, properties.Pass(), &error); } - wifi_service->StartConnect(network_guid, &error); + + wifi_service_->SetEventObservers( + loop.message_loop_proxy(), + base::Bind(&WiFiTest::OnNetworksChanged, base::Unretained(this)), + base::Bind(&WiFiTest::OnNetworkListChanged, base::Unretained(this))); + + wifi_service_->StartConnect(network_guid, &error); VLOG(0) << error; + base::MessageLoop::current()->Run(); return true; } } @@ -186,7 +203,7 @@ bool WiFiTest::ParseCommandLine(int argc, const char* argv[]) { if (parsed_command_line.HasSwitch("disconnect")) { if (network_guid.length() > 0) { std::string error; - wifi_service->StartDisconnect(network_guid, &error); + wifi_service_->StartDisconnect(network_guid, &error); VLOG(0) << error; return true; } @@ -196,9 +213,7 @@ bool WiFiTest::ParseCommandLine(int argc, const char* argv[]) { if (network_guid.length() > 0) { std::string error; std::string key_data; - wifi_service->GetKeyFromSystem(network_guid, - &key_data, - &error); + wifi_service_->GetKeyFromSystem(network_guid, &key_data, &error); VLOG(0) << key_data << error; return true; } |