mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-30 13:35:18 +00:00
f72cd5b0ff
Fixes #3347 Closes #3408 // FREEBIE
35 lines
1.7 KiB
Java
35 lines
1.7 KiB
Java
package org.thoughtcrime.securesms.util;
|
|
|
|
import org.thoughtcrime.securesms.TextSecureTestCase;
|
|
|
|
public class BitmapUtilTest extends TextSecureTestCase {
|
|
public void testScaleFactorNormal() {
|
|
assertEquals(1, BitmapUtil.getScaleFactor(1000, 1000, 9000, 9000, false));
|
|
|
|
assertEquals(1, BitmapUtil.getScaleFactor(1000, 1000, 750, 750, false));
|
|
assertEquals(2, BitmapUtil.getScaleFactor(1000, 1000, 500, 500, false));
|
|
assertEquals(2, BitmapUtil.getScaleFactor(1000, 1000, 499, 499, false));
|
|
assertEquals(4, BitmapUtil.getScaleFactor(1000, 1000, 250, 250, false));
|
|
assertEquals(4, BitmapUtil.getScaleFactor(1000, 1000, 249, 249, false));
|
|
|
|
assertEquals(1, BitmapUtil.getScaleFactor(1000, 500, 750, 750, false));
|
|
assertEquals(1, BitmapUtil.getScaleFactor(2000, 1000, 501, 501, false));
|
|
assertEquals(2, BitmapUtil.getScaleFactor(2000, 1000, 500, 500, false));
|
|
assertEquals(2, BitmapUtil.getScaleFactor(1000, 2000, 499, 499, false));
|
|
}
|
|
|
|
public void testScaleFactorConstrained() {
|
|
assertEquals(1, BitmapUtil.getScaleFactor(1000, 1000, 9000, 9000, true));
|
|
|
|
assertEquals(2, BitmapUtil.getScaleFactor(1000, 1000, 750, 750, true));
|
|
assertEquals(2, BitmapUtil.getScaleFactor(1000, 1000, 500, 500, true));
|
|
assertEquals(4, BitmapUtil.getScaleFactor(1000, 1000, 499, 499, true));
|
|
assertEquals(4, BitmapUtil.getScaleFactor(1000, 1000, 250, 250, true));
|
|
assertEquals(8, BitmapUtil.getScaleFactor(1000, 1000, 249, 249, true));
|
|
|
|
assertEquals(2, BitmapUtil.getScaleFactor(1000, 500, 750, 750, true));
|
|
assertEquals(4, BitmapUtil.getScaleFactor(2000, 1000, 500, 500, true));
|
|
assertEquals(8, BitmapUtil.getScaleFactor(1000, 2000, 499, 499, true));
|
|
}
|
|
}
|