-
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 590dd8e
Showing
6 changed files
with
57 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 |
36 changes: 36 additions & 0 deletions
36
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,36 @@ | ||
package com.stripe.android.utils | ||
|
||
import com.stripe.android.paymentsheet.example.test.BuildConfig | ||
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 BuildConfig.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