|
23 | 23 | import com.bumptech.glide.load.engine.Resource;
|
24 | 24 | import com.bumptech.glide.load.engine.executor.GlideExecutor;
|
25 | 25 | import com.bumptech.glide.load.engine.executor.GlideExecutor.UncaughtThrowableStrategy;
|
| 26 | +import com.bumptech.glide.request.FutureTarget; |
26 | 27 | import com.bumptech.glide.request.RequestListener;
|
27 | 28 | import com.bumptech.glide.test.ConcurrencyHelper;
|
28 | 29 | import com.bumptech.glide.test.ResourceIds;
|
29 | 30 | import com.bumptech.glide.test.TearDownGlide;
|
| 31 | +import com.bumptech.glide.test.WaitModelLoader; |
| 32 | +import com.bumptech.glide.test.WaitModelLoader.WaitModel; |
30 | 33 | import java.io.File;
|
31 | 34 | import java.util.concurrent.CountDownLatch;
|
32 | 35 | import org.junit.Before;
|
@@ -106,6 +109,30 @@ public void load_whenLoadSucceeds_butEncoderFails_doesNotCallOnLoadFailed()
|
106 | 109 | .onLoadFailed(any(GlideException.class), any(), anyDrawableTarget(), anyBoolean());
|
107 | 110 | }
|
108 | 111 |
|
| 112 | + @Test |
| 113 | + public void clearRequest_withError_afterPrimaryFails_clearsErrorRequest() |
| 114 | + throws InterruptedException { |
| 115 | + WaitModel<Integer> errorModel = WaitModelLoader.Factory.waitOn(ResourceIds.raw.canonical); |
| 116 | + |
| 117 | + FutureTarget<Drawable> target = |
| 118 | + Glide.with(context) |
| 119 | + .load((Object) null) |
| 120 | + .error( |
| 121 | + Glide.with(context) |
| 122 | + .load(errorModel) |
| 123 | + .listener(requestListener)) |
| 124 | + .submit(); |
| 125 | + |
| 126 | + Glide.with(context).clear(target); |
| 127 | + errorModel.countDown(); |
| 128 | + |
| 129 | + // Make sure any pending requests run. |
| 130 | + concurrency.pokeMainThread(); |
| 131 | + Glide.tearDown(); |
| 132 | + // Make sure that any callbacks posted back to the main thread run. |
| 133 | + concurrency.pokeMainThread(); |
| 134 | + } |
| 135 | + |
109 | 136 | private static final class WaitForErrorStrategy implements UncaughtThrowableStrategy {
|
110 | 137 | final CountDownLatch latch = new CountDownLatch(1);
|
111 | 138 | @Nullable Throwable error = null;
|
|
0 commit comments