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
diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
index 15e8f68..a3b05f6 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.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 @@
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 @@
@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 39cd4ff..b5290b7 100644
--- a/tests/tapl/com/android/launcher3/tapl/Launchable.java
+++ b/tests/tapl/com/android/launcher3/tapl/Launchable.java
@@ -117,7 +117,6 @@
expectLongClickEvents);
}
-
return dragStartCenter;
}
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 2b3583e..51baa87 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -1567,11 +1567,11 @@
// 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) {