1 /* 2 * Copyright (C) 2024 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.notification.promoted 18 19 import android.app.Notification 20 import com.android.systemui.statusbar.NotificationLockscreenUserManager.RedactionType 21 import com.android.systemui.statusbar.notification.collection.NotificationEntry 22 import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModels 23 import com.android.systemui.statusbar.notification.row.shared.ImageModelProvider 24 import org.junit.Assert 25 26 class FakePromotedNotificationContentExtractor : PromotedNotificationContentExtractor { 27 @JvmField 28 val contentForEntry = mutableMapOf<NotificationEntry, PromotedNotificationContentModels?>() 29 @JvmField val extractCalls = mutableListOf<Pair<NotificationEntry, Notification.Builder>>() 30 extractContentnull31 override fun extractContent( 32 entry: NotificationEntry, 33 recoveredBuilder: Notification.Builder, 34 @RedactionType redactionType: Int, 35 imageModelProvider: ImageModelProvider, 36 ): PromotedNotificationContentModels? { 37 extractCalls.add(entry to recoveredBuilder) 38 39 if (contentForEntry.isEmpty()) { 40 // If *no* entries are set, just return null for everything. 41 return null 42 } else { 43 // If entries *are* set, fail on unexpected ones. 44 Assert.assertTrue(contentForEntry.containsKey(entry)) 45 return contentForEntry[entry] 46 } 47 } 48 resetForEntrynull49 fun resetForEntry(entry: NotificationEntry, content: PromotedNotificationContentModels?) { 50 contentForEntry.clear() 51 contentForEntry[entry] = content 52 extractCalls.clear() 53 } 54 verifyZeroExtractCallsnull55 fun verifyZeroExtractCalls() { 56 Assert.assertTrue(extractCalls.isEmpty()) 57 } 58 verifyOneExtractCallnull59 fun verifyOneExtractCall() { 60 Assert.assertEquals(1, extractCalls.size) 61 } 62 } 63