35
35
import org .junit .runner .RunWith ;
36
36
37
37
/**
38
- * Pixel test for frame processing via {@link PresentationFrameProcessor }.
38
+ * Pixel test for frame processing via {@link Presentation }.
39
39
*
40
40
* <p>Expected images are taken from an emulator, so tests on different emulators or physical
41
41
* devices may fail. To test on other devices, please increase the {@link
42
42
* BitmapTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output bitmaps
43
43
* as recommended in {@link FrameProcessorChainPixelTest}.
44
44
*/
45
45
@ RunWith (AndroidJUnit4 .class )
46
- public final class PresentationFrameProcessorPixelTest {
46
+ public final class PresentationPixelTest {
47
47
public static final String ORIGINAL_PNG_ASSET_PATH =
48
48
"media/bitmap/sample_mp4_first_frame/original.png" ;
49
49
public static final String CROP_SMALLER_PNG_ASSET_PATH =
@@ -97,7 +97,7 @@ public void release() {
97
97
@ Test
98
98
public void drawFrame_noEdits_producesExpectedOutput () throws Exception {
99
99
String testId = "drawFrame_noEdits" ;
100
- presentationFrameProcessor = new PresentationFrameProcessor .Builder ().build ();
100
+ presentationFrameProcessor = new Presentation .Builder ().build (). toGlFrameProcessor ();
101
101
presentationFrameProcessor .initialize (
102
102
getApplicationContext (), inputTexId , inputWidth , inputHeight );
103
103
Size outputSize = presentationFrameProcessor .getOutputSize ();
@@ -122,9 +122,10 @@ public void drawFrame_noEdits_producesExpectedOutput() throws Exception {
122
122
public void drawFrame_cropSmaller_producesExpectedOutput () throws Exception {
123
123
String testId = "drawFrame_cropSmaller" ;
124
124
GlFrameProcessor presentationFrameProcessor =
125
- new PresentationFrameProcessor .Builder ()
125
+ new Presentation .Builder ()
126
126
.setCrop (/* left= */ -.9f , /* right= */ .1f , /* bottom= */ -1f , /* top= */ .5f )
127
- .build ();
127
+ .build ()
128
+ .toGlFrameProcessor ();
128
129
presentationFrameProcessor .initialize (
129
130
getApplicationContext (), inputTexId , inputWidth , inputHeight );
130
131
Size outputSize = presentationFrameProcessor .getOutputSize ();
@@ -149,9 +150,10 @@ public void drawFrame_cropSmaller_producesExpectedOutput() throws Exception {
149
150
public void drawFrame_cropLarger_producesExpectedOutput () throws Exception {
150
151
String testId = "drawFrame_cropSmaller" ;
151
152
GlFrameProcessor presentationFrameProcessor =
152
- new PresentationFrameProcessor .Builder ()
153
+ new Presentation .Builder ()
153
154
.setCrop (/* left= */ -2f , /* right= */ 2f , /* bottom= */ -1f , /* top= */ 2f )
154
- .build ();
155
+ .build ()
156
+ .toGlFrameProcessor ();
155
157
presentationFrameProcessor .initialize (
156
158
getApplicationContext (), inputTexId , inputWidth , inputHeight );
157
159
Size outputSize = presentationFrameProcessor .getOutputSize ();
@@ -177,9 +179,10 @@ public void drawFrame_changeAspectRatio_scaleToFit_narrow_producesExpectedOutput
177
179
throws Exception {
178
180
String testId = "drawFrame_changeAspectRatio_scaleToFit_narrow" ;
179
181
presentationFrameProcessor =
180
- new PresentationFrameProcessor .Builder ()
181
- .setAspectRatio (1f , PresentationFrameProcessor .LAYOUT_SCALE_TO_FIT )
182
- .build ();
182
+ new Presentation .Builder ()
183
+ .setAspectRatio (1f , Presentation .LAYOUT_SCALE_TO_FIT )
184
+ .build ()
185
+ .toGlFrameProcessor ();
183
186
presentationFrameProcessor .initialize (
184
187
getApplicationContext (), inputTexId , inputWidth , inputHeight );
185
188
Size outputSize = presentationFrameProcessor .getOutputSize ();
@@ -206,9 +209,10 @@ public void drawFrame_changeAspectRatio_scaleToFit_wide_producesExpectedOutput()
206
209
throws Exception {
207
210
String testId = "drawFrame_changeAspectRatio_scaleToFit_wide" ;
208
211
presentationFrameProcessor =
209
- new PresentationFrameProcessor .Builder ()
210
- .setAspectRatio (2f , PresentationFrameProcessor .LAYOUT_SCALE_TO_FIT )
211
- .build ();
212
+ new Presentation .Builder ()
213
+ .setAspectRatio (2f , Presentation .LAYOUT_SCALE_TO_FIT )
214
+ .build ()
215
+ .toGlFrameProcessor ();
212
216
presentationFrameProcessor .initialize (
213
217
getApplicationContext (), inputTexId , inputWidth , inputHeight );
214
218
Size outputSize = presentationFrameProcessor .getOutputSize ();
@@ -235,9 +239,10 @@ public void drawFrame_changeAspectRatio_scaleToFitWithCrop_narrow_producesExpect
235
239
throws Exception {
236
240
String testId = "drawFrame_changeAspectRatio_scaleToFitWithCrop_narrow" ;
237
241
presentationFrameProcessor =
238
- new PresentationFrameProcessor .Builder ()
239
- .setAspectRatio (1f , PresentationFrameProcessor .LAYOUT_SCALE_TO_FIT_WITH_CROP )
240
- .build ();
242
+ new Presentation .Builder ()
243
+ .setAspectRatio (1f , Presentation .LAYOUT_SCALE_TO_FIT_WITH_CROP )
244
+ .build ()
245
+ .toGlFrameProcessor ();
241
246
presentationFrameProcessor .initialize (
242
247
getApplicationContext (), inputTexId , inputWidth , inputHeight );
243
248
Size outputSize = presentationFrameProcessor .getOutputSize ();
@@ -264,9 +269,10 @@ public void drawFrame_changeAspectRatio_scaleToFitWithCrop_wide_producesExpected
264
269
throws Exception {
265
270
String testId = "drawFrame_changeAspectRatio_scaleToFitWithCrop_wide" ;
266
271
presentationFrameProcessor =
267
- new PresentationFrameProcessor .Builder ()
268
- .setAspectRatio (2f , PresentationFrameProcessor .LAYOUT_SCALE_TO_FIT_WITH_CROP )
269
- .build ();
272
+ new Presentation .Builder ()
273
+ .setAspectRatio (2f , Presentation .LAYOUT_SCALE_TO_FIT_WITH_CROP )
274
+ .build ()
275
+ .toGlFrameProcessor ();
270
276
presentationFrameProcessor .initialize (
271
277
getApplicationContext (), inputTexId , inputWidth , inputHeight );
272
278
Size outputSize = presentationFrameProcessor .getOutputSize ();
@@ -293,9 +299,10 @@ public void drawFrame_changeAspectRatio_stretchToFit_narrow_producesExpectedOutp
293
299
throws Exception {
294
300
String testId = "drawFrame_changeAspectRatio_stretchToFit_narrow" ;
295
301
presentationFrameProcessor =
296
- new PresentationFrameProcessor .Builder ()
297
- .setAspectRatio (1f , PresentationFrameProcessor .LAYOUT_STRETCH_TO_FIT )
298
- .build ();
302
+ new Presentation .Builder ()
303
+ .setAspectRatio (1f , Presentation .LAYOUT_STRETCH_TO_FIT )
304
+ .build ()
305
+ .toGlFrameProcessor ();
299
306
presentationFrameProcessor .initialize (
300
307
getApplicationContext (), inputTexId , inputWidth , inputHeight );
301
308
Size outputSize = presentationFrameProcessor .getOutputSize ();
@@ -322,9 +329,10 @@ public void drawFrame_changeAspectRatio_stretchToFit_wide_producesExpectedOutput
322
329
throws Exception {
323
330
String testId = "drawFrame_changeAspectRatio_stretchToFit_wide" ;
324
331
presentationFrameProcessor =
325
- new PresentationFrameProcessor .Builder ()
326
- .setAspectRatio (2f , PresentationFrameProcessor .LAYOUT_STRETCH_TO_FIT )
327
- .build ();
332
+ new Presentation .Builder ()
333
+ .setAspectRatio (2f , Presentation .LAYOUT_STRETCH_TO_FIT )
334
+ .build ()
335
+ .toGlFrameProcessor ();
328
336
presentationFrameProcessor .initialize (
329
337
getApplicationContext (), inputTexId , inputWidth , inputHeight );
330
338
Size outputSize = presentationFrameProcessor .getOutputSize ();
@@ -346,7 +354,7 @@ public void drawFrame_changeAspectRatio_stretchToFit_wide_producesExpectedOutput
346
354
assertThat (averagePixelAbsoluteDifference ).isAtMost (MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE );
347
355
}
348
356
349
- private void setupOutputTexture (int outputWidth , int outputHeight ) throws IOException {
357
+ private void setupOutputTexture (int outputWidth , int outputHeight ) {
350
358
outputTexId = GlUtil .createTexture (outputWidth , outputHeight );
351
359
int frameBuffer = GlUtil .createFboForTexture (outputTexId );
352
360
GlUtil .focusFramebuffer (
0 commit comments