mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-20 11:18:21 +00:00
Merge "TAPL: add setIgnoreTaskbarVisibility in LauncherInstrumentation" into tm-qpr-dev
This commit is contained in:
@@ -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)),
|
||||
|
||||
@@ -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",
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
@@ -479,6 +479,16 @@ public abstract class AbstractLauncherUiTest {
|
||||
false /* newTask */);
|
||||
}
|
||||
|
||||
public static void startImeTestActivity() {
|
||||
final String packageName = getAppPackageName();
|
||||
final Intent intent = getInstrumentation().getContext().getPackageManager().
|
||||
getLaunchIntentForPackage(packageName);
|
||||
intent.setComponent(new ComponentName(packageName,
|
||||
"com.android.launcher3.testcomponent.ImeTestActivity"));
|
||||
startIntent(intent, By.pkg(packageName).text("ImeTestActivity"),
|
||||
false /* newTask */);
|
||||
}
|
||||
|
||||
private static void startIntent(Intent intent, BySelector selector, boolean newTask) {
|
||||
intent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
if (newTask) {
|
||||
|
||||
@@ -206,21 +206,30 @@ public abstract class Background extends LauncherInstrumentation.VisibleContaine
|
||||
MotionEvent.ACTION_UP, end, gestureScope);
|
||||
}
|
||||
|
||||
/**
|
||||
* Quick switching to the app with swiping to right.
|
||||
*/
|
||||
@NonNull
|
||||
public LaunchedAppState quickSwitchToPreviousApp() {
|
||||
boolean toRight = true;
|
||||
quickSwitch(toRight);
|
||||
quickSwitch(true /* toRight */);
|
||||
return new LaunchedAppState(mLauncher);
|
||||
}
|
||||
|
||||
/**
|
||||
* Quick switching to the app with swiping to left.
|
||||
*/
|
||||
@NonNull
|
||||
public LaunchedAppState quickSwitchToPreviousAppSwipeLeft() {
|
||||
boolean toRight = false;
|
||||
quickSwitch(toRight);
|
||||
quickSwitch(false /* toRight */);
|
||||
return new LaunchedAppState(mLauncher);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
/**
|
||||
* Making swipe gesture to quick-switch app tasks.
|
||||
*
|
||||
* @param toRight {@code true} means swiping right, {@code false} means swiping left.
|
||||
* @throws {@link AssertionError} when failing to verify the visible UI in the container.
|
||||
*/
|
||||
private void quickSwitch(boolean toRight) {
|
||||
try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck();
|
||||
LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
|
||||
|
||||
@@ -71,6 +71,16 @@ public final class LaunchedAppState extends Background {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for the taskbar to be visible, or fails.
|
||||
*/
|
||||
public void assertTaskbarVisible() {
|
||||
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
|
||||
"waiting for taskbar to be visible")) {
|
||||
mLauncher.waitForLauncherObject(TASKBAR_RES_ID);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Taskbar in a visible state.
|
||||
*
|
||||
|
||||
@@ -185,13 +185,14 @@ public final class LauncherInstrumentation {
|
||||
private final Deque<String> mDiagnosticContext = new LinkedList<>();
|
||||
private Function<Long, String> mSystemHealthSupplier;
|
||||
|
||||
private boolean mIgnoreTaskbarVisibility = false;
|
||||
|
||||
private Consumer<ContainerType> mOnSettledStateAction;
|
||||
|
||||
private LogEventChecker mEventChecker;
|
||||
|
||||
private boolean mCheckEventsForSuccessfulGestures = false;
|
||||
private Runnable mOnLauncherCrashed;
|
||||
|
||||
private static Pattern getTouchEventPattern(String prefix, String action) {
|
||||
// The pattern includes checks that we don't get a multi-touch events or other surprises.
|
||||
return Pattern.compile(
|
||||
@@ -680,6 +681,18 @@ public final class LauncherInstrumentation {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether to ignore verifying the task bar visibility during instrumenting.
|
||||
*
|
||||
* @param ignoreTaskbarVisibility {@code true} will ignore the instrumentation implicitly
|
||||
* verifying the task bar visibility with
|
||||
* {@link VisibleContainer#verifyActiveContainer}.
|
||||
* {@code false} otherwise.
|
||||
*/
|
||||
public void setIgnoreTaskbarVisibility(boolean ignoreTaskbarVisibility) {
|
||||
mIgnoreTaskbarVisibility = ignoreTaskbarVisibility;
|
||||
}
|
||||
|
||||
public void setExpectedRotation(int expectedRotation) {
|
||||
mExpectedRotation = expectedRotation;
|
||||
}
|
||||
@@ -798,6 +811,9 @@ public final class LauncherInstrumentation {
|
||||
waitUntilLauncherObjectGone(WIDGETS_RES_ID);
|
||||
waitUntilLauncherObjectGone(SPLIT_PLACEHOLDER_RES_ID);
|
||||
|
||||
if (mIgnoreTaskbarVisibility) {
|
||||
return null;
|
||||
}
|
||||
if (isTablet() && !isFallbackOverview()) {
|
||||
waitForLauncherObject(TASKBAR_RES_ID);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user