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

Commit 37cf9838 authored by Pat Manning's avatar Pat Manning Committed by Android (Google) Code Review
Browse files

Merge "Wait for IME to hide in test only if software keyboard." into main

parents 946a2493 b8145edf
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.view.WindowInsetsCompat;

import com.android.launcher3.BubbleTextView;
import com.android.launcher3.DeviceProfile;
@@ -314,6 +315,25 @@ public interface ActivityContext {
                == ((Context) this).getResources().getConfiguration().keyboard;
    }

    /**
     * Returns if the software keyboard is hidden. Hardware keyboards do not display on screen by
     * default.
     */
    default boolean isSoftwareKeyboardHidden() {
        if (isHardwareKeyboard()) {
            return true;
        } else {
            View dragLayer = getDragLayer();
            WindowInsets insets = dragLayer.getRootWindowInsets();
            if (insets == null) {
                return false;
            }
            WindowInsetsCompat insetsCompat =
                    WindowInsetsCompat.toWindowInsetsCompat(insets, dragLayer);
            return !insetsCompat.isVisible(WindowInsetsCompat.Type.ime());
        }
    }

    /**
     * Sends a pending intent animating from a view.
     *
+3 −7
Original line number Diff line number Diff line
@@ -23,8 +23,6 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import android.view.KeyEvent;
import android.view.View;
import android.view.WindowInsets;

import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
@@ -33,6 +31,7 @@ import com.android.launcher3.LauncherState;
import com.android.launcher3.tapl.HomeAllApps;
import com.android.launcher3.ui.AbstractLauncherUiTest;
import com.android.launcher3.util.rule.TestStabilityRule;
import com.android.launcher3.views.ActivityContext;

import org.junit.Before;
import org.junit.Test;
@@ -102,11 +101,8 @@ public class TaplKeyboardFocusTest extends AbstractLauncherUiTest {

            executeOnLauncher(launcher -> launcher.getAppsView().getSearchUiManager().getEditText()
                    .hideKeyboard(/* clearFocus= */ false));
            waitForLauncherCondition("Keyboard still visible.", launcher -> {
                View root = launcher.getDragLayer();
                WindowInsets insets = root.getRootWindowInsets();
                return insets != null && !insets.isVisible(WindowInsets.Type.ime());
            });
            waitForLauncherCondition("Keyboard still visible.",
                    ActivityContext::isSoftwareKeyboardHidden);

            mLauncher.pressAndHoldKeyCode(KeyEvent.KEYCODE_DPAD_DOWN, 0);
            mLauncher.unpressKeyCode(KeyEvent.KEYCODE_DPAD_DOWN, 0);