| 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> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <utility> | 12 #include <utility> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/bind.h" | 15 #include "base/bind.h" |
| 16 #include "base/environment.h" | 16 #include "base/environment.h" |
| 17 #include "base/location.h" |
| 17 #include "base/logging.h" | 18 #include "base/logging.h" |
| 18 #include "base/macros.h" | 19 #include "base/macros.h" |
| 19 #include "base/memory/ptr_util.h" | 20 #include "base/memory/ptr_util.h" |
| 20 #include "base/message_loop/message_loop.h" | 21 #include "base/message_loop/message_loop.h" |
| 21 #include "base/run_loop.h" | 22 #include "base/run_loop.h" |
| 22 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
| 23 #include "base/sys_info.h" | 24 #include "base/sys_info.h" |
| 24 #include "base/test/scoped_path_override.h" | 25 #include "base/test/scoped_path_override.h" |
| 25 #include "base/threading/sequenced_worker_pool.h" | 26 #include "base/threading/sequenced_worker_pool.h" |
| 27 #include "base/threading/thread_task_runner_handle.h" |
| 26 #include "chrome/browser/chromeos/app_mode/kiosk_app_data.h" | 28 #include "chrome/browser/chromeos/app_mode/kiosk_app_data.h" |
| 27 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" | 29 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" |
| 28 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" | 30 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" |
| 29 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 31 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
| 30 #include "chrome/browser/chromeos/ownership/fake_owner_settings_service.h" | 32 #include "chrome/browser/chromeos/ownership/fake_owner_settings_service.h" |
| 31 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 33 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 32 #include "chrome/browser/chromeos/policy/device_local_account.h" | 34 #include "chrome/browser/chromeos/policy/device_local_account.h" |
| 33 #include "chrome/browser/chromeos/policy/stub_enterprise_install_attributes.h" | 35 #include "chrome/browser/chromeos/policy/stub_enterprise_install_attributes.h" |
| 34 #include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h" | 36 #include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h" |
| 35 #include "chrome/common/chrome_paths.h" | 37 #include "chrome/common/chrome_paths.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 47 #include "chromeos/network/network_state.h" | 49 #include "chromeos/network/network_state.h" |
| 48 #include "chromeos/network/network_state_handler.h" | 50 #include "chromeos/network/network_state_handler.h" |
| 49 #include "chromeos/settings/cros_settings_names.h" | 51 #include "chromeos/settings/cros_settings_names.h" |
| 50 #include "chromeos/system/fake_statistics_provider.h" | 52 #include "chromeos/system/fake_statistics_provider.h" |
| 51 #include "components/policy/proto/device_management_backend.pb.h" | 53 #include "components/policy/proto/device_management_backend.pb.h" |
| 52 #include "components/prefs/pref_service.h" | 54 #include "components/prefs/pref_service.h" |
| 53 #include "components/prefs/testing_pref_service.h" | 55 #include "components/prefs/testing_pref_service.h" |
| 54 #include "content/public/browser/browser_thread.h" | 56 #include "content/public/browser/browser_thread.h" |
| 55 #include "content/public/test/test_browser_thread.h" | 57 #include "content/public/test/test_browser_thread.h" |
| 56 #include "content/public/test/test_utils.h" | 58 #include "content/public/test/test_utils.h" |
| 59 #include "mojo/public/cpp/bindings/string.h" |
| 57 #include "storage/browser/fileapi/external_mount_points.h" | 60 #include "storage/browser/fileapi/external_mount_points.h" |
| 58 #include "storage/browser/fileapi/mount_points.h" | 61 #include "storage/browser/fileapi/mount_points.h" |
| 59 #include "storage/common/fileapi/file_system_mount_option.h" | 62 #include "storage/common/fileapi/file_system_mount_option.h" |
| 60 #include "storage/common/fileapi/file_system_types.h" | 63 #include "storage/common/fileapi/file_system_types.h" |
| 61 #include "testing/gmock/include/gmock/gmock.h" | 64 #include "testing/gmock/include/gmock/gmock.h" |
| 62 #include "testing/gtest/include/gtest/gtest.h" | 65 #include "testing/gtest/include/gtest/gtest.h" |
| 63 #include "third_party/cros_system_api/dbus/service_constants.h" | 66 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 64 | 67 |
| 65 using ::testing::Return; | 68 using ::testing::Return; |
| 66 using ::testing::ReturnRef; | 69 using ::testing::ReturnRef; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 79 const char kPublicAccountId[] = "public_user@localhost"; | 82 const char kPublicAccountId[] = "public_user@localhost"; |
| 80 | 83 |
| 81 class TestingDeviceStatusCollector : public policy::DeviceStatusCollector { | 84 class TestingDeviceStatusCollector : public policy::DeviceStatusCollector { |
| 82 public: | 85 public: |
| 83 TestingDeviceStatusCollector( | 86 TestingDeviceStatusCollector( |
| 84 PrefService* local_state, | 87 PrefService* local_state, |
| 85 chromeos::system::StatisticsProvider* provider, | 88 chromeos::system::StatisticsProvider* provider, |
| 86 const policy::DeviceStatusCollector::VolumeInfoFetcher& | 89 const policy::DeviceStatusCollector::VolumeInfoFetcher& |
| 87 volume_info_fetcher, | 90 volume_info_fetcher, |
| 88 const policy::DeviceStatusCollector::CPUStatisticsFetcher& cpu_fetcher, | 91 const policy::DeviceStatusCollector::CPUStatisticsFetcher& cpu_fetcher, |
| 89 const policy::DeviceStatusCollector::CPUTempFetcher& cpu_temp_fetcher) | 92 const policy::DeviceStatusCollector::CPUTempFetcher& cpu_temp_fetcher, |
| 93 const policy::DeviceStatusCollector::AndroidStatusFetcher& |
| 94 android_status_fetcher) |
| 90 : policy::DeviceStatusCollector(local_state, | 95 : policy::DeviceStatusCollector(local_state, |
| 91 provider, | 96 provider, |
| 92 volume_info_fetcher, | 97 volume_info_fetcher, |
| 93 cpu_fetcher, | 98 cpu_fetcher, |
| 94 cpu_temp_fetcher) { | 99 cpu_temp_fetcher, |
| 100 android_status_fetcher) { |
| 95 // Set the baseline time to a fixed value (1 AM) to prevent test flakiness | 101 // Set the baseline time to a fixed value (1 AM) to prevent test flakiness |
| 96 // due to a single activity period spanning two days. | 102 // due to a single activity period spanning two days. |
| 97 SetBaselineTime(Time::Now().LocalMidnight() + TimeDelta::FromHours(1)); | 103 SetBaselineTime(Time::Now().LocalMidnight() + TimeDelta::FromHours(1)); |
| 98 } | 104 } |
| 99 | 105 |
| 100 void Simulate(ui::IdleState* states, int len) { | 106 void Simulate(ui::IdleState* states, int len) { |
| 101 for (int i = 0; i < len; i++) | 107 for (int i = 0; i < len; i++) |
| 102 IdleStateCallback(states[i]); | 108 IdleStateCallback(states[i]); |
| 103 } | 109 } |
| 104 | 110 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 EXPECT_TRUE(found) << "Could not find matching mount point for " | 211 EXPECT_TRUE(found) << "Could not find matching mount point for " |
| 206 << info.volume_id(); | 212 << info.volume_id(); |
| 207 } | 213 } |
| 208 return volume_info; | 214 return volume_info; |
| 209 } | 215 } |
| 210 | 216 |
| 211 std::vector<em::CPUTempInfo> GetEmptyCPUTempInfo() { | 217 std::vector<em::CPUTempInfo> GetEmptyCPUTempInfo() { |
| 212 return std::vector<em::CPUTempInfo>(); | 218 return std::vector<em::CPUTempInfo>(); |
| 213 } | 219 } |
| 214 | 220 |
| 221 void CallAndroidStatusReceiver( |
| 222 const policy::DeviceStatusCollector::AndroidStatusReceiver& receiver, |
| 223 mojo::String status, |
| 224 mojo::String droid_guard_info) { |
| 225 receiver.Run(status, droid_guard_info); |
| 226 } |
| 227 |
| 228 bool GetEmptyAndroidStatus( |
| 229 const policy::DeviceStatusCollector::AndroidStatusReceiver& receiver) { |
| 230 // Post it to the thread because this call is expected to be asynchronous. |
| 231 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 232 FROM_HERE, base::Bind(&CallAndroidStatusReceiver, receiver, "", "")); |
| 233 return true; |
| 234 } |
| 235 |
| 215 std::vector<em::CPUTempInfo> GetFakeCPUTempInfo( | 236 std::vector<em::CPUTempInfo> GetFakeCPUTempInfo( |
| 216 const std::vector<em::CPUTempInfo>& cpu_temp_info) { | 237 const std::vector<em::CPUTempInfo>& cpu_temp_info) { |
| 217 return cpu_temp_info; | 238 return cpu_temp_info; |
| 218 } | 239 } |
| 219 | 240 |
| 220 } // namespace | 241 } // namespace |
| 221 | 242 |
| 222 namespace policy { | 243 namespace policy { |
| 223 | 244 |
| 224 // Though it is a unit test, this test is linked with browser_tests so that it | 245 // Though it is a unit test, this test is linked with browser_tests so that it |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 // DiskMountManager takes ownership of the MockDiskMountManager. | 295 // DiskMountManager takes ownership of the MockDiskMountManager. |
| 275 DiskMountManager::InitializeForTesting(mock_disk_mount_manager.release()); | 296 DiskMountManager::InitializeForTesting(mock_disk_mount_manager.release()); |
| 276 TestingDeviceStatusCollector::RegisterPrefs(prefs_.registry()); | 297 TestingDeviceStatusCollector::RegisterPrefs(prefs_.registry()); |
| 277 | 298 |
| 278 settings_helper_.ReplaceProvider(chromeos::kReportDeviceActivityTimes); | 299 settings_helper_.ReplaceProvider(chromeos::kReportDeviceActivityTimes); |
| 279 owner_settings_service_ = | 300 owner_settings_service_ = |
| 280 settings_helper_.CreateOwnerSettingsService(nullptr); | 301 settings_helper_.CreateOwnerSettingsService(nullptr); |
| 281 | 302 |
| 282 RestartStatusCollector(base::Bind(&GetEmptyVolumeInfo), | 303 RestartStatusCollector(base::Bind(&GetEmptyVolumeInfo), |
| 283 base::Bind(&GetEmptyCPUStatistics), | 304 base::Bind(&GetEmptyCPUStatistics), |
| 284 base::Bind(&GetEmptyCPUTempInfo)); | 305 base::Bind(&GetEmptyCPUTempInfo), |
| 306 base::Bind(&GetEmptyAndroidStatus)); |
| 285 | 307 |
| 286 // Set up a fake local state for KioskAppManager. | 308 // Set up a fake local state for KioskAppManager. |
| 287 TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_); | 309 TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_); |
| 288 chromeos::KioskAppManager::RegisterPrefs(local_state_.registry()); | 310 chromeos::KioskAppManager::RegisterPrefs(local_state_.registry()); |
| 289 | 311 |
| 290 // Use FakeUpdateEngineClient. | 312 // Use FakeUpdateEngineClient. |
| 291 std::unique_ptr<chromeos::DBusThreadManagerSetter> dbus_setter = | 313 std::unique_ptr<chromeos::DBusThreadManagerSetter> dbus_setter = |
| 292 chromeos::DBusThreadManager::GetSetterForTesting(); | 314 chromeos::DBusThreadManager::GetSetterForTesting(); |
| 293 dbus_setter->SetUpdateEngineClient( | 315 dbus_setter->SetUpdateEngineClient( |
| 294 base::WrapUnique<chromeos::UpdateEngineClient>(update_engine_client_)); | 316 base::WrapUnique<chromeos::UpdateEngineClient>(update_engine_client_)); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 319 false); | 341 false); |
| 320 } | 342 } |
| 321 | 343 |
| 322 void TearDown() override { | 344 void TearDown() override { |
| 323 settings_helper_.RestoreProvider(); | 345 settings_helper_.RestoreProvider(); |
| 324 } | 346 } |
| 325 | 347 |
| 326 void RestartStatusCollector( | 348 void RestartStatusCollector( |
| 327 const policy::DeviceStatusCollector::VolumeInfoFetcher& volume_info, | 349 const policy::DeviceStatusCollector::VolumeInfoFetcher& volume_info, |
| 328 const policy::DeviceStatusCollector::CPUStatisticsFetcher& cpu_stats, | 350 const policy::DeviceStatusCollector::CPUStatisticsFetcher& cpu_stats, |
| 329 const policy::DeviceStatusCollector::CPUTempFetcher& cpu_temp_fetcher) { | 351 const policy::DeviceStatusCollector::CPUTempFetcher& cpu_temp_fetcher, |
| 352 const policy::DeviceStatusCollector::AndroidStatusFetcher& |
| 353 android_status_fetcher) { |
| 330 std::vector<em::VolumeInfo> expected_volume_info; | 354 std::vector<em::VolumeInfo> expected_volume_info; |
| 331 status_collector_.reset(new TestingDeviceStatusCollector( | 355 status_collector_.reset(new TestingDeviceStatusCollector( |
| 332 &prefs_, &fake_statistics_provider_, volume_info, cpu_stats, | 356 &prefs_, &fake_statistics_provider_, volume_info, cpu_stats, |
| 333 cpu_temp_fetcher)); | 357 cpu_temp_fetcher, android_status_fetcher)); |
| 334 } | 358 } |
| 335 | 359 |
| 336 void GetStatus() { | 360 void GetStatus() { |
| 337 device_status_.Clear(); | 361 device_status_.Clear(); |
| 338 session_status_.Clear(); | 362 session_status_.Clear(); |
| 339 got_session_status_ = false; | 363 got_session_status_ = false; |
| 340 run_loop_.reset(new base::RunLoop()); | 364 run_loop_.reset(new base::RunLoop()); |
| 341 status_collector_->GetDeviceAndSessionStatusAsync(base::Bind( | 365 status_collector_->GetDeviceAndSessionStatusAsync(base::Bind( |
| 342 &DeviceStatusCollectorTest::OnStatusReceived, base::Unretained(this))); | 366 &DeviceStatusCollectorTest::OnStatusReceived, base::Unretained(this))); |
| 343 run_loop_->Run(); | 367 run_loop_->Run(); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 }; | 538 }; |
| 515 settings_helper_.SetBoolean(chromeos::kReportDeviceActivityTimes, true); | 539 settings_helper_.SetBoolean(chromeos::kReportDeviceActivityTimes, true); |
| 516 status_collector_->Simulate(test_states, | 540 status_collector_->Simulate(test_states, |
| 517 sizeof(test_states) / sizeof(ui::IdleState)); | 541 sizeof(test_states) / sizeof(ui::IdleState)); |
| 518 | 542 |
| 519 // Process the list a second time after restarting the collector. It should be | 543 // Process the list a second time after restarting the collector. It should be |
| 520 // able to count the active periods found by the original collector, because | 544 // able to count the active periods found by the original collector, because |
| 521 // the results are stored in a pref. | 545 // the results are stored in a pref. |
| 522 RestartStatusCollector(base::Bind(&GetEmptyVolumeInfo), | 546 RestartStatusCollector(base::Bind(&GetEmptyVolumeInfo), |
| 523 base::Bind(&GetEmptyCPUStatistics), | 547 base::Bind(&GetEmptyCPUStatistics), |
| 524 base::Bind(&GetEmptyCPUTempInfo)); | 548 base::Bind(&GetEmptyCPUTempInfo), |
| 549 base::Bind(&GetEmptyAndroidStatus)); |
| 525 status_collector_->Simulate(test_states, | 550 status_collector_->Simulate(test_states, |
| 526 sizeof(test_states) / sizeof(ui::IdleState)); | 551 sizeof(test_states) / sizeof(ui::IdleState)); |
| 527 | 552 |
| 528 GetStatus(); | 553 GetStatus(); |
| 529 EXPECT_EQ(6 * ActivePeriodMilliseconds(), | 554 EXPECT_EQ(6 * ActivePeriodMilliseconds(), |
| 530 GetActiveMilliseconds(device_status_)); | 555 GetActiveMilliseconds(device_status_)); |
| 531 } | 556 } |
| 532 | 557 |
| 533 TEST_F(DeviceStatusCollectorTest, Times) { | 558 TEST_F(DeviceStatusCollectorTest, Times) { |
| 534 ui::IdleState test_states[] = { | 559 ui::IdleState test_states[] = { |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 info.set_volume_id(mount_point); | 839 info.set_volume_id(mount_point); |
| 815 // Just put unique numbers in for storage_total/free. | 840 // Just put unique numbers in for storage_total/free. |
| 816 info.set_storage_total(size++); | 841 info.set_storage_total(size++); |
| 817 info.set_storage_free(size++); | 842 info.set_storage_free(size++); |
| 818 expected_volume_info.push_back(info); | 843 expected_volume_info.push_back(info); |
| 819 } | 844 } |
| 820 EXPECT_FALSE(expected_volume_info.empty()); | 845 EXPECT_FALSE(expected_volume_info.empty()); |
| 821 | 846 |
| 822 RestartStatusCollector(base::Bind(&GetFakeVolumeInfo, expected_volume_info), | 847 RestartStatusCollector(base::Bind(&GetFakeVolumeInfo, expected_volume_info), |
| 823 base::Bind(&GetEmptyCPUStatistics), | 848 base::Bind(&GetEmptyCPUStatistics), |
| 824 base::Bind(&GetEmptyCPUTempInfo)); | 849 base::Bind(&GetEmptyCPUTempInfo), |
| 850 base::Bind(&GetEmptyAndroidStatus)); |
| 825 // Force finishing tasks posted by ctor of DeviceStatusCollector. | 851 // Force finishing tasks posted by ctor of DeviceStatusCollector. |
| 826 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 852 content::BrowserThread::GetBlockingPool()->FlushForTesting(); |
| 827 base::RunLoop().RunUntilIdle(); | 853 base::RunLoop().RunUntilIdle(); |
| 828 | 854 |
| 829 GetStatus(); | 855 GetStatus(); |
| 830 EXPECT_EQ(expected_mount_points.size(), | 856 EXPECT_EQ(expected_mount_points.size(), |
| 831 static_cast<size_t>(device_status_.volume_info_size())); | 857 static_cast<size_t>(device_status_.volume_info_size())); |
| 832 | 858 |
| 833 // Walk the returned VolumeInfo to make sure it matches. | 859 // Walk the returned VolumeInfo to make sure it matches. |
| 834 for (const em::VolumeInfo& expected_info : expected_volume_info) { | 860 for (const em::VolumeInfo& expected_info : expected_volume_info) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 // No good way to inject specific test values for available system RAM, so | 893 // No good way to inject specific test values for available system RAM, so |
| 868 // just make sure it's > 0. | 894 // just make sure it's > 0. |
| 869 EXPECT_GT(device_status_.system_ram_total(), 0); | 895 EXPECT_GT(device_status_.system_ram_total(), 0); |
| 870 } | 896 } |
| 871 | 897 |
| 872 TEST_F(DeviceStatusCollectorTest, TestCPUSamples) { | 898 TEST_F(DeviceStatusCollectorTest, TestCPUSamples) { |
| 873 // Mock 100% CPU usage. | 899 // Mock 100% CPU usage. |
| 874 std::string full_cpu_usage("cpu 500 0 500 0 0 0 0"); | 900 std::string full_cpu_usage("cpu 500 0 500 0 0 0 0"); |
| 875 RestartStatusCollector(base::Bind(&GetEmptyVolumeInfo), | 901 RestartStatusCollector(base::Bind(&GetEmptyVolumeInfo), |
| 876 base::Bind(&GetFakeCPUStatistics, full_cpu_usage), | 902 base::Bind(&GetFakeCPUStatistics, full_cpu_usage), |
| 877 base::Bind(&GetEmptyCPUTempInfo)); | 903 base::Bind(&GetEmptyCPUTempInfo), |
| 904 base::Bind(&GetEmptyAndroidStatus)); |
| 878 // Force finishing tasks posted by ctor of DeviceStatusCollector. | 905 // Force finishing tasks posted by ctor of DeviceStatusCollector. |
| 879 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 906 content::BrowserThread::GetBlockingPool()->FlushForTesting(); |
| 880 base::RunLoop().RunUntilIdle(); | 907 base::RunLoop().RunUntilIdle(); |
| 881 GetStatus(); | 908 GetStatus(); |
| 882 ASSERT_EQ(1, device_status_.cpu_utilization_pct().size()); | 909 ASSERT_EQ(1, device_status_.cpu_utilization_pct().size()); |
| 883 EXPECT_EQ(100, device_status_.cpu_utilization_pct(0)); | 910 EXPECT_EQ(100, device_status_.cpu_utilization_pct(0)); |
| 884 | 911 |
| 885 // Now sample CPU usage again (active usage counters will not increase | 912 // Now sample CPU usage again (active usage counters will not increase |
| 886 // so should show 0% cpu usage). | 913 // so should show 0% cpu usage). |
| 887 status_collector_->RefreshSampleResourceUsage(); | 914 status_collector_->RefreshSampleResourceUsage(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 918 int cpu_cnt = 12; | 945 int cpu_cnt = 12; |
| 919 for (int i = 0; i < cpu_cnt; ++i) { | 946 for (int i = 0; i < cpu_cnt; ++i) { |
| 920 em::CPUTempInfo info; | 947 em::CPUTempInfo info; |
| 921 info.set_cpu_temp(i * 10 + 100); | 948 info.set_cpu_temp(i * 10 + 100); |
| 922 info.set_cpu_label(base::StringPrintf("Core %d", i)); | 949 info.set_cpu_label(base::StringPrintf("Core %d", i)); |
| 923 expected_temp_info.push_back(info); | 950 expected_temp_info.push_back(info); |
| 924 } | 951 } |
| 925 | 952 |
| 926 RestartStatusCollector(base::Bind(&GetEmptyVolumeInfo), | 953 RestartStatusCollector(base::Bind(&GetEmptyVolumeInfo), |
| 927 base::Bind(&GetEmptyCPUStatistics), | 954 base::Bind(&GetEmptyCPUStatistics), |
| 928 base::Bind(&GetFakeCPUTempInfo, expected_temp_info)); | 955 base::Bind(&GetFakeCPUTempInfo, expected_temp_info), |
| 956 base::Bind(&GetEmptyAndroidStatus)); |
| 929 // Force finishing tasks posted by ctor of DeviceStatusCollector. | 957 // Force finishing tasks posted by ctor of DeviceStatusCollector. |
| 930 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 958 content::BrowserThread::GetBlockingPool()->FlushForTesting(); |
| 931 base::RunLoop().RunUntilIdle(); | 959 base::RunLoop().RunUntilIdle(); |
| 932 | 960 |
| 933 GetStatus(); | 961 GetStatus(); |
| 934 EXPECT_EQ(expected_temp_info.size(), | 962 EXPECT_EQ(expected_temp_info.size(), |
| 935 static_cast<size_t>(device_status_.cpu_temp_info_size())); | 963 static_cast<size_t>(device_status_.cpu_temp_info_size())); |
| 936 | 964 |
| 937 // Walk the returned CPUTempInfo to make sure it matches. | 965 // Walk the returned CPUTempInfo to make sure it matches. |
| 938 for (const em::CPUTempInfo& expected_info : expected_temp_info) { | 966 for (const em::CPUTempInfo& expected_info : expected_temp_info) { |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1407 AccountId::FromUserEmail(kPublicAccountId)); | 1435 AccountId::FromUserEmail(kPublicAccountId)); |
| 1408 EXPECT_CALL(*user_manager_, IsLoggedInAsPublicAccount()) | 1436 EXPECT_CALL(*user_manager_, IsLoggedInAsPublicAccount()) |
| 1409 .WillRepeatedly(Return(true)); | 1437 .WillRepeatedly(Return(true)); |
| 1410 | 1438 |
| 1411 settings_helper_.SetBoolean(chromeos::kReportDeviceNetworkInterfaces, true); | 1439 settings_helper_.SetBoolean(chromeos::kReportDeviceNetworkInterfaces, true); |
| 1412 GetStatus(); | 1440 GetStatus(); |
| 1413 VerifyNetworkReporting(); | 1441 VerifyNetworkReporting(); |
| 1414 } | 1442 } |
| 1415 | 1443 |
| 1416 } // namespace policy | 1444 } // namespace policy |
| OLD | NEW |