Merge "Revert^2 "Making sure that test go to FixedLandscape on landscape"" into main

This commit is contained in:
Sebastián Franco
2024-12-18 14:16:08 -08:00
committed by Android (Google) Code Review
2 changed files with 21 additions and 2 deletions
+7 -2
View File
@@ -58,6 +58,7 @@ import static com.android.launcher3.LauncherConstants.TraceEvents.ON_CREATE_EVT;
import static com.android.launcher3.LauncherConstants.TraceEvents.ON_NEW_INTENT_EVT;
import static com.android.launcher3.LauncherConstants.TraceEvents.ON_RESUME_EVT;
import static com.android.launcher3.LauncherConstants.TraceEvents.ON_START_EVT;
import static com.android.launcher3.LauncherPrefs.FIXED_LANDSCAPE_MODE;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_DESKTOP;
import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
import static com.android.launcher3.LauncherState.ALL_APPS;
@@ -785,9 +786,13 @@ public class Launcher extends StatefulActivity<LauncherState>
return;
}
// When the flag oneGridSpecs is on we want to disable ALLOW_ROTATION which is replaced
// by FIXED_LANDSCAPE_MODE, ALLOW_ROTATION will only be used on Tablets afterwards.
if (getDeviceProfile().isPhone || getDeviceProfile().isTwoPanels) {
// by FIXED_LANDSCAPE_MODE, ALLOW_ROTATION will only be used on Tablets and foldables
// afterwards.
if (getDeviceProfile().isPhone) {
LauncherPrefs.get(this).put(LauncherPrefs.ALLOW_ROTATION, false);
} else if (getDeviceProfile().isTablet) {
// Tablet do not use fixed landscape mode, make sure it can't be activated by mistake
LauncherPrefs.get(this).put(FIXED_LANDSCAPE_MODE, false);
}
getRotationHelper().setFixedLandscape(
Objects.requireNonNull(mDeviceProfile.inv).isFixedLandscape
@@ -1,11 +1,16 @@
package com.android.launcher3.ui;
import static com.android.launcher3.LauncherPrefs.FIXED_LANDSCAPE_MODE;
import android.util.Log;
import android.view.Surface;
import com.android.launcher3.Flags;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherPrefs;
import com.android.launcher3.tapl.TestHelpers;
import com.android.launcher3.util.rule.FailureWatcher;
import com.android.launcher3.util.window.WindowManagerProxy;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
@@ -67,9 +72,11 @@ public class PortraitLandscapeRunner<LAUNCHER_TYPE extends Launcher> implements
Log.e(TAG, "Error", e);
throw e;
} finally {
mTest.mDevice.setOrientationNatural();
mTest.executeOnLauncher(launcher ->
{
LauncherPrefs.get(launcher).put(FIXED_LANDSCAPE_MODE, false);
if (launcher != null) {
launcher.getRotationHelper().forceAllowRotationForTesting(false);
}
@@ -90,6 +97,13 @@ public class PortraitLandscapeRunner<LAUNCHER_TYPE extends Launcher> implements
}
private void evaluateInLandscape() throws Throwable {
if (Flags.oneGridSpecs()
&& WindowManagerProxy.INSTANCE.get(mTest.mTargetContext)
.isTaskbarDrawnInProcess()) {
mTest.executeOnLauncher(launcher -> LauncherPrefs.get(launcher)
.put(FIXED_LANDSCAPE_MODE, true)
);
}
mTest.mDevice.setOrientationLeft();
mTest.mLauncher.setExpectedRotation(Surface.ROTATION_90);
AbstractLauncherUiTest.checkDetectedLeaks(mTest.mLauncher, true);