@@ -89,38 +89,39 @@ class FindAndReplaceDialogFragmentTest : RobolectricTest() {
8989 runTest {
9090 val note = createFindReplaceTestNote(" A" , " kart" , " kilogram" )
9191 val file = IdsFile (targetContext.cacheDir, listOf (note.id))
92- val scenario =
93- FragmentScenario .launch(
92+ FragmentScenario
93+ .launch(
9494 fragmentClass = FindAndReplaceDialogFragment ::class .java,
9595 fragmentArgs = bundleOf(FindAndReplaceDialogFragment .ARG_IDS to file),
9696 themeResId = R .style.Theme_Light ,
97- )
98- scenario.onFragment { fragment ->
99- advanceUntilIdle()
100- onView(withId(R .id.only_selected_notes_check_box))
101- .inRoot(isDialog())
102- .check(matches(isEnabled()))
103- onView(withId(R .id.only_selected_notes_check_box))
104- .inRoot(isDialog())
105- .check(matches(isChecked()))
106- // 2 default field options + 2 fields from the only note selected
107- val allTargets =
108- targetContext.getDefaultTargets() + listOf (" Afield0" , " Afield1" )
109- assertThat(fragment.adapter.items, equalTo(allTargets))
110- }
111- scenario.recreate()
112- scenario.onFragment { fragment ->
113- advanceUntilIdle()
114- onView(withId(R .id.only_selected_notes_check_box))
115- .inRoot(isDialog())
116- .check(matches(isEnabled()))
117- onView(withId(R .id.only_selected_notes_check_box))
118- .inRoot(isDialog())
119- .check(matches(isChecked()))
120- // check that the target list from before the recreate call wasn't reset
121- val allTargets = targetContext.getDefaultTargets() + listOf (" Afield0" , " Afield1" )
122- assertThat(fragment.adapter.items, equalTo(allTargets))
123- }
97+ ).use { scenario ->
98+ scenario.onFragment { fragment ->
99+ advanceUntilIdle()
100+ onView(withId(R .id.only_selected_notes_check_box))
101+ .inRoot(isDialog())
102+ .check(matches(isEnabled()))
103+ onView(withId(R .id.only_selected_notes_check_box))
104+ .inRoot(isDialog())
105+ .check(matches(isChecked()))
106+ // 2 default field options + 2 fields from the only note selected
107+ val allTargets =
108+ targetContext.getDefaultTargets() + listOf (" Afield0" , " Afield1" )
109+ assertThat(fragment.adapter.items, equalTo(allTargets))
110+ }
111+ scenario.recreate()
112+ scenario.onFragment { fragment ->
113+ advanceUntilIdle()
114+ onView(withId(R .id.only_selected_notes_check_box))
115+ .inRoot(isDialog())
116+ .check(matches(isEnabled()))
117+ onView(withId(R .id.only_selected_notes_check_box))
118+ .inRoot(isDialog())
119+ .check(matches(isChecked()))
120+ // check that the target list from before the recreate call wasn't reset
121+ val allTargets = targetContext.getDefaultTargets() + listOf (" Afield0" , " Afield1" )
122+ assertThat(fragment.adapter.items, equalTo(allTargets))
123+ }
124+ }
124125 }
125126
126127 private fun onFindReplaceFragment (
@@ -133,7 +134,7 @@ class FindAndReplaceDialogFragmentTest : RobolectricTest() {
133134 fragmentClass = FindAndReplaceDialogFragment ::class .java,
134135 fragmentArgs = bundleOf(FindAndReplaceDialogFragment .ARG_IDS to file),
135136 themeResId = R .style.Theme_Light ,
136- ).onFragment { fragment -> fragment.action() }
137+ ).use { scenario -> scenario. onFragment { fragment -> fragment.action() } }
137138 }
138139
139140 /* *
0 commit comments