If you think the Android project FAST listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package org.ligi.fast.testing;
//www.java2s.comimport android.graphics.Point;
import android.test.suitebuilder.annotation.SmallTest;
import org.ligi.fast.model.AppIconCache;
import org.ligi.fast.model.AppInfo;
importstatic org.assertj.core.api.Assertions.assertThat;
/*
* test the AppIconCache
*
* TODO either use BoundBox to access the then hidden scaling calc ( but BoundBox was not working with this gradle setup atm )
* or when Robolectric is able to scale images - use real images
*
*/publicclass TheAppIconCache extends AppInfoTestBase {
private AppIconCache tested;
private Point POINT_96_96 = new Point(96, 96);
@Override
publicvoid setUp() throws Exception {
tested = new AppIconCache(getActivity(), new AppInfo(getActivity(), SERIALIZED_APPINFO));
}
@SmallTest
publicvoid testShouldNotScaleForEqualToSize() {
Point point = tested.scaleToFitCalc(96, POINT_96_96);
assertThat(point).isEqualTo(POINT_96_96);
}
@SmallTest
publicvoid testShouldNotScaleSquareToMaxSquare() {
Point point = tested.scaleToFitCalc(96, new Point(128, 128));
assertThat(point).isEqualTo(POINT_96_96);
}
@SmallTest
publicvoid testShouldScaleWithCorrectAspectRatio() {
Point point = tested.scaleToFitCalc(96, new Point(128, 265));
// aspect ratio should
assertThat(point).isEqualTo(new Point(46, 96));
}
}