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

Commit 4d4f62ac authored by Ming-Shin Lu's avatar Ming-Shin Lu
Browse files

TAPL: add setIgnoreTaskbarVisibility in LauncherInstrumentation

As now FlickerTests is leveraging TAPL to interact devices CUJs,
we realized in LauncherInstrumentation will verify task bar visibility
automatically to expect it always visible when quick-switch, which is
not always reliable since the task bar may be hidden by manual or
when the activity requests to show IME.

Add setIgnoreTaskbarVisibility in LauncherInstrumentation for the caller
to ignore taskbar visibility if the test does not need to verify it.

Bug: 228012334
Bug: 240306344
Test: atest FlickerTests:SwitchImeWindowsFromGestureNavTest
      in tablet device
Test: atest NexusLauncherOutOfProcTests:com.android.quickstep.\
       TaplTestsQuickstep#testQuickSwitchToPreviousAppForTablet

Change-Id: Id0a35561523d733b8434acb702ec7dcaa466a1c2
parent f733a716
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -309,6 +309,28 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
        launchedAppState.switchToOverview();
    }

    @Test
    @ScreenRecord // b/242163205
    public void testQuickSwitchToPreviousAppForTablet() throws Exception {
        assumeTrue(mLauncher.isTablet());
        startTestActivity(2);
        startImeTestActivity();

        // Set ignoreTaskbarVisibility to true to verify the task bar visibility explicitly.
        mLauncher.setIgnoreTaskbarVisibility(true);

        // Expect task bar invisible when the launched app was the IME activity.
        LaunchedAppState launchedAppState = getAndAssertLaunchedApp();
        launchedAppState.assertTaskbarHidden();

        // Quick-switch to the test app with swiping to right.
        launchedAppState.quickSwitchToPreviousApp();

        // Expect task bar visible when the launched app was the test activity.
        launchedAppState = getAndAssertLaunchedApp();
        launchedAppState.assertTaskbarVisible();
    }

    private boolean isTestActivityRunning(int activityNumber) {
        return mDevice.wait(Until.hasObject(By.pkg(getAppPackageName())
                        .text("TestActivity" + activityNumber)),
+1 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ filegroup {
      "src/com/android/launcher3/testcomponent/CustomShortcutConfigActivity.java",
      "src/com/android/launcher3/testcomponent/TestCommandReceiver.java",
      "src/com/android/launcher3/testcomponent/TestLauncherActivity.java",
      "src/com/android/launcher3/testcomponent/ImeTestActivity.java",
    ],
}

+10 −0
Original line number Diff line number Diff line
@@ -277,6 +277,16 @@
            </intent-filter>
        </activity-alias>

        <activity android:name="com.android.launcher3.testcomponent.ImeTestActivity"
            android:label="ImeTestActivity"
            android:icon="@drawable/test_theme_icon"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <!-- [b/197780098] Disable eager initialization of Jetpack libraries. -->
        <provider
            android:name="androidx.startup.InitializationProvider"
+16 −0
Original line number Diff line number Diff line
@@ -24,7 +24,9 @@ import android.graphics.Color;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.View;
import android.view.WindowInsets;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;

@@ -81,6 +83,20 @@ public class BaseTestingActivity extends Activity implements View.OnClickListene
        mView.addView(button, lp);
    }

    protected void addEditor(String initText, String hint, boolean requestIme) {
        EditText editText = new EditText(this);
        editText.setHint(hint);
        editText.setText(initText);

        LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        lp.bottomMargin = mMargin;
        mView.addView(editText, lp);
        if (requestIme) {
            editText.requestFocus();
            mView.getWindowInsetsController().show(WindowInsets.Type.ime());
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
+27 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.android.launcher3.testcomponent;

import android.os.Bundle;

public class ImeTestActivity extends OtherBaseTestingActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // Requests to focus an editor and show IME for test.
        addEditor("Focused editor for test", "Focused editor for test", true);
    }
}
Loading