Created
February 23, 2022 05:14
-
-
Save anangkur/40ae34959a590d82736106b3d016005b to your computer and use it in GitHub Desktop.
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
package com.anangkur.karumishotplayground | |
import android.util.Log | |
import com.karumi.shot.ScreenshotTest | |
import org.junit.Rule | |
import org.junit.Test | |
import androidx.test.ext.junit.rules.activityScenarioRule | |
class MainActivityScreenTest : ScreenshotTest { | |
@get:Rule | |
var activityScenarioRule = activityScenarioRule<MainActivity>() | |
@Test | |
fun activityTest() { | |
val activity = launchActivity() | |
compareScreenshot(activity) | |
} | |
// Hack needed until we fully support Activity Scenarios | |
private fun launchActivity(): MainActivity { | |
var activity: MainActivity? = null | |
activityScenarioRule.scenario.onActivity { | |
activity = it | |
} | |
while (activity == null) { | |
Log.d("MainActivityTest", "Waiting for activity to be initialized") | |
} | |
return activity!! | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment