Skip to content

Commit 797efdb

Browse files
committed
using mActivityIntentsTestRule instead of finding the currently foregrounded Activity
1 parent 1ff41c2 commit 797efdb

File tree

2 files changed

+3
-24
lines changed

2 files changed

+3
-24
lines changed

app/src/androidTest/kotlin/org/wordpress/aztec/demo/pages/EditorPage.kt

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ class EditorPage : BasePage() {
5555
private var photoButton: ViewInteraction
5656
private var galleryButton: ViewInteraction
5757

58-
private var currentActivity: Activity?
59-
6058
override val trait: ViewInteraction
6159
get() = onView(withId(R.id.aztec))
6260

@@ -84,27 +82,6 @@ class EditorPage : BasePage() {
8482

8583
photoButton = onView(allOf(withId(android.R.id.title), withText("Photo from device")))
8684
galleryButton = onView(withId(R.id.media_bar_button_gallery))
87-
88-
currentActivity = null
89-
}
90-
91-
private fun getActivityInstance(): Activity? {
92-
getInstrumentation().runOnMainSync {
93-
val resumedActivities = ActivityLifecycleMonitorRegistry.getInstance().getActivitiesInStage(Stage.RESUMED)
94-
if (resumedActivities.iterator().hasNext()) {
95-
currentActivity = resumedActivities.iterator().next() as Activity
96-
}
97-
}
98-
99-
return currentActivity
100-
}
101-
102-
fun getAztecText(): AztecText? {
103-
return getActivityInstance()?.findViewById(R.id.aztec)
104-
}
105-
106-
fun getAztecSourceEditor(): SourceViewEditText? {
107-
return getActivityInstance()?.findViewById(R.id.source)
10885
}
10986

11087
fun tapTop(): EditorPage {

app/src/androidTest/kotlin/org/wordpress/aztec/demo/tests/GutenbergCompatTests.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,9 @@ class GutenbergCompatTests : BaseTest() {
312312

313313
val editorPage = EditorPage()
314314
val audioShortcodePlugin = AudioShortcodePlugin()
315-
editorPage.getAztecText()?.plugins?.add(audioShortcodePlugin)
315+
val aztecText = mActivityIntentsTestRule.activity.findViewById<AztecText>(R.id.aztec)
316+
aztecText.plugins?.add(audioShortcodePlugin)
317+
316318
// let's test the plugin works as expected, i.e. it preserves the Gutenberg block structure
317319
editorPage
318320
.toggleHtml()

0 commit comments

Comments
 (0)