KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > editor > suites > keybindings > CheckActionsListPerformer


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.test.editor.suites.keybindings;
21
22 import java.io.File JavaDoc;
23 import java.io.FileWriter JavaDoc;
24 import java.io.PrintWriter JavaDoc;
25 import java.util.*;
26 import java.util.List JavaDoc;
27 import org.netbeans.jellytools.*;
28 import org.netbeans.jellytools.EditorOperator;
29 import org.netbeans.jellytools.modules.editor.Abbreviations;
30 import org.netbeans.jellytools.modules.editor.KeyBindings;
31 import org.netbeans.test.editor.LineDiff;
32
33 /**This is test in very development stage. I put it into the CVS mainly because
34  * it simplifies testing on different platforms. This test may or may not
35  * be reliable and may or may not work at all.
36  *
37  * @author Jan Lahoda
38  */

39 public class CheckActionsListPerformer extends JellyTestCase {
40     
41     public static String JavaDoc[] TESTED_EDITORS={"Java Editor","Plain Editor","HTML Editor"};
42     String JavaDoc editorName;
43     
44     public CheckActionsListPerformer(String JavaDoc name) {
45         super(name);
46     }
47     
48     /**
49      * @param args the command line arguments
50      */

51     public void doTest() throws Exception JavaDoc {
52         log("doTest start");
53         log("Editor name: "+editorName);
54         try {
55             Hashtable table;
56             log("Grabbing actions...");
57             table = KeyBindings.listAllKeyBindings(editorName);
58             Object JavaDoc[] keys=table.keySet().toArray();
59             Arrays.sort(keys);
60             List JavaDoc list;
61             log("Writting to ref file...");
62             File JavaDoc f=new File JavaDoc(getWorkDir(),editorName+" actions.ref");
63             PrintWriter JavaDoc pw=new PrintWriter JavaDoc(new FileWriter JavaDoc(f));
64             for (int i=0;i < keys.length;i++) {
65                 pw.print(keys[i]+": ");
66                 list=(List JavaDoc)table.get(keys[i]);
67                 for (int j=0;j < list.size();j++) {
68                     pw.print(list.get(j)+" ");
69                 }
70                 pw.println();
71             }
72             pw.close();
73         } finally {
74             log("doTest finished");
75         }
76     }
77     
78     public void setUp() {
79         log("Starting check Key Bindings actions test.");
80     }
81     
82     public void tearDown() throws Exception JavaDoc {
83         log("Ending check Key Bindings actions test.");
84         File JavaDoc ref=new File JavaDoc(getWorkDir(),editorName+" actions.ref");
85         assertFile("Some actions aren't same as before the split.", getGoldenFile(editorName+" actions.pass"), ref, new File JavaDoc(getWorkDir(),editorName+" actions.diff"), new LineDiff(false));
86         ref.delete();
87     }
88     
89     public void testCheckPlainActions() throws Exception JavaDoc {
90         editorName="Plain Editor";
91         doTest();
92     }
93     
94     public void testCheckJavaActions() throws Exception JavaDoc {
95         editorName="Java Editor";
96         doTest();
97     }
98     
99     public void testCheckHTMLActions() throws Exception JavaDoc {
100         editorName="HTML Editor";
101         doTest();
102     }
103     
104     public static void main(String JavaDoc[] args) throws Exception JavaDoc {
105         //new CheckActionsListPerformer("testCheckActions").testCheckActions();
106
}
107     
108 }
109
Popular Tags