Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New groups implementation #1584

Open
wants to merge 19 commits into
base: dev
Choose a base branch
from
Open
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
  •  
  •  
  •  
10 changes: 10 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
kind: pipeline
type: docker
name: default

steps:
- name: test
image: mingc/android-build-box:1.24.0
commands:
- bash ./gradlew test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
project.properties
.project
.settings
.kotlin
bin/
gen/
.idea/
Expand Down
44 changes: 27 additions & 17 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'org.jetbrains.kotlin.plugin.serialization'
id 'org.jetbrains.kotlin.plugin.compose'
id 'com.google.devtools.ksp'
id 'com.google.dagger.hilt.android'
id 'kotlin-parcelize'
id 'kotlinx-serialization'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'witness'
apply plugin: 'kotlin-parcelize'
apply plugin: 'kotlinx-serialization'

configurations.forEach {
it.exclude module: "commons-logging"
configurations.configureEach {
exclude module: "commons-logging"
}

def canonicalVersionCode = 382
Expand Down Expand Up @@ -40,12 +42,12 @@ android {
useLibrary 'org.apache.http.legacy'

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '17'
}

packagingOptions {
Expand All @@ -54,6 +56,7 @@ android {
}
}


splits {
abi {
enable true
Expand All @@ -64,7 +67,8 @@ android {
}

buildFeatures {
compose true
viewBinding true
buildConfig true
}

composeOptions {
Expand Down Expand Up @@ -151,7 +155,7 @@ android {
}
}

applicationVariants.forEach { variant ->
applicationVariants.configureEach { variant ->
variant.outputs.each { output ->
def abiName = output.getFilter("ABI") ?: 'universal'
def postFix = abiPostFix.get(abiName, 0)
Expand All @@ -169,11 +173,11 @@ android {
}
}

buildFeatures {
viewBinding true
}

def huaweiEnabled = project.properties['huawei'] != null
lint {
abortOnError true
baseline file('lint-baseline.xml')
}

applicationVariants.configureEach { variant ->
if (variant.flavorName == 'huawei') {
Expand Down Expand Up @@ -226,6 +230,7 @@ dependencies {
ksp("androidx.hilt:hilt-compiler:$jetpackHiltVersion")
ksp("com.google.dagger:hilt-compiler:$daggerHiltVersion")
ksp("com.github.bumptech.glide:ksp:$glideVersion")
implementation("androidx.hilt:hilt-navigation-compose:$androidxHiltVersion")

implementation("com.google.dagger:hilt-android:$daggerHiltVersion")
implementation "androidx.appcompat:appcompat:$appcompatVersion"
Expand Down Expand Up @@ -305,7 +310,6 @@ dependencies {
implementation "com.squareup.okhttp3:okhttp:$okhttpVersion"
implementation "com.squareup.phrase:phrase:$phraseVersion"
implementation 'app.cash.copper:copper-flow:1.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion"
implementation "nl.komponents.kovenant:kovenant:$kovenantVersion"
implementation "nl.komponents.kovenant:kovenant-android:$kovenantVersion"
Expand All @@ -328,7 +332,6 @@ dependencies {
androidTestImplementation('com.adevinta.android:barista:4.2.0') {
exclude group: 'org.jetbrains.kotlin'
}

// AndroidJUnitRunner and JUnit Rules
androidTestImplementation 'androidx.test:runner:1.5.2'
androidTestImplementation 'androidx.test:rules:1.5.0'
Expand All @@ -347,6 +350,8 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-web:3.5.1'
androidTestImplementation 'androidx.test.espresso.idling:idling-concurrent:3.5.1'
androidTestImplementation 'androidx.test.espresso:espresso-idling-resource:3.5.1'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.5.3"
debugImplementation "androidx.compose.ui:ui-test-manifest:1.5.3"
androidTestUtil 'androidx.test:orchestrator:1.4.2'

testImplementation 'org.robolectric:robolectric:4.12.2'
Expand All @@ -370,6 +375,11 @@ dependencies {
androidTestImplementation "androidx.compose.ui:ui-test-junit4-android"
debugImplementation "androidx.compose.ui:ui-test-manifest"

// Navigation
implementation "androidx.navigation:navigation-fragment-ktx:$navVersion"
implementation "androidx.navigation:navigation-ui-ktx:$navVersion"
implementation "androidx.navigation:navigation-compose:$navVersion"

implementation "com.google.accompanist:accompanist-themeadapter-appcompat:0.33.1-alpha"
implementation "com.google.accompanist:accompanist-permissions:0.36.0"
implementation "com.google.accompanist:accompanist-drawablepainter:0.33.1-alpha"
Expand Down
3 changes: 3 additions & 0 deletions app/src/androidTest/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
<application>
<uses-library android:name="android.test.runner"
android:required="false" />

<activity android:name="androidx.activity.ComponentActivity"/>

</application>
</manifest>
143 changes: 143 additions & 0 deletions app/src/androidTest/java/network/loki/messenger/CreateGroupTests.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
package network.loki.messenger

import androidx.compose.ui.test.hasContentDescriptionExactly
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performTextInput
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import androidx.test.platform.app.InstrumentationRegistry
import org.hamcrest.CoreMatchers.*
import org.hamcrest.MatcherAssert.*
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.thoughtcrime.securesms.ApplicationContext
import org.thoughtcrime.securesms.groups.compose.CreateGroup
import org.thoughtcrime.securesms.groups.ViewState
import org.thoughtcrime.securesms.ui.theme.PreviewTheme

@RunWith(AndroidJUnit4::class)
@SmallTest
class CreateGroupTests {

@get:Rule
val composeTest = createComposeRule()

@Test
fun testNavigateToCreateGroup() {
val application = InstrumentationRegistry.getInstrumentation().targetContext.applicationContext as ApplicationContext
// Accessibility IDs
val nameDesc = application.getString(R.string.AccessibilityId_closed_group_edit_group_name)
val buttonDesc = application.getString(R.string.AccessibilityId_create_closed_group_create_button)

var backPressed = false
var closePressed = false

composeTest.setContent {
PreviewTheme {
CreateGroup(
viewState = ViewState.DEFAULT,
onBack = { backPressed = true },
onClose = { closePressed = true },
onContactItemClicked = {},
updateState = {}
)
}
}

with(composeTest) {
onNode(hasContentDescriptionExactly(nameDesc)).performTextInput("Name")
onNode(hasContentDescriptionExactly(buttonDesc)).performClick()
}

assertThat(backPressed, equalTo(false))
assertThat(closePressed, equalTo(false))

}

@Test
fun testFailToCreate() {
val application = InstrumentationRegistry.getInstrumentation().targetContext.applicationContext as ApplicationContext
// Accessibility IDs
val nameDesc = application.getString(R.string.AccessibilityId_closed_group_edit_group_name)
val buttonDesc = application.getString(R.string.AccessibilityId_create_closed_group_create_button)

var backPressed = false
var closePressed = false

composeTest.setContent {
PreviewTheme {
CreateGroup(
viewState = ViewState.DEFAULT,
onBack = { backPressed = true },
onClose = { closePressed = true },
updateState = {},
onContactItemClicked = {}
)
}
}
with(composeTest) {
onNode(hasContentDescriptionExactly(nameDesc)).performTextInput("")
onNode(hasContentDescriptionExactly(buttonDesc)).performClick()
}

assertThat(backPressed, equalTo(false))
assertThat(closePressed, equalTo(false))
}

@Test
fun testBackButton() {
val application = InstrumentationRegistry.getInstrumentation().targetContext.applicationContext as ApplicationContext
// Accessibility IDs
val backDesc = application.getString(R.string.new_conversation_dialog_back_button_content_description)

var backPressed = false

composeTest.setContent {
PreviewTheme {
CreateGroup(
viewState = ViewState.DEFAULT,
onBack = { backPressed = true },
onClose = {},
onContactItemClicked = {},
updateState = {}
)
}
}

with (composeTest) {
onNode(hasContentDescriptionExactly(backDesc)).performClick()
}

assertThat(backPressed, equalTo(true))
}

@Test
fun testCloseButton() {
val application = InstrumentationRegistry.getInstrumentation().targetContext.applicationContext as ApplicationContext
// Accessibility IDs
val closeDesc = application.getString(R.string.new_conversation_dialog_close_button_content_description)
var closePressed = false

composeTest.setContent {
PreviewTheme {
CreateGroup(
viewState = ViewState.DEFAULT,
onBack = { },
onClose = { closePressed = true },
onContactItemClicked = {},
updateState = {}
)
}
}

with (composeTest) {
onNode(hasContentDescriptionExactly(closeDesc)).performClick()
}

assertThat(closePressed, equalTo(true))
}


}
Loading