Loading src/com/android/launcher3/compat/AccessibilityManagerCompat.java +12 −3 Original line number Diff line number Diff line Loading @@ -41,7 +41,6 @@ public class AccessibilityManagerCompat { } /** * * @param target The view the accessibility event is initialized on. * If null, this method has no effect. * @param type See TYPE_ constants defined in {@link AccessibilityEvent}. Loading Loading @@ -97,6 +96,16 @@ public class AccessibilityManagerCompat { null); } /** * Notify running tests of a folder opened. */ public static void sendFolderOpenedEventToTest(Context context) { final AccessibilityManager accessibilityManager = getAccessibilityManagerForTest(context); if (accessibilityManager == null) return; sendEventToTest(accessibilityManager, context, TestProtocol.FOLDER_OPENED_MESSAGE, null); } private static void sendEventToTest( AccessibilityManager accessibilityManager, Context context, String eventTag, Bundle data) { Loading src/com/android/launcher3/folder/Folder.java +4 −1 Original line number Diff line number Diff line Loading @@ -78,6 +78,7 @@ import com.android.launcher3.Utilities; import com.android.launcher3.accessibility.AccessibleDragListenerAdapter; import com.android.launcher3.accessibility.FolderAccessibilityHelper; import com.android.launcher3.anim.KeyboardInsetAnimationCallback; import com.android.launcher3.compat.AccessibilityManagerCompat; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.dragndrop.DragController; import com.android.launcher3.dragndrop.DragController.DragListener; Loading Loading @@ -687,6 +688,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo public void onAnimationEnd(Animator animation) { mState = STATE_OPEN; announceAccessibilityChanges(); AccessibilityManagerCompat.sendFolderOpenedEventToTest(getContext()); mContent.setFocusOnFirstChild(); } Loading Loading @@ -1265,7 +1267,8 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo PendingAddShortcutInfo pasi = d.dragInfo instanceof PendingAddShortcutInfo ? (PendingAddShortcutInfo) d.dragInfo : null; WorkspaceItemInfo pasiSi = pasi != null ? pasi.activityInfo.createWorkspaceItemInfo() : null; WorkspaceItemInfo pasiSi = pasi != null ? pasi.activityInfo.createWorkspaceItemInfo() : null; if (pasi != null && pasiSi == null) { // There is no WorkspaceItemInfo, so we have to go through a configuration activity. pasi.container = mInfo.id; Loading src/com/android/launcher3/testing/TestInformationHandler.java +10 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import android.annotation.TargetApi; import android.app.Activity; import android.content.Context; import android.content.res.Resources; import android.graphics.Insets; import android.os.Build; import android.os.Bundle; Loading Loading @@ -148,6 +149,14 @@ public class TestInformationHandler implements ResourceBasedOverride { TestProtocol.TEST_INFO_RESPONSE_FIELD, TestLogging.sHadEventsNotFromTest); return response; case TestProtocol.REQUEST_START_DRAG_THRESHOLD: { final Resources resources = mContext.getResources(); response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, resources.getDimensionPixelSize(R.dimen.deep_shortcuts_start_drag_threshold) + resources.getDimensionPixelSize(R.dimen.pre_drag_view_scale)); return response; } default: return null; } Loading Loading @@ -193,6 +202,7 @@ public class TestInformationHandler implements ResourceBasedOverride { /** * Generic interface for setting a fiend in bundle * * @param <T> the type of value being set */ public interface BundleSetter<T> { Loading src/com/android/launcher3/testing/TestProtocol.java +2 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ public final class TestProtocol { public static final String SCROLL_FINISHED_MESSAGE = "TAPL_SCROLL_FINISHED"; public static final String PAUSE_DETECTED_MESSAGE = "TAPL_PAUSE_DETECTED"; public static final String DISMISS_ANIMATION_ENDS_MESSAGE = "TAPL_DISMISS_ANIMATION_ENDS"; public static final String FOLDER_OPENED_MESSAGE = "TAPL_FOLDER_OPENED"; public static final int NORMAL_STATE_ORDINAL = 0; public static final int SPRING_LOADED_STATE_ORDINAL = 1; public static final int OVERVIEW_STATE_ORDINAL = 2; Loading Loading @@ -99,6 +100,7 @@ public final class TestProtocol { public static final String REQUEST_CLEAR_DATA = "clear-data"; public static final String REQUEST_IS_TABLET = "is-tablet"; public static final String REQUEST_IS_TWO_PANELS = "is-two-panel"; public static final String REQUEST_START_DRAG_THRESHOLD = "start-drag-threshold"; public static final String REQUEST_GET_ACTIVITIES_CREATED_COUNT = "get-activities-created-count"; public static final String REQUEST_GET_ACTIVITIES = "get-activities"; Loading tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java +44 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,8 @@ import com.android.launcher3.tapl.AllApps; import com.android.launcher3.tapl.AppIcon; import com.android.launcher3.tapl.AppIconMenu; import com.android.launcher3.tapl.AppIconMenuItem; import com.android.launcher3.tapl.Folder; import com.android.launcher3.tapl.FolderIcon; import com.android.launcher3.tapl.Widgets; import com.android.launcher3.tapl.Workspace; import com.android.launcher3.views.OptionsPopupView; Loading Loading @@ -369,6 +371,48 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { } } private AppIcon createShortcutIfNotExist(String name) { AppIcon appIcon = mLauncher.getWorkspace().tryGetWorkspaceAppIcon(name); if (appIcon == null) { AllApps allApps = mLauncher.getWorkspace().switchToAllApps(); allApps.freeze(); try { appIcon = allApps.getAppIcon(name); appIcon.dragToWorkspace(false, false); } finally { allApps.unfreeze(); } appIcon = mLauncher.getWorkspace().getWorkspaceAppIcon(name); } return appIcon; } @Test @PortraitLandscape public void testDragToFolder() throws Exception { final AppIcon playStoreIcon = createShortcutIfNotExist("Play Store"); final AppIcon gmailIcon = createShortcutIfNotExist("Gmail"); FolderIcon folderIcon = gmailIcon.dragToIcon(playStoreIcon); Folder folder = folderIcon.open(); folder.getAppIcon("Play Store"); folder.getAppIcon("Gmail"); Workspace workspace = folder.close(); assertNull("Gmail should be moved to a folder.", workspace.tryGetWorkspaceAppIcon("Gmail")); assertNull("Play Store should be moved to a folder.", workspace.tryGetWorkspaceAppIcon("Play Store")); final AppIcon youTubeIcon = createShortcutIfNotExist("YouTube"); folderIcon = youTubeIcon.dragToIcon(folderIcon); folder = folderIcon.open(); folder.getAppIcon("YouTube"); folder.close(); } public static String getAppPackageName() { return getInstrumentation().getContext().getPackageName(); } Loading Loading
src/com/android/launcher3/compat/AccessibilityManagerCompat.java +12 −3 Original line number Diff line number Diff line Loading @@ -41,7 +41,6 @@ public class AccessibilityManagerCompat { } /** * * @param target The view the accessibility event is initialized on. * If null, this method has no effect. * @param type See TYPE_ constants defined in {@link AccessibilityEvent}. Loading Loading @@ -97,6 +96,16 @@ public class AccessibilityManagerCompat { null); } /** * Notify running tests of a folder opened. */ public static void sendFolderOpenedEventToTest(Context context) { final AccessibilityManager accessibilityManager = getAccessibilityManagerForTest(context); if (accessibilityManager == null) return; sendEventToTest(accessibilityManager, context, TestProtocol.FOLDER_OPENED_MESSAGE, null); } private static void sendEventToTest( AccessibilityManager accessibilityManager, Context context, String eventTag, Bundle data) { Loading
src/com/android/launcher3/folder/Folder.java +4 −1 Original line number Diff line number Diff line Loading @@ -78,6 +78,7 @@ import com.android.launcher3.Utilities; import com.android.launcher3.accessibility.AccessibleDragListenerAdapter; import com.android.launcher3.accessibility.FolderAccessibilityHelper; import com.android.launcher3.anim.KeyboardInsetAnimationCallback; import com.android.launcher3.compat.AccessibilityManagerCompat; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.dragndrop.DragController; import com.android.launcher3.dragndrop.DragController.DragListener; Loading Loading @@ -687,6 +688,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo public void onAnimationEnd(Animator animation) { mState = STATE_OPEN; announceAccessibilityChanges(); AccessibilityManagerCompat.sendFolderOpenedEventToTest(getContext()); mContent.setFocusOnFirstChild(); } Loading Loading @@ -1265,7 +1267,8 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo PendingAddShortcutInfo pasi = d.dragInfo instanceof PendingAddShortcutInfo ? (PendingAddShortcutInfo) d.dragInfo : null; WorkspaceItemInfo pasiSi = pasi != null ? pasi.activityInfo.createWorkspaceItemInfo() : null; WorkspaceItemInfo pasiSi = pasi != null ? pasi.activityInfo.createWorkspaceItemInfo() : null; if (pasi != null && pasiSi == null) { // There is no WorkspaceItemInfo, so we have to go through a configuration activity. pasi.container = mInfo.id; Loading
src/com/android/launcher3/testing/TestInformationHandler.java +10 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import android.annotation.TargetApi; import android.app.Activity; import android.content.Context; import android.content.res.Resources; import android.graphics.Insets; import android.os.Build; import android.os.Bundle; Loading Loading @@ -148,6 +149,14 @@ public class TestInformationHandler implements ResourceBasedOverride { TestProtocol.TEST_INFO_RESPONSE_FIELD, TestLogging.sHadEventsNotFromTest); return response; case TestProtocol.REQUEST_START_DRAG_THRESHOLD: { final Resources resources = mContext.getResources(); response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, resources.getDimensionPixelSize(R.dimen.deep_shortcuts_start_drag_threshold) + resources.getDimensionPixelSize(R.dimen.pre_drag_view_scale)); return response; } default: return null; } Loading Loading @@ -193,6 +202,7 @@ public class TestInformationHandler implements ResourceBasedOverride { /** * Generic interface for setting a fiend in bundle * * @param <T> the type of value being set */ public interface BundleSetter<T> { Loading
src/com/android/launcher3/testing/TestProtocol.java +2 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ public final class TestProtocol { public static final String SCROLL_FINISHED_MESSAGE = "TAPL_SCROLL_FINISHED"; public static final String PAUSE_DETECTED_MESSAGE = "TAPL_PAUSE_DETECTED"; public static final String DISMISS_ANIMATION_ENDS_MESSAGE = "TAPL_DISMISS_ANIMATION_ENDS"; public static final String FOLDER_OPENED_MESSAGE = "TAPL_FOLDER_OPENED"; public static final int NORMAL_STATE_ORDINAL = 0; public static final int SPRING_LOADED_STATE_ORDINAL = 1; public static final int OVERVIEW_STATE_ORDINAL = 2; Loading Loading @@ -99,6 +100,7 @@ public final class TestProtocol { public static final String REQUEST_CLEAR_DATA = "clear-data"; public static final String REQUEST_IS_TABLET = "is-tablet"; public static final String REQUEST_IS_TWO_PANELS = "is-two-panel"; public static final String REQUEST_START_DRAG_THRESHOLD = "start-drag-threshold"; public static final String REQUEST_GET_ACTIVITIES_CREATED_COUNT = "get-activities-created-count"; public static final String REQUEST_GET_ACTIVITIES = "get-activities"; Loading
tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java +44 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,8 @@ import com.android.launcher3.tapl.AllApps; import com.android.launcher3.tapl.AppIcon; import com.android.launcher3.tapl.AppIconMenu; import com.android.launcher3.tapl.AppIconMenuItem; import com.android.launcher3.tapl.Folder; import com.android.launcher3.tapl.FolderIcon; import com.android.launcher3.tapl.Widgets; import com.android.launcher3.tapl.Workspace; import com.android.launcher3.views.OptionsPopupView; Loading Loading @@ -369,6 +371,48 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { } } private AppIcon createShortcutIfNotExist(String name) { AppIcon appIcon = mLauncher.getWorkspace().tryGetWorkspaceAppIcon(name); if (appIcon == null) { AllApps allApps = mLauncher.getWorkspace().switchToAllApps(); allApps.freeze(); try { appIcon = allApps.getAppIcon(name); appIcon.dragToWorkspace(false, false); } finally { allApps.unfreeze(); } appIcon = mLauncher.getWorkspace().getWorkspaceAppIcon(name); } return appIcon; } @Test @PortraitLandscape public void testDragToFolder() throws Exception { final AppIcon playStoreIcon = createShortcutIfNotExist("Play Store"); final AppIcon gmailIcon = createShortcutIfNotExist("Gmail"); FolderIcon folderIcon = gmailIcon.dragToIcon(playStoreIcon); Folder folder = folderIcon.open(); folder.getAppIcon("Play Store"); folder.getAppIcon("Gmail"); Workspace workspace = folder.close(); assertNull("Gmail should be moved to a folder.", workspace.tryGetWorkspaceAppIcon("Gmail")); assertNull("Play Store should be moved to a folder.", workspace.tryGetWorkspaceAppIcon("Play Store")); final AppIcon youTubeIcon = createShortcutIfNotExist("YouTube"); folderIcon = youTubeIcon.dragToIcon(folderIcon); folder = folderIcon.open(); folder.getAppIcon("YouTube"); folder.close(); } public static String getAppPackageName() { return getInstrumentation().getContext().getPackageName(); } Loading