Skip to content

Commit

Permalink
Revert back to ActivityTestRule
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpoole committed Sep 19, 2023
1 parent 6b7e223 commit 96633c7
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/androidTest/java/de/blau/android/gpx/GpxTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,15 @@
import org.junit.runner.RunWith;

import android.app.Instrumentation;
import android.app.Instrumentation.ActivityMonitor;
import android.content.Context;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationManager;
import androidx.annotation.NonNull;
import androidx.test.core.app.ActivityScenario;
import androidx.test.ext.junit.rules.ActivityScenarioRule;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.rule.ActivityTestRule;
import androidx.test.uiautomator.UiDevice;
import androidx.test.uiautomator.UiObject2;
import androidx.test.uiautomator.Until;
Expand Down Expand Up @@ -69,11 +67,8 @@ public class GpxTest {
MockWebServer tileServer = null;
Preferences prefs = null;

/**
* Manual start of activity so that we can set up the monitor for main
*/
@Rule
public ActivityScenarioRule<Main> activityScenarioRule = new ActivityScenarioRule<>(Main.class);
public ActivityTestRule<Main> mActivityRule = new ActivityTestRule<>(Main.class);

/**
* Pre-test setup
Expand All @@ -85,10 +80,7 @@ public void setup() {
// this sets the mock location permission
instrumentation.getUiAutomation().executeShellCommand("appops set de.blau.android android:mock_location allow");

ActivityMonitor monitor = instrumentation.addMonitor(Main.class.getName(), null, false);
ActivityScenario scenario = ActivityScenario.launch(Main.class);
main = (Main) instrumentation.waitForMonitorWithTimeout(monitor, 30000);
instrumentation.removeMonitor(monitor);
main = mActivityRule.getActivity();

tileServer = MockTileServer.setupTileServer(main, "ersatz_background.mbt", true);
prefs = App.getPreferences(main);
Expand Down

0 comments on commit 96633c7

Please sign in to comment.