You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have two test. when i run that individual it passes but it is failing when i run with test suite.
Test 1 (In Fragment)
This test opens the camera take picture using intent and passing result in onResultActivity and verifying that data is displayed in Image.
In intent we are using external storage to save data and retrieve URI using FileProvider.
@Test
fun clickingTakeAPhoto_loadsImageInTheForm() {
// arrange
val fragment = rule.launch { Fragment() }
// act
rule.scenario.onActivity {
fragment.startCamera()
}
val request = rule.scenario.withFragment<Fragment, ShadowActivity.IntentForResult> {
shadowOf(fragment.requireActivity()).nextStartedActivityForResult
}
val uri = request.intent.getParcelableExtra<Uri>(MediaStore.EXTRA_OUTPUT)
val source = javaClass.getResourceAsStream("test.jpg")
rule.scenario.recreate()
rule.scenario.onActivity { activity ->
with(shadowOf(activity)) {
shadowOf(activity.contentResolver).registerInputStream(uri, source)
receiveResult(request.intent, Activity.RESULT_OK, Intent())
}
}
// assert
with (LinkPage()) {
onView(this.uploadedImage).check(matches(DrawableMatchers.isDrawableDisplayed()))
}
}
Test 2 (In compose)
This test is verifying Intent(ACTION_VIEW) that on button click
it also uses FileProvider to get URI and storing data in Internal app storage (Cache).
@Test
fun openPDFViewer_Verify_ViewIntent() {
val repo = Repository(mock(), context)
Intents.init()
val expected = hasAction(Intent.ACTION_VIEW)
val file = repo.createUserFile(context, "test", javaClass.getResourceAsStream("/dummy.pdf")!!.readBytes())
rule.setContent {
OpenPDFViewer(file)
}
intended(allOf(hasAction(equalTo(Intent.ACTION_VIEW)), hasType("application/pdf")))
intended(expected)
Intents.release()
}
Steps to Reproduce
It is failing on this line when run test suite FileProvider.getUriForFile(context, package, file)
Did bit of the investigation inside FileProvide class and it is failing when getting multiple root paths and not able to verify path of the Test 2 file and throw Failed to find configured root that contains.
// Find the most-specific root path
Map.Entry<String, File> mostSpecific = null;
for (Map.Entry<String, File> root : mRoots.entrySet()) {
final String rootPath = root.getValue().getPath();
if (path.startsWith(rootPath) && (mostSpecific == null
|| rootPath.length() > mostSpecific.getValue().getPath().length())) {
mostSpecific = root;
}
}
if (mostSpecific == null) {
throw new IllegalArgumentException(
"Failed to find configured root that contains " + path);
}
Description
I have two test. when i run that individual it passes but it is failing when i run with test suite.
Test 1 (In Fragment)
This test opens the camera take picture using intent and passing result in
onResultActivity
and verifying that data is displayed in Image.In intent we are using external storage to save data and retrieve URI using FileProvider.
Test 2 (In compose)
This test is verifying
Intent(ACTION_VIEW)
that on button clickit also uses FileProvider to get URI and storing data in Internal app storage (Cache).
Steps to Reproduce
It is failing on this line when run test suite
FileProvider.getUriForFile(context, package, file)
Did bit of the investigation inside
FileProvide
class and it is failing when getting multiple root paths and not able to verify path of the Test 2 file and throwFailed to find configured root that contains
.Robolectric & Android Version
roboelectric =
4.9.2
compileSdkVersion =
34
minSdkVersion =
26
targetSdkVersion =
33
The text was updated successfully, but these errors were encountered: