From 001b54749919947b5956a129612dbce1f0deb115 Mon Sep 17 00:00:00 2001 From: Tracy Zhou Date: Mon, 9 May 2022 10:21:26 -0700 Subject: [PATCH] Tune dragToFolder test so that it works with the new nav bar height And add screen record in case there is some flakiness Fixes: 200310506 Test: presubmit Change-Id: I7716698fe2fb600bf34fe603e4a98bb20fc6018d --- .../launcher3/ui/TaplTestsLauncher3.java | 35 ++++++++++--------- .../android/launcher3/tapl/Launchable.java | 1 - .../tapl/LauncherInstrumentation.java | 4 +-- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java index 15e8f681e6..a3b05f6868 100644 --- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java +++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java @@ -48,11 +48,13 @@ import com.android.launcher3.tapl.HomeAppIconMenuItem; import com.android.launcher3.tapl.Widgets; import com.android.launcher3.tapl.Workspace; import com.android.launcher3.util.TestUtil; +import com.android.launcher3.util.rule.ScreenRecordRule; import com.android.launcher3.util.rule.ScreenRecordRule.ScreenRecord; import com.android.launcher3.widget.picker.WidgetsFullSheet; import com.android.launcher3.widget.picker.WidgetsRecyclerView; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -66,6 +68,10 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { private static final String DUMMY_APP_NAME = "Aardwolf"; private static final String MAPS_APP_NAME = "Maps"; private static final String STORE_APP_NAME = "Play Store"; + private static final String GMAIL_APP_NAME = "Gmail"; + + @Rule + public ScreenRecordRule mScreenRecordRule = new ScreenRecordRule(); @Before public void setUp() throws Exception { @@ -374,28 +380,23 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { @Test @PortraitLandscape - public void testDragToFolder() throws Exception { - final HomeAppIcon playStoreIcon = createShortcutIfNotExist("Play Store", 0, 1); - final HomeAppIcon gmailIcon = createShortcutIfNotExist("Gmail", 1, 1); + @ScreenRecord + public void testDragToFolder() { + // TODO: add the use case to drag an icon to an existing folder. Currently it either fails + // on tablets or phones due to difference in resolution. + final HomeAppIcon playStoreIcon = createShortcutIfNotExist(STORE_APP_NAME, 0, 1); + final HomeAppIcon gmailIcon = createShortcutInCenterIfNotExist(GMAIL_APP_NAME); FolderIcon folderIcon = gmailIcon.dragToIcon(playStoreIcon); - Folder folder = folderIcon.open(); - folder.getAppIcon("Play Store"); - folder.getAppIcon("Gmail"); + folder.getAppIcon(STORE_APP_NAME); + folder.getAppIcon(GMAIL_APP_NAME); Workspace workspace = folder.close(); - assertNull("Gmail should be moved to a folder.", - workspace.tryGetWorkspaceAppIcon("Gmail")); - assertNull("Play Store should be moved to a folder.", - workspace.tryGetWorkspaceAppIcon("Play Store")); - - final HomeAppIcon youTubeIcon = createShortcutInCenterIfNotExist("YouTube"); - - folderIcon = youTubeIcon.dragToIcon(folderIcon); - folder = folderIcon.open(); - folder.getAppIcon("YouTube"); - folder.close(); + assertNull(STORE_APP_NAME + " should be moved to a folder.", + workspace.tryGetWorkspaceAppIcon(STORE_APP_NAME)); + assertNull(GMAIL_APP_NAME + " should be moved to a folder.", + workspace.tryGetWorkspaceAppIcon(GMAIL_APP_NAME)); } @Test diff --git a/tests/tapl/com/android/launcher3/tapl/Launchable.java b/tests/tapl/com/android/launcher3/tapl/Launchable.java index 39cd4ffeff..b5290b7bd3 100644 --- a/tests/tapl/com/android/launcher3/tapl/Launchable.java +++ b/tests/tapl/com/android/launcher3/tapl/Launchable.java @@ -117,7 +117,6 @@ public abstract class Launchable { expectLongClickEvents); } - return dragStartCenter; } diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 2b3583e5f0..51baa87494 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -1567,11 +1567,11 @@ public final class LauncherInstrumentation { // vx0: initial speed at the x-dimension, set as twice the avg speed // dx: the constant deceleration at the x-dimension - double vx0 = 2 * (to.x - from.x) / duration; + double vx0 = 2.0 * (to.x - from.x) / duration; double dx = vx0 / duration; // vy0: initial speed at the y-dimension, set as twice the avg speed // dy: the constant deceleration at the y-dimension - double vy0 = 2 * (to.y - from.y) / duration; + double vy0 = 2.0 * (to.y - from.y) / duration; double dy = vy0 / duration; for (long i = 0; i < steps; ++i) {