Skip to content

Commit

Permalink
Merge pull request #40 from nowsprinting/fix/specify_directory_on_player
Browse files Browse the repository at this point in the history
Fix can specify directory on player
  • Loading branch information
nowsprinting committed Oct 31, 2023
2 parents e567c6a + 77da00d commit a0db5e9
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Runtime/Attributes/TakeScreenshotAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class TakeScreenshotAttribute : NUnitAttribute, IOuterUnityTestAction
/// <br/>
/// Using <c>ScreenCapture.CaptureScreenshotAsTexture</c> internally.
/// </remarks>
/// <param name="directory">Directory to save screenshots relative to project path. Only effective in Editor.</param>
/// <param name="directory">Directory to save screenshots.</param>
/// <param name="filename">Filename to store screenshot.</param>
/// <param name="superSize">The factor to increase resolution with.</param>
/// <param name="stereoCaptureMode">The eye texture to capture when stereo rendering is enabled.</param>
Expand Down
2 changes: 1 addition & 1 deletion Runtime/Utils/ScreenshotHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private static string DefaultFilename()
/// <br/>
/// Using <c>ScreenCapture.CaptureScreenshotAsTexture</c> internally.
/// </remarks>
/// <param name="directory">Directory to save screenshots relative to project path. Only effective in Editor.</param>
/// <param name="directory">Directory to save screenshots.</param>
/// <param name="filename">Filename to store screenshot.</param>
/// <param name="superSize">The factor to increase resolution with.</param>
/// <param name="stereoCaptureMode">The eye texture to capture when stereo rendering is enabled.</param>
Expand Down
4 changes: 3 additions & 1 deletion RuntimeInternals/GameViewControlHelper.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Copyright (c) 2023 Koji Hasegawa.
// This software is released under the MIT License.

using UnityEngine;
#if UNITY_EDITOR
using TestHelper.RuntimeInternals.Wrappers.UnityEditor;
using UnityEditor;
using UnityEngine;
#endif

namespace TestHelper.RuntimeInternals
{
Expand Down
4 changes: 2 additions & 2 deletions RuntimeInternals/ScreenshotHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private static string DefaultDirectoryPath()
/// <br/>
/// Using <c>ScreenCapture.CaptureScreenshotAsTexture</c> internally.
/// </remarks>
/// <param name="directory">Directory to save screenshots relative to project path. Only effective in Editor.</param>
/// <param name="directory">Directory to save screenshots.</param>
/// <param name="filename">Filename to store screenshot.</param>
/// <param name="superSize">The factor to increase resolution with.</param>
/// <param name="stereoCaptureMode">The eye texture to capture when stereo rendering is enabled.</param>
Expand Down Expand Up @@ -63,7 +63,7 @@ public static IEnumerator TakeScreenshot(
// Note: This is not the case since it is a coroutine.
}

if (Application.isEditor && directory != null)
if (directory != null)
{
directory = Path.GetFullPath(directory);
}
Expand Down
20 changes: 0 additions & 20 deletions Tests/Runtime/Utils/ScreenshotHelperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,26 +71,6 @@ public IEnumerator TakeScreenshot_SpecifyDirectoryInEditor_SaveToSpecifyPath()
Assert.That(path, Does.Exist);
}

[UnityTest]
[UnityPlatform(exclude =
new[] { RuntimePlatform.OSXEditor, RuntimePlatform.WindowsEditor, RuntimePlatform.LinuxEditor })]
[LoadScene(TestScene)]
public IEnumerator TakeScreenshot_SpecifyDirectoryOnPlayer_SaveToDefaultPath()
{
const string RelativePath = "Logs/Screenshots";
var path = Path.Combine(_defaultOutputDirectory,
$"{nameof(TakeScreenshot_SpecifyDirectoryOnPlayer_SaveToDefaultPath)}.png");
if (File.Exists(path))
{
File.Delete(path);
}

Assume.That(path, Does.Not.Exist);

yield return ScreenshotHelper.TakeScreenshot(directory: RelativePath);
Assert.That(path, Does.Exist);
}

[UnityTest]
[LoadScene(TestScene)]
public IEnumerator TakeScreenshot_SpecifyFilename_SaveToSpecifyPath()
Expand Down

0 comments on commit a0db5e9

Please sign in to comment.