From the course: Advanced Android Espresso Testing

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Dialogue fragment idling resource

Dialogue fragment idling resource - Android Tutorial

From the course: Advanced Android Espresso Testing

Start my 1-month free trial

Dialogue fragment idling resource

- [Instructor] To ask Espresso to wait for the dialog to dismiss, we are going to create an idling resource. Its definition for idle is that the dialog is not shown. Right-click on MainActivityTest on the project tree. Select New, Kotlin File/Class. We will call it DialogFragmentIdlingResource, class DialogFragmentIdlingResource: IdlingResource. This means we're extending IdlingResource. Put your cursor on line five and press Alt + Enter to implement members. Choose all of them. First, we will define the logic for isIdleNow. To check if our dialog is displayed, we need two things, FragmentManager and the dialog tag. We will add that as constructor parameters. On line five, add constructor parameters. First, we will add the FragmentManager, private val manager: FragmentManager. Choose the Support Library version. And then we also need a tag, private val tag of type String. Now that we have a FragmentManager, let's use it in isIdleNow. On line 12, delete the TODO. Replace it with return…

Contents