This commit is contained in:
Dennis Guse
2021-07-31 07:42:39 +02:00
parent d898d51f1a
commit 348f74c4b3
8 changed files with 32 additions and 33 deletions
@@ -1,6 +1,20 @@
package de.dennisguse.opentracks; package de.dennisguse.opentracks;
import static androidx.test.espresso.Espresso.onData;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.action.ViewActions.scrollTo;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withClassName;
import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.anything;
import static org.hamcrest.Matchers.is;
import android.content.Context; import android.content.Context;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@@ -24,20 +38,6 @@ import org.junit.Test;
import org.junit.rules.TestRule; import org.junit.rules.TestRule;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import static androidx.test.espresso.Espresso.onData;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.action.ViewActions.scrollTo;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withClassName;
import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.anything;
import static org.hamcrest.Matchers.is;
/** /**
* Espresso test that checks the unit for activity category selected. * Espresso test that checks the unit for activity category selected.
* Also it checks that unit is properly when user change from a pace activity to an speed one. * Also it checks that unit is properly when user change from a pace activity to an speed one.
@@ -153,7 +153,7 @@ public class EspressoCategoryUnitTest {
private static Matcher<View> childAtPosition( private static Matcher<View> childAtPosition(
final Matcher<View> parentMatcher, final int position) { final Matcher<View> parentMatcher, final int position) {
return new TypeSafeMatcher<View>() { return new TypeSafeMatcher<>() {
@Override @Override
public void describeTo(Description description) { public void describeTo(Description description) {
description.appendText("Child at position " + position + " in parent "); description.appendText("Child at position " + position + " in parent ");
@@ -15,6 +15,13 @@
*/ */
package de.dennisguse.opentracks.services; package de.dennisguse.opentracks.services;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import android.content.ContentProvider; import android.content.ContentProvider;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@@ -61,13 +68,6 @@ import de.dennisguse.opentracks.services.sensors.AltitudeSumManager;
import de.dennisguse.opentracks.stats.TrackStatistics; import de.dennisguse.opentracks.stats.TrackStatistics;
import de.dennisguse.opentracks.util.PreferencesUtils; import de.dennisguse.opentracks.util.PreferencesUtils;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
/** /**
* Tests for the track recording service. * Tests for the track recording service.
* *
@@ -115,7 +115,7 @@ public class TrackRecordingServiceTest {
}; };
@Before @Before
public void setUp() throws TimeoutException { public void setUp() {
// Set up the mock content resolver // Set up the mock content resolver
ContentProvider customContentProvider = new CustomContentProvider() { ContentProvider customContentProvider = new CustomContentProvider() {
}; };
@@ -276,7 +276,7 @@ public class TrackRecordingServiceTest {
@MediumTest @MediumTest
@Test @Test
public void testRecording_resumeStoppedTrack() throws TimeoutException, InterruptedException { public void testRecording_resumeStoppedTrack() throws TimeoutException {
// given // given
TrackRecordingService service = ((TrackRecordingService.Binder) mServiceRule.bindService(createStartIntent(context))) TrackRecordingService service = ((TrackRecordingService.Binder) mServiceRule.bindService(createStartIntent(context)))
.getService(); .getService();
@@ -400,7 +400,7 @@ public class TrackRecordingServiceTest {
@MediumTest @MediumTest
@Test @Test
public void testInsertWaypointMarker_validWaypoint() throws TimeoutException, InterruptedException { public void testInsertWaypointMarker_validWaypoint() throws TimeoutException {
// given // given
TrackRecordingService service = ((TrackRecordingService.Binder) mServiceRule.bindService(createStartIntent(context))) TrackRecordingService service = ((TrackRecordingService.Binder) mServiceRule.bindService(createStartIntent(context)))
.getService(); .getService();
@@ -452,7 +452,7 @@ public class TrackRecordingServiceTest {
addTrack(dummyTrack); addTrack(dummyTrack);
} }
static void newTrackPoint(TrackRecordingService trackRecordingService, double latitude, double longitude, float accuracy, long speed) throws InterruptedException { static void newTrackPoint(TrackRecordingService trackRecordingService, double latitude, double longitude, float accuracy, long speed) {
newTrackPoint(trackRecordingService, latitude, longitude, accuracy, speed, System.currentTimeMillis()); newTrackPoint(trackRecordingService, latitude, longitude, accuracy, speed, System.currentTimeMillis());
} }
@@ -50,7 +50,7 @@ public class MarkerResourceCursorAdapter extends ResourceCursorAdapter implement
final long usedMemory = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); final long usedMemory = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
final int cacheSize = (int) (Runtime.getRuntime().maxMemory() - usedMemory) / 8; final int cacheSize = (int) (Runtime.getRuntime().maxMemory() - usedMemory) / 8;
memoryCache = new LruCache<String, Bitmap>(cacheSize) { memoryCache = new LruCache<>(cacheSize) {
@Override @Override
protected int sizeOf(@NonNull String key, @NonNull Bitmap bitmap) { protected int sizeOf(@NonNull String key, @NonNull Bitmap bitmap) {
return bitmap.getByteCount(); return bitmap.getByteCount();
@@ -309,7 +309,7 @@ public final class Marker {
parcel.writeLong(id); parcel.writeLong(id);
} }
public static final Parcelable.Creator<Id> CREATOR = new Parcelable.Creator<Id>() { public static final Parcelable.Creator<Id> CREATOR = new Parcelable.Creator<>() {
public Id createFromParcel(Parcel in) { public Id createFromParcel(Parcel in) {
return new Id(in.readLong()); return new Id(in.readLong());
} }
@@ -167,7 +167,7 @@ public class Track {
parcel.writeLong(id); parcel.writeLong(id);
} }
public static final Parcelable.Creator<Track.Id> CREATOR = new Parcelable.Creator<Track.Id>() { public static final Parcelable.Creator<Track.Id> CREATOR = new Parcelable.Creator<>() {
public Track.Id createFromParcel(Parcel in) { public Track.Id createFromParcel(Parcel in) {
return new Track.Id(in.readLong()); return new Track.Id(in.readLong());
} }
@@ -100,7 +100,7 @@ public class IntervalsFragment extends Fragment {
// TODO handle empty view: before we did viewBinding.intervalList.setEmptyView(viewBinding.intervalListEmptyView); // TODO handle empty view: before we did viewBinding.intervalList.setEmptyView(viewBinding.intervalListEmptyView);
viewBinding.intervalList.setAdapter(adapter); viewBinding.intervalList.setAdapter(adapter);
spinnerAdapter = new ArrayAdapter<IntervalStatisticsModel.IntervalOption>(getContext(), android.R.layout.simple_spinner_dropdown_item, IntervalStatisticsModel.IntervalOption.values()) { spinnerAdapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_dropdown_item, IntervalStatisticsModel.IntervalOption.values()) {
@NonNull @NonNull
@Override @Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
@@ -21,7 +21,6 @@ import android.util.Log;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import org.xml.sax.Locator; import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler; import org.xml.sax.helpers.DefaultHandler;
import java.time.Instant; import java.time.Instant;
@@ -122,7 +121,7 @@ public class GpxTrackImporter extends DefaultHandler implements XMLImporter.Trac
} }
@Override @Override
public void startElement(String uri, String localName, String tag, Attributes attributes) throws SAXException { public void startElement(String uri, String localName, String tag, Attributes attributes) {
switch (tag) { switch (tag) {
case TAG_MARKER: case TAG_MARKER:
onMarkerStart(attributes); onMarkerStart(attributes);
+1 -1
View File
@@ -273,7 +273,7 @@
android:id="@+id/stats_altitude_group" android:id="@+id/stats_altitude_group"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:constraint_referenced_ids="stats_altitude_horizontal_line,stats_altitude_gain_label,@+id/stats_altitude_gain_value,@+id/stats_altitude_gain_unit,stats_altitude_loss_label,@+id/stats_altitude_loss_value,@+id/stats_altitude_loss_unit" /> app:constraint_referenced_ids="stats_altitude_horizontal_line,stats_altitude_gain_label,stats_altitude_gain_value,stats_altitude_gain_unit,stats_altitude_loss_label,stats_altitude_loss_value,stats_altitude_loss_unit" />
<TextView <TextView
android:id="@+id/stats_altitude_gain_label" android:id="@+id/stats_altitude_gain_label"