1 /* 2 * Copyright (C) 2018 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.invoker.shard; 17 18 import com.android.tradefed.device.DeviceNotAvailableException; 19 import com.android.tradefed.invoker.shard.token.ITokenRequest; 20 import com.android.tradefed.invoker.shard.token.TokenProperty; 21 import com.android.tradefed.metrics.proto.MetricMeasurement.Metric; 22 import com.android.tradefed.result.ITestInvocationListener; 23 import com.android.tradefed.result.TestDescription; 24 import com.android.tradefed.testtype.IRemoteTest; 25 import com.android.tradefed.testtype.IReportNotExecuted; 26 27 import java.util.HashSet; 28 import java.util.LinkedHashMap; 29 import java.util.Set; 30 31 /** Test class that implements {@link ITokenRequest}. */ 32 public class TokenTestClass implements IRemoteTest, ITokenRequest, IReportNotExecuted { 33 34 @Override getRequiredTokens()35 public Set<TokenProperty> getRequiredTokens() { 36 Set<TokenProperty> props = new HashSet<>(); 37 props.add(TokenProperty.SIM_CARD); 38 return props; 39 } 40 41 @Override run(ITestInvocationListener listener)42 public void run(ITestInvocationListener listener) throws DeviceNotAvailableException { 43 listener.testRunStarted("TestToken", 1); 44 TestDescription testId = new TestDescription("StubToken", "MethodToken"); 45 listener.testStarted(testId); 46 listener.testEnded(testId, new LinkedHashMap<String, Metric>()); 47 listener.testRunEnded(500, new LinkedHashMap<String, Metric>()); 48 } 49 50 @Override reportNotExecuted(ITestInvocationListener listener, String message)51 public void reportNotExecuted(ITestInvocationListener listener, String message) { 52 listener.testFailed(new TestDescription("token.class", "token.test"), message); 53 } 54 } 55