OSDN Git Service

MMD Ver7.40 対応 新スキーマ開発開始
[mikutoga/Vmd2XML.git] / src / test / java / jp / sfjp / mikutoga / vmd / model / VmdMotionTest.java
1 /*
2  */
3
4 package jp.sfjp.mikutoga.vmd.model;
5
6 import java.util.Iterator;
7 import java.util.List;
8 import java.util.Map;
9 import java.util.Set;
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.*;
16
17 /**
18  *
19  */
20 public class VmdMotionTest {
21
22     public VmdMotionTest() {
23     }
24
25     @BeforeClass
26     public static void setUpClass() {
27     }
28
29     @AfterClass
30     public static void tearDownClass() {
31     }
32
33     @Before
34     public void setUp() {
35     }
36
37     @After
38     public void tearDown() {
39     }
40
41     /**
42      * Test of getせtModelName method, of class VmdMotion.
43      */
44     @Test
45     public void testGetSetModelName() {
46         System.out.println("get/setModelName");
47
48         VmdMotion motion;
49
50         motion = new VmdMotion();
51
52         assertEquals("カメラ・照明", motion.getModelName());
53
54         motion.setModelName("");
55         assertEquals("", motion.getModelName());
56
57         motion.setModelName("model");
58         assertEquals("model", motion.getModelName());
59
60         try{
61             motion.setModelName(null);
62             fail();
63         }catch(NullPointerException e){
64             // GOOD
65         }
66
67         return;
68     }
69
70     /**
71      * Test of isModelMotion method, of class VmdMotion.
72      */
73     @Test
74     public void testIsModelMotion() {
75         System.out.println("isModelMotion");
76
77         VmdMotion motion;
78
79         motion = new VmdMotion();
80
81         assertFalse(motion.isModelMotion());
82
83         motion.setModelName("model");
84         assertTrue(motion.isModelMotion());
85
86         motion.setModelName("カメラ・照明");
87         assertFalse(motion.isModelMotion());
88
89         return;
90     }
91
92     /**
93      * Test of getBonePartMap method, of class VmdMotion.
94      */
95     @Test
96     public void testGetBonePartMap() {
97         System.out.println("getBonePartMap");
98
99         VmdMotion motion;
100         Map<String, List<BoneMotion>> map;
101
102         motion = new VmdMotion();
103
104         map = motion.getBonePartMap();
105         assertNotNull(map);
106         assertTrue(map.isEmpty());
107
108         return;
109     }
110
111     /**
112      * Test of getMorphPartMap method, of class VmdMotion.
113      */
114     @Test
115     public void testGetMorphPartMap() {
116         System.out.println("getMorphPartMap");
117
118         VmdMotion motion;
119         Map<String, List<MorphMotion>> map;
120
121         motion = new VmdMotion();
122
123         map = motion.getMorphPartMap();
124         assertNotNull(map);
125         assertTrue(map.isEmpty());
126
127         return;
128     }
129
130     /**
131      * Test of getCameraMotionList method, of class VmdMotion.
132      */
133     @Test
134     public void testGetCameraMotionList() {
135         System.out.println("getCameraMotionList");
136
137         VmdMotion motion;
138         List<CameraMotion> list;
139
140         motion = new VmdMotion();
141
142         list = motion.getCameraMotionList();
143         assertNotNull(list);
144         assertTrue(list.isEmpty());
145
146         return;
147     }
148
149     /**
150      * Test of getLuminousMotionList method, of class VmdMotion.
151      */
152     @Test
153     public void testGetLuminousMotionList() {
154         System.out.println("getLuminousMotionList");
155
156         VmdMotion motion;
157         List<LuminousMotion> list;
158
159         motion = new VmdMotion();
160
161         list = motion.getLuminousMotionList();
162         assertNotNull(list);
163         assertTrue(list.isEmpty());
164
165         return;
166     }
167
168     /**
169      * Test of getShadowMotionList method, of class VmdMotion.
170      */
171     @Test
172     public void testGetShadowMotionList() {
173         System.out.println("getShadowMotionList");
174
175         VmdMotion motion;
176         List<ShadowMotion> list;
177
178         motion = new VmdMotion();
179
180         list = motion.getShadowMotionList();
181         assertNotNull(list);
182         assertTrue(list.isEmpty());
183
184         return;
185     }
186
187     /**
188      * Test of addBoneMotion method, of class VmdMotion.
189      */
190     @Test
191     public void testAddBoneMotion() {
192         System.out.println("addBoneMotion");
193
194         VmdMotion motion;
195         BoneMotion bone;
196
197         motion = new VmdMotion();
198
199         bone = new BoneMotion();
200         bone.setBoneName("X");
201         bone.setFrameNumber(99);
202         motion.addBoneMotion(bone);
203
204         bone = new BoneMotion();
205         bone.setBoneName("Y");
206         bone.setFrameNumber(9);
207         motion.addBoneMotion(bone);
208
209         bone = new BoneMotion();
210         bone.setBoneName("A");
211         bone.setFrameNumber(10);
212         motion.addBoneMotion(bone);
213
214         bone = new BoneMotion();
215         bone.setBoneName("Y");
216         bone.setFrameNumber(1);
217         motion.addBoneMotion(bone);
218
219         Map<String, List<BoneMotion>> map = motion.getBonePartMap();
220
221         Set<String> keySet = map.keySet();
222         assertEquals(3, keySet.size());
223         Iterator<String> it;
224         it = keySet.iterator();
225         assertEquals("X", it.next());
226         assertEquals("Y", it.next());
227         assertEquals("A", it.next());
228
229         assertEquals(1, map.get("X").size());
230         assertEquals(2, map.get("Y").size());
231         assertEquals(1, map.get("A").size());
232
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());
237
238         return;
239     }
240
241     /**
242      * Test of addMorphMotion method, of class VmdMotion.
243      */
244     @Test
245     public void testAddMorphMotion() {
246         System.out.println("addMorphMotion");
247
248         VmdMotion motion;
249         MorphMotion morph;
250
251         motion = new VmdMotion();
252
253         morph = new MorphMotion();
254         morph.setMorphName("X");
255         morph.setFrameNumber(99);
256         motion.addMorphMotion(morph);
257
258         morph = new MorphMotion();
259         morph.setMorphName("Y");
260         morph.setFrameNumber(9);
261         motion.addMorphMotion(morph);
262
263         morph = new MorphMotion();
264         morph.setMorphName("A");
265         morph.setFrameNumber(10);
266         motion.addMorphMotion(morph);
267
268         morph = new MorphMotion();
269         morph.setMorphName("Y");
270         morph.setFrameNumber(1);
271         motion.addMorphMotion(morph);
272
273         Map<String, List<MorphMotion>> map = motion.getMorphPartMap();
274
275         Set<String> keySet = map.keySet();
276         assertEquals(3, keySet.size());
277         Iterator<String> it;
278         it = keySet.iterator();
279         assertEquals("X", it.next());
280         assertEquals("Y", it.next());
281         assertEquals("A", it.next());
282
283         assertEquals(1, map.get("X").size());
284         assertEquals(2, map.get("Y").size());
285         assertEquals(1, map.get("A").size());
286
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());
291
292         return;
293     }
294
295     /**
296      * Test of frameSort method, of class VmdMotion.
297      */
298     @Test
299     public void testFrameSort() {
300         System.out.println("frameSort");
301
302         VmdMotion motion;
303
304         motion = new VmdMotion();
305
306         BoneMotion bmotion;
307
308         bmotion = new BoneMotion();
309         bmotion.setBoneName("bone");
310         bmotion.setFrameNumber(2);
311         motion.addBoneMotion(bmotion);
312
313         bmotion = new BoneMotion();
314         bmotion.setBoneName("bone");
315         bmotion.setFrameNumber(1);
316         motion.addBoneMotion(bmotion);
317
318         MorphMotion mmotion;
319
320         mmotion = new MorphMotion();
321         mmotion.setMorphName("morph");
322         mmotion.setFrameNumber(20);
323         motion.addMorphMotion(mmotion);
324
325         mmotion = new MorphMotion();
326         mmotion.setMorphName("morph");
327         mmotion.setFrameNumber(10);
328         motion.addMorphMotion(mmotion);
329
330         CameraMotion cmotion;
331
332         cmotion = new CameraMotion();
333         cmotion.setFrameNumber(200);
334         motion.getCameraMotionList().add(cmotion);
335
336         cmotion = new CameraMotion();
337         cmotion.setFrameNumber(100);
338         motion.getCameraMotionList().add(cmotion);
339
340         LuminousMotion lmotion;
341
342         lmotion = new LuminousMotion();
343         lmotion.setFrameNumber(2000);
344         motion.getLuminousMotionList().add(lmotion);
345
346         lmotion = new LuminousMotion();
347         lmotion.setFrameNumber(1000);
348         motion.getLuminousMotionList().add(lmotion);
349
350         ShadowMotion smotion;
351
352         smotion = new ShadowMotion();
353         smotion.setFrameNumber(20000);
354         motion.getShadowMotionList().add(smotion);
355
356         smotion = new ShadowMotion();
357         smotion.setFrameNumber(10000);
358         motion.getShadowMotionList().add(smotion);
359
360         motion.frameSort();
361
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());
365
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());
369
370         assertEquals(2, motion.getCameraMotionList().size());
371         assertEquals(100, motion.getCameraMotionList().get(0).getFrameNumber());
372         assertEquals(200, motion.getCameraMotionList().get(1).getFrameNumber());
373
374         assertEquals(2, motion.getLuminousMotionList().size());
375         assertEquals(1000, motion.getLuminousMotionList().get(0).getFrameNumber());
376         assertEquals(2000, motion.getLuminousMotionList().get(1).getFrameNumber());
377
378         assertEquals(2, motion.getShadowMotionList().size());
379         assertEquals(10000, motion.getShadowMotionList().get(0).getFrameNumber());
380         assertEquals(20000, motion.getShadowMotionList().get(1).getFrameNumber());
381
382         return;
383     }
384
385     /**
386      * Test of toString method, of class VmdMotion.
387      */
388     @Test
389     public void testToString() {
390         System.out.println("toString");
391
392         VmdMotion motion;
393
394         motion = new VmdMotion();
395
396         assertEquals(
397                 "model name : カメラ・照明\n"
398                 +"bone#0 morph#0 camera#0 luminous#0 shadow#0 flag#0",
399                 motion.toString());
400
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());
422
423         assertEquals(
424                 "model name : model\n"
425                 +"bone#1 morph#2 camera#3 luminous#4 shadow#5 flag#5",
426                 motion.toString());
427
428         return;
429     }
430
431 }