KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > core > windows > TopComponentTypeTest


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 2002 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.core.windows;
21
22 import junit.framework.*;
23 import org.netbeans.junit.*;
24
25 import org.openide.windows.*;
26
27
28 /**
29  * Ensure that TopComponent type - "editor" / "view" - is interpreted correctly.
30  *
31  * @author S. Aubrecht
32  */

33 public class TopComponentTypeTest extends NbTestCase {
34
35     public TopComponentTypeTest (String JavaDoc name) {
36         super (name);
37     }
38
39     /**
40      * @param args the command line arguments
41      */

42     public static void main(java.lang.String JavaDoc[] args) {
43         junit.textui.TestRunner.run(suite());
44     }
45     
46     public static Test suite() {
47         TestSuite suite = new NbTestSuite(TopComponentTypeTest.class);
48         
49         return suite;
50     }
51
52     protected boolean runInEQ () {
53         return true;
54     }
55      
56     public void testIsEditorTopComponent () throws Exception JavaDoc {
57         TopComponent tc = new TopComponent ();
58         Mode mode = WindowManagerImpl.getInstance().createMode( "editorMode", Constants.MODE_KIND_EDITOR, Constants.MODE_STATE_JOINED, false, new SplitConstraint[0] );
59         mode.dockInto( tc );
60         
61         assertTrue( WindowManagerImpl.getInstance().isEditorTopComponent( tc ) );
62         assertTrue( WindowManagerImpl.getInstance().isEditorMode( mode ) );
63     }
64     
65     public void testIsViewTopComponent () throws Exception JavaDoc {
66         TopComponent tc = new TopComponent ();
67         Mode mode = WindowManagerImpl.getInstance().createMode( "viewMode", Constants.MODE_KIND_VIEW, Constants.MODE_STATE_JOINED, false, new SplitConstraint[0] );
68         mode.dockInto( tc );
69         
70         assertFalse( WindowManagerImpl.getInstance().isEditorTopComponent( tc ) );
71         assertFalse( WindowManagerImpl.getInstance().isEditorMode( mode ) );
72     }
73     
74     public void testUnknownTopComponent () throws Exception JavaDoc {
75         TopComponent tc = new TopComponent ();
76         //no mode defined for the topcomponent
77

78         assertFalse( WindowManagerImpl.getInstance().isEditorTopComponent( tc ) );
79     }
80 }
81
82
Popular Tags