• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 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.targetprep.multi;
17 
18 import com.android.tradefed.device.DeviceNotAvailableException;
19 import com.android.tradefed.invoker.IInvocationContext;
20 import com.android.tradefed.targetprep.BuildError;
21 import com.android.tradefed.targetprep.ITargetPreparer;
22 import com.android.tradefed.targetprep.TargetSetupError;
23 import com.android.tradefed.util.IDisableable;
24 
25 /**
26  * Prepares the test environment for several devices together. Only use for a setup that requires
27  * multiple devices, otherwise use the regular {@link ITargetPreparer} on each device.
28  *
29  * <p>Note that multiple {@link IMultiTargetPreparer}s can be specified in a configuration. It is
30  * recommended that each IMultiTargetPreparer clearly document its expected environment pre-setup
31  * and post-setUp.
32  */
33 public interface IMultiTargetPreparer extends IDisableable {
34 
35     /**
36      * Perform the targets setup for testing.
37      *
38      * @param context the {@link IInvocationContext} describing the invocation, devices, builds.
39      * @throws TargetSetupError if fatal error occurred setting up environment
40      * @throws DeviceNotAvailableException if device became unresponsive
41      */
setUp(IInvocationContext context)42     public void setUp(IInvocationContext context) throws TargetSetupError,
43             BuildError, DeviceNotAvailableException;
44 
45 
46     /**
47      * Perform the targets cleanup/teardown after testing.
48      *
49      * @param context the {@link IInvocationContext} describing the invocation, devices, builds.
50      * @param e if the invocation ended with an exception, this will be the exception that was
51      *        caught at the Invocation level.  Otherwise, will be <code>null</code>.
52      * @throws DeviceNotAvailableException if device became unresponsive
53      */
tearDown(IInvocationContext context, Throwable e)54     public default void tearDown(IInvocationContext context, Throwable e)
55             throws DeviceNotAvailableException {
56         // default do nothing.
57     }
58 }