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.systemui.statusbar.pipeline.wifi.data.repository
18 
19 import com.android.systemui.statusbar.pipeline.shared.data.model.DataActivityModel
20 import com.android.systemui.statusbar.pipeline.wifi.data.repository.prod.WifiRepositoryImpl.Companion.ACTIVITY_DEFAULT
21 import com.android.systemui.statusbar.pipeline.wifi.shared.model.WifiNetworkModel
22 import com.android.systemui.statusbar.pipeline.wifi.shared.model.WifiScanEntry
23 import kotlinx.coroutines.flow.MutableStateFlow
24 import kotlinx.coroutines.flow.StateFlow
25 
26 /** Fake implementation of [WifiRepository] exposing set methods for all the flows. */
27 class FakeWifiRepository : WifiRepository {
28     private val _isWifiEnabled: MutableStateFlow<Boolean> = MutableStateFlow(false)
29     override val isWifiEnabled: StateFlow<Boolean> = _isWifiEnabled
30 
31     private val _isWifiDefault: MutableStateFlow<Boolean> = MutableStateFlow(false)
32     override val isWifiDefault: StateFlow<Boolean> = _isWifiDefault
33 
34     private val _wifiNetwork: MutableStateFlow<WifiNetworkModel> =
35         MutableStateFlow(WifiNetworkModel.Inactive)
36     override val wifiNetwork: StateFlow<WifiNetworkModel> = _wifiNetwork
37 
38     override val secondaryNetworks = MutableStateFlow<List<WifiNetworkModel>>(emptyList())
39 
40     private val _wifiActivity = MutableStateFlow(ACTIVITY_DEFAULT)
41     override val wifiActivity: StateFlow<DataActivityModel> = _wifiActivity
42 
43     override val wifiScanResults: MutableStateFlow<List<WifiScanEntry>> =
44         MutableStateFlow(emptyList())
45 
setIsWifiEnablednull46     fun setIsWifiEnabled(enabled: Boolean) {
47         _isWifiEnabled.value = enabled
48     }
49 
setIsWifiDefaultnull50     fun setIsWifiDefault(default: Boolean) {
51         _isWifiDefault.value = default
52     }
53 
setWifiNetworknull54     fun setWifiNetwork(wifiNetworkModel: WifiNetworkModel) {
55         _wifiNetwork.value = wifiNetworkModel
56     }
57 
setWifiActivitynull58     fun setWifiActivity(activity: DataActivityModel) {
59         _wifiActivity.value = activity
60     }
61 }
62