forked from Unity-Technologies/EntityComponentSystemSamples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSamplesTest.cs
More file actions
59 lines (53 loc) · 1.76 KB
/
Copy pathSamplesTest.cs
File metadata and controls
59 lines (53 loc) · 1.76 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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using NUnit.Framework;
using Unity.Entities;
using UnityEngine.SceneManagement;
using UnityEngine.TestTools;
namespace Unity.Physics.Samples.Test
{
[TestFixture]
class UnityPhysicsSamplesTest
{
protected static IEnumerable GetScenes()
{
var sceneCount = SceneManager.sceneCountInBuildSettings;
var scenes = new List<string>();
for(int sceneIndex = 0; sceneIndex < sceneCount; ++sceneIndex)
{
var scenePath = SceneUtility.GetScenePathByBuildIndex(sceneIndex);
if (scenePath.Contains("InitTestScene"))
continue;
scenes.Add(scenePath);
}
scenes.Sort();
return scenes;
}
[UnityTest]
[Timeout(60000)]
public virtual IEnumerator LoadScenes([ValueSource(nameof(GetScenes))] string scenePath)
{
// Log scene name in case Unity crashes and test results aren't written out.
Debug.Log("Loading " + scenePath);
LogAssert.Expect(LogType.Log, "Loading " + scenePath);
SceneManager.LoadScene(scenePath);
yield return new WaitForSeconds(1);
EntitiesCleanup();
yield return new WaitForFixedUpdate();
LogAssert.NoUnexpectedReceived();
}
[TearDown]
public void TearDown()
{
EntitiesCleanup();
}
protected static void EntitiesCleanup()
{
var entityManager = World.Active.EntityManager;
var entities = entityManager.GetAllEntities();
entityManager.DestroyEntity(entities);
entities.Dispose();
}
}
}