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.category.client.DefaultWallpaperCategoryClient
28 import com.android.wallpaper.picker.category.domain.interactor.CategoryInteractor
29 import com.android.wallpaper.picker.category.domain.interactor.ThirdPartyCategoryInteractor
30 import com.android.wallpaper.picker.category.ui.view.providers.IndividualPickerFactory
31 import com.android.wallpaper.picker.category.ui.view.providers.implementation.DefaultIndividualPickerFactory
32 import com.android.wallpaper.picker.category.wrapper.WallpaperCategoryWrapper
33 import com.android.wallpaper.picker.common.preview.ui.binder.DefaultWorkspaceCallbackBinder
34 import com.android.wallpaper.picker.common.preview.ui.binder.WorkspaceCallbackBinder
35 import com.android.wallpaper.picker.customization.ui.binder.CustomizationOptionsBinder
36 import com.android.wallpaper.picker.customization.ui.binder.DefaultCustomizationOptionsBinder
37 import com.android.wallpaper.picker.customization.ui.binder.DefaultToolbarBinder
38 import com.android.wallpaper.picker.customization.ui.binder.ToolbarBinder
39 import com.android.wallpaper.picker.preview.ui.util.DefaultImageEffectDialogUtil
40 import com.android.wallpaper.picker.preview.ui.util.ImageEffectDialogUtil
41 import com.android.wallpaper.testing.FakeCategoryInteractor
42 import com.android.wallpaper.testing.FakeDefaultRequester
43 import com.android.wallpaper.testing.FakeDefaultWallpaperCategoryClient
44 import com.android.wallpaper.testing.FakeDefaultWallpaperModelFactory
45 import com.android.wallpaper.testing.FakeThirdPartyCategoryInteractor
46 import com.android.wallpaper.testing.FakeWallpaperCategoryWrapper
47 import com.android.wallpaper.testing.TestInjector
48 import com.android.wallpaper.testing.TestPartnerProvider
49 import com.android.wallpaper.testing.TestWallpaperPreferences
50 import com.android.wallpaper.util.converter.WallpaperModelFactory
51 import dagger.Binds
52 import dagger.Module
53 import dagger.hilt.components.SingletonComponent
54 import dagger.hilt.testing.TestInstallIn
55 import javax.inject.Singleton
56 
57 @Module
58 @TestInstallIn(
59     components = [SingletonComponent::class],
60     replaces = [WallpaperPicker2AppModule::class],
61 )
62 abstract class WallpaperPicker2TestModule {
63 
64     @Binds
65     @Singleton
bindCustomizationOptionsBindernull66     abstract fun bindCustomizationOptionsBinder(
67         impl: DefaultCustomizationOptionsBinder
68     ): CustomizationOptionsBinder
69 
70     @Binds
71     @Singleton
72     abstract fun bindDefaultWallpaperCategoryClient(
73         impl: FakeDefaultWallpaperCategoryClient
74     ): DefaultWallpaperCategoryClient
75 
76     @Binds
77     @Singleton
78     abstract fun bindThirdPartyCategoryInteractor(
79         impl: FakeThirdPartyCategoryInteractor
80     ): ThirdPartyCategoryInteractor
81 
82     @Binds
83     @Singleton
84     abstract fun bindEffectsController(impl: FakeEffectsController): EffectsController
85 
86     @Binds
87     @Singleton
88     abstract fun bindIndividualPickerFactoryFragment(
89         impl: DefaultIndividualPickerFactory
90     ): IndividualPickerFactory
91 
92     @Binds
93     @Singleton
94     abstract fun bindCategoryInteractor(impl: FakeCategoryInteractor): CategoryInteractor
95 
96     @Binds
97     @Singleton
98     abstract fun bindImageEffectDialogUtil(
99         impl: DefaultImageEffectDialogUtil
100     ): ImageEffectDialogUtil
101 
102     @Binds @Singleton abstract fun bindInjector(impl: TestInjector): Injector
103 
104     @Binds @Singleton abstract fun bindPartnerProvider(impl: TestPartnerProvider): PartnerProvider
105 
106     @Binds @Singleton abstract fun bindRequester(impl: FakeDefaultRequester): Requester
107 
108     @Binds @Singleton abstract fun bindToolbarBinder(impl: DefaultToolbarBinder): ToolbarBinder
109 
110     @Binds @Singleton abstract fun bindUserEventLogger(impl: TestUserEventLogger): UserEventLogger
111 
112     @Binds
113     @Singleton
114     abstract fun bindWallpaperCategoryWrapper(
115         impl: FakeWallpaperCategoryWrapper
116     ): WallpaperCategoryWrapper
117 
118     @Binds
119     @Singleton
120     abstract fun bindWallpaperModelFactory(
121         impl: FakeDefaultWallpaperModelFactory
122     ): WallpaperModelFactory
123 
124     @Binds
125     @Singleton
126     abstract fun bindWallpaperPreferences(impl: TestWallpaperPreferences): WallpaperPreferences
127 
128     @Binds
129     @Singleton
130     abstract fun bindWorkspaceCallbackBinder(
131         impl: DefaultWorkspaceCallbackBinder
132     ): WorkspaceCallbackBinder
133 }
134