Merge "Fix TwoPanelWorkspaceTests" into tm-qpr-dev

This commit is contained in:
Schneider Victor-tulias
2023-03-29 17:03:59 +00:00
committed by Android (Google) Code Review
4 changed files with 26 additions and 1 deletions

View File

@@ -33,6 +33,7 @@ import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.DragSource;
@@ -51,6 +52,8 @@ import com.android.launcher3.model.BgDataModel.FixedContainerItems;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.popup.SystemShortcut;
import com.android.launcher3.testing.TestLogging;
import com.android.launcher3.testing.shared.TestProtocol;
import com.android.launcher3.touch.ItemLongClickListener;
import com.android.launcher3.uioverrides.PredictedAppIcon;
import com.android.launcher3.uioverrides.QuickstepLauncher;
@@ -89,10 +92,14 @@ public class HotseatPredictionController implements DragController.DragListener,
private List<PredictedAppIcon.PredictedIconOutlineDrawing> mOutlineDrawings = new ArrayList<>();
private boolean mEnableHotseatLongPressTipForTesting = true;
private final View.OnLongClickListener mPredictionLongClickListener = v -> {
if (!ItemLongClickListener.canStartDrag(mLauncher)) return false;
if (mLauncher.getWorkspace().isSwitchingState()) return false;
if (!mLauncher.getOnboardingPrefs().getBoolean(
TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "onWorkspaceItemLongClick");
if (mEnableHotseatLongPressTipForTesting && !mLauncher.getOnboardingPrefs().getBoolean(
OnboardingPrefs.HOTSEAT_LONGPRESS_TIP_SEEN)) {
Snackbar.show(mLauncher, R.string.hotseat_tip_gaps_filled,
R.string.hotseat_prediction_settings, null,
@@ -132,6 +139,12 @@ public class HotseatPredictionController implements DragController.DragListener,
onHotseatHierarchyChanged();
}
/** Enables/disabled the hotseat prediction icon long press edu for testing. */
@VisibleForTesting
public void enableHotseatEdu(boolean enable) {
mEnableHotseatLongPressTipForTesting = enable;
}
private void onHotseatHierarchyChanged() {
if (mPauseFlags == 0 && !mLauncher.isWorkspaceLoading()) {
// Post update after a single frame to avoid layout within layout

View File

@@ -317,6 +317,12 @@ public class QuickstepLauncher extends Launcher {
return mHotseatPredictionController;
}
@Override
public void enableHotseatEdu(boolean enable) {
super.enableHotseatEdu(enable);
mHotseatPredictionController.enableHotseatEdu(enable);
}
/**
* Builds the {@link QuickstepTransitionManager} instance to use for managing transitions.
*/

View File

@@ -3259,6 +3259,10 @@ public class Launcher extends StatefulActivity<LauncherState>
return new LauncherAccessibilityDelegate(this);
}
/** Enables/disabled the hotseat prediction icon long press edu for testing. */
@VisibleForTesting
public void enableHotseatEdu(boolean enable) {}
/**
* @see LauncherState#getOverviewScaleAndOffset(Launcher)
*/

View File

@@ -59,6 +59,7 @@ public class TwoPanelWorkspaceTest extends AbstractLauncherUiTest {
// Pre verifying the screens
executeOnLauncher(launcher -> {
launcher.enableHotseatEdu(false);
assertPagesExist(launcher, 0, 1);
assertItemsOnPage(launcher, 0, "Play Store", "Maps");
assertPageEmpty(launcher, 1);
@@ -67,6 +68,7 @@ public class TwoPanelWorkspaceTest extends AbstractLauncherUiTest {
@After
public void tearDown() {
executeOnLauncher(launcher -> launcher.enableHotseatEdu(true));
mLauncher.useDefaultWorkspaceLayoutOnReload();
}