@@ -79,27 +79,6 @@ class CustomUserMapFolderFixture
7979 }
8080};
8181
82- void AdvanceClientToMapInfoRequest (GameClient& client, GameMessageInterface& clientMsgInterface,
83- MockClientInterface& callbacks, const std::string& password,
84- ServerType serverType, int serverPort)
85- {
86- mock::sequence s;
87- MOCK_EXPECT (callbacks.CI_NextConnectState ).in (s).with (ConnectState::Initiated).once ();
88- MOCK_EXPECT (callbacks.CI_NextConnectState ).in (s).with (ConnectState::VerifyServer).once ();
89- MOCK_EXPECT (callbacks.CI_NextConnectState ).in (s).with (ConnectState::QueryPw).once ();
90- MOCK_EXPECT (callbacks.CI_NextConnectState ).in (s).with (ConnectState::QueryMapInfo).once ();
91-
92- BOOST_TEST_REQUIRE (client.Connect (" localhost" , password, serverType, serverPort, false , false ));
93- clientMsgInterface.OnGameMessage (GameMessage_Player_Id (1 ));
94- client.GetMainPlayer ().sendQueue .clear ();
95-
96- clientMsgInterface.OnGameMessage (GameMessage_Server_TypeOK (GameMessage_Server_TypeOK::StatusCode::Ok, " " ));
97- client.GetMainPlayer ().sendQueue .clear ();
98-
99- clientMsgInterface.OnGameMessage (GameMessage_Server_Password (" true" ));
100- client.GetMainPlayer ().sendQueue .clear ();
101- }
102-
10382} // namespace
10483
10584BOOST_FIXTURE_TEST_SUITE (GameClientTests, CustomUserMapFolderFixture)
@@ -272,25 +251,22 @@ BOOST_AUTO_TEST_CASE(ClientStoresReceivedSavegamesInSaveFolder)
272251
273252 GameClient client;
274253 GameMessageInterface& clientMsgInterface = client;
275- MockClientInterface callbacks;
276- client.SetInterface (&callbacks);
277254 TestServer server;
278255 const auto serverPort = server.tryListen ();
279256 BOOST_TEST_REQUIRE (serverPort >= 0 );
280- const auto pw = rttr::test::randString (10 );
281- const auto serverType = rttr::test::randomEnum<ServerType>();
282257
283- MOCK_EXPECT (callbacks.CI_NextConnectState ).with (ConnectState::ReceiveMap).once ();
284- AdvanceClientToMapInfoRequest (client, clientMsgInterface, callbacks, pw, serverType, serverPort);
285-
286- const boost::filesystem::path testMapPath =
287- rttr::test::rttrBaseDir / " tests" / " testData" / " maps" / " LuaFunctions.SWD" ;
288- MapInfo mapInfo;
289- mapInfo.mapData .CompressFromFile (testMapPath, &mapInfo.mapChecksum );
290- const auto mapDataSize = mapInfo.mapData .data .size ();
258+ // Map info is ignored unless the client has reached QueryMapInfo; keep this setup minimal.
259+ BOOST_TEST_REQUIRE (
260+ client.Connect (" localhost" , rttr::test::randString (10 ), rttr::test::randomEnum<ServerType>(), serverPort, false ,
261+ false ));
262+ clientMsgInterface.OnGameMessage (GameMessage_Player_Id (1 ));
263+ client.GetMainPlayer ().sendQueue .clear ();
264+ clientMsgInterface.OnGameMessage (GameMessage_Server_TypeOK (GameMessage_Server_TypeOK::StatusCode::Ok, " " ));
265+ client.GetMainPlayer ().sendQueue .clear ();
266+ clientMsgInterface.OnGameMessage (GameMessage_Server_Password (" true" ));
267+ client.GetMainPlayer ().sendQueue .clear ();
291268
292- clientMsgInterface.OnGameMessage (GameMessage_Map_Info (" received.sav" , MapType::Savegame,
293- mapInfo.mapData .uncompressedLength , mapDataSize, 0 , 0 ));
269+ clientMsgInterface.OnGameMessage (GameMessage_Map_Info (" received.sav" , MapType::Savegame, 0 , 0 , 0 , 0 ));
294270
295271 const auto expectedSavePath = RTTRCONFIG .ExpandPath (s25::folders::save) / " received.sav" ;
296272 const auto unexpectedMapsPath = RTTRCONFIG .ExpandPath (s25::folders::mapsPlayed) / " received.sav" ;
@@ -299,18 +275,6 @@ BOOST_AUTO_TEST_CASE(ClientStoresReceivedSavegamesInSaveFolder)
299275 BOOST_TEST (client.GetMapType () == MapType::Savegame);
300276 BOOST_TEST (client.GetMapPath () == expectedSavePath);
301277 BOOST_TEST (client.GetMapPath () != unexpectedMapsPath);
302-
303- const auto transferRequest =
304- boost::dynamic_pointer_cast<GameMessage_MapRequest>(client.GetMainPlayer ().sendQueue .pop ());
305- BOOST_TEST_REQUIRE (transferRequest);
306- BOOST_TEST (!transferRequest->requestInfo );
307-
308- MOCK_EXPECT (callbacks.CI_MapPartReceived ).with (mapDataSize, mapDataSize).once ();
309- MOCK_EXPECT (callbacks.CI_Error ).once ();
310- clientMsgInterface.OnGameMessage (GameMessage_Map_Data (true , 0 , mapInfo.mapData .data .data (), mapDataSize));
311-
312- BOOST_TEST (bfs::exists (expectedSavePath));
313- BOOST_TEST (!bfs::exists (unexpectedMapsPath));
314278}
315279BOOST_AUTO_TEST_CASE (ClientDetectsMapBufferOverflow)
316280{
0 commit comments