From 04e591d35719f08f6cab3877e07ea8396394ccb7 Mon Sep 17 00:00:00 2001 From: Den Date: Thu, 1 Apr 2021 21:38:10 +0300 Subject: [PATCH] Issue 1108 Prepare 1.1.6 (#1142) * Modified SearchMessagesActivityTest.| #1116 * Fixed JUnit tests.| #1116 * Fixed ParcelableTest. Modified Parcelable realization for OutgoingMessageInfo.| #1116 --- .../ui/activity/SearchMessagesActivityTest.kt | 15 +++++++++--- .../api/email/model/OutgoingMessageInfo.kt | 21 ++++++++-------- .../com/flowcrypt/email/ParcelableTest.kt | 24 +++++++++++++++++++ .../email/api/email/EmailUtilTest.kt | 5 ---- 4 files changed, 47 insertions(+), 18 deletions(-) diff --git a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/activity/SearchMessagesActivityTest.kt b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/activity/SearchMessagesActivityTest.kt index e40e141469..bf5c899b60 100644 --- a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/activity/SearchMessagesActivityTest.kt +++ b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/activity/SearchMessagesActivityTest.kt @@ -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) } @@ -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())) } @@ -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())) } @@ -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())) } diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/model/OutgoingMessageInfo.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/model/OutgoingMessageInfo.kt index 6daf57d16c..fed38a1ccf 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/model/OutgoingMessageInfo.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/model/OutgoingMessageInfo.kt @@ -48,16 +48,17 @@ data class OutgoingMessageInfo constructor( return allRecipients } + @Suppress("UNCHECKED_CAST") constructor(parcel: Parcel) : this( parcel.readString()!!, parcel.readString()!!, parcel.readString(), - mutableListOf().apply { parcel.readList(this as List<*>, InternetAddress::class.java.classLoader) }, - mutableListOf().apply { parcel.readList(this as List<*>, InternetAddress::class.java.classLoader) }, - mutableListOf().apply { parcel.readList(this as List<*>, InternetAddress::class.java.classLoader) }, + parcel.readValue(InternetAddress::class.java.classLoader) as List, + parcel.readValue(InternetAddress::class.java.classLoader) as List?, + parcel.readValue(InternetAddress::class.java.classLoader) as List?, parcel.readString()!!, - mutableListOf().apply { parcel.readTypedList(this, AttachmentInfo.CREATOR) }, - mutableListOf().apply { parcel.readTypedList(this, AttachmentInfo.CREATOR) }, + parcel.readValue(AttachmentInfo::class.java.classLoader) as List?, + parcel.readValue(AttachmentInfo::class.java.classLoader) as List?, parcel.readParcelable(MessageEncryptionType::class.java.classLoader)!!, parcel.readParcelable(MessageType::class.java.classLoader)!!, parcel.readParcelable(MessageEntity::class.java.classLoader), @@ -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) diff --git a/FlowCrypt/src/test/java/com/flowcrypt/email/ParcelableTest.kt b/FlowCrypt/src/test/java/com/flowcrypt/email/ParcelableTest.kt index 22cf0b80ee..eca73e0c69 100644 --- a/FlowCrypt/src/test/java/com/flowcrypt/email/ParcelableTest.kt +++ b/FlowCrypt/src/test/java/com/flowcrypt/email/ParcelableTest.kt @@ -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 @@ -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 @@ -40,6 +44,26 @@ class ParcelableTest(val name: String, private val currentClass: Class