File size: 1,114 Bytes
05c9ac2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
using NUnit.Framework;
using Unity.MLAgents.SideChannels;
using UnityEngine;
namespace Unity.MLAgents.Tests
{
public class EngineConfigurationChannelTests
{
float m_OldTimeScale = 1.0f;
[SetUp]
public void Setup()
{
m_OldTimeScale = Time.timeScale;
}
[TearDown]
public void TearDown()
{
Time.timeScale = m_OldTimeScale;
}
[Test]
public void TestTimeScaleClamping()
{
OutgoingMessage pythonMsg = new OutgoingMessage();
pythonMsg.WriteInt32((int)EngineConfigurationChannel.ConfigurationType.TimeScale);
pythonMsg.WriteFloat32(1000f);
var sideChannel = new EngineConfigurationChannel();
sideChannel.ProcessMessage(pythonMsg.ToByteArray());
#if UNITY_EDITOR
// Should be clamped
Assert.AreEqual(100.0f, Time.timeScale);
#else
// Not sure we can run this test from a player, but just in case, shouldn't clamp.
Assert.AreEqual(1000.0f, Time.timeScale);
#endif
}
}
}
|