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.settingslib.spa.screenshot.util
18 
19 import androidx.test.platform.app.InstrumentationRegistry
20 import platform.test.screenshot.GoldenPathManager
21 import platform.test.screenshot.PathConfig
22 
23 /** A [GoldenPathManager] that should be used for all Settings screenshot tests. */
24 class SettingsGoldenPathManager(pathConfig: PathConfig, assetsPathRelativeToBuildRoot: String) :
25     GoldenPathManager(
26         appContext = InstrumentationRegistry.getInstrumentation().context,
27         assetsPathRelativeToBuildRoot = assetsPathRelativeToBuildRoot,
28         deviceLocalPath =
29             InstrumentationRegistry.getInstrumentation()
30                 .targetContext
31                 .filesDir
32                 .absolutePath
33                 .toString() + "/settings_screenshots",
34         pathConfig = pathConfig,
35     ) {
toStringnull36     override fun toString(): String {
37         // This string is appended to all actual/expected screenshots on the device, so make sure
38         // it is a static value.
39         return "SettingsGoldenPathManager"
40     }
41 }
42