Line 0
Link Here
|
|
|
1 |
/* |
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
3 |
* |
4 |
* Copyright 2012 Oracle and/or its affiliates. All rights reserved. |
5 |
* |
6 |
* Oracle and Java are registered trademarks of Oracle and/or its affiliates. |
7 |
* Other names may be trademarks of their respective owners. |
8 |
* |
9 |
* The contents of this file are subject to the terms of either the GNU |
10 |
* General Public License Version 2 only ("GPL") or the Common |
11 |
* Development and Distribution License("CDDL") (collectively, the |
12 |
* "License"). You may not use this file except in compliance with the |
13 |
* License. You can obtain a copy of the License at |
14 |
* http://www.netbeans.org/cddl-gplv2.html |
15 |
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the |
16 |
* specific language governing permissions and limitations under the |
17 |
* License. When distributing the software, include this License Header |
18 |
* Notice in each file and include the License file at |
19 |
* nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this |
20 |
* particular file as subject to the "Classpath" exception as provided |
21 |
* by Oracle in the GPL Version 2 section of the License file that |
22 |
* accompanied this code. If applicable, add the following below the |
23 |
* License Header, with the fields enclosed by brackets [] replaced by |
24 |
* your own identifying information: |
25 |
* "Portions Copyrighted [year] [name of copyright owner]" |
26 |
* |
27 |
* If you wish your version of this file to be governed by only the CDDL |
28 |
* or only the GPL Version 2, indicate your decision by adding |
29 |
* "[Contributor] elects to include this software in this distribution |
30 |
* under the [CDDL or GPL Version 2] license." If you do not indicate a |
31 |
* single choice of license, a recipient has the option to distribute |
32 |
* your version of this file under either the CDDL, the GPL Version 2 or |
33 |
* to extend the choice of license to its licensees as provided above. |
34 |
* However, if you add GPL Version 2 code and therefore, elected the GPL |
35 |
* Version 2 license, then the option applies only if the new code is |
36 |
* made subject to such option by the copyright holder. |
37 |
* |
38 |
* Contributor(s): |
39 |
* |
40 |
* Portions Copyrighted 2012 Sun Microsystems, Inc. |
41 |
*/ |
42 |
package org.netbeans.core.output2; |
43 |
|
44 |
import javax.swing.Action; |
45 |
import javax.swing.Icon; |
46 |
import javax.swing.JComponent; |
47 |
import static org.junit.Assert.*; |
48 |
import org.junit.Test; |
49 |
import org.openide.windows.IOContainer; |
50 |
import org.openide.windows.IOContainer.CallBacks; |
51 |
import org.openide.windows.IOProvider; |
52 |
import org.openide.windows.InputOutput; |
53 |
|
54 |
/** |
55 |
* |
56 |
* @author jhavlin |
57 |
*/ |
58 |
public class NbIOProviderTest { |
59 |
|
60 |
public NbIOProviderTest() { |
61 |
} |
62 |
|
63 |
@Test |
64 |
public void testGetIO_4args() { |
65 |
|
66 |
IOContainer def = IOContainer.getDefault(); |
67 |
IOContainer cus = IOContainer.create(new MyContainerProvider()); |
68 |
|
69 |
InputOutput ioDef1 = IOProvider.getDefault().getIO("test1", true, null, def); |
70 |
InputOutput ioCus1 = IOProvider.getDefault().getIO("test1", true, null, cus); |
71 |
InputOutput ioDef2 = IOProvider.getDefault().getIO("test2", true, null, def); |
72 |
InputOutput ioCus2 = IOProvider.getDefault().getIO("test2", true, null, cus); |
73 |
|
74 |
assertNotSame(ioDef1, ioCus1); |
75 |
assertNotSame(ioDef2, ioCus2); |
76 |
assertNotSame(ioDef1, ioDef2); |
77 |
assertNotSame(ioCus1, ioCus2); |
78 |
|
79 |
InputOutput ioDef1b = IOProvider.getDefault().getIO("test1", false, null, def); |
80 |
InputOutput ioCus1b = IOProvider.getDefault().getIO("test1", false, null, cus); |
81 |
|
82 |
assertSame(ioDef1, ioDef1b); |
83 |
assertSame(ioCus1, ioCus1b); |
84 |
|
85 |
ioDef1.closeInputOutput(); |
86 |
ioDef2.closeInputOutput(); |
87 |
ioCus1.closeInputOutput(); |
88 |
ioCus2.closeInputOutput(); |
89 |
} |
90 |
|
91 |
public static class MyContainerProvider implements IOContainer.Provider { |
92 |
|
93 |
@Override |
94 |
public void open() { |
95 |
} |
96 |
|
97 |
@Override |
98 |
public void requestActive() { |
99 |
} |
100 |
|
101 |
@Override |
102 |
public void requestVisible() { |
103 |
} |
104 |
|
105 |
@Override |
106 |
public boolean isActivated() { |
107 |
return true; |
108 |
} |
109 |
|
110 |
@Override |
111 |
public void add(JComponent comp, CallBacks cb) { |
112 |
} |
113 |
|
114 |
@Override |
115 |
public void remove(JComponent comp) { |
116 |
} |
117 |
|
118 |
@Override |
119 |
public void select(JComponent comp) { |
120 |
} |
121 |
|
122 |
@Override |
123 |
public JComponent getSelected() { |
124 |
return null; |
125 |
} |
126 |
|
127 |
@Override |
128 |
public void setTitle(JComponent comp, String name) { |
129 |
} |
130 |
|
131 |
@Override |
132 |
public void setToolTipText(JComponent comp, String text) { |
133 |
} |
134 |
|
135 |
@Override |
136 |
public void setIcon(JComponent comp, Icon icon) { |
137 |
} |
138 |
|
139 |
@Override |
140 |
public void setToolbarActions(JComponent comp, Action[] toolbarActions) { |
141 |
} |
142 |
|
143 |
@Override |
144 |
public boolean isCloseable(JComponent comp) { |
145 |
return true; |
146 |
} |
147 |
} |
148 |
} |