-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Added test case for webview fragment
- Loading branch information
1 parent
9579ebd
commit 7536ed8
Showing
2 changed files
with
39 additions
and
0 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
38 changes: 38 additions & 0 deletions
38
app/src/androidTest/java/in/testpress/testpress/fragment/WebViewFragmentTest.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,38 @@ | ||
package `in`.testpress.testpress.fragment | ||
|
||
import android.os.Bundle | ||
import androidx.fragment.app.testing.FragmentScenario | ||
import androidx.test.espresso.Espresso | ||
import androidx.test.espresso.assertion.ViewAssertions | ||
import androidx.test.espresso.matcher.ViewMatchers | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import `in`.testpress.testpress.R | ||
import `in`.testpress.testpress.ui.fragments.WebViewFragment | ||
import androidx.fragment.app.testing.launchFragmentInContainer | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class WebViewFragmentTest { | ||
|
||
@Test | ||
fun testWebViewFragment() { | ||
val url = "https://www.google.com" | ||
val bundle = WebViewFragment.createArguments(url) | ||
|
||
// Launch the fragment | ||
val scenario: FragmentScenario<WebViewFragment> = launchFragmentInContainer( | ||
bundle, R.style.AppTheme | ||
) | ||
|
||
// Check that the web view is displayed | ||
Espresso.onView(ViewMatchers.withId(R.id.web_view)) | ||
.check(ViewAssertions.matches(ViewMatchers.isDisplayed())) | ||
} | ||
|
||
private fun WebViewFragment.Companion.createArguments(url: String): Bundle { | ||
return Bundle().apply { | ||
putString(URL_TO_OPEN, url) | ||
} | ||
} | ||
} |