Use a reference count with SensorManagers created by SensorManagerFactory

This commit is contained in:
ml1050
2012-02-04 00:47:55 +01:00
parent 073c8a3c98
commit d105c58309
4 changed files with 94 additions and 57 deletions
@@ -17,23 +17,23 @@ public class SensorManagerFactoryTest extends AndroidTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
sharedPreferences = getContext().getSharedPreferences(
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
// Let's use default values.
sharedPreferences.edit().clear().apply();
}
@SmallTest
public void testDefaultSettings() throws Exception {
assertNull(SensorManagerFactory.getSensorManager(getContext()));
}
@SmallTest
public void testCreateZephyr() throws Exception {
assertClassForName(ZephyrSensorManager.class, R.string.sensor_type_value_zephyr);
}
@SmallTest
public void testCreateAnt() throws Exception {
assertClassForName(AntDirectSensorManager.class, R.string.sensor_type_value_ant);
@@ -52,5 +52,6 @@ public class SensorManagerFactoryTest extends AndroidTestCase {
SensorManager sm = SensorManagerFactory.getSensorManager(getContext());
assertNotNull(sm);
assertTrue(c.isInstance(sm));
SensorManagerFactory.releaseSensorManager(sm);
}
}