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

Side by Side Diff: chromeos/dbus/fake_shill_service_client.cc

Issue 330833003: Rely on Service.Visible instead of Manager.Services (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix stubs for tests Created 6 years, 6 months 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
« no previous file with comments | « chromeos/dbus/fake_shill_service_client.h ('k') | chromeos/dbus/shill_manager_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chromeos/dbus/fake_shill_service_client.h" 5 #include "chromeos/dbus/fake_shill_service_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 ShillServiceClient::TestInterface* FakeShillServiceClient::GetTestInterface() { 301 ShillServiceClient::TestInterface* FakeShillServiceClient::GetTestInterface() {
302 return this; 302 return this;
303 } 303 }
304 304
305 // ShillServiceClient::TestInterface overrides. 305 // ShillServiceClient::TestInterface overrides.
306 306
307 void FakeShillServiceClient::AddService(const std::string& service_path, 307 void FakeShillServiceClient::AddService(const std::string& service_path,
308 const std::string& name, 308 const std::string& name,
309 const std::string& type, 309 const std::string& type,
310 const std::string& state, 310 const std::string& state,
311 bool add_to_visible_list) { 311 bool visible) {
312 AddServiceWithIPConfig(service_path, "" /* guid */, name, 312 AddServiceWithIPConfig(service_path, "" /* guid */, name,
313 type, state, "" /* ipconfig_path */, 313 type, state, "" /* ipconfig_path */,
314 add_to_visible_list); 314 visible);
315 } 315 }
316 316
317 void FakeShillServiceClient::AddServiceWithIPConfig( 317 void FakeShillServiceClient::AddServiceWithIPConfig(
318 const std::string& service_path, 318 const std::string& service_path,
319 const std::string& guid, 319 const std::string& guid,
320 const std::string& name, 320 const std::string& name,
321 const std::string& type, 321 const std::string& type,
322 const std::string& state, 322 const std::string& state,
323 const std::string& ipconfig_path, 323 const std::string& ipconfig_path,
324 bool add_to_visible_list) { 324 bool visible) {
325 std::string device_path = 325 base::DictionaryValue* properties = SetServiceProperties(
326 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface()-> 326 service_path, guid, name, type, state, visible);
327 GetDevicePathForType(type);
328 327
328 std::string profile_path;
329 if (properties->GetStringWithoutPathExpansion(shill::kProfileProperty,
330 &profile_path) &&
331 !profile_path.empty()) {
332 DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface()->
333 UpdateService(profile_path, service_path);
334 }
335
336 if (!ipconfig_path.empty()) {
337 properties->SetWithoutPathExpansion(
338 shill::kIPConfigProperty,
339 new base::StringValue(ipconfig_path));
340 }
341
342 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()->
343 AddManagerService(service_path, true);
344 }
345
346
347 base::DictionaryValue* FakeShillServiceClient::SetServiceProperties(
348 const std::string& service_path,
349 const std::string& guid,
350 const std::string& name,
351 const std::string& type,
352 const std::string& state,
353 bool visible) {
329 base::DictionaryValue* properties = 354 base::DictionaryValue* properties =
330 GetModifiableServiceProperties(service_path, true); 355 GetModifiableServiceProperties(service_path, true);
331 connect_behavior_.erase(service_path); 356 connect_behavior_.erase(service_path);
332 357
333 std::string profile_path; 358 std::string profile_path;
334 base::DictionaryValue profile_properties; 359 base::DictionaryValue profile_properties;
335 if (DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface()-> 360 if (DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface()->
336 GetService(service_path, &profile_path, &profile_properties)) { 361 GetService(service_path, &profile_path, &profile_properties)) {
337 properties->SetWithoutPathExpansion( 362 properties->SetWithoutPathExpansion(
338 shill::kProfileProperty, 363 shill::kProfileProperty,
339 new base::StringValue(profile_path)); 364 new base::StringValue(profile_path));
340 } 365 }
341 366
342 // If |guid| is provided, set Service.GUID to that. Otherwise if a GUID is 367 // If |guid| is provided, set Service.GUID to that. Otherwise if a GUID is
343 // stored in a profile entry, use that. Otherwise leave it blank. Shill does 368 // stored in a profile entry, use that. Otherwise leave it blank. Shill does
344 // not enforce a valid guid, we do that at the NetworkStateHandler layer. 369 // not enforce a valid guid, we do that at the NetworkStateHandler layer.
345 std::string guid_to_set = guid; 370 std::string guid_to_set = guid;
346 if (guid_to_set.empty()) { 371 if (guid_to_set.empty()) {
347 profile_properties.GetStringWithoutPathExpansion( 372 profile_properties.GetStringWithoutPathExpansion(
348 shill::kGuidProperty, &guid_to_set); 373 shill::kGuidProperty, &guid_to_set);
349 } 374 }
350 if (!guid_to_set.empty()) { 375 if (!guid_to_set.empty()) {
351 properties->SetWithoutPathExpansion(shill::kGuidProperty, 376 properties->SetWithoutPathExpansion(shill::kGuidProperty,
352 new base::StringValue(guid_to_set)); 377 new base::StringValue(guid_to_set));
353 } 378 }
354 shill_property_util::SetSSID(name, properties); 379 shill_property_util::SetSSID(name, properties);
355 properties->SetWithoutPathExpansion( 380 properties->SetWithoutPathExpansion(
356 shill::kNameProperty, 381 shill::kNameProperty,
357 new base::StringValue(name)); 382 new base::StringValue(name));
383 std::string device_path =
384 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface()->
385 GetDevicePathForType(type);
358 properties->SetWithoutPathExpansion( 386 properties->SetWithoutPathExpansion(
359 shill::kDeviceProperty, 387 shill::kDeviceProperty,
360 new base::StringValue(device_path)); 388 new base::StringValue(device_path));
361 properties->SetWithoutPathExpansion( 389 properties->SetWithoutPathExpansion(
362 shill::kTypeProperty, 390 shill::kTypeProperty,
363 new base::StringValue(type)); 391 new base::StringValue(type));
364 properties->SetWithoutPathExpansion( 392 properties->SetWithoutPathExpansion(
365 shill::kStateProperty, 393 shill::kStateProperty,
366 new base::StringValue(state)); 394 new base::StringValue(state));
367 properties->SetWithoutPathExpansion( 395 properties->SetWithoutPathExpansion(
368 shill::kVisibleProperty, 396 shill::kVisibleProperty,
369 new base::FundamentalValue(add_to_visible_list)); 397 new base::FundamentalValue(visible));
370 if (!ipconfig_path.empty()) {
371 properties->SetWithoutPathExpansion(
372 shill::kIPConfigProperty,
373 new base::StringValue(ipconfig_path));
374 }
375 if (type == shill::kTypeWifi) { 398 if (type == shill::kTypeWifi) {
376 properties->SetWithoutPathExpansion( 399 properties->SetWithoutPathExpansion(
377 shill::kSecurityProperty, 400 shill::kSecurityProperty,
378 new base::StringValue(shill::kSecurityNone)); 401 new base::StringValue(shill::kSecurityNone));
379 } 402 }
380 403 return properties;
381 if (!profile_path.empty()) {
382 DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface()->
383 UpdateService(profile_path, service_path);
384 }
385
386 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()->
387 AddManagerService(service_path);
388 } 404 }
389 405
390 void FakeShillServiceClient::RemoveService(const std::string& service_path) { 406 void FakeShillServiceClient::RemoveService(const std::string& service_path) {
391 stub_services_.RemoveWithoutPathExpansion(service_path, NULL); 407 stub_services_.RemoveWithoutPathExpansion(service_path, NULL);
392 connect_behavior_.erase(service_path); 408 connect_behavior_.erase(service_path);
393 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()-> 409 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()->
394 RemoveManagerService(service_path); 410 RemoveManagerService(service_path);
395 } 411 }
396 412
397 bool FakeShillServiceClient::SetServiceProperty(const std::string& service_path, 413 bool FakeShillServiceClient::SetServiceProperty(const std::string& service_path,
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 base::StringValue(shill::kErrorBadPassphrase))); 625 base::StringValue(shill::kErrorBadPassphrase)));
610 } else { 626 } else {
611 // Set Online. 627 // Set Online.
612 SetServiceProperty(service_path, 628 SetServiceProperty(service_path,
613 shill::kStateProperty, 629 shill::kStateProperty,
614 base::StringValue(shill::kStateOnline)); 630 base::StringValue(shill::kStateOnline));
615 } 631 }
616 } 632 }
617 633
618 } // namespace chromeos 634 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/fake_shill_service_client.h ('k') | chromeos/dbus/shill_manager_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698