From 5eac9a5d81a672a3eed95a11159a5285e711a3bf Mon Sep 17 00:00:00 2001 From: Vadim Tryshev Date: Fri, 8 Dec 2023 12:06:45 -0800 Subject: [PATCH] Waiting for wallpaper animation in widget tests only for Nexus Launcher and in postsubmit This code flakes in postsubmit and presubmit, but the failure is not reproducible in local and abtd runs. Landing the change to make postsubmit flake; then I'll use tricks like tracing to debug the cause. Bug: 313926097 Flag: N/A Test: presubmit Change-Id: I77c324d43a2400fe1015f5cd0a4729e34552687c --- .../ui/widget/TaplAddConfigWidgetTest.java | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/tests/src/com/android/launcher3/ui/widget/TaplAddConfigWidgetTest.java b/tests/src/com/android/launcher3/ui/widget/TaplAddConfigWidgetTest.java index ca72c097d4..3263d60e52 100644 --- a/tests/src/com/android/launcher3/ui/widget/TaplAddConfigWidgetTest.java +++ b/tests/src/com/android/launcher3/ui/widget/TaplAddConfigWidgetTest.java @@ -40,6 +40,7 @@ import com.android.launcher3.ui.PortraitLandscapeRunner.PortraitLandscape; import com.android.launcher3.ui.TestViewHelpers; import com.android.launcher3.util.Wait; import com.android.launcher3.util.rule.ShellCommandRule; +import com.android.launcher3.util.rule.TestStabilityRule; import com.android.launcher3.widget.LauncherAppWidgetProviderInfo; import org.junit.Before; @@ -101,7 +102,7 @@ public class TaplAddConfigWidgetTest extends AbstractLauncherUiTest { // Verify that the widget id is valid and bound assertNotNull(mAppWidgetManager.getAppWidgetInfo(mWidgetId)); - setResult(acceptConfig); + setResultAndWaitForAnimation(acceptConfig); if (acceptConfig) { Wait.atMost("", new WidgetSearchCondition(), DEFAULT_ACTIVITY_TIMEOUT, mLauncher); assertNotNull(mAppWidgetManager.getAppWidgetInfo(mWidgetId)); @@ -112,12 +113,21 @@ public class TaplAddConfigWidgetTest extends AbstractLauncherUiTest { } } - private void setResult(boolean success) { - mLauncher.executeAndWaitForWallpaperAnimation(() -> - getInstrumentation().getTargetContext().sendBroadcast( - WidgetConfigActivity.getCommandIntent(WidgetConfigActivity.class, - success ? "clickOK" : "clickCancel")), - "setting widget coinfig result"); + private static void setResult(boolean success) { + getInstrumentation().getTargetContext().sendBroadcast( + WidgetConfigActivity.getCommandIntent(WidgetConfigActivity.class, + success ? "clickOK" : "clickCancel")); + } + + private void setResultAndWaitForAnimation(boolean success) { + if (mLauncher.isLauncher3() + || TestStabilityRule.isPresubmit() /* b/313926097 */) { + setResult(success); + } else { + mLauncher.executeAndWaitForWallpaperAnimation( + () -> setResult(success), + "setting widget coinfig result"); + } } /**