Skip to content

Commit af8e8fc

Browse files
YvainRaeymaekersEvergreen
authored andcommitted
[content automatically redacted] touching PlatformDependent folder
1 parent 06cb6ef commit af8e8fc

File tree

1 file changed

+48
-1
lines changed
  • Tests/SRPTests/Projects/HDRP_Tests/Assets/GraphicTests/HDRP_EditModeTests

1 file changed

+48
-1
lines changed

Tests/SRPTests/Projects/HDRP_Tests/Assets/GraphicTests/HDRP_EditModeTests/PreviewTests.cs

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using NUnit.Framework;
1+
using NUnit.Framework;
22
using UnityEngine;
33
using UnityEngine.TestTools;
44
using Unity.Graphics.Tests;
@@ -7,6 +7,7 @@
77
using UnityEditor.SceneManagement;
88
using UnityEngine.Rendering;
99
using Object = UnityEngine.Object;
10+
using System;
1011

1112
namespace UnityEditor.Previews
1213
{
@@ -104,6 +105,52 @@ public IEnumerator CreatePreviewDoesNotLeakMemoryInWorkers()
104105
}
105106
}
106107

108+
// Test case for UUM-63257
109+
[UnityTest]
110+
public IEnumerator CreateMeshPreviewDoesNotLeakMemoryInWorkers()
111+
{
112+
var logEntryString = "There are remaining Allocations on the JobTempAlloc.";
113+
int prevLogEntryCount = GetLogEntryCount(logEntryString);
114+
115+
var folderName = "Create_Mesh_Preview_Test";
116+
try
117+
{
118+
AssetDatabase.CreateFolder("Assets", folderName);
119+
120+
for (int i = 0; i < 2; ++i)
121+
{
122+
var meshPath = Path.Combine($"Assets/{folderName}", $"m{i}.mesh");
123+
var mesh = CreateUniqueMiniMesh();
124+
AssetDatabase.CreateAsset(mesh, meshPath);
125+
yield return new WaitForPreview(mesh, 90.0f);
126+
}
127+
128+
//Here we catch any unexpected memory leak messages
129+
int logEntryCountAfterTest = GetLogEntryCount(logEntryString);
130+
Assert.AreEqual(prevLogEntryCount, logEntryCountAfterTest, "There were leaks in the test");
131+
}
132+
finally
133+
{
134+
AssetDatabase.DeleteAsset($"Assets/{folderName}");
135+
}
136+
}
137+
138+
Mesh CreateUniqueMiniMesh()
139+
{
140+
// Use random value because the preview won't be regenerated if the mesh is already present in the library cache
141+
float randomValue = (float)new System.Random(Guid.NewGuid().GetHashCode()).NextDouble();
142+
143+
Mesh mesh = new Mesh();
144+
mesh.vertices = new Vector3[]
145+
{
146+
new Vector3(randomValue, 0, 0),
147+
new Vector3(3.0f, 0, 0),
148+
new Vector3(0, 1.0f, 0)
149+
};
150+
151+
return mesh;
152+
}
153+
107154

108155
[UnityTest]
109156
public IEnumerator AssetPreviewIsCorrect()

0 commit comments

Comments
 (0)