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" | |
| 24 #include "base/test/scoped_path_override.h" | |
| 23 #include "base/threading/sequenced_worker_pool.h" | 25 #include "base/threading/sequenced_worker_pool.h" |
| 26 #include "chrome/browser/chromeos/app_mode/kiosk_app_data.h" | |
| 27 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" | |
| 24 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" | 28 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" |
| 25 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 29 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
| 26 #include "chrome/browser/chromeos/ownership/fake_owner_settings_service.h" | 30 #include "chrome/browser/chromeos/ownership/fake_owner_settings_service.h" |
| 27 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 31 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 28 #include "chrome/browser/chromeos/policy/device_local_account.h" | 32 #include "chrome/browser/chromeos/policy/device_local_account.h" |
| 29 #include "chrome/browser/chromeos/policy/stub_enterprise_install_attributes.h" | 33 #include "chrome/browser/chromeos/policy/stub_enterprise_install_attributes.h" |
| 30 #include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h" | 34 #include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h" |
| 35 #include "chrome/common/chrome_paths.h" | |
| 31 #include "chrome/common/pref_names.h" | 36 #include "chrome/common/pref_names.h" |
| 32 #include "chrome/test/base/testing_browser_process.h" | 37 #include "chrome/test/base/testing_browser_process.h" |
| 33 #include "chromeos/dbus/cros_disks_client.h" | 38 #include "chromeos/dbus/cros_disks_client.h" |
| 34 #include "chromeos/dbus/dbus_thread_manager.h" | 39 #include "chromeos/dbus/dbus_thread_manager.h" |
| 40 #include "chromeos/dbus/fake_update_engine_client.h" | |
| 35 #include "chromeos/dbus/shill_device_client.h" | 41 #include "chromeos/dbus/shill_device_client.h" |
| 36 #include "chromeos/dbus/shill_ipconfig_client.h" | 42 #include "chromeos/dbus/shill_ipconfig_client.h" |
| 37 #include "chromeos/dbus/shill_service_client.h" | 43 #include "chromeos/dbus/shill_service_client.h" |
| 38 #include "chromeos/disks/disk_mount_manager.h" | 44 #include "chromeos/disks/disk_mount_manager.h" |
| 39 #include "chromeos/disks/mock_disk_mount_manager.h" | 45 #include "chromeos/disks/mock_disk_mount_manager.h" |
| 40 #include "chromeos/network/network_handler.h" | 46 #include "chromeos/network/network_handler.h" |
| 41 #include "chromeos/network/network_state.h" | 47 #include "chromeos/network/network_state.h" |
| 42 #include "chromeos/network/network_state_handler.h" | 48 #include "chromeos/network/network_state_handler.h" |
| 43 #include "chromeos/settings/cros_settings_names.h" | 49 #include "chromeos/settings/cros_settings_names.h" |
| 44 #include "chromeos/system/fake_statistics_provider.h" | 50 #include "chromeos/system/fake_statistics_provider.h" |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 253 install_attributes_("managed.com", | 259 install_attributes_("managed.com", |
| 254 "user@managed.com", | 260 "user@managed.com", |
| 255 "device_id", | 261 "device_id", |
| 256 DEVICE_MODE_ENTERPRISE), | 262 DEVICE_MODE_ENTERPRISE), |
| 257 settings_helper_(false), | 263 settings_helper_(false), |
| 258 user_manager_(new chromeos::MockUserManager()), | 264 user_manager_(new chromeos::MockUserManager()), |
| 259 user_manager_enabler_(user_manager_), | 265 user_manager_enabler_(user_manager_), |
| 260 fake_device_local_account_(policy::DeviceLocalAccount::TYPE_KIOSK_APP, | 266 fake_device_local_account_(policy::DeviceLocalAccount::TYPE_KIOSK_APP, |
| 261 kKioskAccountId, | 267 kKioskAccountId, |
| 262 kKioskAppId, | 268 kKioskAppId, |
| 263 std::string() /* kiosk_app_update_url */) { | 269 std::string() /* kiosk_app_update_url */), |
| 270 user_data_dir_override_(chrome::DIR_USER_DATA), | |
| 271 update_engine_client_(new chromeos::FakeUpdateEngineClient) { | |
| 264 // Run this test with a well-known timezone so that Time::LocalMidnight() | 272 // Run this test with a well-known timezone so that Time::LocalMidnight() |
| 265 // returns the same values on all machines. | 273 // returns the same values on all machines. |
| 266 std::unique_ptr<base::Environment> env(base::Environment::Create()); | 274 std::unique_ptr<base::Environment> env(base::Environment::Create()); |
| 267 env->SetVar("TZ", "UTC"); | 275 env->SetVar("TZ", "UTC"); |
| 268 | 276 |
| 269 // Initialize our mock mounted disk volumes. | 277 // Initialize our mock mounted disk volumes. |
| 270 std::unique_ptr<chromeos::disks::MockDiskMountManager> | 278 std::unique_ptr<chromeos::disks::MockDiskMountManager> |
| 271 mock_disk_mount_manager = | 279 mock_disk_mount_manager = |
| 272 base::WrapUnique(new chromeos::disks::MockDiskMountManager()); | 280 base::WrapUnique(new chromeos::disks::MockDiskMountManager()); |
| 273 AddMountPoint("/mount/volume1"); | 281 AddMountPoint("/mount/volume1"); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 292 DiskMountManager::InitializeForTesting(mock_disk_mount_manager.release()); | 300 DiskMountManager::InitializeForTesting(mock_disk_mount_manager.release()); |
| 293 TestingDeviceStatusCollector::RegisterPrefs(prefs_.registry()); | 301 TestingDeviceStatusCollector::RegisterPrefs(prefs_.registry()); |
| 294 | 302 |
| 295 settings_helper_.ReplaceProvider(chromeos::kReportDeviceActivityTimes); | 303 settings_helper_.ReplaceProvider(chromeos::kReportDeviceActivityTimes); |
| 296 owner_settings_service_ = | 304 owner_settings_service_ = |
| 297 settings_helper_.CreateOwnerSettingsService(nullptr); | 305 settings_helper_.CreateOwnerSettingsService(nullptr); |
| 298 | 306 |
| 299 RestartStatusCollector(base::Bind(&GetEmptyVolumeInfo), | 307 RestartStatusCollector(base::Bind(&GetEmptyVolumeInfo), |
| 300 base::Bind(&GetEmptyCPUStatistics), | 308 base::Bind(&GetEmptyCPUStatistics), |
| 301 base::Bind(&GetEmptyCPUTempInfo)); | 309 base::Bind(&GetEmptyCPUTempInfo)); |
| 310 | |
| 311 // Set up a fake local state for KioskAppManager. | |
| 312 TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_); | |
| 313 chromeos::KioskAppManager::RegisterPrefs(local_state_.registry()); | |
| 314 | |
| 315 // Use FakeUpdateEngienClient. | |
|
Thiemo Nagel
2016/07/12 14:08:46
Nit: typo
xiyuan
2016/07/12 15:17:04
Done.
| |
| 316 std::unique_ptr<chromeos::DBusThreadManagerSetter> dbus_setter = | |
| 317 chromeos::DBusThreadManager::GetSetterForTesting(); | |
| 318 dbus_setter->SetUpdateEngineClient( | |
| 319 base::WrapUnique<chromeos::UpdateEngineClient>(update_engine_client_)); | |
| 302 } | 320 } |
| 303 | 321 |
| 304 void AddMountPoint(const std::string& mount_point) { | 322 void AddMountPoint(const std::string& mount_point) { |
| 305 mount_point_map_.insert(DiskMountManager::MountPointMap::value_type( | 323 mount_point_map_.insert(DiskMountManager::MountPointMap::value_type( |
| 306 mount_point, | 324 mount_point, |
| 307 DiskMountManager::MountPointInfo( | 325 DiskMountManager::MountPointInfo( |
| 308 mount_point, mount_point, chromeos::MOUNT_TYPE_DEVICE, | 326 mount_point, mount_point, chromeos::MOUNT_TYPE_DEVICE, |
| 309 chromeos::disks::MOUNT_CONDITION_NONE))); | 327 chromeos::disks::MOUNT_CONDITION_NONE))); |
| 310 } | 328 } |
| 311 | 329 |
| 312 ~DeviceStatusCollectorTest() override { | 330 ~DeviceStatusCollectorTest() override { |
| 313 // Finish pending tasks. | 331 // Finish pending tasks. |
| 314 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 332 content::BrowserThread::GetBlockingPool()->FlushForTesting(); |
| 315 message_loop_.RunUntilIdle(); | 333 message_loop_.RunUntilIdle(); |
| 316 storage::ExternalMountPoints::GetSystemInstance()->RevokeAllFileSystems(); | 334 storage::ExternalMountPoints::GetSystemInstance()->RevokeAllFileSystems(); |
| 317 DiskMountManager::Shutdown(); | 335 DiskMountManager::Shutdown(); |
| 318 } | 336 } |
| 319 | 337 |
| 320 void SetUp() override { | 338 void SetUp() override { |
| 321 // Disable network interface reporting since it requires additional setup. | 339 // Disable network interface reporting since it requires additional setup. |
| 322 settings_helper_.SetBoolean(chromeos::kReportDeviceNetworkInterfaces, | 340 settings_helper_.SetBoolean(chromeos::kReportDeviceNetworkInterfaces, |
| 323 false); | 341 false); |
| 324 } | 342 } |
| 325 | 343 |
| 326 void TearDown() override { settings_helper_.RestoreProvider(); } | 344 void TearDown() override { |
| 345 chromeos::KioskAppManager::Shutdown(); | |
| 346 TestingBrowserProcess::GetGlobal()->SetLocalState(nullptr); | |
| 347 settings_helper_.RestoreProvider(); | |
| 348 } | |
| 327 | 349 |
| 328 void RestartStatusCollector( | 350 void RestartStatusCollector( |
| 329 const policy::DeviceStatusCollector::VolumeInfoFetcher& volume_info, | 351 const policy::DeviceStatusCollector::VolumeInfoFetcher& volume_info, |
| 330 const policy::DeviceStatusCollector::CPUStatisticsFetcher& cpu_stats, | 352 const policy::DeviceStatusCollector::CPUStatisticsFetcher& cpu_stats, |
| 331 const policy::DeviceStatusCollector::CPUTempFetcher& cpu_temp_fetcher) { | 353 const policy::DeviceStatusCollector::CPUTempFetcher& cpu_temp_fetcher) { |
| 332 policy::DeviceStatusCollector::LocationUpdateRequester callback = | 354 policy::DeviceStatusCollector::LocationUpdateRequester callback = |
| 333 base::Bind(&MockPositionUpdateRequester); | 355 base::Bind(&MockPositionUpdateRequester); |
| 334 std::vector<em::VolumeInfo> expected_volume_info; | 356 std::vector<em::VolumeInfo> expected_volume_info; |
| 335 status_collector_.reset(new TestingDeviceStatusCollector( | 357 status_collector_.reset(new TestingDeviceStatusCollector( |
| 336 &prefs_, &fake_statistics_provider_, callback, volume_info, cpu_stats, | 358 &prefs_, &fake_statistics_provider_, callback, volume_info, cpu_stats, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 384 void MockRunningKioskApp(const DeviceLocalAccount& account) { | 406 void MockRunningKioskApp(const DeviceLocalAccount& account) { |
| 385 std::vector<DeviceLocalAccount> accounts; | 407 std::vector<DeviceLocalAccount> accounts; |
| 386 accounts.push_back(account); | 408 accounts.push_back(account); |
| 387 SetDeviceLocalAccounts(owner_settings_service_.get(), accounts); | 409 SetDeviceLocalAccounts(owner_settings_service_.get(), accounts); |
| 388 user_manager_->CreateKioskAppUser( | 410 user_manager_->CreateKioskAppUser( |
| 389 AccountId::FromUserEmail(account.user_id)); | 411 AccountId::FromUserEmail(account.user_id)); |
| 390 EXPECT_CALL(*user_manager_, IsLoggedInAsKioskApp()).WillRepeatedly( | 412 EXPECT_CALL(*user_manager_, IsLoggedInAsKioskApp()).WillRepeatedly( |
| 391 Return(true)); | 413 Return(true)); |
| 392 } | 414 } |
| 393 | 415 |
| 416 void MockPlatformVersion(const std::string& platform_version) { | |
| 417 const std::string lsb_release = base::StringPrintf( | |
| 418 "CHROMEOS_RELEASE_VERSION=%s", platform_version.c_str()); | |
| 419 base::SysInfo::SetChromeOSVersionInfoForTest(lsb_release, | |
| 420 base::Time::Now()); | |
| 421 } | |
| 422 | |
| 423 void MockAutoLaunchKioskAppWithRequiredPlatformVersion( | |
| 424 const DeviceLocalAccount& auto_launch_app_account, | |
| 425 const std::string& required_platform_version) { | |
| 426 chromeos::KioskAppManager* manager = chromeos::KioskAppManager::Get(); | |
| 427 manager->AddAppForTest( | |
| 428 auto_launch_app_account.kiosk_app_id, | |
| 429 AccountId::FromUserEmail(auto_launch_app_account.user_id), | |
| 430 GURL("http://cws/"), // Dummy URL to avoid setup ExtensionsClient. | |
| 431 required_platform_version); | |
| 432 manager->SetEnableAutoLaunch(true); | |
| 433 | |
| 434 std::vector<DeviceLocalAccount> accounts; | |
| 435 accounts.push_back(auto_launch_app_account); | |
| 436 SetDeviceLocalAccounts(owner_settings_service_.get(), accounts); | |
| 437 | |
| 438 owner_settings_service_->SetString( | |
| 439 chromeos::kAccountsPrefDeviceLocalAccountAutoLoginId, | |
| 440 auto_launch_app_account.account_id); | |
| 441 | |
| 442 message_loop_.RunUntilIdle(); | |
| 443 | |
| 444 ASSERT_EQ(required_platform_version, | |
| 445 manager->GetAutoLaunchAppRequiredPlatformVersion()); | |
| 446 } | |
| 447 | |
| 394 protected: | 448 protected: |
| 395 // Convenience method. | 449 // Convenience method. |
| 396 int64_t ActivePeriodMilliseconds() { | 450 int64_t ActivePeriodMilliseconds() { |
| 397 return policy::DeviceStatusCollector::kIdlePollIntervalSeconds * 1000; | 451 return policy::DeviceStatusCollector::kIdlePollIntervalSeconds * 1000; |
| 398 } | 452 } |
| 399 | 453 |
| 400 // Since this is a unit test running in browser_tests we must do additional | 454 // Since this is a unit test running in browser_tests we must do additional |
| 401 // unit test setup and make a TestingBrowserProcess. Must be first member. | 455 // unit test setup and make a TestingBrowserProcess. Must be first member. |
| 402 TestingBrowserProcessInitializer initializer_; | 456 TestingBrowserProcessInitializer initializer_; |
| 403 base::MessageLoopForUI message_loop_; | 457 base::MessageLoopForUI message_loop_; |
| 404 content::TestBrowserThread ui_thread_; | 458 content::TestBrowserThread ui_thread_; |
| 405 content::TestBrowserThread file_thread_; | 459 content::TestBrowserThread file_thread_; |
| 406 content::TestBrowserThread io_thread_; | 460 content::TestBrowserThread io_thread_; |
| 407 | 461 |
| 408 ScopedStubEnterpriseInstallAttributes install_attributes_; | 462 ScopedStubEnterpriseInstallAttributes install_attributes_; |
| 409 TestingPrefServiceSimple prefs_; | 463 TestingPrefServiceSimple prefs_; |
| 410 chromeos::system::ScopedFakeStatisticsProvider fake_statistics_provider_; | 464 chromeos::system::ScopedFakeStatisticsProvider fake_statistics_provider_; |
| 411 DiskMountManager::MountPointMap mount_point_map_; | 465 DiskMountManager::MountPointMap mount_point_map_; |
| 412 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; | 466 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
| 413 chromeos::ScopedTestCrosSettings test_cros_settings_; | 467 chromeos::ScopedTestCrosSettings test_cros_settings_; |
| 414 chromeos::ScopedCrosSettingsTestHelper settings_helper_; | 468 chromeos::ScopedCrosSettingsTestHelper settings_helper_; |
| 415 std::unique_ptr<chromeos::FakeOwnerSettingsService> owner_settings_service_; | 469 std::unique_ptr<chromeos::FakeOwnerSettingsService> owner_settings_service_; |
| 416 chromeos::MockUserManager* user_manager_; | 470 chromeos::MockUserManager* const user_manager_; |
| 417 chromeos::ScopedUserManagerEnabler user_manager_enabler_; | 471 chromeos::ScopedUserManagerEnabler user_manager_enabler_; |
| 418 em::DeviceStatusReportRequest status_; | 472 em::DeviceStatusReportRequest status_; |
| 419 std::unique_ptr<TestingDeviceStatusCollector> status_collector_; | 473 std::unique_ptr<TestingDeviceStatusCollector> status_collector_; |
| 420 const policy::DeviceLocalAccount fake_device_local_account_; | 474 const policy::DeviceLocalAccount fake_device_local_account_; |
| 475 base::ScopedPathOverride user_data_dir_override_; | |
| 476 TestingPrefServiceSimple local_state_; | |
| 477 chromeos::FakeUpdateEngineClient* const update_engine_client_; | |
| 421 }; | 478 }; |
| 422 | 479 |
| 423 TEST_F(DeviceStatusCollectorTest, AllIdle) { | 480 TEST_F(DeviceStatusCollectorTest, AllIdle) { |
| 424 ui::IdleState test_states[] = { | 481 ui::IdleState test_states[] = { |
| 425 ui::IDLE_STATE_IDLE, | 482 ui::IDLE_STATE_IDLE, |
| 426 ui::IDLE_STATE_IDLE, | 483 ui::IDLE_STATE_IDLE, |
| 427 ui::IDLE_STATE_IDLE | 484 ui::IDLE_STATE_IDLE |
| 428 }; | 485 }; |
| 429 settings_helper_.SetBoolean(chromeos::kReportDeviceActivityTimes, true); | 486 settings_helper_.SetBoolean(chromeos::kReportDeviceActivityTimes, true); |
| 430 | 487 |
| (...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1011 ASSERT_EQ(1, session_status.installed_apps_size()); | 1068 ASSERT_EQ(1, session_status.installed_apps_size()); |
| 1012 EXPECT_EQ(kKioskAccountId, session_status.device_local_account_id()); | 1069 EXPECT_EQ(kKioskAccountId, session_status.device_local_account_id()); |
| 1013 const em::AppStatus app = session_status.installed_apps(0); | 1070 const em::AppStatus app = session_status.installed_apps(0); |
| 1014 EXPECT_EQ(kKioskAppId, app.app_id()); | 1071 EXPECT_EQ(kKioskAppId, app.app_id()); |
| 1015 // Test code just sets the version to the app ID. | 1072 // Test code just sets the version to the app ID. |
| 1016 EXPECT_EQ(kKioskAppId, app.extension_version()); | 1073 EXPECT_EQ(kKioskAppId, app.extension_version()); |
| 1017 EXPECT_FALSE(app.has_status()); | 1074 EXPECT_FALSE(app.has_status()); |
| 1018 EXPECT_FALSE(app.has_error()); | 1075 EXPECT_FALSE(app.has_error()); |
| 1019 } | 1076 } |
| 1020 | 1077 |
| 1078 TEST_F(DeviceStatusCollectorTest, NoOsUpdateStatusByDefault) { | |
| 1079 MockPlatformVersion("1234.0.0"); | |
| 1080 MockAutoLaunchKioskAppWithRequiredPlatformVersion(fake_device_local_account_, | |
| 1081 "1234.0.0"); | |
| 1082 | |
| 1083 GetStatus(); | |
| 1084 EXPECT_FALSE(status_.has_os_update_status()); | |
| 1085 } | |
| 1086 | |
| 1087 TEST_F(DeviceStatusCollectorTest, ReportOsUpdateStatusUpToDate) { | |
| 1088 MockPlatformVersion("1234.0.0"); | |
| 1089 settings_helper_.SetBoolean(chromeos::kReportOsUpdateStatus, true); | |
| 1090 | |
| 1091 const char* kRequiredPlatformVersions[] = {"1234", "1234.0", "1234.0.0"}; | |
| 1092 | |
| 1093 for (size_t i = 0; i < arraysize(kRequiredPlatformVersions); ++i) { | |
| 1094 MockAutoLaunchKioskAppWithRequiredPlatformVersion( | |
| 1095 fake_device_local_account_, kRequiredPlatformVersions[i]); | |
| 1096 | |
| 1097 GetStatus(); | |
| 1098 ASSERT_TRUE(status_.has_os_update_status()) << "Required platform version=" | |
| 1099 << kRequiredPlatformVersions[i]; | |
| 1100 EXPECT_EQ(em::OsUpdateStatus::OS_UP_TO_DATE, | |
| 1101 status_.os_update_status().update_status()) | |
| 1102 << "Required platform version=" << kRequiredPlatformVersions[i]; | |
| 1103 EXPECT_EQ(kRequiredPlatformVersions[i], | |
| 1104 status_.os_update_status().new_required_platform_version()) | |
| 1105 << "Required platform version=" << kRequiredPlatformVersions[i]; | |
| 1106 } | |
| 1107 } | |
| 1108 | |
| 1109 TEST_F(DeviceStatusCollectorTest, ReportOsUpdateStatus) { | |
| 1110 MockPlatformVersion("1234.0.0"); | |
| 1111 settings_helper_.SetBoolean(chromeos::kReportOsUpdateStatus, true); | |
| 1112 MockAutoLaunchKioskAppWithRequiredPlatformVersion(fake_device_local_account_, | |
| 1113 "1235"); | |
| 1114 | |
| 1115 chromeos::UpdateEngineClient::Status update_status; | |
| 1116 update_status.status = chromeos::UpdateEngineClient::UPDATE_STATUS_IDLE; | |
| 1117 | |
| 1118 GetStatus(); | |
| 1119 ASSERT_TRUE(status_.has_os_update_status()); | |
| 1120 EXPECT_EQ(em::OsUpdateStatus::OS_IMAGE_DOWNLOAD_NOT_STARTED, | |
| 1121 status_.os_update_status().update_status()); | |
| 1122 | |
| 1123 const chromeos::UpdateEngineClient::UpdateStatusOperation kUpdateEngineOps[] = | |
| 1124 { | |
| 1125 chromeos::UpdateEngineClient::UPDATE_STATUS_DOWNLOADING, | |
| 1126 chromeos::UpdateEngineClient::UPDATE_STATUS_VERIFYING, | |
| 1127 chromeos::UpdateEngineClient::UPDATE_STATUS_FINALIZING, | |
| 1128 }; | |
| 1129 | |
| 1130 for (size_t i = 0; i < arraysize(kUpdateEngineOps); ++i) { | |
| 1131 update_status.status = kUpdateEngineOps[i]; | |
| 1132 update_status.new_version = "1235.1.2"; | |
| 1133 update_engine_client_->PushLastStatus(update_status); | |
| 1134 | |
| 1135 GetStatus(); | |
| 1136 ASSERT_TRUE(status_.has_os_update_status()); | |
| 1137 EXPECT_EQ(em::OsUpdateStatus::OS_IMAGE_DOWNLOAD_IN_PROGRESS, | |
| 1138 status_.os_update_status().update_status()); | |
| 1139 EXPECT_EQ("1235.1.2", status_.os_update_status().new_platform_version()); | |
| 1140 EXPECT_EQ("1235", | |
| 1141 status_.os_update_status().new_required_platform_version()); | |
| 1142 } | |
| 1143 | |
| 1144 update_status.status = | |
| 1145 chromeos::UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT; | |
| 1146 update_engine_client_->PushLastStatus(update_status); | |
| 1147 GetStatus(); | |
| 1148 ASSERT_TRUE(status_.has_os_update_status()); | |
| 1149 EXPECT_EQ(em::OsUpdateStatus::OS_UPDATE_NEED_REBOOT, | |
| 1150 status_.os_update_status().update_status()); | |
| 1151 } | |
| 1152 | |
| 1153 TEST_F(DeviceStatusCollectorTest, NoRunningKioskAppByDefault) { | |
| 1154 MockPlatformVersion("1234.0.0"); | |
| 1155 MockAutoLaunchKioskAppWithRequiredPlatformVersion(fake_device_local_account_, | |
| 1156 "1234.0.0"); | |
| 1157 status_collector_->set_kiosk_account(base::WrapUnique( | |
| 1158 new policy::DeviceLocalAccount(fake_device_local_account_))); | |
| 1159 MockRunningKioskApp(fake_device_local_account_); | |
| 1160 | |
| 1161 GetStatus(); | |
| 1162 EXPECT_FALSE(status_.has_running_kiosk_app()); | |
| 1163 } | |
| 1164 | |
| 1165 TEST_F(DeviceStatusCollectorTest, NoRunningKioskAppWhenNotInKioskSession) { | |
| 1166 settings_helper_.SetBoolean(chromeos::kReportRunningKioskApp, true); | |
| 1167 MockPlatformVersion("1234.0.0"); | |
| 1168 MockAutoLaunchKioskAppWithRequiredPlatformVersion(fake_device_local_account_, | |
| 1169 "1234.0.0"); | |
| 1170 | |
| 1171 GetStatus(); | |
| 1172 EXPECT_FALSE(status_.has_running_kiosk_app()); | |
| 1173 } | |
| 1174 | |
| 1175 TEST_F(DeviceStatusCollectorTest, ReportRunningKioskApp) { | |
| 1176 settings_helper_.SetBoolean(chromeos::kReportRunningKioskApp, true); | |
| 1177 MockPlatformVersion("1234.0.0"); | |
| 1178 MockAutoLaunchKioskAppWithRequiredPlatformVersion(fake_device_local_account_, | |
| 1179 "1235"); | |
| 1180 MockRunningKioskApp(fake_device_local_account_); | |
| 1181 status_collector_->set_kiosk_account(base::WrapUnique( | |
| 1182 new policy::DeviceLocalAccount(fake_device_local_account_))); | |
| 1183 | |
| 1184 GetStatus(); | |
| 1185 ASSERT_TRUE(status_.has_running_kiosk_app()); | |
| 1186 const em::AppStatus app = status_.running_kiosk_app(); | |
| 1187 EXPECT_EQ(kKioskAppId, app.app_id()); | |
| 1188 EXPECT_EQ("1235", app.required_platform_version()); | |
| 1189 EXPECT_FALSE(app.has_status()); | |
| 1190 EXPECT_FALSE(app.has_error()); | |
| 1191 } | |
| 1192 | |
| 1021 // Fake device state. | 1193 // Fake device state. |
| 1022 struct FakeDeviceData { | 1194 struct FakeDeviceData { |
| 1023 const char* device_path; | 1195 const char* device_path; |
| 1024 const char* type; | 1196 const char* type; |
| 1025 const char* object_path; | 1197 const char* object_path; |
| 1026 const char* mac_address; | 1198 const char* mac_address; |
| 1027 const char* meid; | 1199 const char* meid; |
| 1028 const char* imei; | 1200 const char* imei; |
| 1029 int expected_type; // proto enum type value, -1 for not present. | 1201 int expected_type; // proto enum type value, -1 for not present. |
| 1030 }; | 1202 }; |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1314 AccountId::FromUserEmail(kPublicAccountId)); | 1486 AccountId::FromUserEmail(kPublicAccountId)); |
| 1315 EXPECT_CALL(*user_manager_, IsLoggedInAsPublicAccount()) | 1487 EXPECT_CALL(*user_manager_, IsLoggedInAsPublicAccount()) |
| 1316 .WillRepeatedly(Return(true)); | 1488 .WillRepeatedly(Return(true)); |
| 1317 | 1489 |
| 1318 settings_helper_.SetBoolean(chromeos::kReportDeviceNetworkInterfaces, true); | 1490 settings_helper_.SetBoolean(chromeos::kReportDeviceNetworkInterfaces, true); |
| 1319 GetStatus(); | 1491 GetStatus(); |
| 1320 VerifyNetworkReporting(); | 1492 VerifyNetworkReporting(); |
| 1321 } | 1493 } |
| 1322 | 1494 |
| 1323 } // namespace policy | 1495 } // namespace policy |
| OLD | NEW |