| /* |
| * Copyright (C) 2019 The Android Open Source Project |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| |
| package com.android.tests.rollback.host; |
| |
| import static org.junit.Assert.assertTrue; |
| |
| import com.android.tradefed.testtype.DeviceJUnit4ClassRunner; |
| import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test; |
| |
| import org.junit.Test; |
| import org.junit.runner.RunWith; |
| |
| /** |
| * Runs the staged rollback tests. |
| */ |
| @RunWith(DeviceJUnit4ClassRunner.class) |
| public class StagedRollbackTest extends BaseHostJUnit4Test { |
| |
| /** |
| * Runs the given phase of a test by calling into the device. |
| * Throws an exception if the test phase fails. |
| * <p> |
| * For example, <code>runPhase("testApkOnlyEnableRollback");</code> |
| */ |
| private void runPhase(String phase) throws Exception { |
| assertTrue(runDeviceTests("com.android.tests.rollback", |
| "com.android.tests.rollback.StagedRollbackTest", |
| phase)); |
| } |
| |
| /** |
| * Tests staged rollbacks involving only apks. |
| */ |
| @Test |
| public void testApkOnly() throws Exception { |
| runPhase("testApkOnlyEnableRollback"); |
| getDevice().reboot(); |
| runPhase("testApkOnlyCommitRollback"); |
| getDevice().reboot(); |
| runPhase("testApkOnlyConfirmRollback"); |
| } |
| |
| /** |
| * Tests staged rollbacks involving only apex. |
| */ |
| @Test |
| public void testApexOnly() throws Exception { |
| runPhase("testApexOnlyPrepareApex"); |
| getDevice().reboot(); |
| runPhase("testApexOnlyEnableRollback"); |
| getDevice().reboot(); |
| runPhase("testApexOnlyCommitRollback"); |
| getDevice().reboot(); |
| runPhase("testApexOnlyConfirmRollback"); |
| } |
| } |