Commit fbff5c4f authored by Pavel Yatsuk's avatar Pavel Yatsuk Committed by Commit Bot

Add diagnostic to deflake ChromeTabModalPresenterTest.testShow_UrlBarFocused

Test fails to receive callback about url focus change. Screenshots
indicate that url bar didn't get focused. I suspect that
OmniboxTestUtils.toggleUrlBarFocus logic to tap in the middle of the
view doesn't correctly focus urlbar in some cases. If that's the case
then directly calling urlBar.requestFocus() would work better for this
test.

This CL adds check to see if urlbar got focused.

BUG=812066
R=twellington@chromium.org

Change-Id: I9b120fa6cb2cf68b95a34f1e08c4143bf6e5787a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2136060
Commit-Queue: Pavel Yatsuk <pavely@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756483}
parent a2c23a3b
...@@ -141,6 +141,15 @@ public class ChromeTabModalPresenterTest { ...@@ -141,6 +141,15 @@ public class ChromeTabModalPresenterTest {
UrlBar urlBar = mActivity.findViewById(R.id.url_bar); UrlBar urlBar = mActivity.findViewById(R.id.url_bar);
int callCount = mTestObserver.onUrlFocusChangedCallback.getCallCount(); int callCount = mTestObserver.onUrlFocusChangedCallback.getCallCount();
OmniboxTestUtils.toggleUrlBarFocus(urlBar, true); OmniboxTestUtils.toggleUrlBarFocus(urlBar, true);
// TODO(crbug/812066): Following line helps narrow down the cause of flakiness. Previous
// call to toggleUrlBarFocus() should have focused urlBar. Screenshots indicate that
// sometimes it doesn't happen. toggleUrlBarFocus() simulates tap in the middle of the view,
// maybe there are some timing issues there. Accurately simulating tap is not necessary for
// the purpose of this test therefore as an alternative we could call requestFocus() on
// urlBar view.
Assert.assertTrue(
"UrlBar didn't get focused", OmniboxTestUtils.doesUrlBarHaveFocus(urlBar));
mTestObserver.onUrlFocusChangedCallback.waitForCallback(callCount); mTestObserver.onUrlFocusChangedCallback.waitForCallback(callCount);
TestThreadUtils.runOnUiThreadBlocking(() -> { TestThreadUtils.runOnUiThreadBlocking(() -> {
Assert.assertThat(containerParent.indexOfChild(dialogContainer), Assert.assertThat(containerParent.indexOfChild(dialogContainer),
......
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