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

Commit 61fee704 authored by Tyler Gunn's avatar Tyler Gunn Committed by Automerger Merge Worker
Browse files

Add unit test coverage for BlockedNumbersUtil am: 9d9a830a

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/services/Telecomm/+/15014779

Change-Id: Iff4f02f2c2a2104a5b9161104d504765c4681193
parents 83dd3bb4 9d9a830a
Loading
Loading
Loading
Loading
+60 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server.telecom.tests;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.verify;

import android.app.Notification;
import android.app.NotificationManager;
import android.os.UserHandle;
import android.test.suitebuilder.annotation.SmallTest;

import com.android.server.telecom.settings.BlockedNumbersUtil;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

@RunWith(JUnit4.class)
public class BlockedNumbersUtilTests extends TelecomTestCase {
    @Override
    @Before
    public void setUp() throws Exception {
        super.setUp();
    }

    @SmallTest
    @Test
    public void testPostNotification() {
        BlockedNumbersUtil.updateEmergencyCallNotification(mContext, true);
        NotificationManager mgr = mComponentContextFixture.getNotificationManager();
        verify(mgr).notifyAsUser(isNull(), anyInt(), any(Notification.class),
                any(UserHandle.class));
    }

    @SmallTest
    @Test
    public void testDismissNotification() {
        BlockedNumbersUtil.updateEmergencyCallNotification(mContext, false);
        NotificationManager mgr = mComponentContextFixture.getNotificationManager();
        verify(mgr).cancelAsUser(isNull(), anyInt(), any(UserHandle.class));
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -711,6 +711,10 @@ public class ComponentContextFixture implements TestFixture<Context> {
        return mTelephonyManager;
    }

    public NotificationManager getNotificationManager() {
        return mNotificationManager;
    }

    private void addService(String action, ComponentName name, IInterface service) {
        mComponentNamesByAction.put(action, name);
        mServiceByComponentName.put(name, service);