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

Commit 20c82558 authored by Wu Ahan's avatar Wu Ahan Committed by Android (Google) Code Review
Browse files

Merge "Remove the exceptions of the return values of getNameOfCuj()"

parents dbdc5284 6ee0642f
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -780,17 +780,17 @@ public class InteractionJankMonitor {
        // 2. The returned string should be the same with the name defined in atoms.proto.
        switch (cujType) {
            case CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE:
                return "SHADE_EXPAND_COLLAPSE";
                return "NOTIFICATION_SHADE_EXPAND_COLLAPSE";
            case CUJ_NOTIFICATION_SHADE_SCROLL_FLING:
                return "SHADE_SCROLL_FLING";
                return "NOTIFICATION_SHADE_SCROLL_FLING";
            case CUJ_NOTIFICATION_SHADE_ROW_EXPAND:
                return "SHADE_ROW_EXPAND";
                return "NOTIFICATION_SHADE_ROW_EXPAND";
            case CUJ_NOTIFICATION_SHADE_ROW_SWIPE:
                return "SHADE_ROW_SWIPE";
                return "NOTIFICATION_SHADE_ROW_SWIPE";
            case CUJ_NOTIFICATION_SHADE_QS_EXPAND_COLLAPSE:
                return "SHADE_QS_EXPAND_COLLAPSE";
                return "NOTIFICATION_SHADE_QS_EXPAND_COLLAPSE";
            case CUJ_NOTIFICATION_SHADE_QS_SCROLL_SWIPE:
                return "SHADE_QS_SCROLL_SWIPE";
                return "NOTIFICATION_SHADE_QS_SCROLL_SWIPE";
            case CUJ_LAUNCHER_APP_LAUNCH_FROM_RECENTS:
                return "LAUNCHER_APP_LAUNCH_FROM_RECENTS";
            case CUJ_LAUNCHER_APP_LAUNCH_FROM_ICON:
@@ -880,9 +880,9 @@ public class InteractionJankMonitor {
            case CUJ_SPLIT_SCREEN_EXIT:
                return "SPLIT_SCREEN_EXIT";
            case CUJ_LOCKSCREEN_LAUNCH_CAMERA:
                return "CUJ_LOCKSCREEN_LAUNCH_CAMERA";
                return "LOCKSCREEN_LAUNCH_CAMERA";
            case CUJ_SPLIT_SCREEN_RESIZE:
                return "CUJ_SPLIT_SCREEN_RESIZE";
                return "SPLIT_SCREEN_RESIZE";
            case CUJ_SETTINGS_SLIDER:
                return "SETTINGS_SLIDER";
            case CUJ_TAKE_SCREENSHOT:
+3 −23
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import static android.text.TextUtils.formatSimple;

import static com.android.internal.jank.FrameTracker.REASON_CANCEL_TIMEOUT;
import static com.android.internal.jank.FrameTracker.REASON_END_NORMAL;
import static com.android.internal.jank.InteractionJankMonitor.CUJ_LOCKSCREEN_LAUNCH_CAMERA;
import static com.android.internal.jank.InteractionJankMonitor.CUJ_NOTIFICATION_ADD;
import static com.android.internal.jank.InteractionJankMonitor.CUJ_NOTIFICATION_APP_START;
import static com.android.internal.jank.InteractionJankMonitor.CUJ_NOTIFICATION_HEADS_UP_APPEAR;
@@ -32,7 +31,6 @@ import static com.android.internal.jank.InteractionJankMonitor.CUJ_NOTIFICATION_
import static com.android.internal.jank.InteractionJankMonitor.CUJ_NOTIFICATION_SHADE_ROW_EXPAND;
import static com.android.internal.jank.InteractionJankMonitor.CUJ_NOTIFICATION_SHADE_ROW_SWIPE;
import static com.android.internal.jank.InteractionJankMonitor.CUJ_NOTIFICATION_SHADE_SCROLL_FLING;
import static com.android.internal.jank.InteractionJankMonitor.CUJ_SPLIT_SCREEN_RESIZE;
import static com.android.internal.jank.InteractionJankMonitor.CUJ_TO_STATSD_INTERACTION_TYPE;
import static com.android.internal.jank.InteractionJankMonitor.MAX_LENGTH_OF_CUJ_NAME;
import static com.android.internal.jank.InteractionJankMonitor.getNameOfCuj;
@@ -92,7 +90,6 @@ import java.util.stream.Collectors;
public class InteractionJankMonitorTest {
    private static final String CUJ_POSTFIX = "";
    private static final SparseArray<String> ENUM_NAME_EXCEPTION_MAP = new SparseArray<>();
    private static final SparseArray<String> CUJ_NAME_EXCEPTION_MAP = new SparseArray<>();
    private static final String ENUM_NAME_PREFIX =
            "UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__";

@@ -129,22 +126,6 @@ public class InteractionJankMonitorTest {
                CUJ_NOTIFICATION_SHADE_ROW_SWIPE, getEnumName("SHADE_ROW_SWIPE"));
        ENUM_NAME_EXCEPTION_MAP.put(
                CUJ_NOTIFICATION_SHADE_SCROLL_FLING, getEnumName("SHADE_SCROLL_FLING"));

        CUJ_NAME_EXCEPTION_MAP.put(
                CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE, "CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE");
        CUJ_NAME_EXCEPTION_MAP.put(
                CUJ_NOTIFICATION_SHADE_QS_EXPAND_COLLAPSE,
                "CUJ_NOTIFICATION_SHADE_QS_EXPAND_COLLAPSE");
        CUJ_NAME_EXCEPTION_MAP.put(
                CUJ_NOTIFICATION_SHADE_QS_SCROLL_SWIPE, "CUJ_NOTIFICATION_SHADE_QS_SCROLL_SWIPE");
        CUJ_NAME_EXCEPTION_MAP.put(
                CUJ_NOTIFICATION_SHADE_ROW_EXPAND, "CUJ_NOTIFICATION_SHADE_ROW_EXPAND");
        CUJ_NAME_EXCEPTION_MAP.put(
                CUJ_NOTIFICATION_SHADE_ROW_SWIPE, "CUJ_NOTIFICATION_SHADE_ROW_SWIPE");
        CUJ_NAME_EXCEPTION_MAP.put(
                CUJ_NOTIFICATION_SHADE_SCROLL_FLING, "CUJ_NOTIFICATION_SHADE_SCROLL_FLING");
        CUJ_NAME_EXCEPTION_MAP.put(CUJ_LOCKSCREEN_LAUNCH_CAMERA, "CUJ_LOCKSCREEN_LAUNCH_CAMERA");
        CUJ_NAME_EXCEPTION_MAP.put(CUJ_SPLIT_SCREEN_RESIZE, "CUJ_SPLIT_SCREEN_RESIZE");
    }

    private static String getEnumName(String name) {
@@ -272,9 +253,8 @@ public class InteractionJankMonitorTest {
                    : formatSimple("%s%s", ENUM_NAME_PREFIX, cujName.substring(4));
            final int enumKey = CUJ_TO_STATSD_INTERACTION_TYPE[cuj];
            final String enumName = enumsMap.get(enumKey);
            final String expectedNameOfCuj = CUJ_NAME_EXCEPTION_MAP.contains(cuj)
                    ? CUJ_NAME_EXCEPTION_MAP.get(cuj)
                    : formatSimple("CUJ_%s", getNameOfCuj(cuj));
            final String expectedNameOfCuj = formatSimple("CUJ_%s", getNameOfCuj(cuj));

            mExpect
                    .withMessage(formatSimple(
                            "%s (%d) not matches %s (%d)", cujName, cuj, enumName, enumKey))
@@ -323,7 +303,7 @@ public class InteractionJankMonitorTest {
        // Since the length of the cuj name is tested in another test, no need to test it here.
        // Too long postfix case, should trim the postfix and keep the cuj name completed.
        final String expectedTrimmedName = formatSimple("J<%s::%s>", cujName,
                "ThisIsTheCujTagThisIsTheCujTagThisIsTheCujTagThisIsTheCujTagThisIsTheCujTagT...");
                "ThisIsTheCujTagThisIsTheCujTagThisIsTheCujTagThisIsTheCujTagThi...");
        Session longPostfix = new Session(cujType, tooLongTag);
        assertThat(longPostfix.getName()).isEqualTo(expectedTrimmedName);
    }