Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e99a4e13 authored by Pomai Ahlo's avatar Pomai Ahlo
Browse files

use createAndConnectSocket in connect tests

Bug: 331415222
Test: atest RfcommTest
Flag: TEST_ONLY
Change-Id: I423fd6121b2aab4f3edece3cbc9090837f808727
parent 61572594
Loading
Loading
Loading
Loading
+2 −27
Original line number Diff line number Diff line
@@ -164,20 +164,7 @@ class RfcommTest {
        startServer { serverId ->
            runBlocking { withTimeout(BOND_TIMEOUT.toMillis()) { bondDevice(mBumbleDevice) } }

            // Insecure connection to RFCOMM Server
            val insecureSocket =
                mBumbleDevice.createInsecureRfcommSocketToServiceRecord(UUID.fromString(TEST_UUID))
            insecureSocket.connect()

            val connectionResponse =
                mBumble
                    .rfcommBlocking()
                    .withDeadlineAfter(GRPC_TIMEOUT.toMillis(), TimeUnit.MILLISECONDS)
                    .acceptConnection(
                        RfcommProto.AcceptConnectionRequest.newBuilder().setServer(serverId).build()
                    )
            Truth.assertThat(connectionResponse.connection.id).isEqualTo(mConnectionCounter)
            Truth.assertThat(insecureSocket.isConnected).isTrue()
            createAndConnectSocket(isSecure = false, serverId)
        }
    }

@@ -185,20 +172,8 @@ class RfcommTest {
    fun clientConnectToOpenServerSocketBondedSecure() {
        startServer { serverId ->
            runBlocking { withTimeout(BOND_TIMEOUT.toMillis()) { bondDevice(mBumbleDevice) } }
            // Secure connection to RFCOMM Server
            val secureSocket =
                mBumbleDevice.createRfcommSocketToServiceRecord(UUID.fromString(TEST_UUID))
            secureSocket.connect()

            val connectionResponse =
                mBumble
                    .rfcommBlocking()
                    .withDeadlineAfter(GRPC_TIMEOUT.toMillis(), TimeUnit.MILLISECONDS)
                    .acceptConnection(
                        RfcommProto.AcceptConnectionRequest.newBuilder().setServer(serverId).build()
                    )
            Truth.assertThat(connectionResponse.connection.id).isEqualTo(mConnectionCounter)
            Truth.assertThat(secureSocket.isConnected).isTrue()
            createAndConnectSocket(isSecure = true, serverId)
        }
    }