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

Commit a68628ba authored by Kai Li's avatar Kai Li
Browse files

Fix MainContentCaptureSessionTest when FLAG_REDUCE_BINDER_TRANSACTION_ENABLED is on.

Bug: 433614684
Flag: android.view.contentcapture.flags.reduce_binder_transaction_enabled
Test: atest FrameworksCoreTests:android.view.contentcapture.MainContentCaptureSessionTest
Change-Id: I57765dac75b7fb6de468cf27ca8f267ff7fe59b7
parent 7e30dbcc
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 =