Skip to content

Commit

Permalink
changed getting initial frameId
Browse files Browse the repository at this point in the history
  • Loading branch information
Corwin-Kh committed May 14, 2024
1 parent 33b7fc6 commit c5ff168
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@

import android.os.Handler;
import android.os.Looper;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.lifecycle.Lifecycle;
import androidx.test.espresso.Espresso;
import androidx.test.espresso.IdlingPolicies;
import androidx.test.ext.junit.rules.ActivityScenarioRule;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;

import net.osmand.PlatformUtil;
import net.osmand.core.android.MapRendererView;
import net.osmand.gpx.GPXFile;
import net.osmand.gpx.GpxParameter;
Expand All @@ -28,6 +29,7 @@
import net.osmand.test.common.ResourcesImporter;
import net.osmand.util.Algorithms;

import org.apache.commons.logging.Log;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
Expand All @@ -42,6 +44,7 @@
@LargeTest
@RunWith(AndroidJUnit4.class)
public class AnalysisUpdateCallsTest extends AndroidTest {
public static final Log LOG = PlatformUtil.getLog(AnalysisUpdateCallsTest.class);

private static final String SELECTED_GPX_NAME = "gpx_recalc_test.gpx";

Expand Down Expand Up @@ -84,17 +87,17 @@ public void test() throws Throwable {
gpxFile.path = testItem.getFile().getPath();
app.getSelectedGpxHelper().selectGpxFile(gpxFile, params);

mActivityScenarioRule.getScenario().onActivity(activity -> {
mActivityScenarioRule.getScenario().moveToState(Lifecycle.State.RESUMED).onActivity(activity -> {
mapView = activity.getMapView();

MapRendererView rendererView = mapView.getMapRenderer();
if (rendererView != null) {
startFrameId = rendererView.getFrameId();
}
});

observeDistToFinishIdlingResource = new ObserveDistToFinishIdlingResource(app);
registerIdlingResources(observeDistToFinishIdlingResource);
observeDistToFinishIdlingResource = new ObserveDistToFinishIdlingResource(app);
registerIdlingResources(observeDistToFinishIdlingResource);

});
Espresso.onIdle();
}

Expand Down Expand Up @@ -128,6 +131,7 @@ public ObserveDistToFinishIdlingResource(@NonNull OsmandApplication app) {
MapRendererView rendererView = mapView.getMapRenderer();
if (rendererView != null) {
int renderedFrames = rendererView.getFrameId() - startFrameId;
LOG.debug("rendered " + renderedFrames + " frames");
if(renderedFrames < 50) {
throw new AssertionError("Map rendering to slow. rendered " + renderedFrames + " frames");
}
Expand Down

0 comments on commit c5ff168

Please sign in to comment.