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

Commit 367a4855 authored by vadimt's avatar vadimt
Browse files

Fixing menu tests when context menu caption is the first line

The tests mistakenly took the caption (if on top) as the first context
menu item.

Change-Id: Ibd3264814f2c818742ab164503bf7136fedcde31
Tests: com.android.launcher3.ui.ShortcutsToHomeTest
parent d32e4769
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import static org.junit.Assert.assertTrue;

import androidx.test.uiautomator.UiObject2;

import java.util.List;

/**
 * Context menu of an app icon.
 */
@@ -37,10 +39,9 @@ public class AppIconMenu {
     * Returns a menu item with a given number. Fails if it doesn't exist.
     */
    public AppIconMenuItem getMenuItem(int itemNumber) {
        assertTrue(mDeepShortcutsContainer.getChildCount() > itemNumber);

        final UiObject2 shortcut = mLauncher.waitForObjectInContainer(
                mDeepShortcutsContainer.getChildren().get(itemNumber), "bubble_text");
        return new AppIconMenuItem(mLauncher, shortcut);
        final List<UiObject2> menuItems = mLauncher.getObjectsInContainer(mDeepShortcutsContainer,
                "bubble_text");
        assertTrue(menuItems.size() > itemNumber);
        return new AppIconMenuItem(mLauncher, menuItems.get(itemNumber));
    }
}
+6 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import com.android.quickstep.SwipeUpSetting;
import org.junit.Assert;

import java.lang.ref.WeakReference;
import java.util.List;
import java.util.concurrent.TimeoutException;

/**
@@ -366,6 +367,11 @@ public final class LauncherInstrumentation {
        return object;
    }

    @NonNull
    List<UiObject2> getObjectsInContainer(UiObject2 container, String resName) {
        return container.findObjects(getLauncherObjectSelector(resName));
    }

    @NonNull
    UiObject2 waitForObjectInContainer(UiObject2 container, String resName) {
        final UiObject2 object = container.wait(