Skip to content

Commit

Permalink
Merge pull request #239 from enviroCar/develop
Browse files Browse the repository at this point in the history
merge for release of 0.10.0
  • Loading branch information
matthesrieke committed Jul 3, 2014
2 parents 1273df9 + 65412f3 commit e1a498b
Show file tree
Hide file tree
Showing 56 changed files with 2,008 additions and 715 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ else if (s.equals("01 10")) {
int bytethree = (1+random.nextInt(8));
int bytefour = (80+random.nextInt(19));
//MAF
rawData = "7F100"+ bytethree+""+ bytefour;
rawData = "41100"+ bytethree+""+ bytefour;
lastMaf = (bytethree * 256 + bytefour) / 100.0f;
}
else if (s.equals("01 0B")) {
Expand Down Expand Up @@ -506,6 +506,11 @@ else if (s.equals("01 0C")) {
rawData = "410C"+rawData.substring(4);
}
}
else if (s.equals("01 04")) {
//engine load
String val = integerToByteString(80+random.nextInt(140));
rawData = "4104" + val.substring(val.length()-2, val.length());
}
else {
String[] result = s.split(" ");
rawData = "";
Expand Down
2 changes: 1 addition & 1 deletion org.envirocar.app.test/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
android:label="@string/app_name">
<uses-library android:name="android.test.runner" />
</application>

Expand Down
7 changes: 7 additions & 0 deletions org.envirocar.app.test/res/layout/test_layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >


</LinearLayout>
16 changes: 16 additions & 0 deletions org.envirocar.app.test/res/xml/edit_text_summary_mock_layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >

<org.envirocar.app.activity.preference.EditPreferenceWithSummary
xmlns:enviroCar="http://envirocar.org"
android:key="ec_test_key"
android:title="testTitle"
android:summary="testSummary: %s"
android:defaultValue="5"
android:inputType="number"
enviroCar:min="0"
enviroCar:max="15"
android:maxLength="8"
android:id="@+id/test_id"/>

</PreferenceScreen>
186 changes: 0 additions & 186 deletions org.envirocar.app.test/src/org/envirocar/app/test/DbAdapterMockup.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,11 @@ public void testObfuscation() throws JSONException, TrackAlreadyFinishedExceptio
}

private Track createTrack() throws TrackAlreadyFinishedException {
Track result = Track.createNewLocalTrack(new DbAdapterMockup());
Track result = Track.createLocalTrack();
result.setCar(new Car(FuelType.DIESEL, "man", "mod", "id", 1234, 123));

List<Measurement> measurements = createMeasurements();
for (Measurement measurement : measurements) {
result.addMeasurement(measurement);
}
result.setMeasurementsAsArrayList(measurements);

return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import junit.framework.Assert;

import org.envirocar.app.storage.DbAdapter;
import org.envirocar.app.storage.Measurement;
import org.envirocar.app.storage.Track;
import org.envirocar.app.storage.TrackAlreadyFinishedException;
Expand All @@ -15,15 +14,13 @@

public class TrackComparisonTest extends AndroidTestCase {

private DbAdapter dbMock = new DbAdapterMockup();

public void testTracksWithMeasurements() throws TrackAlreadyFinishedException {
Track t1 = Track.createNewLocalTrack(dbMock);
t1.addMeasurement(createMeasurement(0));
Track t2 = Track.createNewLocalTrack(dbMock);
t2.addMeasurement(createMeasurement(1));
Track t3 = Track.createNewLocalTrack(dbMock);
t3.addMeasurement(createMeasurement(2));
Track t1 = Track.createLocalTrack();
t1.setMeasurementsAsArrayList(Collections.singletonList(createMeasurement(0)));
Track t2 = Track.createLocalTrack();
t2.setMeasurementsAsArrayList(Collections.singletonList(createMeasurement(1)));
Track t3 = Track.createLocalTrack();
t3.setMeasurementsAsArrayList(Collections.singletonList(createMeasurement(2)));

List<Track> list = createListAndSort(t1, t2, t3);

Expand All @@ -33,8 +30,8 @@ public void testTracksWithMeasurements() throws TrackAlreadyFinishedException {
}

public void testTracksWithoutMeasurements() {
Track t1 = Track.createNewLocalTrack(dbMock);
Track t3 = Track.createNewLocalTrack(dbMock);
Track t1 = Track.createLocalTrack();
Track t3 = Track.createLocalTrack();

List<Track> list = createListAndSort(t1, t3);

Expand All @@ -43,10 +40,10 @@ public void testTracksWithoutMeasurements() {
}

public void testOneTrackWithNoMeasurements() throws TrackAlreadyFinishedException {
Track t1 = Track.createNewLocalTrack(dbMock);
t1.addMeasurement(createMeasurement(0));
Track t2 = Track.createNewLocalTrack(dbMock);
Track t3 = Track.createNewLocalTrack(dbMock);
Track t1 = Track.createLocalTrack();
t1.setMeasurementsAsArrayList(Collections.singletonList(createMeasurement(0)));
Track t2 = Track.createLocalTrack();
Track t3 = Track.createLocalTrack();

List<Track> list = createListAndSort(t1, t2, t3);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,25 @@

package org.envirocar.app.test;

import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Collections;

import junit.framework.Assert;

import org.envirocar.app.json.StreamTrackEncoder;
import org.envirocar.app.json.TrackEncoder;
import org.envirocar.app.json.TrackWithoutMeasurementsException;
import org.envirocar.app.model.Car;
import org.envirocar.app.model.Car.FuelType;
import org.envirocar.app.storage.Measurement;
import org.envirocar.app.storage.Track;
import org.envirocar.app.storage.Measurement.PropertyKey;
import org.envirocar.app.storage.TrackAlreadyFinishedException;
import org.envirocar.app.storage.TrackMetadata;
import org.envirocar.app.storage.TrackWithoutMeasurementsException;
import org.envirocar.app.util.InputStreamWithLength;
import org.envirocar.app.util.Util;
import org.json.JSONException;
import org.json.JSONObject;

Expand Down Expand Up @@ -93,9 +101,9 @@ public void testMetadataEncoding() throws TrackAlreadyFinishedException, JSONExc
}

private Track createTrack() throws TrackAlreadyFinishedException {
Track result = Track.createNewLocalTrack(new DbAdapterMockup());
Track result = Track.createLocalTrack();
result.setCar(car);
result.addMeasurement(createMeasurement());
result.setMeasurementsAsArrayList(Collections.singletonList(createMeasurement()));
result.setDescription("desc");
result.setName("test-track");
return result;
Expand All @@ -108,5 +116,18 @@ private Measurement createMeasurement() {
m.setTime(1380105000000L);
return m;
}

public void testStreamEncoding() throws FileNotFoundException, IOException, TrackWithoutMeasurementsException, JSONException, TrackAlreadyFinishedException {
InputStreamWithLength in = new StreamTrackEncoder().createTrackJsonAsInputStream(createTrack(), false);
ByteArrayOutputStream content = Util.readStreamContents(in.getInputStream());

String json = new String(content.toByteArray());

JSONObject result = new JSONObject(json);
JSONObject expected = new JSONObject(expectedJson);

Assert.assertTrue("The JSON was null!", json != null);
Assert.assertTrue("The JSON was not as expected!", result.toString().equals(expected.toString()));

}
}
Loading

0 comments on commit e1a498b

Please sign in to comment.