KickJava   Java API By Example, From Geeks To Geeks.

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


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 /** Test to guarantee that the compatibility for docking operations is
29  * preserved for components written against release 3.5 and later and
30  * that such components can be docked.
31  *
32  * @author Jaroslav Tulach
33  */

34 public class DockingCompatibilityTest extends NbTestCase {
35
36     /** Creates a new instance of SFSTest */
37     public DockingCompatibilityTest (String JavaDoc name) {
38         super (name);
39     }
40
41     /**
42      * @param args the command line arguments
43      */

44     public static void main(java.lang.String JavaDoc[] args) {
45         junit.textui.TestRunner.run(suite());
46     }
47     
48     public static Test suite() {
49         TestSuite suite = new NbTestSuite(DockingCompatibilityTest.class);
50         
51         return suite;
52     }
53
54     protected boolean runInEQ () {
55         return true;
56     }
57     
58     
59     public void testSimplyOpenedComponentCanBeDockedWhereeverItWants () throws Exception JavaDoc {
60         TopComponent tc = new TopComponent ();
61         tc.open ();
62         
63         assertCanBeDocked (tc, Boolean.TRUE);
64     }
65     
66     public void testComponentPutIntoOwnModeCanBeDockedAsWell () {
67         Mode mode = WindowManager.getDefault ().getCurrentWorkspace ().createMode ("OwnMode", "displayName", null);
68         TopComponent tc = new TopComponent ();
69         mode.dockInto (tc);
70         tc.open ();
71         
72         assertCanBeDocked (tc, Boolean.TRUE);
73     }
74
75     public void testComponentPlacedDirectlyIntoEditorModeHasToStayThere () {
76         Mode mode = WindowManager.getDefault ().findMode ("editor");
77         assertNotNull ("Shall not be null", mode);
78         TopComponent tc = new TopComponent ();
79         mode.dockInto (tc);
80         assertCanBeDocked (tc, null);
81     }
82     
83     
84     private static void assertCanBeDocked (TopComponent tc, Boolean JavaDoc expectedValue) {
85         assertEquals (
86             expectedValue,
87             tc.getClientProperty (Constants.TOPCOMPONENT_ALLOW_DOCK_ANYWHERE)
88         );
89     }
90 }
91
92
Popular Tags