4 package jp.sfjp.mikutoga.vmd.model;
6 import java.util.Iterator;
10 import org.junit.After;
11 import org.junit.AfterClass;
12 import org.junit.Before;
13 import org.junit.BeforeClass;
14 import org.junit.Test;
15 import static org.junit.Assert.*;
20 public class VmdMotionTest {
22 public VmdMotionTest() {
26 public static void setUpClass() {
30 public static void tearDownClass() {
38 public void tearDown() {
42 * Test of getせtModelName method, of class VmdMotion.
45 public void testGetSetModelName() {
46 System.out.println("get/setModelName");
50 motion = new VmdMotion();
52 assertEquals("カメラ・照明", motion.getModelName());
54 motion.setModelName("");
55 assertEquals("", motion.getModelName());
57 motion.setModelName("model");
58 assertEquals("model", motion.getModelName());
61 motion.setModelName(null);
63 }catch(NullPointerException e){
71 * Test of isModelMotion method, of class VmdMotion.
74 public void testIsModelMotion() {
75 System.out.println("isModelMotion");
79 motion = new VmdMotion();
81 assertFalse(motion.isModelMotion());
83 motion.setModelName("model");
84 assertTrue(motion.isModelMotion());
86 motion.setModelName("カメラ・照明");
87 assertFalse(motion.isModelMotion());
93 * Test of getBonePartMap method, of class VmdMotion.
96 public void testGetBonePartMap() {
97 System.out.println("getBonePartMap");
100 Map<String, List<BoneMotion>> map;
102 motion = new VmdMotion();
104 map = motion.getBonePartMap();
106 assertTrue(map.isEmpty());
112 * Test of getMorphPartMap method, of class VmdMotion.
115 public void testGetMorphPartMap() {
116 System.out.println("getMorphPartMap");
119 Map<String, List<MorphMotion>> map;
121 motion = new VmdMotion();
123 map = motion.getMorphPartMap();
125 assertTrue(map.isEmpty());
131 * Test of getCameraMotionList method, of class VmdMotion.
134 public void testGetCameraMotionList() {
135 System.out.println("getCameraMotionList");
138 List<CameraMotion> list;
140 motion = new VmdMotion();
142 list = motion.getCameraMotionList();
144 assertTrue(list.isEmpty());
150 * Test of getLuminousMotionList method, of class VmdMotion.
153 public void testGetLuminousMotionList() {
154 System.out.println("getLuminousMotionList");
157 List<LuminousMotion> list;
159 motion = new VmdMotion();
161 list = motion.getLuminousMotionList();
163 assertTrue(list.isEmpty());
169 * Test of getShadowMotionList method, of class VmdMotion.
172 public void testGetShadowMotionList() {
173 System.out.println("getShadowMotionList");
176 List<ShadowMotion> list;
178 motion = new VmdMotion();
180 list = motion.getShadowMotionList();
182 assertTrue(list.isEmpty());
188 * Test of addBoneMotion method, of class VmdMotion.
191 public void testAddBoneMotion() {
192 System.out.println("addBoneMotion");
197 motion = new VmdMotion();
199 bone = new BoneMotion();
200 bone.setBoneName("X");
201 bone.setFrameNumber(99);
202 motion.addBoneMotion(bone);
204 bone = new BoneMotion();
205 bone.setBoneName("Y");
206 bone.setFrameNumber(9);
207 motion.addBoneMotion(bone);
209 bone = new BoneMotion();
210 bone.setBoneName("A");
211 bone.setFrameNumber(10);
212 motion.addBoneMotion(bone);
214 bone = new BoneMotion();
215 bone.setBoneName("Y");
216 bone.setFrameNumber(1);
217 motion.addBoneMotion(bone);
219 Map<String, List<BoneMotion>> map = motion.getBonePartMap();
221 Set<String> keySet = map.keySet();
222 assertEquals(3, keySet.size());
224 it = keySet.iterator();
225 assertEquals("X", it.next());
226 assertEquals("Y", it.next());
227 assertEquals("A", it.next());
229 assertEquals(1, map.get("X").size());
230 assertEquals(2, map.get("Y").size());
231 assertEquals(1, map.get("A").size());
233 assertEquals(99, map.get("X").get(0).getFrameNumber());
234 assertEquals(9, map.get("Y").get(0).getFrameNumber());
235 assertEquals(1, map.get("Y").get(1).getFrameNumber());
236 assertEquals(10, map.get("A").get(0).getFrameNumber());
242 * Test of addMorphMotion method, of class VmdMotion.
245 public void testAddMorphMotion() {
246 System.out.println("addMorphMotion");
251 motion = new VmdMotion();
253 morph = new MorphMotion();
254 morph.setMorphName("X");
255 morph.setFrameNumber(99);
256 motion.addMorphMotion(morph);
258 morph = new MorphMotion();
259 morph.setMorphName("Y");
260 morph.setFrameNumber(9);
261 motion.addMorphMotion(morph);
263 morph = new MorphMotion();
264 morph.setMorphName("A");
265 morph.setFrameNumber(10);
266 motion.addMorphMotion(morph);
268 morph = new MorphMotion();
269 morph.setMorphName("Y");
270 morph.setFrameNumber(1);
271 motion.addMorphMotion(morph);
273 Map<String, List<MorphMotion>> map = motion.getMorphPartMap();
275 Set<String> keySet = map.keySet();
276 assertEquals(3, keySet.size());
278 it = keySet.iterator();
279 assertEquals("X", it.next());
280 assertEquals("Y", it.next());
281 assertEquals("A", it.next());
283 assertEquals(1, map.get("X").size());
284 assertEquals(2, map.get("Y").size());
285 assertEquals(1, map.get("A").size());
287 assertEquals(99, map.get("X").get(0).getFrameNumber());
288 assertEquals(9, map.get("Y").get(0).getFrameNumber());
289 assertEquals(1, map.get("Y").get(1).getFrameNumber());
290 assertEquals(10, map.get("A").get(0).getFrameNumber());
296 * Test of frameSort method, of class VmdMotion.
299 public void testFrameSort() {
300 System.out.println("frameSort");
304 motion = new VmdMotion();
308 bmotion = new BoneMotion();
309 bmotion.setBoneName("bone");
310 bmotion.setFrameNumber(2);
311 motion.addBoneMotion(bmotion);
313 bmotion = new BoneMotion();
314 bmotion.setBoneName("bone");
315 bmotion.setFrameNumber(1);
316 motion.addBoneMotion(bmotion);
320 mmotion = new MorphMotion();
321 mmotion.setMorphName("morph");
322 mmotion.setFrameNumber(20);
323 motion.addMorphMotion(mmotion);
325 mmotion = new MorphMotion();
326 mmotion.setMorphName("morph");
327 mmotion.setFrameNumber(10);
328 motion.addMorphMotion(mmotion);
330 CameraMotion cmotion;
332 cmotion = new CameraMotion();
333 cmotion.setFrameNumber(200);
334 motion.getCameraMotionList().add(cmotion);
336 cmotion = new CameraMotion();
337 cmotion.setFrameNumber(100);
338 motion.getCameraMotionList().add(cmotion);
340 LuminousMotion lmotion;
342 lmotion = new LuminousMotion();
343 lmotion.setFrameNumber(2000);
344 motion.getLuminousMotionList().add(lmotion);
346 lmotion = new LuminousMotion();
347 lmotion.setFrameNumber(1000);
348 motion.getLuminousMotionList().add(lmotion);
350 ShadowMotion smotion;
352 smotion = new ShadowMotion();
353 smotion.setFrameNumber(20000);
354 motion.getShadowMotionList().add(smotion);
356 smotion = new ShadowMotion();
357 smotion.setFrameNumber(10000);
358 motion.getShadowMotionList().add(smotion);
362 assertEquals(2, motion.getBonePartMap().get("bone").size());
363 assertEquals(1, motion.getBonePartMap().get("bone").get(0).getFrameNumber());
364 assertEquals(2, motion.getBonePartMap().get("bone").get(1).getFrameNumber());
366 assertEquals(2, motion.getMorphPartMap().get("morph").size());
367 assertEquals(10, motion.getMorphPartMap().get("morph").get(0).getFrameNumber());
368 assertEquals(20, motion.getMorphPartMap().get("morph").get(1).getFrameNumber());
370 assertEquals(2, motion.getCameraMotionList().size());
371 assertEquals(100, motion.getCameraMotionList().get(0).getFrameNumber());
372 assertEquals(200, motion.getCameraMotionList().get(1).getFrameNumber());
374 assertEquals(2, motion.getLuminousMotionList().size());
375 assertEquals(1000, motion.getLuminousMotionList().get(0).getFrameNumber());
376 assertEquals(2000, motion.getLuminousMotionList().get(1).getFrameNumber());
378 assertEquals(2, motion.getShadowMotionList().size());
379 assertEquals(10000, motion.getShadowMotionList().get(0).getFrameNumber());
380 assertEquals(20000, motion.getShadowMotionList().get(1).getFrameNumber());
386 * Test of toString method, of class VmdMotion.
389 public void testToString() {
390 System.out.println("toString");
394 motion = new VmdMotion();
397 "model name : カメラ・照明\n"
398 +"bone#0 morph#0 camera#0 luminous#0 shadow#0 flag#0",
401 motion.setModelName("model");
402 motion.addBoneMotion(new BoneMotion());
403 motion.addMorphMotion(new MorphMotion());
404 motion.addMorphMotion(new MorphMotion());
405 motion.getCameraMotionList().add(new CameraMotion());
406 motion.getCameraMotionList().add(new CameraMotion());
407 motion.getCameraMotionList().add(new CameraMotion());
408 motion.getLuminousMotionList().add(new LuminousMotion());
409 motion.getLuminousMotionList().add(new LuminousMotion());
410 motion.getLuminousMotionList().add(new LuminousMotion());
411 motion.getLuminousMotionList().add(new LuminousMotion());
412 motion.getShadowMotionList().add(new ShadowMotion());
413 motion.getShadowMotionList().add(new ShadowMotion());
414 motion.getShadowMotionList().add(new ShadowMotion());
415 motion.getShadowMotionList().add(new ShadowMotion());
416 motion.getShadowMotionList().add(new ShadowMotion());
417 motion.getNumberedFlagList().add(new NumberedVmdFlag());
418 motion.getNumberedFlagList().add(new NumberedVmdFlag());
419 motion.getNumberedFlagList().add(new NumberedVmdFlag());
420 motion.getNumberedFlagList().add(new NumberedVmdFlag());
421 motion.getNumberedFlagList().add(new NumberedVmdFlag());
424 "model name : model\n"
425 +"bone#1 morph#2 camera#3 luminous#4 shadow#5 flag#5",