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

Commit 66d707b1 authored by Kai Li's avatar Kai Li Committed by Android (Google) Code Review
Browse files

Merge "Fix MainContentCaptureSessionTest when...

Merge "Fix MainContentCaptureSessionTest when FLAG_REDUCE_BINDER_TRANSACTION_ENABLED is on." into main
parents cde5988b a68628ba
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -413,6 +413,7 @@ public class MainContentCaptureSessionTest {
    }

    @Test
    @DisableFlags(Flags.FLAG_REDUCE_BINDER_TRANSACTION_ENABLED)
    @SuppressWarnings("GuardedBy")
    public void notifyContentCaptureEvents_started_ContentCaptureEnabled_ProtectionEnabled_Flush()
            throws RemoteException {
@@ -439,6 +440,33 @@ public class MainContentCaptureSessionTest {
        assertThat(session.mEvents).isEmpty();
    }

    @Test
    @EnableFlags(Flags.FLAG_REDUCE_BINDER_TRANSACTION_ENABLED)
    @SuppressWarnings("GuardedBy")
    public void notifyContentCaptureEvents_flush_reducedBinderTransactionEnabled()
            throws RemoteException {
        ContentCaptureOptions options =
                createOptions(
                        /* enableContentCaptureReceiver= */ true,
                        /* enableContentProtectionReceiver= */ true);
        MainContentCaptureSession session = createSession(options);
        session.mDirectServiceInterface = mMockContentCaptureDirectManager;

        session.onSessionStarted(0x2, null);
        // Override the processor for interaction verification.
        session.mContentProtectionEventProcessor = mMockContentProtectionEventProcessor;
        notifyContentCaptureEvents(session);
        mTestableLooper.processAllMessages();

        // Force flush will happen only once when flag enabled.
        verify(mMockContentCaptureDirectManager, times(1))
                .sendEvents(any(), anyInt(), any());
        verifyNoMoreInteractions(mMockContentCaptureDirectManager);
        // 5 view events + 2 view tree events + 1 flush event
        verify(mMockContentProtectionEventProcessor, times(8)).processEvent(any());
        assertThat(session.mEvents).isEmpty();
    }

    @Test
    public void notifyViewAppearedBelowMaximumBufferSize() throws RemoteException {
        ContentCaptureOptions options =