.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( .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) .expect(100, 12))) .givenImageWithDimensionsOf(100, 800, atAndAbove(KITKAT).with(allFormats().expect(13, 100)), below(KITKAT).with(allFormats().expect(25, 200))) .givenImageWithDimensionsOf(87, 78, atAndAbove(KITKAT).with(allFormats().expect(100, 90)), below(KITKAT).with(allFormats().expect(87, 78))) .setTargetDimensions(897, 897) .givenImageWithDimensionsOf(2208, 1520, atAndAbove(KITKAT).with(allFormats().expect(897, 618)), below(KITKAT).with(allFormats().expect(1104, 760))) .setTargetDimensions(270, 270)
.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( .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) .expect(100, 12))) .givenImageWithDimensionsOf(100, 800, atAndAbove(KITKAT).with(allFormats().expect(13, 100)), below(KITKAT).with(allFormats().expect(25, 200))) .givenImageWithDimensionsOf(87, 78, onAllApisAndAllFormatsExpect(87, 78)) .setTargetDimensions(897, 897) .givenImageWithDimensionsOf(2208, 1520, atAndAbove(KITKAT).with(allFormats().expect(897, 618)), below(KITKAT).with(allFormats().expect(1104, 760)))
@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)); }