Skip to content

Commit

Permalink
Reorder
Browse files Browse the repository at this point in the history
  • Loading branch information
pyamsoft committed Nov 12, 2024
1 parent f783927 commit 26abdea
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 59 deletions.
75 changes: 38 additions & 37 deletions server/src/test/java/com/pyamsoft/tetherfi/server/ProxySetupTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,51 +16,52 @@

package com.pyamsoft.tetherfi.server

import kotlinx.coroutines.delay
import kotlin.test.Test
import kotlin.time.Duration.Companion.seconds
import kotlinx.coroutines.delay

class ProxySetupTest {

/**
* It works right?
*/
@Test
fun setupNormal(): Unit = runBlockingWithDelays {
setupProxy(
this,
isLoggingEnabled = true,
proxyPort = 5553,
) {
delay(5.seconds)
}
/** It works right? */
@Test
fun setupNormal(): Unit = runBlockingWithDelays {
setupProxy(
this,
isLoggingEnabled = true,
proxyPort = 5553,
) {
delay(5.seconds)
}
}

/** On files with lower memory like Android 7 or 8, sometimes opening the server
* socket crashes with Too Many Open Files. We want to catch the problem and show an error in the app, instead of having the app crash and die */
@Test
fun socketCreatorExceptionIsCaught(): Unit = runBlockingWithDelays {
setupProxy(
this,
isLoggingEnabled = true,
proxyPort = 5555,
testSocketCrash = true,
) {
delay(5.seconds)
}
/**
* On files with lower memory like Android 7 or 8, sometimes opening the server socket crashes
* with Too Many Open Files. We want to catch the problem and show an error in the app, instead of
* having the app crash and die
*/
@Test
fun socketCreatorExceptionIsCaught(): Unit = runBlockingWithDelays {
setupProxy(
this,
isLoggingEnabled = true,
proxyPort = 5555,
testSocketCrash = true,
) {
delay(5.seconds)
}
}

/** We also are prepared to handle when a socket fails to open right? */
@Test
fun yoloFailThrows(): Unit = runBlockingWithDelays {
setupProxy(
this,
isLoggingEnabled = true,
proxyPort = 5554,
expectServerFail = true,
appEnv = { updateYolo(true) },
) {
delay(5.seconds)
}
/** We also are prepared to handle when a socket fails to open right? */
@Test
fun yoloFailThrows(): Unit = runBlockingWithDelays {
setupProxy(
this,
isLoggingEnabled = true,
proxyPort = 5554,
expectServerFail = true,
appEnv = { updateYolo(true) },
) {
delay(5.seconds)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ internal fun LazyListScope.renderExpertSettings(
}

item(
contentType = ExpertSettingsContentTypes.POWER_BALANCE,
contentType = ExpertSettingsContentTypes.BROADCAST_TYPE,
) {
Card(
modifier = itemModifier.padding(bottom = MaterialTheme.keylines.content),
Expand All @@ -68,17 +68,18 @@ internal fun LazyListScope.renderExpertSettings(
),
shape = MaterialTheme.shapes.medium,
) {
PowerBalance(
modifier = Modifier.padding(MaterialTheme.keylines.content),
isEditable = isEditable,
BroadcastTypeSelection(
modifier = Modifier.padding(vertical = MaterialTheme.keylines.content),
serverViewState = serverViewState,
appName = appName,
onShowPowerBalance = onShowPowerBalance,
isEditable = isEditable,
onSelectBroadcastType = onSelectBroadcastType,
)
}
}

item(
contentType = ExpertSettingsContentTypes.SOCKET_TIMEOUT,
contentType = ExpertSettingsContentTypes.PREFERRED_NETWORK,
) {
Card(
modifier = itemModifier.padding(bottom = MaterialTheme.keylines.content),
Expand All @@ -89,17 +90,18 @@ internal fun LazyListScope.renderExpertSettings(
),
shape = MaterialTheme.shapes.medium,
) {
SocketTimeout(
modifier = Modifier.padding(MaterialTheme.keylines.content),
isEditable = isEditable,
PreferredNetworkSelection(
modifier = Modifier.padding(vertical = MaterialTheme.keylines.content),
serverViewState = serverViewState,
appName = appName,
onShowSocketTimeout = onShowSocketTimeout,
isEditable = isEditable,
onSelectPreferredNetwork = onSelectPreferredNetwork,
)
}
}

item(
contentType = ExpertSettingsContentTypes.BROADCAST_TYPE,
contentType = ExpertSettingsContentTypes.POWER_BALANCE,
) {
Card(
modifier = itemModifier.padding(bottom = MaterialTheme.keylines.content),
Expand All @@ -110,18 +112,17 @@ internal fun LazyListScope.renderExpertSettings(
),
shape = MaterialTheme.shapes.medium,
) {
BroadcastTypeSelection(
modifier = Modifier.padding(vertical = MaterialTheme.keylines.content),
serverViewState = serverViewState,
appName = appName,
PowerBalance(
modifier = Modifier.padding(MaterialTheme.keylines.content),
isEditable = isEditable,
onSelectBroadcastType = onSelectBroadcastType,
appName = appName,
onShowPowerBalance = onShowPowerBalance,
)
}
}

item(
contentType = ExpertSettingsContentTypes.PREFERRED_NETWORK,
contentType = ExpertSettingsContentTypes.SOCKET_TIMEOUT,
) {
Card(
modifier = itemModifier.padding(bottom = MaterialTheme.keylines.content),
Expand All @@ -132,12 +133,11 @@ internal fun LazyListScope.renderExpertSettings(
),
shape = MaterialTheme.shapes.medium,
) {
PreferredNetworkSelection(
modifier = Modifier.padding(vertical = MaterialTheme.keylines.content),
serverViewState = serverViewState,
appName = appName,
SocketTimeout(
modifier = Modifier.padding(MaterialTheme.keylines.content),
isEditable = isEditable,
onSelectPreferredNetwork = onSelectPreferredNetwork,
appName = appName,
onShowSocketTimeout = onShowSocketTimeout,
)
}
}
Expand Down

0 comments on commit 26abdea

Please sign in to comment.