1 /*
2  * Copyright (C) 2021 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.tradefed.suite.checker;
17 
18 import static org.junit.Assert.assertEquals;
19 
20 import com.android.tradefed.device.TestDevice;
21 import com.android.tradefed.device.ITestDevice;
22 import com.android.tradefed.suite.checker.StatusCheckerResult.CheckStatus;
23 import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
24 import com.android.tradefed.testtype.IDeviceTest;
25 
26 import org.junit.Before;
27 import org.junit.Test;
28 import org.junit.runner.RunWith;
29 
30 /** Functional tests for the {@link ITestDevice} user management APIs */
31 @RunWith(DeviceJUnit4ClassRunner.class)
32 public class ActivityStatusCheckerFuncTest implements IDeviceTest {
33     private TestDevice mTestDevice;
34     private ActivityStatusChecker mChecker;
35 
36     @Override
setDevice(ITestDevice device)37     public void setDevice(ITestDevice device) {
38         mTestDevice = (TestDevice) device;
39     }
40 
41     @Override
getDevice()42     public ITestDevice getDevice() {
43         return mTestDevice;
44     }
45 
46     @Before
setUp()47     public void setUp() throws Exception {
48         // Ensure at set-up that the device is available.
49         mTestDevice.waitForDeviceAvailable();
50         mChecker = new ActivityStatusChecker();
51     }
52 
53     /** Tests the postExecutionCheck method which calls private method isFrontActivityLauncher */
54     @Test
testPostExecutionCheck()55     public void testPostExecutionCheck() throws Exception {
56         assertEquals(CheckStatus.SUCCESS, mChecker.postExecutionCheck(mTestDevice).getStatus());
57     }
58 }
59