.givenSquareImageWithDimensionOf(400, onAllApisAndAllFormatsExpect(100, 100)) .givenImageWithDimensionsOf(300, 300, atAndAbove(KITKAT).with(allFormats().expect(100, 100)), below(KITKAT).with(allFormats().expect(150, 150))) .givenImageWithDimensionsOf(799, 100, atAndAbove(KITKAT).with(allFormats().expect(100, 13)), below(KITKAT) .with( formats(JPEG) .expect(200, 25), .expect(199, 25))) .givenImageWithDimensionsOf(800, 100, atAndAbove(KITKAT).with(allFormats().expect(100, 13)), below(KITKAT).with(allFormats().expect(200, 25))) .givenImageWithDimensionsOf(801, 100, atAndAbove(VERSION_CODES.N) .with( formats(JPEG, WEBP) .expect(100, 13), .expect(100, 12)), apis(KITKAT, VERSION_CODES.M) .with( formats(JPEG) .expect(100, 13), .expect(100, 12)), below(KITKAT)
.givenImageWithDimensionsOf(799, 100, atAndAbove(VERSION_CODES.N) .with( formats(JPEG, WEBP) .expect(100, 13), .expect(99, 12)), below(VERSION_CODES.N) .with( formats(JPEG) .expect(100, 13), .givenImageWithDimensionsOf(800, 100, atAndAbove(VERSION_CODES.N) .with( formats(JPEG, WEBP) .expect(100, 13), .expect(100, 12)), below(VERSION_CODES.N) .with( formats(JPEG) .expect(100, 13), .givenImageWithDimensionsOf(100, 800, atAndAbove(VERSION_CODES.N) .with( formats(JPEG, WEBP) .expect(13, 100),
.givenSquareImageWithDimensionOf(400, onAllApisAndAllFormatsExpect(100, 100)) .givenImageWithDimensionsOf(300, 300, atAndAbove(KITKAT).with(allFormats().expect(100, 100)), below(KITKAT).with(allFormats().expect(150, 150))) .givenImageWithDimensionsOf(799, 100, atAndAbove(KITKAT).with(allFormats().expect(100, 13)), below(KITKAT) .with( formats(JPEG) .expect(200, 25), .expect(199, 25))) .givenImageWithDimensionsOf(800, 100, atAndAbove(KITKAT).with(allFormats().expect(100, 13)), below(KITKAT).with(allFormats().expect(200, 25))) .givenImageWithDimensionsOf(801, 100, atAndAbove(VERSION_CODES.N) .with( formats(JPEG, WEBP) .expect(100, 13), .expect(100, 12)), apis(KITKAT, VERSION_CODES.M) .with( formats(JPEG) .expect(100, 13), .expect(100, 12)), below(KITKAT)
@Test public void calculateScaling_withCenterOutside() throws IOException { new Tester(DownsampleStrategy.CENTER_OUTSIDE) .setTargetDimensions(100, 100) .givenSquareImageWithDimensionOf(100, onAllApisAndAllFormatsExpect(100, 100)) .givenSquareImageWithDimensionOf(200, onAllApisAndAllFormatsExpect(100, 100)) .givenSquareImageWithDimensionOf(400, onAllApisAndAllFormatsExpect(100, 100)) .givenImageWithDimensionsOf(300, 300, atAndAbove(KITKAT).with(allFormats().expect(100, 100)), below(KITKAT).with(allFormats().expect(150, 150))) .givenImageWithDimensionsOf(799, 100, onAllApisAndAllFormatsExpect(799, 100)) .givenImageWithDimensionsOf(800, 100, onAllApisAndAllFormatsExpect(800, 100)) .givenImageWithDimensionsOf(801, 100, onAllApisAndAllFormatsExpect(801, 100)) .givenImageWithDimensionsOf(100, 800, onAllApisAndAllFormatsExpect(100, 800)) .givenImageWithDimensionsOf(87, 78, atAndAbove(KITKAT).with(allFormats().expect(112, 100)), below(KITKAT).with(allFormats().expect(87, 78))) // Upscaling .setTargetDimensions(500, 500) .givenSquareImageWithDimensionOf(200, atAndAbove(KITKAT).with(allFormats().expect(500, 500)), below(KITKAT).with(allFormats().expect(200, 200))) .givenSquareImageWithDimensionOf(450, atAndAbove(KITKAT).with(allFormats().expect(500, 500)), below(KITKAT).with(allFormats().expect(450, 450))) .givenImageWithDimensionsOf(200, 450, atAndAbove(KITKAT).with(allFormats().expect(500, 1125)), below(KITKAT).with(allFormats().expect(200, 450))) .run(); }
static Api onAllApisAndAllFormatsExpect(int width, int height) { return allApis().with(allFormats().expect(width, height)); }