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

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

Issue 1135413002: Disable screenshot uploading if there has been user input. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Self-review Created 5 years, 7 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_cloud_policy_manager_chromeos.h" 5 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 .Times(AtMost(1)) 255 .Times(AtMost(1))
256 .WillOnce(device_management_service_.CreateAsyncJob(&policy_fetch_job)); 256 .WillOnce(device_management_service_.CreateAsyncJob(&policy_fetch_job));
257 EXPECT_CALL(device_management_service_, 257 EXPECT_CALL(device_management_service_,
258 StartJob(dm_protocol::kValueRequestPolicy, _, _, _, _, _, _)) 258 StartJob(dm_protocol::kValueRequestPolicy, _, _, _, _, _, _))
259 .Times(AtMost(1)); 259 .Times(AtMost(1));
260 ConnectManager(); 260 ConnectManager();
261 base::RunLoop().RunUntilIdle(); 261 base::RunLoop().RunUntilIdle();
262 Mock::VerifyAndClearExpectations(&device_management_service_); 262 Mock::VerifyAndClearExpectations(&device_management_service_);
263 ASSERT_TRUE(policy_fetch_job); 263 ASSERT_TRUE(policy_fetch_job);
264 // Should create a status uploader for reporting on enrolled devices. 264 // Should create a status uploader for reporting on enrolled devices.
265 EXPECT_TRUE(manager_->HasStatusUploaderForTest()); 265 EXPECT_TRUE(manager_->GetStatusUploader());
266 VerifyPolicyPopulated(); 266 VerifyPolicyPopulated();
267 267
268 manager_->Shutdown(); 268 manager_->Shutdown();
269 VerifyPolicyPopulated(); 269 VerifyPolicyPopulated();
270 270
271 EXPECT_EQ(store_->policy()->service_account_identity(), 271 EXPECT_EQ(store_->policy()->service_account_identity(),
272 PolicyBuilder::kFakeServiceAccountIdentity); 272 PolicyBuilder::kFakeServiceAccountIdentity);
273 } 273 }
274 274
275 TEST_F(DeviceCloudPolicyManagerChromeOSTest, UnmanagedDevice) { 275 TEST_F(DeviceCloudPolicyManagerChromeOSTest, UnmanagedDevice) {
(...skipping 18 matching lines...) Expand all
294 .WillOnce(device_management_service_.CreateAsyncJob(&policy_fetch_job)); 294 .WillOnce(device_management_service_.CreateAsyncJob(&policy_fetch_job));
295 EXPECT_CALL(device_management_service_, 295 EXPECT_CALL(device_management_service_,
296 StartJob(dm_protocol::kValueRequestPolicy, _, _, _, _, _, _)) 296 StartJob(dm_protocol::kValueRequestPolicy, _, _, _, _, _, _))
297 .Times(AtMost(1)); 297 .Times(AtMost(1));
298 ConnectManager(); 298 ConnectManager();
299 base::RunLoop().RunUntilIdle(); 299 base::RunLoop().RunUntilIdle();
300 Mock::VerifyAndClearExpectations(&device_management_service_); 300 Mock::VerifyAndClearExpectations(&device_management_service_);
301 ASSERT_TRUE(policy_fetch_job); 301 ASSERT_TRUE(policy_fetch_job);
302 // Should create a status provider for reporting on enrolled devices, even 302 // Should create a status provider for reporting on enrolled devices, even
303 // those that aren't managed. 303 // those that aren't managed.
304 EXPECT_TRUE(manager_->HasStatusUploaderForTest()); 304 EXPECT_TRUE(manager_->GetStatusUploader());
305 305
306 // Switch back to ACTIVE, service the policy fetch and let it propagate. 306 // Switch back to ACTIVE, service the policy fetch and let it propagate.
307 device_policy_.policy_data().set_state(em::PolicyData::ACTIVE); 307 device_policy_.policy_data().set_state(em::PolicyData::ACTIVE);
308 device_policy_.Build(); 308 device_policy_.Build();
309 device_settings_test_helper_.set_policy_blob(device_policy_.GetBlob()); 309 device_settings_test_helper_.set_policy_blob(device_policy_.GetBlob());
310 em::DeviceManagementResponse policy_fetch_response; 310 em::DeviceManagementResponse policy_fetch_response;
311 policy_fetch_response.mutable_policy_response()->add_response()->CopyFrom( 311 policy_fetch_response.mutable_policy_response()->add_response()->CopyFrom(
312 device_policy_.policy()); 312 device_policy_.policy());
313 policy_fetch_job->SendResponse(DM_STATUS_SUCCESS, policy_fetch_response); 313 policy_fetch_job->SendResponse(DM_STATUS_SUCCESS, policy_fetch_response);
314 FlushDeviceSettings(); 314 FlushDeviceSettings();
315 315
316 // Policy state should now be active and the policy map should be populated. 316 // Policy state should now be active and the policy map should be populated.
317 EXPECT_TRUE(store_->is_managed()); 317 EXPECT_TRUE(store_->is_managed());
318 VerifyPolicyPopulated(); 318 VerifyPolicyPopulated();
319 } 319 }
320 320
321 TEST_F(DeviceCloudPolicyManagerChromeOSTest, ConsumerDevice) { 321 TEST_F(DeviceCloudPolicyManagerChromeOSTest, ConsumerDevice) {
322 FlushDeviceSettings(); 322 FlushDeviceSettings();
323 EXPECT_EQ(CloudPolicyStore::STATUS_BAD_STATE, store_->status()); 323 EXPECT_EQ(CloudPolicyStore::STATUS_BAD_STATE, store_->status());
324 EXPECT_TRUE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME)); 324 EXPECT_TRUE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME));
325 325
326 PolicyBundle bundle; 326 PolicyBundle bundle;
327 EXPECT_TRUE(manager_->policies().Equals(bundle)); 327 EXPECT_TRUE(manager_->policies().Equals(bundle));
328 328
329 ConnectManager(); 329 ConnectManager();
330 EXPECT_TRUE(manager_->policies().Equals(bundle)); 330 EXPECT_TRUE(manager_->policies().Equals(bundle));
331 // Should not create a status provider for reporting on consumer devices. 331 // Should not create a status provider for reporting on consumer devices.
332 EXPECT_FALSE(manager_->HasStatusUploaderForTest()); 332 EXPECT_FALSE(manager_->GetStatusUploader());
333 333
334 manager_->Shutdown(); 334 manager_->Shutdown();
335 EXPECT_TRUE(manager_->policies().Equals(bundle)); 335 EXPECT_TRUE(manager_->policies().Equals(bundle));
336 } 336 }
337 337
338 TEST_F(DeviceCloudPolicyManagerChromeOSTest, ConnectAndDisconnect) { 338 TEST_F(DeviceCloudPolicyManagerChromeOSTest, ConnectAndDisconnect) {
339 LockDevice(); 339 LockDevice();
340 FlushDeviceSettings(); 340 FlushDeviceSettings();
341 EXPECT_FALSE(manager_->core()->service()); // Not connected. 341 EXPECT_FALSE(manager_->core()->service()); // Not connected.
342 342
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 740
741 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentBlankSystemSaltTest, 741 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentBlankSystemSaltTest,
742 RobotRefreshSaveFailed) { 742 RobotRefreshSaveFailed) {
743 // Without the system salt, the robot token can't be stored. 743 // Without the system salt, the robot token can't be stored.
744 RunTest(); 744 RunTest();
745 ExpectFailedEnrollment(EnrollmentStatus::STATUS_ROBOT_REFRESH_STORE_FAILED); 745 ExpectFailedEnrollment(EnrollmentStatus::STATUS_ROBOT_REFRESH_STORE_FAILED);
746 } 746 }
747 747
748 } // namespace 748 } // namespace
749 } // namespace policy 749 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698