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

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

Issue 2782553004: Move TestingPrefService to use unique_ptr<Value> (Closed)
Patch Set: comments Created 3 years, 8 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/auto_enrollment_client.h" 5 #include "chrome/browser/chromeos/policy/auto_enrollment_client.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ptr_util.h"
12 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
13 #include "base/run_loop.h" 14 #include "base/run_loop.h"
14 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
15 #include "base/threading/thread_task_runner_handle.h" 16 #include "base/threading/thread_task_runner_handle.h"
16 #include "base/values.h" 17 #include "base/values.h"
17 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/chromeos/policy/server_backed_device_state.h" 19 #include "chrome/browser/chromeos/policy/server_backed_device_state.h"
19 #include "chrome/common/pref_names.h" 20 #include "chrome/common/pref_names.h"
20 #include "chrome/test/base/scoped_testing_local_state.h" 21 #include "chrome/test/base/scoped_testing_local_state.h"
21 #include "chrome/test/base/testing_browser_process.h" 22 #include "chrome/test/base/testing_browser_process.h"
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 VerifyServerBackedState("example.com", 420 VerifyServerBackedState("example.com",
420 kDeviceStateRestoreModeReEnrollmentEnforced, 421 kDeviceStateRestoreModeReEnrollmentEnforced,
421 kDisabledMessage); 422 kDisabledMessage);
422 } 423 }
423 424
424 TEST_F(AutoEnrollmentClientTest, ReuseCachedDecision) { 425 TEST_F(AutoEnrollmentClientTest, ReuseCachedDecision) {
425 // No bucket download requests should be issued. 426 // No bucket download requests should be issued.
426 EXPECT_CALL(*service_, 427 EXPECT_CALL(*service_,
427 CreateJob(DeviceManagementRequestJob::TYPE_AUTO_ENROLLMENT, _)) 428 CreateJob(DeviceManagementRequestJob::TYPE_AUTO_ENROLLMENT, _))
428 .Times(0); 429 .Times(0);
429 local_state_->SetUserPref(prefs::kShouldAutoEnroll, new base::Value(true)); 430 local_state_->SetUserPref(prefs::kShouldAutoEnroll,
431 base::MakeUnique<base::Value>(true));
430 local_state_->SetUserPref(prefs::kAutoEnrollmentPowerLimit, 432 local_state_->SetUserPref(prefs::kAutoEnrollmentPowerLimit,
431 new base::Value(8)); 433 base::MakeUnique<base::Value>(8));
432 434
433 // Note that device state will be retrieved every time, regardless of any 435 // Note that device state will be retrieved every time, regardless of any
434 // cached information. This is intentional, the idea is that device state on 436 // cached information. This is intentional, the idea is that device state on
435 // the server may change. 437 // the server may change.
436 ServerWillSendState( 438 ServerWillSendState(
437 "example.com", 439 "example.com",
438 em::DeviceStateRetrievalResponse::RESTORE_MODE_REENROLLMENT_ENFORCED, 440 em::DeviceStateRetrievalResponse::RESTORE_MODE_REENROLLMENT_ENFORCED,
439 kDisabledMessage); 441 kDisabledMessage);
440 442
441 client_->Start(); 443 client_->Start();
442 EXPECT_EQ(AUTO_ENROLLMENT_STATE_TRIGGER_ENROLLMENT, state_); 444 EXPECT_EQ(AUTO_ENROLLMENT_STATE_TRIGGER_ENROLLMENT, state_);
443 VerifyServerBackedState("example.com", 445 VerifyServerBackedState("example.com",
444 kDeviceStateRestoreModeReEnrollmentEnforced, 446 kDeviceStateRestoreModeReEnrollmentEnforced,
445 kDisabledMessage); 447 kDisabledMessage);
446 } 448 }
447 449
448 TEST_F(AutoEnrollmentClientTest, RetryIfPowerLargerThanCached) { 450 TEST_F(AutoEnrollmentClientTest, RetryIfPowerLargerThanCached) {
449 local_state_->SetUserPref(prefs::kShouldAutoEnroll, new base::Value(false)); 451 local_state_->SetUserPref(prefs::kShouldAutoEnroll,
452 base::MakeUnique<base::Value>(false));
450 local_state_->SetUserPref(prefs::kAutoEnrollmentPowerLimit, 453 local_state_->SetUserPref(prefs::kAutoEnrollmentPowerLimit,
451 new base::Value(8)); 454 base::MakeUnique<base::Value>(8));
452 CreateClient(kStateKey, 5, 10); 455 CreateClient(kStateKey, 5, 10);
453 ServerWillReply(-1, true, true); 456 ServerWillReply(-1, true, true);
454 ServerWillSendState( 457 ServerWillSendState(
455 "example.com", 458 "example.com",
456 em::DeviceStateRetrievalResponse::RESTORE_MODE_REENROLLMENT_ENFORCED, 459 em::DeviceStateRetrievalResponse::RESTORE_MODE_REENROLLMENT_ENFORCED,
457 kDisabledMessage); 460 kDisabledMessage);
458 client_->Start(); 461 client_->Start();
459 EXPECT_EQ(AUTO_ENROLLMENT_STATE_TRIGGER_ENROLLMENT, state_); 462 EXPECT_EQ(AUTO_ENROLLMENT_STATE_TRIGGER_ENROLLMENT, state_);
460 VerifyServerBackedState("example.com", 463 VerifyServerBackedState("example.com",
461 kDeviceStateRestoreModeReEnrollmentEnforced, 464 kDeviceStateRestoreModeReEnrollmentEnforced,
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 EXPECT_EQ(AUTO_ENROLLMENT_STATE_TRIGGER_ENROLLMENT, state_); 616 EXPECT_EQ(AUTO_ENROLLMENT_STATE_TRIGGER_ENROLLMENT, state_);
614 EXPECT_TRUE(HasCachedDecision()); 617 EXPECT_TRUE(HasCachedDecision());
615 VerifyServerBackedState("example.com", 618 VerifyServerBackedState("example.com",
616 kDeviceStateRestoreModeReEnrollmentEnforced, 619 kDeviceStateRestoreModeReEnrollmentEnforced,
617 kDisabledMessage); 620 kDisabledMessage);
618 Mock::VerifyAndClearExpectations(service_.get()); 621 Mock::VerifyAndClearExpectations(service_.get());
619 } 622 }
620 623
621 } // namespace 624 } // namespace
622 } // namespace policy 625 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698