'The user protocol\'s connectionLost is only called when transport
underlying TLS is disconnected.'

def test_connectionLostOnlyAfterUnderlyingCloses(self):

    class LostProtocol(Protocol, ):
        disconnected = None
        def connectionLost(self, reason):
            self.disconnected = reason
    wrapperFactory = TLSMemoryBIOFactory(ClientTLSContext(), True, ClientFactory())
    protocol = LostProtocol()
    tlsProtocol = TLSMemoryBIOProtocol(wrapperFactory, protocol)
    transport = StringTransport()
    tlsProtocol.makeConnection(transport)
    tlsProtocol._tlsShutdownFinished(None)
    self.assertTrue(transport.disconnecting)
    self.assertIsNone(protocol.disconnected)
    tlsProtocol.connectionLost(Failure(ConnectionLost('ono')))
    self.assertTrue(protocol.disconnected.check(ConnectionLost))
    self.assertEqual(protocol.disconnected.value.args, ('ono',))
