1 //
2 // Copyright (C) 2020 The Android Open Source Project
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #include <memory>
18
19 #include "update_engine/update_manager/enterprise_rollback_policy_impl.h"
20 #include "update_engine/update_manager/policy_test_utils.h"
21 #include "update_engine/update_manager/weekly_time.h"
22
23 using chromeos_update_engine::ErrorCode;
24 using chromeos_update_engine::InstallPlan;
25
26 namespace chromeos_update_manager {
27
28 class UmEnterpriseRollbackPolicyImplTest : public UmPolicyTestBase {
29 protected:
UmEnterpriseRollbackPolicyImplTest()30 UmEnterpriseRollbackPolicyImplTest() {
31 policy_ = std::make_unique<EnterpriseRollbackPolicyImpl>();
32 }
33 };
34
TEST_F(UmEnterpriseRollbackPolicyImplTest,ContinueWhenUpdateIsNotEnterpriseRollback)35 TEST_F(UmEnterpriseRollbackPolicyImplTest,
36 ContinueWhenUpdateIsNotEnterpriseRollback) {
37 InstallPlan install_plan{.is_rollback = false};
38 ErrorCode result;
39 ExpectPolicyStatus(EvalStatus::kContinue,
40 &Policy::UpdateCanBeApplied,
41 &result,
42 &install_plan);
43 }
44
TEST_F(UmEnterpriseRollbackPolicyImplTest,SuccessWhenUpdateIsEnterpriseRollback)45 TEST_F(UmEnterpriseRollbackPolicyImplTest,
46 SuccessWhenUpdateIsEnterpriseRollback) {
47 InstallPlan install_plan{.is_rollback = true};
48 ErrorCode result;
49 ExpectPolicyStatus(EvalStatus::kSucceeded,
50 &Policy::UpdateCanBeApplied,
51 &result,
52 &install_plan);
53 EXPECT_EQ(result, ErrorCode::kSuccess);
54 }
55
56 } // namespace chromeos_update_manager
57