-
Notifications
You must be signed in to change notification settings - Fork 662
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
16b2da4
commit b2c5821
Showing
6 changed files
with
61 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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 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
4 changes: 4 additions & 0 deletions
4
paymentsheet-example/src/androidTest/java/com/stripe/android/utils/GooglePayTest.kt
This file contains 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.stripe.android.utils | ||
@Retention(AnnotationRetention.RUNTIME) | ||
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.TYPE) | ||
annotation class GooglePayTest |
40 changes: 40 additions & 0 deletions
40
paymentsheet-example/src/androidTest/java/com/stripe/android/utils/GooglePayTestRule.kt
This file contains 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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.stripe.android.utils | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import org.junit.rules.TestRule | ||
import org.junit.runner.Description | ||
import org.junit.runners.model.Statement | ||
|
||
class GooglePayTestRule : TestRule { | ||
override fun apply(base: Statement, description: Description): Statement { | ||
return object : Statement() { | ||
override fun evaluate() { | ||
if (description.hasGooglePayTestAnnotation()) { | ||
if (shouldRunGooglePayTests()) { | ||
base.evaluate() | ||
} | ||
} else { | ||
base.evaluate() | ||
} | ||
} | ||
} | ||
} | ||
|
||
private fun Description.hasGooglePayTestAnnotation(): Boolean { | ||
for (annotation in annotations) { | ||
if (annotation is GooglePayTest) { | ||
return true | ||
} | ||
} | ||
|
||
return false | ||
} | ||
|
||
private fun shouldRunGooglePayTests(): Boolean { | ||
return InstrumentationRegistry.getArguments().getString(SHOULD_RUN_GOOGLE_PAY_TESTS_ARGUMENTS).toBoolean() | ||
} | ||
|
||
private companion object { | ||
const val SHOULD_RUN_GOOGLE_PAY_TESTS_ARGUMENTS = "com.stripe.android.should_run_google_pay_tests" | ||
} | ||
} |
This file contains 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