Skip to content

Commit

Permalink
Add kdoc and remove file from kdoc_validity_excemptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Vishwajith-Shettigar committed Jul 2, 2024
1 parent 2bef747 commit 6d8f714
Showing 1 changed file with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,24 @@ import org.oppia.android.util.extensions.getProtoExtra
/** A custom matcher to check if an Intent has a specific proto extra. */
class ProtoExtraMatcher {
companion object {
fun <T : MessageLite> hasProtoExtraCheck(keyName: String, expectedProto: T):
Matcher<Intent> {
val defaultProto = expectedProto.newBuilderForType().build()
return object : TypeSafeMatcher<Intent>() {
override fun describeTo(description: Description) {
description.appendText("Intent with extra: $keyName and proto value: $expectedProto")
}
override fun matchesSafely(intent: Intent): Boolean {
return intent.hasExtra(keyName) &&
intent.getProtoExtra(keyName, defaultProto) == expectedProto
}
/**
* Returns a matcher that verifies if an Intent contains a specific proto extra.
*
* @param keyName The key name of the proto extra in the Intent.
* @param expectedProto The expected proto message to be matched.
*/
fun <T : MessageLite> hasProtoExtraCheck(keyName: String, expectedProto: T): Matcher<Intent> {
val defaultProto = expectedProto.newBuilderForType().build()
return object : TypeSafeMatcher<Intent>() {
override fun describeTo(description: Description) {
description.appendText("Intent with extra: $keyName and proto value: $expectedProto")
}

override fun matchesSafely(intent: Intent): Boolean {
return intent.hasExtra(keyName) &&
intent.getProtoExtra(keyName, defaultProto) == expectedProto
}
}
}
}
}

0 comments on commit 6d8f714

Please sign in to comment.