Merge "Fixing flakiness of ShortcutsToHomeTest" into ub-launcher3-master

This commit is contained in:
TreeHugger Robot 2019-01-29 20:08:50 +00:00 committed by Android (Google) Code Review
commit 4f197550f7
2 changed files with 13 additions and 6 deletions

View File

@ -17,6 +17,7 @@
package com.android.launcher3.tapl;
import android.graphics.Point;
import android.view.MotionEvent;
import android.widget.TextView;
import androidx.test.uiautomator.By;
@ -40,9 +41,10 @@ public final class AppIcon extends Launchable {
*/
public AppIconMenu openMenu() {
final Point iconCenter = mObject.getVisibleCenter();
mLauncher.longTap(iconCenter.x, iconCenter.y);
mLauncher.sendPointer(MotionEvent.ACTION_DOWN, iconCenter);
final UiObject2 deepShortcutsContainer = mLauncher.waitForLauncherObject(
"deep_shortcuts_container");
mLauncher.sendPointer(MotionEvent.ACTION_UP, iconCenter);
return new AppIconMenu(mLauncher, deepShortcutsContainer);
}
}

View File

@ -21,10 +21,13 @@ import static com.android.systemui.shared.system.SettingsCompat.SWIPE_UP_SETTING
import android.app.ActivityManager;
import android.app.Instrumentation;
import android.app.UiAutomation;
import android.graphics.Point;
import android.os.Bundle;
import android.os.Parcelable;
import android.os.SystemClock;
import android.provider.Settings;
import android.util.Log;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.accessibility.AccessibilityEvent;
@ -403,11 +406,6 @@ public final class LauncherInstrumentation {
return mDevice;
}
void longTap(int x, int y) {
mDevice.drag(x, y, x, y, 0);
}
void swipe(int startX, int startY, int endX, int endY) {
executeAndWaitForEvent(
() -> mDevice.swipe(startX, startY, endX, endY, 60),
@ -419,4 +417,11 @@ public final class LauncherInstrumentation {
void waitForIdle() {
mDevice.waitForIdle();
}
void sendPointer(int action, Point point) {
final MotionEvent event = MotionEvent.obtain(SystemClock.uptimeMillis(),
SystemClock.uptimeMillis(), action, point.x, point.y, 0);
mInstrumentation.sendPointerSync(event);
event.recycle();
}
}