-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SDK-381] add test for avatar loader window (#110)
- add test to verify, that the prefab created is a directly linked to object in world without overrides or changes.
- Loading branch information
Showing
5 changed files
with
69 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System.Collections; | ||
using System.Reflection; | ||
using JetBrains.Annotations; | ||
using NUnit.Framework; | ||
using ReadyPlayerMe.Core.Editor; | ||
using UnityEditor; | ||
using UnityEngine; | ||
using UnityEngine.TestTools; | ||
using Assert = UnityEngine.Assertions.Assert; | ||
|
||
namespace ReadyPlayerMe.Core.Tests | ||
{ | ||
public class AvatarLoaderWindowTests | ||
{ | ||
private GameObject avatar; | ||
|
||
[TearDown] | ||
public void Cleanup() | ||
{ | ||
TestUtils.DeleteAvatarDirectoryIfExists(TestAvatarData.DefaultAvatarUri.Guid, true); | ||
TestUtils.DeleteCachedAvatar(TestAvatarData.DefaultAvatarUri.Guid); | ||
if (avatar != null) | ||
{ | ||
Object.DestroyImmediate(avatar); | ||
} | ||
} | ||
|
||
[UnityTest] | ||
public IEnumerator Avatar_Loaded_Stored_And_No_Overrides() | ||
{ | ||
AvatarLoaderEditor window = EditorWindow.GetWindow<AvatarLoaderEditor>(); | ||
|
||
MethodInfo loadAvatarMethod = typeof(AvatarLoaderEditor).GetMethod("LoadAvatar", BindingFlags.NonPublic | BindingFlags.Instance); | ||
|
||
Assert.IsNotNull(loadAvatarMethod); | ||
loadAvatarMethod.Invoke(window, new object[] { TestAvatarData.DefaultAvatarUri.ModelUrl }); | ||
|
||
var time = System.DateTime.Now; | ||
|
||
do | ||
{ | ||
yield return null; | ||
avatar = GameObject.Find(TestAvatarData.DefaultAvatarUri.Guid); | ||
} while (avatar == null && System.DateTime.Now.Subtract(time).Seconds < 5); | ||
|
||
window.Close(); | ||
Assert.IsNotNull(avatar); | ||
var overrides = PrefabUtility.HasPrefabInstanceAnyOverrides(avatar.gameObject, false); | ||
Assert.IsFalse(overrides); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters