Skip to content

Commit eed49ab

Browse files
test(audience-sample): pin frame rate to 1 on Linux PlayMode runs
1 parent 8bdb0b0 commit eed49ab

2 files changed

Lines changed: 53 additions & 0 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#nullable enable
2+
3+
#if UNITY_STANDALONE_LINUX
4+
using NUnit.Framework;
5+
using UnityEngine;
6+
7+
namespace Immutable.Audience.Samples.SampleApp.Tests
8+
{
9+
// Linux-only test suppression: clamp the player's frame rate to 1 fps
10+
// and disable vsync. The SampleApp PlayMode tests assert on UI Toolkit
11+
// visual-element state, which is layout-driven, not paint-driven.
12+
// Painting fewer frames between coroutine yields removes llvmpipe
13+
// fragment-fill cost without changing what tests observe.
14+
//
15+
// Scope: every test in the Tests assembly when the build target is
16+
// StandaloneLinux64. UNITY_STANDALONE_LINUX is defined by Unity for
17+
// PlayMode runs invoked with -testPlatform StandaloneLinux64.
18+
[SetUpFixture]
19+
public sealed class LinuxRenderSuppression
20+
{
21+
private int _priorTargetFrameRate;
22+
private int _priorVSyncCount;
23+
24+
[OneTimeSetUp]
25+
public void Suppress()
26+
{
27+
_priorTargetFrameRate = Application.targetFrameRate;
28+
_priorVSyncCount = QualitySettings.vSyncCount;
29+
30+
Application.targetFrameRate = 1;
31+
QualitySettings.vSyncCount = 0;
32+
}
33+
34+
[OneTimeTearDown]
35+
public void Restore()
36+
{
37+
Application.targetFrameRate = _priorTargetFrameRate;
38+
QualitySettings.vSyncCount = _priorVSyncCount;
39+
}
40+
}
41+
}
42+
#endif

examples/audience/Assets/SampleApp/Tests/Runtime/LinuxRenderSuppression.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)