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