10
10
import com .bumptech .glide .load .EncodeStrategy ;
11
11
import com .bumptech .glide .load .Options ;
12
12
import com .bumptech .glide .load .engine .Resource ;
13
+ import com .bumptech .glide .load .engine .bitmap_recycle .ArrayPool ;
14
+ import com .bumptech .glide .load .engine .bitmap_recycle .LruArrayPool ;
13
15
import com .bumptech .glide .util .ByteBufferUtil ;
14
16
import java .io .File ;
15
17
import java .io .IOException ;
@@ -86,13 +88,13 @@ public void testEncoderEncodesPngWithNullFormatAndBitmapWithAlpha() throws IOExc
86
88
87
89
@ Test
88
90
public void testReturnsTrueFromWrite () {
89
- BitmapEncoder encoder = new BitmapEncoder ();
91
+ BitmapEncoder encoder = new BitmapEncoder (harness . arrayPool );
90
92
assertTrue (encoder .encode (harness .resource , harness .file , harness .options ));
91
93
}
92
94
93
95
@ Test
94
96
public void testEncodeStrategy_alwaysReturnsTransformed () {
95
- BitmapEncoder encoder = new BitmapEncoder ();
97
+ BitmapEncoder encoder = new BitmapEncoder (harness . arrayPool );
96
98
assertEquals (EncodeStrategy .TRANSFORMED , encoder .getEncodeStrategy (harness .options ));
97
99
}
98
100
@@ -105,6 +107,7 @@ private static class EncoderHarness {
105
107
final Bitmap bitmap = Bitmap .createBitmap (100 , 100 , Bitmap .Config .ARGB_8888 );
106
108
final Options options = new Options ();
107
109
final File file = new File (RuntimeEnvironment .application .getCacheDir (), "test" );
110
+ final ArrayPool arrayPool = new LruArrayPool ();
108
111
109
112
EncoderHarness () {
110
113
when (resource .get ()).thenReturn (bitmap );
@@ -119,7 +122,7 @@ void setFormat(Bitmap.CompressFormat format) {
119
122
}
120
123
121
124
String encode () throws IOException {
122
- BitmapEncoder encoder = new BitmapEncoder ();
125
+ BitmapEncoder encoder = new BitmapEncoder (arrayPool );
123
126
encoder .encode (resource , file , options );
124
127
byte [] data = ByteBufferUtil .toBytes (ByteBufferUtil .fromFile (file ));
125
128
return new String (data , "UTF-8" );
0 commit comments