diff --git a/app/libs/fusion-release.aar b/app/libs/fusion-release.aar index 038c53bf0..93212aafc 100644 Binary files a/app/libs/fusion-release.aar and b/app/libs/fusion-release.aar differ diff --git a/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/contacts/ContactsRobot.kt b/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/contacts/ContactsRobot.kt index b50d6ca89..9c0404776 100644 --- a/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/contacts/ContactsRobot.kt +++ b/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/contacts/ContactsRobot.kt @@ -36,8 +36,9 @@ import me.proton.fusion.utils.StringUtils.stringFromResource */ class ContactsRobot : Fusion { - private fun openAddContactsMenu() { + private fun openAddContactsMenu(): ContactsRobot { view.withId(R.id.fab_contacts_add_menu).click() + return this } fun addContact(): AddContactRobot { diff --git a/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/device/DeviceRobot.kt b/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/device/DeviceRobot.kt index 143012465..66758285e 100644 --- a/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/device/DeviceRobot.kt +++ b/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/device/DeviceRobot.kt @@ -25,39 +25,40 @@ import androidx.test.uiautomator.UiDevice import androidx.test.uiautomator.UiSelector import androidx.test.uiautomator.Until import me.proton.core.test.android.instrumented.utils.Shell +import me.proton.fusion.Fusion -open class DeviceRobot { +open class DeviceRobot: Fusion { fun clickHomeButton(): DeviceRobot { - device.pressHome() + uiDevice.pressHome() return this } fun clickRecentAppsButton(): DeviceRobot { - device.pressRecentApps() + uiDevice.pressRecentApps() return this } fun clickRecentAppView(): DeviceRobot { val recentAppSelector = UiSelector().resourceId("com.google.android.apps.nexuslauncher:id/overview_panel") - device.findObject(recentAppSelector).waitForExists(5000) - device.findObject(recentAppSelector).click() + uiDevice.findObject(recentAppSelector).waitForExists(5000) + uiDevice.findObject(recentAppSelector).click() return this } fun expandNotifications(): DeviceRobot { - device.openNotification() + uiDevice.openNotification() return this } fun clickNotificationByText(text: String): DeviceRobot { - device.wait(Until.findObject(By.text(text)), TIMEOUT_5S).click() + uiDevice.wait(Until.findObject(By.text(text)), TIMEOUT_5S).click() return this } fun clickShareDialogJustOnceButton(): DeviceRobot { - device.wait(Until.findObject(By.textContains("ProtonMail")), TIMEOUT_30S)?.click() - device.wait(Until.findObject(By.res("android:id/button_once")), TIMEOUT_30S).click() + byObject.containsText("Proton Mail").withTimeout(TIMEOUT_30S).click() + byObject.withResName("android:id/button_once").withTimeout(TIMEOUT_30S).click() return this } @@ -70,6 +71,6 @@ open class DeviceRobot { private const val TIMEOUT_5S = 5000L private const val TIMEOUT_30S = 30_000L - private val device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) + private val uiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) } } diff --git a/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/mailbox/MailboxRobotInterface.kt b/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/mailbox/MailboxRobotInterface.kt index b7942226a..2cf9798f3 100644 --- a/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/mailbox/MailboxRobotInterface.kt +++ b/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/mailbox/MailboxRobotInterface.kt @@ -22,15 +22,20 @@ package ch.protonmail.android.uitests.robots.mailbox import android.widget.ImageView import androidx.annotation.IdRes +import androidx.recyclerview.widget.RecyclerView import androidx.test.espresso.Espresso import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.ViewAction import androidx.test.espresso.ViewInteraction +import androidx.test.espresso.action.ViewActions import androidx.test.espresso.assertion.ViewAssertions.matches +import androidx.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition import androidx.test.espresso.matcher.ViewMatchers import androidx.test.espresso.matcher.ViewMatchers.isDisplayed import androidx.test.espresso.matcher.ViewMatchers.withId import ch.protonmail.android.R import ch.protonmail.android.uitests.robots.mailbox.MailboxMatchers.withFirstInstanceMessageSubject +import ch.protonmail.android.uitests.robots.mailbox.MailboxMatchers.withMessageSubject import ch.protonmail.android.uitests.robots.mailbox.MailboxMatchers.withMessageSubjectAndFlag import ch.protonmail.android.uitests.robots.mailbox.MailboxMatchers.withMessageSubjectAndRecipient import ch.protonmail.android.uitests.robots.mailbox.composer.ComposerRobot @@ -39,9 +44,12 @@ import ch.protonmail.android.uitests.robots.mailbox.messagedetail.MessageRobot import ch.protonmail.android.uitests.robots.mailbox.search.SearchRobot import ch.protonmail.android.uitests.robots.menu.MenuRobot import ch.protonmail.android.uitests.testsHelper.StringUtils +import ch.protonmail.android.uitests.testsHelper.UICustomViewActions.TIMEOUT_15S +import ch.protonmail.android.uitests.testsHelper.UICustomViewActions.TIMEOUT_30S import ch.protonmail.android.uitests.testsHelper.UICustomViewActions.TIMEOUT_60S import ch.protonmail.android.uitests.testsHelper.UICustomViewActions.saveMessageSubject import ch.protonmail.android.uitests.testsHelper.waitForCondition +import com.google.android.material.snackbar.SnackbarContentLayout import me.proton.fusion.Fusion import okhttp3.internal.wait @@ -65,11 +73,16 @@ interface MailboxRobotInterface : Fusion { return Any() } + fun deleteMessageWithSwipe(subject: String): Any { + recyclerView.onHolderItem(withMessageSubject(subject)).swipeRight() + return Any() + } + fun deleteMessageWithSwipe(position: Int): Any { - saveMessageSubjectAtPosition(messagesRecyclerViewId, position, (::SetDeleteWithSwipeMessage)()) recyclerView .withId(messagesRecyclerViewId) .onItemAtPosition(position) + .withTimeout(TIMEOUT_15S) .swipeRight() return Any() } @@ -145,10 +158,9 @@ interface MailboxRobotInterface : Fusion { view.withId(messageTitleTextViewId).withText(draftSubject).checkIsDisplayed() } - fun messageMovedToTrash(subject: String, date: String) { - val messageMovedToTrash = StringUtils.quantityStringFromResource(R.plurals.action_move_to_trash, 1) - view.withText(messageMovedToTrash).checkIsDisplayed() - view.withId(R.id.subject_text_view).withText(subject).checkDoesNotExist() + fun messageMovedToTrash(subject: String) { + view.withText(R.string.swipe_action_trash).waitForDisplayed().checkIsDisplayed() + view.withId(R.id.subject_text_view).withText(subject).waitUntilGone().checkDoesNotExist() } fun messageDeleted(subject: String) { @@ -157,7 +169,7 @@ interface MailboxRobotInterface : Fusion { fun multipleMessagesMovedToTrash(subjectMessageOne: String, subjectMessageTwo: String) { val messagesMovedToTrash = StringUtils.quantityStringFromResource(R.plurals.action_move_to_trash, 2) - view.withText(messagesMovedToTrash).checkIsDisplayed() + view.withText(messagesMovedToTrash).waitForDisplayed().checkIsDisplayed() view.withId(R.id.subject_text_view).withText(subjectMessageOne).checkDoesNotExist() view.withId(R.id.subject_text_view).withText(subjectMessageTwo).checkDoesNotExist() } @@ -168,9 +180,9 @@ interface MailboxRobotInterface : Fusion { } fun messageWithSubjectExists(subject: String) { - view.withText(subject).waitForDisplayed() recyclerView .withId(messagesRecyclerViewId) + .withTimeout(TIMEOUT_30S) .scrollToHolder(withFirstInstanceMessageSubject(subject)) } @@ -189,6 +201,7 @@ interface MailboxRobotInterface : Fusion { fun messageWithSubjectHasForwardedFlag(subject: String) { recyclerView .withId(messagesRecyclerViewId) + .withTimeout(TIMEOUT_30S) .scrollToHolder(withMessageSubjectAndFlag(subject, R.id.forward_image_view)) } diff --git a/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/mailbox/composer/ComposerRobot.kt b/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/mailbox/composer/ComposerRobot.kt index c72010420..20498da27 100644 --- a/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/mailbox/composer/ComposerRobot.kt +++ b/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/mailbox/composer/ComposerRobot.kt @@ -154,6 +154,7 @@ class ComposerRobot : Fusion { .setExpirationInDays(days) .attachments() .addImageCaptureAttachment(logoDrawable) + .navigateUpToComposer() .send() fun sendMessageEOAndExpiryTimeWithAttachmentAndConfirmation( @@ -171,6 +172,7 @@ class ComposerRobot : Fusion { .setExpirationInDays(days) .attachments() .addImageCaptureAttachment(logoDrawable) + .navigateUpToComposer() .sendWithNotSupportedExpiryConfirmation() .sendAnyway() @@ -178,27 +180,28 @@ class ComposerRobot : Fusion { composeMessage(to, subject, body) .attachments() .addImageCaptureAttachment(logoDrawable) + .navigateUpToComposer() .send() fun sendMessageWithFileAttachment(to: String, subject: String, body: String): InboxRobot = composeMessage(to, subject, body) .attachments() .addFileAttachment(logoDrawable) - .goBackToComposer() + .navigateUpToComposer() .send() fun sendMessageTwoImageCaptureAttachments(to: String, subject: String, body: String): InboxRobot = composeMessage(to, subject, body) .attachments() - .addTwoImageCaptureAttachments(logoDrawable, welcomeDrawable) + .addTwoImageCaptureAttachments(logoDrawable, driveDrawable) .send() fun addAndRemoveAttachmentAndSend(to: String, subject: String, body: String): InboxRobot = composeMessage(to, subject, body) .attachments() .addFileAttachment(logoDrawable) - .removeLastAttachment() - .goBackToComposer() + .removeAttachmentAtPosition(0) + .navigateUpToComposer() .send() fun draftToSubjectBody(to: String, messageSubject: String, body: String): ComposerRobot = @@ -218,6 +221,7 @@ class ComposerRobot : Fusion { return draftToSubjectBody(to, messageSubject, body) .attachments() .addImageCaptureAttachment(logoDrawable) + .navigateUpToComposer() } fun editBodyAndReply(newBody: String): MessageRobot = @@ -349,7 +353,7 @@ class ComposerRobot : Fusion { } private fun waitForConditionAndSend() { - view.withId(sendMessageId).waitForEnabled().checkEnabled().click() + view.withId(sendMessageId).waitForEnabled().checkIsEnabled().click() } /** @@ -359,7 +363,6 @@ class ComposerRobot : Fusion { fun sendAnyway(): InboxRobot { view.withId(ok).click() -// view.withText(R.string.message_sent).inRoot(rootView.withNotCurrentActivityDecorView()) return InboxRobot() } } @@ -391,8 +394,8 @@ class ComposerRobot : Fusion { const val sendMessageId = R.id.send_button const val messageBodyId = R.id.composer_message_body_edit_text const val subjectId = R.id.composer_subject_edit_text - const val logoDrawable = R.drawable.ic_launcher_foreground - const val welcomeDrawable = R.drawable.welcome + const val logoDrawable = R.drawable.ic_logo_proton + const val driveDrawable = R.drawable.ic_logo_drive const val addressSpinnerId = R.id.composer_from_spinner const val toRecipientsId = R.id.composer_to_recipient_view const val ok = R.id.ok diff --git a/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/mailbox/composer/MessageAttachmentsRobot.kt b/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/mailbox/composer/MessageAttachmentsRobot.kt index c0bd2df40..994b87aa4 100644 --- a/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/mailbox/composer/MessageAttachmentsRobot.kt +++ b/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/mailbox/composer/MessageAttachmentsRobot.kt @@ -19,8 +19,10 @@ package ch.protonmail.android.uitests.robots.mailbox.composer import androidx.annotation.IdRes +import androidx.appcompat.widget.AppCompatImageButton import ch.protonmail.android.R import ch.protonmail.android.uitests.testsHelper.MockAddAttachmentIntent +import ch.protonmail.android.uitests.testsHelper.TestData import me.proton.fusion.Fusion /** @@ -28,7 +30,7 @@ import me.proton.fusion.Fusion */ open class MessageAttachmentsRobot : Fusion { - fun addImageCaptureAttachment(@IdRes drawable: Int): ComposerRobot = + fun addImageCaptureAttachment(@IdRes drawable: Int): MessageAttachmentsRobot = mockCameraImageCapture(drawable) fun addTwoImageCaptureAttachments( @@ -36,35 +38,54 @@ open class MessageAttachmentsRobot : Fusion { @IdRes secondDrawable: Int ): ComposerRobot = mockCameraImageCapture(firstDrawable) - .attachments() .mockCameraImageCapture(secondDrawable) + .navigateUpToComposer() fun addFileAttachment(@IdRes drawable: Int): MessageAttachmentsRobot { + intent.init() mockFileAttachment(drawable) + intent.release() return this } - fun removeLastAttachment(): MessageAttachmentsRobot { + fun removeAttachmentAtPosition(position: Int): MessageAttachmentsRobot = + waitForLoadingToBeNotVisible().removeAttachment(position) + + private fun removeAttachment(position: Int): MessageAttachmentsRobot { + listView + .onListItem() + .inAdapterView(view.withId(R.id.attachment_list)) + .atPosition(position) + .onChild(view.withId(R.id.remove)).click() return this } - fun goBackToComposer(): ComposerRobot { + private fun waitForLoadingToBeNotVisible(): MessageAttachmentsRobot { + view.withText(R.string.sync_attachments).waitForNotDisplayed() + return this + } + + fun navigateUpToComposer(): ComposerRobot { + view.instanceOf(AppCompatImageButton::class.java).hasParent(view.withId(R.id.toolbar)).click() return ComposerRobot() } - private fun mockCameraImageCapture(@IdRes drawableId: Int): ComposerRobot { - view.withId(takePhotoIconId).checkIsDisplayed() + private fun mockCameraImageCapture(@IdRes drawableId: Int): MessageAttachmentsRobot { + intent.init() + view.withId(takePhotoIconId).waitForDisplayed() MockAddAttachmentIntent.mockCameraImageCapture(takePhotoIconId, drawableId) - return ComposerRobot() + intent.release() + return this } private fun mockFileAttachment(@IdRes drawable: Int): ComposerRobot { view.withId(addAttachmentIconId).checkIsDisplayed() - MockAddAttachmentIntent.mockChooseAttachment(addAttachmentIconId, drawable) + MockAddAttachmentIntent.mockChooseAttachment(addAttachmentIconId, TestData.pngFile) return ComposerRobot() } companion object { + private const val takePhotoIconId = R.id.take_photo private const val addAttachmentIconId = R.id.attach_file } diff --git a/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/mailbox/messagedetail/MessageRobot.kt b/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/mailbox/messagedetail/MessageRobot.kt index ee46a3f7f..e62893e49 100644 --- a/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/mailbox/messagedetail/MessageRobot.kt +++ b/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/mailbox/messagedetail/MessageRobot.kt @@ -39,6 +39,7 @@ import ch.protonmail.android.uitests.robots.mailbox.trash.TrashRobot import ch.protonmail.android.uitests.testsHelper.StringUtils import ch.protonmail.android.uitests.testsHelper.TestData.pgpEncryptedTextDecrypted import ch.protonmail.android.uitests.testsHelper.TestData.pgpSignedTextDecrypted +import ch.protonmail.android.uitests.testsHelper.UICustomViewActions.TIMEOUT_30S import me.proton.fusion.Fusion import org.hamcrest.CoreMatchers.`is` @@ -80,13 +81,12 @@ class MessageRobot : Fusion { } fun openActionSheet(): MessageActionSheet { - view.withId(R.id.messageWebViewContainer).checkIsDisplayed() + view.withId(R.id.messageWebViewContainer).withTimeout(TIMEOUT_30S).waitForDisplayed() view.withId(R.id.moreActionImageButton).click() return MessageActionSheet() } fun navigateUpToSearch(): SearchRobot { - view.withId(R.id.messageWebViewContainer).checkIsDisplayed() view.instanceOf(AppCompatImageButton::class.java).hasParent(view.withId(R.id.toolbar)).click() return SearchRobot() } @@ -268,18 +268,20 @@ class MessageRobot : Fusion { } fun messageContainsAttachment() { - view.withId(R.id.attachmentsView).checkIsDisplayed() + view.withId(R.id.attachmentsView).waitForDisplayed().checkIsDisplayed() } fun messageContainsOneAttachment() { - val oneAttachmentString = StringUtils.quantityStringFromResource(R.plurals.attachments_number, 1) - view.withId(R.id.attachments_text_view).containsText(oneAttachmentString).checkIsDisplayed() - view.withId(R.id.attachment_name_text_view).checkIsDisplayed() + val oneAttachmentString = String.format(StringUtils.quantityStringFromResource(R.plurals.attachments_number, 1), 1) + view + .withId(R.id.attachments_text_view) + .containsText(oneAttachmentString) + .waitForDisplayed() + .checkIsDisplayed() } fun messageContainsTwoAttachments() { - val twoAttachmentString = StringUtils.quantityStringFromResource(R.plurals.attachments_number, 2) - .replace("%d", "2") + val twoAttachmentString = String.format(StringUtils.quantityStringFromResource(R.plurals.attachments_number, 2), 2) view.withId(R.id.attachments_text_view).containsText(twoAttachmentString).checkIsDisplayed() } diff --git a/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/mailbox/search/SearchRobot.kt b/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/mailbox/search/SearchRobot.kt index 0a5b2be69..51e2916f5 100644 --- a/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/mailbox/search/SearchRobot.kt +++ b/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/mailbox/search/SearchRobot.kt @@ -27,6 +27,7 @@ import ch.protonmail.android.uitests.robots.mailbox.composer.ComposerRobot import ch.protonmail.android.uitests.robots.mailbox.inbox.InboxRobot import ch.protonmail.android.uitests.robots.mailbox.messagedetail.MessageRobot import ch.protonmail.android.uitests.testsHelper.TestData +import ch.protonmail.android.uitests.testsHelper.UICustomViewActions.TIMEOUT_15S import me.proton.fusion.Fusion /** @@ -65,7 +66,7 @@ class SearchRobot : Fusion { fun clickSearchedMessageBySubjectPart(subject: String): MessageRobot { recyclerView .withId(messagesRecyclerViewId) -// .waitUntilPopulated() + .withTimeout(TIMEOUT_15S) .onHolderItem(withMessageSubjectContaining(subject)) .click() return MessageRobot() diff --git a/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/mailbox/sent/SentRobot.kt b/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/mailbox/sent/SentRobot.kt index 6a27ea71f..253127276 100644 --- a/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/mailbox/sent/SentRobot.kt +++ b/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/mailbox/sent/SentRobot.kt @@ -43,6 +43,11 @@ class SentRobot : MailboxRobotInterface, Fusion { return SelectionStateRobot() } + override fun deleteMessageWithSwipe(subject: String): SentRobot { + super.deleteMessageWithSwipe(subject) + return this + } + override fun deleteMessageWithSwipe(position: Int): SentRobot { super.deleteMessageWithSwipe(position) return this diff --git a/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/mailbox/spam/SpamRobot.kt b/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/mailbox/spam/SpamRobot.kt index d41442a39..5e9a8e6a0 100644 --- a/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/mailbox/spam/SpamRobot.kt +++ b/app/src/uiTest/kotlin/ch/protonmail/android/uitests/robots/mailbox/spam/SpamRobot.kt @@ -40,7 +40,10 @@ open class SpamRobot : MailboxRobotInterface, Fusion { } fun moreOptions(): SpamRobot { - view.instanceOf(AppCompatImageView::class.java).hasParent(view.instanceOf(ActionMenuView::class.java)).click() + view + .instanceOf(AppCompatImageView::class.java) + .hasParent(view.instanceOf(ActionMenuView::class.java)) + .click() return this } } diff --git a/app/src/uiTest/kotlin/ch/protonmail/android/uitests/tests/composer/AttachmentsTests.kt b/app/src/uiTest/kotlin/ch/protonmail/android/uitests/tests/composer/AttachmentsTests.kt index 24107954d..47370ffa8 100644 --- a/app/src/uiTest/kotlin/ch/protonmail/android/uitests/tests/composer/AttachmentsTests.kt +++ b/app/src/uiTest/kotlin/ch/protonmail/android/uitests/tests/composer/AttachmentsTests.kt @@ -43,12 +43,13 @@ import ch.protonmail.android.uitests.testsHelper.TestUser.onePassUser import ch.protonmail.android.uitests.testsHelper.annotations.SmokeTest import ch.protonmail.android.uitests.testsHelper.annotations.TestId import me.proton.core.test.android.instrumented.utils.FileUtils +import me.proton.fusion.Fusion import org.hamcrest.CoreMatchers.not import org.junit.experimental.categories.Category import kotlin.test.BeforeTest import kotlin.test.Test -class AttachmentsTests : BaseTest() { +class AttachmentsTests : BaseTest(), Fusion { private val loginRobot = LoginMailRobot() private val composeRobot = ComposerRobot() @@ -62,8 +63,6 @@ class AttachmentsTests : BaseTest() { super.setUp() subject = TestData.messageSubject body = TestData.messageBody - intending(not(isInternal())) - .respondWith(Instrumentation.ActivityResult(Activity.RESULT_OK, null)) } @TestId("53707") @@ -72,7 +71,6 @@ class AttachmentsTests : BaseTest() { val messageSubject = "One inline image and one attachment" loginRobot .loginOnePassUser() - .searchBar() .searchMessageText(messageSubject) .clickSearchedMessageBySubject(messageSubject) @@ -86,7 +84,6 @@ class AttachmentsTests : BaseTest() { val to = internalEmailTrustedKeys.email loginRobot .loginOnePassUser() - .mailboxLayoutShown() deviceRobot @@ -307,7 +304,7 @@ class AttachmentsTests : BaseTest() { .sent() .clickMessageBySubject(subject) .expandAttachments() - .verify { messageContainsOneAttachment() } + .verify { messageContainsTwoAttachments() } } @TestId("1485") diff --git a/app/src/uiTest/kotlin/ch/protonmail/android/uitests/tests/composer/ForwardMessageTests.kt b/app/src/uiTest/kotlin/ch/protonmail/android/uitests/tests/composer/ForwardMessageTests.kt index 4f56c7abe..900f51a8d 100644 --- a/app/src/uiTest/kotlin/ch/protonmail/android/uitests/tests/composer/ForwardMessageTests.kt +++ b/app/src/uiTest/kotlin/ch/protonmail/android/uitests/tests/composer/ForwardMessageTests.kt @@ -19,6 +19,7 @@ package ch.protonmail.android.uitests.tests.composer import ch.protonmail.android.uitests.robots.login.LoginMailRobot +import ch.protonmail.android.uitests.robots.mailbox.sent.SentRobot import ch.protonmail.android.uitests.tests.BaseTest import ch.protonmail.android.uitests.testsHelper.TestData import ch.protonmail.android.uitests.testsHelper.TestData.fwSubject @@ -34,6 +35,7 @@ import kotlin.test.Test class ForwardMessageTests : BaseTest() { private val loginRobot = LoginMailRobot() + private val sentRobot = SentRobot() private lateinit var subject: String private lateinit var body: String @@ -60,13 +62,14 @@ class ForwardMessageTests : BaseTest() { .forwardMessage(to, body) .navigateUpToSent() .refreshMessageList() - .verify { - messageWithSubjectExists(fwSubject(subject)) - messageWithSubjectHasForwardedFlag(subject) - } + .verify { messageWithSubjectExists(fwSubject(subject)) } + sentRobot + .refreshMessageList() + .verify { messageWithSubjectHasForwardedFlag(subject) } } @TestId("1950") + @Category(SmokeTest::class) @Test fun forwardMessageWithAttachment() { val to = internalEmailTrustedKeys.email @@ -83,7 +86,6 @@ class ForwardMessageTests : BaseTest() { .navigateUpToSent() .refreshMessageList() .clickMessageBySubject(fwSubject(subject)) - .expandAttachments() .verify { messageContainsOneAttachment() } } @@ -107,7 +109,6 @@ class ForwardMessageTests : BaseTest() { .sent() .refreshMessageList() .clickMessageBySubject(updatedSubject(subject)) - .expandAttachments() .verify { messageContainsOneAttachment() } } @@ -126,12 +127,11 @@ class ForwardMessageTests : BaseTest() { .openActionSheet() .forward() .attachments() - .removeLastAttachment() - .goBackToComposer() + .removeAttachmentAtPosition(1) + .navigateUpToComposer() .forwardMessage(to, body) .navigateUpToSent() .clickMessageBySubject(fwSubject(subject)) - .expandAttachments() .verify { messageContainsOneAttachment() } } @@ -152,7 +152,6 @@ class ForwardMessageTests : BaseTest() { .forwardMessage(to, body) .navigateUpToSent() .clickMessageBySubject(fwSubject(subject)) - .expandAttachments() .verify { messageContainsOneAttachment() } } } diff --git a/app/src/uiTest/kotlin/ch/protonmail/android/uitests/tests/composer/ReplyToMessageTests.kt b/app/src/uiTest/kotlin/ch/protonmail/android/uitests/tests/composer/ReplyToMessageTests.kt index 65a4d7c1e..60a777aa2 100644 --- a/app/src/uiTest/kotlin/ch/protonmail/android/uitests/tests/composer/ReplyToMessageTests.kt +++ b/app/src/uiTest/kotlin/ch/protonmail/android/uitests/tests/composer/ReplyToMessageTests.kt @@ -19,6 +19,7 @@ package ch.protonmail.android.uitests.tests.composer import ch.protonmail.android.uitests.robots.login.LoginMailRobot +import ch.protonmail.android.uitests.robots.mailbox.sent.SentRobot import ch.protonmail.android.uitests.tests.BaseTest import ch.protonmail.android.uitests.testsHelper.TestData import ch.protonmail.android.uitests.testsHelper.TestData.reSubject @@ -32,6 +33,7 @@ import kotlin.test.Test class ReplyToMessageTests : BaseTest() { private val loginRobot = LoginMailRobot() + private val sentRobot = SentRobot() private lateinit var subject: String private lateinit var body: String @@ -58,12 +60,11 @@ class ReplyToMessageTests : BaseTest() { .editBodyAndReply("Reply") .navigateUpToSent() .refreshMessageList() - .verify { - messageWithSubjectExists(reSubject(subject)) - } + .verify { messageWithSubjectExists(reSubject(subject)) } } @TestId("1946") + @Category(SmokeTest::class) @Test fun replyMessageWithAttachment() { val to = internalEmailTrustedKeys.email @@ -78,7 +79,8 @@ class ReplyToMessageTests : BaseTest() { .reply() .editBodyAndReply("Robot Reply With Attachment") .navigateUpToSent() - .verify { messageWithSubjectExists(TestData.reSubject(subject)) } + .refreshMessageList() + .verify { messageWithSubjectExists(reSubject(subject)) } } @TestId("21093") @@ -96,9 +98,10 @@ class ReplyToMessageTests : BaseTest() { .replyAll() .editBodyAndReply("Robot ReplyAll") .navigateUpToSent() - .verify { - messageWithSubjectExists(TestData.reSubject(subject)) - messageWithSubjectHasRepliedAllFlag(subject) - } + .refreshMessageList() + .verify { messageWithSubjectExists(reSubject(subject)) } + sentRobot + .refreshMessageList() + .verify { messageWithSubjectHasRepliedAllFlag(subject) } } } diff --git a/app/src/uiTest/kotlin/ch/protonmail/android/uitests/tests/composer/SendNewMessageTests.kt b/app/src/uiTest/kotlin/ch/protonmail/android/uitests/tests/composer/SendNewMessageTests.kt index 4b6c8c096..046450bc8 100644 --- a/app/src/uiTest/kotlin/ch/protonmail/android/uitests/tests/composer/SendNewMessageTests.kt +++ b/app/src/uiTest/kotlin/ch/protonmail/android/uitests/tests/composer/SendNewMessageTests.kt @@ -20,6 +20,7 @@ package ch.protonmail.android.uitests.tests.composer import ch.protonmail.android.uitests.robots.login.LoginMailRobot import ch.protonmail.android.uitests.tests.BaseTest +import ch.protonmail.android.uitests.tests.suites.RegressionSuite import ch.protonmail.android.uitests.testsHelper.TestData import ch.protonmail.android.uitests.testsHelper.TestData.editedPassword import ch.protonmail.android.uitests.testsHelper.TestData.editedPasswordHint diff --git a/app/src/uiTest/kotlin/ch/protonmail/android/uitests/tests/drafts/DraftsTests.kt b/app/src/uiTest/kotlin/ch/protonmail/android/uitests/tests/drafts/DraftsTests.kt index f6bdf3ff7..66dfe39fe 100644 --- a/app/src/uiTest/kotlin/ch/protonmail/android/uitests/tests/drafts/DraftsTests.kt +++ b/app/src/uiTest/kotlin/ch/protonmail/android/uitests/tests/drafts/DraftsTests.kt @@ -176,7 +176,7 @@ class DraftsTests : BaseTest() { .clickDraftBySubject(subject) .attachments() .addFileAttachment(welcomeDrawable) - .goBackToComposer() + .navigateUpToComposer() .confirmDraftSavingFromDrafts() .refreshMessageList() .clickMessageBySubject(subject) @@ -267,7 +267,7 @@ class DraftsTests : BaseTest() { .clickDraftBySubject(subject) .attachments() .addFileAttachment(welcomeDrawable) - .goBackToComposer() + .navigateUpToComposer() .draftSubjectBody(subjectEditOne, bodyEditOne) .clickUpButton() .confirmDraftSavingFromDrafts() @@ -306,15 +306,15 @@ class DraftsTests : BaseTest() { .refreshMessageList() .clickDraftBySubject(fwSubject(subject)) .attachments() - .removeLastAttachment() - .goBackToComposer() + .removeAttachmentAtPosition(0) + .navigateUpToComposer() .clickUpButton() .confirmDraftSavingFromDrafts() .refreshMessageList() .clickDraftBySubject(fwSubject(subject)) .attachments() .addFileAttachment(welcomeDrawable) - .goBackToComposer() + .navigateUpToComposer() .updateSubject(subject) .send() .menuDrawer() diff --git a/app/src/uiTest/kotlin/ch/protonmail/android/uitests/tests/settings/SwipeGesturesTests.kt b/app/src/uiTest/kotlin/ch/protonmail/android/uitests/tests/settings/SwipeGesturesTests.kt index 3cc88569b..ac62f5b9b 100644 --- a/app/src/uiTest/kotlin/ch/protonmail/android/uitests/tests/settings/SwipeGesturesTests.kt +++ b/app/src/uiTest/kotlin/ch/protonmail/android/uitests/tests/settings/SwipeGesturesTests.kt @@ -24,6 +24,7 @@ import ch.protonmail.android.uitests.robots.mailbox.MailboxRobotInterface.Compan import ch.protonmail.android.uitests.robots.mailbox.MailboxRobotInterface.Companion.deletedMessageSubject import ch.protonmail.android.uitests.robots.mailbox.MailboxRobotInterface.Companion.swipeLeftMessageSubject import ch.protonmail.android.uitests.tests.BaseTest +import ch.protonmail.android.uitests.testsHelper.TestData import ch.protonmail.android.uitests.testsHelper.TestUser.onePassUser import ch.protonmail.android.uitests.testsHelper.TestUser.twoPassUser import ch.protonmail.android.uitests.testsHelper.annotations.SmokeTest @@ -39,13 +40,18 @@ class SwipeGesturesTests : BaseTest() { @Category(SmokeTest::class) @Test fun deleteMessageWithSwipe() { + val subject = TestData.messageSubject + val body = TestData.messageBody loginRobot .loginOnePassUser() + .compose() + .sendMessage(twoPassUser.email, subject, body) .menuDrawer() .sent() - .deleteMessageWithSwipe(1) + .refreshMessageList() + .deleteMessageWithSwipe(0) .verify { - messageMovedToTrash(deletedMessageSubject, deletedMessageDate) + messageMovedToTrash(subject) } } diff --git a/app/src/uiTest/kotlin/ch/protonmail/android/uitests/testsHelper/MockAddAttachmentIntent.kt b/app/src/uiTest/kotlin/ch/protonmail/android/uitests/testsHelper/MockAddAttachmentIntent.kt index 725cfdb8c..deed62e7b 100644 --- a/app/src/uiTest/kotlin/ch/protonmail/android/uitests/testsHelper/MockAddAttachmentIntent.kt +++ b/app/src/uiTest/kotlin/ch/protonmail/android/uitests/testsHelper/MockAddAttachmentIntent.kt @@ -28,24 +28,20 @@ import android.os.Bundle import android.os.Parcelable import android.provider.MediaStore import androidx.annotation.IdRes -import androidx.test.espresso.intent.Intents -import androidx.test.espresso.intent.matcher.IntentMatchers import androidx.test.platform.app.InstrumentationRegistry import androidx.test.runner.intent.IntentCallback import androidx.test.runner.intent.IntentMonitorRegistry -import me.proton.core.test.android.instrumented.Robot +import me.proton.fusion.Fusion import org.jetbrains.annotations.Contract import java.io.File import java.io.FileOutputStream import java.io.IOException import java.util.ArrayList -object MockAddAttachmentIntent : Robot { - private fun createImage(@IdRes resourceId: Int) { - val icon = BitmapFactory.decodeResource( - InstrumentationRegistry.getInstrumentation().targetContext.resources, - resourceId - ) +object MockAddAttachmentIntent : Fusion { + private fun createImage(assetsFilename: String) { + val icon = BitmapFactory + .decodeStream(InstrumentationRegistry.getInstrumentation().context.assets.open(assetsFilename)) val file = File(InstrumentationRegistry.getInstrumentation() .targetContext.externalCacheDir, "pickImageResult.jpeg") try { @@ -72,16 +68,16 @@ object MockAddAttachmentIntent : Robot { return ActivityResult(Activity.RESULT_OK, resultData) } - fun mockChooseAttachment(@IdRes objectId: Int, @IdRes imageResourceId: Int) { - createImage(imageResourceId) + fun mockChooseAttachment(@IdRes objectId: Int, assetsFilename: String) { + createImage(assetsFilename) val result = pickImageResult() - Intents.intending(IntentMatchers.hasAction(Intent.ACTION_GET_CONTENT)).respondWith(result) + intent.hasAction(Intent.ACTION_CHOOSER).respondWith(result) view.withId(objectId).click() } fun mockCameraImageCapture(@IdRes objectId: Int, @IdRes imageResourceId: Int) { val result = ActivityResult(Activity.RESULT_OK, null) - Intents.intending(IntentMatchers.hasAction(MediaStore.ACTION_IMAGE_CAPTURE)).respondWith(result) + intent.hasAction(MediaStore.ACTION_IMAGE_CAPTURE).respondWith(result) val cameraCallback = intentCallback(imageResourceId) IntentMonitorRegistry.getInstance().addIntentCallback(cameraCallback) view.withId(objectId).click()