tests/auto/qlocalsocket/lackey/scripts/client.js
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 19 Feb 2010 23:40:16 +0200
branchRCL_3
changeset 4 3b1da2848fc7
parent 0 1918ee327afb
permissions -rw-r--r--
Revision: 201003 Kit: 201007

#/bin/qscript
function QVERIFY(x, socket) {
    if (!(x)) {
        throw(socket.errorString());
    }
}

var socket = new QScriptLocalSocket;
var tries = 0;
do {
    socket.serverName = "qlocalsocket_autotest";
    if ((socket.errorString() != "QLocalSocket::connectToServer: Invalid name")
        && (socket.errorString() != "QLocalSocket::connectToServer: Connection refused"))
        break;
    socket.sleep(1);
    ++tries;
    print("isConnected:", socket.isConnected());
} while ((socket.errorString() == "QLocalSocket::connectToServer: Invalid name"
        || (socket.errorString() == "QlocalSocket::connectToServer: Connection refused"))
        && tries < 5000);
if (tries == 5000) {
    print("too many tries, exiting");
} else {
socket.waitForConnected();
//print("isConnected:", socket.isConnected());
if (!socket.isConnected())
    print("Not Connected:", socket.errorString());
socket.waitForReadyRead();
var text = socket.readLine();
var testLine = "test";
QVERIFY((text == testLine), socket);
QVERIFY((socket.errorString() == "Unknown error"), socket);
socket.close();
//print("client: exiting", text);
}