merge heads

This commit is contained in:
Jimmy Shih
2011-09-29 18:14:44 -07:00
12 changed files with 99 additions and 48 deletions
@@ -49,7 +49,6 @@ public class MyTracksTest extends ActivityInstrumentationTestCase2<MyTracks>{
protected void tearDown() throws Exception {
clearSelectedAndRecordingTracks();
waitForIdle();
super.tearDown();
}
@@ -85,7 +84,7 @@ public class MyTracksTest extends ActivityInstrumentationTestCase2<MyTracks>{
// Simulate start with ACTION_VIEW intent.
Intent startIntent = new Intent();
startIntent.setAction(Intent.ACTION_VIEW);
Uri uri = Uri.fromFile(File.createTempFile("valid", ".gpx"));
Uri uri = Uri.fromFile(File.createTempFile("valid", ".gpx", getActivity().getFilesDir()));
// TODO: Add a valid GPX.
@@ -108,7 +107,7 @@ public class MyTracksTest extends ActivityInstrumentationTestCase2<MyTracks>{
// Simulate start with ACTION_VIEW intent.
Intent startIntent = new Intent();
startIntent.setAction(Intent.ACTION_VIEW);
Uri uri = Uri.fromFile(File.createTempFile("invalid", ".gpx"));
Uri uri = Uri.fromFile(File.createTempFile("invalid", ".gpx", getActivity().getFilesDir()));
startIntent.setData(uri);
setActivityIntent(startIntent);
@@ -168,8 +167,13 @@ public class MyTracksTest extends ActivityInstrumentationTestCase2<MyTracks>{
// properly saved.
// Simulate a click on Save button.
Button save = (Button) activity.findViewById(R.id.trackdetails_save);
save.performClick();
final Button save = (Button) activity.findViewById(R.id.trackdetails_save);
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
save.performClick();
}
});
// Check the remaining properties.
recordingTrackId = awaitRecordingStatus(5000, false);
@@ -28,6 +28,8 @@ import android.test.mock.MockContext;
import android.test.mock.MockResources;
import java.io.IOException;
import java.text.DateFormat;
import java.util.Date;
import junit.framework.TestCase;
@@ -55,13 +57,13 @@ public class DocsHelper_AddTrackRowTest extends TestCase {
StringWritingDocsHelper docsHelper = new StringWritingDocsHelper();
addTrackRow(docsHelper, false);
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
String expectedData =
"<entry xmlns='http://www.w3.org/2005/Atom' "
+ "xmlns:gsx='http://schemas.google.com/spreadsheets/2006/extended'>"
+ "<gsx:name><![CDATA[trackName]]></gsx:name>"
+ "<gsx:description><![CDATA[trackDescription]]></gsx:description>"
// We format the date here because we can't guarantee/force the timezone
+ "<gsx:date><![CDATA[" + String.format("%tc", TIME) + "]]></gsx:date>"
+ "<gsx:date><![CDATA[" + dateFormat.format(new Date(TIME)) + "]]></gsx:date>"
+ "<gsx:totaltime><![CDATA[0:00:05]]></gsx:totaltime>"
+ "<gsx:movingtime><![CDATA[0:00:04]]></gsx:movingtime>"
+ "<gsx:distance><![CDATA[12.43]]></gsx:distance>"
@@ -76,12 +78,12 @@ public class DocsHelper_AddTrackRowTest extends TestCase {
+ "<gsx:maxelevation><![CDATA[1,804]]></gsx:maxelevation>"
+ "<gsx:elevationunit><![CDATA[feet]]></gsx:elevationunit>"
+ "<gsx:map>"
+ "<![CDATA[http://maps.google.com/maps/ms?msa=0&msid=trackMapId]]>"
+ "<![CDATA[https://maps.google.com/maps/ms?msa=0&msid=trackMapId]]>"
+ "</gsx:map>"
+ "</entry>";
assertEquals(
"http://spreadsheets.google.com/feeds/list/ssid/wsid/private/full",
"https://spreadsheets.google.com/feeds/list/ssid/wsid/private/full",
docsHelper.writtenSheetUri);
assertEquals(expectedData, docsHelper.writtenData);
}
@@ -53,7 +53,7 @@ public class WriteProgressControllerTest extends ActivityInstrumentationTestCase
}
};
WriteProgressController controller = new WriteProgressController(
final WriteProgressController controller = new WriteProgressController(
getActivity(), mockWriter, SaveActivity.PROGRESS_DIALOG);
controller.setOnCompletionListener(new WriteProgressController.OnCompletionListener() {
@Override
@@ -62,6 +62,22 @@ public class WriteProgressControllerTest extends ActivityInstrumentationTestCase
}
});
/*
* The WriteProgressController constructor calls the mockWriter's
* setOnCompletionListener method with a listener that dismisses the
* progress dialog. However, this unit test only tests the
* WriteProgressController and doesn't actually show any progress dialog.
* Thus after the WriteProgressController is setup, we need to call the
* mockWriter's setOnCompletionListener method again with an listener that
* doesn't dismiss dialog.
*/
mockWriter.setOnCompletionListener(new TrackWriter.OnCompletionListener() {
@Override
public void onComplete() {
controller.getOnCompletionListener().onComplete();
}
});
dialogRef.set(controller.createProgressDialog());
controller.startWrite();
@@ -69,7 +85,6 @@ public class WriteProgressControllerTest extends ActivityInstrumentationTestCase
// wait for the writer to finish
writerDone.acquire();
assertFalse(dialogRef.get().isShowing());
assertTrue(controllerDoneRef.get());
}
}
@@ -26,9 +26,9 @@ public class ZephyrMessageParserTest extends TestCase {
public void testParseBuffer() {
byte[] buf = new byte[60];
// Heartrate (-1 =^ 255 unsigned byte)
// Heart Rate (-1 =^ 255 unsigned byte)
buf[12] = -1;
// Power
// Battery Level
buf[11] = 51;
// Cadence (=^ 255*16 strides/min)
buf[56] = -1;
@@ -37,9 +37,9 @@ public class ZephyrMessageParserTest extends TestCase {
assertTrue(sds.hasHeartRate());
assertTrue(sds.getHeartRate().getState() == Sensor.SensorState.SENDING);
assertEquals(255, sds.getHeartRate().getValue());
assertTrue(sds.hasPower());
assertTrue(sds.getPower().getState() == Sensor.SensorState.SENDING);
assertEquals(51, sds.getPower().getValue());
assertTrue(sds.hasBatteryLevel());
assertTrue(sds.getBatteryLevel().getState() == Sensor.SensorState.SENDING);
assertEquals(51, sds.getBatteryLevel().getValue());
assertTrue(sds.hasCadence());
assertTrue(sds.getCadence().getState() == Sensor.SensorState.SENDING);
assertEquals(255, sds.getCadence().getValue());