1 /* 2 * Copyright (C) 2017 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.device.metric; 17 18 import com.android.tradefed.invoker.IInvocationContext; 19 import com.android.tradefed.result.ITestInvocationListener; 20 import com.android.tradefed.testtype.IRemoteTest; 21 import com.android.tradefed.testtype.suite.ITestSuite; 22 23 import java.util.List; 24 25 /** 26 * Interface for {@link IRemoteTest}s to implement if they need to get the list of {@link 27 * IMetricCollector}s for the test run. 28 * 29 * <p>Tests implementing this interface will not have their default {@link ITestInvocationListener} 30 * instrumented with the collectors, they will have to do it themselves via {@link 31 * IMetricCollector#init(IInvocationContext, ITestInvocationListener)}. 32 * 33 * <p>Some tests mechanisms involved buffering Tradefed callbacks and replaying it at the end (like 34 * in {@link ITestSuite}), such mechanism would results in the collectors being called during the 35 * replay and not during the actual execution. By letting tests runner handle when to use the 36 * collectors we can ensure the callbacks being handled at the proper time. 37 * 38 * <pre>In order to use the collectors, the following pattern can be used: 39 * for (IMetricCollector collector : config.getMetricCollectors()) { 40 * originalCollector = collector.init(mModuleInvocationContext, originalCollector); 41 * } 42 * </pre> 43 * 44 * The originalCollector will have all the metric collector wrapped around it to be called in 45 * sequence. 46 * 47 * @see IMetricCollector#init(IInvocationContext, ITestInvocationListener) 48 */ 49 public interface IMetricCollectorReceiver { 50 51 /** Sets the list of {@link IMetricCollector}s defined for the test run. */ setMetricCollectors(List<IMetricCollector> collectors)52 public void setMetricCollectors(List<IMetricCollector> collectors); 53 } 54