KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > module > wizards > shortcut > SelectFolderPanelTest


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.apache.tools.ant.module.wizards.shortcut;
21
22 import java.util.Arrays JavaDoc;
23 import javax.swing.ListModel JavaDoc;
24 import org.openide.loaders.DataFolder;
25
26 /**
27  * Test functionality of SelectFolderPanel.
28  * @author Jesse Glick
29  */

30 public final class SelectFolderPanelTest extends ShortcutWizardTestBase {
31
32     public SelectFolderPanelTest(String JavaDoc name) {
33         super(name);
34     }
35
36     private SelectFolderPanel.SelectFolderWizardPanel menuPanel;
37     private SelectFolderPanel.SelectFolderWizardPanel toolbarsPanel;
38     private ListModel JavaDoc menuListModel;
39     private ListModel JavaDoc toolbarsListModel;
40     @Override JavaDoc
41     protected void setUp() throws Exception JavaDoc {
42         super.setUp();
43         wiz.putProperty(ShortcutWizard.PROP_SHOW_MENU, Boolean.TRUE);
44         wiz.putProperty(ShortcutWizard.PROP_SHOW_TOOL, Boolean.TRUE);
45         iter.nextPanel();
46         iter.current().readSettings(wiz);
47         menuPanel = (SelectFolderPanel.SelectFolderWizardPanel)iter.current();
48         menuListModel = menuPanel.getPanel().getModel();
49         iter.current().storeSettings(wiz);
50         iter.nextPanel();
51         iter.current().readSettings(wiz);
52         toolbarsPanel = (SelectFolderPanel.SelectFolderWizardPanel)iter.current();
53         toolbarsListModel = toolbarsPanel.getPanel().getModel();
54         iter.current().storeSettings(wiz);
55     }
56     
57     public void testFolderListDisplay() throws Exception JavaDoc {
58         String JavaDoc[] names = new String JavaDoc[menuListModel.getSize()];
59         for (int i = 0; i < names.length; i++) {
60             names[i] = menuPanel.getPanel().getNestedDisplayName((DataFolder)menuListModel.getElementAt(i));
61         }
62         String JavaDoc[] expected = {
63             "File",
64             "Edit",
65             "Build",
66             "Build \u2192 Other",
67             "Help",
68         };
69         assertEquals("right names in list", Arrays.asList(expected), Arrays.asList(names));
70         names = new String JavaDoc[toolbarsListModel.getSize()];
71         for (int i = 0; i < names.length; i++) {
72             names[i] = toolbarsPanel.getPanel().getNestedDisplayName((DataFolder)toolbarsListModel.getElementAt(i));
73         }
74         expected = new String JavaDoc[] {
75             "Build",
76             "Help",
77         };
78         assertEquals("right names in list", Arrays.asList(expected), Arrays.asList(names));
79     }
80     
81     // XXX test setting correct folder & display name in wizard data
82

83 }
84
Popular Tags