forked from upstream-mirrors/OpenTracks
Merge to head
This commit is contained in:
+2
-2
@@ -18,7 +18,7 @@ package com.google.android.apps.mytracks.services;
|
||||
import android.content.Context;
|
||||
import android.test.AndroidTestCase;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@@ -52,7 +52,7 @@ public class DefaultTrackNameFactoryTest extends AndroidTestCase {
|
||||
DefaultTrackNameFactory factory =
|
||||
new MockDefaultTrackNameFactory(getContext(), true);
|
||||
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||
DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
|
||||
assertEquals(formatter.format(new Date(TIMESTAMP)),
|
||||
factory.newTrackName(1, TIMESTAMP));
|
||||
}
|
||||
|
||||
+6
-7
@@ -151,17 +151,16 @@ public class TrackRecordingServiceTest
|
||||
|
||||
providerUtils = MyTracksProviderUtils.Factory.get(context);
|
||||
|
||||
sharedPreferences = context.getSharedPreferences(
|
||||
Constants.SETTINGS_NAME, 0);
|
||||
sharedPreferences = context.getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||
// Let's use default values.
|
||||
sharedPreferences.edit().clear().commit();
|
||||
sharedPreferences.edit().clear().apply();
|
||||
|
||||
// Disable auto resume by default.
|
||||
updateAutoResumePrefs(0, -1);
|
||||
// No recording track.
|
||||
Editor editor = sharedPreferences.edit();
|
||||
editor.putLong(context.getString(R.string.recording_track_key), -1);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
@@ -654,7 +653,7 @@ public class TrackRecordingServiceTest
|
||||
R.string.auto_resume_track_current_retry_key), attempts);
|
||||
editor.putInt(context.getString(
|
||||
R.string.auto_resume_track_timeout_key), timeoutMins);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
private Intent createStartIntent() {
|
||||
@@ -673,7 +672,7 @@ public class TrackRecordingServiceTest
|
||||
private void setRecordingTrack(long id) {
|
||||
Editor editor = sharedPreferences.edit();
|
||||
editor.putLong(context.getString(R.string.recording_track_key), id);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
// TODO: We support multiple values for readability, however this test's
|
||||
@@ -697,7 +696,7 @@ public class TrackRecordingServiceTest
|
||||
} else if (value == null) {
|
||||
// Do nothing, as clear above has already removed this property.
|
||||
}
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
|
||||
fullRecordingSession();
|
||||
}
|
||||
|
||||
+6
-5
@@ -2,9 +2,10 @@ package com.google.android.apps.mytracks.services.sensors;
|
||||
|
||||
import com.google.android.apps.mytracks.Constants;
|
||||
import com.google.android.apps.mytracks.services.sensors.ant.AntDirectSensorManager;
|
||||
import com.google.android.apps.mytracks.services.sensors.ant.AntSRMSensorManager;
|
||||
import com.google.android.apps.mytracks.services.sensors.ant.AntSrmBridgeSensorManager;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.test.AndroidTestCase;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
@@ -18,9 +19,9 @@ public class SensorManagerFactoryTest extends AndroidTestCase {
|
||||
super.setUp();
|
||||
|
||||
sharedPreferences = getContext().getSharedPreferences(
|
||||
Constants.SETTINGS_NAME, 0);
|
||||
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||
// Let's use default values.
|
||||
sharedPreferences.edit().clear().commit();
|
||||
sharedPreferences.edit().clear().apply();
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
@@ -40,14 +41,14 @@ public class SensorManagerFactoryTest extends AndroidTestCase {
|
||||
|
||||
@SmallTest
|
||||
public void testCreateAntSRM() throws Exception {
|
||||
assertClassForName(AntSRMSensorManager.class, R.string.sensor_type_value_srm_ant_bridge);
|
||||
assertClassForName(AntSrmBridgeSensorManager.class, R.string.sensor_type_value_srm_ant_bridge);
|
||||
}
|
||||
|
||||
private void assertClassForName(Class<?> c, int i) {
|
||||
sharedPreferences.edit()
|
||||
.putString(getContext().getString(R.string.sensor_type_key),
|
||||
getContext().getString(i))
|
||||
.commit();
|
||||
.apply();
|
||||
SensorManager sm = SensorManagerFactory.getSensorManager(getContext());
|
||||
assertNotNull(sm);
|
||||
assertTrue(c.isInstance(sm));
|
||||
|
||||
+3
-3
@@ -18,9 +18,9 @@ package com.google.android.apps.mytracks.services.sensors.ant;
|
||||
import com.dsi.ant.AntMesg;
|
||||
import com.google.android.apps.mytracks.Constants;
|
||||
import com.google.android.apps.mytracks.content.Sensor;
|
||||
import com.google.android.apps.mytracks.services.sensors.ant.AntDirectSensorManager;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.test.AndroidTestCase;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
@@ -32,9 +32,9 @@ public class AntDirectSensorManagerTest extends AndroidTestCase {
|
||||
|
||||
public void setUp() {
|
||||
sharedPreferences = getContext().getSharedPreferences(
|
||||
Constants.SETTINGS_NAME, 0);
|
||||
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||
// Let's use default values.
|
||||
sharedPreferences.edit().clear().commit();
|
||||
sharedPreferences.edit().clear().apply();
|
||||
manager = new AntDirectSensorManager(getContext());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user