Add assumption check to skip inline autofill tests on automotive
* automotive doesn't have the FEATURE_INPUT_METHODS, so MockIme
is not available there. For this reason, inline autofill
tests will fail because the inline suggestions won't show up
in the default IME from the automotive
* Adding assumption check for availability of FEATURE_INPUT_METHOD
will skip these tests on aotomotive
Test: atest android.autofillservice.cts.inline
on gcar_hl_emu_x86-userdebug emulator
Bug: 159631291
Change-Id: Idb0d1401bd643aa45ca657fd670f4b4f80b0ef56
diff --git a/tests/autofillservice/src/android/autofillservice/cts/inline/DatasetFilteringInlineTest.java b/tests/autofillservice/src/android/autofillservice/cts/inline/DatasetFilteringInlineTest.java
index e303321..036e744 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/inline/DatasetFilteringInlineTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/inline/DatasetFilteringInlineTest.java
@@ -22,11 +22,19 @@
import android.autofillservice.cts.DatasetFilteringTest;
import android.autofillservice.cts.Helper;
+import org.junit.rules.TestRule;
+
public class DatasetFilteringInlineTest extends DatasetFilteringTest {
public DatasetFilteringInlineTest() {
super(getInlineUiBot());
}
+
+ @Override
+ public TestRule getMainTestRule() {
+ return InlineUiBot.annotateRule(super.getMainTestRule());
+ }
+
@Override
protected boolean isInlineMode() {
return true;
diff --git a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineAugmentedLoginActivityTest.java b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineAugmentedLoginActivityTest.java
index d645834..332c645 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineAugmentedLoginActivityTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineAugmentedLoginActivityTest.java
@@ -43,6 +43,7 @@
import android.widget.EditText;
import org.junit.Test;
+import org.junit.rules.TestRule;
import java.util.List;
@@ -66,6 +67,11 @@
};
}
+ @Override
+ public TestRule getMainTestRule() {
+ return InlineUiBot.annotateRule(super.getMainTestRule());
+ }
+
@Test
public void testAugmentedAutoFill_oneDatasetThenFilled() throws Exception {
// Set services
diff --git a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineAuthenticationTest.java b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineAuthenticationTest.java
index 43c2abc..5c63891 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineAuthenticationTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineAuthenticationTest.java
@@ -38,6 +38,7 @@
import android.platform.test.annotations.AppModeFull;
import org.junit.Test;
+import org.junit.rules.TestRule;
import java.util.regex.Pattern;
@@ -61,6 +62,11 @@
Helper.enableAutofillService(getContext(), SERVICE_NAME);
}
+ @Override
+ public TestRule getMainTestRule() {
+ return InlineUiBot.annotateRule(super.getMainTestRule());
+ }
+
@Test
public void testDatasetAuthTwoFields() throws Exception {
datasetAuthTwoFields(/* cancelFirstAttempt */ false);
diff --git a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineFillEventHistoryTest.java b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineFillEventHistoryTest.java
index feba57c..595b7ea 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineFillEventHistoryTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineFillEventHistoryTest.java
@@ -39,6 +39,7 @@
import android.support.test.uiautomator.UiObject2;
import org.junit.Test;
+import org.junit.rules.TestRule;
import java.util.List;
@@ -62,6 +63,11 @@
Helper.enableAutofillService(getContext(), SERVICE_NAME);
}
+ @Override
+ public TestRule getMainTestRule() {
+ return InlineUiBot.annotateRule(super.getMainTestRule());
+ }
+
@Test
public void testOneDatasetAndSave() throws Exception {
enableService();
diff --git a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineFilteringTest.java b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineFilteringTest.java
index e9675b1..c761d02 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineFilteringTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineFilteringTest.java
@@ -26,6 +26,7 @@
import android.autofillservice.cts.Helper;
import org.junit.Test;
+import org.junit.rules.TestRule;
// TODO: Move any tests needed from here into DatasetFilteringInlineTest.
/**
@@ -45,6 +46,11 @@
Helper.enableAutofillService(getContext(), SERVICE_NAME);
}
+ @Override
+ public TestRule getMainTestRule() {
+ return InlineUiBot.annotateRule(super.getMainTestRule());
+ }
+
@Test
public void testFiltering_filtersByPrefix() throws Exception {
enableService();
diff --git a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineLoginActivityTest.java b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineLoginActivityTest.java
index eff7b97..6aff0d5 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineLoginActivityTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineLoginActivityTest.java
@@ -48,6 +48,7 @@
import com.android.cts.mockime.MockImeSession;
import org.junit.Test;
+import org.junit.rules.TestRule;
public class InlineLoginActivityTest extends LoginActivityCommonTestCase {
@@ -67,6 +68,11 @@
return true;
}
+ @Override
+ public TestRule getMainTestRule() {
+ return InlineUiBot.annotateRule(super.getMainTestRule());
+ }
+
@Test
public void testAutofill_disjointDatasets() throws Exception {
// Set service.
diff --git a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineSimpleSaveActivityTest.java b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineSimpleSaveActivityTest.java
index c2b5515..42f4f16 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineSimpleSaveActivityTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineSimpleSaveActivityTest.java
@@ -36,6 +36,7 @@
import androidx.annotation.NonNull;
import org.junit.Test;
+import org.junit.rules.TestRule;
public class InlineSimpleSaveActivityTest
extends AutoFillServiceTestCase.AutoActivityLaunch<SimpleSaveActivity> {
@@ -63,6 +64,11 @@
};
}
+ @Override
+ public TestRule getMainTestRule() {
+ return InlineUiBot.annotateRule(super.getMainTestRule());
+ }
+
@Test
public void testAutofillSave() throws Exception {
// Set service.
diff --git a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineUiBot.java b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineUiBot.java
index ca8e473..af53383 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineUiBot.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineUiBot.java
@@ -21,14 +21,19 @@
import static android.autofillservice.cts.Timeouts.UI_TIMEOUT;
import android.autofillservice.cts.UiBot;
+import android.content.pm.PackageManager;
import android.support.test.uiautomator.By;
import android.support.test.uiautomator.BySelector;
import android.support.test.uiautomator.Direction;
import android.support.test.uiautomator.UiObject2;
+import com.android.compatibility.common.util.RequiredFeatureRule;
import com.android.compatibility.common.util.Timeout;
import com.android.cts.mockime.MockIme;
+import org.junit.rules.RuleChain;
+import org.junit.rules.TestRule;
+
/**
* UiBot for the inline suggestion.
*/
@@ -39,6 +44,9 @@
private static final BySelector SUGGESTION_STRIP_SELECTOR = By.desc(SUGGESTION_STRIP_DESC);
+ private static final RequiredFeatureRule REQUIRES_IME_RULE = new RequiredFeatureRule(
+ PackageManager.FEATURE_INPUT_METHODS);
+
public InlineUiBot() {
this(UI_TIMEOUT);
}
@@ -47,6 +55,10 @@
super(defaultTimeout);
}
+ public static RuleChain annotateRule(TestRule rule) {
+ return RuleChain.outerRule(REQUIRES_IME_RULE).around(rule);
+ }
+
@Override
public void assertNoDatasets() throws Exception {
assertNoDatasetsEver();
diff --git a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineWebViewActivityTest.java b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineWebViewActivityTest.java
index d5f0503..63cf648 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineWebViewActivityTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineWebViewActivityTest.java
@@ -40,6 +40,7 @@
import android.view.ViewStructure.HtmlInfo;
import org.junit.Test;
+import org.junit.rules.TestRule;
public class InlineWebViewActivityTest extends AbstractWebViewTestCase<WebViewActivity> {
@@ -77,6 +78,11 @@
return true;
}
+ @Override
+ public TestRule getMainTestRule() {
+ return InlineUiBot.annotateRule(super.getMainTestRule());
+ }
+
@Test
public void testAutofillNoDatasets() throws Exception {
// Set service.