Reputation: 2108
I am having simple function as Below
fun openWebPage(url: String) {
val openURL = Intent(Intent.ACTION_VIEW)
openURL.data = Uri.parse(url)
startActivity(openURL)
}
How to test and verify that webpage is opened successfully using Robolectric?
Upvotes: 3
Views: 338
Reputation: 2108
This code snippet helped to capture that scenario
val shadow = Shadows.shadowOf(activity)
val exp_url = "www.google.com"
val intent = shadow.nextStartedActivity
val url = intent.data.toString()
assertEquals(exp_url,url)
Upvotes: 3