Commit ca38b22f authored by Wenyu Fu's avatar Wenyu Fu Committed by Commit Bot

Fix flaky test HomepageSettingsFragmentTest#testChangeCustomized

Use criteria helper to wait desire state of UI to reduce flakiness.

Bug: 1056985
Change-Id: I8883722a62120cc4228e2fd5d7c3abc8b3ca071d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2080470
Commit-Queue: Theresa  <twellington@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Auto-Submit: Wenyu Fu <wenyufu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746145}
parent 1b0ad2b7
......@@ -41,6 +41,7 @@ import org.chromium.chrome.test.util.browser.Features;
import org.chromium.components.browser_ui.widget.RadioButtonWithDescription;
import org.chromium.components.browser_ui.widget.RadioButtonWithEditText;
import org.chromium.components.embedder_support.util.UrlConstants;
import org.chromium.content_public.browser.test.util.Criteria;
import org.chromium.content_public.browser.test.util.CriteriaHelper;
import org.chromium.content_public.browser.test.util.TestThreadUtils;
import org.chromium.content_public.browser.test.util.TouchCommon;
......@@ -542,9 +543,15 @@ public class HomepageSettingsFragmentTest {
// Update the text box. To do this, request focus for customized radio button so that the
// checked option will be changed.
TestThreadUtils.runOnUiThreadBlocking(() -> {
mCustomUriRadioButton.requestFocus();
mCustomUriRadioButton.getEditTextForTests().requestFocus();
mCustomUriRadioButton.setPrimaryText(TEST_URL_FOO);
});
CriteriaHelper.pollUiThread(new Criteria("EditText never got the focus.") {
@Override
public boolean isSatisfied() {
return mCustomUriRadioButton.getEditTextForTests().isFocused();
}
});
// Radio Button should switched to customized homepage.
Assert.assertFalse(
......
......@@ -13,6 +13,8 @@ import android.util.AttributeSet;
import android.widget.EditText;
import android.widget.TextView;
import androidx.annotation.VisibleForTesting;
import org.chromium.ui.KeyboardVisibilityDelegate;
import java.util.ArrayList;
......@@ -194,4 +196,12 @@ public class RadioButtonWithEditText extends RadioButtonWithDescription {
public void setHint(int hintId) {
mEditText.setHint(hintId);
}
/**
* @return the EditText living inside this widget.
*/
@VisibleForTesting
public EditText getEditTextForTests() {
return mEditText;
}
}
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