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 com.android.wallpaper
17 
18 import com.android.wallpaper.effects.EffectsController
19 import com.android.wallpaper.effects.FakeEffectsController
20 import com.android.wallpaper.module.Injector
21 import com.android.wallpaper.module.PartnerProvider
22 import com.android.wallpaper.module.WallpaperPreferences
23 import com.android.wallpaper.module.logging.TestUserEventLogger
24 import com.android.wallpaper.module.logging.UserEventLogger
25 import com.android.wallpaper.modules.WallpaperPicker2AppModule
26 import com.android.wallpaper.network.Requester
27 import com.android.wallpaper.picker.customization.ui.binder.CustomizationOptionsBinder
28 import com.android.wallpaper.picker.customization.ui.binder.DefaultCustomizationOptionsBinder
29 import com.android.wallpaper.picker.di.modules.EffectsModule
30 import com.android.wallpaper.picker.preview.data.util.FakeLiveWallpaperDownloader
31 import com.android.wallpaper.picker.preview.data.util.LiveWallpaperDownloader
32 import com.android.wallpaper.picker.preview.ui.util.DefaultImageEffectDialogUtil
33 import com.android.wallpaper.picker.preview.ui.util.ImageEffectDialogUtil
34 import com.android.wallpaper.testing.FakeDefaultRequester
35 import com.android.wallpaper.testing.FakeDefaultWallpaperModelFactory
36 import com.android.wallpaper.testing.TestInjector
37 import com.android.wallpaper.testing.TestPartnerProvider
38 import com.android.wallpaper.testing.TestWallpaperPreferences
39 import com.android.wallpaper.util.converter.WallpaperModelFactory
40 import dagger.Binds
41 import dagger.Module
42 import dagger.hilt.components.SingletonComponent
43 import dagger.hilt.testing.TestInstallIn
44 import javax.inject.Singleton
45 
46 @Module
47 @TestInstallIn(
48     components = [SingletonComponent::class],
49     replaces = [EffectsModule::class, WallpaperPicker2AppModule::class]
50 )
51 abstract class WallpaperPicker2TestModule {
bindInjectornull52     @Binds @Singleton abstract fun bindInjector(impl: TestInjector): Injector
53 
54     @Binds @Singleton abstract fun bindUserEventLogger(impl: TestUserEventLogger): UserEventLogger
55 
56     @Binds @Singleton abstract fun bindFakeRequester(impl: FakeDefaultRequester): Requester
57 
58     @Binds
59     @Singleton
60     abstract fun bindWallpaperModelFactory(
61         impl: FakeDefaultWallpaperModelFactory
62     ): WallpaperModelFactory
63 
64     @Binds
65     @Singleton
66     abstract fun bindWallpaperPreferences(impl: TestWallpaperPreferences): WallpaperPreferences
67 
68     @Binds
69     @Singleton
70     abstract fun bindLiveWallpaperDownloader(
71         impl: FakeLiveWallpaperDownloader
72     ): LiveWallpaperDownloader
73 
74     @Binds
75     @Singleton
76     abstract fun providePartnerProvider(impl: TestPartnerProvider): PartnerProvider
77 
78     @Binds
79     @Singleton
80     abstract fun bindEffectsWallpaperDialogUtil(
81         impl: DefaultImageEffectDialogUtil
82     ): ImageEffectDialogUtil
83 
84     @Binds
85     @Singleton
86     abstract fun bindEffectsController(impl: FakeEffectsController): EffectsController
87 
88     @Binds
89     @Singleton
90     abstract fun bindCustomizationOptionsBinder(
91         impl: DefaultCustomizationOptionsBinder
92     ): CustomizationOptionsBinder
93 }
94