• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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 package com.android.cuttlefish.tests;
17 
18 import static org.junit.Assert.assertEquals;
19 
20 import com.android.tradefed.device.DeviceNotAvailableException;
21 import com.android.tradefed.device.ITestDevice;
22 
23 public class FactoryResetUtils {
24 
25     private static final String TMP_GUEST_FILE_PATH = "/data/check_factory_reset.txt";
26 
createTemporaryGuestFile(ITestDevice device)27     public static void createTemporaryGuestFile(ITestDevice device)
28             throws DeviceNotAvailableException {
29         device.enableAdbRoot();
30         device.executeShellV2Command("touch " + TMP_GUEST_FILE_PATH);
31 
32         assertTemporaryGuestFileExists(device, true);
33     }
34 
assertTemporaryGuestFileExists(ITestDevice device, boolean exists)35     public static void assertTemporaryGuestFileExists(ITestDevice device, boolean exists)
36             throws DeviceNotAvailableException {
37         assertEquals(
38                 String.format(
39                         "Expected file %s %s",
40                         TMP_GUEST_FILE_PATH,
41                         (exists ? "exists" : "not exists")),
42                 exists,
43                 device.doesFileExist(TMP_GUEST_FILE_PATH));
44     }
45 }
46