1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.launcher3.tapl; 17 18 import static com.android.launcher3.tapl.LauncherInstrumentation.KEYBOARD_QUICK_SWITCH_RES_ID; 19 20 import android.view.KeyEvent; 21 22 /** 23 * {@link com.android.launcher3.tapl.LauncherInstrumentation.VisibleContainer} that can be used to 24 * show the keyboard quick switch view. 25 */ 26 interface KeyboardQuickSwitchSource { 27 28 /** 29 * Shows the Keyboard Quick Switch view. 30 */ showQuickSwitchView()31 default KeyboardQuickSwitch showQuickSwitchView() { 32 LauncherInstrumentation launcher = getLauncher(); 33 34 try (LauncherInstrumentation.Closable c1 = launcher.addContextLayer( 35 "want to show keyboard quick switch object"); 36 LauncherInstrumentation.Closable e = launcher.eventsCheck()) { 37 launcher.pressAndHoldKeyCode(KeyEvent.KEYCODE_TAB, KeyEvent.META_ALT_LEFT_ON); 38 39 try (LauncherInstrumentation.Closable c2 = launcher.addContextLayer( 40 "press and held alt+tab")) { 41 launcher.waitForLauncherObject(KEYBOARD_QUICK_SWITCH_RES_ID); 42 launcher.unpressKeyCode(KeyEvent.KEYCODE_TAB, 0); 43 44 return new KeyboardQuickSwitch( 45 launcher, getStartingContainerType(), isHomeState()); 46 } 47 } 48 } 49 50 /** This method requires public access, however should not be called in tests. */ getLauncher()51 LauncherInstrumentation getLauncher(); 52 53 /** This method requires public access, however should not be called in tests. */ getStartingContainerType()54 LauncherInstrumentation.ContainerType getStartingContainerType(); 55 56 /** This method requires public access, however should not be called in tests. */ isHomeState()57 boolean isHomeState(); 58 } 59