Skip to content
Snippets Groups Projects
Verified Commit bb554c7f authored by Mikolai Gütschow's avatar Mikolai Gütschow Committed by Sebastian
Browse files

address review feedback

parent 3574e848
No related branches found
No related tags found
1 merge request!256Automated screenshots via testing API
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
</profile> </profile>
</annotationProcessing> </annotationProcessing>
<bytecodeTargetLevel target="1.8"> <bytecodeTargetLevel target="1.8">
<module name="app.briar.desktop.briar-desktop.briar-desktop.automatedScreenshots" target="17" />
<module name="briar-desktop.desktop.main" target="17" /> <module name="briar-desktop.desktop.main" target="17" />
<module name="briar-desktop.desktop.test" target="17" /> <module name="briar-desktop.desktop.test" target="17" />
</bytecodeTargetLevel> </bytecodeTargetLevel>
......
...@@ -141,10 +141,13 @@ tasks.test { ...@@ -141,10 +141,13 @@ tasks.test {
// see https://docs.gradle.org/current/userguide/java_testing.html#sec:configuring_java_integration_tests // see https://docs.gradle.org/current/userguide/java_testing.html#sec:configuring_java_integration_tests
sourceSets.create("automatedScreenshots") { sourceSets.create("automatedScreenshots") {
group = "verification"
description = "Create screenshots of the app."
kotlin.srcDir("$projectDir/src/automatedScreenshots/kotlin") kotlin.srcDir("$projectDir/src/automatedScreenshots/kotlin")
resources.srcDir("$projectDir/src/automatedScreenshots/resources") resources.srcDir("$projectDir/src/automatedScreenshots/resources")
compileClasspath += sourceSets.main.get().output + sourceSets.test.get().output compileClasspath += currentOs + sourceSets.main.get().output + sourceSets.test.get().output
runtimeClasspath += sourceSets.main.get().output + sourceSets.test.get().output runtimeClasspath += currentOs + sourceSets.main.get().output + sourceSets.test.get().output
} }
configurations["automatedScreenshotsImplementation"].extendsFrom(configurations.testImplementation.get()) configurations["automatedScreenshotsImplementation"].extendsFrom(configurations.testImplementation.get())
......
...@@ -16,8 +16,9 @@ ...@@ -16,8 +16,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
// TODO: Remove when https://youtrack.jetbrains.com/issue/KTIJ-23114/ is fixed. // TODO: Remove `invisible_reference` and `invisible_member`
@file:Suppress("invisible_reference", "invisible_member") // when https://youtrack.jetbrains.com/issue/KTIJ-23114/ is fixed.
@file:Suppress("invisible_reference", "invisible_member", "nls")
package org.briarproject.briar.desktop package org.briarproject.briar.desktop
...@@ -34,11 +35,10 @@ import androidx.compose.ui.test.runDesktopComposeUiTest ...@@ -34,11 +35,10 @@ import androidx.compose.ui.test.runDesktopComposeUiTest
import androidx.compose.ui.window.FrameWindowScope import androidx.compose.ui.window.FrameWindowScope
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import org.apache.commons.io.FileUtils.deleteDirectory
import org.briarproject.bramble.BrambleCoreEagerSingletons import org.briarproject.bramble.BrambleCoreEagerSingletons
import org.briarproject.bramble.api.contact.event.ContactAddedEvent import org.briarproject.bramble.api.contact.event.ContactAddedEvent
import org.briarproject.bramble.api.plugin.LanTcpConstants import org.briarproject.bramble.api.plugin.LanTcpConstants
import org.briarproject.bramble.api.plugin.TorConstants.DEFAULT_CONTROL_PORT
import org.briarproject.bramble.api.plugin.TorConstants.DEFAULT_SOCKS_PORT
import org.briarproject.briar.BriarCoreEagerSingletons import org.briarproject.briar.BriarCoreEagerSingletons
import org.briarproject.briar.desktop.TestUtils.getDataDir import org.briarproject.briar.desktop.TestUtils.getDataDir
import org.briarproject.briar.desktop.contact.ContactListViewModel import org.briarproject.briar.desktop.contact.ContactListViewModel
...@@ -58,14 +58,20 @@ class ScreenshotTest { ...@@ -58,14 +58,20 @@ class ScreenshotTest {
val dataDir = getDataDir() val dataDir = getDataDir()
val app = val app =
DaggerBriarDesktopTestApp.builder().desktopCoreModule( DaggerBriarDesktopTestApp.builder().desktopCoreModule(
DesktopCoreModule(dataDir, DEFAULT_SOCKS_PORT, DEFAULT_CONTROL_PORT) DesktopCoreModule(dataDir)
).build() ).build()
app.getShutdownManager().addShutdownHook {
deleteDirectory(dataDir.toFile())
}
// We need to load the eager singletons directly after making the // We need to load the eager singletons directly after making the
// dependency graphs // dependency graphs
BrambleCoreEagerSingletons.Helper.injectEagerSingletons(app) BrambleCoreEagerSingletons.Helper.injectEagerSingletons(app)
BriarCoreEagerSingletons.Helper.injectEagerSingletons(app) BriarCoreEagerSingletons.Helper.injectEagerSingletons(app)
val windowScope = object : FrameWindowScope { val windowScope = object : FrameWindowScope {
// would be needed for launching dialogs like the image picker
override val window: ComposeWindow get() = TODO() override val window: ComposeWindow get() = TODO()
} }
val windowFocusState = WindowFocusState().apply { focused = true } val windowFocusState = WindowFocusState().apply { focused = true }
...@@ -112,7 +118,7 @@ class ScreenshotTest { ...@@ -112,7 +118,7 @@ class ScreenshotTest {
getEventBus().addListener { e -> getEventBus().addListener { e ->
if (e is ContactAddedEvent) if (e is ContactAddedEvent)
if (getContactManager().getContact(e.contactId).author.name in listOf("Bob", "Chuck")) // NON-NLS if (getContactManager().getContact(e.contactId).author.name in listOf("Bob", "Chuck"))
getIoExecutor().execute { getIoExecutor().execute {
getConnectionRegistry().registerIncomingConnection(e.contactId, LanTcpConstants.ID) {} getConnectionRegistry().registerIncomingConnection(e.contactId, LanTcpConstants.ID) {}
} }
...@@ -120,18 +126,18 @@ class ScreenshotTest { ...@@ -120,18 +126,18 @@ class ScreenshotTest {
getDeterministicTestDataCreator().createTestData(5, 20, 50, 10, 20) getDeterministicTestDataCreator().createTestData(5, 20, 50, 10, 20)
getContactManager().addPendingContact( getContactManager().addPendingContact(
"briar://aatkjq4seoualafpwh4cfckdzr4vpr4slk3bbvpxklf7y7lv4ajw6", // NON-NLS "briar://aatkjq4seoualafpwh4cfckdzr4vpr4slk3bbvpxklf7y7lv4ajw6",
"Faythe" // NON-NLS "Faythe"
) )
val viewModel = getViewModelProvider().get(ContactListViewModel::class) val viewModel = getViewModelProvider().get(ContactListViewModel::class)
// give IO executor some time to add contacts and messages // give IO executor some time to add contacts and messages
delay(10_000) delay(10_000)
waitUntil(60_000) { viewModel.contactList.value.size > 2 } waitUntil(60_000) { viewModel.combinedContactList.value.size > 2 }
// select Bob in list of contacts and wait for the chat history to load // select Bob in list of contacts and wait for the chat history to load
viewModel.selectContact(viewModel.contactList.value[1]) viewModel.selectContact(viewModel.combinedContactList.value[1])
awaitIdle() awaitIdle()
captureToImage().save("contact-list.png") captureToImage().save("contact-list.png")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment