Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor tests #51

Merged
merged 1 commit into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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