Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(547)

Side by Side Diff: chrome/browser/chromeos/policy/device_status_collector_browsertest.cc

Issue 2132663002: kiosk: Add status report for os update and running app (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move clean up code from TearDown to dtor since set up code is in ctor now and fix DeviceStatusColle… Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 FakeUpdateEngineClient.
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 {
331 chromeos::KioskAppManager::Shutdown();
332 TestingBrowserProcess::GetGlobal()->SetLocalState(nullptr);
333
313 // Finish pending tasks. 334 // Finish pending tasks.
314 content::BrowserThread::GetBlockingPool()->FlushForTesting(); 335 content::BrowserThread::GetBlockingPool()->FlushForTesting();
315 message_loop_.RunUntilIdle(); 336 message_loop_.RunUntilIdle();
316 storage::ExternalMountPoints::GetSystemInstance()->RevokeAllFileSystems(); 337 storage::ExternalMountPoints::GetSystemInstance()->RevokeAllFileSystems();
317 DiskMountManager::Shutdown(); 338 DiskMountManager::Shutdown();
318 } 339 }
319 340
320 void SetUp() override { 341 void SetUp() override {
321 // Disable network interface reporting since it requires additional setup. 342 // Disable network interface reporting since it requires additional setup.
322 settings_helper_.SetBoolean(chromeos::kReportDeviceNetworkInterfaces, 343 settings_helper_.SetBoolean(chromeos::kReportDeviceNetworkInterfaces,
323 false); 344 false);
324 } 345 }
325 346
326 void TearDown() override { settings_helper_.RestoreProvider(); } 347 void TearDown() override {
348 settings_helper_.RestoreProvider();
349 }
327 350
328 void RestartStatusCollector( 351 void RestartStatusCollector(
329 const policy::DeviceStatusCollector::VolumeInfoFetcher& volume_info, 352 const policy::DeviceStatusCollector::VolumeInfoFetcher& volume_info,
330 const policy::DeviceStatusCollector::CPUStatisticsFetcher& cpu_stats, 353 const policy::DeviceStatusCollector::CPUStatisticsFetcher& cpu_stats,
331 const policy::DeviceStatusCollector::CPUTempFetcher& cpu_temp_fetcher) { 354 const policy::DeviceStatusCollector::CPUTempFetcher& cpu_temp_fetcher) {
332 policy::DeviceStatusCollector::LocationUpdateRequester callback = 355 policy::DeviceStatusCollector::LocationUpdateRequester callback =
333 base::Bind(&MockPositionUpdateRequester); 356 base::Bind(&MockPositionUpdateRequester);
334 std::vector<em::VolumeInfo> expected_volume_info; 357 std::vector<em::VolumeInfo> expected_volume_info;
335 status_collector_.reset(new TestingDeviceStatusCollector( 358 status_collector_.reset(new TestingDeviceStatusCollector(
336 &prefs_, &fake_statistics_provider_, callback, volume_info, cpu_stats, 359 &prefs_, &fake_statistics_provider_, callback, volume_info, cpu_stats,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 void MockRunningKioskApp(const DeviceLocalAccount& account) { 407 void MockRunningKioskApp(const DeviceLocalAccount& account) {
385 std::vector<DeviceLocalAccount> accounts; 408 std::vector<DeviceLocalAccount> accounts;
386 accounts.push_back(account); 409 accounts.push_back(account);
387 SetDeviceLocalAccounts(owner_settings_service_.get(), accounts); 410 SetDeviceLocalAccounts(owner_settings_service_.get(), accounts);
388 user_manager_->CreateKioskAppUser( 411 user_manager_->CreateKioskAppUser(
389 AccountId::FromUserEmail(account.user_id)); 412 AccountId::FromUserEmail(account.user_id));
390 EXPECT_CALL(*user_manager_, IsLoggedInAsKioskApp()).WillRepeatedly( 413 EXPECT_CALL(*user_manager_, IsLoggedInAsKioskApp()).WillRepeatedly(
391 Return(true)); 414 Return(true));
392 } 415 }
393 416
417 void MockPlatformVersion(const std::string& platform_version) {
418 const std::string lsb_release = base::StringPrintf(
419 "CHROMEOS_RELEASE_VERSION=%s", platform_version.c_str());
420 base::SysInfo::SetChromeOSVersionInfoForTest(lsb_release,
421 base::Time::Now());
422 }
423
424 void MockAutoLaunchKioskAppWithRequiredPlatformVersion(
425 const DeviceLocalAccount& auto_launch_app_account,
426 const std::string& required_platform_version) {
427 chromeos::KioskAppManager* manager = chromeos::KioskAppManager::Get();
428 manager->AddAppForTest(
429 auto_launch_app_account.kiosk_app_id,
430 AccountId::FromUserEmail(auto_launch_app_account.user_id),
431 GURL("http://cws/"), // Dummy URL to avoid setup ExtensionsClient.
432 required_platform_version);
433 manager->SetEnableAutoLaunch(true);
434
435 std::vector<DeviceLocalAccount> accounts;
436 accounts.push_back(auto_launch_app_account);
437 SetDeviceLocalAccounts(owner_settings_service_.get(), accounts);
438
439 owner_settings_service_->SetString(
440 chromeos::kAccountsPrefDeviceLocalAccountAutoLoginId,
441 auto_launch_app_account.account_id);
442
443 message_loop_.RunUntilIdle();
444
445 ASSERT_EQ(required_platform_version,
446 manager->GetAutoLaunchAppRequiredPlatformVersion());
447 }
448
394 protected: 449 protected:
395 // Convenience method. 450 // Convenience method.
396 int64_t ActivePeriodMilliseconds() { 451 int64_t ActivePeriodMilliseconds() {
397 return policy::DeviceStatusCollector::kIdlePollIntervalSeconds * 1000; 452 return policy::DeviceStatusCollector::kIdlePollIntervalSeconds * 1000;
398 } 453 }
399 454
400 // Since this is a unit test running in browser_tests we must do additional 455 // 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. 456 // unit test setup and make a TestingBrowserProcess. Must be first member.
402 TestingBrowserProcessInitializer initializer_; 457 TestingBrowserProcessInitializer initializer_;
403 base::MessageLoopForUI message_loop_; 458 base::MessageLoopForUI message_loop_;
404 content::TestBrowserThread ui_thread_; 459 content::TestBrowserThread ui_thread_;
405 content::TestBrowserThread file_thread_; 460 content::TestBrowserThread file_thread_;
406 content::TestBrowserThread io_thread_; 461 content::TestBrowserThread io_thread_;
407 462
408 ScopedStubEnterpriseInstallAttributes install_attributes_; 463 ScopedStubEnterpriseInstallAttributes install_attributes_;
409 TestingPrefServiceSimple prefs_; 464 TestingPrefServiceSimple prefs_;
410 chromeos::system::ScopedFakeStatisticsProvider fake_statistics_provider_; 465 chromeos::system::ScopedFakeStatisticsProvider fake_statistics_provider_;
411 DiskMountManager::MountPointMap mount_point_map_; 466 DiskMountManager::MountPointMap mount_point_map_;
412 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; 467 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_;
413 chromeos::ScopedTestCrosSettings test_cros_settings_; 468 chromeos::ScopedTestCrosSettings test_cros_settings_;
414 chromeos::ScopedCrosSettingsTestHelper settings_helper_; 469 chromeos::ScopedCrosSettingsTestHelper settings_helper_;
415 std::unique_ptr<chromeos::FakeOwnerSettingsService> owner_settings_service_; 470 std::unique_ptr<chromeos::FakeOwnerSettingsService> owner_settings_service_;
416 chromeos::MockUserManager* user_manager_; 471 chromeos::MockUserManager* const user_manager_;
417 chromeos::ScopedUserManagerEnabler user_manager_enabler_; 472 chromeos::ScopedUserManagerEnabler user_manager_enabler_;
418 em::DeviceStatusReportRequest status_; 473 em::DeviceStatusReportRequest status_;
419 std::unique_ptr<TestingDeviceStatusCollector> status_collector_; 474 std::unique_ptr<TestingDeviceStatusCollector> status_collector_;
420 const policy::DeviceLocalAccount fake_device_local_account_; 475 const policy::DeviceLocalAccount fake_device_local_account_;
476 base::ScopedPathOverride user_data_dir_override_;
477 TestingPrefServiceSimple local_state_;
478 chromeos::FakeUpdateEngineClient* const update_engine_client_;
421 }; 479 };
422 480
423 TEST_F(DeviceStatusCollectorTest, AllIdle) { 481 TEST_F(DeviceStatusCollectorTest, AllIdle) {
424 ui::IdleState test_states[] = { 482 ui::IdleState test_states[] = {
425 ui::IDLE_STATE_IDLE, 483 ui::IDLE_STATE_IDLE,
426 ui::IDLE_STATE_IDLE, 484 ui::IDLE_STATE_IDLE,
427 ui::IDLE_STATE_IDLE 485 ui::IDLE_STATE_IDLE
428 }; 486 };
429 settings_helper_.SetBoolean(chromeos::kReportDeviceActivityTimes, true); 487 settings_helper_.SetBoolean(chromeos::kReportDeviceActivityTimes, true);
430 488
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 ASSERT_EQ(1, session_status.installed_apps_size()); 1069 ASSERT_EQ(1, session_status.installed_apps_size());
1012 EXPECT_EQ(kKioskAccountId, session_status.device_local_account_id()); 1070 EXPECT_EQ(kKioskAccountId, session_status.device_local_account_id());
1013 const em::AppStatus app = session_status.installed_apps(0); 1071 const em::AppStatus app = session_status.installed_apps(0);
1014 EXPECT_EQ(kKioskAppId, app.app_id()); 1072 EXPECT_EQ(kKioskAppId, app.app_id());
1015 // Test code just sets the version to the app ID. 1073 // Test code just sets the version to the app ID.
1016 EXPECT_EQ(kKioskAppId, app.extension_version()); 1074 EXPECT_EQ(kKioskAppId, app.extension_version());
1017 EXPECT_FALSE(app.has_status()); 1075 EXPECT_FALSE(app.has_status());
1018 EXPECT_FALSE(app.has_error()); 1076 EXPECT_FALSE(app.has_error());
1019 } 1077 }
1020 1078
1079 TEST_F(DeviceStatusCollectorTest, NoOsUpdateStatusByDefault) {
1080 MockPlatformVersion("1234.0.0");
1081 MockAutoLaunchKioskAppWithRequiredPlatformVersion(fake_device_local_account_,
1082 "1234.0.0");
1083
1084 GetStatus();
1085 EXPECT_FALSE(status_.has_os_update_status());
1086 }
1087
1088 TEST_F(DeviceStatusCollectorTest, ReportOsUpdateStatusUpToDate) {
1089 MockPlatformVersion("1234.0.0");
1090 settings_helper_.SetBoolean(chromeos::kReportOsUpdateStatus, true);
1091
1092 const char* kRequiredPlatformVersions[] = {"1234", "1234.0", "1234.0.0"};
1093
1094 for (size_t i = 0; i < arraysize(kRequiredPlatformVersions); ++i) {
1095 MockAutoLaunchKioskAppWithRequiredPlatformVersion(
1096 fake_device_local_account_, kRequiredPlatformVersions[i]);
1097
1098 GetStatus();
1099 ASSERT_TRUE(status_.has_os_update_status()) << "Required platform version="
1100 << kRequiredPlatformVersions[i];
1101 EXPECT_EQ(em::OsUpdateStatus::OS_UP_TO_DATE,
1102 status_.os_update_status().update_status())
1103 << "Required platform version=" << kRequiredPlatformVersions[i];
1104 EXPECT_EQ(kRequiredPlatformVersions[i],
1105 status_.os_update_status().new_required_platform_version())
1106 << "Required platform version=" << kRequiredPlatformVersions[i];
1107 }
1108 }
1109
1110 TEST_F(DeviceStatusCollectorTest, ReportOsUpdateStatus) {
1111 MockPlatformVersion("1234.0.0");
1112 settings_helper_.SetBoolean(chromeos::kReportOsUpdateStatus, true);
1113 MockAutoLaunchKioskAppWithRequiredPlatformVersion(fake_device_local_account_,
1114 "1235");
1115
1116 chromeos::UpdateEngineClient::Status update_status;
1117 update_status.status = chromeos::UpdateEngineClient::UPDATE_STATUS_IDLE;
1118
1119 GetStatus();
1120 ASSERT_TRUE(status_.has_os_update_status());
1121 EXPECT_EQ(em::OsUpdateStatus::OS_IMAGE_DOWNLOAD_NOT_STARTED,
1122 status_.os_update_status().update_status());
1123
1124 const chromeos::UpdateEngineClient::UpdateStatusOperation kUpdateEngineOps[] =
1125 {
1126 chromeos::UpdateEngineClient::UPDATE_STATUS_DOWNLOADING,
1127 chromeos::UpdateEngineClient::UPDATE_STATUS_VERIFYING,
1128 chromeos::UpdateEngineClient::UPDATE_STATUS_FINALIZING,
1129 };
1130
1131 for (size_t i = 0; i < arraysize(kUpdateEngineOps); ++i) {
1132 update_status.status = kUpdateEngineOps[i];
1133 update_status.new_version = "1235.1.2";
1134 update_engine_client_->PushLastStatus(update_status);
1135
1136 GetStatus();
1137 ASSERT_TRUE(status_.has_os_update_status());
1138 EXPECT_EQ(em::OsUpdateStatus::OS_IMAGE_DOWNLOAD_IN_PROGRESS,
1139 status_.os_update_status().update_status());
1140 EXPECT_EQ("1235.1.2", status_.os_update_status().new_platform_version());
1141 EXPECT_EQ("1235",
1142 status_.os_update_status().new_required_platform_version());
1143 }
1144
1145 update_status.status =
1146 chromeos::UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT;
1147 update_engine_client_->PushLastStatus(update_status);
1148 GetStatus();
1149 ASSERT_TRUE(status_.has_os_update_status());
1150 EXPECT_EQ(em::OsUpdateStatus::OS_UPDATE_NEED_REBOOT,
1151 status_.os_update_status().update_status());
1152 }
1153
1154 TEST_F(DeviceStatusCollectorTest, NoRunningKioskAppByDefault) {
1155 MockPlatformVersion("1234.0.0");
1156 MockAutoLaunchKioskAppWithRequiredPlatformVersion(fake_device_local_account_,
1157 "1234.0.0");
1158 status_collector_->set_kiosk_account(base::WrapUnique(
1159 new policy::DeviceLocalAccount(fake_device_local_account_)));
1160 MockRunningKioskApp(fake_device_local_account_);
1161
1162 GetStatus();
1163 EXPECT_FALSE(status_.has_running_kiosk_app());
1164 }
1165
1166 TEST_F(DeviceStatusCollectorTest, NoRunningKioskAppWhenNotInKioskSession) {
1167 settings_helper_.SetBoolean(chromeos::kReportRunningKioskApp, true);
1168 MockPlatformVersion("1234.0.0");
1169 MockAutoLaunchKioskAppWithRequiredPlatformVersion(fake_device_local_account_,
1170 "1234.0.0");
1171
1172 GetStatus();
1173 EXPECT_FALSE(status_.has_running_kiosk_app());
1174 }
1175
1176 TEST_F(DeviceStatusCollectorTest, ReportRunningKioskApp) {
1177 settings_helper_.SetBoolean(chromeos::kReportRunningKioskApp, true);
1178 MockPlatformVersion("1234.0.0");
1179 MockAutoLaunchKioskAppWithRequiredPlatformVersion(fake_device_local_account_,
1180 "1235");
1181 MockRunningKioskApp(fake_device_local_account_);
1182 status_collector_->set_kiosk_account(base::WrapUnique(
1183 new policy::DeviceLocalAccount(fake_device_local_account_)));
1184
1185 GetStatus();
1186 ASSERT_TRUE(status_.has_running_kiosk_app());
1187 const em::AppStatus app = status_.running_kiosk_app();
1188 EXPECT_EQ(kKioskAppId, app.app_id());
1189 EXPECT_EQ("1235", app.required_platform_version());
1190 EXPECT_FALSE(app.has_status());
1191 EXPECT_FALSE(app.has_error());
1192 }
1193
1021 // Fake device state. 1194 // Fake device state.
1022 struct FakeDeviceData { 1195 struct FakeDeviceData {
1023 const char* device_path; 1196 const char* device_path;
1024 const char* type; 1197 const char* type;
1025 const char* object_path; 1198 const char* object_path;
1026 const char* mac_address; 1199 const char* mac_address;
1027 const char* meid; 1200 const char* meid;
1028 const char* imei; 1201 const char* imei;
1029 int expected_type; // proto enum type value, -1 for not present. 1202 int expected_type; // proto enum type value, -1 for not present.
1030 }; 1203 };
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 AccountId::FromUserEmail(kPublicAccountId)); 1487 AccountId::FromUserEmail(kPublicAccountId));
1315 EXPECT_CALL(*user_manager_, IsLoggedInAsPublicAccount()) 1488 EXPECT_CALL(*user_manager_, IsLoggedInAsPublicAccount())
1316 .WillRepeatedly(Return(true)); 1489 .WillRepeatedly(Return(true));
1317 1490
1318 settings_helper_.SetBoolean(chromeos::kReportDeviceNetworkInterfaces, true); 1491 settings_helper_.SetBoolean(chromeos::kReportDeviceNetworkInterfaces, true);
1319 GetStatus(); 1492 GetStatus();
1320 VerifyNetworkReporting(); 1493 VerifyNetworkReporting();
1321 } 1494 }
1322 1495
1323 } // namespace policy 1496 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698