mirror of
https://github.com/QuasarApp/Snake.git
synced 2025-04-29 11:14:40 +00:00
fix tests ports
This commit is contained in:
parent
e26f933b3a
commit
d929bc842a
@ -80,12 +80,12 @@ void Client::incommingData() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Client::Client(QObject *ptr):
|
Client::Client(const QString &addrress, unsigned short port, QObject *ptr):
|
||||||
QObject (ptr) {
|
QObject (ptr) {
|
||||||
|
|
||||||
_destination = new QTcpSocket(this);
|
_destination = new QTcpSocket(this);
|
||||||
|
|
||||||
_destination->connectToHost(DEFAULT_SNAKE_SERVER, DEFAULT_SNAKE_PORT);
|
_destination->connectToHost(addrress, port);
|
||||||
|
|
||||||
connect(_destination, &QTcpSocket::readyRead,
|
connect(_destination, &QTcpSocket::readyRead,
|
||||||
this, &Client::incommingData);
|
this, &Client::incommingData);
|
||||||
|
@ -36,7 +36,9 @@ private slots:
|
|||||||
void incommingData();
|
void incommingData();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Client(QObject * ptr = nullptr);
|
explicit Client(const QString& addrress = LOCAL_SNAKE_SERVER,
|
||||||
|
unsigned short port = DEFAULT_SNAKE_PORT,
|
||||||
|
QObject * ptr = nullptr);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#ifndef CONFIG_H
|
#ifndef CONFIG_H
|
||||||
#define CONFIG_H
|
#define CONFIG_H
|
||||||
|
|
||||||
#define DEFAULT_SNAKE_SERVER "127.0.0.1"
|
|
||||||
#define LOCAL_SNAKE_SERVER "127.0.0.1"
|
#define LOCAL_SNAKE_SERVER "127.0.0.1"
|
||||||
|
|
||||||
#define DEFAULT_SNAKE_PORT 7777
|
#define DEFAULT_SNAKE_PORT 7777
|
||||||
|
@ -152,7 +152,7 @@ bool MainServer::run(const QString &ip, unsigned short port, const QString& db)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!restartSrver(ip.isEmpty()? DEFAULT_SNAKE_SERVER: ip,
|
if (!restartSrver(ip.isEmpty()? LOCAL_SNAKE_SERVER: ip,
|
||||||
port ? port : DEFAULT_SNAKE_PORT)) {
|
port ? port : DEFAULT_SNAKE_PORT)) {
|
||||||
QuasarAppUtils::Params::verboseLog("restart server fail", QuasarAppUtils::Error);
|
QuasarAppUtils::Params::verboseLog("restart server fail", QuasarAppUtils::Error);
|
||||||
return false;
|
return false;
|
||||||
|
@ -27,12 +27,12 @@ void Client::incommingData() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Client::Client(QObject *ptr):
|
Client::Client(const QString& server, QObject *ptr):
|
||||||
QObject (ptr) {
|
QObject (ptr) {
|
||||||
|
|
||||||
_destination = new QLocalSocket(this);
|
_destination = new QLocalSocket(this);
|
||||||
|
|
||||||
_destination->connectToServer(DEFAULT_SERVER);
|
_destination->connectToServer(server);
|
||||||
|
|
||||||
connect(_destination, &QLocalSocket::readyRead,
|
connect(_destination, &QLocalSocket::readyRead,
|
||||||
this, &Client::incommingData);
|
this, &Client::incommingData);
|
||||||
|
@ -22,7 +22,7 @@ private slots:
|
|||||||
void incommingData();
|
void incommingData();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Client(QObject * ptr = nullptr);
|
explicit Client(const QString &server = DEFAULT_SERVER, QObject * ptr = nullptr);
|
||||||
bool ping();
|
bool ping();
|
||||||
bool getState();
|
bool getState();
|
||||||
bool ban(const QHostAddress& address);
|
bool ban(const QHostAddress& address);
|
||||||
|
@ -15,6 +15,10 @@
|
|||||||
|
|
||||||
// add necessary includes here
|
// add necessary includes here
|
||||||
|
|
||||||
|
#define TEST_LOCAL_SERVER QString(DEFAULT_SERVER) + "Test"
|
||||||
|
#define TEST_SERVER_ADDRESS LOCAL_SNAKE_SERVER
|
||||||
|
#define TEST_SERVER_PORT 27777
|
||||||
|
|
||||||
class testSankeServer : public QObject
|
class testSankeServer : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -77,9 +81,9 @@ void testSankeServer::testPingServerProtockol() {
|
|||||||
|
|
||||||
auto serv = new ServerProtocol::Server(this);
|
auto serv = new ServerProtocol::Server(this);
|
||||||
|
|
||||||
QVERIFY(serv->run(DEFAULT_SERVER));
|
QVERIFY(serv->run(TEST_LOCAL_SERVER));
|
||||||
|
|
||||||
auto client = new ServerProtocol::Client(this);
|
auto client = new ServerProtocol::Client(TEST_LOCAL_SERVER, this);
|
||||||
|
|
||||||
bool isWork = false;
|
bool isWork = false;
|
||||||
QObject::connect(client, &ServerProtocol::Client::sigIncommingData,
|
QObject::connect(client, &ServerProtocol::Client::sigIncommingData,
|
||||||
@ -106,12 +110,12 @@ void testSankeServer::testPingServerProtockol() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void testSankeServer::testStateServerProtockol() {
|
void testSankeServer::testStateServerProtockol() {
|
||||||
ServerProtocol::Client cle;
|
ServerProtocol::Client cle(TEST_LOCAL_SERVER);
|
||||||
QVERIFY(cle.getState());
|
QVERIFY(cle.getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
void testSankeServer::testBanServerProtockol() {
|
void testSankeServer::testBanServerProtockol() {
|
||||||
ServerProtocol::Client cle;
|
ServerProtocol::Client cle(TEST_LOCAL_SERVER);
|
||||||
QVERIFY(!cle.ban(QHostAddress()));
|
QVERIFY(!cle.ban(QHostAddress()));
|
||||||
|
|
||||||
QVERIFY(cle.ban(QHostAddress("192.192.192.192")));
|
QVERIFY(cle.ban(QHostAddress("192.192.192.192")));
|
||||||
@ -119,14 +123,14 @@ void testSankeServer::testBanServerProtockol() {
|
|||||||
|
|
||||||
void testSankeServer::testUnBanServerProtockol()
|
void testSankeServer::testUnBanServerProtockol()
|
||||||
{
|
{
|
||||||
ServerProtocol::Client cle;
|
ServerProtocol::Client cle(TEST_LOCAL_SERVER);
|
||||||
QVERIFY(!cle.unBan(QHostAddress()));
|
QVERIFY(!cle.unBan(QHostAddress()));
|
||||||
|
|
||||||
QVERIFY(cle.unBan(QHostAddress("192.192.192.192")));
|
QVERIFY(cle.unBan(QHostAddress("192.192.192.192")));
|
||||||
}
|
}
|
||||||
|
|
||||||
void testSankeServer::testRestartServerProtockol() {
|
void testSankeServer::testRestartServerProtockol() {
|
||||||
ServerProtocol::Client cle;
|
ServerProtocol::Client cle(TEST_LOCAL_SERVER);
|
||||||
QVERIFY(!cle.restart("lolo", 0));
|
QVERIFY(!cle.restart("lolo", 0));
|
||||||
|
|
||||||
QVERIFY(!cle.restart("192.168.1.999", 0));
|
QVERIFY(!cle.restart("192.168.1.999", 0));
|
||||||
@ -151,9 +155,11 @@ void testSankeServer::testPingClientProtockol() {
|
|||||||
|
|
||||||
auto serv = new ClientProtocol::Server(this);
|
auto serv = new ClientProtocol::Server(this);
|
||||||
|
|
||||||
QVERIFY(serv->run(LOCAL_SNAKE_SERVER, DEFAULT_SNAKE_PORT));
|
QVERIFY(serv->run(TEST_SERVER_ADDRESS, TEST_SERVER_PORT));
|
||||||
|
|
||||||
auto client = new ClientProtocol::Client(this);
|
auto client = new ClientProtocol::Client(TEST_SERVER_ADDRESS,
|
||||||
|
TEST_SERVER_PORT,
|
||||||
|
this);
|
||||||
|
|
||||||
bool isWork = false;
|
bool isWork = false;
|
||||||
QObject::connect(client, &ClientProtocol::Client::sigIncommingData,
|
QObject::connect(client, &ClientProtocol::Client::sigIncommingData,
|
||||||
@ -180,7 +186,7 @@ void testSankeServer::testPingClientProtockol() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void testSankeServer::testLogin() {
|
void testSankeServer::testLogin() {
|
||||||
ClientProtocol::Client cle;
|
ClientProtocol::Client cle(TEST_SERVER_ADDRESS, TEST_SERVER_PORT);
|
||||||
|
|
||||||
auto pass = QCryptographicHash::hash("testpass", QCryptographicHash::Sha512);
|
auto pass = QCryptographicHash::hash("testpass", QCryptographicHash::Sha512);
|
||||||
QVERIFY(!cle.login("Test@gmail.com", pass));
|
QVERIFY(!cle.login("Test@gmail.com", pass));
|
||||||
@ -191,7 +197,7 @@ void testSankeServer::testLogin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void testSankeServer::testUserData() {
|
void testSankeServer::testUserData() {
|
||||||
ClientProtocol::Client cle;
|
ClientProtocol::Client cle(TEST_SERVER_ADDRESS, TEST_SERVER_PORT);
|
||||||
|
|
||||||
QVERIFY(!cle.updateData());
|
QVERIFY(!cle.updateData());
|
||||||
|
|
||||||
@ -204,7 +210,7 @@ void testSankeServer::testUserData() {
|
|||||||
|
|
||||||
void testSankeServer::testGetItem() {
|
void testSankeServer::testGetItem() {
|
||||||
|
|
||||||
ClientProtocol::Client cle;
|
ClientProtocol::Client cle(TEST_SERVER_ADDRESS, TEST_SERVER_PORT);
|
||||||
|
|
||||||
QVERIFY(!cle.updateData());
|
QVERIFY(!cle.updateData());
|
||||||
|
|
||||||
@ -217,7 +223,7 @@ void testSankeServer::testGetItem() {
|
|||||||
|
|
||||||
void testSankeServer::testApplyData() {
|
void testSankeServer::testApplyData() {
|
||||||
|
|
||||||
ClientProtocol::Client cle;
|
ClientProtocol::Client cle(TEST_SERVER_ADDRESS, TEST_SERVER_PORT);
|
||||||
|
|
||||||
|
|
||||||
auto token = QCryptographicHash::hash("testtoken", QCryptographicHash::Sha256);
|
auto token = QCryptographicHash::hash("testtoken", QCryptographicHash::Sha256);
|
||||||
@ -457,7 +463,7 @@ void testSankeServer::testServerProtockol() {
|
|||||||
testPingServerProtockol();
|
testPingServerProtockol();
|
||||||
|
|
||||||
auto serv = new ServerProtocol::Server(this);
|
auto serv = new ServerProtocol::Server(this);
|
||||||
QVERIFY(serv->run(DEFAULT_SERVER));
|
QVERIFY(serv->run(TEST_LOCAL_SERVER));
|
||||||
testStateServerProtockol();
|
testStateServerProtockol();
|
||||||
testBanServerProtockol();
|
testBanServerProtockol();
|
||||||
testUnBanServerProtockol();
|
testUnBanServerProtockol();
|
||||||
@ -468,7 +474,7 @@ void testSankeServer::testClientProtockol() {
|
|||||||
testPingClientProtockol();
|
testPingClientProtockol();
|
||||||
|
|
||||||
auto serv = new ClientProtocol::Server(this);
|
auto serv = new ClientProtocol::Server(this);
|
||||||
QVERIFY(serv->run(LOCAL_SNAKE_SERVER, DEFAULT_SNAKE_PORT));
|
QVERIFY(serv->run(TEST_SERVER_ADDRESS, TEST_SERVER_PORT));
|
||||||
|
|
||||||
testLogin();
|
testLogin();
|
||||||
testGetItem();
|
testGetItem();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user