diff options
7 files changed, 217 insertions, 2 deletions
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/broadcast/BroadcastDispatcherKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/broadcast/BroadcastDispatcherKosmos.kt new file mode 100644 index 000000000000..7207948412b4 --- /dev/null +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/broadcast/BroadcastDispatcherKosmos.kt @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.broadcast + +import com.android.systemui.kosmos.Kosmos +import com.android.systemui.util.mockito.mock + +val Kosmos.broadcastDispatcher by + Kosmos.Fixture { + FakeBroadcastDispatcher( + context = mock(), + mainExecutor = mock(), + broadcastRunningLooper = mock(), + broadcastRunningExecutor = mock(), + dumpManager = mock(), + logger = mock(), + userTracker = mock(), + shouldFailOnLeakedReceiver = false + ) + } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/flags/FeatureFlagsKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/flags/FeatureFlagsKosmos.kt new file mode 100644 index 000000000000..a78076338c79 --- /dev/null +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/flags/FeatureFlagsKosmos.kt @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.flags + +import com.android.systemui.kosmos.Kosmos + +val Kosmos.featureFlags by Kosmos.Fixture { FakeFeatureFlagsClassic() } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/GeneralKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/GeneralKosmos.kt index cc843b536756..b05915c4f678 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/GeneralKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/GeneralKosmos.kt @@ -1,8 +1,16 @@ package com.android.systemui.kosmos +import android.content.Context +import android.os.UserManager import com.android.systemui.kosmos.Kosmos.Fixture +import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.test.StandardTestDispatcher import kotlinx.coroutines.test.TestScope +import org.mockito.Mockito -val Kosmos.testDispatcher by Fixture { StandardTestDispatcher() } -val Kosmos.testScope by Fixture { TestScope(testDispatcher) } +var Kosmos.testDispatcher by Fixture { StandardTestDispatcher() } +var Kosmos.testScope by Fixture { TestScope(testDispatcher) } +var Kosmos.context by Fixture<Context>() +var Kosmos.lifecycleScope by Fixture<CoroutineScope>() + +val Kosmos.userManager by Fixture { Mockito.mock(UserManager::class.java) } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/user/data/repository/UserRepositoryKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/user/data/repository/UserRepositoryKosmos.kt new file mode 100644 index 000000000000..8bce9b6d461d --- /dev/null +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/user/data/repository/UserRepositoryKosmos.kt @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.user.data.repository + +import com.android.systemui.kosmos.Kosmos + +val Kosmos.userRepository by Kosmos.Fixture { FakeUserRepository() } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/user/domain/interactor/GuestUserInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/user/domain/interactor/GuestUserInteractorKosmos.kt new file mode 100644 index 000000000000..e69570433d43 --- /dev/null +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/user/domain/interactor/GuestUserInteractorKosmos.kt @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.user.domain.interactor + +import com.android.systemui.kosmos.Kosmos +import com.android.systemui.kosmos.context +import com.android.systemui.kosmos.lifecycleScope +import com.android.systemui.kosmos.testDispatcher +import com.android.systemui.kosmos.userManager +import com.android.systemui.user.data.repository.userRepository +import com.android.systemui.util.mockito.mock + +val Kosmos.guestUserInteractor by + Kosmos.Fixture { + GuestUserInteractor( + applicationContext = context, + applicationScope = lifecycleScope, + mainDispatcher = testDispatcher, + backgroundDispatcher = testDispatcher, + manager = userManager, + deviceProvisionedController = mock(), + repository = userRepository, + devicePolicyManager = mock(), + refreshUsersScheduler = refreshUsersScheduler, + uiEventLogger = mock(), + resumeSessionReceiver = mock(), + resetOrExitSessionReceiver = mock(), + ) + } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/user/domain/interactor/RefreshUsersSchedulerKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/user/domain/interactor/RefreshUsersSchedulerKosmos.kt new file mode 100644 index 000000000000..87a2fe0249e3 --- /dev/null +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/user/domain/interactor/RefreshUsersSchedulerKosmos.kt @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.user.domain.interactor + +import com.android.systemui.kosmos.Kosmos +import com.android.systemui.kosmos.lifecycleScope +import com.android.systemui.kosmos.testDispatcher +import com.android.systemui.user.data.repository.userRepository + +val Kosmos.refreshUsersScheduler by + Kosmos.Fixture { + RefreshUsersScheduler( + applicationScope = lifecycleScope, + mainDispatcher = testDispatcher, + repository = userRepository, + ) + } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/user/domain/interactor/UserSwitcherInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/user/domain/interactor/UserSwitcherInteractorKosmos.kt new file mode 100644 index 000000000000..6d6b2683a7ea --- /dev/null +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/user/domain/interactor/UserSwitcherInteractorKosmos.kt @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.user.domain.interactor + +import com.android.systemui.broadcast.broadcastDispatcher +import com.android.systemui.flags.featureFlags +import com.android.systemui.keyguard.domain.interactor.KeyguardInteractorFactory +import com.android.systemui.kosmos.Kosmos +import com.android.systemui.kosmos.context +import com.android.systemui.kosmos.lifecycleScope +import com.android.systemui.kosmos.testDispatcher +import com.android.systemui.kosmos.userManager +import com.android.systemui.telephony.data.repository.FakeTelephonyRepository +import com.android.systemui.telephony.domain.interactor.TelephonyInteractor +import com.android.systemui.user.data.repository.userRepository +import com.android.systemui.util.mockito.mock + +val Kosmos.userSwitcherInteractor by + Kosmos.Fixture { + UserSwitcherInteractor( + applicationContext = context, + repository = userRepository, + activityStarter = mock(), + keyguardInteractor = + KeyguardInteractorFactory.create(featureFlags = featureFlags).keyguardInteractor, + featureFlags = featureFlags, + manager = userManager, + headlessSystemUserMode = mock(), + applicationScope = lifecycleScope, + telephonyInteractor = + TelephonyInteractor( + repository = FakeTelephonyRepository(), + ), + broadcastDispatcher = broadcastDispatcher, + keyguardUpdateMonitor = mock(), + backgroundDispatcher = testDispatcher, + activityManager = mock(), + refreshUsersScheduler = refreshUsersScheduler, + guestUserInteractor = guestUserInteractor, + uiEventLogger = mock(), + userRestrictionChecker = mock() + ) + } |