-
Notifications
You must be signed in to change notification settings - Fork 237
Add unit tests in some push classes #2899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
50004e3
Add test on UnifiedPushGatewayResolver
bmarty 86eceb3
UnifiedPushGatewayResolver.getGateway cannot return null.
bmarty 1bf38e9
Add test on `UnifiedPushProvider`
bmarty 538c2b0
Create FakeIsPlayServiceAvailable
bmarty 0087972
Add test for FirebasePushProvider
bmarty b70c591
Remove unused code notificationStyleChanged()
bmarty 20880b0
Extract testPush to its own class and rename PushersManager to Defaul…
bmarty dc6e62a
Add test on PushGatewayNotifyRequest
bmarty 505f6d4
Add test on DefaultPushService
bmarty 08f70b9
Move some classes to the test module.
bmarty 707a530
Fix wrong package name.
bmarty 97530e7
Add test on DefaultPusherSubscriber
bmarty 3bde744
Add test on DefaultTestPush
bmarty fe771a3
isCalledExactly(1) -> isCalledOnce()
bmarty 980a80b
Cleanup
bmarty 5b074dc
Create interface for NotifiableEventResolver
bmarty b2a3b96
Add test on DefaultPushHandler
bmarty eafa713
Add test on VectorFirebaseMessagingService
bmarty 90a14ce
Change to lambda
bmarty b38c144
Add test on DefaultFirebaseNewTokenHandler
bmarty 5c68956
Fix test on `VectorFirebaseMessagingService`
bmarty 738bb83
Create interface UnifiedPushGatewayResolver
bmarty 09b2b2c
Create interface UnifiedPushNewGatewayHandler
bmarty 50b7f2c
Add test on VectorUnifiedPushMessagingReceiver
bmarty f304c1f
Add test on DefaultRegisterUnifiedPushUseCase
bmarty f974cdd
Add test on DefaultUnifiedPushNewGatewayHandler
bmarty 02fa405
Add test on UnifiedPushTest.isRelevant
bmarty 0a2d87f
Add test on DefaultUnregisterUnifiedPushUseCase
bmarty 4e7f5c4
Refactor: change signature to always have `clientSecret` first, since…
bmarty cf3b2bb
Add test on isRelevant
bmarty c71c491
Clean up
bmarty f042532
Introduce lambdaError instead of using TODO, to handle error when a l…
bmarty de032fa
Use lambdaError() instead of `throw NotImplementedError()`
bmarty b8b66b3
Add missing import
bmarty 0639bc6
Simplify `RegisterUnifiedPushUseCase`, fix test
jmartinesp b716482
No need to use advanceTimeBy
bmarty 788d9e0
No need to use StandardTestDispatcher
bmarty File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,9 @@ package io.element.android.libraries.push.impl.notifications | |
import android.content.Context | ||
import android.net.Uri | ||
import androidx.core.content.FileProvider | ||
import com.squareup.anvil.annotations.ContributesBinding | ||
import io.element.android.libraries.core.log.logger.LoggerTag | ||
import io.element.android.libraries.di.AppScope | ||
import io.element.android.libraries.di.ApplicationContext | ||
import io.element.android.libraries.matrix.api.MatrixClient | ||
import io.element.android.libraries.matrix.api.MatrixClientProvider | ||
|
@@ -55,23 +57,28 @@ import io.element.android.services.toolbox.api.systemclock.SystemClock | |
import timber.log.Timber | ||
import javax.inject.Inject | ||
|
||
private val loggerTag = LoggerTag("NotifiableEventResolver", LoggerTag.NotificationLoggerTag) | ||
private val loggerTag = LoggerTag("DefaultNotifiableEventResolver", LoggerTag.NotificationLoggerTag) | ||
|
||
/** | ||
* The notifiable event resolver is able to create a NotifiableEvent (view model for notifications) from an sdk Event. | ||
* It is used as a bridge between the Event Thread and the NotificationDrawerManager. | ||
* The NotifiableEventResolver is the only aware of session/store, the NotificationDrawerManager has no knowledge of that, | ||
* this pattern allow decoupling between the object responsible of displaying notifications and the matrix sdk. | ||
*/ | ||
class NotifiableEventResolver @Inject constructor( | ||
interface NotifiableEventResolver { | ||
suspend fun resolveEvent(sessionId: SessionId, roomId: RoomId, eventId: EventId): NotifiableEvent? | ||
} | ||
|
||
@ContributesBinding(AppScope::class) | ||
class DefaultNotifiableEventResolver @Inject constructor( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe move this to a separate file in the api module? |
||
private val stringProvider: StringProvider, | ||
private val clock: SystemClock, | ||
private val matrixClientProvider: MatrixClientProvider, | ||
private val notificationMediaRepoFactory: NotificationMediaRepo.Factory, | ||
@ApplicationContext private val context: Context, | ||
private val permalinkParser: PermalinkParser, | ||
) { | ||
suspend fun resolveEvent(sessionId: SessionId, roomId: RoomId, eventId: EventId): NotifiableEvent? { | ||
) : NotifiableEventResolver { | ||
override suspend fun resolveEvent(sessionId: SessionId, roomId: RoomId, eventId: EventId): NotifiableEvent? { | ||
// Restore session | ||
val client = matrixClientProvider.getOrRestore(sessionId).getOrNull() ?: return null | ||
val notificationService = client.notificationService() | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally it would be nice to use
matrixClientResult
here to the getMatrixClient
instead of having 2 sources of truth, but changing it may not be worth it.