Create FakeIsPlayServiceAvailable

This commit is contained in:
Benoit Marty
2024-05-22 11:11:14 +02:00
parent bfa238ba0d
commit fbd0d397de
2 changed files with 26 additions and 10 deletions

View File

@@ -0,0 +1,23 @@
/*
* Copyright (c) 2024 New Vector Ltd
*
* 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 io.element.android.libraries.pushproviders.firebase
class FakeIsPlayServiceAvailable(
private val isAvailable: Boolean,
) : IsPlayServiceAvailable {
override fun isAvailable() = isAvailable
}

View File

@@ -18,6 +18,7 @@ package io.element.android.libraries.pushproviders.firebase.troubleshoot
import app.cash.turbine.test
import com.google.common.truth.Truth.assertThat
import io.element.android.libraries.pushproviders.firebase.FakeIsPlayServiceAvailable
import io.element.android.libraries.pushproviders.firebase.IsPlayServiceAvailable
import io.element.android.libraries.troubleshoot.api.test.NotificationTroubleshootTestState
import io.element.android.services.toolbox.test.strings.FakeStringProvider
@@ -29,11 +30,7 @@ class FirebaseAvailabilityTestTest {
@Test
fun `test FirebaseAvailabilityTest success`() = runTest {
val sut = FirebaseAvailabilityTest(
isPlayServiceAvailable = object : IsPlayServiceAvailable {
override fun isAvailable(): Boolean {
return true
}
},
isPlayServiceAvailable = FakeIsPlayServiceAvailable(true),
stringProvider = FakeStringProvider(),
)
launch {
@@ -50,11 +47,7 @@ class FirebaseAvailabilityTestTest {
@Test
fun `test FirebaseAvailabilityTest failure`() = runTest {
val sut = FirebaseAvailabilityTest(
isPlayServiceAvailable = object : IsPlayServiceAvailable {
override fun isAvailable(): Boolean {
return false
}
},
isPlayServiceAvailable = FakeIsPlayServiceAvailable(false),
stringProvider = FakeStringProvider(),
)
launch {