00001
00034 #ifdef THIS_DOESNT_LINK
00035
00036
00037 #include <tut/tut.h>
00038 #include "lltut.h"
00039 #include "linden_common.h"
00040 #include "m4math.h"
00041 #include "v3math.h"
00042 #include "lljoint.h"
00043
00044
00045 namespace tut
00046 {
00047 struct lljoint_data
00048 {
00049 };
00050 typedef test_group<lljoint_data> lljoint_test;
00051 typedef lljoint_test::object lljoint_object;
00052 tut::lljoint_test lljoint_testcase("lljoint");
00053
00054 template<> template<>
00055 void lljoint_object::test<1>()
00056 {
00057 LLJoint lljoint;
00058 LLJoint* jnt = lljoint.getParent();
00059 ensure("getParent() failed ", (NULL == jnt));
00060 ensure("getRoot() failed ", (&lljoint == lljoint.getRoot()));
00061 }
00062
00063 template<> template<>
00064 void lljoint_object::test<2>()
00065 {
00066 std::string str = "LLJoint";
00067 LLJoint parent(str), child;
00068 child.setup(str, &parent);
00069 LLJoint* jnt = child.getParent();
00070 ensure("setup() failed ", (&parent == jnt));
00071 }
00072
00073 template<> template<>
00074 void lljoint_object::test<3>()
00075 {
00076 LLJoint parent, child;
00077 std::string str = "LLJoint";
00078 child.setup(str, &parent);
00079 LLJoint* jnt = parent.findJoint(str);
00080 ensure("findJoint() failed ", (&child == jnt));
00081 }
00082
00083 template<> template<>
00084 void lljoint_object::test<4>()
00085 {
00086 LLJoint parent;
00087 std::string str1 = "LLJoint", str2;
00088 parent.setName(str1);
00089 str2 = parent.getName();
00090 ensure("setName() failed ", (str1 == str2));
00091 }
00092
00093 template<> template<>
00094 void lljoint_object::test<5>()
00095 {
00096 LLJoint lljoint;
00097 LLVector3 vec3(2.3f,30.f,10.f);
00098 lljoint.setPosition(vec3);
00099 LLVector3 pos = lljoint.getPosition();
00100 ensure("setPosition()/getPosition() failed ", (vec3 == pos));
00101 }
00102
00103 template<> template<>
00104 void lljoint_object::test<6>()
00105 {
00106 LLJoint lljoint;
00107 LLVector3 vec3(2.3f,30.f,10.f);
00108 lljoint.setWorldPosition(vec3);
00109 LLVector3 pos = lljoint.getWorldPosition();
00110 ensure("1:setWorldPosition()/getWorldPosition() failed ", (vec3 == pos));
00111 LLVector3 lastPos = lljoint.getLastWorldPosition();
00112 ensure("2:getLastWorldPosition failed ", (vec3 == lastPos));
00113 }
00114
00115 template<> template<>
00116 void lljoint_object::test<7>()
00117 {
00118 LLJoint lljoint("LLJoint");
00119 LLQuaternion q(2.3f,30.f,10.f,1.f);
00120 lljoint.setRotation(q);
00121 LLQuaternion rot = lljoint.getRotation();
00122 ensure("setRotation()/getRotation() failed ", (q == rot));
00123 }
00124 template<> template<>
00125 void lljoint_object::test<8>()
00126 {
00127 LLJoint lljoint("LLJoint");
00128 LLQuaternion q(2.3f,30.f,10.f,1.f);
00129 lljoint.setWorldRotation(q);
00130 LLQuaternion rot = lljoint.getWorldRotation();
00131 ensure("1:setWorldRotation()/getWorldRotation() failed ", (q == rot));
00132 LLQuaternion lastRot = lljoint.getLastWorldRotation();
00133 ensure("2:getLastWorldRotation failed ", (q == lastRot));
00134 }
00135
00136 template<> template<>
00137 void lljoint_object::test<9>()
00138 {
00139 LLJoint lljoint;
00140 LLVector3 vec3(2.3f,30.f,10.f);
00141 lljoint.setScale(vec3);
00142 LLVector3 scale = lljoint.getScale();
00143 ensure("setScale()/getScale failed ", (vec3 == scale));
00144 }
00145
00146 template<> template<>
00147 void lljoint_object::test<10>()
00148 {
00149 LLJoint lljoint("LLJoint");
00150 LLMatrix4 mat;
00151 mat.identity();
00152 lljoint.setWorldMatrix(mat);
00153 LLMatrix4 mat4 = lljoint.getWorldMatrix();
00154 ensure("setWorldMatrix()/getWorldMatrix failed ", (mat4 == mat));
00155 }
00156
00157 template<> template<>
00158 void lljoint_object::test<11>()
00159 {
00160 LLJoint lljoint("parent");
00161 S32 joint_num = 12;
00162 lljoint.setJointNum(joint_num);
00163 S32 jointNum = lljoint.getJointNum();
00164 ensure("setJointNum()/getJointNum failed ", (jointNum == joint_num));
00165 }
00166
00167 template<> template<>
00168 void lljoint_object::test<12>()
00169 {
00170 LLJoint lljoint;
00171 LLVector3 vec3(2.3f,30.f,10.f);
00172 lljoint.setSkinOffset(vec3);
00173 LLVector3 offset = lljoint.getSkinOffset();
00174 ensure("1:setSkinOffset()/getSkinOffset() failed ", (vec3 == offset));
00175 }
00176
00177 template<> template<>
00178 void lljoint_object::test<13>()
00179 {
00180 LLJoint lljointgp("gparent");
00181 LLJoint lljoint("parent");
00182 LLJoint lljoint1("child1");
00183 lljoint.addChild(&lljoint1);
00184 LLJoint lljoint2("child2");
00185 lljoint.addChild(&lljoint2);
00186 LLJoint lljoint3("child3");
00187 lljoint.addChild(&lljoint3);
00188
00189 LLJoint* jnt = NULL;
00190 jnt = lljoint2.getParent();
00191 ensure("addChild() failed ", (&lljoint == jnt));
00192 LLJoint* jnt1 = lljoint.findJoint("child3");
00193 ensure("findJoint() failed ", (&lljoint3 == jnt1));
00194 lljoint.removeChild(&lljoint3);
00195 LLJoint* jnt2 = lljoint.findJoint("child3");
00196 ensure("removeChild() failed ", (NULL == jnt2));
00197
00198 lljointgp.addChild(&lljoint);
00199 ensure("GetParent() failed ", (&lljoint== lljoint2.getParent()));
00200 ensure("getRoot() failed ", (&lljointgp == lljoint2.getRoot()));
00201
00202 ensure("getRoot() failed ", &lljoint1 == lljoint.findJoint("child1"));
00203
00204 lljointgp.removeAllChildren();
00205
00206 ensure("removeAllChildren() failed ", (NULL == lljointgp.findJoint("child1")));
00207
00208 ensure("removeAllChildren() failed ", (&lljoint1 == lljoint.findJoint("child1")));
00209 }
00210
00211 template<> template<>
00212 void lljoint_object::test<14>()
00213 {
00214 LLJoint lljointgp("gparent");
00215
00216 LLJoint llparent1("parent1");
00217 LLJoint llparent2("parent2");
00218
00219 LLJoint llchild("child1");
00220 LLJoint lladoptedchild("child2");
00221 llparent1.addChild(&llchild);
00222 llparent1.addChild(&lladoptedchild);
00223
00224 llparent2.addChild(&lladoptedchild);
00225 ensure("1. addChild failed to remove prior parent", lladoptedchild.getParent() == &llparent2);
00226 ensure("2. addChild failed to remove prior parent", llparent1.findJoint("child2") == NULL);
00227 }
00228
00229
00230
00231 Test cases for the following not added. They perform operations
00232 on underlying LLXformMatrix and LLVector3 elements which have
00233 been unit tested separately.
00234 Unit Testing these functions will basically require re-implementing
00235 logic of these function in the test case itself
00236
00237 1) void WorldMatrixChildren();
00238 2) void updateWorldMatrixParent();
00239 3) void updateWorldPRSParent();
00240 4) void updateWorldMatrix();
00241 5) LLXformMatrix *getXform() { return &mXform; }
00242 6) void setConstraintSilhouette(LLDynamicArray<LLVector3>& silhouette);
00243 7) void clampRotation(LLQuaternion old_rot, LLQuaternion new_rot);
00244
00245
00246 }
00247 #endif // THIS_DOESNT_LINK