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

Commit 1c17b80e authored by Peter Kalauskas's avatar Peter Kalauskas
Browse files

Use Kosmos for jank tracker in tests

Use Kosmos for InteractionJankMonitor usage in tests

Bug: 304583132
Bug: 304582856
Test: atest com.android.systemui.notetask.LaunchNotesRoleSettingsTrampolineActivityTest
Flag: ACONFIG com.android.systemui.edge_back_gesture_handler_thread DISABLED
Change-Id: I095759f95b51f073e6d55adc3b37cdb453cf8e4f
parent db4f8d4f
Loading
Loading
Loading
Loading
+6 −3
Original line number Original line Diff line number Diff line
@@ -20,16 +20,18 @@ import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.when;


import static kotlinx.coroutines.flow.FlowKt.emptyFlow;

import android.view.View;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.ViewTreeObserver;
import android.widget.FrameLayout;
import android.widget.FrameLayout;


import com.android.internal.jank.InteractionJankMonitor;
import com.android.keyguard.logging.KeyguardLogger;
import com.android.keyguard.logging.KeyguardLogger;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository;
import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository;
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractorFactory;
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractorFactory;
import com.android.systemui.kosmos.KosmosJavaAdapter;
import com.android.systemui.power.data.repository.FakePowerRepository;
import com.android.systemui.power.data.repository.FakePowerRepository;
import com.android.systemui.power.domain.interactor.PowerInteractorFactory;
import com.android.systemui.power.domain.interactor.PowerInteractorFactory;
import com.android.systemui.res.R;
import com.android.systemui.res.R;
@@ -46,6 +48,7 @@ import org.mockito.MockitoAnnotations;


public class KeyguardStatusViewControllerBaseTest extends SysuiTestCase {
public class KeyguardStatusViewControllerBaseTest extends SysuiTestCase {


    private KosmosJavaAdapter mKosmos;
    @Mock protected KeyguardStatusView mKeyguardStatusView;
    @Mock protected KeyguardStatusView mKeyguardStatusView;


