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 "chrome/browser/chromeos/policy/device_status_collector.h" | 5 #include "chrome/browser/chromeos/policy/device_status_collector.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1388 chromeos::NetworkHandler::Initialize(); | 1388 chromeos::NetworkHandler::Initialize(); |
1389 chromeos::ShillDeviceClient::TestInterface* test_device_client = | 1389 chromeos::ShillDeviceClient::TestInterface* test_device_client = |
1390 chromeos::DBusThreadManager::Get()->GetShillDeviceClient()-> | 1390 chromeos::DBusThreadManager::Get()->GetShillDeviceClient()-> |
1391 GetTestInterface(); | 1391 GetTestInterface(); |
1392 test_device_client->ClearDevices(); | 1392 test_device_client->ClearDevices(); |
1393 for (size_t i = 0; i < arraysize(kFakeDevices); ++i) { | 1393 for (size_t i = 0; i < arraysize(kFakeDevices); ++i) { |
1394 const FakeDeviceData& dev = kFakeDevices[i]; | 1394 const FakeDeviceData& dev = kFakeDevices[i]; |
1395 test_device_client->AddDevice(dev.device_path, dev.type, | 1395 test_device_client->AddDevice(dev.device_path, dev.type, |
1396 dev.object_path); | 1396 dev.object_path); |
1397 if (*dev.mac_address) { | 1397 if (*dev.mac_address) { |
1398 test_device_client->SetDeviceProperty( | 1398 test_device_client->SetDeviceProperty(dev.device_path, |
1399 dev.device_path, shill::kAddressProperty, | 1399 shill::kAddressProperty, |
1400 base::StringValue(dev.mac_address)); | 1400 base::Value(dev.mac_address)); |
1401 } | 1401 } |
1402 if (*dev.meid) { | 1402 if (*dev.meid) { |
1403 test_device_client->SetDeviceProperty( | 1403 test_device_client->SetDeviceProperty( |
1404 dev.device_path, shill::kMeidProperty, | 1404 dev.device_path, shill::kMeidProperty, base::Value(dev.meid)); |
1405 base::StringValue(dev.meid)); | |
1406 } | 1405 } |
1407 if (*dev.imei) { | 1406 if (*dev.imei) { |
1408 test_device_client->SetDeviceProperty( | 1407 test_device_client->SetDeviceProperty( |
1409 dev.device_path, shill::kImeiProperty, | 1408 dev.device_path, shill::kImeiProperty, base::Value(dev.imei)); |
1410 base::StringValue(dev.imei)); | |
1411 } | 1409 } |
1412 } | 1410 } |
1413 | 1411 |
1414 chromeos::ShillServiceClient::TestInterface* service_client = | 1412 chromeos::ShillServiceClient::TestInterface* service_client = |
1415 chromeos::DBusThreadManager::Get()->GetShillServiceClient()-> | 1413 chromeos::DBusThreadManager::Get()->GetShillServiceClient()-> |
1416 GetTestInterface(); | 1414 GetTestInterface(); |
1417 service_client->ClearServices(); | 1415 service_client->ClearServices(); |
1418 | 1416 |
1419 // Now add services for every fake network. | 1417 // Now add services for every fake network. |
1420 for (const FakeNetworkState& fake_network : kFakeNetworks) { | 1418 for (const FakeNetworkState& fake_network : kFakeNetworks) { |
1421 // Shill forces non-visible networks to report a disconnected state. | 1419 // Shill forces non-visible networks to report a disconnected state. |
1422 bool is_visible = | 1420 bool is_visible = |
1423 fake_network.connection_status != shill::kStateDisconnect; | 1421 fake_network.connection_status != shill::kStateDisconnect; |
1424 service_client->AddService( | 1422 service_client->AddService( |
1425 fake_network.name, /* service_path */ | 1423 fake_network.name, /* service_path */ |
1426 fake_network.name /* guid */, | 1424 fake_network.name /* guid */, |
1427 fake_network.name /* name */, | 1425 fake_network.name /* name */, |
1428 fake_network.type /* type */, | 1426 fake_network.type /* type */, |
1429 fake_network.connection_status, | 1427 fake_network.connection_status, |
1430 is_visible); | 1428 is_visible); |
1431 service_client->SetServiceProperty( | 1429 service_client->SetServiceProperty( |
1432 fake_network.name, shill::kSignalStrengthProperty, | 1430 fake_network.name, shill::kSignalStrengthProperty, |
1433 base::Value(fake_network.signal_strength)); | 1431 base::Value(fake_network.signal_strength)); |
1434 service_client->SetServiceProperty( | 1432 service_client->SetServiceProperty(fake_network.name, |
1435 fake_network.name, shill::kDeviceProperty, | 1433 shill::kDeviceProperty, |
1436 base::StringValue(fake_network.device_path)); | 1434 base::Value(fake_network.device_path)); |
1437 // Set the profile so this shows up as a configured network. | 1435 // Set the profile so this shows up as a configured network. |
1438 service_client->SetServiceProperty( | 1436 service_client->SetServiceProperty(fake_network.name, |
1439 fake_network.name, shill::kProfileProperty, | 1437 shill::kProfileProperty, |
1440 base::StringValue(fake_network.name)); | 1438 base::Value(fake_network.name)); |
1441 if (strlen(fake_network.address) > 0) { | 1439 if (strlen(fake_network.address) > 0) { |
1442 // Set the IP config. | 1440 // Set the IP config. |
1443 base::DictionaryValue ip_config_properties; | 1441 base::DictionaryValue ip_config_properties; |
1444 ip_config_properties.SetStringWithoutPathExpansion( | 1442 ip_config_properties.SetStringWithoutPathExpansion( |
1445 shill::kAddressProperty, fake_network.address); | 1443 shill::kAddressProperty, fake_network.address); |
1446 ip_config_properties.SetStringWithoutPathExpansion( | 1444 ip_config_properties.SetStringWithoutPathExpansion( |
1447 shill::kGatewayProperty, fake_network.gateway); | 1445 shill::kGatewayProperty, fake_network.gateway); |
1448 chromeos::ShillIPConfigClient::TestInterface* ip_config_test = | 1446 chromeos::ShillIPConfigClient::TestInterface* ip_config_test = |
1449 chromeos::DBusThreadManager::Get()->GetShillIPConfigClient()-> | 1447 chromeos::DBusThreadManager::Get()->GetShillIPConfigClient()-> |
1450 GetTestInterface(); | 1448 GetTestInterface(); |
1451 const std::string kIPConfigPath = "test_ip_config"; | 1449 const std::string kIPConfigPath = "test_ip_config"; |
1452 ip_config_test->AddIPConfig(kIPConfigPath, ip_config_properties); | 1450 ip_config_test->AddIPConfig(kIPConfigPath, ip_config_properties); |
1453 service_client->SetServiceProperty( | 1451 service_client->SetServiceProperty(fake_network.name, |
1454 fake_network.name, shill::kIPConfigProperty, | 1452 shill::kIPConfigProperty, |
1455 base::StringValue(kIPConfigPath)); | 1453 base::Value(kIPConfigPath)); |
1456 } | 1454 } |
1457 } | 1455 } |
1458 | 1456 |
1459 // Now add an unconfigured network - it should not show up in the | 1457 // Now add an unconfigured network - it should not show up in the |
1460 // reported list of networks because it doesn't have a profile specified. | 1458 // reported list of networks because it doesn't have a profile specified. |
1461 service_client->AddService( | 1459 service_client->AddService( |
1462 kUnconfiguredNetwork.name, /* service_path */ | 1460 kUnconfiguredNetwork.name, /* service_path */ |
1463 kUnconfiguredNetwork.name /* guid */, | 1461 kUnconfiguredNetwork.name /* guid */, |
1464 kUnconfiguredNetwork.name /* name */, | 1462 kUnconfiguredNetwork.name /* name */, |
1465 kUnconfiguredNetwork.type /* type */, | 1463 kUnconfiguredNetwork.type /* type */, |
1466 kUnconfiguredNetwork.connection_status, | 1464 kUnconfiguredNetwork.connection_status, |
1467 true /* visible */); | 1465 true /* visible */); |
1468 service_client->SetServiceProperty( | 1466 service_client->SetServiceProperty( |
1469 kUnconfiguredNetwork.name, shill::kSignalStrengthProperty, | 1467 kUnconfiguredNetwork.name, shill::kSignalStrengthProperty, |
1470 base::Value(kUnconfiguredNetwork.signal_strength)); | 1468 base::Value(kUnconfiguredNetwork.signal_strength)); |
1471 service_client->SetServiceProperty( | 1469 service_client->SetServiceProperty( |
1472 kUnconfiguredNetwork.name, shill::kDeviceProperty, | 1470 kUnconfiguredNetwork.name, shill::kDeviceProperty, |
1473 base::StringValue(kUnconfiguredNetwork.device_path)); | 1471 base::Value(kUnconfiguredNetwork.device_path)); |
1474 | 1472 |
1475 // Flush out pending state updates. | 1473 // Flush out pending state updates. |
1476 base::RunLoop().RunUntilIdle(); | 1474 base::RunLoop().RunUntilIdle(); |
1477 | 1475 |
1478 chromeos::NetworkStateHandler::NetworkStateList state_list; | 1476 chromeos::NetworkStateHandler::NetworkStateList state_list; |
1479 chromeos::NetworkStateHandler* network_state_handler = | 1477 chromeos::NetworkStateHandler* network_state_handler = |
1480 chromeos::NetworkHandler::Get()->network_state_handler(); | 1478 chromeos::NetworkHandler::Get()->network_state_handler(); |
1481 network_state_handler->GetNetworkListByType( | 1479 network_state_handler->GetNetworkListByType( |
1482 chromeos::NetworkTypePattern::Default(), | 1480 chromeos::NetworkTypePattern::Default(), |
1483 true, // configured_only | 1481 true, // configured_only |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1592 AccountId::FromUserEmail(kPublicAccountId)); | 1590 AccountId::FromUserEmail(kPublicAccountId)); |
1593 EXPECT_CALL(*user_manager_, IsLoggedInAsPublicAccount()) | 1591 EXPECT_CALL(*user_manager_, IsLoggedInAsPublicAccount()) |
1594 .WillRepeatedly(Return(true)); | 1592 .WillRepeatedly(Return(true)); |
1595 | 1593 |
1596 settings_helper_.SetBoolean(chromeos::kReportDeviceNetworkInterfaces, true); | 1594 settings_helper_.SetBoolean(chromeos::kReportDeviceNetworkInterfaces, true); |
1597 GetStatus(); | 1595 GetStatus(); |
1598 VerifyNetworkReporting(); | 1596 VerifyNetworkReporting(); |
1599 } | 1597 } |
1600 | 1598 |
1601 } // namespace policy | 1599 } // namespace policy |
OLD | NEW |