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;
}
在右側方向上的任何指導理解。