@@ -244,6 +244,51 @@ BOOST_DATA_TEST_CASE(ClientFollowsConnectProtocol, usesLuaScriptValues, usesLuaS
244244 }
245245}
246246
247+ BOOST_AUTO_TEST_CASE (ClientStoresReceivedSavegamesInSaveFolder)
248+ {
249+ GameClient client;
250+ GameMessageInterface& clientMsgInterface = client;
251+ MockClientInterface callbacks;
252+ client.SetInterface (&callbacks);
253+ TestServer server;
254+ const auto serverPort = server.tryListen ();
255+ BOOST_TEST_REQUIRE (serverPort >= 0 );
256+ const auto pw = rttr::test::randString (10 );
257+ const auto serverType = rttr::test::randomEnum<ServerType>();
258+
259+ mock::sequence s;
260+ MOCK_EXPECT (callbacks.CI_NextConnectState ).in (s).with (ConnectState::Initiated).once ();
261+ MOCK_EXPECT (callbacks.CI_NextConnectState ).in (s).with (ConnectState::VerifyServer).once ();
262+ MOCK_EXPECT (callbacks.CI_NextConnectState ).in (s).with (ConnectState::QueryPw).once ();
263+ MOCK_EXPECT (callbacks.CI_NextConnectState ).in (s).with (ConnectState::QueryMapInfo).once ();
264+ MOCK_EXPECT (callbacks.CI_NextConnectState ).in (s).with (ConnectState::ReceiveMap).once ();
265+
266+ BOOST_TEST_REQUIRE (client.Connect (" localhost" , pw, serverType, serverPort, false , false ));
267+ clientMsgInterface.OnGameMessage (GameMessage_Player_Id (1 ));
268+ BOOST_TEST_REQUIRE (boost::dynamic_pointer_cast<GameMessage_Server_Type>(client.GetMainPlayer ().sendQueue .pop ()));
269+
270+ clientMsgInterface.OnGameMessage (GameMessage_Server_TypeOK (GameMessage_Server_TypeOK::StatusCode::Ok, " " ));
271+ BOOST_TEST_REQUIRE (boost::dynamic_pointer_cast<GameMessage_Server_Password>(client.GetMainPlayer ().sendQueue .pop ()));
272+
273+ clientMsgInterface.OnGameMessage (GameMessage_Server_Password (" true" ));
274+ BOOST_TEST_REQUIRE (dynamic_cast <GameMessage_Player_Name*>(client.GetMainPlayer ().sendQueue .pop ().get ()));
275+ BOOST_TEST_REQUIRE (dynamic_cast <GameMessage_Player_Portrait*>(client.GetMainPlayer ().sendQueue .pop ().get ()));
276+ const auto infoRequest = boost::dynamic_pointer_cast<GameMessage_MapRequest>(client.GetMainPlayer ().sendQueue .pop ());
277+ BOOST_TEST_REQUIRE (infoRequest);
278+ BOOST_TEST (infoRequest->requestInfo );
279+
280+ clientMsgInterface.OnGameMessage (GameMessage_Map_Info (" received.sav" , MapType::Savegame, 100 , 10 , 0 , 0 ));
281+
282+ const auto expectedSavePath = RTTRCONFIG .ExpandPath (s25::folders::save) / " received.sav" ;
283+ const auto unexpectedMapsPath = RTTRCONFIG .ExpandPath (s25::folders::mapsPlayed) / " received.sav" ;
284+ BOOST_TEST (client.GetMapType () == MapType::Savegame);
285+ BOOST_TEST (client.GetMapPath () == expectedSavePath);
286+ BOOST_TEST (client.GetMapPath () != unexpectedMapsPath);
287+
288+ const auto transferRequest = boost::dynamic_pointer_cast<GameMessage_MapRequest>(client.GetMainPlayer ().sendQueue .pop ());
289+ BOOST_TEST_REQUIRE (transferRequest);
290+ BOOST_TEST (!transferRequest->requestInfo );
291+ }
247292BOOST_AUTO_TEST_CASE (ClientDetectsMapBufferOverflow)
248293{
249294 rttr::test::LogAccessor _suppressLogOutput;
0 commit comments