Skip to content

Commit

Permalink
Merge pull request #51 from nowsprinting/chore/refactor_tests
Browse files Browse the repository at this point in the history
Refactor tests
  • Loading branch information
nowsprinting authored Dec 1, 2023
2 parents 83a2fe8 + c94497b commit b50a150
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
8 changes: 4 additions & 4 deletions Tests/Runtime/Attributes/GizmosShowOnGameViewAttributeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,35 +40,35 @@ public IEnumerator UnityTearDown()
[Test]
[CreateScene(camera: true, light: true)]
[GizmosShowOnGameView]
[Description("See the screenshot yourself! Be a witness!!")]
public void Attach_True_ShowGizmos()
{
// See the screenshot yourself! Be a witness!!
}

[Test]
[CreateScene(camera: true, light: true)]
[GizmosShowOnGameView(false)]
[Description("See the screenshot yourself! Be a witness!!")]
public void Attach_False_HideGizmos()
{
// See the screenshot yourself! Be a witness!!
}

[Test]
[CreateScene(camera: true, light: true)]
[GizmosShowOnGameView]
[Description("See the screenshot yourself! Be a witness!!")]
public async Task AttachToAsyncTest_ShowGizmos()
{
await Task.Yield();
// See the screenshot yourself! Be a witness!!
}

[UnityTest]
[CreateScene(camera: true, light: true)]
[GizmosShowOnGameView]
[Description("See the screenshot yourself! Be a witness!!")]
public IEnumerator AttachToUnityTest_ShowGizmos()
{
yield return null;
// See the screenshot yourself! Be a witness!!
}
}
}
16 changes: 6 additions & 10 deletions Tests/Runtime/Attributes/TakeScreenshotAttributeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ public void Attach_SaveScreenshotToDefaultPath_ExistFile()
var path = Path.Combine(
_defaultOutputDirectory,
$"{nameof(Attach_SaveScreenshotToDefaultPath)}.png");
Assert.That(path, Does.Exist);
Assert.That(File.ReadAllBytes(path), Has.Length.GreaterThan(FileSizeThreshold));
Assert.That(new FileInfo(path), Has.Length.GreaterThan(FileSizeThreshold));
}

[Test, Order(0)]
Expand Down Expand Up @@ -87,8 +86,7 @@ public void AttachToAsyncTest_SaveScreenshotToDefaultPath_ExistFile()
var path = Path.Combine(
_defaultOutputDirectory,
$"{nameof(AttachToAsyncTest_SaveScreenshotToDefaultPath)}.png");
Assert.That(path, Does.Exist);
Assert.That(File.ReadAllBytes(path), Has.Length.GreaterThan(FileSizeThreshold));
Assert.That(new FileInfo(path), Has.Length.GreaterThan(FileSizeThreshold));
}

[UnityTest, Order(0)]
Expand Down Expand Up @@ -116,8 +114,7 @@ public void AttachToUnityTest_SaveScreenshotToDefaultPath_ExistFile()
var path = Path.Combine(
_defaultOutputDirectory,
$"{nameof(AttachToUnityTest_SaveScreenshotToDefaultPath)}.png");
Assert.That(path, Does.Exist);
Assert.That(File.ReadAllBytes(path), Has.Length.GreaterThan(FileSizeThreshold));
Assert.That(new FileInfo(path), Has.Length.GreaterThan(FileSizeThreshold));
}

[Test, Order(0)]
Expand Down Expand Up @@ -235,8 +232,7 @@ public void AttachWithSuperSize_SaveSuperSizeScreenshot_ExistFile()
var path = Path.Combine(
_defaultOutputDirectory,
$"{nameof(AttachWithSuperSize_SaveSuperSizeScreenshot)}.png");
Assert.That(path, Does.Exist);
Assert.That(File.ReadAllBytes(path), Has.Length.GreaterThan(FileSizeThreshold2X));
Assert.That(new FileInfo(path), Has.Length.GreaterThan(FileSizeThreshold2X));
// Note: This test fails with stereo rendering settings.
// See: https://docs.unity3d.com/Manual/SinglePassStereoRendering.html
}
Expand All @@ -260,13 +256,13 @@ public void AttachWithStereoCaptureMode_SaveStereoScreenshot()
}

[Test, Order(1)]
[Description("Is it a stereo screenshot? See for yourself! Be a witness!!")]
public void AttachWithStereoCaptureMode_SaveStereoScreenshot_ExistFile()
{
var path = Path.Combine(
_defaultOutputDirectory,
$"{nameof(AttachWithStereoCaptureMode_SaveStereoScreenshot)}.png");
Assert.That(path, Does.Exist);
// Is it a stereo screenshot? See for yourself! Be a witness!!
// Note: Require stereo rendering settings.
// See: https://docs.unity3d.com/Manual/SinglePassStereoRendering.html
}
Expand Down Expand Up @@ -294,13 +290,13 @@ public void AttachWithGizmos_TakeScreenshotWithGizmos()

[Test, Order(1)]
[UnityPlatform(RuntimePlatform.OSXEditor, RuntimePlatform.WindowsEditor, RuntimePlatform.LinuxEditor)]
[Description("Is Gizmos shown in the screenshot? See for yourself! Be a witness!!")]
public void AttachWithGizmos_TakeScreenshotWithGizmos_ExistFile()
{
var path = Path.Combine(
_defaultOutputDirectory,
$"{nameof(AttachWithGizmos_TakeScreenshotWithGizmos)}.png");
Assert.That(path, Does.Exist);
// Is Gizmos shown in the screenshot? See for yourself! Be a witness!!
}
}
}
3 changes: 1 addition & 2 deletions Tests/RuntimeInternals/ScreenshotHelperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ public IEnumerator TakeScreenshot_SaveToDefaultPath()

yield return ScreenshotHelper.TakeScreenshot(); // default filename is member name when internal

Assert.That(path, Does.Exist);
Assert.That(File.ReadAllBytes(path), Has.Length.GreaterThan(FileSizeThreshold));
Assert.That(new FileInfo(path), Has.Length.GreaterThan(FileSizeThreshold));
}

[UnityTest]
Expand Down

0 comments on commit b50a150

Please sign in to comment.