PublicAPI: add test for setting icon via parameter.

Follow-up to #1818.
This commit is contained in:
Dennis Guse
2024-04-08 18:17:54 +02:00
parent dfdbc373ff
commit 52624b5cfe
2 changed files with 29 additions and 2 deletions
@@ -1,18 +1,24 @@
package de.dennisguse.opentracks.publicapi;
import android.content.Context;
import android.content.Intent;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
import androidx.test.rule.GrantPermissionRule;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.List;
import de.dennisguse.opentracks.R;
import de.dennisguse.opentracks.TestUtil;
import de.dennisguse.opentracks.data.ContentProviderUtils;
import de.dennisguse.opentracks.data.models.Track;
import de.dennisguse.opentracks.settings.PreferencesUtils;
import de.dennisguse.opentracks.util.IntentUtils;
@@ -35,12 +41,23 @@ public class PublicApiTest {
@Test
public void StartStopTest() throws InterruptedException {
PreferencesUtils.setBoolean(R.string.publicapi_enabled_key, true);
context.startActivity(IntentUtils.newIntent(context, StartRecording.class));
Intent startIntent = IntentUtils.newIntent(context, StartRecording.class);
startIntent.putExtra("TRACK_NAME", "trackName");
startIntent.putExtra("TRACK_CATEGORY", "activityTypeLocalized");
startIntent.putExtra("TRACK_ICON", "airplane");
startIntent.putExtra("TRACK_DESCRIPTION", "description");
context.startActivity(startIntent);
Thread.sleep(5000);
context.startActivity(IntentUtils.newIntent(context, StopRecording.class));
List<Track> tracks = new ContentProviderUtils(context).getTracks();
Assert.assertEquals(1, tracks.size());
Track track = tracks.get(0);
Assert.assertEquals("trackName", track.getName());
Assert.assertEquals("activityTypeLocalized", track.getActivityTypeLocalized());
Assert.assertEquals("airplane", track.getActivityType().getId());
}
@Test
@@ -130,6 +130,16 @@ public class Track {
this.trackStatistics = trackStatistics;
}
@Override
public String toString() {
return "Track{" +
"name='" + name + '\'' +
", description='" + description + '\'' +
", activityTypeLocalized='" + activityTypeLocalized + '\'' +
", activityType=" + activityType +
'}';
}
@Override
public boolean equals(Object o) {
if (this == o) return true;