OSDN Git Service

Merge branch 旧コメント仕様で過去ログ取得できる機能の実装
[coroid/inqubus.git] / frontend / test / saccubus / SaccubusTest.java
1 /*$Id$*/
2 package saccubus;
3
4 import java.io.File;
5 import java.io.FileOutputStream;
6 import java.io.IOException;
7 import java.io.OutputStream;
8 import java.util.HashMap;
9 import java.util.Map;
10 import java.util.Properties;
11 import javax.swing.JFrame;
12 import mockit.Mock;
13 import mockit.MockClass;
14 import mockit.Mockit;
15 import mockit.integration.junit4.JMockit;
16 import static org.fest.assertions.Assertions.*;
17 import org.fest.reflect.core.Reflection;
18 import org.fest.swing.fixture.JFileChooserFixture;
19 import org.fest.swing.keystroke.KeyStrokeMappingProvider;
20 import static org.fest.swing.launcher.ApplicationLauncher.application;
21 import org.fest.swing.core.BasicRobot;
22 import org.fest.swing.core.Robot;
23 import org.fest.swing.finder.JFileChooserFinder;
24 import org.fest.swing.finder.WindowFinder;
25 import org.fest.swing.fixture.FrameFixture;
26 import org.fest.swing.keystroke.KeyStrokeMap;
27 import org.fest.swing.keystroke.KeyStrokeMappingsParser;
28 import org.junit.After;
29 import org.junit.Before;
30 import org.junit.Test;
31 import org.junit.runner.RunWith;
32 import saccubus.properties.SProperties;
33 import static org.junit.Assert.*;
34
35 /**
36  *
37  * @author yuki
38  */
39 @RunWith(JMockit.class)
40 public class SaccubusTest {
41
42     private static Robot robot;
43     private static FrameFixture window;
44
45     @Before
46     public void setUp() throws IOException {
47         KeyStrokeMappingsParser parser = new KeyStrokeMappingsParser();
48         KeyStrokeMappingProvider provider = parser.parse("fest-swing_mapping.txt");
49         KeyStrokeMap.addKeyStrokesFrom(provider);
50
51         robot = BasicRobot.robotWithNewAwtHierarchy();
52         application(saccubus.Saccubus.class).start();
53         window = WindowFinder.findFrame(JFrame.class).using(robot);
54     }
55
56     @After
57     public void tearDown() {
58         robot.cleanUp();
59     }
60
61     private SProperties getProperties() {
62         return Reflection.method("getSetting").withReturnType(SProperties.class).in(window.component()).invoke();
63     }
64
65     @Test
66     public void testConfigSave() throws Exception {
67         Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream());
68
69         SProperties.saveSetting(getProperties());
70     }
71
72     @Test
73     public void testMailAddress() {
74         Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream());
75
76         window.tabbedPane("mainTabbedPane").selectTab("基本設定");
77         window.textBox("mailAddressField").enterText("mail@example.com");
78         SProperties.saveSetting(getProperties());
79     }
80
81     @Test
82     public void testPassword() {
83         Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream());
84
85         window.tabbedPane("mainTabbedPane").selectTab("基本設定");
86         window.textBox("passwordField").enterText("pass word input");
87         SProperties.saveSetting(getProperties());
88     }
89
90     @Test
91     public void testUseProxy() {
92         Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream());
93
94         window.tabbedPane("mainTabbedPane").selectTab("基本設定");
95         window.checkBox("useProxyCheckBox").check();
96         SProperties.saveSetting(getProperties());
97
98         window.tabbedPane("mainTabbedPane").selectTab("基本設定");
99         window.checkBox("useProxyCheckBox").uncheck();
100         SProperties.saveSetting(getProperties());
101     }
102
103     @Test
104     public void testProxyHost() {
105         Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream());
106
107         window.tabbedPane("mainTabbedPane").selectTab("基本設定");
108         window.textBox("proxyTextField").enterText("proxy.example.com");
109         SProperties.saveSetting(getProperties());
110     }
111
112     @Test
113     public void testProxyPort() {
114         Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream());
115
116         window.tabbedPane("mainTabbedPane").selectTab("基本設定");
117         window.textBox("proxyPortTextField").enterText("8090");
118         SProperties.saveSetting(getProperties());
119     }
120
121     @Test
122     public void testMovieSouce() {
123         Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream());
124
125         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
126         window.tabbedPane("saveTabbedPane").selectTab("入力動画");
127         window.radioButton("videoUseNiBrButton").check();
128         window.textBox("nibrFileField").enterText("nibr_file.mp4");
129         window.radioButton("videoNoSaveButton").check();
130         window.checkBox("delVideoCheckBox").click();
131         window.textBox("videoSavedFolderField").selectAll().enterText("C:\\works\\");
132         window.textBox("videoSavedFileField").selectAll().enterText("C:\\movie_file.flv");
133         SProperties.saveSetting(getProperties());
134
135         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
136         window.tabbedPane("saveTabbedPane").selectTab("入力動画");
137         window.radioButton("videoSaveButton").check();
138         window.checkBox("delVideoCheckBox").click();
139         window.textBox("videoSavedFolderField").selectAll().enterText("C:\\works\\movie");
140         window.textBox("videoSavedFileField").selectAll().enterText("C:\\movie_file\\file.flv");
141         SProperties.saveSetting(getProperties());
142
143         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
144         window.tabbedPane("saveTabbedPane").selectTab("入力動画");
145         window.checkBox("delVideoCheckBox").click();
146         window.textBox("videoSavedFolderField").deleteText();
147         window.textBox("videoSavedFileField").deleteText();
148         window.radioButton("videoUseNiBrButton").check();
149         SProperties.saveSetting(getProperties());
150     }
151
152     @Test
153     public void testMovieSouce2() {
154         Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream());
155
156         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
157         window.tabbedPane("saveTabbedPane").selectTab("入力動画");
158         window.radioButton("saveFolderRadioButton").check();
159         window.textBox("videoSavedFolderField").selectAll().enterText("folder\\");
160         window.textBox("videoSavedFileField").selectAll().enterText("file.flv");
161         SProperties.saveSetting(getProperties());
162
163         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
164         window.tabbedPane("saveTabbedPane").selectTab("入力動画");
165         window.radioButton("saveFileRadioButton").check();
166         window.textBox("videoSavedFolderField").selectAll().enterText("folder1\\folder2\\");
167         window.textBox("videoSavedFileField").selectAll().enterText("folder\\file.flv");
168         SProperties.saveSetting(getProperties());
169     }
170
171     @Test
172     public void testMovieSourceFolderButton() {
173         Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream());
174
175         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
176         window.tabbedPane("saveTabbedPane").selectTab("入力動画");
177         window.button("showSavingVideoFolderDialogButton").click();
178         JFileChooserFixture chooser = JFileChooserFinder.findFileChooser().using(robot);
179         File folder = new File("F:\\docs\\NetBeansProjects");
180         chooser.selectFile(folder).approve();
181         assertThat(folder.getAbsolutePath()).isEqualTo(window.textBox("videoSavedFolderField").text());
182     }
183
184     @Test
185     public void testMovieSourceFileButton() {
186         Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream());
187
188         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
189         window.tabbedPane("saveTabbedPane").selectTab("入力動画");
190         window.button("showSavingVideoFileDialogButton").click();
191         JFileChooserFixture chooser = JFileChooserFinder.findFileChooser().using(robot);
192         File folder = new File("F:\\docs\\NetBeansProjects\\saccubus_frontend\\out\\movie\\aa.flv");
193         chooser.selectFile(folder).approve();
194         assertThat(folder.getAbsolutePath()).isEqualTo(window.textBox("videoSavedFileField").text());
195     }
196
197     @Test
198     public void testDownloadComment() {
199         Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream());
200
201         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
202         window.tabbedPane("saveTabbedPane").selectTab("入力コメント");
203         window.checkBox("savingCommentCheckBox").check();
204         SProperties.saveSetting(getProperties());
205
206         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
207         window.tabbedPane("saveTabbedPane").selectTab("入力コメント");
208         window.checkBox("savingCommentCheckBox").uncheck();
209         SProperties.saveSetting(getProperties());
210     }
211
212     @Test
213     public void testDeleteComment() {
214         Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream());
215
216         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
217         window.tabbedPane("saveTabbedPane").selectTab("入力コメント");
218         window.checkBox("delCommentCheckBox").check();
219         SProperties.saveSetting(getProperties());
220
221         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
222         window.tabbedPane("saveTabbedPane").selectTab("入力コメント");
223         window.checkBox("delCommentCheckBox").uncheck();
224         SProperties.saveSetting(getProperties());
225     }
226
227     @Test
228     public void testCommentDownloadNum() {
229         Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream());
230
231         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
232         window.tabbedPane("saveTabbedPane").selectTab("入力コメント");
233         window.checkBox("fixCommentNumCheckBox").check();
234         window.textBox("commentNumField").selectAll().enterText("100");
235         SProperties.saveSetting(getProperties());
236
237         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
238         window.tabbedPane("saveTabbedPane").selectTab("入力コメント");
239         window.checkBox("fixCommentNumCheckBox").uncheck();
240         window.radioButton("commentSaveFolderRadioButton").check();
241         window.textBox("commentNumField").deleteText();
242         SProperties.saveSetting(getProperties());
243
244     }
245
246     @Test
247     public void testCommentDownloadFolder() {
248         Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream());
249
250         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
251         window.tabbedPane("saveTabbedPane").selectTab("入力コメント");
252         window.radioButton("commentSaveFolderRadioButton").check();
253         window.textBox("commentSavedFolderField").selectAll().enterText("c:\\comment\\");
254         window.textBox("commentSavedFileField").selectAll().enterText("c:\\comment\\file.xml");
255         SProperties.saveSetting(getProperties());
256
257         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
258         window.tabbedPane("saveTabbedPane").selectTab("入力コメント");
259         window.radioButton("commentSaveFileRadioButton").check();
260         window.textBox("commentSavedFolderField").selectAll().enterText("comment");
261         window.textBox("commentSavedFileField").selectAll().enterText("file.xml");
262         SProperties.saveSetting(getProperties());
263
264     }
265
266     @Test
267     public void testCommentFolderButton() {
268         Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream());
269
270         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
271         window.tabbedPane("saveTabbedPane").selectTab("入力コメント");
272         window.button("showSavingCommentFolderDialogButton").click();
273         JFileChooserFixture chooser = JFileChooserFinder.findFileChooser().using(robot);
274         File folder = new File("F:\\docs\\NetBeansProjects");
275         chooser.selectFile(folder).approve();
276         assertThat(folder.getAbsolutePath()).isEqualTo(window.textBox("commentSavedFolderField").text());
277     }
278
279     @Test
280     public void testCommentFileButton() {
281         Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream());
282
283         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
284         window.tabbedPane("saveTabbedPane").selectTab("入力コメント");
285         window.button("showSavingCommentFileDialogButton").click();
286         JFileChooserFixture chooser = JFileChooserFinder.findFileChooser().using(robot);
287         File folder = new File("F:\\docs\\NetBeansProjects\\comment.xml");
288         chooser.selectFile(folder).approve();
289         assertThat(folder.getAbsolutePath()).isEqualTo(window.textBox("commentSavedFileField").text());
290     }
291
292     @Test
293     public void testDownloadTcomment() {
294         Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream());
295
296         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
297         window.tabbedPane("saveTabbedPane").selectTab("入力投稿者コメント");
298         window.checkBox("needDownloadTcomment").check();
299         SProperties.saveSetting(getProperties());
300
301         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
302         window.tabbedPane("saveTabbedPane").selectTab("入力投稿者コメント");
303         window.checkBox("needDownloadTcomment").uncheck();
304         SProperties.saveSetting(getProperties());
305     }
306
307     @Test
308     public void testDeleteTcomment() {
309         Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream());
310
311         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
312         window.tabbedPane("saveTabbedPane").selectTab("入力投稿者コメント");
313         window.checkBox("delTcomment").check();
314         SProperties.saveSetting(getProperties());
315
316         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
317         window.tabbedPane("saveTabbedPane").selectTab("入力投稿者コメント");
318         window.checkBox("delTcomment").uncheck();
319         SProperties.saveSetting(getProperties());
320     }
321
322     @Test
323     public void testTcommentDownloadFolder() {
324         Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream());
325
326         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
327         window.tabbedPane("saveTabbedPane").selectTab("入力投稿者コメント");
328         window.radioButton("tcommentSaveInFolder").check();
329         window.textBox("tcommentFolder").selectAll().enterText("c:\\comment\\");
330         window.textBox("tcommentFile").selectAll().enterText("c:\\comment\\file.xml");
331         SProperties.saveSetting(getProperties());
332
333         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
334         window.tabbedPane("saveTabbedPane").selectTab("入力投稿者コメント");
335         window.radioButton("tcommentSaveToFile").check();
336         window.textBox("tcommentFolder").selectAll().enterText("comment");
337         window.textBox("tcommentFile").selectAll().enterText("file.xml");
338         SProperties.saveSetting(getProperties());
339
340     }
341
342     @Test
343     public void testTcommentFolderButton() {
344         Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream());
345
346         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
347         window.tabbedPane("saveTabbedPane").selectTab("入力投稿者コメント");
348         window.button("tcoomentFolderChooserButton").click();
349         JFileChooserFixture chooser = JFileChooserFinder.findFileChooser().using(robot);
350         File folder = new File("F:\\docs\\NetBeansProjects\\saccubus_frontend\\src");
351         chooser.selectFile(folder).approve();
352         assertThat(folder.getAbsolutePath()).isEqualTo(window.textBox("tcommentFolder").text());
353     }
354
355     @Test
356     public void testTcommentFileButton() {
357         Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream());
358
359         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
360         window.tabbedPane("saveTabbedPane").selectTab("入力投稿者コメント");
361         window.button("tcommentFileChooserButton").click();
362         JFileChooserFixture chooser = JFileChooserFinder.findFileChooser().using(robot);
363         File folder = new File("F:\\docs\\NetBeansProjects\\tcomment.xml");
364         chooser.selectFile(folder).approve();
365         assertThat(folder.getAbsolutePath()).isEqualTo(window.textBox("tcommentFile").text());
366     }
367
368     @Test
369     public void testConvertVideo() {
370         Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream());
371
372         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
373         window.tabbedPane("saveTabbedPane").selectTab("出力コメント付き動画");
374         window.checkBox("savingConvertedVideoCheckBox").uncheck();
375         SProperties.saveSetting(getProperties());
376
377         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
378         window.tabbedPane("saveTabbedPane").selectTab("出力コメント付き動画");
379         window.checkBox("savingConvertedVideoCheckBox").check();
380         SProperties.saveSetting(getProperties());
381     }
382
383     @Test
384     public void testAddComment() {
385         Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream());
386
387         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
388         window.tabbedPane("saveTabbedPane").selectTab("出力コメント付き動画");
389         window.checkBox("addComment").uncheck();
390         SProperties.saveSetting(getProperties());
391
392         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
393         window.tabbedPane("saveTabbedPane").selectTab("出力コメント付き動画");
394         window.checkBox("addComment").check();
395         SProperties.saveSetting(getProperties());
396     }
397
398     @Test
399     public void testAddTcomment() {
400         Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream());
401
402         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
403         window.tabbedPane("saveTabbedPane").selectTab("出力コメント付き動画");
404         window.checkBox("addTcomment").uncheck();
405         SProperties.saveSetting(getProperties());
406
407         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
408         window.tabbedPane("saveTabbedPane").selectTab("出力コメント付き動画");
409         window.checkBox("addTcomment").check();
410         SProperties.saveSetting(getProperties());
411     }
412
413     @Test
414     public void testNoAddId() {
415         Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream());
416
417         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
418         window.tabbedPane("saveTabbedPane").selectTab("出力コメント付き動画");
419         window.checkBox("notAddVideoIdConvVideoCheckBox").uncheck();
420         SProperties.saveSetting(getProperties());
421
422         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
423         window.tabbedPane("saveTabbedPane").selectTab("出力コメント付き動画");
424         window.checkBox("notAddVideoIdConvVideoCheckBox").check();
425         SProperties.saveSetting(getProperties());
426     }
427
428     @Test
429     public void testConvertedVideoSavePlace() {
430         Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream());
431
432         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
433         window.tabbedPane("saveTabbedPane").selectTab("出力コメント付き動画");
434         window.radioButton("convSaveFolderRadioButton").check();
435         window.textBox("convertedVideoSavedFolderField").setText("folder");
436         window.textBox("convertedVideoSavedFileField").setText("converted.avi");
437         SProperties.saveSetting(getProperties());
438
439         window.tabbedPane("mainTabbedPane").selectTab("保存設定");
440         window.tabbedPane("saveTabbedPane").selectTab("出力コメント付き動画");
441         window.radioButton("convSaveFileRadioButton").check();
442         window.textBox("convertedVideoSavedFolderField").setText("folder\\folder2");
443         window.textBox("convertedVideoSavedFileField").setText("folder\\converted.avi");
444         SProperties.saveSetting(getProperties());
445     }
446
447     @MockClass(realClass = FileOutputStream.class)
448     public static class MockFileOutputStream {
449
450         public MockFileOutputStream() {
451         }
452
453         @Mock
454         public MockFileOutputStream(String name) {
455             System.out.println("FileOutputStream constructor mocked.");
456         }
457     }
458
459     @MockClass(realClass = Properties.class)
460     public static class MockProperties {
461
462         private Map<String, String> map = new HashMap<String, String>();
463
464         @Mock
465         public void storeToXML(OutputStream os, String comment) {
466             System.out.println("storeToXML mocked.");
467
468             // 基本設定
469             window.tabbedPane("mainTabbedPane").selectTab("基本設定");
470             // ユーザ設定
471             assertThat(map.get("MailAddress")).isEqualTo(window.textBox("mailAddressField").text());
472             assertThat(map.get("Password")).isEqualTo(window.textBox("passwordField").text());
473             // プロキシ設定
474             assertThat(Boolean.parseBoolean(map.get("UseProxy"))).isEqualTo(window.checkBox("useProxyCheckBox").
475                     component().isSelected());
476             assertThat(map.get("Proxy")).isEqualTo(window.textBox("proxyTextField").text());
477             final String port = window.textBox("proxyPortTextField").text();
478             if (!"".equals(port)) {
479                 assertThat(map.get("ProxyPort")).isEqualTo(port);
480             } else {
481                 assertThat(map.get("ProxyPort")).as("ポートが空の場合には-1(無効な番号)を設定する").isEqualTo("-1");
482             }
483
484             // 保存設定 - 入力動画
485             window.tabbedPane("mainTabbedPane").selectTab("保存設定");
486             window.tabbedPane("saveTabbedPane").selectTab("入力動画");
487
488             final VideoSaveKind saveVideo = VideoSaveKind.valueOf(map.get("SaveVideoFile"));
489             switch (saveVideo) {
490                 case NO_SAVE:
491                     window.radioButton("videoNoSaveButton").requireSelected();
492                     window.radioButton("videoSaveButton").requireNotSelected();
493                     window.radioButton("videoUseNiBrButton").requireNotSelected();
494                     break;
495                 case SAVE:
496                     window.radioButton("videoNoSaveButton").requireNotSelected();
497                     window.radioButton("videoSaveButton").requireSelected();
498                     window.radioButton("videoUseNiBrButton").requireNotSelected();
499                     break;
500                 case NICOBROWSER:
501                     window.radioButton("videoNoSaveButton").requireNotSelected();
502                     window.radioButton("videoSaveButton").requireNotSelected();
503                     window.radioButton("videoUseNiBrButton").requireSelected();
504                     break;
505                 default:
506                     fail();
507             }
508
509             final boolean videoAutoNaming = Boolean.parseBoolean(map.get("VideoFixFileName"));
510             if (videoAutoNaming) {
511                 window.radioButton("saveFolderRadioButton").requireSelected();
512                 window.radioButton("saveFileRadioButton").requireNotSelected();
513             } else {
514                 window.radioButton("saveFolderRadioButton").requireNotSelected();
515                 window.radioButton("saveFileRadioButton").requireSelected();
516             }
517
518             assertThat(Boolean.parseBoolean(map.get("DeleteVideoAfterConv"))).isEqualTo(window.checkBox(
519                     "delVideoCheckBox").component().isSelected());
520             assertThat(map.get("VideoFixFileNameFolder")).isEqualTo(new File(window.textBox("videoSavedFolderField").
521                     text()).getPath());
522             assertThat(map.get("VideoFile")).isEqualTo(window.textBox("videoSavedFileField").text());
523
524             assertThat(map.get("NicoBrowserFileName")).isEqualTo(window.textBox("nibrFileField").text());
525
526
527             // 保存設定 - 入力コメント
528             window.tabbedPane("saveTabbedPane").selectTab("入力コメント");
529
530             assertThat(Boolean.parseBoolean(map.get("SaveCommentFile"))).isEqualTo(window.checkBox(
531                     "savingCommentCheckBox").component().isSelected());
532             assertThat(Boolean.parseBoolean(map.get("DeleteCommentAfterConv"))).isEqualTo(window.checkBox(
533                     "delCommentCheckBox").component().isSelected());
534             assertThat(Boolean.parseBoolean(map.get("FixCommentSize"))).isEqualTo(window.checkBox(
535                     "fixCommentNumCheckBox").component().isSelected());
536             // 空だったらデフォルト値500を設定する
537             String backComment = (window.textBox("commentNumField").text().isEmpty()) ? "500" : window.textBox(
538                     "commentNumField").text();
539             assertThat(map.get("BackComment")).isEqualTo(backComment);
540
541             final boolean commentAutoNaming = Boolean.parseBoolean(map.get("CommentFixFileName"));
542             if (commentAutoNaming) {
543                 window.radioButton("commentSaveFolderRadioButton").requireSelected();
544                 window.radioButton("commentSaveFileRadioButton").requireNotSelected();
545             } else {
546                 window.radioButton("commentSaveFolderRadioButton").requireNotSelected();
547                 window.radioButton("commentSaveFileRadioButton").requireSelected();
548             }
549
550             assertThat(map.get("CommentFixFileNameFolder")).isEqualTo(new File(window.textBox("commentSavedFolderField").
551                     text()).getPath());
552             assertThat(map.get("CommentFile")).isEqualTo(window.textBox("commentSavedFileField").text());
553
554
555             // 保存設定 - 入力投稿者コメント
556             window.tabbedPane("saveTabbedPane").selectTab("入力投稿者コメント");
557
558             assertThat(Boolean.parseBoolean(map.get("TCDownload"))).isEqualTo(window.checkBox("needDownloadTcomment").
559                     component().isSelected());
560             assertThat(Boolean.parseBoolean(map.get("TCDelete"))).isEqualTo(window.checkBox("delTcomment").component().
561                     isSelected());
562
563             final boolean tcommAutoNaming = Boolean.parseBoolean(map.get("TCAutoNaming"));
564             if (tcommAutoNaming) {
565                 window.radioButton("tcommentSaveInFolder").requireSelected();
566                 window.radioButton("tcommentSaveToFile").requireNotSelected();
567             } else {
568                 window.radioButton("tcommentSaveInFolder").requireNotSelected();
569                 window.radioButton("tcommentSaveToFile").requireSelected();
570             }
571
572             assertThat(map.get("TCDirectory")).isEqualTo(window.textBox("tcommentFolder").text());
573             assertThat(map.get("TCFileName")).isEqualTo(window.textBox("tcommentFile").text());
574
575
576             // 保存設定 - 出力コメント付き動画
577             window.tabbedPane("saveTabbedPane").selectTab("出力コメント付き動画");
578
579             assertThat(Boolean.parseBoolean(map.get("SaveConvertedFile"))).isEqualTo(window.checkBox(
580                     "savingConvertedVideoCheckBox").component().isSelected());
581             assertThat(Boolean.parseBoolean(map.get("AddComment"))).isEqualTo(window.checkBox("addComment").component().
582                     isSelected());
583             assertThat(Boolean.parseBoolean(map.get("AddTcomment"))).isEqualTo(window.checkBox("addTcomment").component().
584                     isSelected());
585
586             final boolean convertedAutoNaming = Boolean.parseBoolean(map.get("ConvFixFileName"));
587             if (convertedAutoNaming) {
588                 window.radioButton("convSaveFolderRadioButton").requireSelected();
589                 window.radioButton("convSaveFileRadioButton").requireNotSelected();
590             } else {
591                 window.radioButton("convSaveFolderRadioButton").requireNotSelected();
592                 window.radioButton("convSaveFileRadioButton").requireSelected();
593             }
594
595             assertThat(Boolean.parseBoolean(map.get("NotAddVideoIDtoConverted"))).isEqualTo(window.checkBox(
596                     "notAddVideoIdConvVideoCheckBox").component().isSelected());
597             assertThat(map.get("ConvFixFileNameFolder")).isEqualTo(
598                     window.textBox("convertedVideoSavedFolderField").text());
599             assertThat(map.get("ConvertedFile")).isEqualTo(window.textBox("convertedVideoSavedFileField").text());
600
601
602             // 基本設定
603             window.tabbedPane("mainTabbedPane").selectTab("動画設定");
604
605             assertThat(map.get("FFnpegPath")).isEqualTo(window.textBox("ffmpegPathField").text());
606             assertThat(map.get("VhookPath")).isEqualTo(window.textBox("vhookPathField").text());
607
608             assertThat(map.get("CMD_EXT")).isEqualTo(window.textBox("extOptionField").text());
609             assertThat(map.get("CMD_MAIN")).isEqualTo(window.textBox("mainOptionField").text());
610             assertThat(map.get("CMD_IN")).isEqualTo(window.textBox("inputOptionField").text());
611             assertThat(map.get("CMD_OUT")).isEqualTo(window.textBox("outputOptionField").text());
612
613
614             // 変換設定
615             window.tabbedPane("mainTabbedPane").selectTab("変換設定");
616             assertThat(Boolean.parseBoolean(map.get("VhookDisabled"))).isEqualTo(window.checkBox("disableVhookCheckBox").
617                     component().isSelected());
618             assertThat(map.get("ShowCommentNum")).isEqualTo(window.textBox("viewCommentField").text());
619             assertThat(map.get("FontPath")).isEqualTo(window.textBox("fontPathField").text());
620             assertThat(map.get("FontIndex")).isEqualTo(window.textBox("fontIndexField").text());
621             window.comboBox("shadowComboBox").requireSelection(Integer.parseInt(map.get("ShadowIndex")));
622             assertThat(Boolean.parseBoolean(map.get("ShowVideo"))).isEqualTo(window.checkBox("showConvVideoCheckBox").
623                     component().isSelected());
624             assertThat(Boolean.parseBoolean(map.get("FixFontSize"))).isEqualTo(window.checkBox("fixFontSizeCheckBox").
625                     component().isSelected());
626             assertThat(Boolean.parseBoolean(map.get("OpaqueComment"))).isEqualTo(window.checkBox("opaqueCommentCheckBox").
627                     component().isSelected());
628
629             assertThat(map.get("NG_Word")).isEqualTo(window.textBox("ngWordTextField").text());
630             assertThat(map.get("NG_ID")).isEqualTo(window.textBox("ngIdTextField").text());
631
632
633 //assertThat(map.get("TempDir")).isEqualTo(window.
634         }
635
636         @Mock
637         public Object setProperty(String key, String value) {
638             String prev = map.put(key, value);
639 //            assertNull(prev);
640             return prev;
641         }
642     }
643 }