#include "udp_loss_test.h"

int main(int argc, char *argv[])
{
	QCoreApplication a(argc, argv);
	//Start Sending
	sendingThread * tsend = new sendingThread;
	tsend->start(QThread::HighestPriority);
	QThread::msleep(3000);
	printf("Start...\n");

	//test UDP loop
	int total_loop = test_Loop();
	printf("QUdpSocket LOOP:\n\tSend %d, Recv %d, Lost %d.\n",
							   total_loop,tests,total_loop-tests );

	QThread::msleep(3000);
	printf("Start...\n");

	//test Class
	QThread * trecv = new QThread;
	TestObj * sobj = new TestObj;
	sobj->moveToThread(trecv);
	trecv->start();
	sobj->start();
	trecv->wait();
	sobj->deleteLater();
	trecv->deleteLater();
	const int totaltest_ss = sobj->endID()-sobj->startID()+1;
	printf("QUdpSocket Signal and Slots:\n\tSend %d, Recv %d, Lost %d.\n",
							   totaltest_ss,
							   tests,
							   totaltest_ss-tests );

	QThread::msleep(3000);
	printf("Start...\n");

	//Test Local
	const int local_total = local_test();
	printf("Local Socket :\n\tSend %d, Recv %d, Lost %d.\n",
							   local_total,
							   tests,
							   local_total-tests );
	//end
	tsend->stop();
	tsend->wait();
	tsend->deleteLater();
	QCoreApplication::processEvents();
	getchar();
	return 0;
}