Similar to a target preparer, a multi-target preparer allows setup of multiple devices together. For example, this would be used when connecting two devices with Bluetooth for testing.
Base interface
The base interface is
IMultiTargetPreparer
,
which allows implementing a setUp
method to be executed. We recommend
implementing our basic abstract class
BaseMultiTargetPreparer
,
which provides a built-in disablement feature to easily disable a preparer.
Multi-target preparers also directly provide a tearDown
method for any cleanup
operation.
Recommendation
We recommend limiting each preparer to a single main function. This allows for easier reuse of preparers.
Also check the list of available preparers before adding a new one, to
avoid duplicating work. Preparers are available in
tools/tradefederation/core/src/com/android/tradefed/targetprep/multi/
.
There's no limit to the number of devices that a multi-target preparer can
set up. All the devices are available in IInvocationContext
of the
interface to implement.
XML configuration
The object tag is multi_target_preparer
, for example:
<multi_target_preparer class="com.android.tradefed.targetprep.multi.HelloWorldMultiTargetPreparer">
</multi_target_preparer>
Operation order
multi_target_preparer
executessetUp
aftertarget_preparer
.multi_target_preparer
executestearDown
before target cleaners.
This doesn't always allow for performance of all setup steps, so it's possible
in the XML to define the multi-target preparer as multi_pre_target_preparer
and execute it before target_preparer
instances.
<multi_pre_target_preparer class="com.android.tradefed.targetprep.multi.HelloWorldMultiTargetPreparer">
</multi_pre_target_preparer>
The overall operation order is as followed:
multi_pre_target_preparer setUp
target_preparer setUp
multi_target_preparer setUp
multi_target_preparer tearDown
target_preparer tearDown
multi_pre_target_preparer tearDown
Any multi-target preparer can be declared as multi_target_preparer
or
multi_pre_target_preparer
depending of what order of setup is required.