OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/json/json_writer.h" | 6 #include "base/json/json_writer.h" |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/strings/string_piece.h" | 8 #include "base/strings/string_piece.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chromeos/dbus/dbus_thread_manager.h" | 10 #include "chromeos/dbus/dbus_thread_manager.h" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 base::MessageLoopForUI message_loop_; | 210 base::MessageLoopForUI message_loop_; |
211 base::DictionaryValue* dictionary_value_result_; | 211 base::DictionaryValue* dictionary_value_result_; |
212 }; | 212 }; |
213 | 213 |
214 TEST_F(NetworkConfigurationHandlerTest, GetProperties) { | 214 TEST_F(NetworkConfigurationHandlerTest, GetProperties) { |
215 std::string service_path = "/service/1"; | 215 std::string service_path = "/service/1"; |
216 std::string expected_json = "{\n \"SSID\": \"MyNetwork\"\n}\n"; | 216 std::string expected_json = "{\n \"SSID\": \"MyNetwork\"\n}\n"; |
217 std::string networkName = "MyNetwork"; | 217 std::string networkName = "MyNetwork"; |
218 std::string key = "SSID"; | 218 std::string key = "SSID"; |
219 scoped_ptr<base::StringValue> networkNameValue( | 219 scoped_ptr<base::StringValue> networkNameValue( |
220 base::Value::CreateStringValue(networkName)); | 220 new base::StringValue(networkName)); |
221 | 221 |
222 base::DictionaryValue value; | 222 base::DictionaryValue value; |
223 value.Set(key, base::Value::CreateStringValue(networkName)); | 223 value.Set(key, new base::StringValue(networkName)); |
224 dictionary_value_result_ = &value; | 224 dictionary_value_result_ = &value; |
225 EXPECT_CALL(*mock_service_client_, | 225 EXPECT_CALL(*mock_service_client_, |
226 SetProperty(dbus::ObjectPath(service_path), key, | 226 SetProperty(dbus::ObjectPath(service_path), key, |
227 IsEqualTo(networkNameValue.get()), _, _)).Times(1); | 227 IsEqualTo(networkNameValue.get()), _, _)).Times(1); |
228 mock_service_client_->SetProperty(dbus::ObjectPath(service_path), | 228 mock_service_client_->SetProperty(dbus::ObjectPath(service_path), |
229 key, | 229 key, |
230 *networkNameValue, | 230 *networkNameValue, |
231 base::Bind(&base::DoNothing), | 231 base::Bind(&base::DoNothing), |
232 base::Bind(&DBusErrorCallback)); | 232 base::Bind(&DBusErrorCallback)); |
233 message_loop_.RunUntilIdle(); | 233 message_loop_.RunUntilIdle(); |
(...skipping 10 matching lines...) Expand all Loading... |
244 expected_json), | 244 expected_json), |
245 base::Bind(&ErrorCallback, false, service_path)); | 245 base::Bind(&ErrorCallback, false, service_path)); |
246 message_loop_.RunUntilIdle(); | 246 message_loop_.RunUntilIdle(); |
247 } | 247 } |
248 | 248 |
249 TEST_F(NetworkConfigurationHandlerTest, SetProperties) { | 249 TEST_F(NetworkConfigurationHandlerTest, SetProperties) { |
250 std::string service_path = "/service/1"; | 250 std::string service_path = "/service/1"; |
251 std::string networkName = "MyNetwork"; | 251 std::string networkName = "MyNetwork"; |
252 std::string key = "SSID"; | 252 std::string key = "SSID"; |
253 scoped_ptr<base::StringValue> networkNameValue( | 253 scoped_ptr<base::StringValue> networkNameValue( |
254 base::Value::CreateStringValue(networkName)); | 254 new base::StringValue(networkName)); |
255 | 255 |
256 base::DictionaryValue value; | 256 base::DictionaryValue value; |
257 value.Set(key, base::Value::CreateStringValue(networkName)); | 257 value.Set(key, new base::StringValue(networkName)); |
258 dictionary_value_result_ = &value; | 258 dictionary_value_result_ = &value; |
259 EXPECT_CALL(*mock_service_client_, | 259 EXPECT_CALL(*mock_service_client_, |
260 SetProperties(_, _, _, _)).WillOnce( | 260 SetProperties(_, _, _, _)).WillOnce( |
261 Invoke(this, | 261 Invoke(this, |
262 &NetworkConfigurationHandlerTest::OnSetProperties)); | 262 &NetworkConfigurationHandlerTest::OnSetProperties)); |
263 network_configuration_handler_->SetProperties( | 263 network_configuration_handler_->SetProperties( |
264 service_path, | 264 service_path, |
265 value, | 265 value, |
266 base::Bind(&base::DoNothing), | 266 base::Bind(&base::DoNothing), |
267 base::Bind(&ErrorCallback, false, service_path)); | 267 base::Bind(&ErrorCallback, false, service_path)); |
268 message_loop_.RunUntilIdle(); | 268 message_loop_.RunUntilIdle(); |
269 } | 269 } |
270 | 270 |
271 TEST_F(NetworkConfigurationHandlerTest, ClearProperties) { | 271 TEST_F(NetworkConfigurationHandlerTest, ClearProperties) { |
272 std::string service_path = "/service/1"; | 272 std::string service_path = "/service/1"; |
273 std::string networkName = "MyNetwork"; | 273 std::string networkName = "MyNetwork"; |
274 std::string key = "SSID"; | 274 std::string key = "SSID"; |
275 scoped_ptr<base::StringValue> networkNameValue( | 275 scoped_ptr<base::StringValue> networkNameValue( |
276 base::Value::CreateStringValue(networkName)); | 276 new base::StringValue(networkName)); |
277 | 277 |
278 // First set up a value to clear. | 278 // First set up a value to clear. |
279 base::DictionaryValue value; | 279 base::DictionaryValue value; |
280 value.Set(key, base::Value::CreateStringValue(networkName)); | 280 value.Set(key, new base::StringValue(networkName)); |
281 dictionary_value_result_ = &value; | 281 dictionary_value_result_ = &value; |
282 EXPECT_CALL(*mock_service_client_, | 282 EXPECT_CALL(*mock_service_client_, |
283 SetProperties(_, _, _, _)).WillOnce( | 283 SetProperties(_, _, _, _)).WillOnce( |
284 Invoke(this, | 284 Invoke(this, |
285 &NetworkConfigurationHandlerTest::OnSetProperties)); | 285 &NetworkConfigurationHandlerTest::OnSetProperties)); |
286 network_configuration_handler_->SetProperties( | 286 network_configuration_handler_->SetProperties( |
287 service_path, | 287 service_path, |
288 value, | 288 value, |
289 base::Bind(&base::DoNothing), | 289 base::Bind(&base::DoNothing), |
290 base::Bind(&ErrorCallback, false, service_path)); | 290 base::Bind(&ErrorCallback, false, service_path)); |
(...skipping 12 matching lines...) Expand all Loading... |
303 base::Bind(&base::DoNothing), | 303 base::Bind(&base::DoNothing), |
304 base::Bind(&ErrorCallback, false, service_path)); | 304 base::Bind(&ErrorCallback, false, service_path)); |
305 message_loop_.RunUntilIdle(); | 305 message_loop_.RunUntilIdle(); |
306 } | 306 } |
307 | 307 |
308 TEST_F(NetworkConfigurationHandlerTest, ClearPropertiesError) { | 308 TEST_F(NetworkConfigurationHandlerTest, ClearPropertiesError) { |
309 std::string service_path = "/service/1"; | 309 std::string service_path = "/service/1"; |
310 std::string networkName = "MyNetwork"; | 310 std::string networkName = "MyNetwork"; |
311 std::string key = "SSID"; | 311 std::string key = "SSID"; |
312 scoped_ptr<base::StringValue> networkNameValue( | 312 scoped_ptr<base::StringValue> networkNameValue( |
313 base::Value::CreateStringValue(networkName)); | 313 new base::StringValue(networkName)); |
314 | 314 |
315 // First set up a value to clear. | 315 // First set up a value to clear. |
316 base::DictionaryValue value; | 316 base::DictionaryValue value; |
317 value.Set(key, base::Value::CreateStringValue(networkName)); | 317 value.Set(key, new base::StringValue(networkName)); |
318 dictionary_value_result_ = &value; | 318 dictionary_value_result_ = &value; |
319 EXPECT_CALL(*mock_service_client_, | 319 EXPECT_CALL(*mock_service_client_, |
320 SetProperties(_, _, _, _)).WillOnce( | 320 SetProperties(_, _, _, _)).WillOnce( |
321 Invoke(this, | 321 Invoke(this, |
322 &NetworkConfigurationHandlerTest::OnSetProperties)); | 322 &NetworkConfigurationHandlerTest::OnSetProperties)); |
323 network_configuration_handler_->SetProperties( | 323 network_configuration_handler_->SetProperties( |
324 service_path, | 324 service_path, |
325 value, | 325 value, |
326 base::Bind(&base::DoNothing), | 326 base::Bind(&base::DoNothing), |
327 base::Bind(&ErrorCallback, false, service_path)); | 327 base::Bind(&ErrorCallback, false, service_path)); |
(...skipping 16 matching lines...) Expand all Loading... |
344 } | 344 } |
345 | 345 |
346 TEST_F(NetworkConfigurationHandlerTest, CreateConfiguration) { | 346 TEST_F(NetworkConfigurationHandlerTest, CreateConfiguration) { |
347 std::string networkName = "MyNetwork"; | 347 std::string networkName = "MyNetwork"; |
348 std::string key = "SSID"; | 348 std::string key = "SSID"; |
349 std::string type = "wifi"; | 349 std::string type = "wifi"; |
350 std::string profile = "profile path"; | 350 std::string profile = "profile path"; |
351 base::DictionaryValue value; | 351 base::DictionaryValue value; |
352 shill_property_util::SetSSID(networkName, &value); | 352 shill_property_util::SetSSID(networkName, &value); |
353 value.SetWithoutPathExpansion(shill::kTypeProperty, | 353 value.SetWithoutPathExpansion(shill::kTypeProperty, |
354 base::Value::CreateStringValue(type)); | 354 new base::StringValue(type)); |
355 value.SetWithoutPathExpansion(shill::kProfileProperty, | 355 value.SetWithoutPathExpansion(shill::kProfileProperty, |
356 base::Value::CreateStringValue(profile)); | 356 new base::StringValue(profile)); |
357 | 357 |
358 EXPECT_CALL(*mock_manager_client_, | 358 EXPECT_CALL(*mock_manager_client_, |
359 ConfigureServiceForProfile(dbus::ObjectPath(profile), _, _, _)) | 359 ConfigureServiceForProfile(dbus::ObjectPath(profile), _, _, _)) |
360 .WillOnce( | 360 .WillOnce( |
361 Invoke(this, &NetworkConfigurationHandlerTest::OnConfigureService)); | 361 Invoke(this, &NetworkConfigurationHandlerTest::OnConfigureService)); |
362 network_configuration_handler_->CreateConfiguration( | 362 network_configuration_handler_->CreateConfiguration( |
363 value, | 363 value, |
364 base::Bind(&StringResultCallback, std::string("/service/2")), | 364 base::Bind(&StringResultCallback, std::string("/service/2")), |
365 base::Bind(&ErrorCallback, false, std::string())); | 365 base::Bind(&ErrorCallback, false, std::string())); |
366 message_loop_.RunUntilIdle(); | 366 message_loop_.RunUntilIdle(); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 create_service_path_, shill::kGuidProperty, &guid)); | 620 create_service_path_, shill::kGuidProperty, &guid)); |
621 EXPECT_EQ(service_path, guid); | 621 EXPECT_EQ(service_path, guid); |
622 | 622 |
623 std::string actual_profile; | 623 std::string actual_profile; |
624 EXPECT_TRUE(GetServiceStringProperty( | 624 EXPECT_TRUE(GetServiceStringProperty( |
625 create_service_path_, shill::kProfileProperty, &actual_profile)); | 625 create_service_path_, shill::kProfileProperty, &actual_profile)); |
626 EXPECT_EQ(NetworkProfileHandler::GetSharedProfilePath(), actual_profile); | 626 EXPECT_EQ(NetworkProfileHandler::GetSharedProfilePath(), actual_profile); |
627 } | 627 } |
628 | 628 |
629 } // namespace chromeos | 629 } // namespace chromeos |
OLD | NEW |