Commit 8e51d82a authored by sandromaggi's avatar sandromaggi Committed by Commit Bot

[Autofill Assistant] Enable integration tests

These tests ran stably on a real Nexus5.

This CL adds new waiting conditions before clicking the
confirm button for the CVC dialog.

This CL adds a new restriction to tapping HTML elements
by restricting the area to the visible webpage, not
obstructed by the BottomSheet.

Bug: 1136166
Change-Id: I84753527d8260a6bc4bc38e4f6fc0b1df1e921ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2470660
Commit-Queue: Sandro Maggi <sandromaggi@google.com>
Reviewed-by: default avatarClemens Arbesser <arbesser@google.com>
Cr-Commit-Position: refs/heads/master@{#816983}
parent f8b93bea
...@@ -139,7 +139,6 @@ public class AutofillAssistantCollectUserDataIntegrationTest { ...@@ -139,7 +139,6 @@ public class AutofillAssistantCollectUserDataIntegrationTest {
*/ */
@Test @Test
@MediumTest @MediumTest
@DisabledTest(message = "crbug.com/1136166")
public void testEnterPayment() throws Exception { public void testEnterPayment() throws Exception {
String profileId = mHelper.addDummyProfile("John Doe", "johndoe@gmail.com"); String profileId = mHelper.addDummyProfile("John Doe", "johndoe@gmail.com");
mHelper.addDummyCreditCard(profileId); mHelper.addDummyCreditCard(profileId);
...@@ -224,6 +223,8 @@ public class AutofillAssistantCollectUserDataIntegrationTest { ...@@ -224,6 +223,8 @@ public class AutofillAssistantCollectUserDataIntegrationTest {
onView(withText("Continue")).perform(click()); onView(withText("Continue")).perform(click());
waitUntilViewMatchesCondition(withId(R.id.card_unmask_input), isCompletelyDisplayed()); waitUntilViewMatchesCondition(withId(R.id.card_unmask_input), isCompletelyDisplayed());
onView(withId(R.id.card_unmask_input)).perform(typeText("123")); onView(withId(R.id.card_unmask_input)).perform(typeText("123"));
waitUntilViewMatchesCondition(
withId(R.id.positive_button), allOf(isDisplayed(), isEnabled()));
onView(withId(R.id.positive_button)).perform(click()); onView(withId(R.id.positive_button)).perform(click());
waitUntilViewMatchesCondition(withText("Prompt"), isCompletelyDisplayed(), 6000L); waitUntilViewMatchesCondition(withText("Prompt"), isCompletelyDisplayed(), 6000L);
assertThat(getElementValue(getWebContents(), "name"), is("John Doe")); assertThat(getElementValue(getWebContents(), "name"), is("John Doe"));
......
...@@ -54,7 +54,6 @@ import org.junit.Test; ...@@ -54,7 +54,6 @@ import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.chromium.base.test.util.CommandLineFlags; import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.DisabledTest;
import org.chromium.chrome.autofill_assistant.R; import org.chromium.chrome.autofill_assistant.R;
import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard; import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard;
import org.chromium.chrome.browser.autofill_assistant.proto.ActionProto; import org.chromium.chrome.browser.autofill_assistant.proto.ActionProto;
...@@ -491,7 +490,6 @@ public class AutofillAssistantPersonalDataManagerTest { ...@@ -491,7 +490,6 @@ public class AutofillAssistantPersonalDataManagerTest {
*/ */
@Test @Test
@MediumTest @MediumTest
@DisabledTest(message = "crbug.com/1136166")
public void testCreateAndEnterCard() throws Exception { public void testCreateAndEnterCard() throws Exception {
// Add a profile for easier address selection. // Add a profile for easier address selection.
mHelper.addDummyProfile("Adam West", "adamwest@google.com"); mHelper.addDummyProfile("Adam West", "adamwest@google.com");
...@@ -564,6 +562,8 @@ public class AutofillAssistantPersonalDataManagerTest { ...@@ -564,6 +562,8 @@ public class AutofillAssistantPersonalDataManagerTest {
onView(withContentDescription("Continue")).perform(click()); onView(withContentDescription("Continue")).perform(click());
waitUntilViewMatchesCondition(withId(R.id.card_unmask_input), isCompletelyDisplayed()); waitUntilViewMatchesCondition(withId(R.id.card_unmask_input), isCompletelyDisplayed());
onView(withId(R.id.card_unmask_input)).perform(typeText("123")); onView(withId(R.id.card_unmask_input)).perform(typeText("123"));
waitUntilViewMatchesCondition(
withId(R.id.positive_button), allOf(isDisplayed(), isEnabled()));
onView(withId(R.id.positive_button)).perform(click()); onView(withId(R.id.positive_button)).perform(click());
waitUntilViewMatchesCondition(withText("Prompt"), isCompletelyDisplayed()); waitUntilViewMatchesCondition(withText("Prompt"), isCompletelyDisplayed());
assertThat(getElementValue(getWebContents(), "name"), is("John Doe")); assertThat(getElementValue(getWebContents(), "name"), is("John Doe"));
......
...@@ -559,11 +559,17 @@ class AutofillAssistantUiTestUtil { ...@@ -559,11 +559,17 @@ class AutofillAssistantUiTestUtil {
// Sanity check, can only click on coordinates on screen. // Sanity check, can only click on coordinates on screen.
DisplayMetrics displayMetrics = testRule.getActivity().getResources().getDisplayMetrics(); DisplayMetrics displayMetrics = testRule.getActivity().getResources().getDisplayMetrics();
if (x < 0 || x > displayMetrics.widthPixels || y < 0 || y > displayMetrics.heightPixels) { BottomSheetController bottomSheetController =
testRule.getActivity().getRootUiCoordinatorForTesting().getBottomSheetController();
int totalBottomSheetHeight = bottomSheetController.getCurrentOffset()
+ bottomSheetController.getTopShadowHeight();
if (x < 0 || x > displayMetrics.widthPixels || y < 0
|| y > displayMetrics.heightPixels - totalBottomSheetHeight) {
throw new IllegalArgumentException(Arrays.toString(elementIds) throw new IllegalArgumentException(Arrays.toString(elementIds)
+ " not on screen: tried to tap x=" + x + ", y=" + y + " not on screen: tried to tap x=" + x + ", y=" + y
+ ", which is outside of display with w=" + displayMetrics.widthPixels + ", which is outside of display with w=" + displayMetrics.widthPixels
+ ", h=" + displayMetrics.heightPixels); + ", h=" + displayMetrics.heightPixels
+ ", or obstructed by the BottomSheet with height=" + totalBottomSheetHeight);
} }
TestTouchUtils.singleClick(InstrumentationRegistry.getInstrumentation(), x, y); TestTouchUtils.singleClick(InstrumentationRegistry.getInstrumentation(), x, y);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment