| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.test; |
| 18 |
|
| 19 |
import android.util.Log; |
| 20 |
import junit.framework.Test; |
| 21 |
import junit.framework.TestListener; |
| 22 |
|
| 23 |
import java.util.HashSet; |
| 24 |
import java.util.Set; |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
@Deprecated |
| 36 |
class TestPrinter implements TestListener { |
| 37 |
|
| 38 |
private String mTag; |
| 39 |
private boolean mOnlyFailures; |
| 40 |
private Set<String> mFailedTests = new HashSet<String>(); |
| 41 |
|
| 42 |
|
| 43 |
TestPrinter(String tag, boolean onlyFailures) { |
| 44 |
mTag = tag; |
| 45 |
mOnlyFailures = onlyFailures; |
| 46 |
} |
| 47 |
|
| 48 |
private void started(String className) { |
| 49 |
if (!mOnlyFailures) { |
| 50 |
Log.i(mTag, "started: " + className); |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
private void finished(String className) { |
| 55 |
if (!mOnlyFailures) { |
| 56 |
Log.i(mTag, "finished: " + className); |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
private void passed(String className) { |
| 61 |
if (!mOnlyFailures) { |
| 62 |
Log.i(mTag, "passed: " + className); |
| 63 |
} |
| 64 |
} |
| 65 |
|
| 66 |
private void failed(String className, Throwable exception) { |
| 67 |
Log.i(mTag, "failed: " + className); |
| 68 |
Log.i(mTag, "----- begin exception -----"); |
| 69 |
Log.i(mTag, "", exception); |
| 70 |
Log.i(mTag, "----- end exception -----"); |
| 71 |
} |
| 72 |
|
| 73 |
private void failed(Test test, Throwable t) { |
| 74 |
mFailedTests.add(test.toString()); |
| 75 |
failed(test.toString(), t); |
| 76 |
} |
| 77 |
|
| 78 |
public void addError(Test test, Throwable t) { |
| 79 |
failed(test, t); |
| 80 |
} |
| 81 |
|
| 82 |
public void addFailure(Test test, junit.framework.AssertionFailedError t) { |
| 83 |
failed(test, t); |
| 84 |
} |
| 85 |
|
| 86 |
public void endTest(Test test) { |
| 87 |
finished(test.toString()); |
| 88 |
if (!mFailedTests.contains(test.toString())) { |
| 89 |
passed(test.toString()); |
| 90 |
} |
| 91 |
mFailedTests.remove(test.toString()); |
| 92 |
} |
| 93 |
|
| 94 |
public void startTest(Test test) { |
| 95 |
started(test.toString()); |
| 96 |
} |
| 97 |
} |