FbxPoseTest.cs 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // ***********************************************************************
  2. // Copyright (c) 2017 Unity Technologies. All rights reserved.
  3. //
  4. // Licensed under the ##LICENSENAME##.
  5. // See LICENSE.md file in the project root for full license information.
  6. // ***********************************************************************
  7. using NUnit.Framework;
  8. using System.Collections;
  9. using Autodesk.Fbx;
  10. namespace Autodesk.Fbx.UnitTests
  11. {
  12. public class FbxPoseTest : Base<FbxPose>
  13. {
  14. [Test]
  15. public void TestSetIsBindPose ()
  16. {
  17. var fbxPose = CreateObject ("pose");
  18. fbxPose.SetIsBindPose (false);
  19. Assert.IsFalse (fbxPose.IsBindPose ());
  20. }
  21. [Test]
  22. public void TestAdd()
  23. {
  24. using(var fbxPose = CreateObject ("pose")){
  25. using(var fbxNode = FbxNode.Create (Manager, "node"))
  26. using(var fbxMatrix = new FbxMatrix ()){
  27. Assert.AreEqual (0, fbxPose.GetCount ());
  28. // test basic use
  29. int index = fbxPose.Add (fbxNode, fbxMatrix); // returns -1 if it fails
  30. Assert.Greater(index, -1);
  31. Assert.AreEqual (fbxPose.GetNode (index), fbxNode);
  32. Assert.AreEqual (fbxPose.GetMatrix (index), fbxMatrix);
  33. Assert.AreEqual (1, fbxPose.GetCount ());
  34. // test adding null
  35. Assert.That (() => {
  36. fbxPose.Add (null, null);
  37. }, Throws.Exception.TypeOf<System.ArgumentNullException> ());
  38. fbxPose.Add (FbxNode.Create(Manager,"node1"), fbxMatrix);
  39. Assert.AreEqual (2, fbxPose.GetCount ());
  40. }
  41. var node = FbxNode.Create (Manager, "node1");
  42. using (var fbxMatrix = new FbxMatrix ()) {
  43. // test adding invalid node
  44. node.Destroy ();
  45. Assert.That (() => {
  46. fbxPose.Add (node, fbxMatrix);
  47. }, Throws.Exception.TypeOf<System.ArgumentNullException> ());
  48. }
  49. using (var fbxNode = FbxNode.Create (Manager, "node2")){
  50. var fbxMatrix = new FbxMatrix ();
  51. // test adding invalid matrix
  52. fbxMatrix.Dispose ();
  53. Assert.That (() => {
  54. fbxPose.Add (fbxNode, fbxMatrix);
  55. }, Throws.Exception.TypeOf<System.ArgumentNullException> ());
  56. }
  57. using (var fbxNode = FbxNode.Create (Manager, "node3"))
  58. using (var fbxMatrix = new FbxMatrix ()) {
  59. // test with local matrix arg
  60. int index = fbxPose.Add (fbxNode, fbxMatrix, true); // false is default
  61. Assert.Greater(index, -1);
  62. Assert.AreEqual (fbxPose.GetNode (index), fbxNode);
  63. Assert.AreEqual (fbxPose.GetMatrix (index), fbxMatrix);
  64. }
  65. using (var fbxNode = FbxNode.Create (Manager, "node4"))
  66. using (var fbxMatrix = new FbxMatrix ()) {
  67. // test with multiple bind pose arg
  68. int index = fbxPose.Add (fbxNode, fbxMatrix, false, false); // true is default
  69. Assert.Greater(index, -1);
  70. Assert.AreEqual (fbxPose.GetNode (index), fbxNode);
  71. Assert.AreEqual (fbxPose.GetMatrix (index), fbxMatrix);
  72. }
  73. }
  74. }
  75. }
  76. }