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 package com.android.wm.shell.testing.goldenpathmanager 17 18 import android.os.Build 19 import androidx.test.platform.app.InstrumentationRegistry 20 import platform.test.screenshot.GoldenPathManager 21 import platform.test.screenshot.PathConfig 22 23 /** A WM Shell specific implementation of [GoldenPathManager]. */ 24 class WMShellGoldenPathManager(pathConfig: PathConfig) : 25 GoldenPathManager( 26 appContext = InstrumentationRegistry.getInstrumentation().context, 27 assetsPathRelativeToBuildRoot = assetPath, 28 deviceLocalPath = deviceLocalPath, 29 pathConfig = pathConfig, 30 ) { 31 32 private companion object { 33 private const val ASSETS_PATH = 34 "frameworks/base/libs/WindowManager/Shell/multivalentScreenshotTests/goldens/onDevice" 35 private const val ASSETS_PATH_ROBO = 36 "frameworks/base/libs/WindowManager/Shell/multivalentScreenshotTests/goldens/" + 37 "robolectric" 38 private val assetPath: String 39 get() = if (Build.FINGERPRINT.contains("robolectric")) ASSETS_PATH_ROBO else ASSETS_PATH 40 private val deviceLocalPath: String 41 get() = 42 InstrumentationRegistry.getInstrumentation() 43 .targetContext 44 .filesDir 45 .absolutePath 46 .toString() + "/wmshell_screenshots" 47 } toStringnull48 override fun toString(): String { 49 // This string is appended to all actual/expected screenshots on the device, so make sure 50 // it is a static value. 51 return "WMShellGoldenPathManager" 52 } 53 } 54