Commit 290f44e6 authored by Wenyu Fu's avatar Wenyu Fu Committed by Chromium LUCI CQ

Extend the delay before exiting test to deflake

Make sure during screen orientation changes happens when the
disclaimer is still on the screen.

Change-Id: Icd6fa16de94b84c8acb8e4666ebfd27074629eca
Bug: 1157611
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2600042Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Commit-Queue: Wenyu Fu <wenyufu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#839001}
parent 1895a56c
...@@ -13,6 +13,7 @@ import android.view.accessibility.AccessibilityEvent; ...@@ -13,6 +13,7 @@ import android.view.accessibility.AccessibilityEvent;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import org.chromium.base.Log; import org.chromium.base.Log;
import org.chromium.base.ThreadUtils; import org.chromium.base.ThreadUtils;
...@@ -31,6 +32,8 @@ public class TosAndUmaFirstRunFragmentWithEnterpriseSupport ...@@ -31,6 +32,8 @@ public class TosAndUmaFirstRunFragmentWithEnterpriseSupport
extends ToSAndUMAFirstRunFragment implements LoadingView.Observer { extends ToSAndUMAFirstRunFragment implements LoadingView.Observer {
private static final String TAG = "TosAndUmaFragment"; private static final String TAG = "TosAndUmaFragment";
private static Runnable sOverridenOnExitFreRunnableForTest;
/** FRE page that instantiates this fragment. */ /** FRE page that instantiates this fragment. */
public static class Page public static class Page
implements FirstRunPage<TosAndUmaFirstRunFragmentWithEnterpriseSupport> { implements FirstRunPage<TosAndUmaFirstRunFragmentWithEnterpriseSupport> {
...@@ -189,11 +192,21 @@ public class TosAndUmaFirstRunFragmentWithEnterpriseSupport ...@@ -189,11 +192,21 @@ public class TosAndUmaFirstRunFragmentWithEnterpriseSupport
mPrivacyDisclaimer.announceForAccessibility(mPrivacyDisclaimer.getText()); mPrivacyDisclaimer.announceForAccessibility(mPrivacyDisclaimer.getText());
} }
mExitFreRunnable = () -> { if (sOverridenOnExitFreRunnableForTest != null) {
getPageDelegate().exitFirstRun(); mExitFreRunnable = sOverridenOnExitFreRunnableForTest;
mExitFreRunnable = null; } else {
}; mExitFreRunnable = () -> {
getPageDelegate().exitFirstRun();
mExitFreRunnable = null;
};
}
mHandler = new Handler(ThreadUtils.getUiThreadLooper()); mHandler = new Handler(ThreadUtils.getUiThreadLooper());
mHandler.postDelayed(mExitFreRunnable, FirstRunUtils.getSkipTosExitDelayMs()); mHandler.postDelayed(mExitFreRunnable, FirstRunUtils.getSkipTosExitDelayMs());
} }
@VisibleForTesting
static void setOverrideOnExitFreRunnableForTest(Runnable runnable) {
sOverridenOnExitFreRunnableForTest = runnable;
}
} }
...@@ -41,7 +41,6 @@ import org.chromium.base.metrics.RecordHistogram; ...@@ -41,7 +41,6 @@ import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.test.util.CallbackHelper; import org.chromium.base.test.util.CallbackHelper;
import org.chromium.base.test.util.Criteria; import org.chromium.base.test.util.Criteria;
import org.chromium.base.test.util.CriteriaHelper; import org.chromium.base.test.util.CriteriaHelper;
import org.chromium.base.test.util.DisabledTest;
import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Feature;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.customtabs.CustomTabsTestUtils; import org.chromium.chrome.browser.customtabs.CustomTabsTestUtils;
...@@ -166,6 +165,7 @@ public class TosAndUmaFirstRunFragmentWithEnterpriseSupportTest { ...@@ -166,6 +165,7 @@ public class TosAndUmaFirstRunFragmentWithEnterpriseSupportTest {
public void tearDown() { public void tearDown() {
FirstRunAppRestrictionInfo.setInitializedInstanceForTest(null); FirstRunAppRestrictionInfo.setInitializedInstanceForTest(null);
ToSAndUMAFirstRunFragment.setShowUmaCheckBoxForTesting(false); ToSAndUMAFirstRunFragment.setShowUmaCheckBoxForTesting(false);
TosAndUmaFirstRunFragmentWithEnterpriseSupport.setOverrideOnExitFreRunnableForTest(null);
PolicyServiceFactory.setPolicyServiceForTest(null); PolicyServiceFactory.setPolicyServiceForTest(null);
FirstRunUtilsJni.TEST_HOOKS.setInstanceForTesting(mFirstRunUtils); FirstRunUtilsJni.TEST_HOOKS.setInstanceForTesting(mFirstRunUtils);
EnterpriseInfo.setInstanceForTest(null); EnterpriseInfo.setInstanceForTest(null);
...@@ -430,8 +430,11 @@ public class TosAndUmaFirstRunFragmentWithEnterpriseSupportTest { ...@@ -430,8 +430,11 @@ public class TosAndUmaFirstRunFragmentWithEnterpriseSupportTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"RenderTest", "FirstRun"}) @Feature({"RenderTest", "FirstRun"})
@DisabledTest(message = "https://crbug.com/1157521")
public void testRenderWithPolicy() throws Exception { public void testRenderWithPolicy() throws Exception {
final CallbackHelper onExitFreCallback = new CallbackHelper();
TosAndUmaFirstRunFragmentWithEnterpriseSupport.setOverrideOnExitFreRunnableForTest(
onExitFreCallback::notifyCalled);
setAppRestrictionsMockInitialized(true); setAppRestrictionsMockInitialized(true);
setEnterpriseInfoInitializedWithDeviceOwner(true); setEnterpriseInfoInitializedWithDeviceOwner(true);
launchFirstRunThroughCustomTab(); launchFirstRunThroughCustomTab();
...@@ -444,10 +447,10 @@ public class TosAndUmaFirstRunFragmentWithEnterpriseSupportTest { ...@@ -444,10 +447,10 @@ public class TosAndUmaFirstRunFragmentWithEnterpriseSupportTest {
TestThreadUtils.runOnUiThreadBlocking(tosAndUmaFragment::clearFocus); TestThreadUtils.runOnUiThreadBlocking(tosAndUmaFragment::clearFocus);
setPolicyServiceMockInitializedWithDialogEnabled(false); setPolicyServiceMockInitializedWithDialogEnabled(false);
CriteriaHelper.pollUiThread( onExitFreCallback.waitForFirst("OnExitFreCallback is never invoked.");
() Assert.assertEquals("Privacy disclaimer is not visible", mPrivacyDisclaimer.getVisibility(),
-> Criteria.checkThat( View.VISIBLE);
mPrivacyDisclaimer.getVisibility(), Matchers.is(View.VISIBLE)));
renderWithPortraitAndLandscape(tosAndUmaFragment, "fre_tosanduma_withpolicy"); renderWithPortraitAndLandscape(tosAndUmaFragment, "fre_tosanduma_withpolicy");
} }
......
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