forked from vrm-c/UniVRM
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vrm-c#399 vrm-c#400 * BlendShapeClip.Key 追加 * BlendShapeKey(string name, BlendShapePreset preset) を private に。代わりに、CreateFromPreset または CreateUnknown を使用してください * BlendShapeKey.CreateFromClip(BlendShapeKey.CreateFrom からリネーム) * BlendShapeKey.CreateFromPreset(new BlendShpaeKey(BlendShapePreset)からリネーム) * BlendShapeKey.CreateUnknown(new BlendShpaeKey(string)からリネーム) * BlendShapeKey.m_name, Preset を readonly
- Loading branch information
Showing
9 changed files
with
127 additions
and
63 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
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 |
---|---|---|
@@ -1,42 +1,51 @@ | ||
using NUnit.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using VRM; | ||
using System.Reflection; | ||
|
||
|
||
namespace VRM | ||
{ | ||
public class VRMBlendShapeKeyTest | ||
{ | ||
static BlendShapeKey CreateBlendShapeKey(string name, BlendShapePreset preset) | ||
{ | ||
var argTypes = new Type[] { typeof(string), typeof(BlendShapePreset) }; | ||
// private constructor | ||
var constructor = typeof(BlendShapeKey).GetConstructor( | ||
BindingFlags.Instance | BindingFlags.NonPublic, | ||
null, argTypes, null); | ||
return (BlendShapeKey)constructor.Invoke(new object[] { name, preset }); | ||
} | ||
|
||
[Test] | ||
public void KeyTest() | ||
{ | ||
var key = new BlendShapeKey("Blink", BlendShapePreset.Blink); | ||
|
||
Assert.AreEqual(key, new BlendShapeKey("Blink", BlendShapePreset.Blink)); | ||
Assert.AreEqual(key, new BlendShapeKey(BlendShapePreset.Blink)); | ||
Assert.AreEqual(key, new BlendShapeKey("xxx", BlendShapePreset.Blink)); | ||
var key = CreateBlendShapeKey("Blink", BlendShapePreset.Blink); | ||
Assert.AreEqual(key, CreateBlendShapeKey("Blink", BlendShapePreset.Blink)); | ||
Assert.AreEqual(key, BlendShapeKey.CreateFromPreset(BlendShapePreset.Blink)); | ||
Assert.AreEqual(key, CreateBlendShapeKey("xxx", BlendShapePreset.Blink)); | ||
|
||
var dict = new Dictionary<BlendShapeKey, float>(); | ||
dict[key] = 1.0f; | ||
|
||
Assert.IsTrue(dict.ContainsKey(new BlendShapeKey("Blink",BlendShapePreset.Blink))); | ||
Assert.IsTrue(dict.ContainsKey(new BlendShapeKey(BlendShapePreset.Blink))); | ||
Assert.IsTrue(dict.ContainsKey(new BlendShapeKey("xxx", BlendShapePreset.Blink))); | ||
Assert.IsTrue(dict.ContainsKey(CreateBlendShapeKey("Blink", BlendShapePreset.Blink))); | ||
Assert.IsTrue(dict.ContainsKey(BlendShapeKey.CreateFromPreset(BlendShapePreset.Blink))); | ||
Assert.IsTrue(dict.ContainsKey(CreateBlendShapeKey("xxx", BlendShapePreset.Blink))); | ||
|
||
dict.Clear(); | ||
var key2 = new BlendShapeKey("Blink"); // name: Blink, Preset: Unknown | ||
|
||
var key2 = BlendShapeKey.CreateUnknown("Blink"); // name: Blink, Preset: Unknown | ||
dict[key2] = 1.0f; | ||
|
||
Assert.AreEqual( key2, new BlendShapeKey("Blink", BlendShapePreset.Unknown)); | ||
Assert.AreNotEqual(key2, new BlendShapeKey("blink")); | ||
Assert.AreNotEqual(key2, new BlendShapeKey("Blink", BlendShapePreset.Blink)); | ||
Assert.AreNotEqual(key2, new BlendShapeKey(BlendShapePreset.Blink)); | ||
|
||
Assert.IsFalse(dict.ContainsKey(new BlendShapeKey("blink"))); | ||
Assert.IsFalse(dict.ContainsKey(new BlendShapeKey("Blink",BlendShapePreset.Blink))); | ||
Assert.IsFalse(dict.ContainsKey(new BlendShapeKey(BlendShapePreset.Blink))); | ||
|
||
|
||
Assert.AreEqual(key2, CreateBlendShapeKey("Blink", BlendShapePreset.Unknown)); | ||
Assert.AreNotEqual(key2, BlendShapeKey.CreateUnknown("blink")); | ||
Assert.AreNotEqual(key2, CreateBlendShapeKey("Blink", BlendShapePreset.Blink)); | ||
Assert.AreNotEqual(key2, BlendShapeKey.CreateFromPreset(BlendShapePreset.Blink)); | ||
|
||
Assert.IsFalse(dict.ContainsKey(BlendShapeKey.CreateUnknown("blink"))); | ||
Assert.IsFalse(dict.ContainsKey(CreateBlendShapeKey("Blink", BlendShapePreset.Blink))); | ||
Assert.IsFalse(dict.ContainsKey(BlendShapeKey.CreateFromPreset(BlendShapePreset.Blink))); | ||
} | ||
} | ||
} | ||
} |
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
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
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