forked from upstream-mirrors/OpenTracks
Fix polar tests and sensor strings.
This commit is contained in:
@@ -410,10 +410,5 @@ limitations under the License.
|
|||||||
<string name="sending">S\'està enviant</string>
|
<string name="sending">S\'està enviant</string>
|
||||||
|
|
||||||
<!-- Sensor Type Options -->
|
<!-- Sensor Type Options -->
|
||||||
<string name="no_sensor_option">NONE</string>
|
<string name="no_sensor_option">Cap</string>
|
||||||
<string name="ant_sensor_option">ANT+ Sensors</string>
|
|
||||||
<string name="ant_bridge_sensor_option">SRM ANT+ Bridge</string>
|
|
||||||
<string name="polar_bt_sensor_option">Polar Bluetooth</string>
|
|
||||||
<string name="zephyr_bt_sensor_option">Zephyr Bluetooth</string>
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -129,10 +129,7 @@ limitations under the License.
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<!-- Sensor Type Options -->
|
<!-- Sensor Type Options -->
|
||||||
<string name="no_sensor_option">NONE</string>
|
<string name="no_sensor_option">Ninguna</string>
|
||||||
<string name="ant_sensor_option">ANT+ Sensors</string>
|
<string name="ant_sensor_option">ANT+ Sensores</string>
|
||||||
<string name="ant_bridge_sensor_option">SRM ANT+ Bridge</string>
|
<string name="ant_bridge_sensor_option">SRM ANT+ Puente</string>
|
||||||
<string name="polar_bt_sensor_option">Polar Bluetooth</string>
|
|
||||||
<string name="zephyr_bt_sensor_option">Zephyr Bluetooth</string>
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -467,8 +467,6 @@ limitations under the License.
|
|||||||
<string name="no_sensor_option">なし</string>
|
<string name="no_sensor_option">なし</string>
|
||||||
<string name="ant_sensor_option">ANT+ センサー</string>
|
<string name="ant_sensor_option">ANT+ センサー</string>
|
||||||
<string name="ant_bridge_sensor_option">SRM ANT+ ブリッジ</string>
|
<string name="ant_bridge_sensor_option">SRM ANT+ ブリッジ</string>
|
||||||
<string name="polar_bt_sensor_option">Polar Bluetooth</string>
|
|
||||||
<string name="zephyr_bt_sensor_option">Zephyr Bluetooth</string>
|
|
||||||
|
|
||||||
<!-- Manifest description (not seen inside the app) -->
|
<!-- Manifest description (not seen inside the app) -->
|
||||||
<string name="notification_permission_label">トラック記録通知受信</string>
|
<string name="notification_permission_label">トラック記録通知受信</string>
|
||||||
|
|||||||
@@ -494,8 +494,6 @@ limitations under the License.
|
|||||||
<string name="no_sensor_option">Нет</string>
|
<string name="no_sensor_option">Нет</string>
|
||||||
<string name="ant_sensor_option">ANT+ Датчик</string>
|
<string name="ant_sensor_option">ANT+ Датчик</string>
|
||||||
<string name="ant_bridge_sensor_option">SRM ANT+ Bridge</string>
|
<string name="ant_bridge_sensor_option">SRM ANT+ Bridge</string>
|
||||||
<string name="polar_bt_sensor_option">Polar Bluetooth</string>
|
|
||||||
<string name="zephyr_bt_sensor_option">Zephyr Bluetooth</string>
|
|
||||||
|
|
||||||
<!-- Manifest description (not seen inside the app) -->
|
<!-- Manifest description (not seen inside the app) -->
|
||||||
<string name="notification_permission_label">получать уведомления о записи трека</string>
|
<string name="notification_permission_label">получать уведомления о записи трека</string>
|
||||||
|
|||||||
+43
-16
@@ -1,5 +1,7 @@
|
|||||||
package com.google.android.apps.mytracks.services.sensors;
|
package com.google.android.apps.mytracks.services.sensors;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.content.Sensor;
|
import com.google.android.apps.mytracks.content.Sensor;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
@@ -7,26 +9,40 @@ import junit.framework.TestCase;
|
|||||||
public class PolarMessageParserTest extends TestCase {
|
public class PolarMessageParserTest extends TestCase {
|
||||||
|
|
||||||
PolarMessageParser parser = new PolarMessageParser();
|
PolarMessageParser parser = new PolarMessageParser();
|
||||||
|
// A complete and valid Polar HxM packet
|
||||||
|
// FE08F701D1001104FE08F702D1001104
|
||||||
|
private final byte[] originalBuf =
|
||||||
|
{(byte) 0xFE, 0x08, (byte) 0xF7, 0x01, (byte) 0xD1, 0x00, 0x11, 0x04, (byte) 0xFE, 0x08,
|
||||||
|
(byte) 0xF7, 0x02, (byte) 0xD1, 0x00, 0x11, 0x04};
|
||||||
|
private byte[] buf;
|
||||||
|
|
||||||
|
public void setUp() {
|
||||||
|
buf = Arrays.copyOf(originalBuf, originalBuf.length);
|
||||||
|
}
|
||||||
|
|
||||||
public void testIsValid() {
|
public void testIsValid() {
|
||||||
// A complete and valid Polar HxM packet
|
assertTrue(parser.isValid(buf));
|
||||||
// FE08F701D1001104FE08F702D1001104
|
}
|
||||||
byte[] buf = { 0xFE,0x08,0xF7,0x01,0xD1,0x00,0x11,0x04,0xFE,0x08,0xF7,0x02,0xD1,0x00,0x11,0x04 };
|
|
||||||
|
public void testIsValid_invalidHeader() {
|
||||||
buf[0] = 0x03; // Invalidate header
|
// Invalidate header.
|
||||||
|
buf[0] = 0x03;
|
||||||
assertFalse(parser.isValid(buf));
|
assertFalse(parser.isValid(buf));
|
||||||
|
}
|
||||||
buf[0] = 0xFE; // Good header
|
|
||||||
buf[2] = 0x03; // Invalidate checkbyte
|
public void testIsValid_invalidCheckbyte() {
|
||||||
|
// Invalidate checkbyte.
|
||||||
|
buf[2] = 0x03;
|
||||||
assertFalse(parser.isValid(buf));
|
assertFalse(parser.isValid(buf));
|
||||||
|
}
|
||||||
buf[2] = 0xF7; // Good checkbyte
|
|
||||||
buf[3] = 0x11; // Invalidate sequence
|
public void testIsValid_invalidSequence() {
|
||||||
|
// Invalidate sequence.
|
||||||
|
buf[3] = 0x11;
|
||||||
assertFalse(parser.isValid(buf));
|
assertFalse(parser.isValid(buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testParseBuffer() {
|
public void testParseBuffer() {
|
||||||
byte[] buf = { 0xFE,0x08,0xF7,0x01,0xD1,0x00,0x11,0x04,0xFE,0x08,0xF7,0x02,0xD1,0x00,0x11,0x04 };
|
|
||||||
buf[5] = 70;
|
buf[5] = 70;
|
||||||
Sensor.SensorDataSet sds = parser.parseBuffer(buf);
|
Sensor.SensorDataSet sds = parser.parseBuffer(buf);
|
||||||
assertTrue(sds.hasHeartRate());
|
assertTrue(sds.hasHeartRate());
|
||||||
@@ -34,10 +50,21 @@ public class PolarMessageParserTest extends TestCase {
|
|||||||
assertEquals(70, sds.getHeartRate().getValue());
|
assertEquals(70, sds.getHeartRate().getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFindNextAlignment() {
|
public void testFindNextAlignment_offset() {
|
||||||
byte[] buf = { 0x0E,0x08,0xF7,0x01,0xD1,0x00,0x11,0x04,0x0E,0x08,0xF7,0x02,0xD1,0x00,0x11,0x04 };
|
// The first 4 bytes are garbage
|
||||||
|
buf = new byte[originalBuf.length + 4];
|
||||||
|
buf[0] = 4;
|
||||||
|
buf[1] = 2;
|
||||||
|
buf[2] = 4;
|
||||||
|
buf[3] = 2;
|
||||||
|
|
||||||
|
// Then the valid message.
|
||||||
|
System.arraycopy(originalBuf, 0, buf, 4, originalBuf.length);
|
||||||
|
assertEquals(4, parser.findNextAlignment(buf));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testFindNextAlignment_invalid() {
|
||||||
|
buf[0] = 0;
|
||||||
assertEquals(-1, parser.findNextAlignment(buf));
|
assertEquals(-1, parser.findNextAlignment(buf));
|
||||||
buf[8] = 0xFE;
|
|
||||||
assertEquals(8, parser.findNextAlignment(buf));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user