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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,3 @@ local.properties
/compile.sh
/ctest.sh
/test.sh

7 changes: 5 additions & 2 deletions .idea/codeStyles/Project.xml

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

2 changes: 1 addition & 1 deletion FlowCrypt/lint.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
<!-- This file is needed for debug purposes -->
<ignore path="res/raw/debug_certificate.crt" />
</issue>
</lint>
</lint>
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ Content-Transfer-Encoding: 8bit
Text: Ваше оголошення
</body>
</html>

Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,3 @@ vT56K5RcJnyZkFMaxqqKa6qBJ7XXL3nn2ePquNwj3zO59yVoF2AeoipJCTLE
C/jf1vpjTJlbneWAjUWjm8+SlfCY1V/oERo=
=UCCQ
-----END PGP MESSAGE-----

Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,3 @@ YHAmeAIbDAUWAgMBAAQLCQgHBRUKCQgLAh4BAAoJEMyEq3t0m4PryFkA/jZ7HuJK
qH98S9dQSRizw3hxAg==
=g+Is
-----END PGP PRIVATE KEY BLOCK-----

Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,3 @@ q00PAwEIB4h1BBgWCgAdBQJgcCU5AhsMBRYCAwEABAsJCAcFFQoJCAsCHgEACgkQ
0oMmO25amIOvw4zoOJDypIQ+wNp+62iNde0pukwP
=8kgY
-----END PGP PUBLIC KEY BLOCK-----

Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,3 @@ oPnfUupWCMKXM3PN/Sw6Zn5Zja3DRuFxrSXIAQCOXPE4EOucuOmMCi2JcfkVmpfE
ReZjtUMWEusItbv4Cg==
=I9MB
-----END PGP PRIVATE KEY BLOCK-----

Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,3 @@ z++0ULA1AQDAfGX9fWSFkFJeUEMf3wdtH4f7uBnpHFed9T7ccHh1hgD/YkNbtpMI
EdJrIZnU/alchpAYC5JRJuaoyuaOgWxAgQI=
=E5rK
-----END PGP PRIVATE KEY BLOCK-----

Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,3 @@ CAsCHgEACgkQCW1r0sdsyuuVRQD/TsQc21Kg+d9S6lYIwpczc839LDpmflmNrcNG
4XGtJcgBAI5c8TgQ65y46YwKLYlx+RWal8RF5mO1QxYS6wi1u/gK
=tPlZ
-----END PGP PUBLIC KEY BLOCK-----

Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,3 @@ YHADnhIKKwYBBAGXVQEFAQEHQCL+4AjWCMUzWCsMmSJGF3WcUNOLFNR4zWsLtJl2
W7aTCBHSayGZ1P2pXIaQGAuSUSbmqMrmjoFsQIEC
=wEh7
-----END PGP PUBLIC KEY BLOCK-----

Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ class DebugTestingTest {
@Test
fun alwaysSuccessTestSecond() {
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ interface BaseActivityTestImplementation {

val useIntents: Boolean
get() = false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ abstract class BaseTest : BaseActivityTestImplementation {
*/
protected fun isToastDisplayed(decorView: View?, message: String) {
onView(withText(message))
.inRoot(withDecorView(not(`is`(decorView))))
.check(matches(isDisplayed()))
.inRoot(withDecorView(not(`is`(decorView))))
.check(matches(isDisplayed()))
}

/**
Expand All @@ -133,8 +133,8 @@ abstract class BaseTest : BaseActivityTestImplementation {
*/
protected fun isDialogWithTextDisplayed(decorView: View?, message: String) {
onView(withText(message))
.inRoot(withDecorView(not(`is`(decorView))))
.check(matches(isDisplayed()))
.inRoot(withDecorView(not(`is`(decorView))))
.check(matches(isDisplayed()))
}

/**
Expand All @@ -143,15 +143,15 @@ abstract class BaseTest : BaseActivityTestImplementation {
//todo-denbond7 - fix me
protected fun testHelpScreen() {
onView(withId(R.id.menuActionHelp))
.check(matches(isDisplayed()))
.perform(click())
.check(matches(isDisplayed()))
.perform(click())

onView(withId(R.id.textViewAuthorHint))
.check(matches(isDisplayed()))
.check(matches(withText(R.string.i_will_usually_reply_within_an_hour_except_when_i_sleep_tom)))
.check(matches(isDisplayed()))
.check(matches(withText(R.string.i_will_usually_reply_within_an_hour_except_when_i_sleep_tom)))

onView(withText(R.string.help_feedback_or_question))
.check(matches(isDisplayed()))
.check(matches(isDisplayed()))
}

/**
Expand All @@ -163,8 +163,8 @@ abstract class BaseTest : BaseActivityTestImplementation {
onView(withText(message)).check(matches(isDisplayed()))

onView(withId(com.google.android.material.R.id.snackbar_action))
.check(matches(isDisplayed()))
.perform(click())
.check(matches(isDisplayed()))
.perform(click())
}

/**
Expand All @@ -173,11 +173,11 @@ abstract class BaseTest : BaseActivityTestImplementation {
protected fun checkIsSnackBarDisplayed(text: String? = null) {
if (text.isNullOrEmpty()) {
onView(withId(com.google.android.material.R.id.snackbar_action))
.check(matches(isDisplayed()))
.check(matches(isDisplayed()))
} else {
onView(withId(com.google.android.material.R.id.snackbar_text))
.check(matches(isDisplayed()))
.check(matches(withText(text)))
.check(matches(isDisplayed()))
.check(matches(withText(text)))
}
}

Expand All @@ -186,7 +186,7 @@ abstract class BaseTest : BaseActivityTestImplementation {
*/
protected fun checkIsSnackBarNotDisplayed() {
onView(withId(com.google.android.material.R.id.snackbar_action))
.check(doesNotExist())
.check(doesNotExist())
}

/**
Expand All @@ -198,14 +198,16 @@ abstract class BaseTest : BaseActivityTestImplementation {
*/
protected fun addTextToClipboard(label: String, text: String) {
runOnUiThread {
val clipboard = getTargetContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
val clipboard =
getTargetContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
val clip = ClipData.newPlainText(label, text)
clipboard.setPrimaryClip(clip)
}
}

protected fun checkClipboardText(text: CharSequence) {
val clipboardManager = getTargetContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
val clipboardManager =
getTargetContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
val primaryClip: ClipData? = clipboardManager.primaryClip

var clipboardText: CharSequence? = null
Expand Down Expand Up @@ -239,14 +241,20 @@ abstract class BaseTest : BaseActivityTestImplementation {
return InstrumentationRegistry.getInstrumentation().context
}

fun getMsgInfo(path: String, mimeMsgPath: String, vararg atts: AttachmentInfo?): IncomingMessageInfo? {
fun getMsgInfo(
path: String,
mimeMsgPath: String,
vararg atts: AttachmentInfo?
): IncomingMessageInfo? {
val incomingMsgInfo = TestGeneralUtil.getObjectFromJson(path, IncomingMessageInfo::class.java)
incomingMsgInfo?.msgEntity?.let {
val uri = roomDatabase.msgDao().insert(it)
val attEntities = mutableListOf<AttachmentEntity>()

for (attInfo in atts) {
attInfo?.let { info -> AttachmentEntity.fromAttInfo(info)?.let { candidate -> attEntities.add(candidate) } }
attInfo?.let { info ->
AttachmentEntity.fromAttInfo(info)?.let { candidate -> attEntities.add(candidate) }
}
}

roomDatabase.attachmentDao().insert(attEntities)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ class MigrationTest {

@get:Rule
val migrationTestHelper: MigrationTestHelper = MigrationTestHelper(
InstrumentationRegistry.getInstrumentation(),
FlowCryptRoomDatabase::class.java.canonicalName,
FrameworkSQLiteOpenHelperFactory()
InstrumentationRegistry.getInstrumentation(),
FlowCryptRoomDatabase::class.java.canonicalName,
FrameworkSQLiteOpenHelperFactory()
)

@Test
Expand All @@ -55,8 +55,8 @@ class MigrationTest {

// Open latest version of the DB. Room will validate the schema once all migrations execute.
Room.databaseBuilder(
InstrumentationRegistry.getInstrumentation().targetContext,
FlowCryptRoomDatabase::class.java, FlowCryptRoomDatabase.DB_NAME
InstrumentationRegistry.getInstrumentation().targetContext,
FlowCryptRoomDatabase::class.java, FlowCryptRoomDatabase.DB_NAME
).addMigrations(*arrayOfMigrations).build().apply {
openHelper.writableDatabase
close()
Expand All @@ -66,4 +66,4 @@ class MigrationTest {
companion object {
const val INIT_DATABASE_VERSION = 19
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ package com.flowcrypt.email.junit.annotations
* E-mail: DenBond7@gmail.com
*/
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
annotation class DebugTest
annotation class DebugTest
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ package com.flowcrypt.email.junit.annotations
* E-mail: DenBond7@gmail.com
*/
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
annotation class DependsOnMailServer
annotation class DependsOnMailServer
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ package com.flowcrypt.email.junit.annotations
* E-mail: DenBond7@gmail.com
*/
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
annotation class NotReadyForCI
annotation class NotReadyForCI
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ class DependsOnMailServerFilter : ReadyForCIFilter() {
}

override fun describe() = "Filter tests that depend on an email server"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ class DoesNotNeedMailServerFilter : ReadyForCIFilter() {
}

override fun describe() = "Filter tests that don't need an email server"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ open class NotReadyForCIFilter : ParentFilter() {
}

override fun describe() = "Filter tests that can't be run on CI yet"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ class OtherTestsFilter : ParentFilter() {
private val doesNotNeedMailServerFilter = DoesNotNeedMailServerFilter()

override fun evaluateTest(description: Description?): Boolean {
return (!dependsOnMailServerFilter.shouldRun(description) && !doesNotNeedMailServerFilter.shouldRun(description))
return (!dependsOnMailServerFilter.shouldRun(description) && !doesNotNeedMailServerFilter.shouldRun(
description
))
}

override fun describe() = "Filter tests that are not related to any conditions"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ import org.junit.runner.Description
open class ReadyForCIFilter : ParentFilter() {
override fun evaluateTest(description: Description?): Boolean {
val annotationClass = NotReadyForCI::class.java
return (description?.testClass?.isAnnotationPresent(annotationClass) == false && description.getAnnotation(annotationClass) == null)
return (description?.testClass?.isAnnotationPresent(annotationClass) == false && description.getAnnotation(
annotationClass
) == null)
}

override fun describe() = "Filter tests that are ready to be run on a CI server"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import org.hamcrest.Description
* Time: 3:17 PM
* E-mail: DenBond7@gmail.com
*/
class AppBarLayoutBackgroundColorMatcher(val color: Int)
: BoundedMatcher<View, AppBarLayout>(AppBarLayout::class.java) {
class AppBarLayoutBackgroundColorMatcher(val color: Int) :
BoundedMatcher<View, AppBarLayout>(AppBarLayout::class.java) {
public override fun matchesSafely(appBarLayout: AppBarLayout): Boolean {
return if (appBarLayout.background is ColorDrawable) {
color == (appBarLayout.background as ColorDrawable).color
Expand All @@ -28,4 +28,4 @@ class AppBarLayoutBackgroundColorMatcher(val color: Int)
override fun describeTo(description: Description) {
description.appendText("Background color AppBarLayout: $color")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ class DrawableMatcher(private val expectedId: Int) : TypeSafeMatcher<View>(View:
ANY -> return target.drawable != null
else -> {
val resources = target.getContext().resources
val expectedDrawable = resources.getDrawable(expectedId, target.getContext().theme) ?: return false
val expectedDrawable =
resources.getDrawable(expectedId, target.getContext().theme) ?: return false
resourceName = resources.getResourceEntryName(expectedId)

val bitmap = getBitmap(target.drawable)
Expand All @@ -56,7 +57,11 @@ class DrawableMatcher(private val expectedId: Int) : TypeSafeMatcher<View>(View:
}

private fun getBitmap(drawable: Drawable): Bitmap {
val bitmap = Bitmap.createBitmap(drawable.intrinsicWidth, drawable.intrinsicHeight, Bitmap.Config.ARGB_8888)
val bitmap = Bitmap.createBitmap(
drawable.intrinsicWidth,
drawable.intrinsicHeight,
Bitmap.Config.ARGB_8888
)
val canvas = Canvas(bitmap)
drawable.setBounds(0, 0, canvas.width, canvas.height)
drawable.draw(canvas)
Expand All @@ -67,4 +72,4 @@ class DrawableMatcher(private val expectedId: Int) : TypeSafeMatcher<View>(View:
const val EMPTY = -1
const val ANY = -2
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ class EmptyListViewMather<T : View> : BaseMatcher<T>() {
override fun describeTo(description: Description) {
description.appendText("List is not empty")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ class EmptyRecyclerViewMatcher<T : View> : BaseMatcher<T>() {
override fun describeTo(description: Description) {
description.appendText("RecyclerView is not empty")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ class ListViewItemCountMatcher<T : View>(val itemCount: Int) : BaseMatcher<T>()
override fun describeTo(description: Description) {
description.appendText("The size of the list is not equal = $itemCount")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ import org.hamcrest.Description
* Time: 10:19 AM
* E-mail: DenBond7@gmail.com
*/
class NachoTextViewChipBackgroundColorMatcher(private val chipText: String,
private val backgroundColor: Int)
: BoundedMatcher<View, NachoTextView>(NachoTextView::class.java) {
class NachoTextViewChipBackgroundColorMatcher(
private val chipText: String,
private val backgroundColor: Int
) : BoundedMatcher<View, NachoTextView>(NachoTextView::class.java) {
public override fun matchesSafely(nachoTextView: NachoTextView): Boolean {
val expectedChip = nachoTextView.allChips.firstOrNull { it.text == chipText } ?: return false
val pgpContactChipSpan = expectedChip as? PGPContactChipSpan ?: return false
Expand All @@ -29,4 +30,4 @@ class NachoTextViewChipBackgroundColorMatcher(private val chipText: String,
override fun describeTo(description: Description) {
description.appendText("Chip details: text = $chipText, color = $backgroundColor")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ class RecyclerViewItemCountMatcher<T : View>(private val itemCount: Int) : BaseM
override fun describeTo(description: Description) {
description.appendText("The count of the RecyclerView is not equal = $itemCount")
}
}
}
Loading