0

DeviceStatusCollectorTest: Remove log error spam

Bug: 550539
Change-Id: Ie9d2a8f0ef8d9558546269f638ca319d6edc0a2b
Reviewed-on: https://chromium-review.googlesource.com/655617
Commit-Queue: Steven Bennetts <stevenjb@chromium.org>
Reviewed-by: Maksim Ivanov <emaxx@chromium.org>
Cr-Commit-Position: refs/heads/master@{#502031}
This commit is contained in:
Steven Bennetts
2017-09-14 20:19:53 +00:00
committed by Commit Bot
parent 5fa1cb3745
commit e5a86d7009
2 changed files with 50 additions and 42 deletions

@ -44,6 +44,7 @@
#include "chromeos/dbus/fake_update_engine_client.h"
#include "chromeos/dbus/shill_device_client.h"
#include "chromeos/dbus/shill_ipconfig_client.h"
#include "chromeos/dbus/shill_profile_client.h"
#include "chromeos/dbus/shill_service_client.h"
#include "chromeos/disks/disk_mount_manager.h"
#include "chromeos/disks/mock_disk_mount_manager.h"
@ -88,6 +89,8 @@ const char kArcStatus[] = "{\"applications\":[ { "
"\"permissions\": [\"android.permission.INTERNET\"] }],"
"\"userEmail\":\"xxx@google.com\"}";
const char kDroidGuardInfo[] = "{\"droid_guard_info\":42}";
const std::string kShillFakeProfilePath = "/profile/user1/shill";
const std::string kShillFakeUserhash = "user1";
class TestingDeviceStatusCollector : public policy::DeviceStatusCollector {
public:
@ -1430,46 +1433,55 @@ class DeviceStatusCollectorNetworkInterfacesTest
void SetUp() override {
chromeos::DBusThreadManager::Initialize();
chromeos::NetworkHandler::Initialize();
chromeos::ShillDeviceClient::TestInterface* test_device_client =
chromeos::DBusThreadManager::Get()->GetShillDeviceClient()->
GetTestInterface();
test_device_client->ClearDevices();
for (size_t i = 0; i < arraysize(kFakeDevices); ++i) {
const FakeDeviceData& dev = kFakeDevices[i];
test_device_client->AddDevice(dev.device_path, dev.type,
dev.object_path);
base::RunLoop().RunUntilIdle();
chromeos::ShillDeviceClient::TestInterface* device_client =
chromeos::DBusThreadManager::Get()
->GetShillDeviceClient()
->GetTestInterface();
chromeos::ShillServiceClient::TestInterface* service_client =
chromeos::DBusThreadManager::Get()
->GetShillServiceClient()
->GetTestInterface();
chromeos::ShillIPConfigClient::TestInterface* ip_config_client =
chromeos::DBusThreadManager::Get()
->GetShillIPConfigClient()
->GetTestInterface();
device_client->ClearDevices();
service_client->ClearServices();
for (const FakeDeviceData& dev : kFakeDevices) {
device_client->AddDevice(dev.device_path, dev.type, dev.object_path);
if (*dev.mac_address) {
test_device_client->SetDeviceProperty(dev.device_path,
shill::kAddressProperty,
base::Value(dev.mac_address));
device_client->SetDeviceProperty(dev.device_path,
shill::kAddressProperty,
base::Value(dev.mac_address));
}
if (*dev.meid) {
test_device_client->SetDeviceProperty(
dev.device_path, shill::kMeidProperty, base::Value(dev.meid));
device_client->SetDeviceProperty(dev.device_path, shill::kMeidProperty,
base::Value(dev.meid));
}
if (*dev.imei) {
test_device_client->SetDeviceProperty(
dev.device_path, shill::kImeiProperty, base::Value(dev.imei));
device_client->SetDeviceProperty(dev.device_path, shill::kImeiProperty,
base::Value(dev.imei));
}
}
chromeos::ShillServiceClient::TestInterface* service_client =
chromeos::DBusThreadManager::Get()->GetShillServiceClient()->
GetTestInterface();
service_client->ClearServices();
chromeos::DBusThreadManager::Get()
->GetShillProfileClient()
->GetTestInterface()
->AddProfile(kShillFakeProfilePath, kShillFakeUserhash);
// Now add services for every fake network.
for (const FakeNetworkState& fake_network : kFakeNetworks) {
// Shill forces non-visible networks to report a disconnected state.
bool is_visible =
fake_network.connection_status != shill::kStateDisconnect;
service_client->AddService(
fake_network.name, /* service_path */
fake_network.name /* guid */,
fake_network.name /* name */,
fake_network.type /* type */,
fake_network.connection_status,
is_visible);
service_client->AddService(fake_network.name /* service_path */,
fake_network.name /* guid */,
fake_network.name, fake_network.type,
fake_network.connection_status, is_visible);
service_client->SetServiceProperty(
fake_network.name, shill::kSignalStrengthProperty,
base::Value(fake_network.signal_strength));
@ -1479,7 +1491,7 @@ class DeviceStatusCollectorNetworkInterfacesTest
// Set the profile so this shows up as a configured network.
service_client->SetServiceProperty(fake_network.name,
shill::kProfileProperty,
base::Value(fake_network.name));
base::Value(kShillFakeProfilePath));
if (strlen(fake_network.address) > 0) {
// Set the IP config.
base::DictionaryValue ip_config_properties;
@ -1487,11 +1499,8 @@ class DeviceStatusCollectorNetworkInterfacesTest
base::Value(fake_network.address));
ip_config_properties.SetKey(shill::kGatewayProperty,
base::Value(fake_network.gateway));
chromeos::ShillIPConfigClient::TestInterface* ip_config_test =
chromeos::DBusThreadManager::Get()->GetShillIPConfigClient()->
GetTestInterface();
const std::string kIPConfigPath = "test_ip_config";
ip_config_test->AddIPConfig(kIPConfigPath, ip_config_properties);
ip_config_client->AddIPConfig(kIPConfigPath, ip_config_properties);
service_client->SetServiceProperty(fake_network.name,
shill::kIPConfigProperty,
base::Value(kIPConfigPath));
@ -1500,13 +1509,12 @@ class DeviceStatusCollectorNetworkInterfacesTest
// Now add an unconfigured network - it should not show up in the
// reported list of networks because it doesn't have a profile specified.
service_client->AddService(
kUnconfiguredNetwork.name, /* service_path */
kUnconfiguredNetwork.name /* guid */,
kUnconfiguredNetwork.name /* name */,
kUnconfiguredNetwork.type /* type */,
kUnconfiguredNetwork.connection_status,
true /* visible */);
service_client->AddService(kUnconfiguredNetwork.name, /* service_path */
kUnconfiguredNetwork.name /* guid */,
kUnconfiguredNetwork.name /* name */,
kUnconfiguredNetwork.type /* type */,
kUnconfiguredNetwork.connection_status,
true /* visible */);
service_client->SetServiceProperty(
kUnconfiguredNetwork.name, shill::kSignalStrengthProperty,
base::Value(kUnconfiguredNetwork.signal_strength));
@ -1536,8 +1544,7 @@ class DeviceStatusCollectorNetworkInterfacesTest
void VerifyNetworkReporting() {
int count = 0;
for (size_t i = 0; i < arraysize(kFakeDevices); ++i) {
const FakeDeviceData& dev = kFakeDevices[i];
for (const FakeDeviceData& dev : kFakeDevices) {
if (dev.expected_type == -1)
continue;
@ -1560,7 +1567,8 @@ class DeviceStatusCollectorNetworkInterfacesTest
}
}
EXPECT_TRUE(found_match) << "No matching interface for fake device " << i;
EXPECT_TRUE(found_match)
<< "No matching interface for fake device " << dev.device_path;
count++;
}

@ -634,7 +634,7 @@ void FakeShillDeviceClient::NotifyObserversPropertyChanged(
base::DictionaryValue* dict = NULL;
std::string path = device_path.value();
if (!stub_devices_.GetDictionaryWithoutPathExpansion(path, &dict)) {
LOG(ERROR) << "Notify for unknown service: " << path;
LOG(ERROR) << "Notify for unknown device: " << path;
return;
}
base::Value* value = NULL;