Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/login/enrollment/enrollment_screen.h" | |
| 5 #include "chrome/browser/chromeos/login/enrollment/enterprise_enrollment_helper_ mock.h" | 6 #include "chrome/browser/chromeos/login/enrollment/enterprise_enrollment_helper_ mock.h" |
| 6 #include "chrome/browser/chromeos/login/enrollment/enterprise_enrollment_helper_ impl.h" | 7 #include "chrome/browser/chromeos/login/enrollment/enterprise_enrollment_helper_ impl.h" |
| 8 #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h" | |
| 9 #include "testing/gmock/include/gmock/gmock.h" | |
| 10 #include "testing/gtest/include/gtest/gtest.h" | |
|
xiyuan
2017/02/01 23:01:52
The above two headers are already included in the
| |
| 11 | |
| 12 using testing::Invoke; | |
| 7 | 13 |
| 8 namespace chromeos { | 14 namespace chromeos { |
| 9 | 15 |
| 10 EnterpriseEnrollmentHelperMock::EnterpriseEnrollmentHelperMock( | 16 EnterpriseEnrollmentHelperMock::EnterpriseEnrollmentHelperMock( |
| 11 EnrollmentStatusConsumer* status_consumer) | 17 EnrollmentStatusConsumer* status_consumer) |
| 12 : EnterpriseEnrollmentHelper(status_consumer) {} | 18 : EnterpriseEnrollmentHelper(status_consumer) { |
| 19 ON_CALL(*this, EnrollUsingAttestation()) | |
| 20 .WillByDefault( | |
| 21 Invoke(this, &EnterpriseEnrollmentHelperMock::TryEnrollment)); | |
|
xiyuan
2017/02/01 23:01:52
This probably should be moved to the mock creator
| |
| 22 } | |
| 13 | 23 |
| 14 EnterpriseEnrollmentHelperMock::~EnterpriseEnrollmentHelperMock() {} | 24 EnterpriseEnrollmentHelperMock::~EnterpriseEnrollmentHelperMock() {} |
| 15 | 25 |
| 16 EnterpriseEnrollmentHelper::EnrollmentStatusConsumer* | 26 EnterpriseEnrollmentHelper::EnrollmentStatusConsumer* |
| 17 EnterpriseEnrollmentHelperMock::status_consumer() { | 27 EnterpriseEnrollmentHelperMock::status_consumer() { |
| 18 return EnterpriseEnrollmentHelper::status_consumer(); | 28 return EnterpriseEnrollmentHelper::status_consumer(); |
| 19 } | 29 } |
| 20 | 30 |
| 31 void EnterpriseEnrollmentHelperMock::TryEnrollment() { | |
| 32 if (should_enroll) { | |
| 33 static_cast<EnrollmentScreen*>(status_consumer()) | |
| 34 ->ShowEnrollmentStatusOnSuccess(); | |
| 35 } else { | |
| 36 status_consumer()->OnEnrollmentError(policy::EnrollmentStatus::ForStatus( | |
| 37 policy::EnrollmentStatus::REGISTRATION_FAILED)); | |
| 38 } | |
| 39 } | |
| 40 | |
| 41 bool EnterpriseEnrollmentHelperMock::should_enroll = true; | |
| 42 | |
| 21 } // namespace chromeos | 43 } // namespace chromeos |
| OLD | NEW |