    @Mock protected KeyguardSliceViewController mKeyguardSliceViewController;
    @Mock protected KeyguardSliceViewController mKeyguardSliceViewController;
@@ -57,7 +60,6 @@ public class KeyguardStatusViewControllerBaseTest extends SysuiTestCase {
    @Mock protected ScreenOffAnimationController mScreenOffAnimationController;
    @Mock protected ScreenOffAnimationController mScreenOffAnimationController;
    @Mock protected KeyguardLogger mKeyguardLogger;
    @Mock protected KeyguardLogger mKeyguardLogger;
    @Mock protected KeyguardStatusViewController mControllerMock;
    @Mock protected KeyguardStatusViewController mControllerMock;
    @Mock protected InteractionJankMonitor mInteractionJankMonitor;
    @Mock protected ViewTreeObserver mViewTreeObserver;
    @Mock protected ViewTreeObserver mViewTreeObserver;
    @Mock protected DumpManager mDumpManager;
    @Mock protected DumpManager mDumpManager;
    protected FakeKeyguardRepository mFakeKeyguardRepository;
    protected FakeKeyguardRepository mFakeKeyguardRepository;
@@ -71,6 +73,7 @@ public class KeyguardStatusViewControllerBaseTest extends SysuiTestCase {


    @Before
    @Before
    public void setup() {
    public void setup() {
        mKosmos = new KosmosJavaAdapter(this);
        MockitoAnnotations.initMocks(this);
        MockitoAnnotations.initMocks(this);


        KeyguardInteractorFactory.WithDependencies deps = KeyguardInteractorFactory.create();
        KeyguardInteractorFactory.WithDependencies deps = KeyguardInteractorFactory.create();
@@ -87,7 +90,7 @@ public class KeyguardStatusViewControllerBaseTest extends SysuiTestCase {
                mDozeParameters,
                mDozeParameters,
                mScreenOffAnimationController,
                mScreenOffAnimationController,
                mKeyguardLogger,
                mKeyguardLogger,
                mInteractionJankMonitor,
                mKosmos.getInteractionJankMonitor(),
                deps.getKeyguardInteractor(),
                deps.getKeyguardInteractor(),
                mDumpManager,
                mDumpManager,
                PowerInteractorFactory.create(
                PowerInteractorFactory.create(
+4 −2
Original line number Original line Diff line number Diff line
@@ -135,6 +135,7 @@ import com.android.systemui.deviceentry.shared.model.ErrorFaceAuthenticationStat
import com.android.systemui.deviceentry.shared.model.FaceDetectionStatus;
import com.android.systemui.deviceentry.shared.model.FaceDetectionStatus;
import com.android.systemui.deviceentry.shared.model.FailedFaceAuthenticationStatus;
import com.android.systemui.deviceentry.shared.model.FailedFaceAuthenticationStatus;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.kosmos.KosmosJavaAdapter;
import com.android.systemui.log.SessionTracker;
import com.android.systemui.log.SessionTracker;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.settings.UserTracker;
import com.android.systemui.settings.UserTracker;
@@ -195,7 +196,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
            DATA_ROAMING_DISABLE, null, null, null, null, false, null, "", false, TEST_GROUP_UUID,
            DATA_ROAMING_DISABLE, null, null, null, null, false, null, "", false, TEST_GROUP_UUID,
            TEST_CARRIER_ID, PROFILE_CLASS_PROVISIONING);
            TEST_CARRIER_ID, PROFILE_CLASS_PROVISIONING);
    private static final int FINGERPRINT_SENSOR_ID = 1;
    private static final int FINGERPRINT_SENSOR_ID = 1;

    private KosmosJavaAdapter mKosmos;
    @Mock
    @Mock
    private UserTracker mUserTracker;
    private UserTracker mUserTracker;
    @Mock
    @Mock
@@ -240,7 +241,6 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
    private AuthController mAuthController;
    private AuthController mAuthController;
    @Mock
    @Mock
    private TelephonyListenerManager mTelephonyListenerManager;
    private TelephonyListenerManager mTelephonyListenerManager;
    @Mock
    private InteractionJankMonitor mInteractionJankMonitor;
    private InteractionJankMonitor mInteractionJankMonitor;
    @Mock
    @Mock
    private LatencyTracker mLatencyTracker;
    private LatencyTracker mLatencyTracker;
@@ -300,6 +300,8 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {


    @Before
    @Before
    public void setup() throws RemoteException {
    public void setup() throws RemoteException {
        mKosmos = new KosmosJavaAdapter(this);
        mInteractionJankMonitor = mKosmos.getInteractionJankMonitor();
        MockitoAnnotations.initMocks(this);
        MockitoAnnotations.initMocks(this);
        when(mSessionTracker.getSessionId(SESSION_KEYGUARD)).thenReturn(mKeyguardInstanceId);
        when(mSessionTracker.getSessionId(SESSION_KEYGUARD)).thenReturn(mKeyguardInstanceId);


+3 −2
Original line number Original line Diff line number Diff line
@@ -18,6 +18,8 @@ import androidx.test.filters.SmallTest
import com.android.internal.jank.InteractionJankMonitor
import com.android.internal.jank.InteractionJankMonitor
import com.android.internal.policy.DecorView
import com.android.internal.policy.DecorView
import com.android.systemui.SysuiTestCase
import com.android.systemui.SysuiTestCase
import com.android.systemui.jank.interactionJankMonitor
import com.android.systemui.kosmos.Kosmos
import com.google.common.truth.Truth.assertThat
import com.google.common.truth.Truth.assertThat
import junit.framework.Assert.assertEquals
import junit.framework.Assert.assertEquals
import junit.framework.Assert.assertFalse
import junit.framework.Assert.assertFalse
@@ -31,7 +33,6 @@ import org.junit.Before
import org.junit.Rule
import org.junit.Rule
import org.junit.Test
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runner.RunWith
import org.mockito.Mock
import org.mockito.Mockito.any
import org.mockito.Mockito.any
import org.mockito.Mockito.verify
import org.mockito.Mockito.verify
import org.mockito.junit.MockitoJUnit
import org.mockito.junit.MockitoJUnit
@@ -43,7 +44,7 @@ class DialogTransitionAnimatorTest : SysuiTestCase() {
    private lateinit var mDialogTransitionAnimator: DialogTransitionAnimator
    private lateinit var mDialogTransitionAnimator: DialogTransitionAnimator
    private val attachedViews = mutableSetOf<View>()
    private val attachedViews = mutableSetOf<View>()


    @Mock lateinit var interactionJankMonitor: InteractionJankMonitor
    val interactionJankMonitor = Kosmos().interactionJankMonitor
    @get:Rule val rule = MockitoJUnit.rule()
    @get:Rule val rule = MockitoJUnit.rule()


    @Before
    @Before
+1 −5
Original line number Original line Diff line number Diff line
@@ -75,7 +75,6 @@ import android.view.WindowManager;
import androidx.test.filters.SmallTest;
import androidx.test.filters.SmallTest;


import com.android.internal.foldables.FoldGracePeriodProvider;
import com.android.internal.foldables.FoldGracePeriodProvider;
import com.android.internal.jank.InteractionJankMonitor;
import com.android.internal.logging.InstanceId;
import com.android.internal.logging.InstanceId;
import com.android.internal.logging.UiEventLogger;
import com.android.internal.logging.UiEventLogger;
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockPatternUtils;
@@ -181,7 +180,6 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
    private @Mock NotificationShadeDepthController mNotificationShadeDepthController;
    private @Mock NotificationShadeDepthController mNotificationShadeDepthController;
    private @Mock KeyguardUnlockAnimationController mKeyguardUnlockAnimationController;
    private @Mock KeyguardUnlockAnimationController mKeyguardUnlockAnimationController;
    private @Mock ScreenOffAnimationController mScreenOffAnimationController;
    private @Mock ScreenOffAnimationController mScreenOffAnimationController;
    private @Mock InteractionJankMonitor mInteractionJankMonitor;
    private @Mock ScreenOnCoordinator mScreenOnCoordinator;
    private @Mock ScreenOnCoordinator mScreenOnCoordinator;
    private @Mock KeyguardTransitions mKeyguardTransitions;
    private @Mock KeyguardTransitions mKeyguardTransitions;
    private @Mock ShadeController mShadeController;
    private @Mock ShadeController mShadeController;
@@ -235,8 +233,6 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
        when(mLockPatternUtils.getDevicePolicyManager()).thenReturn(mDevicePolicyManager);
        when(mLockPatternUtils.getDevicePolicyManager()).thenReturn(mDevicePolicyManager);
        when(mPowerManager.newWakeLock(anyInt(), any())).thenReturn(mock(WakeLock.class));
        when(mPowerManager.newWakeLock(anyInt(), any())).thenReturn(mock(WakeLock.class));
        when(mPowerManager.isInteractive()).thenReturn(true);
        when(mPowerManager.isInteractive()).thenReturn(true);
        when(mInteractionJankMonitor.begin(any(), anyInt())).thenReturn(true);
        when(mInteractionJankMonitor.end(anyInt())).thenReturn(true);
        mContext.addMockSystemService(Context.ALARM_SERVICE, mAlarmManager);
        mContext.addMockSystemService(Context.ALARM_SERVICE, mAlarmManager);
        final ViewRootImpl testViewRoot = mock(ViewRootImpl.class);
        final ViewRootImpl testViewRoot = mock(ViewRootImpl.class);
        when(testViewRoot.getView()).thenReturn(mock(View.class));
        when(testViewRoot.getView()).thenReturn(mock(View.class));
@@ -1245,7 +1241,7 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
                () -> mNotificationShadeDepthController,
                () -> mNotificationShadeDepthController,
                mScreenOnCoordinator,
                mScreenOnCoordinator,
                mKeyguardTransitions,
                mKeyguardTransitions,
                mInteractionJankMonitor,
                mKosmos.getInteractionJankMonitor(),
                mDreamOverlayStateController,
                mDreamOverlayStateController,
                mJavaAdapter,
                mJavaAdapter,
                mWallpaperRepository,
                mWallpaperRepository,
+0 −5
Original line number Original line Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.systemui.shade;
package com.android.systemui.shade;


import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.when;
@@ -289,10 +288,6 @@ public class QuickSettingsControllerImplBaseTest extends SysuiTestCase {


        when(mNotificationRemoteInputManager.isRemoteInputActive())
        when(mNotificationRemoteInputManager.isRemoteInputActive())
                .thenReturn(false);
                .thenReturn(false);
        when(mInteractionJankMonitor.begin(any(), anyInt()))
                .thenReturn(true);
        when(mInteractionJankMonitor.end(anyInt()))
                .thenReturn(true);


        when(mPanelView.getParent()).thenReturn(mPanelViewParent);
        when(mPanelView.getParent()).thenReturn(mPanelViewParent);
        when(mQs.getHeader()).thenReturn(mQsHeader);
        when(mQs.getHeader()).thenReturn(mQsHeader);
Loading