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.wallpaper.testing
18 
19 import android.content.res.XmlResourceParser
20 import com.android.wallpaper.model.SystemStaticWallpaperInfo
21 import com.android.wallpaper.model.WallpaperCategory
22 import com.android.wallpaper.model.WallpaperInfo
23 import com.android.wallpaper.util.WallpaperParser
24 import javax.inject.Inject
25 import javax.inject.Singleton
26 
27 @Singleton
28 class FakeWallpaperParser @Inject constructor() : WallpaperParser {
29     var wallpapers: List<WallpaperInfo> = emptyList()
30 
parseSystemCategoriesnull31     override fun parseSystemCategories(parser: XmlResourceParser): List<WallpaperCategory> {
32         val wallpapers = listOf(fakeSystemStaticWallpaperInfo)
33         return listOf(
34             WallpaperCategory(
35                 /* title= */ "sample-title-1",
36                 /* collectionId= */ "sample-collection-id",
37                 wallpapers,
38                 1
39             )
40         )
41     }
42 
parsePartnerWallpaperInfoResourcesnull43     override fun parsePartnerWallpaperInfoResources(): List<WallpaperInfo> {
44         return wallpapers
45     }
46 
setPartnerWallpapersnull47     fun setPartnerWallpapers(wallpapers: List<WallpaperInfo>) {
48         this.wallpapers = wallpapers
49     }
50 
51     companion object FakeWallpaperData {
52         val fakeSystemStaticWallpaperInfo =
53             SystemStaticWallpaperInfo(
54                 "fake_package_name",
55                 "fake_wallpaper_1",
56                 "fake_category_id",
57                 0, // drawableResId
58                 0, // titleResId
59                 0, // subtitle1ResId
60                 0, // subtitle2ResId
61                 0, // actionTypeResId
62                 0, // actionUrlResId
63                 0 // thumbnailResId
64             )
65     }
66 }
67