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

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

Issue 907323002: Implemented DeviceStatusCollector::GetDeviceSessionStatus() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge ToT Created 5 years, 10 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 <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/environment.h" 11 #include "base/environment.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/prefs/pref_service.h" 15 #include "base/prefs/pref_service.h"
16 #include "base/prefs/testing_pref_service.h" 16 #include "base/prefs/testing_pref_service.h"
17 #include "base/run_loop.h" 17 #include "base/run_loop.h"
18 #include "base/threading/sequenced_worker_pool.h" 18 #include "base/threading/sequenced_worker_pool.h"
19 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" 19 #include "chrome/browser/chromeos/login/users/mock_user_manager.h"
20 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 20 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
21 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 21 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
22 #include "chrome/browser/chromeos/policy/device_local_account.h"
22 #include "chrome/browser/chromeos/policy/stub_enterprise_install_attributes.h" 23 #include "chrome/browser/chromeos/policy/stub_enterprise_install_attributes.h"
23 #include "chrome/browser/chromeos/settings/cros_settings.h" 24 #include "chrome/browser/chromeos/settings/cros_settings.h"
24 #include "chrome/browser/chromeos/settings/device_settings_service.h" 25 #include "chrome/browser/chromeos/settings/device_settings_service.h"
25 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" 26 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h"
26 #include "chrome/common/pref_names.h" 27 #include "chrome/common/pref_names.h"
27 #include "chrome/test/base/testing_browser_process.h" 28 #include "chrome/test/base/testing_browser_process.h"
28 #include "chromeos/dbus/cros_disks_client.h" 29 #include "chromeos/dbus/cros_disks_client.h"
29 #include "chromeos/dbus/dbus_thread_manager.h" 30 #include "chromeos/dbus/dbus_thread_manager.h"
30 #include "chromeos/dbus/shill_device_client.h" 31 #include "chromeos/dbus/shill_device_client.h"
31 #include "chromeos/dbus/shill_ipconfig_client.h" 32 #include "chromeos/dbus/shill_ipconfig_client.h"
32 #include "chromeos/dbus/shill_service_client.h" 33 #include "chromeos/dbus/shill_service_client.h"
33 #include "chromeos/disks/disk_mount_manager.h" 34 #include "chromeos/disks/disk_mount_manager.h"
34 #include "chromeos/disks/mock_disk_mount_manager.h" 35 #include "chromeos/disks/mock_disk_mount_manager.h"
35 #include "chromeos/network/network_handler.h" 36 #include "chromeos/network/network_handler.h"
36 #include "chromeos/network/network_state.h" 37 #include "chromeos/network/network_state.h"
37 #include "chromeos/network/network_state_handler.h" 38 #include "chromeos/network/network_state_handler.h"
38 #include "chromeos/settings/cros_settings_names.h" 39 #include "chromeos/settings/cros_settings_names.h"
39 #include "chromeos/settings/cros_settings_provider.h" 40 #include "chromeos/settings/cros_settings_provider.h"
40 #include "chromeos/system/fake_statistics_provider.h" 41 #include "chromeos/system/fake_statistics_provider.h"
41 #include "content/public/browser/browser_thread.h" 42 #include "content/public/browser/browser_thread.h"
42 #include "content/public/browser/geolocation_provider.h" 43 #include "content/public/browser/geolocation_provider.h"
43 #include "content/public/test/test_browser_thread.h" 44 #include "content/public/test/test_browser_thread.h"
44 #include "content/public/test/test_utils.h" 45 #include "content/public/test/test_utils.h"
45 #include "policy/proto/device_management_backend.pb.h" 46 #include "policy/proto/device_management_backend.pb.h"
46 #include "testing/gmock/include/gmock/gmock.h" 47 #include "testing/gmock/include/gmock/gmock.h"
47 #include "testing/gtest/include/gtest/gtest.h" 48 #include "testing/gtest/include/gtest/gtest.h"
48 #include "third_party/cros_system_api/dbus/service_constants.h" 49 #include "third_party/cros_system_api/dbus/service_constants.h"
49 50
51 using ::testing::Return;
50 using ::testing::ReturnRef; 52 using ::testing::ReturnRef;
51 using base::Time; 53 using base::Time;
52 using base::TimeDelta; 54 using base::TimeDelta;
53 using chromeos::disks::DiskMountManager; 55 using chromeos::disks::DiskMountManager;
54 56
55 namespace em = enterprise_management; 57 namespace em = enterprise_management;
56 58
57 namespace { 59 namespace {
58 60
59 const int64 kMillisecondsPerDay = Time::kMicrosecondsPerDay / 1000; 61 const int64 kMillisecondsPerDay = Time::kMicrosecondsPerDay / 1000;
62 const char kKioskAccountId[] = "kiosk_user@localhost";
63 const char kKioskAppId[] = "kiosk_app_id";
60 64
61 scoped_ptr<content::Geoposition> mock_position_to_return_next; 65 scoped_ptr<content::Geoposition> mock_position_to_return_next;
62 66
63 void SetMockPositionToReturnNext(const content::Geoposition &position) { 67 void SetMockPositionToReturnNext(const content::Geoposition &position) {
64 mock_position_to_return_next.reset(new content::Geoposition(position)); 68 mock_position_to_return_next.reset(new content::Geoposition(position));
65 } 69 }
66 70
67 void MockPositionUpdateRequester( 71 void MockPositionUpdateRequester(
68 const content::GeolocationProvider::LocationUpdateCallback& callback) { 72 const content::GeolocationProvider::LocationUpdateCallback& callback) {
69 if (!mock_position_to_return_next.get()) 73 if (!mock_position_to_return_next.get())
(...skipping 16 matching lines...) Expand all
86 PrefService* local_state, 90 PrefService* local_state,
87 chromeos::system::StatisticsProvider* provider, 91 chromeos::system::StatisticsProvider* provider,
88 const policy::DeviceStatusCollector::LocationUpdateRequester& 92 const policy::DeviceStatusCollector::LocationUpdateRequester&
89 location_update_requester, 93 location_update_requester,
90 const policy::DeviceStatusCollector::VolumeInfoFetcher& 94 const policy::DeviceStatusCollector::VolumeInfoFetcher&
91 volume_info_fetcher) 95 volume_info_fetcher)
92 : policy::DeviceStatusCollector( 96 : policy::DeviceStatusCollector(
93 local_state, 97 local_state,
94 provider, 98 provider,
95 location_update_requester, 99 location_update_requester,
96 volume_info_fetcher), 100 volume_info_fetcher) {
97 kiosk_mode_(false) { 101
98 // Set the baseline time to a fixed value (1 AM) to prevent test flakiness 102 // Set the baseline time to a fixed value (1 AM) to prevent test flakiness
99 // due to a single activity period spanning two days. 103 // due to a single activity period spanning two days.
100 SetBaselineTime(Time::Now().LocalMidnight() + TimeDelta::FromHours(1)); 104 SetBaselineTime(Time::Now().LocalMidnight() + TimeDelta::FromHours(1));
101 } 105 }
102 106
103 void Simulate(ui::IdleState* states, int len) { 107 void Simulate(ui::IdleState* states, int len) {
104 for (int i = 0; i < len; i++) 108 for (int i = 0; i < len; i++)
105 IdleStateCallback(states[i]); 109 IdleStateCallback(states[i]);
106 } 110 }
107 111
(...skipping 14 matching lines...) Expand all
122 void set_mock_cpu_usage(double total_cpu_usage, int num_processors) { 126 void set_mock_cpu_usage(double total_cpu_usage, int num_processors) {
123 std::vector<double> usage; 127 std::vector<double> usage;
124 for (int i = 0; i < num_processors; ++i) 128 for (int i = 0; i < num_processors; ++i)
125 usage.push_back(total_cpu_usage / num_processors); 129 usage.push_back(total_cpu_usage / num_processors);
126 130
127 mock_cpu_usage_ = usage; 131 mock_cpu_usage_ = usage;
128 132
129 RefreshSampleResourceUsage(); 133 RefreshSampleResourceUsage();
130 } 134 }
131 135
132 void set_kiosk_mode(bool is_kiosk) { 136 void set_kiosk_account(scoped_ptr<policy::DeviceLocalAccount> account) {
133 kiosk_mode_ = is_kiosk; 137 kiosk_account_ = account.Pass();
134 } 138 }
135 139
136 bool IsAutoLaunchedKioskSession() override { 140 scoped_ptr<policy::DeviceLocalAccount>
137 return kiosk_mode_; 141 GetAutoLaunchedKioskSessionInfo() override {
142 if (kiosk_account_)
143 return make_scoped_ptr(new policy::DeviceLocalAccount(*kiosk_account_));
144 return scoped_ptr<policy::DeviceLocalAccount>();
145 }
146
147 std::string GetAppVersion(const std::string& app_id) override {
148 // Just return the app_id as the version - this makes it easy for tests
149 // to confirm that the correct app's version was requested.
150 return app_id;
138 } 151 }
139 152
140 void RefreshSampleResourceUsage() { 153 void RefreshSampleResourceUsage() {
141 // Refresh our samples. Sample more than kMaxHardwareSamples times to 154 // Refresh our samples. Sample more than kMaxHardwareSamples times to
142 // make sure that the code correctly caps the number of cached samples. 155 // make sure that the code correctly caps the number of cached samples.
143 for (int i = 0; i < static_cast<int>(kMaxResourceUsageSamples + 1); ++i) 156 for (int i = 0; i < static_cast<int>(kMaxResourceUsageSamples + 1); ++i)
144 SampleResourceUsage(); 157 SampleResourceUsage();
145 } 158 }
146 159
147 protected: 160 protected:
(...skipping 16 matching lines...) Expand all
164 177
165 private: 178 private:
166 // Baseline time for the fake times returned from GetCurrentTime(). 179 // Baseline time for the fake times returned from GetCurrentTime().
167 Time baseline_time_; 180 Time baseline_time_;
168 181
169 // The number of simulated periods since the baseline time. 182 // The number of simulated periods since the baseline time.
170 int baseline_offset_periods_; 183 int baseline_offset_periods_;
171 184
172 std::vector<double> mock_cpu_usage_; 185 std::vector<double> mock_cpu_usage_;
173 186
174 bool kiosk_mode_; 187 scoped_ptr<policy::DeviceLocalAccount> kiosk_account_;
175 }; 188 };
176 189
177 // Return the total number of active milliseconds contained in a device 190 // Return the total number of active milliseconds contained in a device
178 // status report. 191 // status report.
179 int64 GetActiveMilliseconds(em::DeviceStatusReportRequest& status) { 192 int64 GetActiveMilliseconds(em::DeviceStatusReportRequest& status) {
180 int64 active_milliseconds = 0; 193 int64 active_milliseconds = 0;
181 for (int i = 0; i < status.active_period_size(); i++) { 194 for (int i = 0; i < status.active_period_size(); i++) {
182 active_milliseconds += status.active_period(i).active_duration(); 195 active_milliseconds += status.active_period(i).active_duration();
183 } 196 }
184 return active_milliseconds; 197 return active_milliseconds;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 public: 235 public:
223 DeviceStatusCollectorTest() 236 DeviceStatusCollectorTest()
224 : ui_thread_(content::BrowserThread::UI, &message_loop_), 237 : ui_thread_(content::BrowserThread::UI, &message_loop_),
225 file_thread_(content::BrowserThread::FILE, &message_loop_), 238 file_thread_(content::BrowserThread::FILE, &message_loop_),
226 io_thread_(content::BrowserThread::IO, &message_loop_), 239 io_thread_(content::BrowserThread::IO, &message_loop_),
227 install_attributes_("managed.com", 240 install_attributes_("managed.com",
228 "user@managed.com", 241 "user@managed.com",
229 "device_id", 242 "device_id",
230 DEVICE_MODE_ENTERPRISE), 243 DEVICE_MODE_ENTERPRISE),
231 user_manager_(new chromeos::MockUserManager()), 244 user_manager_(new chromeos::MockUserManager()),
232 user_manager_enabler_(user_manager_) { 245 user_manager_enabler_(user_manager_),
246 fake_local_account_(
247 policy::DeviceLocalAccount::TYPE_KIOSK_APP,
248 kKioskAccountId,
249 kKioskAppId,
250 std::string()) {
bartfab (slow) 2015/02/16 13:30:33 Nit: /* kiosk_app_update_url */
Andrew T Wilson (Slow) 2015/02/17 10:57:25 Done.
233 // Run this test with a well-known timezone so that Time::LocalMidnight() 251 // Run this test with a well-known timezone so that Time::LocalMidnight()
234 // returns the same values on all machines. 252 // returns the same values on all machines.
235 scoped_ptr<base::Environment> env(base::Environment::Create()); 253 scoped_ptr<base::Environment> env(base::Environment::Create());
236 env->SetVar("TZ", "UTC"); 254 env->SetVar("TZ", "UTC");
237 255
238 // Initialize our mock mounted disk volumes. 256 // Initialize our mock mounted disk volumes.
239 scoped_ptr<chromeos::disks::MockDiskMountManager> mock_disk_mount_manager = 257 scoped_ptr<chromeos::disks::MockDiskMountManager> mock_disk_mount_manager =
240 make_scoped_ptr(new chromeos::disks::MockDiskMountManager()); 258 make_scoped_ptr(new chromeos::disks::MockDiskMountManager());
241 AddMountPoint("/mount/volume1"); 259 AddMountPoint("/mount/volume1");
242 AddMountPoint("/mount/volume2"); 260 AddMountPoint("/mount/volume2");
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 351
334 void CheckThatALocationErrorIsReported() { 352 void CheckThatALocationErrorIsReported() {
335 GetStatus(); 353 GetStatus();
336 EXPECT_TRUE(status_.has_device_location()); 354 EXPECT_TRUE(status_.has_device_location());
337 em::DeviceLocation location = status_.device_location(); 355 em::DeviceLocation location = status_.device_location();
338 EXPECT_TRUE(location.has_error_code()); 356 EXPECT_TRUE(location.has_error_code());
339 EXPECT_EQ(em::DeviceLocation::ERROR_CODE_POSITION_UNAVAILABLE, 357 EXPECT_EQ(em::DeviceLocation::ERROR_CODE_POSITION_UNAVAILABLE,
340 location.error_code()); 358 location.error_code());
341 } 359 }
342 360
361 void MockRunningKioskApp(const DeviceLocalAccount& account) {
362 std::vector<DeviceLocalAccount> accounts;
363 accounts.push_back(account);
364 SetDeviceLocalAccounts(cros_settings_, accounts);
365 user_manager_->CreateKioskAppUser(account.user_id);
366 EXPECT_CALL(*user_manager_, IsLoggedInAsKioskApp()).WillRepeatedly(
367 Return(true));
368 }
369
343 protected: 370 protected:
344 // Convenience method. 371 // Convenience method.
345 int64 ActivePeriodMilliseconds() { 372 int64 ActivePeriodMilliseconds() {
346 return policy::DeviceStatusCollector::kIdlePollIntervalSeconds * 1000; 373 return policy::DeviceStatusCollector::kIdlePollIntervalSeconds * 1000;
347 } 374 }
348 375
349 // Since this is a unit test running in browser_tests we must do additional 376 // Since this is a unit test running in browser_tests we must do additional
350 // unit test setup and make a TestingBrowserProcess. Must be first member. 377 // unit test setup and make a TestingBrowserProcess. Must be first member.
351 TestingBrowserProcessInitializer initializer_; 378 TestingBrowserProcessInitializer initializer_;
352 base::MessageLoopForUI message_loop_; 379 base::MessageLoopForUI message_loop_;
353 content::TestBrowserThread ui_thread_; 380 content::TestBrowserThread ui_thread_;
354 content::TestBrowserThread file_thread_; 381 content::TestBrowserThread file_thread_;
355 content::TestBrowserThread io_thread_; 382 content::TestBrowserThread io_thread_;
356 383
357 ScopedStubEnterpriseInstallAttributes install_attributes_; 384 ScopedStubEnterpriseInstallAttributes install_attributes_;
358 TestingPrefServiceSimple prefs_; 385 TestingPrefServiceSimple prefs_;
359 chromeos::system::ScopedFakeStatisticsProvider fake_statistics_provider_; 386 chromeos::system::ScopedFakeStatisticsProvider fake_statistics_provider_;
360 DiskMountManager::MountPointMap mount_point_map_; 387 DiskMountManager::MountPointMap mount_point_map_;
361 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; 388 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_;
362 chromeos::ScopedTestCrosSettings test_cros_settings_; 389 chromeos::ScopedTestCrosSettings test_cros_settings_;
363 chromeos::CrosSettings* cros_settings_; 390 chromeos::CrosSettings* cros_settings_;
364 chromeos::CrosSettingsProvider* device_settings_provider_; 391 chromeos::CrosSettingsProvider* device_settings_provider_;
365 chromeos::StubCrosSettingsProvider stub_settings_provider_; 392 chromeos::StubCrosSettingsProvider stub_settings_provider_;
366 chromeos::MockUserManager* user_manager_; 393 chromeos::MockUserManager* user_manager_;
367 chromeos::ScopedUserManagerEnabler user_manager_enabler_; 394 chromeos::ScopedUserManagerEnabler user_manager_enabler_;
368 em::DeviceStatusReportRequest status_; 395 em::DeviceStatusReportRequest status_;
369 scoped_ptr<TestingDeviceStatusCollector> status_collector_; 396 scoped_ptr<TestingDeviceStatusCollector> status_collector_;
397 const policy::DeviceLocalAccount fake_local_account_;
bartfab (slow) 2015/02/16 13:30:33 Nit: s/local/device_local/
Andrew T Wilson (Slow) 2015/02/17 10:57:25 Done.
370 }; 398 };
371 399
372 TEST_F(DeviceStatusCollectorTest, AllIdle) { 400 TEST_F(DeviceStatusCollectorTest, AllIdle) {
373 ui::IdleState test_states[] = { 401 ui::IdleState test_states[] = {
374 ui::IDLE_STATE_IDLE, 402 ui::IDLE_STATE_IDLE,
375 ui::IDLE_STATE_IDLE, 403 ui::IDLE_STATE_IDLE,
376 ui::IDLE_STATE_IDLE 404 ui::IDLE_STATE_IDLE
377 }; 405 };
378 cros_settings_->SetBoolean(chromeos::kReportDeviceActivityTimes, true); 406 cros_settings_->SetBoolean(chromeos::kReportDeviceActivityTimes, true);
379 407
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 status_.cpu_utilization_pct().size()); 862 status_.cpu_utilization_pct().size());
835 for (const auto utilization : status_.cpu_utilization_pct()) 863 for (const auto utilization : status_.cpu_utilization_pct())
836 EXPECT_EQ(idle_cpu_usage, utilization); 864 EXPECT_EQ(idle_cpu_usage, utilization);
837 865
838 // Turning off hardware reporting should not report CPU utilization. 866 // Turning off hardware reporting should not report CPU utilization.
839 cros_settings_->SetBoolean(chromeos::kReportDeviceHardwareStatus, false); 867 cros_settings_->SetBoolean(chromeos::kReportDeviceHardwareStatus, false);
840 GetStatus(); 868 GetStatus();
841 EXPECT_EQ(0, status_.cpu_utilization_pct().size()); 869 EXPECT_EQ(0, status_.cpu_utilization_pct().size());
842 } 870 }
843 871
872 TEST_F(DeviceStatusCollectorTest, NoSessionStatusIfNotKioskMode) {
873 // Should not report session status if we don't have an active kiosk app.
874 cros_settings_->SetBoolean(chromeos::kReportDeviceSessionStatus, true);
875 status_collector_->set_kiosk_account(
bartfab (slow) 2015/02/16 13:30:33 Nit: This is unnecessary. status_collector_->kiosk
Andrew T Wilson (Slow) 2015/02/17 10:57:25 Done.
876 scoped_ptr<policy::DeviceLocalAccount>());
877 em::SessionStatusReportRequest session_status;
878 EXPECT_FALSE(status_collector_->GetDeviceSessionStatus(&session_status));
879 }
880
881 TEST_F(DeviceStatusCollectorTest, NoSessionStatusIfSessionReportingDisabled) {
882 // Should not report session status if session status reporting is disabled.
883 cros_settings_->SetBoolean(chromeos::kReportDeviceSessionStatus, false);
884 status_collector_->set_kiosk_account(make_scoped_ptr(
885 new policy::DeviceLocalAccount(fake_local_account_)).Pass());
886 // Setup a device-local account for single-app kiosk mode.
bartfab (slow) 2015/02/16 13:30:33 Nit: s/Setup/Set up/
Andrew T Wilson (Slow) 2015/02/17 10:57:25 Done.
887 MockRunningKioskApp(fake_local_account_);
888
889 em::SessionStatusReportRequest session_status;
890 EXPECT_FALSE(status_collector_->GetDeviceSessionStatus(&session_status));
891 }
892
893 TEST_F(DeviceStatusCollectorTest, ReportSessionStatus) {
894 cros_settings_->SetBoolean(chromeos::kReportDeviceSessionStatus, true);
895 status_collector_->set_kiosk_account(make_scoped_ptr(
896 new policy::DeviceLocalAccount(fake_local_account_)).Pass());
897
898 // Setup a device-local account for single-app kiosk mode.
bartfab (slow) 2015/02/16 13:30:33 Nit: s/Setup/Set up/
Andrew T Wilson (Slow) 2015/02/17 10:57:25 Done.
899 MockRunningKioskApp(fake_local_account_);
900
901 em::SessionStatusReportRequest session_status;
902 EXPECT_TRUE(status_collector_->GetDeviceSessionStatus(&session_status));
903 ASSERT_EQ(1, session_status.installed_apps_size());
904 EXPECT_EQ(kKioskAccountId, session_status.device_local_account_id());
905 const em::AppStatus app = session_status.installed_apps(0);
906 EXPECT_EQ(kKioskAppId, app.app_id());
907 // Test code just sets the version to the app ID.
908 EXPECT_EQ(kKioskAppId, app.extension_version());
909 EXPECT_FALSE(app.has_status());
910 EXPECT_FALSE(app.has_error());
911 }
912
844 // Fake device state. 913 // Fake device state.
845 struct FakeDeviceData { 914 struct FakeDeviceData {
846 const char* device_path; 915 const char* device_path;
847 const char* type; 916 const char* type;
848 const char* object_path; 917 const char* object_path;
849 const char* mac_address; 918 const char* mac_address;
850 const char* meid; 919 const char* meid;
851 const char* imei; 920 const char* imei;
852 int expected_type; // proto enum type value, -1 for not present. 921 int expected_type; // proto enum type value, -1 for not present.
853 }; 922 };
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 TEST_F(DeviceStatusCollectorNetworkInterfacesTest, NoNetworkStateIfNotKiosk) { 1108 TEST_F(DeviceStatusCollectorNetworkInterfacesTest, NoNetworkStateIfNotKiosk) {
1040 // If not in an active kiosk session, there should be network interfaces 1109 // If not in an active kiosk session, there should be network interfaces
1041 // reported, but no network state. 1110 // reported, but no network state.
1042 GetStatus(); 1111 GetStatus();
1043 EXPECT_LT(0, status_.network_interface_size()); 1112 EXPECT_LT(0, status_.network_interface_size());
1044 EXPECT_EQ(0, status_.network_state_size()); 1113 EXPECT_EQ(0, status_.network_state_size());
1045 } 1114 }
1046 1115
1047 TEST_F(DeviceStatusCollectorNetworkInterfacesTest, NetworkInterfaces) { 1116 TEST_F(DeviceStatusCollectorNetworkInterfacesTest, NetworkInterfaces) {
1048 // Mock that we are in kiosk mode so we report network state. 1117 // Mock that we are in kiosk mode so we report network state.
1049 status_collector_->set_kiosk_mode(true); 1118 status_collector_->set_kiosk_account(make_scoped_ptr(
1119 new policy::DeviceLocalAccount(fake_local_account_)).Pass());
1050 1120
1051 // Interfaces should be reported by default. 1121 // Interfaces should be reported by default.
1052 GetStatus(); 1122 GetStatus();
1053 EXPECT_LT(0, status_.network_interface_size()); 1123 EXPECT_LT(0, status_.network_interface_size());
1054 EXPECT_LT(0, status_.network_state_size()); 1124 EXPECT_LT(0, status_.network_state_size());
1055 1125
1056 // No interfaces should be reported if the policy is off. 1126 // No interfaces should be reported if the policy is off.
1057 cros_settings_->SetBoolean(chromeos::kReportDeviceNetworkInterfaces, false); 1127 cros_settings_->SetBoolean(chromeos::kReportDeviceNetworkInterfaces, false);
1058 GetStatus(); 1128 GetStatus();
1059 EXPECT_EQ(0, status_.network_interface_size()); 1129 EXPECT_EQ(0, status_.network_interface_size());
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 found_match = true; 1187 found_match = true;
1118 break; 1188 break;
1119 } 1189 }
1120 } 1190 }
1121 EXPECT_TRUE(found_match) << "No matching state for fake network " 1191 EXPECT_TRUE(found_match) << "No matching state for fake network "
1122 << " (" << state.name << ")"; 1192 << " (" << state.name << ")";
1123 } 1193 }
1124 } 1194 }
1125 1195
1126 } // namespace policy 1196 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698