Close WhatsNewActivity if open

Signed-off-by: Unpublished <unpublished@gmx.net>
This commit is contained in:
Unpublished 2019-05-20 21:23:36 +02:00
parent bd4bc646c6
commit c635e2e49a

View file

@ -1,14 +1,20 @@
package com.owncloud.android.ui.activity;
import android.app.Activity;
import com.nextcloud.client.whatsnew.WhatsNewActivity;
import com.owncloud.android.AbstractIT;
import org.junit.Rule;
import org.junit.Test;
import androidx.test.core.app.ActivityScenario;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.rule.GrantPermissionRule;
import androidx.test.runner.lifecycle.ActivityLifecycleMonitorRegistry;
import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE;
import static androidx.test.runner.lifecycle.Stage.RESUMED;
public class FileDisplayActivityTest extends AbstractIT {
@ -17,6 +23,13 @@ public class FileDisplayActivityTest extends AbstractIT {
@Test
public void testSetupToolbar() {
try (ActivityScenario<FileDisplayActivity> scenario = ActivityScenario.launch(FileDisplayActivity.class)) {
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
Activity activity =
ActivityLifecycleMonitorRegistry.getInstance().getActivitiesInStage(RESUMED).iterator().next();
if (activity instanceof WhatsNewActivity) {
activity.onBackPressed();
}
});
scenario.recreate();
}
}