forked from upstream-mirrors/OpenTracks
Merging Marian's change to German translation.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
<factorypath>
|
||||
<factorypathentry kind="PLUGIN" id="org.eclipse.jst.ws.annotations.core" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="WKSPJAR" id="/MyTracksTest/libs/AndroidMockGenerator.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="ANDROID_SDK/platforms/android-8/android.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="ANDROID_SDK/add-ons/addon_google_apis_google_inc_8/libs/maps.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="ANDROID_SDK/platforms/android-11/android.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="ANDROID_SDK/add-ons/addon_google_apis_google_inc_11/libs/maps.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="MYTRACKS_BIN" enabled="true" runInBatchMode="false"/>
|
||||
</factorypath>
|
||||
|
||||
@@ -10,4 +10,4 @@
|
||||
# Indicates whether an apk should be generated for each density.
|
||||
split.density=false
|
||||
# Project target.
|
||||
target=Google Inc.:Google APIs:9
|
||||
target=Google Inc.:Google APIs:11
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
// Copyright 2010 Google Inc. All Rights Reserved.
|
||||
package com.google.android.apps.mytracks.io;
|
||||
|
||||
import com.google.android.apps.mytracks.content.Waypoint;
|
||||
|
||||
import android.location.Location;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -30,57 +25,41 @@ public class GpxTrackWriterTest extends TrackFormatWriterTest {
|
||||
assertEquals(Long.toString(TRACK_ID),
|
||||
getChildTextValue(trackTag, "number"));
|
||||
List<Element> segmentTags = getChildElements(trackTag, "trkseg", 2);
|
||||
Element segment1Tag = segmentTags.get(0);
|
||||
Element segment2Tag = segmentTags.get(1);
|
||||
List<Element> seg1PointTags = getChildElements(segment1Tag, "trkpt", 2);
|
||||
List<Element> seg2PointTags = getChildElements(segment2Tag, "trkpt", 2);
|
||||
assertTagsMatchPoints(seg1PointTags, location1, location2);
|
||||
assertTagsMatchPoints(seg2PointTags, location3, location4);
|
||||
List<Element> segPointTags = getChildElements(segmentTags.get(0), "trkpt", 2);
|
||||
assertTagMatchesLocation(segPointTags.get(0),
|
||||
"0", "0", "1970-01-01T02:46:40Z", "0");
|
||||
assertTagMatchesLocation(segPointTags.get(1),
|
||||
"1", "-1", "1970-01-01T02:46:41Z", "5000000");
|
||||
|
||||
segPointTags = getChildElements(segmentTags.get(1), "trkpt", 2);
|
||||
assertTagMatchesLocation(segPointTags.get(0),
|
||||
"2", "-2", "1970-01-01T02:46:42Z", "10000000");
|
||||
assertTagMatchesLocation(segPointTags.get(1),
|
||||
"3", "-3", "1970-01-01T02:46:43Z", "15000000");
|
||||
|
||||
List<Element> waypointTags = getChildElements(gpxTag, "wpt", 2);
|
||||
assertTagsMatchWaypoints(waypointTags, wp1, wp2);
|
||||
Element wptTag = waypointTags.get(0);
|
||||
assertEquals(WAYPOINT1_NAME, getChildTextValue(wptTag, "name"));
|
||||
assertEquals(WAYPOINT1_DESCRIPTION, getChildTextValue(wptTag, "desc"));
|
||||
assertTagMatchesLocation(wptTag,
|
||||
"1", "-1", "1970-01-01T02:46:41Z", "5000000");
|
||||
|
||||
wptTag = waypointTags.get(1);
|
||||
assertEquals(WAYPOINT2_NAME, getChildTextValue(wptTag, "name"));
|
||||
assertEquals(WAYPOINT2_DESCRIPTION, getChildTextValue(wptTag, "desc"));
|
||||
assertTagMatchesLocation(wptTag,
|
||||
"2", "-2", "1970-01-01T02:46:42Z", "10000000");
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the given tags describe the given waypoints, in the same
|
||||
* order.
|
||||
* Asserts that the given tag describes the location given by the
|
||||
* Strings lat, lon, time, and ele.
|
||||
*/
|
||||
protected void assertTagsMatchWaypoints(List<Element> tags, Waypoint... wps) {
|
||||
assertEquals(wps.length, tags.size());
|
||||
for (int i = 0; i < wps.length; i++) {
|
||||
Element tag = tags.get(i);
|
||||
Waypoint wp = wps[i];
|
||||
Location loc = wp.getLocation();
|
||||
|
||||
assertTagMatchesLocation(tag, loc);
|
||||
|
||||
assertEquals(wp.getName(), getChildTextValue(tag, "name"));
|
||||
assertEquals(wp.getDescription(), getChildTextValue(tag, "desc"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the given tags describe the given points, in the same order.
|
||||
*/
|
||||
protected void assertTagsMatchPoints(List<Element> tags, Location... locs) {
|
||||
assertEquals(locs.length, tags.size());
|
||||
for (int i = 0; i < locs.length; i++) {
|
||||
Element tag = tags.get(i);
|
||||
Location loc = locs[i];
|
||||
|
||||
assertTagMatchesLocation(tag, loc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the given tag describes the given location.
|
||||
*/
|
||||
private void assertTagMatchesLocation(Element tag, Location loc) {
|
||||
assertEquals(Double.toString(loc.getLatitude()), tag.getAttribute("lat"));
|
||||
assertEquals(Double.toString(loc.getLongitude()), tag.getAttribute("lon"));
|
||||
assertEquals(
|
||||
GpxTrackWriter.TIMESTAMP_FORMAT.format(new Date(loc.getTime())),
|
||||
getChildTextValue(tag, "time"));
|
||||
assertEquals(Double.toString(loc.getAltitude()),
|
||||
getChildTextValue(tag, "ele"));
|
||||
private void assertTagMatchesLocation(Element tag, String lat,
|
||||
String lon, String time, String ele) {
|
||||
assertEquals(lat, tag.getAttribute("lat"));
|
||||
assertEquals(lon, tag.getAttribute("lon"));
|
||||
assertEquals(time, getChildTextValue(tag, "time"));
|
||||
assertEquals(ele, getChildTextValue(tag, "ele"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public abstract class TrackFormatWriterTest extends AndroidTestCase {
|
||||
protected void populateLocations(MyTracksLocation... locs) {
|
||||
for (int i = 0; i < locs.length; i++) {
|
||||
MyTracksLocation loc = locs[i];
|
||||
loc.setAltitude(i * 1000);
|
||||
loc.setAltitude(i * 5000000);
|
||||
loc.setLatitude(i);
|
||||
loc.setLongitude(-i);
|
||||
loc.setTime(10000000 + i * 1000);
|
||||
|
||||
@@ -267,8 +267,13 @@ public class TrackWriterTest extends AndroidTestCase {
|
||||
wpt.setId(i + 1);
|
||||
}
|
||||
|
||||
// Begin the track
|
||||
formatWriter.writeHeader();
|
||||
|
||||
// Expect reading/writing of the waypoints (except the first)
|
||||
formatWriter.writeWaypoint(wptEq(wps[1]));
|
||||
formatWriter.writeWaypoint(wptEq(wps[2]));
|
||||
|
||||
// Begin the track
|
||||
formatWriter.writeBeginTrack(locEq(locs[0]));
|
||||
|
||||
// Write locations 1-2
|
||||
@@ -289,10 +294,6 @@ public class TrackWriterTest extends AndroidTestCase {
|
||||
// End the track
|
||||
formatWriter.writeEndTrack(locEq(locs[5]));
|
||||
|
||||
// Expect reading/writing of the waypoints (except the first)
|
||||
formatWriter.writeWaypoint(wptEq(wps[1]));
|
||||
formatWriter.writeWaypoint(wptEq(wps[2]));
|
||||
|
||||
formatWriter.writeFooter();
|
||||
formatWriter.close();
|
||||
|
||||
|
||||
+11
@@ -20,6 +20,7 @@ import android.content.SharedPreferences.Editor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
@@ -81,6 +82,11 @@ public class PreferenceBackupHelperTest extends TestCase {
|
||||
return put(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Editor putStringSet(String key, Set<String> value) {
|
||||
return put(key, value);
|
||||
}
|
||||
|
||||
private <T> Editor put(String key, T value) {
|
||||
newPreferences.put(key, value);
|
||||
return this;
|
||||
@@ -137,6 +143,11 @@ public class PreferenceBackupHelperTest extends TestCase {
|
||||
return get(key, defValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getStringSet(String key, Set<String> defValue) {
|
||||
return get(key, defValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerOnSharedPreferenceChangeListener(
|
||||
OnSharedPreferenceChangeListener listener) {
|
||||
|
||||
+17
-19
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2009 Google Inc.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
@@ -28,7 +28,7 @@ public class AntDirectSensorManagerTest extends AndroidTestCase {
|
||||
|
||||
private SharedPreferences sharedPreferences;
|
||||
private AntDirectSensorManager manager;
|
||||
|
||||
|
||||
public void setUp() {
|
||||
sharedPreferences = getContext().getSharedPreferences(
|
||||
MyTracksSettings.SETTINGS_NAME, 0);
|
||||
@@ -36,14 +36,16 @@ public class AntDirectSensorManagerTest extends AndroidTestCase {
|
||||
sharedPreferences.edit().clear().commit();
|
||||
manager = new AntDirectSensorManager(getContext());
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@SmallTest
|
||||
public void testBroadcastData() {
|
||||
manager.setDeviceNumberHRM((short) 42);
|
||||
byte[] buff = new byte[11];
|
||||
buff[0] = 9;
|
||||
buff[1] = AntMesg.MESG_BROADCAST_DATA_ID;
|
||||
buff[2] = 0; // HRM CHANNEL
|
||||
buff[10] = (byte) 220;
|
||||
buff[10] = (byte) 220;
|
||||
manager.handleMessage(buff);
|
||||
|
||||
Sensor.SensorDataSet sds = manager.getSensorDataSet();
|
||||
@@ -52,24 +54,16 @@ public class AntDirectSensorManagerTest extends AndroidTestCase {
|
||||
assertEquals(Sensor.SensorState.SENDING,
|
||||
sds.getHeartRate().getState());
|
||||
assertEquals(220, sds.getHeartRate().getValue());
|
||||
|
||||
|
||||
assertFalse(sds.hasCadence());
|
||||
assertFalse(sds.hasPower());
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testHandleChannelId() {
|
||||
assertEquals(0, manager.getDeviceNumberHRM());
|
||||
short id = 42;
|
||||
byte[] buff = new byte[5];
|
||||
buff[3] = 42;
|
||||
manager.handleChannelId(buff);
|
||||
assertEquals(id, manager.getDeviceNumberHRM());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@SmallTest
|
||||
public void testChannelId() {
|
||||
byte[] buff = new byte[11];
|
||||
buff[0] = 9;
|
||||
buff[1] = AntMesg.MESG_CHANNEL_ID_ID;
|
||||
buff[3] = 42;
|
||||
manager.handleMessage(buff);
|
||||
@@ -81,17 +75,21 @@ public class AntDirectSensorManagerTest extends AndroidTestCase {
|
||||
assertNull(manager.getSensorDataSet());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@SmallTest
|
||||
public void testResponseEvent() {
|
||||
assertEquals(Sensor.SensorState.NONE, manager.getSensorState());
|
||||
byte[] buff = new byte[11];
|
||||
byte[] buff = new byte[5];
|
||||
buff[0] = 3; // length
|
||||
buff[1] = AntMesg.MESG_RESPONSE_EVENT_ID;
|
||||
buff[2] = 0; // channel
|
||||
buff[3] = AntMesg.MESG_UNASSIGN_CHANNEL_ID;
|
||||
buff[4] = 0; // code
|
||||
manager.handleMessage(buff);
|
||||
|
||||
assertEquals(Sensor.SensorState.DISCONNECTED, manager.getSensorState());
|
||||
assertNull(manager.getSensorDataSet());
|
||||
}
|
||||
|
||||
|
||||
// TODO: Test timeout too.
|
||||
}
|
||||
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright 2011 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package com.google.android.apps.mytracks.services.sensors;
|
||||
|
||||
import android.test.AndroidTestCase;
|
||||
import android.test.MoreAsserts;
|
||||
|
||||
public class AntSensorManagerTest extends AndroidTestCase {
|
||||
private class TestAntSensorManager extends AntSensorManager {
|
||||
public byte messageId;
|
||||
public byte[] messageData;
|
||||
|
||||
public TestAntSensorManager() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupAntSensorChannels() {}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void handleMessage(byte[] rawMessage) {
|
||||
super.handleMessage(rawMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleMessage(byte messageId, byte[] messageData) {
|
||||
this.messageId = messageId;
|
||||
this.messageData = messageData;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private final TestAntSensorManager sensorManager = new TestAntSensorManager();
|
||||
|
||||
public void testSimple() {
|
||||
byte[] rawMessage = {
|
||||
0x03, // length
|
||||
0x12, // message id
|
||||
0x11, 0x22, 0x33, // body
|
||||
};
|
||||
|
||||
byte[] expectedBody = { 0x11, 0x22, 0x33 };
|
||||
|
||||
sensorManager.handleMessage(rawMessage);
|
||||
assertEquals((byte) 0x12, sensorManager.messageId);
|
||||
MoreAsserts.assertEquals(expectedBody, sensorManager.messageData);
|
||||
}
|
||||
|
||||
public void testTooShort() {
|
||||
byte[] rawMessage = {
|
||||
0x53, // length
|
||||
0x12 // message id
|
||||
};
|
||||
|
||||
sensorManager.handleMessage(rawMessage);
|
||||
assertEquals(0, sensorManager.messageId);
|
||||
assertNull(sensorManager.messageData);
|
||||
}
|
||||
|
||||
public void testLengthWrong() {
|
||||
byte[] rawMessage = {
|
||||
0x53, // length
|
||||
0x12, // message id
|
||||
0x34, // body
|
||||
};
|
||||
|
||||
sensorManager.handleMessage(rawMessage);
|
||||
assertEquals(0, sensorManager.messageId);
|
||||
assertNull(sensorManager.messageData);
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2011 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package com.google.android.apps.mytracks.services.sensors.ant;
|
||||
|
||||
import android.test.AndroidTestCase;
|
||||
|
||||
public class AntChannelIdMessageTest extends AndroidTestCase {
|
||||
public void testParse() {
|
||||
byte[] rawMessage = {
|
||||
0, // channel number
|
||||
0x34, 0x12, // device number
|
||||
(byte) 0xaa, // device type id
|
||||
(byte) 0xbb, // transmission type
|
||||
};
|
||||
|
||||
AntChannelIdMessage message = new AntChannelIdMessage(rawMessage);
|
||||
assertEquals(0, message.getChannelNumber());
|
||||
assertEquals(0x1234, message.getDeviceNumber());
|
||||
assertEquals((byte) 0xaa, message.getDeviceTypeId());
|
||||
assertEquals((byte) 0xbb, message.getTransmissionType());
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2011 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package com.google.android.apps.mytracks.services.sensors.ant;
|
||||
|
||||
import com.dsi.ant.AntDefine;
|
||||
import com.dsi.ant.AntMesg;
|
||||
|
||||
import android.test.AndroidTestCase;
|
||||
|
||||
public class AntChannelResponseMessageTest extends AndroidTestCase {
|
||||
public void testParse() {
|
||||
byte[] rawMessage = {
|
||||
0,
|
||||
AntMesg.MESG_EVENT_ID,
|
||||
AntDefine.EVENT_RX_SEARCH_TIMEOUT
|
||||
};
|
||||
AntChannelResponseMessage message = new AntChannelResponseMessage(rawMessage);
|
||||
|
||||
assertEquals(0, message.getChannelNumber());
|
||||
assertEquals(AntMesg.MESG_EVENT_ID, message.getMessageId());
|
||||
assertEquals(AntDefine.EVENT_RX_SEARCH_TIMEOUT, message.getMessageCode());
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2011 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package com.google.android.apps.mytracks.services.sensors.ant;
|
||||
|
||||
import android.test.AndroidTestCase;
|
||||
|
||||
public class AntMessageTest extends AndroidTestCase {
|
||||
private static class TestAntMessage extends AntMessage {
|
||||
public static short decodeShort(byte low, byte high) {
|
||||
return AntMessage.decodeShort(low, high);
|
||||
}
|
||||
}
|
||||
|
||||
public void testDecode() {
|
||||
assertEquals(0x1234, TestAntMessage.decodeShort((byte) 0x34, (byte) 0x12));
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2011 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package com.google.android.apps.mytracks.services.sensors.ant;
|
||||
|
||||
import android.test.AndroidTestCase;
|
||||
|
||||
public class AntStartupMessageTest extends AndroidTestCase {
|
||||
public void testParse() {
|
||||
byte[] rawMessage = {
|
||||
0x12,
|
||||
};
|
||||
|
||||
AntStartupMessage message = new AntStartupMessage(rawMessage);
|
||||
assertEquals(0x12, message.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -63,8 +63,7 @@ public class ChartURLGeneratorTest extends TestCase {
|
||||
elevations,
|
||||
t,
|
||||
"Title",
|
||||
true,
|
||||
false);
|
||||
true);
|
||||
|
||||
assertEquals(
|
||||
"http://chart.apis.google.com/chart?&chs=600x350&cht=lxy&"
|
||||
|
||||
Reference in New Issue
Block a user