1 #include "locktestclient.h"
8 LockTestClient::LockTestClient(QObject *parent)
14 LockTestClient::~LockTestClient()
18 void LockTestClient::startTests()
21 socket.connectToHost ( "localhost", 55555);
24 #define GetNextCommand() if(socket.waitForReadyRead (-1) )\
26 if(socket.bytesAvailable() > 1)\
27 qDebug()<<"Something is wrong here";\
28 socket.getChar(&control);\
31 socket.disconnectFromHost();\
36 qDebug()<<"Wrong control command";\
40 if(socket.waitForConnected (-1))
42 QFile file("lock.file");
44 if(!file.open(QIODevice::ReadWrite))
46 qDebug()<<"Could not open lockfile";
53 //Trying to readlock the same region
54 QxtFileLock lock(&file,0x10,20,QxtFileLock::ReadLock);
56 socket.putChar('s'); //s for success f for fail
59 socket.waitForBytesWritten(-1);
65 //Trying to lock the same region with different locks
66 QxtFileLock lock(&file,0x10,20,QxtFileLock::WriteLock);
69 socket.putChar('s'); //s for success f for fail
72 socket.waitForBytesWritten(-1);
78 //Trying to writelock the same region
79 QxtFileLock lock(&file,0x10,20,QxtFileLock::WriteLock);
82 socket.putChar('s'); //s for success f for fail
85 socket.waitForBytesWritten(-1);
91 //Trying to writelock different regions
92 QxtFileLock lock(&file,0x10+21,20,QxtFileLock::WriteLock);
95 socket.putChar('s'); //s for success f for fail
98 socket.waitForBytesWritten(-1);