Commit e0ff4b57 authored by Alec Douglas's avatar Alec Douglas Committed by Commit Bot

[Android] Ensure popup appears during ContentViewPopupZoomerTests

After a recent change to increase the amount of element overlap required for
the disambiguation popup to appear, this test would fail on some devices due
to the links on the test page not being close enough together.

This commit changes the test webpage so all links completely overlap one
another to ensure the disambiguation popup appears on all devices.

BUG=670676

TEST=all ContentViewPopupZoomerTest.java tests

Change-Id: I3350d446331b6c669807c6ad6c873a9b5326ce36
Reviewed-on: https://chromium-review.googlesource.com/612324Reviewed-by: default avatarAlexandre Elias <aelias@chromium.org>
Reviewed-by: default avatarBo <boliu@chromium.org>
Commit-Queue: Alexandre Elias <aelias@chromium.org>
Cr-Commit-Position: refs/heads/master@{#498548}
parent 20f9b478
...@@ -33,6 +33,7 @@ Alex Gabriel <minilogo@gmail.com> ...@@ -33,6 +33,7 @@ Alex Gabriel <minilogo@gmail.com>
Alex Gartrell <agartrell@cmu.edu> Alex Gartrell <agartrell@cmu.edu>
Alex Henrie <alexhenrie24@gmail.com> Alex Henrie <alexhenrie24@gmail.com>
Alex Scheele <alexscheele@gmail.com> Alex Scheele <alexscheele@gmail.com>
Alexander Douglas <agdoug@amazon.com>
Alexander Shalamov <alexander.shalamov@intel.com> Alexander Shalamov <alexander.shalamov@intel.com>
Alexander Sulfrian <alexander@sulfrian.net> Alexander Sulfrian <alexander@sulfrian.net>
Alexandre Abreu <wiss1976@gmail.com> Alexandre Abreu <wiss1976@gmail.com>
......
...@@ -31,6 +31,8 @@ import java.util.concurrent.TimeoutException; ...@@ -31,6 +31,8 @@ import java.util.concurrent.TimeoutException;
@RunWith(BaseJUnit4ClassRunner.class) @RunWith(BaseJUnit4ClassRunner.class)
@RetryOnFailure @RetryOnFailure
public class ContentViewPopupZoomerTest { public class ContentViewPopupZoomerTest {
private static final String TARGET_NODE_ID = "target";
@Rule @Rule
public ContentShellActivityTestRule mActivityTestRule = new ContentShellActivityTestRule(); public ContentShellActivityTestRule mActivityTestRule = new ContentShellActivityTestRule();
...@@ -73,19 +75,17 @@ public class ContentViewPopupZoomerTest { ...@@ -73,19 +75,17 @@ public class ContentViewPopupZoomerTest {
} }
} }
private String generateTestUrl(int totalUrls, int targetIdAt, String targetId) { /**
StringBuilder testUrl = new StringBuilder(); * Creates a webpage that has a couple links next to one another with a zero-width node between
* them. Clicking on the zero-width node should trigger the popup zoomer to appear.
*/
private String generateTestUrl() {
final StringBuilder testUrl = new StringBuilder();
testUrl.append("<html><body>"); testUrl.append("<html><body>");
for (int i = 0; i < totalUrls; i++) { testUrl.append("<a href=\"javascript:void(0);\">A</a>");
boolean isTargeted = i == targetIdAt; testUrl.append("<a id=\"" + TARGET_NODE_ID + "\"></a>");
testUrl.append("<a href=\"data:text/html;utf-8,<html><head><script>" testUrl.append("<a href=\"javascript:void(0);\">Z</a>");
+ "function doesItWork() { return 'yes'; }</script></head></html>\"" testUrl.append("</body></html>");
+ (isTargeted ? (" id=\"" + targetId + "\"") : "") + ">"
+ "<small><sup>"
+ (isTargeted ? "<b>" : "") + i + (isTargeted ? "</b>" : "")
+ "</sup></small></a>");
}
testUrl.append("</small></div></body></html>");
return UrlUtils.encodeHtmlDataUri(testUrl.toString()); return UrlUtils.encodeHtmlDataUri(testUrl.toString());
} }
...@@ -99,7 +99,7 @@ public class ContentViewPopupZoomerTest { ...@@ -99,7 +99,7 @@ public class ContentViewPopupZoomerTest {
@MediumTest @MediumTest
@Feature({"Browser"}) @Feature({"Browser"})
public void testPopupZoomerShowsUp() throws InterruptedException, TimeoutException { public void testPopupZoomerShowsUp() throws InterruptedException, TimeoutException {
mActivityTestRule.launchContentShellWithUrl(generateTestUrl(100, 15, "clickme")); mActivityTestRule.launchContentShellWithUrl(generateTestUrl());
mActivityTestRule.waitForActiveShellToBeDoneLoading(); mActivityTestRule.waitForActiveShellToBeDoneLoading();
final ContentViewCore viewCore = mActivityTestRule.getContentViewCore(); final ContentViewCore viewCore = mActivityTestRule.getContentViewCore();
...@@ -109,7 +109,7 @@ public class ContentViewPopupZoomerTest { ...@@ -109,7 +109,7 @@ public class ContentViewPopupZoomerTest {
CriteriaHelper.pollInstrumentationThread(new PopupShowingCriteria(view, false)); CriteriaHelper.pollInstrumentationThread(new PopupShowingCriteria(view, false));
// Once clicked, the popup should show up. // Once clicked, the popup should show up.
DOMUtils.clickNode(viewCore, "clickme"); DOMUtils.clickNode(viewCore, TARGET_NODE_ID);
CriteriaHelper.pollInstrumentationThread(new PopupShowingCriteria(view, true)); CriteriaHelper.pollInstrumentationThread(new PopupShowingCriteria(view, true));
// The shown popup should have valid dimensions eventually. // The shown popup should have valid dimensions eventually.
...@@ -124,14 +124,14 @@ public class ContentViewPopupZoomerTest { ...@@ -124,14 +124,14 @@ public class ContentViewPopupZoomerTest {
@Feature({"Browser"}) @Feature({"Browser"})
@RetryOnFailure @RetryOnFailure
public void testBackKeyDismissesPopupZoomer() throws InterruptedException, TimeoutException { public void testBackKeyDismissesPopupZoomer() throws InterruptedException, TimeoutException {
mActivityTestRule.launchContentShellWithUrl(generateTestUrl(100, 15, "clickme")); mActivityTestRule.launchContentShellWithUrl(generateTestUrl());
mActivityTestRule.waitForActiveShellToBeDoneLoading(); mActivityTestRule.waitForActiveShellToBeDoneLoading();
final ContentViewCore viewCore = mActivityTestRule.getContentViewCore(); final ContentViewCore viewCore = mActivityTestRule.getContentViewCore();
final ViewGroup view = viewCore.getContainerView(); final ViewGroup view = viewCore.getContainerView();
CriteriaHelper.pollInstrumentationThread(new PopupShowingCriteria(view, false)); CriteriaHelper.pollInstrumentationThread(new PopupShowingCriteria(view, false));
DOMUtils.clickNode(viewCore, "clickme"); DOMUtils.clickNode(viewCore, TARGET_NODE_ID);
CriteriaHelper.pollInstrumentationThread(new PopupShowingCriteria(view, true)); CriteriaHelper.pollInstrumentationThread(new PopupShowingCriteria(view, true));
InstrumentationRegistry.getInstrumentation().sendKeyDownUpSync(KeyEvent.KEYCODE_BACK); InstrumentationRegistry.getInstrumentation().sendKeyDownUpSync(KeyEvent.KEYCODE_BACK);
// When device key is pressed, popup zoomer should hide if already showing. // When device key is pressed, popup zoomer should hide if already showing.
......
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