Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 58b3b5b5 authored by Tony Wickham's avatar Tony Wickham
Browse files

Simplify/fix testThreeButtonsTaskbarBoundsAfterConfigChangeDuringIme

Instead of dealing with changing dark theme which can lead to races
with stale Taskbar icons, instead just go home and launch the IME
activity. This is sufficient because the taskbar height changes
when going between home and an app, and the IME will stash the
Taskbar during this transition.

Fixes: 320490387
Test: testThreeButtonsTaskbarBoundsAfterConfigChangeDuringIme
Flag: None
Change-Id: Ib5b1481751af0bf1fccda085c78174f6612441b9
parent 1721e8a7
Loading
Loading
Loading
Loading
+13 −27
Original line number Diff line number Diff line
@@ -15,18 +15,14 @@
 */
package com.android.quickstep;

import static com.android.launcher3.util.rule.TestStabilityRule.LOCAL;
import static com.android.launcher3.util.rule.TestStabilityRule.PLATFORM_POSTSUBMIT;
import static com.android.quickstep.TaskbarModeSwitchRule.Mode.PERSISTENT;

import android.graphics.Rect;

import androidx.test.filters.LargeTest;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;

import com.android.launcher3.ui.PortraitLandscapeRunner.PortraitLandscape;
import com.android.launcher3.util.rule.TestStabilityRule;
import com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch;
import com.android.quickstep.TaskbarModeSwitchRule.TaskbarModeSwitch;

@@ -34,9 +30,6 @@ import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.io.Closeable;
import java.io.IOException;

@LargeTest
@RunWith(AndroidJUnit4.class)
public class TaplTestsPersistentTaskbar extends AbstractTaplTestsTaskbar {
@@ -51,27 +44,20 @@ public class TaplTestsPersistentTaskbar extends AbstractTaplTestsTaskbar {
    }

    @Test
    @TestStabilityRule.Stability(flavors = LOCAL | PLATFORM_POSTSUBMIT) // b/320490387
    @NavigationModeSwitch(mode = NavigationModeSwitchRule.Mode.THREE_BUTTON)
    public void testThreeButtonsTaskbarBoundsAfterConfigChangeDuringIme() {
        // Start off in light mode.
        try (Closeable c = InstrumentationRegistry.getInstrumentation().getUiAutomation()
                .executeShellCommand("cmd uimode night no")) {
        Rect taskbarBoundsBefore = getTaskbar().getVisibleBounds();
        // Go home and to an IME activity (any configuration change would do, as long as it
        // triggers taskbar insets or height change while taskbar is stashed).
        mLauncher.goHome();
        startImeTestActivity();
        // IME should stash the taskbar, which hides icons even in 3 button mode.
        mLauncher.getLaunchedAppState().assertTaskbarHidden();
            // Switch to dark mode (any configuration change here would do).
            InstrumentationRegistry.getInstrumentation().getUiAutomation().executeShellCommand(
                    "cmd uimode night yes").close();
        // Close IME to check new taskbar bounds.
            mLauncher.pressBack();
        startTestActivity(2);
        Rect taskbarBoundsAfter = getTaskbar().getVisibleBounds();
        Assert.assertEquals(
                "Taskbar bounds are not the same after a configuration change while stashed.",
                taskbarBoundsBefore, taskbarBoundsAfter);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}