From bb554c7f1ec8d12d2a7fc8e569b0767526534de4 Mon Sep 17 00:00:00 2001 From: ialokim <ialokim@mailbox.org> Date: Mon, 19 Dec 2022 19:16:14 +0100 Subject: [PATCH] address review feedback --- .idea/compiler.xml | 1 + briar-desktop/build.gradle.kts | 7 +++-- .../briar/desktop/ScreenshotTest.kt | 26 ++++++++++++------- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/.idea/compiler.xml b/.idea/compiler.xml index a052e5d798..2c7f19a61a 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -39,6 +39,7 @@ </profile> </annotationProcessing> <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.test" target="17" /> </bytecodeTargetLevel> diff --git a/briar-desktop/build.gradle.kts b/briar-desktop/build.gradle.kts index 0a3d572e29..e4a5843bd4 100644 --- a/briar-desktop/build.gradle.kts +++ b/briar-desktop/build.gradle.kts @@ -141,10 +141,13 @@ tasks.test { // see https://docs.gradle.org/current/userguide/java_testing.html#sec:configuring_java_integration_tests sourceSets.create("automatedScreenshots") { + group = "verification" + description = "Create screenshots of the app." + kotlin.srcDir("$projectDir/src/automatedScreenshots/kotlin") resources.srcDir("$projectDir/src/automatedScreenshots/resources") - compileClasspath += sourceSets.main.get().output + sourceSets.test.get().output - runtimeClasspath += sourceSets.main.get().output + sourceSets.test.get().output + compileClasspath += currentOs + sourceSets.main.get().output + sourceSets.test.get().output + runtimeClasspath += currentOs + sourceSets.main.get().output + sourceSets.test.get().output } configurations["automatedScreenshotsImplementation"].extendsFrom(configurations.testImplementation.get()) diff --git a/briar-desktop/src/automatedScreenshots/kotlin/org/briarproject/briar/desktop/ScreenshotTest.kt b/briar-desktop/src/automatedScreenshots/kotlin/org/briarproject/briar/desktop/ScreenshotTest.kt index 4b2c8a3b8f..2deeab1cd8 100644 --- a/briar-desktop/src/automatedScreenshots/kotlin/org/briarproject/briar/desktop/ScreenshotTest.kt +++ b/briar-desktop/src/automatedScreenshots/kotlin/org/briarproject/briar/desktop/ScreenshotTest.kt @@ -16,8 +16,9 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -// TODO: Remove when https://youtrack.jetbrains.com/issue/KTIJ-23114/ is fixed. -@file:Suppress("invisible_reference", "invisible_member") +// TODO: Remove `invisible_reference` and `invisible_member` +// when https://youtrack.jetbrains.com/issue/KTIJ-23114/ is fixed. +@file:Suppress("invisible_reference", "invisible_member", "nls") package org.briarproject.briar.desktop @@ -34,11 +35,10 @@ import androidx.compose.ui.test.runDesktopComposeUiTest import androidx.compose.ui.window.FrameWindowScope import kotlinx.coroutines.delay import kotlinx.coroutines.runBlocking +import org.apache.commons.io.FileUtils.deleteDirectory import org.briarproject.bramble.BrambleCoreEagerSingletons import org.briarproject.bramble.api.contact.event.ContactAddedEvent 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.desktop.TestUtils.getDataDir import org.briarproject.briar.desktop.contact.ContactListViewModel @@ -58,14 +58,20 @@ class ScreenshotTest { val dataDir = getDataDir() val app = DaggerBriarDesktopTestApp.builder().desktopCoreModule( - DesktopCoreModule(dataDir, DEFAULT_SOCKS_PORT, DEFAULT_CONTROL_PORT) + DesktopCoreModule(dataDir) ).build() + + app.getShutdownManager().addShutdownHook { + deleteDirectory(dataDir.toFile()) + } + // We need to load the eager singletons directly after making the // dependency graphs BrambleCoreEagerSingletons.Helper.injectEagerSingletons(app) BriarCoreEagerSingletons.Helper.injectEagerSingletons(app) val windowScope = object : FrameWindowScope { + // would be needed for launching dialogs like the image picker override val window: ComposeWindow get() = TODO() } val windowFocusState = WindowFocusState().apply { focused = true } @@ -112,7 +118,7 @@ class ScreenshotTest { getEventBus().addListener { e -> 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 { getConnectionRegistry().registerIncomingConnection(e.contactId, LanTcpConstants.ID) {} } @@ -120,18 +126,18 @@ class ScreenshotTest { getDeterministicTestDataCreator().createTestData(5, 20, 50, 10, 20) getContactManager().addPendingContact( - "briar://aatkjq4seoualafpwh4cfckdzr4vpr4slk3bbvpxklf7y7lv4ajw6", // NON-NLS - "Faythe" // NON-NLS + "briar://aatkjq4seoualafpwh4cfckdzr4vpr4slk3bbvpxklf7y7lv4ajw6", + "Faythe" ) val viewModel = getViewModelProvider().get(ContactListViewModel::class) // give IO executor some time to add contacts and messages 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 - viewModel.selectContact(viewModel.contactList.value[1]) + viewModel.selectContact(viewModel.combinedContactList.value[1]) awaitIdle() captureToImage().save("contact-list.png") -- GitLab