-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #134 from superwall/develop
1.2.0
- Loading branch information
Showing
171 changed files
with
3,940 additions
and
2,595 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
android-pixel-7: | ||
type: instrumentation | ||
use-orchestrator: true | ||
app: app/build/outputs/apk/debug/app-debug.apk | ||
test: app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk | ||
directories-to-pull: /sdcard/Download/ | ||
device: | ||
- model: panther | ||
version: 33 | ||
locale: 'en' | ||
orientation: portrait |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ | |
private_key.pepk | ||
upload-keystore.jks | ||
.env | ||
**/google-services.json |
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
Binary file not shown.
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,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:sharedUserId="com.superwall.superapp.uid"> | ||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> | ||
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/> | ||
<application android:requestLegacyExternalStorage="true" /> | ||
</manifest> |
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,28 @@ | ||
## Superwall integration & screenshot tests | ||
|
||
This module contains the Superwall integration tests and screenshot tests, using the [Dropshot](https://github.com/dropbox/dropshots) library | ||
for screenshot testing. The tests need to run on an Android device, emulator or a device lab (such as Firebase Test Lab). | ||
Note: currently screenshots are recorded only for Pixel 7, API 33. Devices with different resolutions might fail. | ||
|
||
### Running the tests | ||
|
||
To run the tests, just run `./gradlew :app:connectedCheck` from the root of the project. | ||
This will run the integration tests on your adb connected device or emulator. | ||
|
||
### Viewing tests results | ||
|
||
The tests results will be saved under `app/build/reports/androidTests/connected` folder in this directory. | ||
If there are failing tests, the screenshots will be saved under `app/build/outputs/androidTest-results/connected/debug` folder. | ||
|
||
### Recording the screenshots | ||
|
||
To record the screenshots, run `./gradlew :app:connectedCheck -Pdropshots.record` from the root of the project. | ||
This will record new screenshots on your current device. | ||
|
||
### Viewing the recorded screenshots | ||
|
||
To recorded screenshots are saved under `screenshots` folder in this directory. | ||
|
||
|
||
|
||
|
6 changes: 0 additions & 6 deletions
6
app/src/androidTest/java/com/example/superapp/AndroidManifest.xml
This file was deleted.
Oops, something went wrong.
166 changes: 166 additions & 0 deletions
166
app/src/androidTest/java/com/example/superapp/test/FlowScreenshotTestExecutor.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,166 @@ | ||
@file:Suppress("ktlint:standard:no-empty-file") | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import com.dropbox.dropshots.Dropshots | ||
import com.dropbox.dropshots.ThresholdValidator | ||
import com.example.superapp.utils.CustomComparator | ||
import com.example.superapp.utils.awaitUntilShimmerDisappears | ||
import com.example.superapp.utils.awaitUntilWebviewAppears | ||
import com.example.superapp.utils.delayFor | ||
import com.example.superapp.utils.screenshotFlow | ||
import com.example.superapp.utils.waitFor | ||
import com.superwall.sdk.Superwall | ||
import com.superwall.sdk.analytics.superwall.SuperwallEvent | ||
import com.superwall.superapp.test.UITestHandler | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.async | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import kotlin.time.Duration.Companion.milliseconds | ||
import kotlin.time.Duration.Companion.seconds | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class FlowScreenshotTestExecutor { | ||
@get:Rule | ||
val dropshots = | ||
Dropshots( | ||
resultValidator = ThresholdValidator(0.01f), | ||
imageComparator = CustomComparator(), | ||
) | ||
|
||
val mainScope = CoroutineScope(Dispatchers.Main) | ||
|
||
@Test | ||
fun test_paywall_reappers_with_video() = | ||
with(dropshots) { | ||
screenshotFlow(UITestHandler.test4Info) { | ||
step("first_paywall") { | ||
it.waitFor { it is SuperwallEvent.PaywallWebviewLoadComplete } | ||
awaitUntilShimmerDisappears() | ||
awaitUntilWebviewAppears() | ||
delayFor(500.milliseconds) | ||
} | ||
step("second_paywall") { | ||
awaitUntilWebviewAppears() | ||
delayFor(1.seconds) | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun test_paywall_presents_regardless_of_subscription() = | ||
with(dropshots) { | ||
screenshotFlow(UITestHandler.test9Info) { | ||
step("") { | ||
it.waitFor { it is SuperwallEvent.PaywallOpen } | ||
awaitUntilShimmerDisappears() | ||
awaitUntilWebviewAppears() | ||
delayFor(500.milliseconds) | ||
// We scroll a bit to display the button | ||
mainScope | ||
.async { | ||
Superwall.instance.paywallView | ||
?.webView | ||
?.scrollBy(0, 300) ?: kotlin.run { | ||
throw IllegalStateException("No viewcontroller found") | ||
} | ||
}.await() | ||
// We delay a bit to ensure the button is visible | ||
delayFor(100.milliseconds) | ||
// We scroll back to the top | ||
mainScope | ||
.async { | ||
Superwall.instance.paywallView | ||
?.webView | ||
?.scrollTo(0, 0) ?: kotlin.run { | ||
throw IllegalStateException("No viewcontroller found") | ||
} | ||
}.await() | ||
// We delay a bit to ensure scroll has finished | ||
delayFor(1.seconds) | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun test_paywall_reappears_after_dismissing() = | ||
with(dropshots) { | ||
screenshotFlow(UITestHandler.test11Info) { | ||
step { | ||
it.waitFor { it is SuperwallEvent.PaywallWebviewLoadComplete } | ||
awaitUntilShimmerDisappears() || awaitUntilWebviewAppears() | ||
delayFor(1.seconds) | ||
} | ||
step { | ||
it.waitFor { it is SuperwallEvent.PaywallOpen } | ||
awaitUntilWebviewAppears() | ||
delayFor(1.seconds) | ||
} | ||
step { | ||
it.waitFor { it is SuperwallEvent.PaywallOpen } | ||
awaitUntilWebviewAppears() | ||
delayFor(1.seconds) | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun test_paywall_calls_reset_after_present() = | ||
with(dropshots) { | ||
screenshotFlow(UITestHandler.test34Info) { | ||
step("") { | ||
it.waitFor { it is SuperwallEvent.PaywallWebviewLoadComplete } | ||
awaitUntilShimmerDisappears() | ||
awaitUntilWebviewAppears() | ||
} | ||
step { | ||
it.waitFor { it is SuperwallEvent.Reset } | ||
delayFor(100.milliseconds) | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun test_paywall_presents_then_dismisses_without_reappearing() = | ||
with(dropshots) { | ||
screenshotFlow(UITestHandler.test14Info) { | ||
step { | ||
it.waitFor { it is SuperwallEvent.PaywallWebviewLoadComplete } | ||
awaitUntilShimmerDisappears() | ||
awaitUntilWebviewAppears() | ||
delayFor(100.milliseconds) | ||
mainScope | ||
.async { | ||
// We scroll a bit to display the button | ||
Superwall.instance.paywallView | ||
?.webView | ||
?.apply { | ||
// Disable the scrollbar for the test | ||
// so its not visible in screenshots | ||
isVerticalScrollBarEnabled = false | ||
scrollTo(0, 300) | ||
} | ||
}.await() | ||
// We delay a bit to ensure the button is visible | ||
delayFor(100.milliseconds) | ||
// We scroll back to the top | ||
mainScope | ||
.async { | ||
Superwall.instance.paywallView | ||
?.webView | ||
?.apply { | ||
scrollTo(0, 0) | ||
} | ||
}.await() | ||
// We delay a bit to ensure scroll has finished | ||
delayFor(500.milliseconds) | ||
} | ||
|
||
step { | ||
delayFor(10.seconds) | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.