Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/network/tests/test_Net.h
Show First 20 Lines • Show All 144 Lines • ▼ Show 20 Lines | void test_basic_DISABLED() | ||||
TestStdoutLogger logger; | TestStdoutLogger logger; | ||||
std::vector<CNetClient*> clients; | std::vector<CNetClient*> clients; | ||||
CGame client1Game(false); | CGame client1Game(false); | ||||
CGame client2Game(false); | CGame client2Game(false); | ||||
CGame client3Game(false); | CGame client3Game(false); | ||||
CNetServer server; | CNetServer server("no_secret"); | ||||
JS::RootedValue attrs(rq.cx); | JS::RootedValue attrs(rq.cx); | ||||
ScriptInterface::CreateObject( | ScriptInterface::CreateObject( | ||||
rq, | rq, | ||||
&attrs, | &attrs, | ||||
"mapType", "scenario", | "mapType", "scenario", | ||||
"map", "maps/scenarios/Saharan Oases", | "map", "maps/scenarios/Saharan Oases", | ||||
"mapPath", "maps/scenarios/", | "mapPath", "maps/scenarios/", | ||||
"thing", "example"); | "thing", "example"); | ||||
server.UpdateGameAttributes(&attrs, scriptInterface); | server.UpdateGameAttributes(&attrs, scriptInterface); | ||||
CNetClient client1(&client1Game, false); | CNetClient client1(&client1Game); | ||||
CNetClient client2(&client2Game, false); | CNetClient client2(&client2Game); | ||||
CNetClient client3(&client3Game, false); | CNetClient client3(&client3Game); | ||||
clients.push_back(&client1); | clients.push_back(&client1); | ||||
clients.push_back(&client2); | clients.push_back(&client2); | ||||
clients.push_back(&client3); | clients.push_back(&client3); | ||||
connect(server, clients); | connect(server, clients); | ||||
debug_printf("%s", client1.TestReadGuiMessages().c_str()); | debug_printf("%s", client1.TestReadGuiMessages().c_str()); | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | void test_rejoin_DISABLED() | ||||
TestStdoutLogger logger; | TestStdoutLogger logger; | ||||
std::vector<CNetClient*> clients; | std::vector<CNetClient*> clients; | ||||
CGame client1Game(false); | CGame client1Game(false); | ||||
CGame client2Game(false); | CGame client2Game(false); | ||||
CGame client3Game(false); | CGame client3Game(false); | ||||
CNetServer server; | CNetServer server("no_secret"); | ||||
JS::RootedValue attrs(rq.cx); | JS::RootedValue attrs(rq.cx); | ||||
ScriptInterface::CreateObject( | ScriptInterface::CreateObject( | ||||
rq, | rq, | ||||
&attrs, | &attrs, | ||||
"mapType", "scenario", | "mapType", "scenario", | ||||
"map", "maps/scenarios/Saharan Oases", | "map", "maps/scenarios/Saharan Oases", | ||||
"mapPath", "maps/scenarios/", | "mapPath", "maps/scenarios/", | ||||
"thing", "example"); | "thing", "example"); | ||||
server.UpdateGameAttributes(&attrs, scriptInterface); | server.UpdateGameAttributes(&attrs, scriptInterface); | ||||
CNetClient client1(&client1Game, false); | CNetClient client1(&client1Game); | ||||
CNetClient client2(&client2Game, false); | CNetClient client2(&client2Game); | ||||
CNetClient client3(&client3Game, false); | CNetClient client3(&client3Game); | ||||
client1.SetUserName(L"alice"); | client1.SetUserName(L"alice"); | ||||
client2.SetUserName(L"bob"); | client2.SetUserName(L"bob"); | ||||
client3.SetUserName(L"charlie"); | client3.SetUserName(L"charlie"); | ||||
clients.push_back(&client1); | clients.push_back(&client1); | ||||
clients.push_back(&client2); | clients.push_back(&client2); | ||||
clients.push_back(&client3); | clients.push_back(&client3); | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | void test_rejoin_DISABLED() | ||||
debug_printf("==== Disconnecting client 2\n"); | debug_printf("==== Disconnecting client 2\n"); | ||||
client2.DestroyConnection(); | client2.DestroyConnection(); | ||||
clients.erase(clients.begin()+1); | clients.erase(clients.begin()+1); | ||||
debug_printf("==== Connecting client 2B\n"); | debug_printf("==== Connecting client 2B\n"); | ||||
CGame client2BGame(false); | CGame client2BGame(false); | ||||
CNetClient client2B(&client2BGame, false); | CNetClient client2B(&client2BGame); | ||||
client2B.SetUserName(L"bob"); | client2B.SetUserName(L"bob"); | ||||
clients.push_back(&client2B); | clients.push_back(&client2B); | ||||
client2B.SetupServerData("127.0.0.1", PS_DEFAULT_PORT, false); | client2B.SetupServerData("127.0.0.1", PS_DEFAULT_PORT, false); | ||||
TS_ASSERT(client2B.SetupConnection(nullptr)); | TS_ASSERT(client2B.SetupConnection(nullptr)); | ||||
for (size_t i = 0; ; ++i) | for (size_t i = 0; ; ++i) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 70 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator