tests/auto/qlocalsocket/lackey/scripts/client.js
changeset 0 1918ee327afb
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 #/bin/qscript
       
     2 function QVERIFY(x, socket) {
       
     3     if (!(x)) {
       
     4         throw(socket.errorString());
       
     5     }
       
     6 }
       
     7 
       
     8 var socket = new QScriptLocalSocket;
       
     9 var tries = 0;
       
    10 do {
       
    11     socket.serverName = "qlocalsocket_autotest";
       
    12     if ((socket.errorString() != "QLocalSocket::connectToServer: Invalid name")
       
    13         && (socket.errorString() != "QLocalSocket::connectToServer: Connection refused"))
       
    14         break;
       
    15     socket.sleep(1);
       
    16     ++tries;
       
    17     print("isConnected:", socket.isConnected());
       
    18 } while ((socket.errorString() == "QLocalSocket::connectToServer: Invalid name"
       
    19         || (socket.errorString() == "QlocalSocket::connectToServer: Connection refused"))
       
    20         && tries < 5000);
       
    21 if (tries == 5000) {
       
    22     print("too many tries, exiting");
       
    23 } else {
       
    24 socket.waitForConnected();
       
    25 //print("isConnected:", socket.isConnected());
       
    26 if (!socket.isConnected())
       
    27     print("Not Connected:", socket.errorString());
       
    28 socket.waitForReadyRead();
       
    29 var text = socket.readLine();
       
    30 var testLine = "test";
       
    31 QVERIFY((text == testLine), socket);
       
    32 QVERIFY((socket.errorString() == "Unknown error"), socket);
       
    33 socket.close();
       
    34 //print("client: exiting", text);
       
    35 }