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 21 matching lines...) Expand all Loading... |
32 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 32 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
33 #include "chrome/browser/chromeos/policy/device_local_account.h" | 33 #include "chrome/browser/chromeos/policy/device_local_account.h" |
34 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 34 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
35 #include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h" | 35 #include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h" |
36 #include "chrome/browser/chromeos/settings/stub_install_attributes.h" | 36 #include "chrome/browser/chromeos/settings/stub_install_attributes.h" |
37 #include "chrome/common/chrome_paths.h" | 37 #include "chrome/common/chrome_paths.h" |
38 #include "chrome/common/pref_names.h" | 38 #include "chrome/common/pref_names.h" |
39 #include "chrome/test/base/chrome_unit_test_suite.h" | 39 #include "chrome/test/base/chrome_unit_test_suite.h" |
40 #include "chrome/test/base/testing_browser_process.h" | 40 #include "chrome/test/base/testing_browser_process.h" |
41 #include "chrome/test/base/testing_profile_manager.h" | 41 #include "chrome/test/base/testing_profile_manager.h" |
| 42 #include "chromeos/audio/cras_audio_handler.h" |
42 #include "chromeos/dbus/cros_disks_client.h" | 43 #include "chromeos/dbus/cros_disks_client.h" |
43 #include "chromeos/dbus/dbus_thread_manager.h" | 44 #include "chromeos/dbus/dbus_thread_manager.h" |
44 #include "chromeos/dbus/fake_update_engine_client.h" | 45 #include "chromeos/dbus/fake_update_engine_client.h" |
45 #include "chromeos/dbus/shill_device_client.h" | 46 #include "chromeos/dbus/shill_device_client.h" |
46 #include "chromeos/dbus/shill_ipconfig_client.h" | 47 #include "chromeos/dbus/shill_ipconfig_client.h" |
47 #include "chromeos/dbus/shill_service_client.h" | 48 #include "chromeos/dbus/shill_service_client.h" |
48 #include "chromeos/disks/disk_mount_manager.h" | 49 #include "chromeos/disks/disk_mount_manager.h" |
49 #include "chromeos/disks/mock_disk_mount_manager.h" | 50 #include "chromeos/disks/mock_disk_mount_manager.h" |
50 #include "chromeos/network/network_handler.h" | 51 #include "chromeos/network/network_handler.h" |
51 #include "chromeos/network/network_state.h" | 52 #include "chromeos/network/network_state.h" |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 | 339 |
339 // Set up a fake local state for KioskAppManager. | 340 // Set up a fake local state for KioskAppManager. |
340 TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_); | 341 TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_); |
341 chromeos::KioskAppManager::RegisterPrefs(local_state_.registry()); | 342 chromeos::KioskAppManager::RegisterPrefs(local_state_.registry()); |
342 | 343 |
343 // Use FakeUpdateEngineClient. | 344 // Use FakeUpdateEngineClient. |
344 std::unique_ptr<chromeos::DBusThreadManagerSetter> dbus_setter = | 345 std::unique_ptr<chromeos::DBusThreadManagerSetter> dbus_setter = |
345 chromeos::DBusThreadManager::GetSetterForTesting(); | 346 chromeos::DBusThreadManager::GetSetterForTesting(); |
346 dbus_setter->SetUpdateEngineClient( | 347 dbus_setter->SetUpdateEngineClient( |
347 base::WrapUnique<chromeos::UpdateEngineClient>(update_engine_client_)); | 348 base::WrapUnique<chromeos::UpdateEngineClient>(update_engine_client_)); |
| 349 |
| 350 chromeos::CrasAudioHandler::InitializeForTesting(); |
348 } | 351 } |
349 | 352 |
350 void AddMountPoint(const std::string& mount_point) { | 353 void AddMountPoint(const std::string& mount_point) { |
351 mount_point_map_.insert(DiskMountManager::MountPointMap::value_type( | 354 mount_point_map_.insert(DiskMountManager::MountPointMap::value_type( |
352 mount_point, | 355 mount_point, |
353 DiskMountManager::MountPointInfo( | 356 DiskMountManager::MountPointInfo( |
354 mount_point, mount_point, chromeos::MOUNT_TYPE_DEVICE, | 357 mount_point, mount_point, chromeos::MOUNT_TYPE_DEVICE, |
355 chromeos::disks::MOUNT_CONDITION_NONE))); | 358 chromeos::disks::MOUNT_CONDITION_NONE))); |
356 } | 359 } |
357 | 360 |
358 ~DeviceStatusCollectorTest() override { | 361 ~DeviceStatusCollectorTest() override { |
| 362 chromeos::CrasAudioHandler::Shutdown(); |
359 chromeos::KioskAppManager::Shutdown(); | 363 chromeos::KioskAppManager::Shutdown(); |
360 TestingBrowserProcess::GetGlobal()->SetLocalState(nullptr); | 364 TestingBrowserProcess::GetGlobal()->SetLocalState(nullptr); |
361 | 365 |
362 // Finish pending tasks. | 366 // Finish pending tasks. |
363 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 367 content::BrowserThread::GetBlockingPool()->FlushForTesting(); |
364 base::RunLoop().RunUntilIdle(); | 368 base::RunLoop().RunUntilIdle(); |
365 storage::ExternalMountPoints::GetSystemInstance()->RevokeAllFileSystems(); | 369 storage::ExternalMountPoints::GetSystemInstance()->RevokeAllFileSystems(); |
366 DiskMountManager::Shutdown(); | 370 DiskMountManager::Shutdown(); |
367 } | 371 } |
368 | 372 |
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1288 | 1292 |
1289 GetStatus(); | 1293 GetStatus(); |
1290 ASSERT_TRUE(device_status_.has_running_kiosk_app()); | 1294 ASSERT_TRUE(device_status_.has_running_kiosk_app()); |
1291 const em::AppStatus app = device_status_.running_kiosk_app(); | 1295 const em::AppStatus app = device_status_.running_kiosk_app(); |
1292 EXPECT_EQ(kKioskAppId, app.app_id()); | 1296 EXPECT_EQ(kKioskAppId, app.app_id()); |
1293 EXPECT_EQ("1235", app.required_platform_version()); | 1297 EXPECT_EQ("1235", app.required_platform_version()); |
1294 EXPECT_FALSE(app.has_status()); | 1298 EXPECT_FALSE(app.has_status()); |
1295 EXPECT_FALSE(app.has_error()); | 1299 EXPECT_FALSE(app.has_error()); |
1296 } | 1300 } |
1297 | 1301 |
| 1302 TEST_F(DeviceStatusCollectorTest, TestSoundVolume) { |
| 1303 // Expect the sound volume to be reported by default (default sound volume |
| 1304 // used in testing is 75). |
| 1305 GetStatus(); |
| 1306 EXPECT_EQ(75, device_status_.sound_volume()); |
| 1307 |
| 1308 // When the pref to collect this data is not enabled, expect that the field |
| 1309 // isn't present in the protobuf. |
| 1310 settings_helper_.SetBoolean(chromeos::kReportDeviceHardwareStatus, false); |
| 1311 GetStatus(); |
| 1312 EXPECT_FALSE(device_status_.has_sound_volume()); |
| 1313 |
| 1314 // Try setting a custom volume value and check that it matches. |
| 1315 const int kCustomVolume = 42; |
| 1316 settings_helper_.SetBoolean(chromeos::kReportDeviceHardwareStatus, true); |
| 1317 chromeos::CrasAudioHandler::Get()->SetOutputVolumePercent(kCustomVolume); |
| 1318 GetStatus(); |
| 1319 EXPECT_EQ(kCustomVolume, device_status_.sound_volume()); |
| 1320 } |
| 1321 |
1298 // Fake device state. | 1322 // Fake device state. |
1299 struct FakeDeviceData { | 1323 struct FakeDeviceData { |
1300 const char* device_path; | 1324 const char* device_path; |
1301 const char* type; | 1325 const char* type; |
1302 const char* object_path; | 1326 const char* object_path; |
1303 const char* mac_address; | 1327 const char* mac_address; |
1304 const char* meid; | 1328 const char* meid; |
1305 const char* imei; | 1329 const char* imei; |
1306 int expected_type; // proto enum type value, -1 for not present. | 1330 int expected_type; // proto enum type value, -1 for not present. |
1307 }; | 1331 }; |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1590 AccountId::FromUserEmail(kPublicAccountId)); | 1614 AccountId::FromUserEmail(kPublicAccountId)); |
1591 EXPECT_CALL(*user_manager_, IsLoggedInAsPublicAccount()) | 1615 EXPECT_CALL(*user_manager_, IsLoggedInAsPublicAccount()) |
1592 .WillRepeatedly(Return(true)); | 1616 .WillRepeatedly(Return(true)); |
1593 | 1617 |
1594 settings_helper_.SetBoolean(chromeos::kReportDeviceNetworkInterfaces, true); | 1618 settings_helper_.SetBoolean(chromeos::kReportDeviceNetworkInterfaces, true); |
1595 GetStatus(); | 1619 GetStatus(); |
1596 VerifyNetworkReporting(); | 1620 VerifyNetworkReporting(); |
1597 } | 1621 } |
1598 | 1622 |
1599 } // namespace policy | 1623 } // namespace policy |
OLD | NEW |