mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 00:37:47 +00:00
Fix HomeActivityTests
This commit is contained in:
parent
d083b19a12
commit
92c2d574ae
@ -363,14 +363,16 @@ dependencies {
|
||||
implementation 'androidx.compose.ui:ui:1.6.2'
|
||||
implementation 'androidx.compose.animation:animation:1.6.2'
|
||||
implementation 'androidx.compose.ui:ui-tooling:1.6.2'
|
||||
implementation "androidx.compose.runtime:runtime-livedata:1.6.2"
|
||||
implementation 'androidx.compose.foundation:foundation-layout:1.6.2'
|
||||
implementation 'androidx.compose.material:material:1.6.2'
|
||||
androidTestImplementation 'androidx.compose.ui:ui-test-junit4-android:1.6.2'
|
||||
debugImplementation 'androidx.compose.ui:ui-test-manifest:1.6.2'
|
||||
|
||||
implementation "com.google.accompanist:accompanist-themeadapter-appcompat:0.33.1-alpha"
|
||||
implementation "com.google.accompanist:accompanist-pager:0.33.1-alpha"
|
||||
implementation "com.google.accompanist:accompanist-pager-indicators:0.33.1-alpha"
|
||||
implementation "com.google.accompanist:accompanist-permissions:0.33.1-alpha"
|
||||
implementation "androidx.compose.runtime:runtime-livedata:1.6.2"
|
||||
|
||||
implementation 'androidx.compose.foundation:foundation-layout:1.6.2'
|
||||
implementation 'androidx.compose.material:material:1.6.2'
|
||||
|
||||
implementation "androidx.camera:camera-camera2:1.3.1"
|
||||
implementation "androidx.camera:camera-lifecycle:1.3.1"
|
||||
|
@ -22,6 +22,8 @@ import androidx.test.ext.junit.rules.ActivityScenarioRule
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.LargeTest
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.uiautomator.By
|
||||
import androidx.test.uiautomator.UiDevice
|
||||
import com.adevinta.android.barista.interaction.PermissionGranter
|
||||
import network.loki.messenger.util.InputBarButtonDrawableMatcher.Companion.inputButtonWithDrawable
|
||||
import org.hamcrest.Matcher
|
||||
@ -49,9 +51,14 @@ class HomeActivityTests {
|
||||
|
||||
private val activityMonitor = Instrumentation.ActivityMonitor(ConversationActivityV2::class.java.name, null, false)
|
||||
|
||||
private val device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
||||
|
||||
private val context = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
InstrumentationRegistry.getInstrumentation().addMonitor(activityMonitor)
|
||||
|
||||
}
|
||||
|
||||
@After
|
||||
@ -72,25 +79,34 @@ class HomeActivityTests {
|
||||
onView(isRoot()).perform(waitFor(500))
|
||||
}
|
||||
|
||||
private fun objectFromDesc(id: Int) = device.findObject(By.desc(context.getString(id)))
|
||||
|
||||
private fun setupLoggedInState(hasViewedSeed: Boolean = false) {
|
||||
// landing activity
|
||||
onView(withId(R.id.registerButton)).perform(ViewActions.click())
|
||||
// session ID - register activity
|
||||
onView(withId(R.id.registerButton)).perform(ViewActions.click())
|
||||
objectFromDesc(R.string.onboardingAccountCreate).click()
|
||||
|
||||
// display name selection
|
||||
onView(withId(R.id.displayNameEditText)).perform(ViewActions.typeText("test-user123"))
|
||||
onView(withId(R.id.registerButton)).perform(ViewActions.click())
|
||||
objectFromDesc(R.string.displayNameEnter).click()
|
||||
device.pressKeyCode(28)
|
||||
device.pressKeyCode(29)
|
||||
device.pressKeyCode(30)
|
||||
|
||||
// Continue with display name
|
||||
objectFromDesc(R.string.continue_2).click()
|
||||
|
||||
// Continue with default push notification setting
|
||||
objectFromDesc(R.string.continue_2).click()
|
||||
|
||||
// PN select
|
||||
if (hasViewedSeed) {
|
||||
// has viewed seed is set to false after register activity
|
||||
TextSecurePreferences.setHasViewedSeed(InstrumentationRegistry.getInstrumentation().targetContext, true)
|
||||
}
|
||||
onView(withId(R.id.backgroundPollingOptionView)).perform(ViewActions.click())
|
||||
onView(withId(R.id.registerButton)).perform(ViewActions.click())
|
||||
// allow notification permission
|
||||
PermissionGranter.allowPermissionsIfNeeded(Manifest.permission.POST_NOTIFICATIONS)
|
||||
}
|
||||
|
||||
|
||||
private fun goToMyChat() {
|
||||
onView(withId(R.id.newConversationButton)).perform(ViewActions.click())
|
||||
onView(withId(R.id.createPrivateChatButton)).perform(ViewActions.click())
|
||||
@ -111,8 +127,8 @@ class HomeActivityTests {
|
||||
@Test
|
||||
fun testLaunches_dismiss_seedView() {
|
||||
setupLoggedInState()
|
||||
onView(allOf(withId(R.id.button), isDescendantOfA(withId(R.id.seedReminderView)))).perform(ViewActions.click())
|
||||
onView(withId(R.id.copyButton)).perform(ViewActions.click())
|
||||
objectFromDesc(R.string.continue_2).click()
|
||||
objectFromDesc(R.string.copy).click()
|
||||
pressBack()
|
||||
onView(withId(R.id.seedReminderView)).check(matches(not(isDisplayed())))
|
||||
}
|
||||
@ -133,7 +149,7 @@ class HomeActivityTests {
|
||||
fun testChat_withSelf() {
|
||||
setupLoggedInState()
|
||||
goToMyChat()
|
||||
TextSecurePreferences.setLinkPreviewsEnabled(InstrumentationRegistry.getInstrumentation().targetContext, true)
|
||||
TextSecurePreferences.setLinkPreviewsEnabled(context, true)
|
||||
sendMessage("howdy")
|
||||
sendMessage("test")
|
||||
// tests url rewriter doesn't crash
|
||||
|
@ -103,6 +103,7 @@ import org.thoughtcrime.securesms.ui.OutlineButton
|
||||
import org.thoughtcrime.securesms.ui.PreviewTheme
|
||||
import org.thoughtcrime.securesms.ui.SessionShieldIcon
|
||||
import org.thoughtcrime.securesms.ui.ThemeResPreviewParameterProvider
|
||||
import org.thoughtcrime.securesms.ui.contentDescription
|
||||
import org.thoughtcrime.securesms.ui.h8
|
||||
import org.thoughtcrime.securesms.ui.small
|
||||
import org.thoughtcrime.securesms.util.ConfigurationMessageUtilities
|
||||
|
@ -36,6 +36,7 @@ import org.thoughtcrime.securesms.ui.BorderlessButton
|
||||
import org.thoughtcrime.securesms.ui.FilledButton
|
||||
import org.thoughtcrime.securesms.ui.OutlineButton
|
||||
import org.thoughtcrime.securesms.ui.classicDarkColors
|
||||
import org.thoughtcrime.securesms.ui.contentDescription
|
||||
import org.thoughtcrime.securesms.ui.session_accent
|
||||
import org.thoughtcrime.securesms.util.setUpActionBarSessionLogo
|
||||
|
||||
@ -77,9 +78,11 @@ class LandingActivity : BaseActionBarActivity() {
|
||||
OutgoingText(stringResource(R.string.onboardingBubbleCreatingAnAccountIsEasy))
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
|
||||
OutlineButton(text = stringResource(R.string.onboardingAccountCreate), modifier = Modifier
|
||||
.width(262.dp)
|
||||
.align(Alignment.CenterHorizontally)) { startPickDisplayNameActivity() }
|
||||
OutlineButton(
|
||||
text = stringResource(R.string.onboardingAccountCreate),
|
||||
modifier = Modifier
|
||||
.width(262.dp)
|
||||
.align(Alignment.CenterHorizontally)) { startPickDisplayNameActivity() }
|
||||
Spacer(modifier = Modifier.height(14.dp))
|
||||
FilledButton(text = stringResource(R.string.onboardingAccountExists), modifier = Modifier
|
||||
.width(262.dp)
|
||||
|
@ -22,8 +22,8 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.ComposeView
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
@ -38,8 +38,7 @@ import org.thoughtcrime.securesms.ui.OutlineButton
|
||||
import org.thoughtcrime.securesms.ui.PreviewTheme
|
||||
import org.thoughtcrime.securesms.ui.base
|
||||
import org.thoughtcrime.securesms.ui.baseBold
|
||||
import org.thoughtcrime.securesms.ui.classicDark3
|
||||
import org.thoughtcrime.securesms.ui.colorDestructive
|
||||
import org.thoughtcrime.securesms.ui.contentDescription
|
||||
import org.thoughtcrime.securesms.ui.outlinedTextFieldColors
|
||||
import org.thoughtcrime.securesms.util.setUpActionBarSessionLogo
|
||||
import javax.inject.Inject
|
||||
@ -106,6 +105,7 @@ class PickDisplayNameActivity : BaseActionBarActivity() {
|
||||
|
||||
OutlinedTextField(
|
||||
value = state.displayName,
|
||||
modifier = Modifier.contentDescription(R.string.displayNameEnter),
|
||||
onValueChange = { onChange(it) },
|
||||
placeholder = { Text(stringResource(R.string.displayNameEnter)) },
|
||||
colors = outlinedTextFieldColors(state.error != null),
|
||||
|
@ -71,7 +71,7 @@ fun OutlineButton(
|
||||
onClick: () -> Unit
|
||||
) {
|
||||
OutlinedButton(
|
||||
modifier = modifier,
|
||||
modifier = modifier.contentDescription(GetString(text)),
|
||||
onClick = onClick,
|
||||
border = BorderStroke(1.dp, color),
|
||||
shape = RoundedCornerShape(50), // = 50% percent
|
||||
@ -262,6 +262,12 @@ fun Modifier.contentDescription(text: GetString?): Modifier {
|
||||
return text?.let { semantics { contentDescription = it(context) } } ?: this
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun Modifier.contentDescription(id: Int?): Modifier {
|
||||
val context = LocalContext.current
|
||||
return id?.let { semantics { contentDescription = context.getString(it) } } ?: this
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun OutlineButton(text: GetString, contentDescription: GetString? = text, modifier: Modifier = Modifier, onClick: () -> Unit) {
|
||||
OutlinedButton(
|
||||
|
@ -16,7 +16,7 @@ android.enableJetifier=true
|
||||
org.gradle.jvmargs=-Xmx2048M -Dkotlin.daemon.jvm.options\="-Xmx2048M"
|
||||
org.gradle.unsafe.configuration-cache=true
|
||||
|
||||
gradlePluginVersion=7.4.2
|
||||
gradlePluginVersion=7.3.1
|
||||
googleServicesVersion=4.3.12
|
||||
kotlinVersion=1.8.21
|
||||
android.useAndroidX=true
|
||||
|
Loading…
x
Reference in New Issue
Block a user