Fixed refernces to LabelId and AddressIs in some instrumented tests.
MAILAND-1430
This commit is contained in:
parent
17ecd77f67
commit
b22ece6e42
|
@ -21,10 +21,8 @@ package ch.protonmail.android.crypto
|
|||
import android.text.TextUtils
|
||||
import androidx.test.filters.LargeTest
|
||||
import ch.protonmail.android.api.models.Keys
|
||||
import ch.protonmail.android.api.models.User
|
||||
import ch.protonmail.android.core.UserManager
|
||||
import ch.protonmail.android.data.local.model.Attachment
|
||||
import me.proton.core.domain.entity.UserId
|
||||
import ch.protonmail.android.mapper.bridge.AddressKeyBridgeMapper
|
||||
import ch.protonmail.android.mapper.bridge.AddressKeysBridgeMapper
|
||||
import ch.protonmail.android.mapper.bridge.UserKeyBridgeMapper
|
||||
|
@ -40,7 +38,8 @@ import io.mockk.mockk
|
|||
import io.mockk.mockkStatic
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import me.proton.core.domain.arch.map
|
||||
import me.proton.core.util.kotlin.invoke
|
||||
import me.proton.core.domain.entity.UserId
|
||||
import me.proton.core.user.domain.entity.AddressId
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
|
@ -691,7 +690,7 @@ internal class CryptoTest {
|
|||
|
||||
private val oneKeyUserMock: ch.protonmail.android.domain.entity.user.User = mockk {
|
||||
every { addresses } returns mockk {
|
||||
every { findBy(UserId(oneAddressKeyAddressId)) } answers { addresses[1] }
|
||||
every { findBy(AddressId(oneAddressKeyAddressId)) } answers { addresses[1] }
|
||||
every { addresses } returns mapOf(
|
||||
1 to mockk {
|
||||
every { keys } returns mockk {
|
||||
|
@ -709,7 +708,7 @@ internal class CryptoTest {
|
|||
|
||||
private val manyAddressKeysUserMock: ch.protonmail.android.domain.entity.user.User = mockk {
|
||||
every { addresses } returns mockk {
|
||||
every { findBy(UserId(manyAddressKeysAddressId)) } answers { addresses[1] }
|
||||
every { findBy(AddressId(manyAddressKeysAddressId)) } answers { addresses[1] }
|
||||
every { addresses } returns mapOf(
|
||||
1 to mockk {
|
||||
every { keys } returns mockk {
|
||||
|
@ -786,7 +785,7 @@ internal class CryptoTest {
|
|||
|
||||
val expected = "Test PGP/MIME Message\r\n\r\n\r\n"
|
||||
|
||||
val addressCrypto = Crypto.forAddress(userManagerMock, oneAddressKeyUserId, UserId(oneAddressKeyAddressId))
|
||||
val addressCrypto = Crypto.forAddress(userManagerMock, oneAddressKeyUserId, AddressId(oneAddressKeyAddressId))
|
||||
val result = addressCrypto.decrypt(CipherText(encryptedMessage)).decryptedData
|
||||
|
||||
assertEquals(expected, result)
|
||||
|
@ -852,7 +851,7 @@ internal class CryptoTest {
|
|||
"The ProtonMail Team\r\n"
|
||||
|
||||
val addressCrypto =
|
||||
Crypto.forAddress(userManagerMock, manyAddressKeysUserId, UserId(manyAddressKeysAddressId))
|
||||
Crypto.forAddress(userManagerMock, manyAddressKeysUserId, AddressId(manyAddressKeysAddressId))
|
||||
val result = addressCrypto.decrypt(CipherText(encryptedMessage)).decryptedData
|
||||
|
||||
assertEquals(expected, result)
|
||||
|
@ -897,7 +896,7 @@ internal class CryptoTest {
|
|||
|
||||
val expected = "Test PGP/MIME Message\r\n\r\n\r\n"
|
||||
|
||||
val addressCrypto = Crypto.forAddress(userManagerMock, oneAddressKeyUserId, UserId(oneAddressKeyAddressId))
|
||||
val addressCrypto = Crypto.forAddress(userManagerMock, oneAddressKeyUserId, AddressId(oneAddressKeyAddressId))
|
||||
val decryptor = addressCrypto.decryptMime(CipherText(encryptedMessage))
|
||||
|
||||
lateinit var resultBody: String
|
||||
|
@ -1622,7 +1621,7 @@ internal class CryptoTest {
|
|||
}
|
||||
)
|
||||
|
||||
val addressCrypto = Crypto.forAddress(userManagerMock, oneAddressKeyUserId, UserId(oneAddressKeyAddressId))
|
||||
val addressCrypto = Crypto.forAddress(userManagerMock, oneAddressKeyUserId, AddressId(oneAddressKeyAddressId))
|
||||
val decryptor = addressCrypto.decryptMime(CipherText(encryptedMessage))
|
||||
|
||||
lateinit var resultBody: String
|
||||
|
|
|
@ -29,7 +29,6 @@ import ch.protonmail.android.api.models.factories.PackageFactory
|
|||
import ch.protonmail.android.crypto.AddressCrypto
|
||||
import ch.protonmail.android.crypto.CipherText
|
||||
import ch.protonmail.android.data.local.model.Message
|
||||
import me.proton.core.domain.entity.UserId
|
||||
import ch.protonmail.android.utils.HTMLToMDConverter
|
||||
import ch.protonmail.android.utils.base64.Base64Encoder
|
||||
import com.proton.gopenpgp.crypto.SessionKey
|
||||
|
@ -40,6 +39,8 @@ import io.mockk.impl.annotations.MockK
|
|||
import io.mockk.impl.annotations.RelaxedMockK
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import me.proton.core.domain.entity.UserId
|
||||
import me.proton.core.user.domain.entity.AddressId
|
||||
import kotlin.test.BeforeTest
|
||||
import kotlin.test.Test
|
||||
|
||||
|
@ -97,7 +98,7 @@ class PackageFactoryTest {
|
|||
val currentUsername = "Marino"
|
||||
val currentUserId = UserId("marino")
|
||||
every { base64Encoder.encode(any()) } returns "encodedBase64"
|
||||
every { addressCryptoFactory.create(currentUserId, UserId(addressId)) } returns crypto
|
||||
every { addressCryptoFactory.create(currentUserId, AddressId(addressId)) } returns crypto
|
||||
every { htmlToMDConverter.convert(any()) } returns bodyPlainText
|
||||
every { crypto.encrypt(bodyPlainText, true) } returns cipherText
|
||||
every { crypto.decryptKeyPacket(keyPackage) } returns "decryptedKeyPackets".toByteArray()
|
||||
|
|
|
@ -28,13 +28,13 @@ import androidx.test.espresso.matcher.ViewMatchers.withId
|
|||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
|
||||
import ch.protonmail.android.R
|
||||
import ch.protonmail.android.domain.entity.LabelId
|
||||
import ch.protonmail.android.domain.entity.Name
|
||||
import ch.protonmail.android.testAndroidInstrumented.assertion.isGone
|
||||
import ch.protonmail.android.testAndroidInstrumented.assertion.isVisible
|
||||
import ch.protonmail.android.testAndroidInstrumented.withBackgroundColor
|
||||
import ch.protonmail.android.ui.model.LabelChipUiModel
|
||||
import ch.protonmail.android.util.ViewTest
|
||||
import me.proton.core.domain.entity.UserId
|
||||
import org.junit.runner.RunWith
|
||||
import kotlin.test.Test
|
||||
|
||||
|
@ -45,13 +45,13 @@ import kotlin.test.Test
|
|||
class MultiLineLabelChipGroupViewTest : ViewTest<MultiLineLabelChipGroupView>(::MultiLineLabelChipGroupView) {
|
||||
|
||||
private val testLabelsList = listOf(
|
||||
LabelChipUiModel(UserId("a"), Name("long name for first label"), Color.RED),
|
||||
LabelChipUiModel(UserId("b"), Name("second label"), Color.GREEN),
|
||||
LabelChipUiModel(UserId("c"), Name("third"), Color.BLUE),
|
||||
LabelChipUiModel(UserId("d"), Name("long name for forth label"), Color.CYAN),
|
||||
LabelChipUiModel(UserId("e"), Name("fifth label"), Color.MAGENTA),
|
||||
LabelChipUiModel(UserId("f"), Name("sixth"), Color.GRAY),
|
||||
LabelChipUiModel(UserId("g"), Name("long name for seventh label"), Color.BLACK),
|
||||
LabelChipUiModel(LabelId("a"), Name("long name for first label"), Color.RED),
|
||||
LabelChipUiModel(LabelId("b"), Name("second label"), Color.GREEN),
|
||||
LabelChipUiModel(LabelId("c"), Name("third"), Color.BLUE),
|
||||
LabelChipUiModel(LabelId("d"), Name("long name for forth label"), Color.CYAN),
|
||||
LabelChipUiModel(LabelId("e"), Name("fifth label"), Color.MAGENTA),
|
||||
LabelChipUiModel(LabelId("f"), Name("sixth"), Color.GRAY),
|
||||
LabelChipUiModel(LabelId("g"), Name("long name for seventh label"), Color.BLACK),
|
||||
)
|
||||
|
||||
@Test
|
||||
|
|
|
@ -25,13 +25,13 @@ import androidx.test.espresso.Espresso.onView
|
|||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
|
||||
import ch.protonmail.android.domain.entity.LabelId
|
||||
import ch.protonmail.android.domain.entity.Name
|
||||
import ch.protonmail.android.testAndroidInstrumented.assertion.isGone
|
||||
import ch.protonmail.android.testAndroidInstrumented.assertion.isVisible
|
||||
import ch.protonmail.android.testAndroidInstrumented.withBackgroundColor
|
||||
import ch.protonmail.android.ui.model.LabelChipUiModel
|
||||
import ch.protonmail.android.util.ViewTest
|
||||
import me.proton.core.domain.entity.UserId
|
||||
import org.hamcrest.Description
|
||||
import org.hamcrest.Matcher
|
||||
import org.hamcrest.TypeSafeDiagnosingMatcher
|
||||
|
@ -45,9 +45,9 @@ import kotlin.test.Test
|
|||
class SingleLineLabelChipGroupViewTest : ViewTest<SingleLineLabelChipGroupView>(::SingleLineLabelChipGroupView) {
|
||||
|
||||
private val testLabelsList = listOf(
|
||||
LabelChipUiModel(UserId("a"), Name("first"), Color.RED),
|
||||
LabelChipUiModel(UserId("b"), Name("second"), Color.GREEN),
|
||||
LabelChipUiModel(UserId("c"), Name("third"), Color.BLUE),
|
||||
LabelChipUiModel(LabelId("a"), Name("first"), Color.RED),
|
||||
LabelChipUiModel(LabelId("b"), Name("second"), Color.GREEN),
|
||||
LabelChipUiModel(LabelId("c"), Name("third"), Color.BLUE),
|
||||
)
|
||||
|
||||
@Test
|
||||
|
@ -89,7 +89,7 @@ class SingleLineLabelChipGroupViewTest : ViewTest<SingleLineLabelChipGroupView>(
|
|||
.check(matches(withBackgroundColor(expectedLabelColor)))
|
||||
}
|
||||
|
||||
private fun withLabelId(labelId: UserId): Matcher<View> {
|
||||
private fun withLabelId(labelId: LabelId): Matcher<View> {
|
||||
return object : TypeSafeDiagnosingMatcher<View>() {
|
||||
|
||||
override fun matchesSafely(item: View, mismatchDescription: Description) =
|
||||
|
|
Loading…
Reference in New Issue