Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: components/wifi/wifi_test.cc

Issue 86123003: Use WiFi.Frequency property to set desired band for networkingPrivateApi.StartConnect() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Separated move of GetVisibleNetworks filtering into https://codereview.chromium.org/88653002 Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdio.h> 5 #include <stdio.h>
6 #include <iostream> 6 #include <iostream>
7 #include <string> 7 #include <string>
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 result_ = RESULT_PENDING; 81 result_ = RESULT_PENDING;
82 82
83 return result_; 83 return result_;
84 } 84 }
85 85
86 bool WiFiTest::ParseCommandLine(int argc, const char* argv[]) { 86 bool WiFiTest::ParseCommandLine(int argc, const char* argv[]) {
87 CommandLine::Init(argc, argv); 87 CommandLine::Init(argc, argv);
88 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); 88 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
89 std::string network_guid = 89 std::string network_guid =
90 parsed_command_line.GetSwitchValueASCII("network_guid"); 90 parsed_command_line.GetSwitchValueASCII("network_guid");
91 std::string frequency =
92 parsed_command_line.GetSwitchValueASCII("frequency");
91 93
92 if (parsed_command_line.GetArgs().size() == 1) { 94 if (parsed_command_line.GetArgs().size() == 1) {
93 #if defined(OS_WIN) 95 #if defined(OS_WIN)
94 network_guid = WideToASCII(parsed_command_line.GetArgs()[0]); 96 network_guid = WideToASCII(parsed_command_line.GetArgs()[0]);
95 #else 97 #else
96 network_guid = parsed_command_line.GetArgs()[0]; 98 network_guid = parsed_command_line.GetArgs()[0];
97 #endif 99 #endif
98 } 100 }
99 101
100 #if defined(OS_WIN) 102 #if defined(OS_WIN)
101 if (parsed_command_line.HasSwitch("debug")) 103 if (parsed_command_line.HasSwitch("debug"))
102 MessageBoxA(NULL, __FUNCTION__, "Debug Me!", MB_OK); 104 MessageBoxA(NULL, __FUNCTION__, "Debug Me!", MB_OK);
103 #endif 105 #endif
104 106
105 #if defined(OS_WIN) 107 #if defined(OS_WIN)
106 scoped_ptr<WiFiService> wifi_service(WiFiService::Create()); 108 scoped_ptr<WiFiService> wifi_service(WiFiService::Create());
107 #else 109 #else
108 scoped_ptr<WiFiService> wifi_service(WiFiService::CreateForTest()); 110 scoped_ptr<WiFiService> wifi_service(WiFiService::CreateForTest());
109 #endif 111 #endif
110 112
111 wifi_service->Initialize(NULL); 113 wifi_service->Initialize(NULL);
112 114
113 if (parsed_command_line.HasSwitch("list")) { 115 if (parsed_command_line.HasSwitch("list")) {
114 ListValue network_list; 116 ListValue network_list;
115 wifi_service->GetVisibleNetworks(&network_list); 117 wifi_service->GetVisibleNetworks(std::string(), &network_list);
116 std::cout << network_list; 118 std::cout << network_list;
117 return true; 119 return true;
118 } 120 }
119 121
120 if (parsed_command_line.HasSwitch("get_properties")) { 122 if (parsed_command_line.HasSwitch("get_properties")) {
121 if (network_guid.length() > 0) { 123 if (network_guid.length() > 0) {
122 DictionaryValue properties; 124 DictionaryValue properties;
123 std::string error; 125 std::string error;
124 wifi_service->GetProperties(network_guid, &properties, &error); 126 wifi_service->GetProperties(network_guid, &properties, &error);
125 std::cout << error << ":\n" << properties; 127 std::cout << error << ":\n" << properties;
126 return true; 128 return true;
127 } 129 }
128 } 130 }
129 131
132 // Optional properties (frequency, password) to use for connect.
133 scoped_ptr<DictionaryValue> connect_properties(new DictionaryValue());
134
135 if (parsed_command_line.HasSwitch("frequency")) {
136 int value = 0;
137 if (!network_guid.empty() &&
138 !frequency.empty() &&
139 base::StringToInt(frequency, &value)) {
140 connect_properties->SetInteger("WiFi.Frequency", value);
141 // fall through to connect.
142 }
143 }
144
130 if (parsed_command_line.HasSwitch("connect")) { 145 if (parsed_command_line.HasSwitch("connect")) {
131 if (network_guid.length() > 0) { 146 if (network_guid.length() > 0) {
132 std::string error; 147 std::string error;
148 if (!connect_properties->empty()) {
149 std::cout << "Using connect properties: " << *connect_properties;
150 wifi_service->SetProperties(network_guid,
151 connect_properties.Pass(),
152 &error);
153 }
133 wifi_service->StartConnect(network_guid, &error); 154 wifi_service->StartConnect(network_guid, &error);
134 std::cout << error; 155 std::cout << error;
135 return true; 156 return true;
136 } 157 }
137 } 158 }
138 159
139 if (parsed_command_line.HasSwitch("disconnect")) { 160 if (parsed_command_line.HasSwitch("disconnect")) {
140 if (network_guid.length() > 0) { 161 if (network_guid.length() > 0) {
141 std::string error; 162 std::string error;
142 wifi_service->StartDisconnect(network_guid, &error); 163 wifi_service->StartDisconnect(network_guid, &error);
143 std::cout << error; 164 std::cout << error;
144 return true; 165 return true;
145 } 166 }
146 } 167 }
147 168
148 return false; 169 return false;
149 } 170 }
150 171
151 } // namespace wifi 172 } // namespace wifi
152 173
153 int main(int argc, const char* argv[]) { 174 int main(int argc, const char* argv[]) {
154 wifi::WiFiTest wifi_test; 175 wifi::WiFiTest wifi_test;
155 return wifi_test.Main(argc, argv); 176 return wifi_test.Main(argc, argv);
156 } 177 }
OLDNEW
« components/wifi/wifi_service_win.cc ('K') | « components/wifi/wifi_service_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698