Skip to content

Commit

Permalink
Added Script icon check and fixed formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
FilipAlg committed Dec 3, 2024
1 parent 3d92762 commit 10a3e4c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using UnityEditor;
using UnityEngine;

using Assembly = System.Reflection.Assembly;

namespace AGXUnityTesting
{
public class HelpURLTest
public class EditorMetadataTests
{
[Test]
public void HelpURLTestSimplePasses()
public void ScriptsHaveHelpURLs()
{
var asm = Assembly.GetAssembly(typeof(RigidBody));
List<Type> missing = new List<Type>();
Expand All @@ -37,5 +38,25 @@ public void HelpURLTestSimplePasses()
Assert.Fail( errStr );
}
}

private void CheckScriptIconsInDirectory( string path )
{
if ( System.IO.Directory.Exists( path ) ) {
foreach ( var subfile in System.IO.Directory.EnumerateFiles( path ) )
CheckScriptIconsInDirectory( subfile );
}
else if ( path.EndsWith( ".cs" ) ) {
var mi = AssetImporter.GetAtPath( path ) as MonoImporter;
Assert.NotNull( mi.GetIcon(), $"Script file '{path}' has no icon" );
}

}

[Test]
public void ScriptsHaveIcons()
{
var sourceDir = AGXUnityEditor.IO.Utils.AGXUnitySourceDirectory;
CheckScriptIconsInDirectory( sourceDir );
}
}
}
File renamed without changes.
16 changes: 10 additions & 6 deletions Tests/TestUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
#define TEST_REALTIME_SYNC
#endif

#if TEST_NO_REALTIME_SYNC
#undef TEST_REALTIME_SYNC
#endif

using AGXUnity;
using System.Collections;
using UnityEngine;
Expand All @@ -12,35 +16,35 @@ public static class TestUtils
{
public static IEnumerator WaitUntilLoaded()
{
if ( Application.isPlaying )
if ( !Application.isPlaying )
Debug.LogError( "TestUtils are not supported in edit-mode" );
else {
yield return new WaitForEndOfFrame();
#if !TEST_REALTIME_SYNC
Simulation.Instance.AutoSteppingMode = Simulation.AutoSteppingModes.Disabled;
Simulation.Instance.AutoSteppingMode = Simulation.AutoSteppingModes.Disabled;
#endif
}
}

public static IEnumerator SimulateTo( float time )
{
if ( Application.isPlaying )
if ( !Application.isPlaying )
Debug.LogError( "TestUtils are not supported in edit-mode" );
else {
yield return WaitUntilLoaded();
while ( Simulation.Instance.Native.getTimeStamp() < time ) {
#if TEST_REALTIME_SYNC
yield return new WaitForFixedUpdate();
#else
Simulation.Instance.DoStep();
Simulation.Instance.DoStep();
#endif
}
}
}

public static IEnumerator SimulateSeconds( float time )
{
if ( Application.isPlaying )
if ( !Application.isPlaying )
Debug.LogError( "TestUtils are not supported in edit-mode" );
else {
yield return WaitUntilLoaded();
Expand All @@ -49,7 +53,7 @@ public static IEnumerator SimulateSeconds( float time )
#if TEST_REALTIME_SYNC
yield return new WaitForFixedUpdate();
#else
Simulation.Instance.DoStep();
Simulation.Instance.DoStep();
#endif
}
}
Expand Down

0 comments on commit 10a3e4c

Please sign in to comment.