Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
13af189
Moved CreateMessageFragment to fragment package.| #1620
DenBond7 Dec 21, 2021
9ecb411
Added a template of ProvidePasswordToProtectMsgDialogFragment.| #1620
DenBond7 Dec 22, 2021
5f2a8bb
CreateMessageFragment. Migrated to use binding.| #1620
DenBond7 Dec 22, 2021
0417524
CreateMessageActivity. Refactoring and improving the code.| #1620
DenBond7 Dec 23, 2021
fc56ca5
Refactored code.| #1620
DenBond7 Dec 24, 2021
23130d5
Merge branch 'master' into issue_1620_ui_for_send_password_encrypted_msg
DenBond7 Jan 10, 2022
a39eb80
CreateMessageFragment. Modified logic to show the "Protect with Passw…
DenBond7 Jan 11, 2022
89d44ba
Refactored code.| #1620
DenBond7 Jan 11, 2022
7c04874
Added IllegalTextForStrengthMeasuring. Refactored code.| #1620
DenBond7 Jan 11, 2022
77db74b
Added a workable realization to support password-protected messages.|…
DenBond7 Jan 11, 2022
b1d1a9d
Enabled password-protected messages only for "flowcrypt.com" domain.|…
DenBond7 Jan 11, 2022
0108d26
Fixed some bugs. Refactored code.| #1620
DenBond7 Jan 12, 2022
4d7abd8
Merge branch 'master' into issue_1620_ui_for_send_password_encrypted_msg
DenBond7 Jan 12, 2022
3a106a5
Fixed some more bugs.| #1620
DenBond7 Jan 12, 2022
7678207
Reverted back some changes in CheckPassphraseStrengthFragment. Refact…
DenBond7 Jan 12, 2022
b4dcf02
Added missing russian translation.| #1620
DenBond7 Jan 12, 2022
cf95a12
Fix translation.| #1620
DenBond7 Jan 12, 2022
914c0b9
Simplified some code.| #1620
DenBond7 Jan 12, 2022
5900865
Fixed lint warnings.| #1620
DenBond7 Jan 12, 2022
2320f38
Fixed russian translation.| #1620
DenBond7 Jan 13, 2022
a40dea4
Fixed some existing tests.| #1620
DenBond7 Jan 13, 2022
e7d414b
Fixed CheckPassphraseStrengthFragmentTest.| #1620
DenBond7 Jan 13, 2022
d9d05c6
Added CreateMessageFragmentPasswordProtectedTest.| #1620
DenBond7 Jan 14, 2022
7c99246
Modifed logic in BetterInternetAddressTest to fix tests that use "loc…
DenBond7 Jan 17, 2022
f7e489c
Fixed "com.project.starter:easylauncher" usage.| #1620
DenBond7 Jan 17, 2022
f8d8990
Modified tests. Fixed rules ordering. Refactored code.| #1620
DenBond7 Jan 19, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import androidx.test.espresso.matcher.RootMatchers.withDecorView
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.internal.runner.junit4.statement.UiThreadStatement.runOnUiThread
import androidx.test.platform.app.InstrumentationRegistry
import com.flowcrypt.email.R
Expand All @@ -40,7 +39,6 @@ import org.hamcrest.Matchers.`is`
import org.hamcrest.Matchers.not
import org.junit.After
import org.junit.Before
import org.junit.runner.RunWith
import java.io.InputStream
import java.util.*
import javax.mail.Session
Expand All @@ -54,7 +52,6 @@ import javax.mail.internet.MimeMessage
* Time: 16:37
* E-mail: DenBond7@gmail.com
*/
@RunWith(AndroidJUnit4::class)
abstract class BaseTest : BaseActivityTestImplementation {
val roomDatabase: FlowCryptRoomDatabase = FlowCryptRoomDatabase.getDatabase(getTargetContext())
private var countingIdlingResource: IdlingResource? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package com.flowcrypt.email.matchers

import android.view.View
import android.widget.ListView
import androidx.annotation.DrawableRes
import androidx.recyclerview.widget.RecyclerView
import androidx.test.espresso.Root
import androidx.test.espresso.matcher.BoundedMatcher
Expand Down Expand Up @@ -115,5 +116,12 @@ class CustomMatchers {
fun isToast(): BaseMatcher<Root?> {
return ToastMatcher()
}

fun withTextViewDrawable(
@DrawableRes resourceId: Int,
@TextViewDrawableMatcher.DrawablePosition drawablePosition: Int
): Matcher<View> {
return TextViewDrawableMatcher(resourceId, drawablePosition)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* © 2016-present FlowCrypt a.s. Limitations apply. Contact human@flowcrypt.com
* Contributors: DenBond7
*/

package com.flowcrypt.email.matchers

import android.view.View
import android.widget.TextView
import androidx.annotation.DrawableRes
import androidx.annotation.IntDef
import androidx.core.graphics.drawable.toBitmap
import org.hamcrest.Description
import org.hamcrest.TypeSafeMatcher

/**
* @author Denis Bondarenko
* Date: 1/14/22
* Time: 11:55 AM
* E-mail: DenBond7@gmail.com
*/
class TextViewDrawableMatcher(
@DrawableRes private val resourceId: Int,
@DrawablePosition private val drawablePosition: Int
) : TypeSafeMatcher<View>() {
override fun describeTo(description: Description) {
description.appendText(
"TextView with compound drawable at position $drawablePosition" +
" same as drawable with id $resourceId"
)
}

override fun matchesSafely(view: View): Boolean {
if (view !is TextView) {
return false
}

val expectedBitmap = view.context.getDrawable(resourceId)?.toBitmap()
return view.compoundDrawables[drawablePosition].toBitmap().sameAs(expectedBitmap)
}

@Retention(AnnotationRetention.SOURCE)
@IntDef(
DrawablePosition.LEFT,
DrawablePosition.TOP,
DrawablePosition.RIGHT,
DrawablePosition.BOTTOM
)
annotation class DrawablePosition {
companion object {
const val LEFT = 0
const val TOP = 1
const val RIGHT = 2
const val BOTTOM = 3
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ class AddOtherAccountFragmentTest : BaseTest() {

@get:Rule
var ruleChain: TestRule = RuleChain
.outerRule(ClearAppSettingsRule())
.around(RetryRule.DEFAULT)
.outerRule(RetryRule.DEFAULT)
.around(ClearAppSettingsRule())
.around(activityScenarioRule)
.around(ScreenshotTestRule())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ class AttesterSettingsFragmentTest : BaseTest() {

@get:Rule
var ruleChain: TestRule = RuleChain
.outerRule(ClearAppSettingsRule())
.outerRule(RetryRule.DEFAULT)
.around(ClearAppSettingsRule())
.around(accountRule)
.around(RetryRule.DEFAULT)
.around(activityScenarioRule)
.around(ScreenshotTestRule())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ class BackupKeysFragmentNoKeysTest : BaseBackupKeysFragmentTest() {

@get:Rule
var ruleChain: TestRule = RuleChain
.outerRule(ClearAppSettingsRule())
.outerRule(RetryRule.DEFAULT)
.around(ClearAppSettingsRule())
.around(addAccountToDatabaseRule)
.around(RetryRule.DEFAULT)
.around(activityScenarioRule)
.around(ScreenshotTestRule())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ class BackupKeysFragmentNoPrvBackupOrgRuleTest : BaseBackupKeysFragmentTest() {

@get:Rule
var ruleChain: TestRule = RuleChain
.outerRule(ClearAppSettingsRule())
.outerRule(RetryRule.DEFAULT)
.around(ClearAppSettingsRule())
.around(addAccountToDatabaseRule)
.around(RetryRule.DEFAULT)
.around(activityScenarioRule)
.around(ScreenshotTestRule())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ class BackupKeysFragmentSingleKeyPassphraseInRamTest : BaseBackupKeysFragmentTes

@get:Rule
var ruleChain: TestRule = RuleChain
.outerRule(ClearAppSettingsRule())
.outerRule(RetryRule.DEFAULT)
.around(ClearAppSettingsRule())
.around(addAccountToDatabaseRule)
.around(addPrivateKeyToDatabaseRule)
.around(RetryRule.DEFAULT)
.around(activityScenarioRule)
.around(ScreenshotTestRule())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class BackupKeysFragmentSingleKeyWeakPassphraseTest : BaseBackupKeysFragmentTest

@get:Rule
var ruleChain: TestRule = RuleChain
.outerRule(ClearAppSettingsRule())
.outerRule(RetryRule.DEFAULT)
.around(ClearAppSettingsRule())
.around(addAccountToDatabaseRule)
.around(
AddPrivateKeyToDatabaseRule(
Expand All @@ -52,7 +53,6 @@ class BackupKeysFragmentSingleKeyWeakPassphraseTest : BaseBackupKeysFragmentTest
sourceType = KeyImportDetails.SourceType.EMAIL
)
)
.around(RetryRule.DEFAULT)
.around(activityScenarioRule)
.around(ScreenshotTestRule())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ class BackupKeysFragmentTest : BaseBackupKeysFragmentTest() {

@get:Rule
var ruleChain: TestRule = RuleChain
.outerRule(ClearAppSettingsRule())
.outerRule(RetryRule.DEFAULT)
.around(ClearAppSettingsRule())
.around(addAccountToDatabaseRule)
.around(AddPrivateKeyToDatabaseRule())
.around(RetryRule.DEFAULT)
.around(activityScenarioRule)
.around(ScreenshotTestRule())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ class BackupKeysFragmentTwoKeysDiffPassphraseInRamTest : BaseBackupKeysFragmentT

@get:Rule
var ruleChain: TestRule = RuleChain
.outerRule(ClearAppSettingsRule())
.outerRule(RetryRule.DEFAULT)
.around(ClearAppSettingsRule())
.around(addAccountToDatabaseRule)
.around(addPrivateKeyToDatabaseRule)
.around(
Expand All @@ -62,7 +63,6 @@ class BackupKeysFragmentTwoKeysDiffPassphraseInRamTest : BaseBackupKeysFragmentT
passphraseType = KeyEntity.PassphraseType.RAM
)
)
.around(RetryRule.DEFAULT)
.around(activityScenarioRule)
.around(ScreenshotTestRule())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class BackupKeysFragmentTwoKeysDiffPassphrasesTest : BaseBackupKeysFragmentTest(

@get:Rule
var ruleChain: TestRule = RuleChain
.outerRule(ClearAppSettingsRule())
.outerRule(RetryRule.DEFAULT)
.around(ClearAppSettingsRule())
.around(addAccountToDatabaseRule)
.around(AddPrivateKeyToDatabaseRule())
.around(
Expand All @@ -54,7 +55,6 @@ class BackupKeysFragmentTwoKeysDiffPassphrasesTest : BaseBackupKeysFragmentTest(
sourceType = KeyImportDetails.SourceType.EMAIL
)
)
.around(RetryRule.DEFAULT)
.around(activityScenarioRule)
.around(ScreenshotTestRule())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class BackupKeysFragmentTwoKeysSamePassphraseTest : BaseBackupKeysFragmentTest()

@get:Rule
var ruleChain: TestRule = RuleChain
.outerRule(ClearAppSettingsRule())
.outerRule(RetryRule.DEFAULT)
.around(ClearAppSettingsRule())
.around(addAccountToDatabaseRule)
.around(AddPrivateKeyToDatabaseRule())
.around(
Expand All @@ -53,7 +54,6 @@ class BackupKeysFragmentTwoKeysSamePassphraseTest : BaseBackupKeysFragmentTest()
sourceType = KeyImportDetails.SourceType.EMAIL
)
)
.around(RetryRule.DEFAULT)
.around(activityScenarioRule)
.around(ScreenshotTestRule())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ class ChangePassphraseOfImportedKeysFragmentTest : BaseTest() {

@get:Rule
var ruleChain: TestRule = RuleChain
.outerRule(ClearAppSettingsRule())
.outerRule(RetryRule.DEFAULT)
.around(ClearAppSettingsRule())
.around(addAccountToDatabaseRule)
.around(AddPrivateKeyToDatabaseRule())
.around(RetryRule.DEFAULT)
.around(activityScenarioRule)
.around(ScreenshotTestRule())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class CheckKeysActivityTestMultiBackups : BaseTest() {

@get:Rule
var ruleChain: TestRule = RuleChain
.outerRule(ClearAppSettingsRule())
.around(RetryRule.DEFAULT)
.outerRule(RetryRule.DEFAULT)
.around(ClearAppSettingsRule())
.around(activeActivityRule)
.around(ScreenshotTestRule())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ class CheckKeysActivityWithExistingKeysTest : BaseTest() {

@get:Rule
var ruleChain: TestRule = RuleChain
.outerRule(ClearAppSettingsRule())
.outerRule(RetryRule.DEFAULT)
.around(ClearAppSettingsRule())
.around(addAccountToDatabaseRule)
.around(
AddPrivateKeyToDatabaseRule(
Expand All @@ -75,7 +76,6 @@ class CheckKeysActivityWithExistingKeysTest : BaseTest() {
sourceType = KeyImportDetails.SourceType.EMAIL
)
)
.around(RetryRule.DEFAULT)
.around(activityScenarioRule)
.around(ScreenshotTestRule())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ class CheckKeysActivityWithoutExistingKeysTest : BaseTest() {

@get:Rule
var ruleChain: TestRule = RuleChain
.outerRule(ClearAppSettingsRule())
.around(RetryRule.DEFAULT)
.outerRule(RetryRule.DEFAULT)
.around(ClearAppSettingsRule())
.around(activityScenarioRule)
.around(ScreenshotTestRule())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import org.junit.Test
import org.junit.rules.RuleChain
import org.junit.rules.TestRule
import org.junit.runner.RunWith
import java.util.Locale

/**
* @author Denis Bondarenko
Expand All @@ -58,10 +57,10 @@ class CheckPassphraseStrengthFragmentTest : BaseTest() {

@get:Rule
var ruleChain: TestRule = RuleChain
.outerRule(ClearAppSettingsRule())
.outerRule(RetryRule.DEFAULT)
.around(ClearAppSettingsRule())
.around(addAccountToDatabaseRule)
.around(AddPrivateKeyToDatabaseRule())
.around(RetryRule.DEFAULT)
.around(activityScenarioRule)
.around(ScreenshotTestRule())

Expand Down Expand Up @@ -105,7 +104,7 @@ class CheckPassphraseStrengthFragmentTest : BaseTest() {
.check(matches(isDisplayed()))
.perform(replaceText(passPhrases[i]))
onView(withId(R.id.tVPassphraseQuality))
.check(matches(withText(startsWith(degreeOfReliabilityOfPassPhrase[i].toUpperCase(Locale.getDefault())))))
.check(matches(withText(startsWith(degreeOfReliabilityOfPassPhrase[i].uppercase()))))
onView(withId(R.id.eTPassphrase))
.check(matches(isDisplayed()))
.perform(clearText())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ class CreateMessageActivityReplyAllTest : BaseTest() {

@get:Rule
var ruleChain: TestRule = RuleChain
.outerRule(ClearAppSettingsRule())
.outerRule(RetryRule.DEFAULT)
.around(ClearAppSettingsRule())
.around(AddAccountToDatabaseRule(account))
.around(AddPrivateKeyToDatabaseRule())
.around(RetryRule.DEFAULT)
.around(activeActivityRule)
.around(ScreenshotTestRule())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ class CreateMessageActivityReplyTest : BaseTest() {

@get:Rule
var ruleChain: TestRule = RuleChain
.outerRule(ClearAppSettingsRule())
.outerRule(RetryRule.DEFAULT)
.around(ClearAppSettingsRule())
.around(AddAccountToDatabaseRule())
.around(AddPrivateKeyToDatabaseRule())
.around(RetryRule.DEFAULT)
.around(activeActivityRule)
.around(ScreenshotTestRule())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.hasSibling
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withParent
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
Expand Down Expand Up @@ -103,11 +104,11 @@ class CreateMessageActivityTest : BaseCreateMessageActivityTest() {

@get:Rule
var ruleChain: TestRule = RuleChain
.outerRule(ClearAppSettingsRule())
.outerRule(RetryRule.DEFAULT)
.around(ClearAppSettingsRule())
.around(addAccountToDatabaseRule)
.around(addPrivateKeyToDatabaseRule)
.around(temporaryFolderRule)
.around(RetryRule.DEFAULT)
.around(activeActivityRule)
.around(ScreenshotTestRule())

Expand Down Expand Up @@ -728,7 +729,7 @@ class CreateMessageActivityTest : BaseCreateMessageActivityTest() {
private fun deleteAtt(att: File) {
onView(
allOf(
withId(R.id.imageButtonClearAtt), ViewMatchers.withParent(
withId(R.id.imageButtonClearAtt), withParent(
allOf(withId(R.id.actionButtons), hasSibling(withText(att.name)))
)
)
Expand Down
Loading