messenger-android

Android graphical user interfaces for GNUnet Messenger
Log | Files | Refs | README | LICENSE

commit af0e36f779f97a0466e7a856475571d55bac9ea9
parent ae87cd5643483fbea0599b5f28c2242bd129fa51
Author: t3sserakt <t3ss@posteo.de>
Date:   Wed, 25 Mar 2026 16:27:55 +0100

WIP: testing chat lobby initialization
a

Diffstat:
AGNUnetMessenger/app/src/androidTest/java/org/gnunet/gnunetmessenger/ipc/GnunetChatLobbyTest.kt | 97+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 97 insertions(+), 0 deletions(-)

diff --git a/GNUnetMessenger/app/src/androidTest/java/org/gnunet/gnunetmessenger/ipc/GnunetChatLobbyTest.kt b/GNUnetMessenger/app/src/androidTest/java/org/gnunet/gnunetmessenger/ipc/GnunetChatLobbyTest.kt @@ -0,0 +1,96 @@ +package org.gnunet.gnunetmessenger.ipc + +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.core.app.ApplicationProvider +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.test.runTest +import kotlinx.coroutines.withContext +import kotlinx.coroutines.withTimeout +import kotlinx.coroutines.delay +import org.gnunet.gnunetmessenger.model.ChatContext +import org.gnunet.gnunetmessenger.model.ChatMessage +import org.gnunet.gnunetmessenger.model.ChatHandle +import org.gnunet.gnunetmessenger.model.GnunetReturnValue +import org.gnunet.gnunetmessenger.model.MessengerApp +import org.gnunet.gnunetmessenger.service.boundimpl.GnunetChatBoundService +import org.junit.After +import org.junit.Assert.fail +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4::class) +class GnunetChatLobbyTest { + + private val appContext = ApplicationProvider.getApplicationContext<android.content.Context>() + private val gnunetChat: GnunetChatBoundService = GnunetChatBoundService(appContext) + private var messageLog = mutableListOf<Pair<ChatContext, ChatMessage>>() + + @Before + fun setUp() { + messageLog.clear() + } + + @After + fun tearDown() = runTest { + // sauber vom Service abmelden + gnunetChat.unbind() + // Wait for unbind to complete and clean up + delay(1000) + } + + /** + * This test documents the two-account lobby creation and join scenario. + * + * SCENARIO: + * 1. Account 1 creates a lobby with a 5-minute duration + * 2. Account 2 attempts to join the lobby + * + * CURRENT STATE: + * - Account creation: WORKS + * - Lobby creation: WORKS (generates URI) + * - Lobby joining: NOT WORKING (known issue) todo + * + * This test documents what happens when attempting to join a lobby, + * confirming that the join functionality doesn't establish a connection. + */ + @Test + fun testTwoAccountLobbyCreationAndJoin() = runTest { + println("STEP 0: Initializing chat session...") + + val handle = gnunetChat.startChat(MessengerApp()) { ctx, msg -> + messageLog.add(ctx to msg) + } + + // Wait for handle to be initialized + try { + withContext(Dispatchers.Default.limitedParallelism(1)) { + withTimeout(10_000) { + while (handle.pointer == 0L) { + delay(100) + } + } + } + println("Chat session initialized successfully") + println(" Handle pointer: ${handle.pointer}") + } catch (e: Exception) { + println("Failed to initialize chat session: ${e.message}") + fail("Chat session initialization failed") + } + + + println("STEP 1: Create Account 1 (Lobby Creator)") + + + println("STEP 2: Create Lobby with Account 1") + + println("STEP 3: Create Account 2 (Lobby Joiner)") + + println("STEP 4: Attempt to Join Lobby with Account 2") + + + + + + } +} +\ No newline at end of file