aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/test/lljoint_tut.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:02 -0500
committerJacek Antonelli2008-08-15 23:45:02 -0500
commitd644fc64407dcd14ffcee6a0e9fbe28ee3a4e9bd (patch)
tree7ed0c2c27d717801238a2e6b5749cd5bf88c3059 /linden/indra/test/lljoint_tut.cpp
parentSecond Life viewer sources 1.17.3.0 (diff)
downloadmeta-impy-d644fc64407dcd14ffcee6a0e9fbe28ee3a4e9bd.zip
meta-impy-d644fc64407dcd14ffcee6a0e9fbe28ee3a4e9bd.tar.gz
meta-impy-d644fc64407dcd14ffcee6a0e9fbe28ee3a4e9bd.tar.bz2
meta-impy-d644fc64407dcd14ffcee6a0e9fbe28ee3a4e9bd.tar.xz
Second Life viewer sources 1.18.0.6
Diffstat (limited to 'linden/indra/test/lljoint_tut.cpp')
-rw-r--r--linden/indra/test/lljoint_tut.cpp244
1 files changed, 244 insertions, 0 deletions
diff --git a/linden/indra/test/lljoint_tut.cpp b/linden/indra/test/lljoint_tut.cpp
new file mode 100644
index 0000000..5be81ae
--- /dev/null
+++ b/linden/indra/test/lljoint_tut.cpp
@@ -0,0 +1,244 @@
1/**
2 * @file lljoint_tut.cpp
3 * @author Adroit
4 * @date 2007=-03
5 * @brief lljoint test cases.
6 *
7 * Copyright (c) 2007-2007, Linden Research, Inc.
8 *
9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlife.com/developers/opensource/gplv2
16 *
17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlife.com/developers/opensource/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 */
30
31#ifdef THIS_DOESNT_LINK
32// THIS DOESN'T LINK!
33
34#include <tut/tut.h>
35#include "lltut.h"
36#include "linden_common.h"
37#include "m4math.h"
38#include "v3math.h"
39#include "lljoint.h"
40
41
42namespace tut
43{
44 struct lljoint_data
45 {
46 };
47 typedef test_group<lljoint_data> lljoint_test;
48 typedef lljoint_test::object lljoint_object;
49 tut::lljoint_test lljoint_testcase("lljoint");
50
51 template<> template<>
52 void lljoint_object::test<1>()
53 {
54 LLJoint lljoint;
55 LLJoint* jnt = lljoint.getParent();
56 ensure("getParent() failed ", (NULL == jnt));
57 ensure("getRoot() failed ", (&lljoint == lljoint.getRoot()));
58 }
59
60 template<> template<>
61 void lljoint_object::test<2>()
62 {
63 std::string str = "LLJoint";
64 LLJoint parent(str), child;
65 child.setup(str, &parent);
66 LLJoint* jnt = child.getParent();
67 ensure("setup() failed ", (&parent == jnt));
68 }
69
70 template<> template<>
71 void lljoint_object::test<3>()
72 {
73 LLJoint parent, child;
74 std::string str = "LLJoint";
75 child.setup(str, &parent);
76 LLJoint* jnt = parent.findJoint(str);
77 ensure("findJoint() failed ", (&child == jnt));
78 }
79
80 template<> template<>
81 void lljoint_object::test<4>()
82 {
83 LLJoint parent;
84 std::string str1 = "LLJoint", str2;
85 parent.setName(str1);
86 str2 = parent.getName();
87 ensure("setName() failed ", (str1 == str2));
88 }
89
90 template<> template<>
91 void lljoint_object::test<5>()
92 {
93 LLJoint lljoint;
94 LLVector3 vec3(2.3f,30.f,10.f);
95 lljoint.setPosition(vec3);
96 LLVector3 pos = lljoint.getPosition();
97 ensure("setPosition()/getPosition() failed ", (vec3 == pos));
98 }
99
100 template<> template<>
101 void lljoint_object::test<6>()
102 {
103 LLJoint lljoint;
104 LLVector3 vec3(2.3f,30.f,10.f);
105 lljoint.setWorldPosition(vec3);
106 LLVector3 pos = lljoint.getWorldPosition();
107 ensure("1:setWorldPosition()/getWorldPosition() failed ", (vec3 == pos));
108 LLVector3 lastPos = lljoint.getLastWorldPosition();
109 ensure("2:getLastWorldPosition failed ", (vec3 == lastPos));
110 }
111
112 template<> template<>
113 void lljoint_object::test<7>()
114 {
115 LLJoint lljoint("LLJoint");
116 LLQuaternion q(2.3f,30.f,10.f,1.f);
117 lljoint.setRotation(q);
118 LLQuaternion rot = lljoint.getRotation();
119 ensure("setRotation()/getRotation() failed ", (q == rot));
120 }
121 template<> template<>
122 void lljoint_object::test<8>()
123 {
124 LLJoint lljoint("LLJoint");
125 LLQuaternion q(2.3f,30.f,10.f,1.f);
126 lljoint.setWorldRotation(q);
127 LLQuaternion rot = lljoint.getWorldRotation();
128 ensure("1:setWorldRotation()/getWorldRotation() failed ", (q == rot));
129 LLQuaternion lastRot = lljoint.getLastWorldRotation();
130 ensure("2:getLastWorldRotation failed ", (q == lastRot));
131 }
132
133 template<> template<>
134 void lljoint_object::test<9>()
135 {
136 LLJoint lljoint;
137 LLVector3 vec3(2.3f,30.f,10.f);
138 lljoint.setScale(vec3);
139 LLVector3 scale = lljoint.getScale();
140 ensure("setScale()/getScale failed ", (vec3 == scale));
141 }
142
143 template<> template<>
144 void lljoint_object::test<10>()
145 {
146 LLJoint lljoint("LLJoint");
147 LLMatrix4 mat;
148 mat.identity();
149 lljoint.setWorldMatrix(mat);//giving warning setWorldMatrix not correctly implemented;
150 LLMatrix4 mat4 = lljoint.getWorldMatrix();
151 ensure("setWorldMatrix()/getWorldMatrix failed ", (mat4 == mat));
152 }
153
154 template<> template<>
155 void lljoint_object::test<11>()
156 {
157 LLJoint lljoint("parent");
158 S32 joint_num = 12;
159 lljoint.setJointNum(joint_num);
160 S32 jointNum = lljoint.getJointNum();
161 ensure("setJointNum()/getJointNum failed ", (jointNum == joint_num));
162 }
163
164 template<> template<>
165 void lljoint_object::test<12>()
166 {
167 LLJoint lljoint;
168 LLVector3 vec3(2.3f,30.f,10.f);
169 lljoint.setSkinOffset(vec3);
170 LLVector3 offset = lljoint.getSkinOffset();
171 ensure("1:setSkinOffset()/getSkinOffset() failed ", (vec3 == offset));
172 }
173
174 template<> template<>
175 void lljoint_object::test<13>()
176 {
177 LLJoint lljointgp("gparent");
178 LLJoint lljoint("parent");
179 LLJoint lljoint1("child1");
180 lljoint.addChild(&lljoint1);
181 LLJoint lljoint2("child2");
182 lljoint.addChild(&lljoint2);
183 LLJoint lljoint3("child3");
184 lljoint.addChild(&lljoint3);
185
186 LLJoint* jnt = NULL;
187 jnt = lljoint2.getParent();
188 ensure("addChild() failed ", (&lljoint == jnt));
189 LLJoint* jnt1 = lljoint.findJoint("child3");
190 ensure("findJoint() failed ", (&lljoint3 == jnt1));
191 lljoint.removeChild(&lljoint3);
192 LLJoint* jnt2 = lljoint.findJoint("child3");
193 ensure("removeChild() failed ", (NULL == jnt2));
194
195 lljointgp.addChild(&lljoint);
196 ensure("GetParent() failed ", (&lljoint== lljoint2.getParent()));
197 ensure("getRoot() failed ", (&lljointgp == lljoint2.getRoot()));
198
199 ensure("getRoot() failed ", &lljoint1 == lljoint.findJoint("child1"));
200
201 lljointgp.removeAllChildren();
202 // parent removed from grandparent - so should not be able to locate child
203 ensure("removeAllChildren() failed ", (NULL == lljointgp.findJoint("child1")));
204 // it should still exist in parent though
205 ensure("removeAllChildren() failed ", (&lljoint1 == lljoint.findJoint("child1")));
206 }
207
208 template<> template<>
209 void lljoint_object::test<14>()
210 {
211 LLJoint lljointgp("gparent");
212
213 LLJoint llparent1("parent1");
214 LLJoint llparent2("parent2");
215
216 LLJoint llchild("child1");
217 LLJoint lladoptedchild("child2");
218 llparent1.addChild(&llchild);
219 llparent1.addChild(&lladoptedchild);
220
221 llparent2.addChild(&lladoptedchild);
222 ensure("1. addChild failed to remove prior parent", lladoptedchild.getParent() == &llparent2);
223 ensure("2. addChild failed to remove prior parent", llparent1.findJoint("child2") == NULL);
224 }
225
226
227 //*
228 Test cases for the following not added. They perform operations
229 on underlying LLXformMatrix and LLVector3 elements which have
230 been unit tested separately.
231 Unit Testing these functions will basically require re-implementing
232 logic of these function in the test case itself
233
234 1) void WorldMatrixChildren();
235 2) void updateWorldMatrixParent();
236 3) void updateWorldPRSParent();
237 4) void updateWorldMatrix();
238 5) LLXformMatrix *getXform() { return &mXform; }
239 6) void setConstraintSilhouette(LLDynamicArray<LLVector3>& silhouette);
240 7) void clampRotation(LLQuaternion old_rot, LLQuaternion new_rot);
241
242 //*
243}
244#endif // THIS_DOESNT_LINK