01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: /**
18: * @author Sergey Burlak
19: * @version $Revision$
20: */package javax.swing;
21:
22: import java.awt.Dimension;
23:
24: public class ViewportLayoutTest extends SwingTestCase {
25: private ViewportLayout layout;
26:
27: private JViewport viewport;
28:
29: private JLabel label;
30:
31: @Override
32: public void setUp() {
33: label = new JLabel();
34: StringBuffer b = new StringBuffer();
35: for (int i = 0; i < 1000; i++) {
36: b.append("w" + i);
37: }
38: label.setText(b.toString());
39: viewport = new JViewport();
40: viewport.add(label);
41: layout = (ViewportLayout) viewport.getLayout();
42: }
43:
44: @Override
45: public void tearDown() {
46: layout = null;
47: viewport = null;
48: label = null;
49: }
50:
51: public void testPreferredSize() throws Exception {
52: assertEquals(label.getPreferredSize(), layout
53: .preferredLayoutSize(viewport));
54: }
55:
56: public void testMinimumSize() throws Exception {
57: assertEquals(new Dimension(4, 4), layout
58: .minimumLayoutSize(viewport));
59: }
60: }
|