Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .idea/runConfigurations/Run_all_UI_tests.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions .idea/runConfigurations/Run_depend_on_email_server_UI_tests.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 0 additions & 53 deletions .idea/runConfigurations/Run_depend_on_email_server_tests.xml

This file was deleted.

23 changes: 23 additions & 0 deletions .idea/runConfigurations/Run_no_email_server_UI_tests.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 0 additions & 53 deletions .idea/runConfigurations/Run_no_email_server_tests.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
import com.flowcrypt.email.R
import com.flowcrypt.email.TestConstants
import com.flowcrypt.email.api.email.model.AttachmentInfo
import com.flowcrypt.email.api.retrofit.response.model.OrgRules
import com.flowcrypt.email.database.entity.KeyEntity
import com.flowcrypt.email.model.KeyImportDetails
Expand All @@ -24,6 +25,7 @@ import com.flowcrypt.email.rules.RetryRule
import com.flowcrypt.email.rules.ScreenshotTestRule
import com.flowcrypt.email.ui.activity.base.BaseMessageDetailsActivityTest
import com.flowcrypt.email.util.AccountDaoManager
import com.flowcrypt.email.util.TestGeneralUtil
import org.hamcrest.Matchers.not
import org.junit.Rule
import org.junit.Test
Expand All @@ -40,11 +42,16 @@ import org.junit.runner.RunWith
@MediumTest
@RunWith(AndroidJUnit4::class)
class MessageDetailsActivityEkmTest : BaseMessageDetailsActivityTest() {
private val simpleAttInfo = TestGeneralUtil.getObjectFromJson(
"messages/attachments/simple_att.json",
AttachmentInfo::class.java
)
private val userWithOrgRules = AccountDaoManager.getUserWithOrgRules(
OrgRules(
flags = listOf(
OrgRules.DomainRule.NO_PRV_CREATE,
OrgRules.DomainRule.NO_PRV_BACKUP
OrgRules.DomainRule.NO_PRV_BACKUP,
OrgRules.DomainRule.RESTRICT_ANDROID_ATTACHMENT_HANDLING
),
customKeyserverUrl = null,
keyManagerUrl = "https://keymanagerurl.test",
Expand Down Expand Up @@ -86,4 +93,16 @@ class MessageDetailsActivityEkmTest : BaseMessageDetailsActivityTest() {
onView(withId(R.id.buttonSendOwnPublicKey))
.check(matches(withText(R.string.inform_sender)))
}

@Test
fun testVisibilityOfPreviewAttachmentButton() {
baseCheckWithAtt(
getMsgInfo(
"messages/info/standard_msg_info_plaintext_with_one_att.json",
"messages/mime/standard_msg_info_plaintext_with_one_att.txt", simpleAttInfo
), simpleAttInfo
)
onView(withId(R.id.imageButtonPreviewAtt))
.check(matches(isDisplayed()))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import android.app.Activity
import android.app.Instrumentation
import android.content.ComponentName
import android.text.format.DateUtils
import android.text.format.Formatter
import androidx.recyclerview.widget.RecyclerView
import androidx.test.espresso.Espresso.onData
import androidx.test.espresso.Espresso.onView
Expand All @@ -33,16 +32,13 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
import com.flowcrypt.email.R
import com.flowcrypt.email.TestConstants
import com.flowcrypt.email.api.email.EmailUtil
import com.flowcrypt.email.api.email.model.AttachmentInfo
import com.flowcrypt.email.api.email.model.IncomingMessageInfo
import com.flowcrypt.email.api.retrofit.response.model.DecryptErrorMsgBlock
import com.flowcrypt.email.api.retrofit.response.model.GenericMsgBlock
import com.flowcrypt.email.api.retrofit.response.model.PublicKeyMsgBlock
import com.flowcrypt.email.database.entity.MessageEntity
import com.flowcrypt.email.junit.annotations.NotReadyForCI
import com.flowcrypt.email.matchers.CustomMatchers
import com.flowcrypt.email.matchers.CustomMatchers.Companion.withDrawable
import com.flowcrypt.email.matchers.CustomMatchers.Companion.withEmptyRecyclerView
import com.flowcrypt.email.matchers.CustomMatchers.Companion.withPgpBadge
import com.flowcrypt.email.matchers.CustomMatchers.Companion.withRecyclerViewItemCount
Expand All @@ -54,14 +50,12 @@ import com.flowcrypt.email.rules.ScreenshotTestRule
import com.flowcrypt.email.ui.activity.base.BaseMessageDetailsActivityTest
import com.flowcrypt.email.ui.adapter.MsgDetailsRecyclerViewAdapter
import com.flowcrypt.email.ui.adapter.PgpBadgeListAdapter
import com.flowcrypt.email.util.DateTimeUtil
import com.flowcrypt.email.util.GeneralUtil
import com.flowcrypt.email.util.PrivateKeysManager
import com.flowcrypt.email.util.TestGeneralUtil
import org.hamcrest.Description
import org.hamcrest.Matcher
import org.hamcrest.Matchers.allOf
import org.hamcrest.Matchers.anyOf
import org.hamcrest.Matchers.anything
import org.hamcrest.Matchers.containsString
import org.hamcrest.Matchers.not
Expand Down Expand Up @@ -890,91 +884,6 @@ class MessageDetailsActivityTest : BaseMessageDetailsActivityTest() {
matchReplyButtons(details)
}

private fun baseCheckWithAtt(incomingMsgInfo: IncomingMessageInfo?, att: AttachmentInfo?) {
assertThat(incomingMsgInfo, notNullValue())

val msgEntity = incomingMsgInfo!!.msgEntity
launchActivity(msgEntity)
matchHeader(incomingMsgInfo)

checkWebViewText(incomingMsgInfo.text)
onView(withId(R.id.layoutAtt))
.check(matches(isDisplayed()))
matchAtt(att)
matchReplyButtons(msgEntity)
}

private fun matchHeader(incomingMsgInfo: IncomingMessageInfo?) {
val msgEntity = incomingMsgInfo?.msgEntity
requireNotNull(msgEntity)

onView(withId(R.id.textViewSenderAddress))
.check(matches(withText(EmailUtil.getFirstAddressString(msgEntity.from))))
onView(withId(R.id.textViewDate))
.check(
matches(
withText(
DateTimeUtil.formatSameDayTime(
getTargetContext(),
msgEntity.receivedDate
)
)
)
)
onView(withId(R.id.textViewSubject))
.check(matches(anyOf(withText(msgEntity.subject), withText(incomingMsgInfo.inlineSubject))))
}

private fun matchAtt(att: AttachmentInfo?) {
requireNotNull(att)
onView(withId(R.id.textViewAttachmentName))
.check(matches(withText(att.name)))
onView(withId(R.id.textViewAttSize))
.check(matches(withText(Formatter.formatFileSize(getContext(), att.encodedSize))))
}

private fun matchReplyButtons(msgEntity: MessageEntity) {
onView(withId(R.id.imageButtonReplyAll))
.check(matches(isDisplayed()))
onView(withId(R.id.layoutReplyButton))
.perform(scrollTo())
.check(matches(isDisplayed()))
onView(withId(R.id.layoutReplyAllButton))
.check(matches(isDisplayed()))
onView(withId(R.id.layoutFwdButton))
.check(matches(isDisplayed()))

if (msgEntity.isEncrypted == true) {
onView(withId(R.id.textViewReply))
.check(matches(withText(getResString(R.string.reply_encrypted))))
onView(withId(R.id.textViewReplyAll))
.check(matches(withText(getResString(R.string.reply_all_encrypted))))
onView(withId(R.id.textViewFwd))
.check(matches(withText(getResString(R.string.forward_encrypted))))

onView(withId(R.id.imageViewReply))
.check(matches(withDrawable(R.mipmap.ic_reply_green)))
onView(withId(R.id.imageViewReplyAll))
.check(matches(withDrawable(R.mipmap.ic_reply_all_green)))
onView(withId(R.id.imageViewFwd))
.check(matches(withDrawable(R.mipmap.ic_forward_green)))
} else {
onView(withId(R.id.textViewReply))
.check(matches(withText(getResString(R.string.reply))))
onView(withId(R.id.textViewReplyAll))
.check(matches(withText(getResString(R.string.reply_all))))
onView(withId(R.id.textViewFwd))
.check(matches(withText(getResString(R.string.forward))))

onView(withId(R.id.imageViewReply))
.check(matches(withDrawable(R.mipmap.ic_reply_red)))
onView(withId(R.id.imageViewReplyAll))
.check(matches(withDrawable(R.mipmap.ic_reply_all_red)))
onView(withId(R.id.imageViewFwd))
.check(matches(withDrawable(R.mipmap.ic_forward_red)))
}
}

private fun testTopReplyAction(title: String) {
testStandardMsgPlaintext()

Expand Down
Loading