Skip to content

Commit

Permalink
Issue 1108 Prepare 1.1.6 (#1142)
Browse files Browse the repository at this point in the history
* Modified SearchMessagesActivityTest.| #1116

* Fixed JUnit tests.| #1116

* Fixed ParcelableTest. Modified Parcelable realization for OutgoingMessageInfo.| #1116
  • Loading branch information
DenBond7 authored Apr 1, 2021
1 parent a40b479 commit 04e591d
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class SearchMessagesActivityTest : BaseEmailListActivityTest() {

@Before
fun waitData() {
// Need to improve this code after espresso updates
//todo-denbond7 Need to improve this code after espresso updates
Thread.sleep(2000)
}

Expand All @@ -98,6 +98,8 @@ class SearchMessagesActivityTest : BaseEmailListActivityTest() {
onView(isAssignableFrom(EditText::class.java))
.check(matches(withText(DEFAULT_QUERY_TEXT)))
.perform(clearText(), typeText(SECOND_QUERY_TEXT), pressImeActionButton())
//todo-denbond7 Need to improve this code
Thread.sleep(2000)
onView(withId(R.id.rVMsgs))
.check(matches(withRecyclerViewItemCount(2))).check(matches(isDisplayed()))
}
Expand All @@ -110,6 +112,8 @@ class SearchMessagesActivityTest : BaseEmailListActivityTest() {
onView(isAssignableFrom(EditText::class.java))
.check(matches(withText(DEFAULT_QUERY_TEXT)))
.perform(clearText(), typeText(QUERY_TEXT_FOR_SUBJECT_BODY_FROM), pressImeActionButton())
//todo-denbond7 Need to improve this code
Thread.sleep(2000)
onView(withId(R.id.rVMsgs))
.check(matches(withRecyclerViewItemCount(4))).check(matches(isDisplayed()))
}
Expand Down Expand Up @@ -137,8 +141,13 @@ class SearchMessagesActivityTest : BaseEmailListActivityTest() {
.check(matches(isDisplayed()))
.perform(click())
onView(isAssignableFrom(EditText::class.java))
.perform(clearText(), typeText("The string with no results"), pressImeActionButton())
onView(withId(R.id.emptyView))
.perform(
clearText(),
typeText("The string with no results"),
pressImeActionButton())
//todo-denbond7 Need to improve this code
Thread.sleep(2000)
onView(withId(R.id.tVEmpty))
.check(matches(isDisplayed()))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,17 @@ data class OutgoingMessageInfo constructor(
return allRecipients
}

@Suppress("UNCHECKED_CAST")
constructor(parcel: Parcel) : this(
parcel.readString()!!,
parcel.readString()!!,
parcel.readString(),
mutableListOf<InternetAddress>().apply { parcel.readList(this as List<*>, InternetAddress::class.java.classLoader) },
mutableListOf<InternetAddress>().apply { parcel.readList(this as List<*>, InternetAddress::class.java.classLoader) },
mutableListOf<InternetAddress>().apply { parcel.readList(this as List<*>, InternetAddress::class.java.classLoader) },
parcel.readValue(InternetAddress::class.java.classLoader) as List<InternetAddress>,
parcel.readValue(InternetAddress::class.java.classLoader) as List<InternetAddress>?,
parcel.readValue(InternetAddress::class.java.classLoader) as List<InternetAddress>?,
parcel.readString()!!,
mutableListOf<AttachmentInfo>().apply { parcel.readTypedList(this, AttachmentInfo.CREATOR) },
mutableListOf<AttachmentInfo>().apply { parcel.readTypedList(this, AttachmentInfo.CREATOR) },
parcel.readValue(AttachmentInfo::class.java.classLoader) as List<AttachmentInfo>?,
parcel.readValue(AttachmentInfo::class.java.classLoader) as List<AttachmentInfo>?,
parcel.readParcelable<MessageEncryptionType>(MessageEncryptionType::class.java.classLoader)!!,
parcel.readParcelable<MessageType>(MessageType::class.java.classLoader)!!,
parcel.readParcelable<MessageEntity>(MessageEntity::class.java.classLoader),
Expand All @@ -72,12 +73,12 @@ data class OutgoingMessageInfo constructor(
writeString(account)
writeString(subject)
writeString(msg)
writeList(toRecipients)
writeList(ccRecipients)
writeList(bccRecipients)
writeValue(toRecipients)
writeValue(ccRecipients)
writeValue(bccRecipients)
writeString(from)
writeTypedList(atts)
writeTypedList(forwardedAtts)
writeValue(atts)
writeValue(forwardedAtts)
writeParcelable(encryptionType, flags)
writeParcelable(messageType, flags)
writeParcelable(replyToMsgEntity, flags)
Expand Down
24 changes: 24 additions & 0 deletions FlowCrypt/src/test/java/com/flowcrypt/email/ParcelableTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ import android.os.Build
import android.os.Parcel
import android.os.Parcelable
import com.flextrade.jfixture.JFixture
import com.flowcrypt.email.api.email.model.OutgoingMessageInfo
import com.flowcrypt.email.api.retrofit.response.model.node.GenericMsgBlock
import com.flowcrypt.email.api.retrofit.response.model.node.MsgBlock
import com.flowcrypt.email.jfixture.MsgBlockGenerationCustomization
import com.flowcrypt.email.jfixture.SelectConstructorCustomisation
import com.flowcrypt.email.model.MessageEncryptionType
import com.flowcrypt.email.model.MessageType
import io.github.classgraph.ClassGraph
import org.junit.Assert
import org.junit.Assert.assertNotNull
Expand All @@ -21,6 +24,7 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.ParameterizedRobolectricTestRunner
import org.robolectric.annotation.Config
import javax.mail.internet.InternetAddress

/**
* @author Denis Bondarenko
Expand All @@ -40,6 +44,26 @@ class ParcelableTest(val name: String, private val currentClass: Class<Parcelabl
fixture.customise(SelectConstructorCustomisation(currentClass))
fixture.customise(MsgBlockGenerationCustomization())
fixture.customise().sameInstance(GenericMsgBlock::class.java, GenericMsgBlock(MsgBlock.Type.UNKNOWN, "someContent", false))
//todo-denbond7 improve that
fixture.customise().sameInstance(OutgoingMessageInfo::class.java,
OutgoingMessageInfo(
account = "[email protected]",
subject = "subject",
msg = "msg",
toRecipients = listOf(InternetAddress("[email protected]")),
ccRecipients = listOf(InternetAddress("[email protected]")),
bccRecipients = listOf(
InternetAddress("[email protected]"),
InternetAddress("[email protected]")),
from = "[email protected]",
atts = null,
forwardedAtts = listOf(),
encryptionType = MessageEncryptionType.STANDARD,
messageType = MessageType.NEW,
replyToMsgEntity = null,
uid = 1000
)
)
objectInstance = currentClass.kotlin.objectInstance ?: fixture.create(currentClass)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream
import java.time.Instant
import java.time.LocalDate
import java.time.ZoneId
Expand Down Expand Up @@ -122,10 +121,6 @@ class EmailUtilTest {
val replyMIME = EmailUtil.genReplyMessage(replyToMsg = replyToMIME, info = outgoingMessageInfo)
replyMIME.saveChanges()

val out = ByteArrayOutputStream()
replyMIME.writeTo(out)
println(String(out.toByteArray()))

assertEquals("Re: " + replyToMIME.subject, replyMIME.subject)
assertEquals(replyToMIME.getRecipients(Message.RecipientType.TO).toList(),
replyMIME.from.toList())
Expand Down

0 comments on commit 04e591d

Please sign in to comment.