From 7c3dc7e7bc089576390f88d403d6c8f8d5b240da Mon Sep 17 00:00:00 2001 From: Harris Date: Tue, 31 Aug 2021 14:21:48 +1000 Subject: [PATCH] refactor: instrumentation for clipboard test was failing on smaller screen devices running the tests --- .../java/network/loki/messenger/HomeActivityTests.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/androidTest/java/network/loki/messenger/HomeActivityTests.kt b/app/src/androidTest/java/network/loki/messenger/HomeActivityTests.kt index 43652b09e9..46db01b13f 100644 --- a/app/src/androidTest/java/network/loki/messenger/HomeActivityTests.kt +++ b/app/src/androidTest/java/network/loki/messenger/HomeActivityTests.kt @@ -55,11 +55,15 @@ class HomeActivityTests { onView(newConversationButtonWithDrawable(R.drawable.ic_plus)).perform(ViewActions.click()) onView(newConversationButtonWithDrawable(R.drawable.ic_message)).perform(ViewActions.click()) // new chat + onView(withId(R.id.publicKeyEditText)).perform(ViewActions.closeSoftKeyboard()) onView(withId(R.id.copyButton)).perform(ViewActions.click()) val context = InstrumentationRegistry.getInstrumentation().targetContext - val clipboardManager = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager - val copied = clipboardManager.primaryClip!!.getItemAt(0).text - onView(withId(R.id.publicKeyEditText)).perform(ViewActions.typeText(copied.toString())) + lateinit var copied: String + InstrumentationRegistry.getInstrumentation().runOnMainSync { + val clipboardManager = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager + copied = clipboardManager.primaryClip!!.getItemAt(0).text.toString() + } + onView(withId(R.id.publicKeyEditText)).perform(ViewActions.typeText(copied)) onView(withId(R.id.createPrivateChatButton)).perform(ViewActions.click()) }