Fix eclipse warnings

This commit is contained in:
Jimmy Shih
2013-10-21 12:32:04 -07:00
parent 2e4f4cc4c2
commit b7604a11e4
2 changed files with 35 additions and 49 deletions
@@ -315,7 +315,6 @@ public class CalorieUtils {
* @param gradeBuffer * @param gradeBuffer
* @param distance * @param distance
* @param rise * @param rise
* @return
*/ */
private static double updateGrade(DoubleBuffer gradeBuffer, float distance, Double rise) { private static double updateGrade(DoubleBuffer gradeBuffer, float distance, Double rise) {
double grade = 0; double grade = 0;
@@ -28,7 +28,7 @@ import android.test.AndroidTestCase;
/** /**
* Tests {@link ChartFragment}. * Tests {@link ChartFragment}.
* *
* @author Youtao Liu * @author Youtao Liu
*/ */
public class ChartFragmentTest extends AndroidTestCase { public class ChartFragmentTest extends AndroidTestCase {
@@ -45,12 +45,12 @@ public class ChartFragmentTest extends AndroidTestCase {
} }
/** /**
* Tests the logic to get the incorrect values of sensor in * Tests the logic to get the incorrect values of sensor in {@link ChartFragment#fillDataPoint(Location,
* {@link ChartFragment#fillDataPoint(Location, double[])} * double[], android.content.Context)}
*/ */
public void testFillDataPoint_sensorIncorrect() { public void testFillDataPoint_sensorIncorrect() {
MyTracksLocation myTracksLocation = TrackStubUtils.createMyTracksLocation(); MyTracksLocation myTracksLocation = TrackStubUtils.createMyTracksLocation();
// No input. // No input.
double[] point = fillDataPointTestHelper(myTracksLocation); double[] point = fillDataPointTestHelper(myTracksLocation);
assertEquals(Double.NaN, point[ChartView.HEART_RATE_SERIES + 1]); assertEquals(Double.NaN, point[ChartView.HEART_RATE_SERIES + 1]);
@@ -69,10 +69,7 @@ public class ChartFragmentTest extends AndroidTestCase {
// Creates SensorDataSet. // Creates SensorDataSet.
SensorDataSet sensorDataSet = myTracksLocation.getSensorDataSet(); SensorDataSet sensorDataSet = myTracksLocation.getSensorDataSet();
sensorDataSet = sensorDataSet.toBuilder() sensorDataSet = sensorDataSet.toBuilder()
.setHeartRate(heartRateData) .setHeartRate(heartRateData).setCadence(cadenceData).setPower(powerData).build();
.setCadence(cadenceData)
.setPower(powerData)
.build();
myTracksLocation.setSensorDataSet(sensorDataSet); myTracksLocation.setSensorDataSet(sensorDataSet);
// Test. // Test.
point = fillDataPointTestHelper(myTracksLocation); point = fillDataPointTestHelper(myTracksLocation);
@@ -82,8 +79,8 @@ public class ChartFragmentTest extends AndroidTestCase {
} }
/** /**
* Tests the logic to get the correct values of sensor in * Tests the logic to get the correct values of sensor in {@link ChartFragment#fillDataPoint(Location,
* {@link ChartFragment#fillDataPoint(Location, double[])}. * double[], android.content.Context)}.
*/ */
public void testFillDataPoint_sensorCorrect() { public void testFillDataPoint_sensorCorrect() {
MyTracksLocation myTracksLocation = TrackStubUtils.createMyTracksLocation(); MyTracksLocation myTracksLocation = TrackStubUtils.createMyTracksLocation();
@@ -100,14 +97,11 @@ public class ChartFragmentTest extends AndroidTestCase {
.setValue(101).setState(Sensor.SensorState.SENDING); .setValue(101).setState(Sensor.SensorState.SENDING);
Sensor.SensorData.Builder powerData = Sensor.SensorData.newBuilder() Sensor.SensorData.Builder powerData = Sensor.SensorData.newBuilder()
.setValue(102).setState(Sensor.SensorState.SENDING); .setValue(102).setState(Sensor.SensorState.SENDING);
// Creates SensorDataSet. // Creates SensorDataSet.
SensorDataSet sensorDataSet = myTracksLocation.getSensorDataSet(); SensorDataSet sensorDataSet = myTracksLocation.getSensorDataSet();
sensorDataSet = sensorDataSet.toBuilder() sensorDataSet = sensorDataSet.toBuilder()
.setHeartRate(heartRateData) .setHeartRate(heartRateData).setCadence(cadenceData).setPower(powerData).build();
.setCadence(cadenceData)
.setPower(powerData)
.build();
myTracksLocation.setSensorDataSet(sensorDataSet); myTracksLocation.setSensorDataSet(sensorDataSet);
// Test. // Test.
point = fillDataPointTestHelper(myTracksLocation); point = fillDataPointTestHelper(myTracksLocation);
@@ -117,8 +111,8 @@ public class ChartFragmentTest extends AndroidTestCase {
} }
/** /**
* Tests the logic to get the value of metric Distance in * Tests the logic to get the value of metric Distance in {@link ChartFragment#fillDataPoint(Location,
* {@link ChartFragment#fillDataPoint(Location, double[])}. * double[], android.content.Context)}.
*/ */
public void testFillDataPoint_distanceMetric() { public void testFillDataPoint_distanceMetric() {
// By distance. // By distance.
@@ -137,7 +131,7 @@ public class ChartFragmentTest extends AndroidTestCase {
MyTracksLocation myTracksLocation3 = TrackStubUtils.createMyTracksLocation(); MyTracksLocation myTracksLocation3 = TrackStubUtils.createMyTracksLocation();
myTracksLocation3.setLatitude(23); myTracksLocation3.setLatitude(23);
point = fillDataPointTestHelper(myTracksLocation3); point = fillDataPointTestHelper(myTracksLocation3);
// Computes the distance between Latitude 22 and 23. // Computes the distance between Latitude 22 and 23.
float[] results = new float[4]; float[] results = new float[4];
Location.distanceBetween(myTracksLocation2.getLatitude(), myTracksLocation2.getLongitude(), Location.distanceBetween(myTracksLocation2.getLatitude(), myTracksLocation2.getLongitude(),
@@ -149,7 +143,7 @@ public class ChartFragmentTest extends AndroidTestCase {
MyTracksLocation myTracksLocation4 = TrackStubUtils.createMyTracksLocation(); MyTracksLocation myTracksLocation4 = TrackStubUtils.createMyTracksLocation();
myTracksLocation4.setLatitude(24); myTracksLocation4.setLatitude(24);
point = fillDataPointTestHelper(myTracksLocation4); point = fillDataPointTestHelper(myTracksLocation4);
// Computes the distance between Latitude 23 and 24. // Computes the distance between Latitude 23 and 24.
Location.distanceBetween(myTracksLocation3.getLatitude(), myTracksLocation3.getLongitude(), Location.distanceBetween(myTracksLocation3.getLatitude(), myTracksLocation3.getLongitude(),
myTracksLocation4.getLatitude(), myTracksLocation4.getLongitude(), results); myTracksLocation4.getLatitude(), myTracksLocation4.getLongitude(), results);
@@ -158,8 +152,8 @@ public class ChartFragmentTest extends AndroidTestCase {
} }
/** /**
* Tests the logic to get the value of imperial Distance in * Tests the logic to get the value of imperial Distance in {@link ChartFragment#fillDataPoint(Location,
* {@link ChartFragment#fillDataPoint(Location, double[])}. * double[], android.content.Context)}.
*/ */
public void testFillDataPoint_distanceImperial() { public void testFillDataPoint_distanceImperial() {
// By distance. // By distance.
@@ -203,8 +197,8 @@ public class ChartFragmentTest extends AndroidTestCase {
} }
/** /**
* Tests the logic to get the values of time in * Tests the logic to get the values of time in {@link ChartFragment#fillDataPoint(Location,
* {@link ChartFragment#fillDataPoint(Location, double[])}. * double[], android.content.Context)}.
*/ */
public void testFillDataPoint_time() { public void testFillDataPoint_time() {
// By time // By time
@@ -220,9 +214,8 @@ public class ChartFragmentTest extends AndroidTestCase {
} }
/** /**
* Tests the logic to get the value of elevation in * Tests the logic to get the value of elevation in {@link ChartFragment#fillDataPoint(Location,
* {@link ChartFragment#fillDataPoint(Location, double[])} by one and two * double[], android.content.Context)} by one and two points.
* points.
*/ */
public void testFillDataPoint_elevation() { public void testFillDataPoint_elevation() {
MyTracksLocation myTracksLocation1 = TrackStubUtils.createMyTracksLocation(); MyTracksLocation myTracksLocation1 = TrackStubUtils.createMyTracksLocation();
@@ -246,10 +239,10 @@ public class ChartFragmentTest extends AndroidTestCase {
} }
/** /**
* Tests the logic to get the value of speed in * Tests the logic to get the value of speed in {@link ChartFragment#fillDataPoint(Location,
* {@link ChartFragment#fillDataPoint(Location, double[])}. In this test, * double[], android.content.Context)}. In this test, firstly remove all
* firstly remove all points in memory, and then fill in two points one by * points in memory, and then fill in two points one by one. The speed values
* one. The speed values of these points are 129, 130. * of these points are 129, 130.
*/ */
public void testFillDataPoint_speed() { public void testFillDataPoint_speed() {
/* /*
@@ -283,22 +276,19 @@ public class ChartFragmentTest extends AndroidTestCase {
public void testFillDataPoint_speedImperial() { public void testFillDataPoint_speedImperial() {
// Setups to use imperial. // Setups to use imperial.
chartFragment.setMetricUnits(false); chartFragment.setMetricUnits(false);
// First data point is not added to the speed buffer // First data point is not added to the speed buffer
MyTracksLocation myTracksLocation1 = TrackStubUtils.createMyTracksLocation(); MyTracksLocation myTracksLocation1 = TrackStubUtils.createMyTracksLocation();
myTracksLocation1.setSpeed(100.0f); myTracksLocation1.setSpeed(100.0f);
double[] point = fillDataPointTestHelper(myTracksLocation1); double[] point = fillDataPointTestHelper(myTracksLocation1);
assertEquals(0.0, point[ChartView.SPEED_SERIES + 1]); assertEquals(0.0, point[ChartView.SPEED_SERIES + 1]);
MyTracksLocation myTracksLocation2 = TrackStubUtils.createMyTracksLocation(); MyTracksLocation myTracksLocation2 = TrackStubUtils.createMyTracksLocation();
/* /*
* Add a time span here to make sure the second point is valid and the speed is valid. * Add a time span here to make sure the second point is valid and the speed
* * is valid. Speed is valid if: speedDifference > Constants.MAX_ACCELERATION
* Speed is valid if: * * timeDifference speedDifference = 102 -100 timeDifference = 222
* speedDifference > Constants.MAX_ACCELERATION * timeDifference
* speedDifference = 102 -100
* timeDifference = 222
*/ */
myTracksLocation2.setTime(myTracksLocation2.getTime() + 222); myTracksLocation2.setTime(myTracksLocation2.getTime() + 222);
myTracksLocation2.setSpeed(102); myTracksLocation2.setSpeed(102);
@@ -313,22 +303,19 @@ public class ChartFragmentTest extends AndroidTestCase {
public void testFillDataPoint_pace_nonZeroSpeed() { public void testFillDataPoint_pace_nonZeroSpeed() {
// Setups reportSpeed to false. // Setups reportSpeed to false.
chartFragment.setReportSpeed(false); chartFragment.setReportSpeed(false);
// First data point is not added to the speed buffer // First data point is not added to the speed buffer
MyTracksLocation myTracksLocation1 = TrackStubUtils.createMyTracksLocation(); MyTracksLocation myTracksLocation1 = TrackStubUtils.createMyTracksLocation();
myTracksLocation1.setSpeed(100.0f); myTracksLocation1.setSpeed(100.0f);
double[] point = fillDataPointTestHelper(myTracksLocation1); double[] point = fillDataPointTestHelper(myTracksLocation1);
assertEquals(0.0, point[ChartView.SPEED_SERIES + 1]); assertEquals(0.0, point[ChartView.SPEED_SERIES + 1]);
MyTracksLocation myTracksLocation2 = TrackStubUtils.createMyTracksLocation(); MyTracksLocation myTracksLocation2 = TrackStubUtils.createMyTracksLocation();
/* /*
* Add a time span here to make sure the second point is valid and the speed is valid. * Add a time span here to make sure the second point is valid and the speed
* * is valid. Speed is valid if: speedDifference > Constants.MAX_ACCELERATION
* Speed is valid if: * * timeDifference speedDifference = 102 -100 timeDifference = 222
* speedDifference > Constants.MAX_ACCELERATION * timeDifference
* speedDifference = 102 -100
* timeDifference = 222
*/ */
myTracksLocation2.setTime(myTracksLocation2.getTime() + 222); myTracksLocation2.setTime(myTracksLocation2.getTime() + 222);
myTracksLocation2.setSpeed(102); myTracksLocation2.setSpeed(102);
@@ -352,7 +339,7 @@ public class ChartFragmentTest extends AndroidTestCase {
/** /**
* Helper method to test fillDataPoint. * Helper method to test fillDataPoint.
* *
* @param location location to fill * @param location location to fill
* @return data of this location * @return data of this location
*/ */