Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
baba-s committed Mar 24, 2019
1 parent 8911358 commit ca4965a
Show file tree
Hide file tree
Showing 82 changed files with 3,208 additions and 12 deletions.
21 changes: 9 additions & 12 deletions .gitignore → app/.gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[Ll]ibrary/
[Tt]emp/
[Oo]bj/
[Bb]uild/
[Bb]uilds/
Assets/AssetStoreTools*
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/Assets/AssetStoreTools*

# Visual Studio cache directory
.vs/
# Visual Studio 2015 cache directory
/.vs/

# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
Expand All @@ -22,15 +22,12 @@ ExportedObj/
*.booproj
*.svd
*.pdb
*.opendb

# Unity3D generated meta files
*.pidb.meta
*.pdb.meta

# Unity3D Generated File On Crash Reports
sysinfo.txt

# Builds
*.apk
*.unitypackage
*.apk
8 changes: 8 additions & 0 deletions app/Assets/UniCommonTestRunner.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions app/Assets/UniCommonTestRunner/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions app/Assets/UniCommonTestRunner/Editor/Tests.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using NUnit.Framework;
using UnityEditor;

namespace UniCommonTestRunner
{
public partial class UniCommonTestRunner
{
/// <summary>
/// 加速度センサーが無効になっているかどうかテストします
/// </summary>
[Test]
public void CheckAccelerometerFrequency()
{
Assert.IsTrue( PlayerSettings.accelerometerFrequency == 0 );
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions app/Assets/UniCommonTestRunner/Editor/Tests/CheckAndroidPlugin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using NUnit.Framework;
using System.Linq;
using System.Text;
using UnityEditor;

namespace UniCommonTestRunner
{
public partial class UniCommonTestRunner
{
/// <summary>
/// Android 用のプラグインのプラットフォームが適切に設定されているかどうかテストします
/// </summary>
[Test]
public void CheckAndroidPlugin()
{
var list = AssetDatabase
.GetAllAssetPaths()
.Where( c => c.Contains( "Plugins" ) )
.Where( c => c.Contains( "Android" ) )
.Select( c => AssetImporter.GetAtPath( c ) )
.OfType<PluginImporter>()
.Where( c => c != null )
.Where( c => c.GetCompatibleWithPlatform( BuildTarget.iOS ) )
.Select( c => AssetDatabase.GetAssetPath( c ) )
;

if ( !list.Any() ) return;

var sb = new StringBuilder();

foreach ( var n in list )
{
sb.AppendLine( n );
}

Assert.Fail( sb.ToString() );
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using NUnit.Framework;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEditor.Animations;

namespace UniCommonTestRunner
{
public partial class UniCommonTestRunner
{
/// <summary>
/// Animator Controller のステートが null になっていないかどうかテストします
/// </summary>
[Test]
public void CheckAnimatorControllerState()
{
var list = AssetDatabase
.FindAssets( "t:AnimatorController" )
.Select( AssetDatabase.GUIDToAssetPath )
.Select( c => AssetDatabase.LoadAssetAtPath<AnimatorController>( c ) )
.Where( c => c != null )
.Where( c => HasNullMotion( c ) )
.Select( c => AssetDatabase.GetAssetPath( c ) )
;

if ( !list.Any() ) return;

var sb = new StringBuilder();

foreach ( var n in list )
{
sb.AppendLine( n );
}

Assert.Fail( sb.ToString() );
}

private bool HasNullMotion( AnimatorController controller )
{
foreach ( var layer in controller.layers )
{
if ( layer.stateMachine.states.Any( c => c.state.motion == null ) )
{
return true;
}
}
return false;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using NUnit.Framework;
using UniCommonTestRunner.Internal;
using UnityEditor;
using UnityEngine;

namespace UniCommonTestRunner
{
/// <summary>
/// Audio Listener が存在しないかどうかテストします
/// </summary>
public partial class UniCommonTestRunner
{
[MenuItem( UCTRConst.MENU_ITEM_ROOT + "Check Audio Listener Exist" )]
private static void CheckAudioListenerExistFromMenu()
{
UCTRUtils.CheckGameObjectsInCurrentScene( "CheckAudioListenerExist", DoCheckAudioListenerExist );
}

[Test]
public void CheckAudioListenerExist()
{
UCTRUtils.CheckGameObjectsAll( DoCheckAudioListenerExist );
}

private static bool DoCheckAudioListenerExist( GameObject go )
{
return go.GetComponent<AudioListener>();
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using NUnit.Framework;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEditor.SceneManagement;
using UnityEngine;

namespace UniCommonTestRunner
{
public partial class UniCommonTestRunner
{
/// <summary>
/// Audio Listener が複数存在しないかどうかテストします
/// </summary>
[Test]
public void CheckAudioListenerMultiple()
{
var settings = UCTRUtils.GetSettings();

Assert.IsNotNull( settings, "`UCTRSettings.asset` could not be found." );

if ( settings == null ) return;

var result = new List<string>();

foreach ( var n in settings.GetScenePathList() )
{
var scene = EditorSceneManager.OpenScene( n );
var count = Resources
.FindObjectsOfTypeAll<GameObject>()
.Where( c => c.scene.isLoaded )
.Where( c => c.hideFlags == HideFlags.None )
.Count( c => c.GetComponent<AudioListener>() != null )
;

if ( count <= 1 ) continue;

result.Add( n );
}

if ( result.Count <= 0 ) return;

var sb = new StringBuilder();

foreach ( var n in result )
{
sb.AppendLine( n );
}

Assert.Fail( sb.ToString() );
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions app/Assets/UniCommonTestRunner/Editor/Tests/CheckCamera2D.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using NUnit.Framework;
using UniCommonTestRunner.Internal;
using UnityEditor;
using UnityEngine;

namespace UniCommonTestRunner
{
/// <summary>
/// 2D のカメラのパタメータが正しく設定されているかどうかテストします
/// </summary>
public partial class UniCommonTestRunner
{
[MenuItem( UCTRConst.MENU_ITEM_ROOT + "Check Camera 2D" )]
private static void CheckCamera2DFromMenu()
{
UCTRUtils.CheckGameObjectsInCurrentScene( "CheckCamera2D", DoCheckCamera2D );
}

[Test]
public void CheckCamera2D()
{
UCTRUtils.CheckGameObjectsAll( DoCheckCamera2D );
}

private static bool DoCheckCamera2D( GameObject go )
{
var camera = go.GetComponent<Camera>();
if ( camera == null ) return false;
if ( camera.clearFlags != CameraClearFlags.Color ) return true;
if ( !camera.orthographic ) return true;
if ( camera.orthographicSize != 5 ) return true;
if ( camera.useOcclusionCulling ) return true;
return false;
}
}
}
11 changes: 11 additions & 0 deletions app/Assets/UniCommonTestRunner/Editor/Tests/CheckCamera2D.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ca4965a

Please sign in to comment.