Add new map saving test (#14854)
This commit is contained in:
@@ -78,6 +78,8 @@ namespace Content.IntegrationTests.Tests
|
|||||||
await pairTracker.CleanReturnAsync();
|
await pairTracker.CleanReturnAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const string TestMap = "Maps/bagel.yml";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads the default map, runs it for 5 ticks, then assert that it did not change.
|
/// Loads the default map, runs it for 5 ticks, then assert that it did not change.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -91,13 +93,13 @@ namespace Content.IntegrationTests.Tests
|
|||||||
|
|
||||||
MapId mapId = default;
|
MapId mapId = default;
|
||||||
|
|
||||||
// Load saltern.yml as uninitialized map, and save it to ensure it's up to date.
|
// Load bagel.yml as uninitialized map, and save it to ensure it's up to date.
|
||||||
server.Post(() =>
|
server.Post(() =>
|
||||||
{
|
{
|
||||||
mapId = mapManager.CreateMap();
|
mapId = mapManager.CreateMap();
|
||||||
mapManager.AddUninitializedMap(mapId);
|
mapManager.AddUninitializedMap(mapId);
|
||||||
mapManager.SetMapPaused(mapId, true);
|
mapManager.SetMapPaused(mapId, true);
|
||||||
mapLoader.LoadMap(mapId, "Maps/bagel.yml");
|
mapLoader.LoadMap(mapId, TestMap);
|
||||||
mapLoader.SaveMap(mapId, "load save ticks save 1.yml");
|
mapLoader.SaveMap(mapId, "load save ticks save 1.yml");
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -145,6 +147,78 @@ namespace Content.IntegrationTests.Tests
|
|||||||
TestContext.Error.WriteLine(twoTmp);
|
TestContext.Error.WriteLine(twoTmp);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await server.WaitPost(() => mapManager.DeleteMap(mapId));
|
||||||
|
await pairTracker.CleanReturnAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads the same uninitialized map at slightly different times, and then checks that they are the same
|
||||||
|
/// when getting saved.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Should ensure that entities do not perform randomization prior to initialization and should prevents
|
||||||
|
/// bugs like the one discussed in github.com/space-wizards/RobustToolbox/issues/3870. This test is somewhat
|
||||||
|
/// similar to <see cref="LoadSaveTicksSaveBagel"/> and <see cref="SaveLoadSave"/>, but neither of these
|
||||||
|
/// caught the mentioned bug.
|
||||||
|
/// </remarks>
|
||||||
|
[Test]
|
||||||
|
public async Task LoadTickLoadBagel()
|
||||||
|
{
|
||||||
|
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true});
|
||||||
|
var server = pairTracker.Pair.Server;
|
||||||
|
|
||||||
|
var mapLoader = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<MapLoaderSystem>();
|
||||||
|
var mapManager = server.ResolveDependency<IMapManager>();
|
||||||
|
var userData = server.ResolveDependency<IResourceManager>().UserData;
|
||||||
|
|
||||||
|
MapId mapId = default;
|
||||||
|
const string fileA = "/load tick load a.yml";
|
||||||
|
const string fileB = "/load tick load b.yml";
|
||||||
|
string yamlA;
|
||||||
|
string yamlB;
|
||||||
|
|
||||||
|
// Load & save the first map
|
||||||
|
server.Post(() =>
|
||||||
|
{
|
||||||
|
mapId = mapManager.CreateMap();
|
||||||
|
mapManager.AddUninitializedMap(mapId);
|
||||||
|
mapManager.SetMapPaused(mapId, true);
|
||||||
|
mapLoader.LoadMap(mapId, TestMap);
|
||||||
|
mapLoader.SaveMap(mapId, fileA);
|
||||||
|
});
|
||||||
|
|
||||||
|
await server.WaitIdleAsync();
|
||||||
|
await using (var stream = userData.Open(new ResourcePath(fileA), FileMode.Open))
|
||||||
|
using (var reader = new StreamReader(stream))
|
||||||
|
{
|
||||||
|
yamlA = await reader.ReadToEndAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
server.RunTicks(5);
|
||||||
|
|
||||||
|
// Load & save the second map
|
||||||
|
server.Post(() =>
|
||||||
|
{
|
||||||
|
mapManager.DeleteMap(mapId);
|
||||||
|
mapManager.CreateMap(mapId);
|
||||||
|
mapManager.AddUninitializedMap(mapId);
|
||||||
|
mapManager.SetMapPaused(mapId, true);
|
||||||
|
mapLoader.LoadMap(mapId, TestMap);
|
||||||
|
mapLoader.SaveMap(mapId, fileB);
|
||||||
|
});
|
||||||
|
|
||||||
|
await server.WaitIdleAsync();
|
||||||
|
|
||||||
|
await using (var stream = userData.Open(new ResourcePath(fileB), FileMode.Open))
|
||||||
|
using (var reader = new StreamReader(stream))
|
||||||
|
{
|
||||||
|
yamlB = await reader.ReadToEndAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.That(yamlA, Is.EqualTo(yamlB));
|
||||||
|
|
||||||
|
await server.WaitPost(() => mapManager.DeleteMap(mapId));
|
||||||
await pairTracker.CleanReturnAsync();
|
await pairTracker.CleanReturnAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9373,9 +9373,6 @@ entities:
|
|||||||
- nextUpdate: 8187.135845
|
- nextUpdate: 8187.135845
|
||||||
type: GridPathfinding
|
type: GridPathfinding
|
||||||
- type: RadiationGridResistance
|
- type: RadiationGridResistance
|
||||||
- nextShake: 0
|
|
||||||
shakeTimes: 10
|
|
||||||
type: GravityShake
|
|
||||||
- type: GasTileOverlay
|
- type: GasTileOverlay
|
||||||
- uid: 61
|
- uid: 61
|
||||||
type: GasVentScrubber
|
type: GasVentScrubber
|
||||||
|
|||||||
Reference in New Issue
Block a user