Changeset View
Changeset View
Standalone View
Standalone View
source/network/tests/test_Net.h
Show First 20 Lines • Show All 145 Lines • ▼ Show 20 Lines | void test_basic_DISABLED() | ||||
CGame client1Game(false); | CGame client1Game(false); | ||||
CGame client2Game(false); | CGame client2Game(false); | ||||
CGame client3Game(false); | CGame client3Game(false); | ||||
CNetServer server; | CNetServer server; | ||||
JS::RootedValue attrs(cx); | JS::RootedValue attrs(cx); | ||||
scriptInterface.CreateObject( | ScriptInterface::CreateObject( | ||||
cx, | |||||
&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); | ||||
Show All 16 Lines | for (size_t j = 0; j < clients.size(); ++j) | ||||
TS_ASSERT_OK(LDR_NonprogressiveLoad()); | TS_ASSERT_OK(LDR_NonprogressiveLoad()); | ||||
clients[j]->LoadFinished(); | clients[j]->LoadFinished(); | ||||
} | } | ||||
wait(clients, 100); | wait(clients, 100); | ||||
{ | { | ||||
JS::RootedValue cmd(cx); | JS::RootedValue cmd(cx); | ||||
client1.GetScriptInterface().CreateObject( | ScriptInterface::CreateObject( | ||||
cx, | |||||
&cmd, | &cmd, | ||||
"type", "debug-print", | "type", "debug-print", | ||||
"message", "[>>> client1 test sim command]\\n"); | "message", "[>>> client1 test sim command]\\n"); | ||||
client1Game.GetTurnManager()->PostCommand(cmd); | client1Game.GetTurnManager()->PostCommand(cmd); | ||||
} | } | ||||
{ | { | ||||
JS::RootedValue cmd(cx); | JS::RootedValue cmd(cx); | ||||
client1.GetScriptInterface().CreateObject( | ScriptInterface::CreateObject( | ||||
cx, | |||||
&cmd, | &cmd, | ||||
"type", "debug-print", | "type", "debug-print", | ||||
"message", "[>>> client2 test sim command]\\n"); | "message", "[>>> client2 test sim command]\\n"); | ||||
client2Game.GetTurnManager()->PostCommand(cmd); | client2Game.GetTurnManager()->PostCommand(cmd); | ||||
} | } | ||||
wait(clients, 100); | wait(clients, 100); | ||||
client1Game.GetTurnManager()->Update(1.0f, 1); | client1Game.GetTurnManager()->Update(1.0f, 1); | ||||
Show All 18 Lines | void test_rejoin_DISABLED() | ||||
CGame client1Game(false); | CGame client1Game(false); | ||||
CGame client2Game(false); | CGame client2Game(false); | ||||
CGame client3Game(false); | CGame client3Game(false); | ||||
CNetServer server; | CNetServer server; | ||||
JS::RootedValue attrs(cx); | JS::RootedValue attrs(cx); | ||||
scriptInterface.CreateObject( | ScriptInterface::CreateObject( | ||||
cx, | |||||
&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); | ||||
Show All 20 Lines | for (size_t j = 0; j < clients.size(); ++j) | ||||
TS_ASSERT_OK(LDR_NonprogressiveLoad()); | TS_ASSERT_OK(LDR_NonprogressiveLoad()); | ||||
clients[j]->LoadFinished(); | clients[j]->LoadFinished(); | ||||
} | } | ||||
wait(clients, 100); | wait(clients, 100); | ||||
{ | { | ||||
JS::RootedValue cmd(cx); | JS::RootedValue cmd(cx); | ||||
client1.GetScriptInterface().CreateObject( | ScriptInterface::CreateObject( | ||||
cx, | |||||
&cmd, | &cmd, | ||||
"type", "debug-print", | "type", "debug-print", | ||||
"message", "[>>> client1 test sim command 1]\\n"); | "message", "[>>> client1 test sim command 1]\\n"); | ||||
client1Game.GetTurnManager()->PostCommand(cmd); | client1Game.GetTurnManager()->PostCommand(cmd); | ||||
} | } | ||||
wait(clients, 100); | wait(clients, 100); | ||||
client1Game.GetTurnManager()->Update(1.0f, 1); | client1Game.GetTurnManager()->Update(1.0f, 1); | ||||
client2Game.GetTurnManager()->Update(1.0f, 1); | client2Game.GetTurnManager()->Update(1.0f, 1); | ||||
client3Game.GetTurnManager()->Update(1.0f, 1); | client3Game.GetTurnManager()->Update(1.0f, 1); | ||||
wait(clients, 100); | wait(clients, 100); | ||||
{ | { | ||||
JS::RootedValue cmd(cx); | JS::RootedValue cmd(cx); | ||||
client1.GetScriptInterface().CreateObject( | ScriptInterface::CreateObject( | ||||
cx, | |||||
&cmd, | &cmd, | ||||
"type", "debug-print", | "type", "debug-print", | ||||
"message", "[>>> client1 test sim command 2]\\n"); | "message", "[>>> client1 test sim command 2]\\n"); | ||||
client1Game.GetTurnManager()->PostCommand(cmd); | client1Game.GetTurnManager()->PostCommand(cmd); | ||||
} | } | ||||
debug_printf("==== Disconnecting client 2\n"); | debug_printf("==== Disconnecting client 2\n"); | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | void test_rejoin_DISABLED() | ||||
client3Game.GetTurnManager()->Update(1.0f, 1); | client3Game.GetTurnManager()->Update(1.0f, 1); | ||||
wait(clients, 100); | wait(clients, 100); | ||||
// (This SetTurnLength thing doesn't actually detect errors unless you change | // (This SetTurnLength thing doesn't actually detect errors unless you change | ||||
// CTurnManager::TurnNeedsFullHash to always return true) | // CTurnManager::TurnNeedsFullHash to always return true) | ||||
{ | { | ||||
JS::RootedValue cmd(cx); | JS::RootedValue cmd(cx); | ||||
client1.GetScriptInterface().CreateObject( | ScriptInterface::CreateObject( | ||||
cx, | |||||
&cmd, | &cmd, | ||||
"type", "debug-print", | "type", "debug-print", | ||||
"message", "[>>> client1 test sim command 3]\\n"); | "message", "[>>> client1 test sim command 3]\\n"); | ||||
client1Game.GetTurnManager()->PostCommand(cmd); | client1Game.GetTurnManager()->PostCommand(cmd); | ||||
} | } | ||||
clients[2]->Poll(); | clients[2]->Poll(); | ||||
TS_ASSERT_OK(LDR_NonprogressiveLoad()); | TS_ASSERT_OK(LDR_NonprogressiveLoad()); | ||||
clients[2]->LoadFinished(); | clients[2]->LoadFinished(); | ||||
wait(clients, 100); | wait(clients, 100); | ||||
{ | { | ||||
JS::RootedValue cmd(cx); | JS::RootedValue cmd(cx); | ||||
client1.GetScriptInterface().CreateObject( | ScriptInterface::CreateObject( | ||||
cx, | |||||
&cmd, | &cmd, | ||||
"type", "debug-print", | "type", "debug-print", | ||||
"message", "[>>> client1 test sim command 4]\\n"); | "message", "[>>> client1 test sim command 4]\\n"); | ||||
client1Game.GetTurnManager()->PostCommand(cmd); | client1Game.GetTurnManager()->PostCommand(cmd); | ||||
} | } | ||||
for (size_t i = 0; i < 3; ++i) | for (size_t i = 0; i < 3; ++i) | ||||
{ | { | ||||
client1Game.GetTurnManager()->Update(1.0f, 1); | client1Game.GetTurnManager()->Update(1.0f, 1); | ||||
client2BGame.GetTurnManager()->Update(1.0f, 1); | client2BGame.GetTurnManager()->Update(1.0f, 1); | ||||
client3Game.GetTurnManager()->Update(1.0f, 1); | client3Game.GetTurnManager()->Update(1.0f, 1); | ||||
wait(clients, 100); | wait(clients, 100); | ||||
} | } | ||||
} | } | ||||
}; | }; |
Wildfire Games · Phabricator