Files
Flexera-Launcher/tests/tapl/com/android/launcher3/tapl/SelectModeButtons.java
T
Anushree Ganjam 461038d5d5 Remove expecting DOWN events in TAPL tests.
ACTION_UP is always preceded by ACTION_DOWN which means when launcher
receives an UP events, down event is obviously sent.

In b/325377690 , we started seeing only in P9 devices the DOWN events didn't reach TAPL. I added InputDispatcher logs which shows both DOWN and UP events are sent by system_server to NexusLauncher.
However TAPL doesn't receive it. After spending lot of time debugging this, I think we are safe to remove DOWN event expectation in TAPL.

Bug: 325377690
Test: Manual, TAPL presubmits
Flag: NA
Change-Id: I6d3587c488d45e3dc53d2c1c4f3b6b49285eae94
2024-03-07 12:31:38 -08:00

82 lines
2.8 KiB
Java

/*
* Copyright (C) 2020 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.tapl;
import static android.view.KeyEvent.KEYCODE_ESCAPE;
import static com.android.launcher3.testing.shared.TestProtocol.OVERVIEW_STATE_ORDINAL;
import androidx.annotation.NonNull;
import androidx.test.uiautomator.UiObject2;
import com.android.launcher3.testing.shared.TestProtocol;
import java.util.regex.Pattern;
/**
* View containing select mode buttons
*/
public class SelectModeButtons {
private final UiObject2 mSelectModeButtons;
private final LauncherInstrumentation mLauncher;
private static final Pattern EVENT_ALT_ESC_UP = Pattern.compile(
"Key event: KeyEvent.*?action=ACTION_UP.*?keyCode=KEYCODE_ESCAPE.*?metaState=0");
SelectModeButtons(LauncherInstrumentation launcherInstrumentation) {
mSelectModeButtons = launcherInstrumentation.waitForLauncherObject("select_mode_buttons");
mLauncher = launcherInstrumentation;
}
/**
* Click close button.
*/
@NonNull
public Overview clickClose() {
try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck();
LauncherInstrumentation.Closable c =
mLauncher.addContextLayer("want to click close button")) {
UiObject2 close = mLauncher.waitForObjectInContainer(mSelectModeButtons, "close");
mLauncher.clickLauncherObject(close);
try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer(
"clicked close button")) {
return new Overview(mLauncher);
}
}
}
/**
* Close select mode when ESC key is pressed.
* @return The Overview
*/
@NonNull
public Overview dismissByEscKey() {
try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_ALT_ESC_UP);
mLauncher.runToState(
() -> mLauncher.getDevice().pressKeyCode(KEYCODE_ESCAPE),
OVERVIEW_STATE_ORDINAL,
"pressing Esc");
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
"pressed esc key")) {
return new Overview(mLauncher);
}
}
}
}