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

Commit dbd9c5b1 authored by Jeff DeCew's avatar Jeff DeCew
Browse files

Prevent more unexpected Log.wtf calls

Bug: 381916615
Flag: TEST_ONLY
Test: presubmit
Change-Id: Ic77e586fff51e5c6cd206b614b34a4d7a4e8ce4f
parent c194f9b4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -244,7 +244,7 @@ class LauncherProxyServiceTest : SysuiTestCase() {
        `when`(userManager.isVisibleBackgroundUsersSupported()).thenReturn(true)
        `when`(userManager.isUserForeground()).thenReturn(true)
        val spyContext = spy(context)
        val ops = createLauncherProxyService(spyContext)
        val ops = assertLogsWtf { createLauncherProxyService(spyContext) }.result
        ops.startConnectionToCurrentUser()
        verify(spyContext, times(0)).bindServiceAsUser(any(), any(), anyInt(), any())
    }
+4 −1
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import com.android.systemui.keyguard.shared.model.KeyguardState.LOCKSCREEN
import com.android.systemui.keyguard.shared.model.TransitionStep
import com.android.systemui.kosmos.testDispatcher
import com.android.systemui.kosmos.testScope
import com.android.systemui.log.assertLogsWtf
import com.android.systemui.qs.flags.QSComposeFragment
import com.android.systemui.res.R
import com.android.systemui.scene.ui.view.WindowRootViewKeyEventHandler
@@ -413,7 +414,9 @@ class NotificationShadeWindowViewControllerTest(flags: FlagsParameterization) :

            // THEN move is ignored, down is handled, and window is notified
            assertThat(interactionEventHandler.handleDispatchTouchEvent(MOVE_EVENT)).isFalse()
            assertLogsWtf {
                assertThat(interactionEventHandler.handleDispatchTouchEvent(DOWN_EVENT)).isTrue()
            }
            verify(notificationShadeWindowController).setLaunchingActivity(false)
        }

+2 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.statusbar.notification.row;

import static android.app.Flags.FLAG_NOTIFICATIONS_REDESIGN_TEMPLATES;

import static com.android.systemui.log.LogAssertKt.assertRunnableLogsWtf;
import static com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.FLAG_CONTENT_VIEW_ALL;
import static com.android.systemui.statusbar.notification.row.NotificationTestHelper.PKG;
import static com.android.systemui.statusbar.notification.row.NotificationTestHelper.USER_HANDLE;
@@ -1134,7 +1135,7 @@ public class ExpandableNotificationRowTest extends SysuiTestCase {
    public void hasStatusBarChipDuringHeadsUpAnimation_flagOff_false() throws Exception {
        final ExpandableNotificationRow row = mNotificationTestHelper.createRow();

        row.setHasStatusBarChipDuringHeadsUpAnimation(true);
        assertRunnableLogsWtf(() -> row.setHasStatusBarChipDuringHeadsUpAnimation(true));

        assertThat(row.hasStatusBarChipDuringHeadsUpAnimation()).isFalse();
    }
+5 −2
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import androidx.test.filters.SmallTest;

import com.android.server.notification.Flags;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.log.LogAssertKt;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder;

@@ -173,8 +174,10 @@ public class NotificationCustomContentMemoryVerifierTest extends SysuiTestCase {
    public void satisfiesMemoryLimits_viewWithoutCustomNotificationRoot_returnsTrue() {
        NotificationEntry entry = new NotificationEntryBuilder().build();
        View view = new FrameLayout(mContext);
        LogAssertKt.assertRunnableLogsWtf(() -> {
            assertThat(NotificationCustomContentMemoryVerifier.satisfiesMemoryLimits(view, entry))
                    .isTrue();
        });
    }

    @Test
+0 −17
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.systemui.log
import android.util.Log
import android.util.Log.TerribleFailureHandler
import com.google.common.truth.Truth.assertWithMessage
import java.util.concurrent.Callable

/** Asserts that [notLoggingBlock] does not make a call to [Log.wtf] */
fun <T> assertDoesNotLogWtf(
@@ -65,15 +64,6 @@ fun <T> assertLogsWtf(
    return WtfBlockResult(caught, result)
}

/** Assert that [loggingCallable] makes a call to [Log.wtf] */
@JvmOverloads
fun <T> assertLogsWtf(
    message: String = "Expected Log.wtf to be called",
    allowMultiple: Boolean = false,
    loggingCallable: Callable<T>,
): WtfBlockResult<T> =
    assertLogsWtf(message = message, allowMultiple = allowMultiple, loggingCallable::call)

/** Assert that [loggingBlock] makes at least one call to [Log.wtf] */
@JvmOverloads
fun <T> assertLogsWtfs(
@@ -81,13 +71,6 @@ fun <T> assertLogsWtfs(
    loggingBlock: () -> T,
): WtfBlockResult<T> = assertLogsWtf(message, allowMultiple = true, loggingBlock)

/** Assert that [loggingCallable] makes at least one call to [Log.wtf] */
@JvmOverloads
fun <T> assertLogsWtfs(
    message: String = "Expected Log.wtf to be called once or more",
    loggingCallable: Callable<T>,
): WtfBlockResult<T> = assertLogsWtf(message, allowMultiple = true, loggingCallable)

/** The data passed to [TerribleFailureHandler.onTerribleFailure] */
data class TerribleFailureLog(
    val tag: String,