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