31
31
import androidx .test .espresso .base .ViewHierarchyExceptionHandler .Truncater ;
32
32
import androidx .test .espresso .internal .inject .TargetContext ;
33
33
import androidx .test .internal .platform .util .TestOutputEmitter ;
34
- import androidx .test .platform .io .PlatformTestStorage ;
35
- import androidx .test .platform .io .PlatformTestStorageRegistry ;
36
34
import java .io .IOException ;
37
35
import java .util .ArrayList ;
38
36
import java .util .Arrays ;
39
37
import java .util .List ;
40
38
import java .util .concurrent .atomic .AtomicInteger ;
41
- import javax .inject .Inject ;
42
39
import junit .framework .AssertionFailedError ;
43
40
import org .hamcrest .Matcher ;
44
41
@@ -50,23 +47,15 @@ public final class DefaultFailureHandler implements FailureHandler {
50
47
51
48
private static final AtomicInteger failureCount = new AtomicInteger (0 );
52
49
private final List <FailureHandler > handlers = new ArrayList <>();
53
- private final PlatformTestStorage testStorage ;
54
50
private final boolean captureScreenshotOnFailure ;
55
51
56
52
public DefaultFailureHandler (@ TargetContext Context appContext ) {
57
- this (appContext , PlatformTestStorageRegistry . getInstance (), true );
53
+ this (appContext , true );
58
54
}
59
55
60
56
public DefaultFailureHandler (
61
57
@ TargetContext Context appContext , boolean captureScreenshotOnFailure ) {
62
- this (appContext , PlatformTestStorageRegistry .getInstance (), captureScreenshotOnFailure );
63
- }
64
58
65
- @ Inject
66
- DefaultFailureHandler (
67
- @ TargetContext Context appContext ,
68
- PlatformTestStorage testStorage ,
69
- boolean captureScreenshotOnFailure ) {
70
59
// Adds a chain of exception handlers.
71
60
// Order matters and a matching failure handler in the chain will throw after the exception is
72
61
// handled. Always adds the handler of the child class ahead of its superclasses to make sure
@@ -77,17 +66,14 @@ public DefaultFailureHandler(
77
66
// PerformException ---------> EspressoException
78
67
// ---------> Throwable
79
68
// AssertionError ----------->
80
- this .testStorage = testStorage ;
81
69
this .captureScreenshotOnFailure = captureScreenshotOnFailure ;
82
70
handlers .add (
83
71
new ViewHierarchyExceptionHandler <>(
84
- testStorage ,
85
72
failureCount ,
86
73
NoMatchingViewException .class ,
87
74
getNoMatchingViewExceptionTruncater ()));
88
75
handlers .add (
89
76
new ViewHierarchyExceptionHandler <>(
90
- testStorage ,
91
77
failureCount ,
92
78
AmbiguousViewMatcherException .class ,
93
79
getAmbiguousViewMatcherExceptionTruncater ()));
@@ -141,8 +127,7 @@ private void takeScreenshot(String outputName) {
141
127
}
142
128
try {
143
129
if (DeviceCapture .canTakeScreenshot ()) {
144
- BitmapStorage .writeToTestStorage (
145
- DeviceCapture .takeScreenshotNoSync (), testStorage , outputName );
130
+ BitmapStorage .writeToTestStorage (DeviceCapture .takeScreenshotNoSync (), outputName );
146
131
} else {
147
132
TestOutputEmitter .takeScreenshot (outputName + ".png" );
148
133
}
0 commit comments