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

Commit 26959c27 authored by Robert Gross's avatar Robert Gross Committed by Robert-Reinhold Gross
Browse files

Add tests to CallScreeningServiceFilter when connection is not properly

bound

This addition is related to Change-Id: Ib25cb5b0324e95b9cda3e09bf428e11e2b79601e
Original commit message: Incorrect handling of undefined call screening

If registration of call-screening service fails (by default it is not
available), the disconnection of said service is still attempted
throwing an error due to an attempt to unregister a receiver that
doesn't exist.

Test: Unit test
Bug: 189464381
Change-Id: Ibf175ed6aaa024961ba3e49839bf89d5e7334a27
parent 2056a377
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ import org.mockito.ArgumentCaptor;
import org.mockito.Mock;

import java.util.Collections;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.TimeUnit;

@@ -229,10 +230,28 @@ public class CallScreeningServiceFilterTest extends TelecomTestCase {
        CallScreeningServiceFilter filter = new CallScreeningServiceFilter(mCall, PKG_NAME,
                CallScreeningServiceFilter.PACKAGE_TYPE_CARRIER, mContext, mCallsManager,
                mAppLabelProxy, mParcelableCallUtilsConverter);
        filter.startFilterLookup(inputResult);
        CompletableFuture<CallFilteringResult> result = filter.startFilterLookup(inputResult)
                .toCompletableFuture();

        assertEquals(result.isDone(), false);

        filter.unbindCallScreeningService();
    }

    @SmallTest
    @Test
    public void testBindingFailed() {
        // Use an empty package name here, which fails in the bindCallScreeningService.
        CallScreeningServiceFilter filter = new CallScreeningServiceFilter(mCall, "",
                CallScreeningServiceFilter.PACKAGE_TYPE_CARRIER, mContext, mCallsManager,
                mAppLabelProxy, mParcelableCallUtilsConverter);

        CompletableFuture<CallFilteringResult> result = filter.startFilterLookup(inputResult)
                .toCompletableFuture();

        assertEquals(result.isDone(), true);
    }

    @SmallTest
    @Test
    public void testAllowCall() throws Exception {