Move expectFail to TestUtil
Flag: NA Bug: 298234173 Test: atest TaplWorkspaceTest Change-Id: I7aadab92891ecdb9e8910601a6e1b417ffa5f605
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.android.launcher3.allapps;
|
||||
|
||||
import static com.android.launcher3.ui.TaplTestsLauncher3.expectFail;
|
||||
import static com.android.launcher3.util.TestUtil.expectFail;
|
||||
import static com.android.launcher3.ui.AbstractLauncherUiTest.initialize;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.android.launcher3.ui;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import androidx.test.filters.LargeTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
@@ -36,17 +35,6 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest {
|
||||
initialize(this);
|
||||
}
|
||||
|
||||
// Please don't add negative test cases for methods that fail only after a long wait.
|
||||
public static void expectFail(String message, Runnable action) {
|
||||
boolean failed = false;
|
||||
try {
|
||||
action.run();
|
||||
} catch (AssertionError e) {
|
||||
failed = true;
|
||||
}
|
||||
assertTrue(message, failed);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDevicePressMenu() throws Exception {
|
||||
mDevice.pressMenu();
|
||||
|
||||
@@ -24,6 +24,8 @@ import static com.android.launcher3.LauncherSettings.Settings.LAYOUT_DIGEST_KEY;
|
||||
import static com.android.launcher3.LauncherSettings.Settings.LAYOUT_DIGEST_LABEL;
|
||||
import static com.android.launcher3.LauncherSettings.Settings.LAYOUT_DIGEST_TAG;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import android.app.Instrumentation;
|
||||
import android.app.blob.BlobHandle;
|
||||
import android.app.blob.BlobStoreManager;
|
||||
@@ -252,6 +254,17 @@ public class TestUtil {
|
||||
}
|
||||
}
|
||||
|
||||
// Please don't add negative test cases for methods that fail only after a long wait.
|
||||
public static void expectFail(String message, Runnable action) {
|
||||
boolean failed = false;
|
||||
try {
|
||||
action.run();
|
||||
} catch (AssertionError e) {
|
||||
failed = true;
|
||||
}
|
||||
assertTrue(message, failed);
|
||||
}
|
||||
|
||||
/** Interface to indicate a runnable which can throw any exception. */
|
||||
public interface UncheckedRunnable {
|
||||
/** Method to run the task */
|
||||
|
||||
Reference in New Issue
Block a user