title: Injecting and mocking 3rd party ActivityResultContract for testing purposes
body: <p>I've a <code>Fragment</code>. Inside of this <code>Fragment</code> I open a 3rd party <code>Activity</code> with <code>registerForActivityResult(CropImageContract())</code>.</p>
  <p>Now I want to test the <code>Fragment</code>. Especially I want to verify if the result of the 3rd party <code>Activity</code> is processed correctly.</p>
  <p>Since I have no access to the 3rd party <code>Activity</code> during the instrumentation test I thought of injecting and mocking the <code>CropImageContract()</code> but I don't know how. Are there any ideas or alternativ solutions?</p>
  <p>This is the <code>Fragment</code> I want to test:</p>
  <pre><code>class ProductDetailsFragment : Fragment() {
      private var mBinding: FragmentProductDetailsBinding? = null
  
      private val cropImageLauncher = registerForActivityResult(FakeCropImageContract()) { result -&gt;
          if (result.isSuccessful) {
              // use the returned uri
              val uriContent = result.uriContent
          } else {
              // an error occurred
              val exception = result.error
          }
      }
  
      override fun onCreateView(
          inflater: LayoutInflater,
          container: ViewGroup?,
          savedInstanceState: Bundle?
      ): View {
          mBinding = FragmentProductDetailsBinding.inflate(
              inflater,
              container,
              false
          )
          return mBinding!!.root
      }
  
      override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
          mBinding!!.contentProduct.productProductImageView.setOnClickListener { takePicture() }
      }
  
      private fun takePicture() {
          cropImageLauncher.launch()
      }
  }
  </code></pre>