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 package android.app.notification.extenders.cts.current
17 
18 import android.app.Notification
19 import android.app.Notification.WearableExtender
20 import android.content.Context
21 import android.graphics.Bitmap
22 import android.graphics.Bitmap.Config
23 import android.os.Build
24 import androidx.test.ext.junit.runners.AndroidJUnit4
25 import androidx.test.platform.app.InstrumentationRegistry
26 import com.google.common.truth.Truth.assertThat
27 import org.junit.Assume
28 import org.junit.Before
29 import org.junit.Test
30 import org.junit.runner.RunWith
31 
32 @RunWith(AndroidJUnit4::class)
33 class WearableExtenderApiCurrentTest {
34 
35     private lateinit var mContext: Context
36 
37     @Before
setUpnull38     fun setUp() {
39         mContext = InstrumentationRegistry.getInstrumentation().targetContext
40     }
41 
42     @Test
wearableBackgroundBlockDisabled_wearableBackgroundSet_valueIsNullnull43     fun wearableBackgroundBlockDisabled_wearableBackgroundSet_valueIsNull() {
44         // The API change in this test is not present in API levels beforehand.
45         Assume.assumeTrue(Build.VERSION.SDK_INT >= 35)
46 
47         val extender = WearableExtender()
48         val bitmap = Bitmap.createBitmap(200, 200, Config.ARGB_8888)
49         extender.setBackground(bitmap)
50         val notif: Notification =
51                 Notification.Builder(mContext, "test id")
52                     .setSmallIcon(1)
53                     .setContentTitle("test_title")
54                     .extend(extender)
55                     .build()
56 
57         val result = WearableExtender(notif)
58         val background = result.getBackground()
59         assertThat(background).isNull()
60     }
61 }
62