mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-16 02:47:17 +01:00
125 lines
3.6 KiB
Java
125 lines
3.6 KiB
Java
package junit.framework;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
import java.util.Enumeration;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
/* loaded from: classes10.dex */
|
|
public class TestResult {
|
|
protected List<TestFailure> fFailures = new ArrayList();
|
|
protected List<TestFailure> fErrors = new ArrayList();
|
|
protected List<TestListener> fListeners = new ArrayList();
|
|
protected int fRunTests = 0;
|
|
private boolean fStop = false;
|
|
|
|
private synchronized List<TestListener> cloneListeners() {
|
|
ArrayList arrayList;
|
|
arrayList = new ArrayList();
|
|
arrayList.addAll(this.fListeners);
|
|
return arrayList;
|
|
}
|
|
|
|
public synchronized void addError(Test test, Throwable th) {
|
|
this.fErrors.add(new TestFailure(test, th));
|
|
Iterator<TestListener> it2 = cloneListeners().iterator();
|
|
while (it2.hasNext()) {
|
|
it2.next().addError(test, th);
|
|
}
|
|
}
|
|
|
|
public synchronized void addFailure(Test test, AssertionFailedError assertionFailedError) {
|
|
this.fFailures.add(new TestFailure(test, assertionFailedError));
|
|
Iterator<TestListener> it2 = cloneListeners().iterator();
|
|
while (it2.hasNext()) {
|
|
it2.next().addFailure(test, assertionFailedError);
|
|
}
|
|
}
|
|
|
|
public synchronized void addListener(TestListener testListener) {
|
|
this.fListeners.add(testListener);
|
|
}
|
|
|
|
public void endTest(Test test) {
|
|
Iterator<TestListener> it2 = cloneListeners().iterator();
|
|
while (it2.hasNext()) {
|
|
it2.next().endTest(test);
|
|
}
|
|
}
|
|
|
|
public synchronized int errorCount() {
|
|
return this.fErrors.size();
|
|
}
|
|
|
|
public synchronized Enumeration<TestFailure> errors() {
|
|
return Collections.enumeration(this.fErrors);
|
|
}
|
|
|
|
public synchronized int failureCount() {
|
|
return this.fFailures.size();
|
|
}
|
|
|
|
public synchronized Enumeration<TestFailure> failures() {
|
|
return Collections.enumeration(this.fFailures);
|
|
}
|
|
|
|
public synchronized void removeListener(TestListener testListener) {
|
|
this.fListeners.remove(testListener);
|
|
}
|
|
|
|
public void run(final TestCase testCase) {
|
|
startTest(testCase);
|
|
runProtected(testCase, new Protectable() { // from class: junit.framework.TestResult.1
|
|
@Override // junit.framework.Protectable
|
|
public void protect() throws Throwable {
|
|
testCase.runBare();
|
|
}
|
|
});
|
|
endTest(testCase);
|
|
}
|
|
|
|
public synchronized int runCount() {
|
|
return this.fRunTests;
|
|
}
|
|
|
|
public void runProtected(Test test, Protectable protectable) {
|
|
try {
|
|
protectable.protect();
|
|
} catch (ThreadDeath e) {
|
|
throw e;
|
|
} catch (AssertionFailedError e2) {
|
|
addFailure(test, e2);
|
|
} catch (Throwable th) {
|
|
addError(test, th);
|
|
}
|
|
}
|
|
|
|
public synchronized boolean shouldStop() {
|
|
return this.fStop;
|
|
}
|
|
|
|
public void startTest(Test test) {
|
|
int countTestCases = test.countTestCases();
|
|
synchronized (this) {
|
|
this.fRunTests += countTestCases;
|
|
}
|
|
Iterator<TestListener> it2 = cloneListeners().iterator();
|
|
while (it2.hasNext()) {
|
|
it2.next().startTest(test);
|
|
}
|
|
}
|
|
|
|
public synchronized void stop() {
|
|
this.fStop = true;
|
|
}
|
|
|
|
public synchronized boolean wasSuccessful() {
|
|
boolean z;
|
|
if (failureCount() == 0) {
|
|
z = errorCount() == 0;
|
|
}
|
|
return z;
|
|
}
|
|
}
|