You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by nd...@apache.org on 2006/11/26 21:15:55 UTC
svn commit: r479418 [9/43] - in
/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common:
javax/swing/ javax/swing/border/ javax/swing/colorchooser/
javax/swing/event/ javax/swing/filechooser/ javax/swing/plaf/
javax/swing/plaf/basic/ ja...
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicRadioButtonMenuItemUITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicRadioButtonMenuItemUITest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicRadioButtonMenuItemUITest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicRadioButtonMenuItemUITest.java Sun Nov 26 12:15:43 2006
@@ -15,25 +15,25 @@
* limitations under the License.
*/
/**
-* @author Alexander T. Simbirtsev
-* @version $Revision$
-*/
+ * @author Alexander T. Simbirtsev
+ * @version $Revision$
+ */
package javax.swing.plaf.basic;
import javax.swing.plaf.ComponentUI;
public class BasicRadioButtonMenuItemUITest extends BasicMenuItemUITest {
-
protected BasicRadioButtonMenuItemUI radioUI;
+ @Override
protected void setUp() throws Exception {
super.setUp();
-
radioUI = new BasicRadioButtonMenuItemUI();
menuItemUI = radioUI;
prefix = "RadioButtonMenuItem.";
}
+ @Override
protected void tearDown() throws Exception {
radioUI = null;
menuItemUI = null;
@@ -43,6 +43,7 @@
/*
* Test method for 'javax.swing.plaf.basic.BasicRadioButtonMenuItemUI.createUI(JComponent)'
*/
+ @Override
public void testCreateUI() {
ComponentUI ui1 = BasicRadioButtonMenuItemUI.createUI(null);
ComponentUI ui2 = BasicRadioButtonMenuItemUI.createUI(null);
@@ -53,6 +54,7 @@
/*
* Test method for 'javax.swing.plaf.basic.BasicRadioButtonMenuItemUI.getPropertyPrefix()'
*/
+ @Override
public void testGetPropertyPrefix() {
assertEquals("RadioButtonMenuItem", menuItemUI.getPropertyPrefix());
}
@@ -63,5 +65,4 @@
*/
public void testProcessMouseEvent() {
}
-
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicRadioButtonUITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicRadioButtonUITest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicRadioButtonUITest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicRadioButtonUITest.java Sun Nov 26 12:15:43 2006
@@ -27,7 +27,6 @@
import java.awt.Font;
import java.awt.Insets;
import java.awt.image.BufferedImage;
-
import javax.swing.AbstractButton;
import javax.swing.BorderFactory;
import javax.swing.Icon;
@@ -45,20 +44,23 @@
import javax.swing.plaf.InsetsUIResource;
public class BasicRadioButtonUITest extends SwingTestCase {
-
public class MyBasicRadioButtonUI extends BasicRadioButtonUI {
+ @Override
public String getPropertyPrefix() {
return super.getPropertyPrefix();
}
+ @Override
public void installDefaults(final AbstractButton b) {
super.installDefaults(b);
}
+ @Override
public void uninstallDefaults(final AbstractButton b) {
super.uninstallDefaults(b);
}
+ @Override
public int getTextShiftOffset() {
return super.getTextShiftOffset();
}
@@ -81,9 +83,9 @@
/*
* @see TestCase#setUp()
*/
+ @Override
protected void setUp() throws Exception {
super.setUp();
-
ui = new MyBasicRadioButtonUI();
}
@@ -92,12 +94,10 @@
UIManager.put("RadioButton.font", font);
Border border = new BorderUIResource(BorderFactory.createEmptyBorder(11, 11, 11, 11));
UIManager.put("RadioButton.border", border);
-
JRadioButton button1 = new JRadioButton();
JRadioButton button2 = new JRadioButton("text");
JRadioButton button3 = new JRadioButton("text");
JRadioButton button6 = new JRadioButton("text");
-
button3.setBorder(new EmptyBorder(10, 10, 10, 10));
button6.setBorder(null);
int iconH = 20;
@@ -106,35 +106,33 @@
// following parameters are not being used by UI
ui.setTextIconGap(100);
ui.setTextShiftOffset(33);
-
int horInsets = button1.getInsets().left + button1.getInsets().right;
int vertInsets = button1.getInsets().top + button1.getInsets().bottom;
int textWidth = button1.getFontMetrics(button1.getFont()).stringWidth("text");
int textHeight = button1.getFontMetrics(button1.getFont()).getHeight();
-
- assertEquals("PreferredSize", new Dimension(horInsets + iconW, vertInsets + iconH),
- ui.getPreferredSize(button1));
- assertEquals("PreferredSize", new Dimension(horInsets + iconW + textWidth + button1.getIconTextGap(),
- vertInsets + Math.max(iconH, textHeight)),
- ui.getPreferredSize(button2));
-
+ assertEquals("PreferredSize", new Dimension(horInsets + iconW, vertInsets + iconH), ui
+ .getPreferredSize(button1));
+ assertEquals("PreferredSize", new Dimension(horInsets + iconW + textWidth
+ + button1.getIconTextGap(), vertInsets + Math.max(iconH, textHeight)), ui
+ .getPreferredSize(button2));
horInsets = button3.getInsets().left + button3.getInsets().right;
vertInsets = button3.getInsets().top + button3.getInsets().bottom;
- assertEquals("PreferredSize", new Dimension(horInsets + iconW + textWidth + button1.getIconTextGap(),
- vertInsets + Math.max(iconH, textHeight)),
- ui.getPreferredSize(button3));
-
+ assertEquals("PreferredSize", new Dimension(horInsets + iconW + textWidth
+ + button1.getIconTextGap(), vertInsets + Math.max(iconH, textHeight)), ui
+ .getPreferredSize(button3));
horInsets = button6.getInsets().left + button6.getInsets().right;
vertInsets = button6.getInsets().top + button6.getInsets().bottom;
- assertEquals("PreferredSize", new Dimension(horInsets + iconW + textWidth + button1.getIconTextGap(),
- vertInsets + Math.max(iconH, textHeight)),
- ui.getPreferredSize(button6));
+ assertEquals("PreferredSize", new Dimension(horInsets + iconW + textWidth
+ + button1.getIconTextGap(), vertInsets + Math.max(iconH, textHeight)), ui
+ .getPreferredSize(button6));
}
public void testCreateUI() {
assertTrue("created UI is not null", null != BasicRadioButtonUI.createUI(new JButton()));
- assertTrue("created UI is of the proper class", BasicRadioButtonUI.createUI(null) instanceof BasicRadioButtonUI);
- assertTrue("created UI is of unique", BasicRadioButtonUI.createUI(null) == BasicRadioButtonUI.createUI(null));
+ assertTrue("created UI is of the proper class",
+ BasicRadioButtonUI.createUI(null) instanceof BasicRadioButtonUI);
+ assertTrue("created UI is of unique",
+ BasicRadioButtonUI.createUI(null) == BasicRadioButtonUI.createUI(null));
}
public void testUninstallDefaults() {
@@ -148,7 +146,6 @@
UIManager.put("RadioButton.border", border);
Insets margin = new InsetsUIResource(10, 20, 30, 40);
UIManager.put("RadioButton.margin", margin);
-
button.setUI(ui);
ui.installDefaults(button);
ui.uninstallDefaults(button);
@@ -170,9 +167,9 @@
UIManager.put("RadioButton.border", border);
Insets margin = new InsetsUIResource(10, 20, 30, 40);
UIManager.put("RadioButton.margin", margin);
- Icon icon = new IconUIResource(new ImageIcon(new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB)));
+ Icon icon = new IconUIResource(new ImageIcon(new BufferedImage(10, 10,
+ BufferedImage.TYPE_INT_RGB)));
UIManager.put("RadioButton.icon", icon);
-
button.setUI(ui);
ui.installDefaults(button);
assertEquals("background", Color.blue, button.getBackground());
@@ -193,5 +190,4 @@
ui.setIcon(icon);
assertEquals("icon", icon, ui.getDefaultIcon());
}
-
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicRootPaneUITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicRootPaneUITest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicRootPaneUITest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicRootPaneUITest.java Sun Nov 26 12:15:43 2006
@@ -14,16 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
/**
* @author Vadim L. Bogdanov
* @version $Revision$
*/
-
package javax.swing.plaf.basic;
import java.beans.PropertyChangeListener;
-
import javax.swing.ActionMap;
import javax.swing.InputMap;
import javax.swing.JButton;
@@ -33,12 +30,11 @@
import javax.swing.SwingTestCase;
import javax.swing.SwingUtilities;
import javax.swing.plaf.ComponentUI;
-
import java.util.EventListener;
-
public class BasicRootPaneUITest extends SwingTestCase {
private JRootPane rootPane;
+
private BasicRootPaneUI ui;
public BasicRootPaneUITest(final String name) {
@@ -48,15 +44,17 @@
/*
* @see TestCase#setUp()
*/
+ @Override
protected void setUp() throws Exception {
super.setUp();
rootPane = new JRootPane();
- ui = (BasicRootPaneUI)BasicRootPaneUI.createUI(rootPane);
+ ui = (BasicRootPaneUI) BasicRootPaneUI.createUI(rootPane);
}
/*
* @see TestCase#tearDown()
*/
+ @Override
protected void tearDown() throws Exception {
super.tearDown();
}
@@ -73,17 +71,15 @@
*
*/
protected boolean isListenerInstalled(final JComponent c,
- final PropertyChangeListener listener) {
+ final PropertyChangeListener listener) {
EventListener[] listeners = rootPane.getPropertyChangeListeners();
boolean result = false;
-
for (int i = 0; i < listeners.length; i++) {
if (listeners[i] == listener) {
result = true;
break;
}
}
-
return result;
}
@@ -94,37 +90,26 @@
*/
public void testInstallUninstallUI() {
ui.installUI(rootPane);
-
// check install listeners
assertTrue(isListenerInstalled(rootPane, ui));
-
// check install keyboard actions
- int inputMapType = isHarmony()
- ? JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
- : JComponent.WHEN_IN_FOCUSED_WINDOW;
+ int inputMapType = isHarmony() ? JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
+ : JComponent.WHEN_IN_FOCUSED_WINDOW;
assertTrue("inputMap installed",
- SwingUtilities.getUIInputMap(rootPane,
- inputMapType) != null);
- int inputMapLength = SwingUtilities.getUIInputMap(rootPane,
- inputMapType).size();
+ SwingUtilities.getUIInputMap(rootPane, inputMapType) != null);
+ int inputMapLength = SwingUtilities.getUIInputMap(rootPane, inputMapType).size();
assertTrue(SwingUtilities.getUIActionMap(rootPane) != null);
int actionMapLength = SwingUtilities.getUIActionMap(rootPane).size();
-
ui.uninstallUI(rootPane);
-
// check uninstall keyboard actions
- InputMap inputMap = SwingUtilities.getUIInputMap(rootPane,
- inputMapType);
+ InputMap inputMap = SwingUtilities.getUIInputMap(rootPane, inputMapType);
if (inputMap != null) {
- assertTrue("keys were uninstalled",
- inputMap.size() < inputMapLength);
+ assertTrue("keys were uninstalled", inputMap.size() < inputMapLength);
}
ActionMap actionMap = SwingUtilities.getUIActionMap(rootPane);
if (actionMap != null) {
- assertTrue("actions were uninstalled",
- actionMap.size() < actionMapLength);
+ assertTrue("actions were uninstalled", actionMap.size() < actionMapLength);
}
-
// check uninstall listeners
assertFalse(isListenerInstalled(rootPane, ui));
}
@@ -135,35 +120,24 @@
public void testPropertyChange() {
JFrame frame = new JFrame();
rootPane = frame.getRootPane();
-
rootPane.setUI(ui);
-
- int inputMapType = isHarmony()
- ? JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
- : JComponent.WHEN_IN_FOCUSED_WINDOW;
- InputMap inputMap = SwingUtilities.getUIInputMap(rootPane,
- inputMapType);
-
+ int inputMapType = isHarmony() ? JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
+ : JComponent.WHEN_IN_FOCUSED_WINDOW;
+ InputMap inputMap = SwingUtilities.getUIInputMap(rootPane, inputMapType);
assertTrue("inputMap != null", inputMap != null);
-
- Object[] keys = SwingUtilities.getUIInputMap(rootPane,
- inputMapType).keys();
+ Object[] keys = SwingUtilities.getUIInputMap(rootPane, inputMapType).keys();
int keysLength = (keys == null) ? 0 : keys.length;
// defaultButton is null, keysLength may be != 0 in 1.5
//assertTrue("", keys == null || keys.length == 0);
-
rootPane.setDefaultButton(new JButton());
- keys = SwingUtilities.getUIInputMap(rootPane,
- inputMapType).keys();
+ keys = SwingUtilities.getUIInputMap(rootPane, inputMapType).keys();
// defaultButton != null
assertTrue("keys were added", keys.length > keysLength);
-
rootPane.setDefaultButton(null);
- keys = SwingUtilities.getUIInputMap(rootPane,
- inputMapType).keys();
+ keys = SwingUtilities.getUIInputMap(rootPane, inputMapType).keys();
// defaultButton is null
- assertTrue("keys were removed",
- keysLength == 0 && keys == null || keys.length == keysLength);
+ assertTrue("keys were removed", keysLength == 0 && keys == null
+ || keys.length == keysLength);
}
/*
@@ -173,7 +147,6 @@
ComponentUI ui = BasicRootPaneUI.createUI(rootPane);
assertTrue(ui != null);
assertTrue(ui instanceof BasicRootPaneUI);
-
ComponentUI ui2 = BasicRootPaneUI.createUI(rootPane);
assertTrue("stateless", ui == ui2);
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicScrollBarUITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicScrollBarUITest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicScrollBarUITest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicScrollBarUITest.java Sun Nov 26 12:15:43 2006
@@ -14,19 +14,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
/**
* @author Sergey Burlak
* @version $Revision$
*/
-
package javax.swing.plaf.basic;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Rectangle;
-
import javax.swing.BasicSwingTestCase;
import javax.swing.DefaultBoundedRangeModel;
import javax.swing.JButton;
@@ -40,8 +37,10 @@
public class BasicScrollBarUITest extends BasicSwingTestCase {
private BasicScrollBarUI barUI;
+
private JScrollBar bar;
+ @Override
protected void setUp() throws Exception {
super.setUp();
bar = new JScrollBar();
@@ -49,6 +48,7 @@
bar.setUI(barUI);
}
+ @Override
protected void tearDown() throws Exception {
barUI = null;
bar = null;
@@ -57,7 +57,6 @@
public void testSetThumbBounds() throws Exception {
Rectangle bounds = barUI.getThumbBounds();
-
barUI.setThumbBounds(2, 3, 4, 5);
assertEquals(new Rectangle(2, 3, 4, 5), barUI.getThumbBounds());
assertTrue(barUI.getThumbBounds() == bounds);
@@ -70,7 +69,6 @@
f.setSize(200, 200);
f.setVisible(true);
SwingWaitTestCase.isRealized(f);
-
bar.setBounds(0, 0, 10, 132);
bar.setValues(0, 50, 0, 100);
waitForIdle();
@@ -78,21 +76,18 @@
checkIsCloseTo(16, barUI.getThumbBounds().y);
checkIsCloseTo(10, barUI.getThumbBounds().width);
checkIsCloseTo(50, barUI.getThumbBounds().height);
-
bar.setValues(30, 50, 0, 100);
waitForIdle();
checkIsCloseTo(0, barUI.getThumbBounds().x);
checkIsCloseTo(46, barUI.getThumbBounds().y);
checkIsCloseTo(10, barUI.getThumbBounds().width);
checkIsCloseTo(50, barUI.getThumbBounds().height);
-
bar.setValues(50, 50, 0, 100);
waitForIdle();
checkIsCloseTo(0, barUI.getThumbBounds().x);
checkIsCloseTo(66, barUI.getThumbBounds().y);
checkIsCloseTo(10, barUI.getThumbBounds().width);
checkIsCloseTo(50, barUI.getThumbBounds().height);
-
f.dispose();
}
@@ -102,7 +97,6 @@
public void testPreferredLayoutSize() throws Exception {
assertEquals(barUI.preferredLayoutSize(bar), barUI.getPreferredSize(bar));
-
JLabel label = new JLabel();
label.setPreferredSize(new Dimension(500, 600));
label.setBackground(Color.RED);
@@ -110,11 +104,10 @@
final JScrollPane pane = new JScrollPane(label);
pane.setPreferredSize(new Dimension(120, 120));
final JFrame f = createFrame(pane);
-
JScrollBar verticalScrollBar = pane.getVerticalScrollBar();
- BasicScrollBarUI basicScrollBarUI = ((BasicScrollBarUI)verticalScrollBar.getUI());
- assertEquals(basicScrollBarUI.getPreferredSize(verticalScrollBar), basicScrollBarUI.preferredLayoutSize(verticalScrollBar));
-
+ BasicScrollBarUI basicScrollBarUI = ((BasicScrollBarUI) verticalScrollBar.getUI());
+ assertEquals(basicScrollBarUI.getPreferredSize(verticalScrollBar), basicScrollBarUI
+ .preferredLayoutSize(verticalScrollBar));
f.dispose();
}
@@ -126,16 +119,14 @@
final JScrollPane pane = new JScrollPane(label);
pane.setPreferredSize(new Dimension(120, 120));
final JFrame f = createFrame(pane);
-
JScrollBar verticalScrollBar = pane.getVerticalScrollBar();
- BasicScrollBarUI basicScrollBarUI = ((BasicScrollBarUI)verticalScrollBar.getUI());
+ BasicScrollBarUI basicScrollBarUI = ((BasicScrollBarUI) verticalScrollBar.getUI());
if (isHarmony()) {
checkIsCloseTo(17, basicScrollBarUI.getMinimumSize(bar).width);
checkIsCloseTo(45, basicScrollBarUI.getMinimumSize(bar).height);
} else {
assertEquals(new Dimension(15, 55), basicScrollBarUI.getMinimumSize(bar));
}
-
f.dispose();
}
@@ -147,11 +138,10 @@
final JScrollPane pane = new JScrollPane(label);
pane.setPreferredSize(new Dimension(120, 120));
final JFrame f = createFrame(pane);
-
JScrollBar verticalScrollBar = pane.getVerticalScrollBar();
- BasicScrollBarUI basicScrollBarUI = ((BasicScrollBarUI)verticalScrollBar.getUI());
- assertEquals(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE), basicScrollBarUI.getMaximumSize(bar));
-
+ BasicScrollBarUI basicScrollBarUI = ((BasicScrollBarUI) verticalScrollBar.getUI());
+ assertEquals(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE), basicScrollBarUI
+ .getMaximumSize(bar));
f.dispose();
}
@@ -175,11 +165,9 @@
final JScrollPane pane = new JScrollPane(label);
pane.setPreferredSize(new Dimension(120, 120));
final JFrame f = createFrame(pane);
-
JScrollBar verticalScrollBar = pane.getVerticalScrollBar();
- BasicScrollBarUI basicScrollBarUI = ((BasicScrollBarUI)verticalScrollBar.getUI());
+ BasicScrollBarUI basicScrollBarUI = ((BasicScrollBarUI) verticalScrollBar.getUI());
assertEquals(new Dimension(4096, 4096), basicScrollBarUI.getMaximumThumbSize());
-
f.dispose();
}
@@ -191,7 +179,8 @@
public void testCreatePropertyChangeListener() throws Exception {
assertNotNull(barUI.createPropertyChangeListener());
if (isHarmony()) {
- assertFalse(barUI.createPropertyChangeListener() == barUI.createPropertyChangeListener());
+ assertFalse(barUI.createPropertyChangeListener() == barUI
+ .createPropertyChangeListener());
}
}
@@ -209,12 +198,11 @@
assertEquals(2, barUI.incrButton.getMouseListeners().length);
assertEquals(1, bar.getMouseListeners().length);
assertEquals(1, bar.getPropertyChangeListeners().length);
- assertEquals(2, ((DefaultBoundedRangeModel)bar.getModel()).getChangeListeners().length);
-
+ assertEquals(2, ((DefaultBoundedRangeModel) bar.getModel()).getChangeListeners().length);
barUI.uninstallListeners();
assertEquals(0, bar.getMouseListeners().length);
assertEquals(0, bar.getPropertyChangeListeners().length);
- assertEquals(1, ((DefaultBoundedRangeModel)bar.getModel()).getChangeListeners().length);
+ assertEquals(1, ((DefaultBoundedRangeModel) bar.getModel()).getChangeListeners().length);
assertEquals(1, barUI.incrButton.getMouseListeners().length);
}
@@ -227,12 +215,9 @@
pane.setPreferredSize(new Dimension(120, 120));
final JFrame f = new JFrame();
f.getContentPane().add(pane);
-
JScrollBar verticalScrollBar = pane.getVerticalScrollBar();
- BasicScrollBarUI basicScrollBarUI = ((BasicScrollBarUI)verticalScrollBar.getUI());
-
+ BasicScrollBarUI basicScrollBarUI = ((BasicScrollBarUI) verticalScrollBar.getUI());
assertEquals(new Rectangle(0, 0, 0, 0), basicScrollBarUI.incrButton.getBounds());
-
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
f.pack();
@@ -240,12 +225,10 @@
}
});
SwingWaitTestCase.isRealized(f);
-
checkIsCloseTo(0, basicScrollBarUI.incrButton.getBounds().x);
checkIsCloseTo(85, basicScrollBarUI.incrButton.getBounds().y);
checkIsCloseTo(16, basicScrollBarUI.incrButton.getBounds().width);
checkIsCloseTo(16, basicScrollBarUI.incrButton.getBounds().height);
-
f.dispose();
}
@@ -263,6 +246,7 @@
}
private void checkIsCloseTo(final int expected, final int actual) {
- assertTrue("expected: " + expected + ", actual: " + actual, Math.abs(expected - actual) <= 2);
+ assertTrue("expected: " + expected + ", actual: " + actual,
+ Math.abs(expected - actual) <= 2);
}
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicScrollPaneUITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicScrollPaneUITest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicScrollPaneUITest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicScrollPaneUITest.java Sun Nov 26 12:15:43 2006
@@ -21,7 +21,6 @@
package javax.swing.plaf.basic;
import java.awt.Dimension;
-
import javax.swing.JScrollPane;
import javax.swing.SwingTestCase;
@@ -32,10 +31,12 @@
super(name);
}
+ @Override
protected void setUp() throws Exception {
ui = new BasicScrollPaneUI();
}
+ @Override
protected void tearDown() throws Exception {
ui = null;
}
@@ -43,7 +44,6 @@
public void testCreateUI() throws Exception {
assertTrue(BasicScrollPaneUI.createUI(null) instanceof BasicScrollPaneUI);
assertNotSame(BasicScrollPaneUI.createUI(null), BasicScrollPaneUI.createUI(null));
-
}
public void testCreateViewportChangeListener() throws Exception {
@@ -90,28 +90,25 @@
ui.scrollpane = new JScrollPane();
int viewportListenersCount = ui.scrollpane.getViewport().getChangeListeners().length;
assertNull(ui.viewportChangeListener);
-
int scrollPaneListenersCount = ui.scrollpane.getPropertyChangeListeners().length;
assertNull(ui.spPropertyChangeListener);
-
assertNull(ui.hsbChangeListener);
assertNull(ui.vsbChangeListener);
-
ui.installListeners(null);
- assertEquals(viewportListenersCount + 1, ui.scrollpane.getViewport().getChangeListeners().length);
+ assertEquals(viewportListenersCount + 1, ui.scrollpane.getViewport()
+ .getChangeListeners().length);
assertNotNull(ui.viewportChangeListener);
-
- assertEquals(scrollPaneListenersCount + 1, ui.scrollpane.getPropertyChangeListeners().length);
+ assertEquals(scrollPaneListenersCount + 1,
+ ui.scrollpane.getPropertyChangeListeners().length);
assertNotNull(ui.spPropertyChangeListener);
-
assertNotNull(ui.hsbChangeListener);
assertNotNull(ui.vsbChangeListener);
-
-
ui.uninstallListeners(null);
- assertEquals(viewportListenersCount, ui.scrollpane.getViewport().getChangeListeners().length);
+ assertEquals(viewportListenersCount,
+ ui.scrollpane.getViewport().getChangeListeners().length);
assertNull(ui.viewportChangeListener);
- assertEquals(scrollPaneListenersCount, ui.scrollpane.getPropertyChangeListeners().length);
+ assertEquals(scrollPaneListenersCount,
+ ui.scrollpane.getPropertyChangeListeners().length);
assertNull(ui.spPropertyChangeListener);
assertNull(ui.hsbChangeListener);
assertNull(ui.vsbChangeListener);
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicSeparatorUITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicSeparatorUITest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicSeparatorUITest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicSeparatorUITest.java Sun Nov 26 12:15:43 2006
@@ -15,13 +15,12 @@
* limitations under the License.
*/
/**
-* @author Alexander T. Simbirtsev
-* @version $Revision$
-*/
+ * @author Alexander T. Simbirtsev
+ * @version $Revision$
+ */
package javax.swing.plaf.basic;
import java.awt.Dimension;
-
import javax.swing.JButton;
import javax.swing.JSeparator;
import javax.swing.SwingConstants;
@@ -30,14 +29,15 @@
import javax.swing.plaf.ColorUIResource;
public class BasicSeparatorUITest extends SwingTestCase {
-
protected BasicSeparatorUI ui;
+ @Override
protected void setUp() throws Exception {
super.setUp();
ui = new BasicSeparatorUI();
}
+ @Override
protected void tearDown() throws Exception {
ui = null;
super.tearDown();
@@ -62,8 +62,10 @@
*/
public void testCreateUI() {
assertNotNull("created UI is not null", BasicSeparatorUI.createUI(new JButton()));
- assertTrue("created UI is of the proper class", BasicSeparatorUI.createUI(null) instanceof BasicSeparatorUI);
- assertNotSame("created UI is of unique", BasicSeparatorUI.createUI(null), BasicSeparatorUI.createUI(null));
+ assertTrue("created UI is of the proper class",
+ BasicSeparatorUI.createUI(null) instanceof BasicSeparatorUI);
+ assertNotSame("created UI is of unique", BasicSeparatorUI.createUI(null),
+ BasicSeparatorUI.createUI(null));
}
/*
@@ -72,11 +74,9 @@
public void testInstallUninstallDefaults() {
JSeparator separator = new JSeparator();
separator.setUI(ui);
-
ui.uninstallDefaults(separator);
assertNull(ui.highlight);
assertNull(ui.shadow);
-
UIManager.put("Separator.highlight", new ColorUIResource(1, 2, 3));
UIManager.put("Separator.shadow", new ColorUIResource(10, 20, 30));
UIManager.put("Separator.foreground", new ColorUIResource(11, 22, 33));
@@ -92,5 +92,4 @@
*/
public void testInstallUninstallListeners() {
}
-
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicSliderUITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicSliderUITest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicSliderUITest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicSliderUITest.java Sun Nov 26 12:15:43 2006
@@ -14,17 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
/**
* @author Sergey Burlak
* @version $Revision$
*/
-
package javax.swing.plaf.basic;
import java.awt.Point;
import java.util.Hashtable;
-
import javax.swing.JLabel;
import javax.swing.JSlider;
import javax.swing.SwingTestCase;
@@ -33,26 +30,37 @@
public class BasicSliderUITest extends SwingTestCase {
private BasicSliderUI sliderUI;
+
private JSlider slider;
+ @Override
protected void setUp() throws Exception {
super.setUp();
try {
UIManager.setLookAndFeel(new BasicLookAndFeel() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
public boolean isNativeLookAndFeel() {
return true;
}
+
+ @Override
public boolean isSupportedLookAndFeel() {
return true;
}
+
+ @Override
public String getDescription() {
return "";
}
+ @Override
public String getID() {
return "";
}
+ @Override
public String getName() {
return "";
}
@@ -64,6 +72,7 @@
sliderUI = new BasicSliderUI(slider);
}
+ @Override
protected void tearDown() throws Exception {
sliderUI = null;
slider = null;
@@ -77,27 +86,32 @@
public void testCreateTrackListener() throws Exception {
assertNotNull(sliderUI.createTrackListener(slider));
- assertFalse(sliderUI.createTrackListener(slider) == sliderUI.createTrackListener(slider));
+ assertFalse(sliderUI.createTrackListener(slider) == sliderUI
+ .createTrackListener(slider));
}
public void testCreateChangeListener() throws Exception {
assertNotNull(sliderUI.createChangeListener(slider));
- assertFalse(sliderUI.createChangeListener(slider) == sliderUI.createChangeListener(slider));
+ assertFalse(sliderUI.createChangeListener(slider) == sliderUI
+ .createChangeListener(slider));
}
public void testCreateComponentListener() throws Exception {
assertNotNull(sliderUI.createComponentListener(slider));
- assertFalse(sliderUI.createComponentListener(slider) == sliderUI.createComponentListener(slider));
+ assertFalse(sliderUI.createComponentListener(slider) == sliderUI
+ .createComponentListener(slider));
}
public void testCreateScrollListener() throws Exception {
assertNotNull(sliderUI.createScrollListener(slider));
- assertFalse(sliderUI.createScrollListener(slider) == sliderUI.createScrollListener(slider));
+ assertFalse(sliderUI.createScrollListener(slider) == sliderUI
+ .createScrollListener(slider));
}
public void testCreatePropertyChangeListener() throws Exception {
assertNotNull(sliderUI.createPropertyChangeListener(slider));
- assertFalse(sliderUI.createPropertyChangeListener(slider) == sliderUI.createPropertyChangeListener(slider));
+ assertFalse(sliderUI.createPropertyChangeListener(slider) == sliderUI
+ .createPropertyChangeListener(slider));
}
public void testGetShadowColor() throws Exception {
@@ -120,99 +134,83 @@
public void testGetLowestValueLabel() throws Exception {
sliderUI.installUI(slider);
-
slider.setLabelTable(slider.createStandardLabels(1));
- assertEquals("0", ((JLabel)sliderUI.getLowestValueLabel()).getText());
-
+ assertEquals("0", ((JLabel) sliderUI.getLowestValueLabel()).getText());
slider.setLabelTable(slider.createStandardLabels(2, 57));
- assertEquals("57", ((JLabel)sliderUI.getLowestValueLabel()).getText());
+ assertEquals("57", ((JLabel) sliderUI.getLowestValueLabel()).getText());
}
public void testGetHighestValueLabel() throws Exception {
sliderUI.installUI(slider);
-
slider.setLabelTable(slider.createStandardLabels(1));
- assertEquals("100", ((JLabel)sliderUI.getHighestValueLabel()).getText());
-
+ assertEquals("100", ((JLabel) sliderUI.getHighestValueLabel()).getText());
slider.setLabelTable(slider.createStandardLabels(2, 56));
- assertEquals("100", ((JLabel)sliderUI.getHighestValueLabel()).getText());
+ assertEquals("100", ((JLabel) sliderUI.getHighestValueLabel()).getText());
}
public void testGetWidthOfHighValueLabel() throws Exception {
sliderUI.installUI(slider);
-
- Hashtable t = new Hashtable();
+ Hashtable<Integer, JLabel> t = new Hashtable<Integer, JLabel>();
t.put(new Integer("1"), new JLabel("1"));
t.put(new Integer("100"), new JLabel("100"));
JLabel label = new JLabel("1000000");
t.put(new Integer("1000000"), label);
-
slider.setLabelTable(t);
assertEquals(label.getWidth(), sliderUI.getWidthOfHighValueLabel());
}
public void testGetWidthOfLowValueLabel() throws Exception {
sliderUI.installUI(slider);
-
- Hashtable t = new Hashtable();
+ Hashtable<Integer, JLabel> t = new Hashtable<Integer, JLabel>();
JLabel label = new JLabel("1");
t.put(new Integer("1"), label);
t.put(new Integer("100"), new JLabel("100"));
t.put(new Integer("1000000"), new JLabel("1000000"));
-
slider.setLabelTable(t);
assertEquals(label.getWidth(), sliderUI.getWidthOfLowValueLabel());
}
public void testGetHightOfHighValueLabel() throws Exception {
sliderUI.installUI(slider);
-
- Hashtable t = new Hashtable();
+ Hashtable<Integer, JLabel> t = new Hashtable<Integer, JLabel>();
t.put(new Integer("1"), new JLabel("1"));
t.put(new Integer("100"), new JLabel("100"));
JLabel label = new JLabel("1000000");
t.put(new Integer("1000000"), label);
-
slider.setLabelTable(t);
assertEquals(label.getHeight(), sliderUI.getHeightOfHighValueLabel());
}
public void testGetHeightOfLowValueLabel() throws Exception {
sliderUI.installUI(slider);
-
- Hashtable t = new Hashtable();
+ Hashtable<Integer, JLabel> t = new Hashtable<Integer, JLabel>();
JLabel label = new JLabel("1");
t.put(new Integer("1"), label);
t.put(new Integer("100"), new JLabel("100"));
t.put(new Integer("1000000"), new JLabel("1000000"));
-
slider.setLabelTable(t);
assertEquals(label.getHeight(), sliderUI.getHeightOfLowValueLabel());
}
public void testGetWidthOfWidestLabel() throws Exception {
sliderUI.installUI(slider);
-
- Hashtable t = new Hashtable();
+ Hashtable<Integer, JLabel> t = new Hashtable<Integer, JLabel>();
t.put(new Integer("1"), new JLabel("1"));
JLabel label = new JLabel("___________100");
t.put(new Integer("100"), label);
t.put(new Integer("1000000"), new JLabel("1000000"));
-
slider.setLabelTable(t);
assertEquals(label.getWidth(), sliderUI.getWidthOfWidestLabel());
}
public void testGetHeightOfTallestLabel() throws Exception {
sliderUI.installUI(slider);
-
- Hashtable t = new Hashtable();
+ Hashtable<Integer, JLabel> t = new Hashtable<Integer, JLabel>();
JLabel label = new JLabel("1");
label.setFont(label.getFont().deriveFont(50f));
t.put(new Integer("1"), label);
t.put(new Integer("100"), new JLabel("100"));
t.put(new Integer("1000000"), new JLabel("1000000"));
-
slider.setLabelTable(t);
assertEquals(label.getHeight(), sliderUI.getHeightOfTallestLabel());
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicSpinnerUITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicSpinnerUITest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicSpinnerUITest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicSpinnerUITest.java Sun Nov 26 12:15:43 2006
@@ -22,20 +22,23 @@
import java.awt.Component;
import java.util.Arrays;
-
import javax.swing.BasicSwingTestCase;
import javax.swing.JSpinner;
+import javax.swing.SwingConstants;
public class BasicSpinnerUITest extends BasicSwingTestCase {
private BasicSpinnerUI ui;
+
private JSpinner spinner;
+ @Override
public void setUp() {
spinner = new JSpinner();
spinner.getUI().uninstallUI(spinner);
ui = new BasicSpinnerUI();
}
+ @Override
public void tearDown() {
spinner = null;
ui = null;
@@ -55,18 +58,17 @@
public void testCreatePreviousNextButton() {
Component nextButton = ui.createNextButton();
assertTrue(nextButton instanceof BasicArrowButton);
- assertEquals(((BasicArrowButton)nextButton).getDirection(), BasicArrowButton.NORTH);
- assertTrue(((BasicArrowButton)nextButton).getActionListeners().length > 0);
- assertTrue(((BasicArrowButton)nextButton).getMouseListeners().length > 1);
- assertTrue(((BasicArrowButton)nextButton).getFocusListeners().length > 1);
+ assertEquals(((BasicArrowButton) nextButton).getDirection(), SwingConstants.NORTH);
+ assertTrue(((BasicArrowButton) nextButton).getActionListeners().length > 0);
+ assertTrue(((BasicArrowButton) nextButton).getMouseListeners().length > 1);
+ assertTrue(((BasicArrowButton) nextButton).getFocusListeners().length > 1);
assertNotSame(nextButton, ui.createNextButton());
-
Component previousButton = ui.createPreviousButton();
assertTrue(previousButton instanceof BasicArrowButton);
- assertEquals(((BasicArrowButton)previousButton).getDirection(), BasicArrowButton.SOUTH);
- assertTrue(((BasicArrowButton)previousButton).getActionListeners().length > 0);
- assertTrue(((BasicArrowButton)previousButton).getMouseListeners().length > 1);
- assertTrue(((BasicArrowButton)previousButton).getFocusListeners().length > 1);
+ assertEquals(((BasicArrowButton) previousButton).getDirection(), SwingConstants.SOUTH);
+ assertTrue(((BasicArrowButton) previousButton).getActionListeners().length > 0);
+ assertTrue(((BasicArrowButton) previousButton).getMouseListeners().length > 1);
+ assertTrue(((BasicArrowButton) previousButton).getFocusListeners().length > 1);
assertNotSame(previousButton, ui.createPreviousButton());
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicSplitPaneDividerTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicSplitPaneDividerTest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicSplitPaneDividerTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicSplitPaneDividerTest.java Sun Nov 26 12:15:43 2006
@@ -22,9 +22,7 @@
import java.awt.Dimension;
import java.awt.Insets;
-import java.beans.PropertyChangeEvent;
import java.lang.reflect.Field;
-
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JSplitPane;
@@ -33,17 +31,20 @@
public class BasicSplitPaneDividerTest extends SwingTestCase {
private BasicSplitPaneDivider divider;
+
private JSplitPane pane;
public BasicSplitPaneDividerTest(final String name) {
super(name);
}
+ @Override
protected void setUp() throws Exception {
pane = new JSplitPane();
- divider = new BasicSplitPaneDivider((BasicSplitPaneUI)pane.getUI());
+ divider = new BasicSplitPaneDivider((BasicSplitPaneUI) pane.getUI());
}
+ @Override
protected void tearDown() throws Exception {
divider = null;
pane = null;
@@ -53,7 +54,6 @@
assertEquals(pane.getUI(), divider.splitPaneUI);
assertEquals(pane, divider.splitPane);
assertNotNull(divider.mouseHandler);
-
assertNull(divider.leftButton);
assertNull(divider.rightButton);
assertNull(divider.dragger);
@@ -65,8 +65,7 @@
public void testGetSetBasicSplitPaneUI() throws Exception {
JSplitPane newPane = new JSplitPane();
- divider.setBasicSplitPaneUI((BasicSplitPaneUI)newPane.getUI());
-
+ divider.setBasicSplitPaneUI((BasicSplitPaneUI) newPane.getUI());
assertEquals(newPane.getUI(), divider.splitPaneUI);
assertEquals(newPane.getUI(), divider.getBasicSplitPaneUI());
assertEquals(newPane, divider.splitPane);
@@ -107,7 +106,6 @@
assertEquals(new Dimension(20, 1), divider.getPreferredSize());
assertEquals(new Dimension(20, 1), divider.getMinimumSize());
assertEquals(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE), divider.getMaximumSize());
-
divider.orientation = JSplitPane.VERTICAL_SPLIT;
assertEquals(new Dimension(1, 20), divider.getPreferredSize());
assertEquals(new Dimension(1, 20), divider.getMinimumSize());
@@ -122,7 +120,6 @@
assertFalse(pane.isOneTouchExpandable());
assertNull(divider.leftButton);
assertNull(divider.rightButton);
-
setProperty("oneTouchExpandable", Boolean.TRUE);
divider.oneTouchExpandableChanged();
assertNotNull(divider.leftButton);
@@ -132,19 +129,14 @@
public void testCreateLeftOneTouchButton() throws Exception {
JButton left = divider.createLeftOneTouchButton();
assertNotNull(left);
-
assertNotSame(left, divider.createLeftOneTouchButton());
}
public void testCreateRightOneTouchButton() throws Exception {
JButton right = divider.createRightOneTouchButton();
assertNotNull(right);
-
assertNotSame(right, divider.createRightOneTouchButton());
}
-
-
-
private void setProperty(final String propertyName, final Object value) throws Exception {
Field property = JSplitPane.class.getDeclaredField(propertyName);
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicSplitPaneUITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicSplitPaneUITest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicSplitPaneUITest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicSplitPaneUITest.java Sun Nov 26 12:15:43 2006
@@ -14,12 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
/**
* @author Sergey Burlak
* @version $Revision$
*/
-
package javax.swing.plaf.basic;
import java.awt.Canvas;
@@ -27,7 +25,6 @@
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.Rectangle;
-
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JSplitPane;
@@ -36,16 +33,18 @@
public class BasicSplitPaneUITest extends SwingTestCase {
private JSplitPane splitPane;
+
private BasicSplitPaneUI ui;
+ @Override
protected void setUp() throws Exception {
splitPane = new JSplitPane();
ui = new BasicSplitPaneUI();
splitPane.setUI(ui);
-
splitPane.setSize(new Dimension(2000, 1000));
}
+ @Override
protected void tearDown() throws Exception {
splitPane = null;
ui = null;
@@ -54,15 +53,14 @@
public void testPreferredLayoutSize() throws Exception {
splitPane.setBorder(BorderFactory.createEmptyBorder(5, 6, 7, 8));
ui.layoutManager.layoutContainer(splitPane);
-
int width = splitPane.getInsets().left + splitPane.getInsets().right
- + ui.layoutManager.components[0].getPreferredSize().width
- + ui.layoutManager.components[1].getPreferredSize().width
- + ui.layoutManager.components[2].getPreferredSize().width;
+ + ui.layoutManager.components[0].getPreferredSize().width
+ + ui.layoutManager.components[1].getPreferredSize().width
+ + ui.layoutManager.components[2].getPreferredSize().width;
int height = splitPane.getInsets().top + splitPane.getInsets().bottom
- + ui.layoutManager.components[0].getPreferredSize().height;
- assertEquals(new Dimension(width, height), ui.layoutManager.preferredLayoutSize(splitPane));
-
+ + ui.layoutManager.components[0].getPreferredSize().height;
+ assertEquals(new Dimension(width, height), ui.layoutManager
+ .preferredLayoutSize(splitPane));
splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
width = splitPane.getInsets().left + splitPane.getInsets().right
+ ui.layoutManager.components[1].getPreferredSize().width;
@@ -70,21 +68,21 @@
+ ui.layoutManager.components[0].getPreferredSize().height
+ ui.layoutManager.components[1].getPreferredSize().height
+ ui.layoutManager.components[2].getPreferredSize().height;
- assertEquals(new Dimension(width, height), ui.layoutManager.preferredLayoutSize(splitPane));
+ assertEquals(new Dimension(width, height), ui.layoutManager
+ .preferredLayoutSize(splitPane));
}
public void testMinLayoutSize() throws Exception {
splitPane.setBorder(BorderFactory.createEmptyBorder(5, 6, 7, 8));
ui.layoutManager.layoutContainer(splitPane);
-
int width = splitPane.getInsets().left + splitPane.getInsets().right
- + ui.layoutManager.components[0].getMinimumSize().width
- + ui.layoutManager.components[1].getMinimumSize().width
- + ui.layoutManager.components[2].getMinimumSize().width;
+ + ui.layoutManager.components[0].getMinimumSize().width
+ + ui.layoutManager.components[1].getMinimumSize().width
+ + ui.layoutManager.components[2].getMinimumSize().width;
int height = splitPane.getInsets().top + splitPane.getInsets().bottom
- + ui.layoutManager.components[0].getMinimumSize().height;
- assertEquals(new Dimension(width, height), ui.layoutManager.minimumLayoutSize(splitPane));
-
+ + ui.layoutManager.components[0].getMinimumSize().height;
+ assertEquals(new Dimension(width, height), ui.layoutManager
+ .minimumLayoutSize(splitPane));
splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
width = splitPane.getInsets().left + splitPane.getInsets().right
+ ui.layoutManager.components[1].getMinimumSize().width;
@@ -92,12 +90,14 @@
+ ui.layoutManager.components[0].getMinimumSize().height
+ ui.layoutManager.components[1].getMinimumSize().height
+ ui.layoutManager.components[2].getMinimumSize().height;
- assertEquals(new Dimension(width, height), ui.layoutManager.minimumLayoutSize(splitPane));
+ assertEquals(new Dimension(width, height), ui.layoutManager
+ .minimumLayoutSize(splitPane));
}
public void testCreateUI() throws Exception {
assertNotNull(BasicSplitPaneUI.createUI(splitPane));
- assertFalse(BasicSplitPaneUI.createUI(splitPane) == BasicSplitPaneUI.createUI(splitPane));
+ assertFalse(BasicSplitPaneUI.createUI(splitPane) == BasicSplitPaneUI
+ .createUI(splitPane));
}
public void testCreatePropertyHandler() throws Exception {
@@ -117,17 +117,13 @@
public void testSetOrientation() throws Exception {
propertyChangeController = new PropertyChangeController();
splitPane.addPropertyChangeListener(propertyChangeController);
- ui = (BasicSplitPaneUI)splitPane.getUI();
-
+ ui = (BasicSplitPaneUI) splitPane.getUI();
assertEquals(JSplitPane.HORIZONTAL_SPLIT, splitPane.getOrientation());
assertEquals(JSplitPane.HORIZONTAL_SPLIT, ui.getOrientation());
-
ui.setOrientation(JSplitPane.VERTICAL_SPLIT);
-
assertEquals(JSplitPane.VERTICAL_SPLIT, ui.getOrientation());
assertFalse(JSplitPane.VERTICAL_SPLIT == splitPane.getOrientation());
ui.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
-
propertyChangeController.reset();
splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
assertTrue(propertyChangeController.isChanged("orientation"));
@@ -140,16 +136,12 @@
splitPane.addPropertyChangeListener(propertyChangeController);
assertFalse(splitPane.isContinuousLayout());
assertFalse(ui.isContinuousLayout());
-
ui.setContinuousLayout(true);
-
assertTrue(ui.isContinuousLayout());
assertFalse(splitPane.isContinuousLayout());
-
ui.setContinuousLayout(false);
assertFalse(ui.isContinuousLayout());
assertFalse(splitPane.isContinuousLayout());
-
propertyChangeController.reset();
splitPane.setContinuousLayout(true);
assertTrue(propertyChangeController.isChanged("continuousLayout"));
@@ -179,18 +171,18 @@
}
public void testCreateDefaultDivider() throws Exception {
- assertTrue(ui.createDefaultDivider() instanceof BasicSplitPaneDivider);
+ assertNotNull(ui.createDefaultDivider());
}
public void testSetNonContinuousLayoutDivider() throws Exception {
- Component component = new Component() {};
+ Component component = new Component() {
+ private static final long serialVersionUID = 1L;
+ };
ui.setNonContinuousLayoutDivider(component);
assertTrue(component == ui.getNonContinuousLayoutDivider());
-
assertFalse(ui.layoutManager.components[0] == component);
assertFalse(ui.layoutManager.components[1] == component);
assertFalse(ui.layoutManager.components[2] == component);
-
assertTrue(ui.nonContinuousLayoutDivider == component);
}
@@ -201,34 +193,27 @@
assertFalse(ui.layoutManager.components[0] == viewport);
assertTrue(ui.layoutManager.components[1] == viewport);
assertFalse(ui.layoutManager.components[2] == viewport);
-
ui.layoutManager.addLayoutComponent(JSplitPane.BOTTOM, new JButton());
assertFalse(ui.layoutManager.components[1] == viewport);
-
ui.layoutManager.addLayoutComponent(JSplitPane.RIGHT, viewport);
assertFalse(ui.layoutManager.components[0] == viewport);
assertTrue(ui.layoutManager.components[1] == viewport);
assertFalse(ui.layoutManager.components[2] == viewport);
ui.layoutManager.addLayoutComponent(JSplitPane.BOTTOM, new JButton());
-
ui.layoutManager.addLayoutComponent(JSplitPane.TOP, viewport);
assertTrue(ui.layoutManager.components[0] == viewport);
assertFalse(ui.layoutManager.components[1] == viewport);
assertFalse(ui.layoutManager.components[2] == viewport);
-
ui.layoutManager.addLayoutComponent(JSplitPane.TOP, new JButton());
assertFalse(ui.layoutManager.components[0] == viewport);
-
ui.layoutManager.addLayoutComponent(JSplitPane.LEFT, viewport);
assertTrue(ui.layoutManager.components[0] == viewport);
assertFalse(ui.layoutManager.components[1] == viewport);
assertFalse(ui.layoutManager.components[2] == viewport);
-
ui.layoutManager.removeLayoutComponent(new JButton());
assertNotNull(ui.layoutManager.components[0]);
assertNotNull(ui.layoutManager.components[1]);
assertNotNull(ui.layoutManager.components[2]);
-
ui.layoutManager.removeLayoutComponent(ui.layoutManager.components[2]);
assertNotNull(ui.layoutManager.components[0]);
assertNotNull(ui.layoutManager.components[1]);
@@ -241,7 +226,6 @@
assertNull(ui.layoutManager.components[0]);
assertNull(ui.layoutManager.components[1]);
assertNull(ui.layoutManager.components[2]);
-
try {
ui.layoutManager.addLayoutComponent("a", viewport);
fail("IllegalArgumentException should be thrown");
@@ -250,54 +234,57 @@
}
public void testGetComponentPreferredSize() throws Exception {
- assertEquals(ui.layoutManager.components[0].getPreferredSize().width, ui.layoutManager.getPreferredSizeOfComponent(ui.layoutManager.components[0]));
+ assertEquals(ui.layoutManager.components[0].getPreferredSize().width, ui.layoutManager
+ .getPreferredSizeOfComponent(ui.layoutManager.components[0]));
splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
- assertEquals(ui.layoutManager.components[0].getPreferredSize().height, ui.layoutManager.getPreferredSizeOfComponent(ui.layoutManager.components[0]));
+ assertEquals(ui.layoutManager.components[0].getPreferredSize().height, ui.layoutManager
+ .getPreferredSizeOfComponent(ui.layoutManager.components[0]));
}
public void testGetComponentSize() throws Exception {
ui.layoutManager.layoutContainer(splitPane);
- assertEquals(ui.layoutManager.components[0].getSize().width, ui.layoutManager.getSizeOfComponent(ui.layoutManager.components[0]));
+ assertEquals(ui.layoutManager.components[0].getSize().width, ui.layoutManager
+ .getSizeOfComponent(ui.layoutManager.components[0]));
splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
- assertEquals(ui.layoutManager.components[0].getSize().height, ui.layoutManager.getSizeOfComponent(ui.layoutManager.components[0]));
+ assertEquals(ui.layoutManager.components[0].getSize().height, ui.layoutManager
+ .getSizeOfComponent(ui.layoutManager.components[0]));
}
public void testGetAvailableSize() throws Exception {
splitPane.setSize(1000, 2000);
splitPane.setBorder(BorderFactory.createEmptyBorder(5, 10, 15, 20));
-
- assertEquals(splitPane.getSize().width - 10 - 20, ui.layoutManager.getAvailableSize(splitPane.getSize(), splitPane.getInsets()));
-
+ assertEquals(splitPane.getSize().width - 10 - 20, ui.layoutManager.getAvailableSize(
+ splitPane.getSize(), splitPane.getInsets()));
splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
- assertEquals(splitPane.getSize().height - 5 - 15, ui.layoutManager.getAvailableSize(splitPane.getSize(), splitPane.getInsets()));
+ assertEquals(splitPane.getSize().height - 5 - 15, ui.layoutManager.getAvailableSize(
+ splitPane.getSize(), splitPane.getInsets()));
}
public void testResetPreferredSizes() throws Exception {
if (isHarmony()) {
assertEquals(0, ui.getDividerLocation(splitPane));
ui.resetToPreferredSizes(splitPane);
- assertEquals(splitPane.getLeftComponent().getPreferredSize().width, ui.getDividerLocation(splitPane));
+ assertEquals(splitPane.getLeftComponent().getPreferredSize().width, ui
+ .getDividerLocation(splitPane));
}
}
public void testMinMaxDividerLocation() throws Exception {
splitPane.setBorder(BorderFactory.createEmptyBorder(5, 10, 15, 20));
- assertEquals(splitPane.getLeftComponent().getPreferredSize().width + splitPane.getInsets().left, ui.getMinimumDividerLocation(splitPane));
- assertEquals(splitPane.getWidth() - splitPane.getDividerSize() - splitPane.getRightComponent().getMinimumSize().width
- - splitPane.getInsets().right, ui.getMaximumDividerLocation(splitPane));
+ assertEquals(splitPane.getLeftComponent().getPreferredSize().width
+ + splitPane.getInsets().left, ui.getMinimumDividerLocation(splitPane));
+ assertEquals(splitPane.getWidth() - splitPane.getDividerSize()
+ - splitPane.getRightComponent().getMinimumSize().width
+ - splitPane.getInsets().right, ui.getMaximumDividerLocation(splitPane));
}
public void testSetDividerLocation() throws Exception {
ui.setDividerLocation(splitPane, 230);
-
assertEquals(-1, splitPane.getDividerLocation());
assertEquals(0, ui.getDividerLocation(splitPane));
-
splitPane.setDividerLocation(20);
-
assertEquals(20, splitPane.getDividerLocation());
assertEquals(0, ui.getDividerLocation(splitPane));
-
ui.layoutManager.layoutContainer(splitPane);
assertEquals(20, ui.getDividerLocation(splitPane));
}
@@ -305,18 +292,17 @@
public void testInitialLocation() throws Exception {
splitPane.setSize(1000, 2000);
splitPane.setBorder(BorderFactory.createEmptyBorder(5, 10, 15, 20));
- assertEquals(splitPane.getInsets().left, ui.layoutManager.getInitialLocation(splitPane.getInsets()));
-
+ assertEquals(splitPane.getInsets().left, ui.layoutManager.getInitialLocation(splitPane
+ .getInsets()));
splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
-
- assertEquals(splitPane.getInsets().top, ui.layoutManager.getInitialLocation(splitPane.getInsets()));
+ assertEquals(splitPane.getInsets().top, ui.layoutManager.getInitialLocation(splitPane
+ .getInsets()));
}
public void testUpdateComponents() throws Exception {
ui.layoutManager.components[0] = null;
ui.layoutManager.components[1] = null;
ui.layoutManager.components[2] = null;
-
ui.layoutManager.updateComponents();
assertEquals(splitPane.getLeftComponent(), ui.layoutManager.components[0]);
assertEquals(splitPane.getRightComponent(), ui.layoutManager.components[1]);
@@ -326,18 +312,19 @@
public void testSetComponentToSize() throws Exception {
JButton b = new JButton();
b.setSize(new Dimension(20, 30));
-
int size = 5;
int location = 15;
int cW = 50;
int cH = 40;
Insets insets = new Insets(1, 2, 3, 4);
ui.layoutManager.setComponentToSize(b, size, location, insets, new Dimension(cW, cH));
- assertEquals(new Rectangle(location, insets.top, size, cH - insets.top - insets.bottom), b.getBounds());
-
+ assertEquals(
+ new Rectangle(location, insets.top, size, cH - insets.top - insets.bottom), b
+ .getBounds());
splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
-
ui.layoutManager.setComponentToSize(b, size, location, insets, new Dimension(cW, cH));
- assertEquals(new Rectangle(insets.left, location, cW - insets.left - insets.right, size), b.getBounds());
+ assertEquals(
+ new Rectangle(insets.left, location, cW - insets.left - insets.right, size), b
+ .getBounds());
}
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicTabbedPaneUI$TabbedPaneLayoutTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicTabbedPaneUI%24TabbedPaneLayoutTest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicTabbedPaneUI$TabbedPaneLayoutTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicTabbedPaneUI$TabbedPaneLayoutTest.java Sun Nov 26 12:15:43 2006
@@ -21,35 +21,35 @@
package javax.swing.plaf.basic;
import java.awt.Dimension;
-
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JTabbedPane;
+import javax.swing.SwingConstants;
import javax.swing.SwingTestCase;
-
public class BasicTabbedPaneUI$TabbedPaneLayoutTest extends SwingTestCase {
-
private JTabbedPane tabbed;
+
private BasicTabbedPaneUI ui;
+
private BasicTabbedPaneUI.TabbedPaneLayout layout;
+
private Dimension emptySize = new Dimension();
+ @Override
protected void setUp() throws Exception {
super.setUp();
-
tabbed = new JTabbedPane();
ui = new BasicTabbedPaneUI();
tabbed.setUI(ui);
- layout = (BasicTabbedPaneUI.TabbedPaneLayout)tabbed.getLayout();
-
+ layout = (BasicTabbedPaneUI.TabbedPaneLayout) tabbed.getLayout();
tabbed.addTab("tab1", new JLabel());
tabbed.setIconAt(0, new ImageIcon());
tabbed.setDisabledIconAt(0, new ImageIcon());
-
tabbed.addTab("tabtab2", new JLabel());
}
+ @Override
protected void tearDown() throws Exception {
super.tearDown();
}
@@ -75,7 +75,7 @@
}
public void testPadSelectedTab() {
- layout.padSelectedTab(JTabbedPane.TOP, -1);
+ layout.padSelectedTab(SwingConstants.TOP, -1);
}
public void testRotateTabRuns() {
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicTabbedPaneUIRTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicTabbedPaneUIRTest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicTabbedPaneUIRTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicTabbedPaneUIRTest.java Sun Nov 26 12:15:43 2006
@@ -21,27 +21,28 @@
package javax.swing.plaf.basic;
import java.awt.Dimension;
-
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.SwingTestCase;
public class BasicTabbedPaneUIRTest extends SwingTestCase {
JTabbedPane tp;
+
BasicTabbedPaneUI ui;
public BasicTabbedPaneUIRTest(final String name) {
super(name);
-
tp = new JTabbedPane();
ui = new BasicTabbedPaneUI();
tp.setUI(ui);
}
+ @Override
protected void setUp() throws Exception {
super.setUp();
}
+ @Override
protected void tearDown() throws Exception {
super.tearDown();
}
@@ -50,17 +51,14 @@
JPanel tabContent1 = new JPanel();
tabContent1.setPreferredSize(new Dimension(300, 300));
tabContent1.setMinimumSize(new Dimension(200, 200));
-
JPanel tabContent2 = new JPanel();
tabContent2.setPreferredSize(new Dimension(500, 200));
tabContent2.setMinimumSize(new Dimension(400, 100));
-
tp.addTab("tab1", tabContent1);
tp.addTab("tab2", tabContent2);
Dimension size = tp.getPreferredSize();
assertTrue(size.width > 500);
assertTrue(size.height > 300);
-
size = tp.getMinimumSize();
assertTrue(size.width > 400);
assertTrue(size.height > 200);