Ensure split screen will be closed after the test

If the test crashes for any reason, still clean-up the device to leave
the device in a consistent state and avoid affecting other tests.

Test: atest FlickerTests
Change-Id: I53d4288b765a5c5221fae4cd1b8ce2b5035676a8
This commit is contained in:
Nataniel Borges
2020-03-12 17:04:37 +01:00
parent b1d388c751
commit 4658c78dbe
2 changed files with 27 additions and 0 deletions

View File

@@ -20,10 +20,13 @@ import static com.android.server.wm.flicker.CommonTransitions.resizeSplitScreen;
import static com.android.server.wm.flicker.WindowUtils.getDisplayBounds;
import static com.android.server.wm.flicker.WindowUtils.getDockedStackDividerInset;
import static com.android.server.wm.flicker.WindowUtils.getNavigationBarHeight;
import static com.android.server.wm.flicker.helpers.AutomationUtils.exitSplitScreen;
import static com.android.server.wm.flicker.helpers.AutomationUtils.isInSplitScreen;
import static com.google.common.truth.Truth.assertThat;
import android.graphics.Rect;
import android.support.test.uiautomator.UiDevice;
import android.util.Rational;
import androidx.test.InstrumentationRegistry;
@@ -32,6 +35,7 @@ import androidx.test.filters.LargeTest;
import com.android.server.wm.flicker.helpers.ImeAppHelper;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Ignore;
@@ -183,4 +187,13 @@ public class ResizeSplitScreenTest extends NonRotationTestBase {
.showsAboveAppWindow(DOCKED_STACK_DIVIDER)
.forAllEntries());
}
@AfterClass
public static void teardown() {
UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
if (isInSplitScreen(device)) {
exitSplitScreen(device);
}
}
}

View File

@@ -18,12 +18,17 @@ package com.android.server.wm.flicker;
import static com.android.server.wm.flicker.CommonTransitions.splitScreenToLauncher;
import static com.android.server.wm.flicker.WindowUtils.getDisplayBounds;
import static com.android.server.wm.flicker.helpers.AutomationUtils.exitSplitScreen;
import static com.android.server.wm.flicker.helpers.AutomationUtils.isInSplitScreen;
import android.support.test.uiautomator.UiDevice;
import androidx.test.InstrumentationRegistry;
import androidx.test.filters.FlakyTest;
import androidx.test.filters.LargeTest;
import androidx.test.runner.AndroidJUnit4;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Ignore;
@@ -97,4 +102,13 @@ public class SplitScreenToLauncherTest extends FlickerTestBase {
.hidesAboveAppWindow(DOCKED_STACK_DIVIDER)
.forAllEntries());
}
@AfterClass
public static void teardown() {
UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
if (isInSplitScreen(device)) {
exitSplitScreen(device);
}
}
}