1 /* 2 * Copyright (C) 2022 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; 17 18 import com.android.tradefed.result.FailureDescription; 19 import com.android.tradefed.result.ITestInvocationListener; 20 import com.android.tradefed.result.TestDescription; 21 22 /** Monitor for any failures from the invocation. */ 23 public class ConditionFailureMonitor implements ITestInvocationListener { 24 25 private boolean mHasFailures = false; 26 private boolean mHasRunFailures = false; 27 hasFailures()28 public boolean hasFailures() { 29 return mHasFailures; 30 } 31 hasRunFailures()32 public boolean hasRunFailures() { 33 return mHasRunFailures; 34 } 35 36 @Override invocationFailed(FailureDescription failure)37 public void invocationFailed(FailureDescription failure) { 38 mHasFailures = true; 39 } 40 41 @Override invocationFailed(Throwable cause)42 public void invocationFailed(Throwable cause) { 43 mHasFailures = true; 44 } 45 46 @Override testRunFailed(FailureDescription failure)47 public void testRunFailed(FailureDescription failure) { 48 mHasFailures = true; 49 mHasRunFailures = true; 50 } 51 52 @Override testRunFailed(String errorMessage)53 public void testRunFailed(String errorMessage) { 54 mHasFailures = true; 55 mHasRunFailures = true; 56 } 57 58 @Override testFailed(TestDescription test, FailureDescription failure)59 public void testFailed(TestDescription test, FailureDescription failure) { 60 mHasFailures = true; 61 mHasRunFailures = true; 62 } 63 64 @Override testFailed(TestDescription test, String trace)65 public void testFailed(TestDescription test, String trace) { 66 mHasFailures = true; 67 mHasRunFailures = true; 68 } 69 } 70