use of android.util.Rational in project android_frameworks_base by crdroidandroid.
the class CameraMetadataTest method testReadWritePrimitiveArray.
@SmallTest
public void testReadWritePrimitiveArray() {
// int32 (n)
checkKeyGetAndSet("android.sensor.info.sensitivityRange", int[].class, new int[] { 0xC0FFEE, 0xDEADF00D });
// byte (n)
checkKeyGetAndSet("android.statistics.faceScores", byte[].class, new byte[] { 1, 2, 3, 4 });
// int64 (n)
checkKeyGetAndSet("android.scaler.availableProcessedMinDurations", long[].class, new long[] { 0xABCD12345678FFFFL, 0x1234ABCD5678FFFFL, 0xFFFF12345678ABCDL });
// float (n)
checkKeyGetAndSet("android.lens.info.availableApertures", float[].class, new float[] { Float.MAX_VALUE, Float.MIN_NORMAL, Float.MIN_VALUE });
// double (n) -- in particular double x 3
checkKeyGetAndSet("android.jpeg.gpsCoordinates", double[].class, new double[] { Double.MAX_VALUE, Double.MIN_NORMAL, Double.MIN_VALUE });
// rational (n) -- in particular rational x 9
checkKeyGetAndSet("android.sensor.calibrationTransform1", Rational[].class, new Rational[] { new Rational(1, 2), new Rational(3, 4), new Rational(5, 6), new Rational(7, 8), new Rational(9, 10), new Rational(10, 11), new Rational(12, 13), new Rational(14, 15), new Rational(15, 16) });
/**
* Weirder cases, that don't map 1:1 with the native types
*/
// bool (n) -- with TYPE_BYTE
checkKeyGetAndSet("android.control.aeLock", boolean[].class, new boolean[] { true, false, true });
// integer (n) -- with TYPE_BYTE
checkKeyGetAndSet("android.control.aeAvailableModes", int[].class, new int[] { 1, 2, 3, 4 });
}
use of android.util.Rational in project android_frameworks_base by crdroidandroid.
the class RationalTest method createIllegalRational.
private static Rational createIllegalRational(int numerator, int denominator) {
Rational r = new Rational(numerator, denominator);
mutateField(r, "mNumerator", numerator);
mutateField(r, "mDenominator", denominator);
return r;
}
use of android.util.Rational in project android_frameworks_base by crdroidandroid.
the class RationalTest method testReduction.
@SmallTest
public void testReduction() {
Rational moreComplicated = new Rational(5 * 78, 7 * 78);
assertEquals(new Rational(5, 7), moreComplicated);
assertEquals(5, moreComplicated.getNumerator());
assertEquals(7, moreComplicated.getDenominator());
Rational posInf = new Rational(5, 0);
assertEquals(1, posInf.getNumerator());
assertEquals(0, posInf.getDenominator());
assertEquals(POSITIVE_INFINITY, posInf);
Rational negInf = new Rational(-100, 0);
assertEquals(-1, negInf.getNumerator());
assertEquals(0, negInf.getDenominator());
assertEquals(NEGATIVE_INFINITY, negInf);
Rational zero = new Rational(0, -100);
assertEquals(0, zero.getNumerator());
assertEquals(1, zero.getDenominator());
assertEquals(ZERO, zero);
Rational flipSigns = new Rational(1, -1);
assertEquals(-1, flipSigns.getNumerator());
assertEquals(1, flipSigns.getDenominator());
Rational flipAndReduce = new Rational(100, -200);
assertEquals(-1, flipAndReduce.getNumerator());
assertEquals(2, flipAndReduce.getDenominator());
}
use of android.util.Rational in project android_frameworks_base by crdroidandroid.
the class RationalTest method testConstructor.
@SmallTest
public void testConstructor() {
// Simple case
Rational r = new Rational(1, 2);
assertEquals(1, r.getNumerator());
assertEquals(2, r.getDenominator());
// Denominator negative
r = new Rational(-1, 2);
assertEquals(-1, r.getNumerator());
assertEquals(2, r.getDenominator());
// Numerator negative
r = new Rational(1, -2);
assertEquals(-1, r.getNumerator());
assertEquals(2, r.getDenominator());
// Both negative
r = new Rational(-1, -2);
assertEquals(1, r.getNumerator());
assertEquals(2, r.getDenominator());
// Infinity.
r = new Rational(1, 0);
assertEquals(1, r.getNumerator());
assertEquals(0, r.getDenominator());
// Negative infinity.
r = new Rational(-1, 0);
assertEquals(-1, r.getNumerator());
assertEquals(0, r.getDenominator());
// NaN.
r = new Rational(0, 0);
assertEquals(0, r.getNumerator());
assertEquals(0, r.getDenominator());
}
use of android.util.Rational in project android_frameworks_base by crdroidandroid.
the class RangeTest method testEquals.
@SmallTest
public void testEquals() {
Range<Float> oneHalf = Range.create(1.0f, 2.0f);
Range<Float> oneHalf2 = new Range<Float>(1.0f, 2.0f);
assertEquals(oneHalf, oneHalf2);
assertHashCodeEquals(oneHalf, oneHalf2);
Range<Float> twoThirds = new Range<Float>(2.0f, 3.0f);
Range<Float> twoThirds2 = Range.create(2.0f, 3.0f);
assertEquals(twoThirds, twoThirds2);
assertHashCodeEquals(twoThirds, twoThirds2);
Range<Rational> negativeOneTenthPositiveOneTenth = new Range<Rational>(new Rational(-1, 10), new Rational(1, 10));
Range<Rational> negativeOneTenthPositiveOneTenth2 = Range.create(new Rational(-1, 10), new Rational(1, 10));
assertEquals(negativeOneTenthPositiveOneTenth, negativeOneTenthPositiveOneTenth2);
assertHashCodeEquals(negativeOneTenthPositiveOneTenth, negativeOneTenthPositiveOneTenth2);
}
Aggregations