0
我有Android应用程序引用的纯Jar项目。 然后,我有我想创建单元测试类的常用函数的Functions.java。Android:单元测试:如何使用SensorManager创建单元测试?
这里是Functions.java内部的样品的功能:
public static double getAltitudeBySensor(float atmosphericPressure) {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD
&& atmosphericPressure > 0d) {
return SensorManager.getAltitude(SensorManager.PRESSURE_STANDARD_ATMOSPHERE, atmosphericPressure);
}
return 0d;
}
public static double toPixelX(double imageSize, android.location.Location upperLeft, android.location.Location lowerRight, android.location.Location target) {
double hypotenuse = upperLeft.distanceTo(target);
double bearing = upperLeft.bearingTo(target);
double currentDistanceX = Math.sin(bearing * Math.PI/OneEightyDeg) * hypotenuse;
// "percentage to mark the position"
double totalHypotenuse = upperLeft.distanceTo(lowerRight);
double totalDistanceX = totalHypotenuse * Math.sin(upperLeft.bearingTo(lowerRight) * Math.PI/OneEightyDeg);
double currentPixelX = currentDistanceX/totalDistanceX * imageSize;
return currentPixelX;
}
在右侧方向上的任何指导理解。