1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.systemui.statusbar 18 19 import android.testing.AndroidTestingRunner 20 import androidx.test.filters.SmallTest 21 import com.android.systemui.SysuiTestCase 22 import com.android.systemui.util.mockito.whenever 23 import org.junit.After 24 import org.junit.Before 25 import org.junit.Test 26 import org.junit.runner.RunWith 27 import org.mockito.Mock 28 import org.mockito.Mockito.anyBoolean 29 import org.mockito.Mockito.doCallRealMethod 30 import org.mockito.Mockito.doReturn 31 import org.mockito.Mockito.never 32 import org.mockito.Mockito.verify 33 import org.mockito.MockitoAnnotations 34 35 /** 36 * Temporary test for the lock screen live wallpaper project. 37 * 38 * TODO(b/273443374): remove this test 39 */ 40 @RunWith(AndroidTestingRunner::class) 41 @SmallTest 42 class NotificationMediaManagerTest : SysuiTestCase() { 43 44 @Mock private lateinit var notificationMediaManager: NotificationMediaManager 45 46 @Mock private lateinit var mockBackDropView: BackDropView 47 48 @Before 49 fun setUp() { 50 MockitoAnnotations.initMocks(this) 51 doCallRealMethod() 52 .whenever(notificationMediaManager) 53 .updateMediaMetaData(anyBoolean(), anyBoolean()) 54 doReturn(mockBackDropView).whenever(notificationMediaManager).backDropView 55 } 56 57 @After fun tearDown() {} 58 59 /** Check that updateMediaMetaData is a no-op with mIsLockscreenLiveWallpaperEnabled = true */ 60 @Test 61 fun testUpdateMediaMetaDataDisabled() { 62 notificationMediaManager.mIsLockscreenLiveWallpaperEnabled = true 63 for (metaDataChanged in listOf(true, false)) { 64 for (allowEnterAnimation in listOf(true, false)) { 65 notificationMediaManager.updateMediaMetaData(metaDataChanged, allowEnterAnimation) 66 verify(notificationMediaManager, never()).mediaMetadata 67 } 68 } 69 } 70 } 71