1 /* <lambda>null2 * 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 package com.android.wm.shell.bubbles 17 18 import android.graphics.Color 19 import android.view.LayoutInflater 20 import android.view.ViewGroup 21 import com.android.wm.shell.R 22 import com.android.wm.shell.shared.bubbles.BubblePopupView 23 import com.android.wm.shell.testing.goldenpathmanager.WMShellGoldenPathManager 24 import org.junit.Rule 25 import org.junit.Test 26 import org.junit.runner.RunWith 27 import platform.test.runner.parameterized.ParameterizedAndroidJunit4 28 import platform.test.runner.parameterized.Parameters 29 import platform.test.screenshot.DeviceEmulationSpec 30 import platform.test.screenshot.Displays 31 import platform.test.screenshot.ViewScreenshotTestRule 32 import platform.test.screenshot.getEmulatedDevicePathConfig 33 34 @RunWith(ParameterizedAndroidJunit4::class) 35 class BubbleEducationViewScreenshotTest(emulationSpec: DeviceEmulationSpec) { 36 companion object { 37 @Parameters(name = "{0}") 38 @JvmStatic 39 fun getTestSpecs() = DeviceEmulationSpec.forDisplays(Displays.Phone, isLandscape = false) 40 } 41 42 @get:Rule 43 val screenshotRule = 44 ViewScreenshotTestRule( 45 emulationSpec, 46 WMShellGoldenPathManager(getEmulatedDevicePathConfig(emulationSpec)) 47 ) 48 49 @Test 50 fun bubblesEducation() { 51 screenshotRule.screenshotTest("bubbles_education") { activity -> 52 activity.actionBar?.hide() 53 // Set the background color of the activity to be something not from the theme to 54 // ensure good contrast between the education view and the background 55 val rootView = activity.window.decorView.findViewById(android.R.id.content) as ViewGroup 56 rootView.setBackgroundColor(Color.RED) 57 val view = 58 LayoutInflater.from(activity) 59 .inflate(R.layout.bubble_bar_stack_education, null) as BubblePopupView 60 view.setup() 61 view 62 } 63 } 64 } 65