forked from Unity-Technologies/EntityComponentSystemSamples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHavokPhysicsSamplesTest.cs
More file actions
83 lines (68 loc) · 2.98 KB
/
Copy pathHavokPhysicsSamplesTest.cs
File metadata and controls
83 lines (68 loc) · 2.98 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using NUnit.Framework;
using System.Collections;
using Unity.Entities;
using Unity.Physics.Systems;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.TestTools;
namespace Unity.Physics.Samples.Test
{
#if HAVOK_PHYSICS_EXISTS
[TestFixture]
class HavokPhysicsSamplesTestMT : UnityPhysicsSamplesTest
{
[UnityTest]
[Timeout(240000)]
public override IEnumerator LoadScenes([ValueSource(nameof(UnityPhysicsSamplesTest.GetScenes))] string scenePath)
{
// Don't create log messages about the number of trial days remaining
PlayerPrefs.SetInt("Havok.Auth.SuppressDialogs", 1);
// Log scene name in case Unity crashes and test results aren't written out.
Debug.Log("Loading " + scenePath);
LogAssert.Expect(LogType.Log, "Loading " + scenePath);
// Ensure Havok
var world = World.DefaultGameObjectInjectionWorld;
var system = world.GetOrCreateSystem<EnsureHavokSystem>();
system.Enabled = true;
SceneManager.LoadScene(scenePath);
yield return new WaitForSeconds(1);
UnityPhysicsSamplesTest.ResetDefaultWorld();
yield return new WaitForFixedUpdate();
LogAssert.NoUnexpectedReceived();
PlayerPrefs.DeleteKey("Havok.Auth.SuppressDialogs");
}
}
[TestFixture]
class HavokPhysicsSamplesTestST : UnityPhysicsSamplesTest
{
[UnityTest]
[Timeout(240000)]
public override IEnumerator LoadScenes([ValueSource(nameof(UnityPhysicsSamplesTest.GetScenes))] string scenePath)
{
// Don't create log messages about the number of trial days remaining
PlayerPrefs.SetInt("Havok.Auth.SuppressDialogs", 1);
// Log scene name in case Unity crashes and test results aren't written out.
Debug.Log("Loading " + scenePath);
LogAssert.Expect(LogType.Log, "Loading " + scenePath);
// Ensure Havok
var world = World.DefaultGameObjectInjectionWorld;
var system = world.GetOrCreateSystem<EnsureHavokSystem>();
system.Enabled = true;
// Ensure ST simulation
var stSystem = world.GetExistingSystem<EnsureSTSimulation>();
{
Assert.IsNull(stSystem, "The 'EnsureSTSimulation' system should only be created by the 'HavokPhysicsSamplesTest.LoadScenes' function!");
stSystem = new EnsureSTSimulation();
world.AddSystem(stSystem);
world.GetExistingSystem<FixedStepSimulationSystemGroup>().AddSystemToUpdateList(stSystem);
}
SceneManager.LoadScene(scenePath);
yield return new WaitForSeconds(1);
UnityPhysicsSamplesTest.ResetDefaultWorld();
yield return new WaitForFixedUpdate();
LogAssert.NoUnexpectedReceived();
PlayerPrefs.DeleteKey("Havok.Auth.SuppressDialogs");
}
}
#endif
}