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 [11/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/ j...
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicTextUITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicTextUITest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicTextUITest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicTextUITest.java Sun Nov 26 12:15:43 2006
@@ -29,7 +29,6 @@
import java.awt.Rectangle;
import java.awt.event.InputEvent;
import java.beans.PropertyChangeEvent;
-
import javax.swing.ActionMap;
import javax.swing.InputMap;
import javax.swing.JComponent;
@@ -68,139 +67,135 @@
import javax.swing.text.View;
public class BasicTextUITest extends SwingTestCase {
- MyBasicTextUI basicTextUI;
+ MyBasicTextUI basicTextUI;
- JTextField tf;
+ JTextField tf;
- JExtTextArea jta;
+ JExtTextArea jta;
- JFrame jf;
+ JFrame jf;
- String s;
+ String s;
- final Dimension PREF_SIZE = new Dimension(184, 20);
+ final Dimension PREF_SIZE = new Dimension(184, 20);
- Position.Bias forward = Position.Bias.Forward;
+ Position.Bias forward = Position.Bias.Forward;
- Position.Bias backward = Position.Bias.Backward;
+ Position.Bias backward = Position.Bias.Backward;
- private View view;
+ private View view;
- boolean wasCallInvalidate = false;
+ boolean wasCallInvalidate = false;
- final ColorUIResource RED = new ColorUIResource(255, 0, 0);
+ final ColorUIResource RED = new ColorUIResource(255, 0, 0);
- final ColorUIResource BLUE = new ColorUIResource(0, 0, 255);
+ final ColorUIResource BLUE = new ColorUIResource(0, 0, 255);
- final ColorUIResource GREEN = new ColorUIResource(0, 255, 255);
+ final ColorUIResource GREEN = new ColorUIResource(0, 255, 255);
- final ColorUIResource YELLOW = new ColorUIResource(255, 255, 0);
+ final ColorUIResource YELLOW = new ColorUIResource(255, 255, 0);
- final ColorUIResource BLACK = new ColorUIResource(0, 0, 0);
+ final ColorUIResource BLACK = new ColorUIResource(0, 0, 0);
- final Font FONT = new Font("SimSun", 8, 8);
+ final Font FONT = new Font("SimSun", 8, 8);
- boolean bWasException;
+ boolean bWasException;
class MyBasicTextUI extends BasicTextUI {
+ @Override
protected String getPropertyPrefix() {
return null;
}
+ @Override
protected void installDefaults() {
super.installDefaults();
}
+ @Override
protected void installKeyboardActions() {
super.installKeyboardActions();
}
+ @Override
protected void installListeners() {
super.installListeners();
}
+ @Override
public void installUI(final JComponent c) {
super.installUI(c);
}
+ @Override
protected void propertyChange(final PropertyChangeEvent e) {
-
super.propertyChange(e);
}
-
}
class JExtTextArea extends JTextArea {
+ private static final long serialVersionUID = 1L;
+
public boolean wasCallInvalidate = false;
JExtTextArea(final String s) {
super(s);
}
+ @Override
public void invalidate() {
wasCallInvalidate = true;
super.invalidate();
}
}
+ @Override
protected void setUp() throws Exception {
super.setUp();
bWasException = false;
s = null;
basicTextUI = new MyBasicTextUI();
tf = new JTextField("JTextField\n JTextField \n JTextField");
-
UIManager.put("TextAreaUI", "javax.swing.plaf.basic.TextAreaUI");
jf = new JFrame();
jta = new JExtTextArea("");
//jta.setText(sLTR + sRTL + sLTR + "\n" + sLTR + sRTL + sLTR + "\n"
// + sLTR + sRTL + sLTR + "\n" + "JTextArea \n JTextArea\n"
// + "\u05dc");
- jta.setText("aaa" + "\n" + "bbb" + "\n"
- + "ccc" + "\n" + "JTextArea \n JTextArea\n"
- + "e");
-
+ jta.setText("aaa" + "\n" + "bbb" + "\n" + "ccc" + "\n" + "JTextArea \n JTextArea\n"
+ + "e");
jf.getContentPane().add(jta);
jf.setSize(200, 300);
-
jf.pack();
}
+ @Override
protected void tearDown() throws Exception {
jf.dispose();
UIManager.put("TextAreaUI", "javax.swing.plaf.basic.BasicTextAreaUI");
super.tearDown();
-
}
public void testBasicTextUI() {
}
private void getPos(final BasicTextUI ui, final int start, final Position.Bias bias,
- final int direction, final int samplePos, final Position.Bias sample,
- final boolean cond) {
-
+ final int direction, final int samplePos, final Position.Bias sample,
+ final boolean cond) {
int p = 0;
Position.Bias b[] = new Position.Bias[1];
try {
p = ui.getNextVisualPositionFrom(jta, start, bias, direction, b);
} catch (BadLocationException e) {
}
-
assertEquals(samplePos, p);
-
}
public void testGetNextVisualPosition() throws Exception {
-
- BasicTextUI ui = (BasicTextUI)jta.getUI();
- int pos;
- Position.Bias bias[] = new Position.Bias[1];
-
+ BasicTextUI ui = (BasicTextUI) jta.getUI();
try {
ui.getNextVisualPositionFrom(jta, 5, Position.Bias.Forward,
- SwingConstants.SOUTH_WEST,
- new Position.Bias[1]);
+ SwingConstants.SOUTH_WEST, new Position.Bias[1]);
} catch (IllegalArgumentException e) {
bWasException = true;
s = e.getMessage();
@@ -209,25 +204,22 @@
if (isHarmony()) {
assertTrue(bWasException);
assertEquals("Invalid direction", s);
-
- getPos(ui, 6, forward, SwingConstants.WEST, 5, forward, true);
- //This tests depends on MagicCaretPosition (timer)
- //getPos(ui, 6, forward, SwingConstants.NORTH, 0, forward);
- //getPos(ui, 6, forward, SwingConstants.SOUTH, 8, forward);
- getPos(ui, 6, forward, SwingConstants.EAST, 7, forward, false);
-
- getPos(ui, 6, backward, SwingConstants.WEST, 5, backward, true);
- //This tests depends on MagicCaretPosition (timer)
- //getPos(ui, 4, backward, SwingConstants.NORTH, 4, backward); //?? 6
- //getPos(ui, 36, backward, SwingConstants.SOUTH, 36, backward); //?? 6
- getPos(ui, 6, backward, SwingConstants.EAST, 7, forward, true);
+ getPos(ui, 6, forward, SwingConstants.WEST, 5, forward, true);
+ //This tests depends on MagicCaretPosition (timer)
+ //getPos(ui, 6, forward, SwingConstants.NORTH, 0, forward);
+ //getPos(ui, 6, forward, SwingConstants.SOUTH, 8, forward);
+ getPos(ui, 6, forward, SwingConstants.EAST, 7, forward, false);
+ getPos(ui, 6, backward, SwingConstants.WEST, 5, backward, true);
+ //This tests depends on MagicCaretPosition (timer)
+ //getPos(ui, 4, backward, SwingConstants.NORTH, 4, backward); //?? 6
+ //getPos(ui, 36, backward, SwingConstants.SOUTH, 36, backward); //?? 6
+ getPos(ui, 6, backward, SwingConstants.EAST, 7, forward, true);
}
}
public void testGetToolTipTextJTextComponentPoint() {
- BasicTextUI ui = getBasicTextUI(jta);
Point p = new Point(0, 0);
- for (int i = 0; i < 200; i++)
+ for (int i = 0; i < 200; i++) {
for (int j = 0; j < 200; j++) {
p.x = i;
p.y = j;
@@ -235,12 +227,12 @@
assertNull(getBasicTextUI(jta).getToolTipText(null, p));
assertNull(getBasicTextUI(jta).getToolTipText(jta, p));
}
+ }
}
public void testModelToView() {
- BasicTextUI ui = (BasicTextUI)jta.getUI();
+ BasicTextUI ui = (BasicTextUI) jta.getUI();
View view = ui.getRootView(jta).getView(0);
-
Rectangle r1 = null, r2 = null;
try {
int length = jta.getDocument().getLength();
@@ -249,25 +241,20 @@
r1 = ui.modelToView(null, i, forward);
r2 = view.modelToView(i, visibleRect, forward).getBounds();
assertEquals(r2, r1);
-
r1 = ui.modelToView(null, i);
assertEquals(r2, r1);
-
r1 = ui.modelToView(null, i, backward);
r2 = view.modelToView(i, visibleRect, backward).getBounds();
assertEquals(r2, r1);
}
} catch (BadLocationException e) {
}
-
}
public void testGetRootView() {
-
BasicTextUI ui = getBasicTextUI(jta);
-
View rootView = ui.getRootView(jta);
- AbstractDocument doc = (AbstractDocument)jta.getDocument();
+ AbstractDocument doc = (AbstractDocument) jta.getDocument();
Element rootElement = jta.getDocument().getDefaultRootElement();
assertEquals(1, rootView.getViewCount());
View sonRootView = rootView.getView(0);
@@ -302,10 +289,6 @@
*/
}
- private int rintSpec(final int i) {
- return (int)Math.rint(i / 10);
- }
-
public void testCreateElementintint() {
Element elem = jta.getDocument().getDefaultRootElement();
assertNull(basicTextUI.create(elem));
@@ -331,88 +314,75 @@
}
public void testViewToModel() {
- BasicTextUI ui = (BasicTextUI)jta.getUI();
+ BasicTextUI ui = (BasicTextUI) jta.getUI();
Position.Bias b[] = new Position.Bias[1];
Rectangle r1 = null;
Rectangle r2 = null;
Point p = new Point(0, 0);
-
try {
r1 = ui.modelToView(null, 6, forward);
} catch (BadLocationException e) {
}
-
try {
r2 = ui.modelToView(null, 6, backward);
} catch (BadLocationException e) {
}
-
assertNotNull(r1);
assertNotNull(r2);
-
assertEquals(6, ui.viewToModel(null, rectToPoint(p, r1)));
assertEquals(6, ui.viewToModel(null, rectToPoint(p, r2)));
-
assertEquals(6, ui.viewToModel(null, rectToPoint(p, r1), b));
-
assertEquals(6, ui.viewToModel(null, rectToPoint(p, r2), b));
-
}
private BasicTextUI getBasicTextUI(final JTextComponent c) {
- return (BasicTextUI)c.getUI();
+ return (BasicTextUI) c.getUI();
}
public void testGetPreferredSizeJComponent() throws Exception {
tf = new JTextField("JTextField\n JTextField \n JTextField");
View view = tf.getUI().getRootView(tf);
Insets insets = tf.getInsets();
- int prefX = (int)view.getPreferredSpan(View.X_AXIS);
- int prefY = (int)view.getPreferredSpan(View.Y_AXIS);
+ int prefX = (int) view.getPreferredSpan(View.X_AXIS);
+ int prefY = (int) view.getPreferredSpan(View.Y_AXIS);
int hrz = insets.left + insets.right;
int vrt = insets.top + insets.bottom;
int uiPrefWidth = prefX + hrz;
int uiPrefHeight = prefY + vrt;
- assertEquals(new Dimension(uiPrefWidth, uiPrefHeight),
- getBasicTextUI(tf).getPreferredSize(tf));
+ assertEquals(new Dimension(uiPrefWidth, uiPrefHeight), getBasicTextUI(tf)
+ .getPreferredSize(tf));
}
public void testGetMinimumSizeJComponent() {
tf = new JTextField("JTextField\n JTextField \n JTextField");
View view = tf.getUI().getRootView(tf);
Insets insets = tf.getInsets();
- int minX = (int)view.getMinimumSpan(View.X_AXIS);
- int minY = (int)view.getMinimumSpan(View.Y_AXIS);
+ int minX = (int) view.getMinimumSpan(View.X_AXIS);
+ int minY = (int) view.getMinimumSpan(View.Y_AXIS);
int hrz = insets.left + insets.right;
int vrt = insets.top + insets.bottom;
int uiMinWidth = minX + hrz;
int uiMinHeight = minY + vrt;
- assertEquals(new Dimension(uiMinWidth, uiMinHeight), getBasicTextUI(tf)
- .getMinimumSize(tf));
+ assertEquals(new Dimension(uiMinWidth, uiMinHeight), getBasicTextUI(tf).getMinimumSize(
+ tf));
}
public void testGetMaximumSizeJComponent() {
- assertEquals(new Dimension(Integer.MAX_VALUE,
- Integer.MAX_VALUE), ((BasicTextUI)jta
+ assertEquals(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE), ((BasicTextUI) jta
.getUI()).getMaximumSize(jta));
}
public void testSetView() throws Exception {
-
jta.wasCallInvalidate = false;
view = new PlainView(jta.getDocument().getDefaultRootElement());
-
- ((BasicTextUI)jta.getUI()).setView(view);
+ ((BasicTextUI) jta.getUI()).setView(view);
wasCallInvalidate = jta.wasCallInvalidate;
-
assertTrue(wasCallInvalidate);
- assertEquals(view, ((BasicTextUI)jta.getUI()).getRootView(jta)
- .getView(0));
-
+ assertEquals(view, ((BasicTextUI) jta.getUI()).getRootView(jta).getView(0));
}
private String getKeymapName(final JTextComponent c) {
- BasicTextUI ui = (BasicTextUI)jta.getUI();
+ BasicTextUI ui = (BasicTextUI) jta.getUI();
String className = ui.getClass().getName();
int start = className.lastIndexOf(".");
int end = className.length();
@@ -423,20 +393,19 @@
public void testCreateKeymap() {
JTextComponent.removeKeymap("BasicTextAreaUI");
TextUI ui = jta.getUI();
- Keymap keymap = ((BasicTextUI)ui).createKeymap();
+ Keymap keymap = ((BasicTextUI) ui).createKeymap();
assertEquals(getKeymapName(jta), keymap.getName());
assertTrue(keymap.getDefaultAction() instanceof DefaultEditorKit.DefaultKeyTypedAction);
assertEquals(0, keymap.getBoundActions().length);
assertEquals(0, keymap.getBoundKeyStrokes().length);
- assertEquals(JTextComponent.DEFAULT_KEYMAP, keymap.getResolveParent()
- .getName());
+ assertEquals(JTextComponent.DEFAULT_KEYMAP, keymap.getResolveParent().getName());
}
public void testDamageRangeJTextComponentintint() {
}
public void testGetComponent() {
- assertEquals(jta, ((BasicTextUI)jta.getUI()).getComponent());
+ assertEquals(jta, ((BasicTextUI) jta.getUI()).getComponent());
}
public void testCreateHighlighter() {
@@ -458,7 +427,6 @@
public void testUninstallUI() throws Exception {
TextUI ui = jta.getUI();
assertTrue(ui instanceof TextAreaUI);
- TextAreaUI textAreaUI = (TextAreaUI)jta.getUI();
TextAreaUI.callOrder = "";
jta.setVisible(false);
jta.getUI().uninstallUI(jta);
@@ -473,14 +441,11 @@
public void testInstallUI() throws Exception {
Caret caret = jta.getCaret();
Highlighter highlighter = jta.getHighlighter();
- String prefix = ((BasicTextUI)tf.getUI()).getPropertyPrefix();
-
+ String prefix = ((BasicTextUI) tf.getUI()).getPropertyPrefix();
(jta.getUI()).uninstallUI(jta);
-
TextUI ui = jta.getUI();
assertTrue(ui instanceof TextAreaUI);
TextAreaUI.callOrder = "";
-
(jta.getUI()).installUI(jta);
String tmp = TextAreaUI.callOrder;
tmp = findAndRemoveSubstring(tmp, "installUI::");
@@ -497,41 +462,31 @@
assertNotSame(highlighter, jta.getHighlighter());
assertTrue(jta.getHighlighter() instanceof UIResource);
assertTrue(jta.getTransferHandler() instanceof UIResource);
-
assertTrue(jta.isOpaque());
-
- int caretBlinkRate = ((Integer)getProperty(prefix, "caretBlinkRate"))
- .intValue();
+ int caretBlinkRate = ((Integer) getProperty(prefix, "caretBlinkRate")).intValue();
assertEquals(caretBlinkRate, caret.getBlinkRate());
- assertEquals(jta.getDocument().getDefaultRootElement(), jta.getUI()
- .getRootView(jta).getElement());
+ assertEquals(jta.getDocument().getDefaultRootElement(), jta.getUI().getRootView(jta)
+ .getElement());
}
public void testGetKeymapName() {
- assertEquals("BasicTextUITest$MyBasicTextUI",basicTextUI.getKeymapName());
+ assertEquals("BasicTextUITest$MyBasicTextUI", basicTextUI.getKeymapName());
}
public void testPropertyChange() throws Exception {
-
- TextAreaUI ui = (TextAreaUI)jta.getUI();
+ TextAreaUI ui = (TextAreaUI) jta.getUI();
ui.propertyChangeFlag = false;
ui.eventName = null;
jta.setCaretColor(null);
-
assertTrue(ui.propertyChangeFlag);
assertEquals("caretColor", ui.eventName);
-
}
public void testGetVisibleEditorRect() throws Exception {
- BasicTextUI ui = (BasicTextUI)jta.getUI();
-
+ BasicTextUI ui = (BasicTextUI) jta.getUI();
jta.setSize(3, 0);
-
assertNull(ui.getVisibleEditorRect());
-
jta.setBounds(0, 0, 234, 553);
-
assertEquals(jta.getBounds(), ui.getVisibleEditorRect());
}
@@ -542,9 +497,6 @@
}
public void testUninstallDefaults() throws Exception {
-
- String prefix = ((BasicTextUI)tf.getUI()).getPropertyPrefix();
-
tf.setCaretColor(null);
tf.setSelectionColor(null);
tf.setSelectedTextColor(null);
@@ -555,8 +507,7 @@
tf.setBorder(BorderUIResource.getEtchedBorderUIResource());
tf.setMargin(null);
tf.setActionMap(null);
- ((BasicTextUI)tf.getUI()).uninstallDefaults();
-
+ ((BasicTextUI) tf.getUI()).uninstallDefaults();
assertNull(tf.getForeground());
assertNull(tf.getBackground());
assertNull(tf.getFont());
@@ -567,7 +518,6 @@
//?????
assertNull(tf.getBorder());
assertNull(tf.getMargin());
-
tf.setCaretColor(RED);
tf.setSelectionColor(GREEN);
tf.setSelectedTextColor(BLUE);
@@ -575,16 +525,13 @@
tf.setFont(new FontUIResource("SimSun", 8, 8));
tf.setBackground(BLACK);
tf.setForeground(YELLOW);
- tf.setBorder(new BorderUIResource.LineBorderUIResource(
- ColorUIResource.RED));
+ tf.setBorder(new BorderUIResource.LineBorderUIResource(Color.RED));
tf.setMargin(new InsetsUIResource(2, 4, 6, 3));
- ((BasicTextUI)tf.getUI()).uninstallDefaults();
-
+ ((BasicTextUI) tf.getUI()).uninstallDefaults();
//TODO specification antogonism
//assertEquals(YELLOW,tf.getForeground()); //???
//assertEquals(BLACK,tf.getBackground()); //???
//assertEquals(new FontUIResource("SimSun", 8, 8),tf.getFont()); //???
-
assertNull(tf.getCaretColor());
assertNull(tf.getSelectionColor());
assertNull(tf.getSelectedTextColor());
@@ -592,7 +539,6 @@
//?????
assertNull(tf.getBorder());
assertNull(tf.getMargin());
-
tf.setCaretColor(Color.RED);
tf.setSelectionColor(Color.GREEN);
tf.setSelectedTextColor(Color.BLUE);
@@ -602,8 +548,7 @@
tf.setForeground(Color.YELLOW);
tf.setBorder(new BasicBorders.ButtonBorder(null, null, null, null));
tf.setMargin(new Insets(2, 4, 6, 3));
- ((BasicTextUI)tf.getUI()).uninstallDefaults();
-
+ ((BasicTextUI) tf.getUI()).uninstallDefaults();
assertEquals(Color.YELLOW, tf.getForeground());
assertEquals(Color.BLACK, tf.getBackground());
assertEquals(FONT, tf.getFont());
@@ -611,20 +556,15 @@
assertEquals(Color.GREEN, tf.getSelectionColor());
assertEquals(Color.BLUE, tf.getSelectedTextColor());
assertEquals(Color.YELLOW, tf.getDisabledTextColor());
-
assertNull(tf.getBorder());//????
assertEquals(new Insets(2, 4, 6, 3), tf.getMargin());
-
}
public void testModelChanged() throws Exception {
-
- TextAreaUI ui = (TextAreaUI)jta.getUI();
+ TextAreaUI ui = (TextAreaUI) jta.getUI();
ui.flagCreate = false;
ui.modelChanged();
-
assertTrue(ui.flagCreate);
-
}
public void testInstallListeners() throws Exception {
@@ -632,7 +572,7 @@
private InputMap getInputMap(final int generation) {
InputMap im = jta.getInputMap();
- for (int i = 0; i < generation; i ++) {
+ for (int i = 0; i < generation; i++) {
im = im.getParent();
}
return im;
@@ -640,17 +580,16 @@
private ActionMap getActionMap(final int generation) {
ActionMap am = jta.getActionMap();
- for (int i = 0; i < generation; i ++) {
+ for (int i = 0; i < generation; i++) {
am = am.getParent();
}
return am;
}
- public void testInstallKeyboardActions() throws Exception {
- ((BasicTextUI)jta.getUI()).uninstallKeyboardActions();
+ public void testInstallKeyboardActions() throws Exception {
+ ((BasicTextUI) jta.getUI()).uninstallKeyboardActions();
assertEquals(0, getInputMap(0).size());
assertFalse(getInputMap(0) instanceof InputMapUIResource);
-
assertEquals(0, getInputMap(1).size());
assertTrue(getInputMap(1) instanceof InputMapUIResource);
//assertEquals(55, jta.getInputMap().getParent().getParent().size());1.5.0
@@ -659,54 +598,41 @@
assertEquals(0, getActionMap(0).size());
assertFalse(getActionMap(0) instanceof ActionMapUIResource);
assertNull(getActionMap(1));
-
assertNull(jta.getKeymap());
- ((BasicTextUI)jta.getUI()).installKeyboardActions();
-
+ ((BasicTextUI) jta.getUI()).installKeyboardActions();
assertNotNull(jta.getKeymap());
assertEquals(getKeymapName(jta), jta.getKeymap().getName());
-
assertEquals(0, getInputMap(0).size());
assertEquals(0, getInputMap(1).size());
assertEquals(0, getInputMap(2).size());
//assertEquals(55, jta.getInputMap().getParent().getParent().getParent()
// .size()); //1.5.0
assertNull(getInputMap(4));
-
assertEquals(0, getActionMap(0).size());
assertEquals(1, getActionMap(1).size());
//Note
//assertEquals(2,jta.getActionMap().getParent().getParent().size());
assertEquals(56, getActionMap(3).size());
assertNull(getActionMap(4));
-
assertFalse(getInputMap(0) instanceof InputMapUIResource);
assertFalse(getInputMap(1) instanceof InputMapUIResource);
assertTrue(getInputMap(2) instanceof InputMapUIResource);
assertTrue(getInputMap(3) instanceof InputMapUIResource);
-
assertFalse(getActionMap(0) instanceof ActionMapUIResource);
assertFalse(getActionMap(1) instanceof ActionMapUIResource);
assertTrue(getActionMap(2) instanceof ActionMapUIResource);
assertTrue(getActionMap(3) instanceof ActionMapUIResource);
-
}
private Object getProperty(final String prefix, final String s) {
return UIManager.getLookAndFeelDefaults().get(prefix + "." + s);
}
- private void setProperies(final JTextComponent c,
- final Color caretColor,
- final Color selectionColor,
- final Color selectedTextColor,
- final Color disabledTextColor,
- final Font font,
- final Color background,
- final Color foreground,
- final Insets margin,
- final Border border,
- final int caretBlinkRate) {
+ private void setProperies(final JTextComponent c, final Color caretColor,
+ final Color selectionColor, final Color selectedTextColor,
+ final Color disabledTextColor, final Font font, final Color background,
+ final Color foreground, final Insets margin, final Border border,
+ final int caretBlinkRate) {
c.setCaretColor(caretColor);
c.setSelectionColor(selectionColor);
c.setSelectedTextColor(selectedTextColor);
@@ -722,17 +648,10 @@
}
}
- private void checkProperies(final JTextComponent c,
- final Color caretColor,
- final Color selectionColor,
- final Color selectedTextColor,
- final Color disabledTextColor,
- final Font font,
- final Color background,
- final Color foreground,
- final Insets margin,
- final Border border
- ) {
+ private void checkProperies(final JTextComponent c, final Color caretColor,
+ final Color selectionColor, final Color selectedTextColor,
+ final Color disabledTextColor, final Font font, final Color background,
+ final Color foreground, final Insets margin, final Border border) {
assertEquals(caretColor, c.getCaretColor());
assertEquals(selectionColor, c.getSelectionColor());
assertEquals(selectedTextColor, c.getSelectedTextColor());
@@ -745,43 +664,33 @@
}
public void testInstallDefaults() throws Exception {
- String prefix = ((BasicTextUI)tf.getUI()).getPropertyPrefix();
- setProperies(tf, null, null, null, null, null, null, null, null, null,
- 0);
+ String prefix = ((BasicTextUI) tf.getUI()).getPropertyPrefix();
+ setProperies(tf, null, null, null, null, null, null, null, null, null, 0);
tf.setActionMap(null);
- ((BasicTextUI)tf.getUI()).installDefaults();
-
- Color foreground = (Color)getProperty(prefix, "foreground");
- Color background = (Color)getProperty(prefix, "background");
- Font font = (Font)getProperty(prefix, "font");
- Color caretForeground = (Color)getProperty(prefix, "caretForeground");
- Color selectionBackground = (Color)getProperty(prefix, "selectionBackground");
- Color selectionForeground = (Color)getProperty(prefix, "selectionForeground");
- Color inactiveForeground = (Color)getProperty(prefix, "inactiveForeground");
- Insets margin = (Insets)getProperty(prefix, "margin");
- Border border = (Border)getProperty(prefix, "border");
- checkProperies(tf, caretForeground, selectionBackground,
- selectionForeground, inactiveForeground,
- font, background, foreground, margin, border);
-
- setProperies(tf, RED, GREEN, BLUE, YELLOW,
- new FontUIResource("SimSun", 8, 8), BLACK, YELLOW,
- new InsetsUIResource(2, 4, 6, 3),
- new BorderUIResource.LineBorderUIResource(
- ColorUIResource.RED), 56);
-
- ((BasicTextUI)tf.getUI()).installDefaults();
- checkProperies(tf, caretForeground, selectionBackground,
- selectionForeground, inactiveForeground,
- font, background, foreground, margin, border);
+ ((BasicTextUI) tf.getUI()).installDefaults();
+ Color foreground = (Color) getProperty(prefix, "foreground");
+ Color background = (Color) getProperty(prefix, "background");
+ Font font = (Font) getProperty(prefix, "font");
+ Color caretForeground = (Color) getProperty(prefix, "caretForeground");
+ Color selectionBackground = (Color) getProperty(prefix, "selectionBackground");
+ Color selectionForeground = (Color) getProperty(prefix, "selectionForeground");
+ Color inactiveForeground = (Color) getProperty(prefix, "inactiveForeground");
+ Insets margin = (Insets) getProperty(prefix, "margin");
+ Border border = (Border) getProperty(prefix, "border");
+ checkProperies(tf, caretForeground, selectionBackground, selectionForeground,
+ inactiveForeground, font, background, foreground, margin, border);
+ setProperies(tf, RED, GREEN, BLUE, YELLOW, new FontUIResource("SimSun", 8, 8), BLACK,
+ YELLOW, new InsetsUIResource(2, 4, 6, 3),
+ new BorderUIResource.LineBorderUIResource(Color.RED), 56);
+ ((BasicTextUI) tf.getUI()).installDefaults();
+ checkProperies(tf, caretForeground, selectionBackground, selectionForeground,
+ inactiveForeground, font, background, foreground, margin, border);
Border newBorder = new TitledBorder("KK");
- setProperies(tf, Color.RED, Color.GREEN, Color.BLUE, Color.YELLOW,
- FONT, Color.BLACK, Color.YELLOW, new Insets(2, 4, 6, 3),
- newBorder, 0);
- ((BasicTextUI)tf.getUI()).installDefaults();
- checkProperies(tf, Color.RED, Color.GREEN, Color.BLUE, Color.YELLOW,
- FONT, Color.BLACK, Color.YELLOW, new Insets(2, 4, 6, 3),
- newBorder);
+ setProperies(tf, Color.RED, Color.GREEN, Color.BLUE, Color.YELLOW, FONT, Color.BLACK,
+ Color.YELLOW, new Insets(2, 4, 6, 3), newBorder, 0);
+ ((BasicTextUI) tf.getUI()).installDefaults();
+ checkProperies(tf, Color.RED, Color.GREEN, Color.BLUE, Color.YELLOW, FONT, Color.BLACK,
+ Color.YELLOW, new Insets(2, 4, 6, 3), newBorder);
}
public void testBasicCaret() {
@@ -798,7 +707,7 @@
public void testI18nProperty() throws Exception {
JTextArea ta = new JTextArea("aaaa");
- TextAreaUI ui = (TextAreaUI)ta.getUI();
+ TextAreaUI ui = (TextAreaUI) ta.getUI();
ui.flagModelChanged = false;
ta.setText("aaaa" + "\u05dc");
assertTrue(ui.flagModelChanged);
@@ -809,31 +718,25 @@
public void testCallOrder() throws Exception {
TextAreaUI.callOrder = "";
-
jta.getUI().uninstallUI(jta);
- assertEquals("uninstallUI::uninstallDefaults::uninstallKeyboard" +
- "Actions::uninstallListeners::", TextAreaUI.callOrder);
+ assertEquals("uninstallUI::uninstallDefaults::uninstallKeyboard"
+ + "Actions::uninstallListeners::", TextAreaUI.callOrder);
TextAreaUI.callOrder = "";
-
jta.getUI().installUI(jta);
- assertEquals("installUI::installDefaults::createCaret::createHighli" +
- "ghter::modelChanged::create::installListeners::installKeyboardActions::", TextAreaUI.callOrder);
+ assertEquals("installUI::installDefaults::createCaret::createHighli"
+ + "ghter::modelChanged::create::installListeners::installKeyboardActions::",
+ TextAreaUI.callOrder);
}
public void testFocusAccelerator() throws Exception {
-
jta.setFocusAccelerator('a');
-
- InputMap im = SwingUtilities
- .getUIInputMap(jta, JComponent.WHEN_IN_FOCUSED_WINDOW);
+ InputMap im = SwingUtilities.getUIInputMap(jta, JComponent.WHEN_IN_FOCUSED_WINDOW);
ActionMap am = jta.getActionMap().getParent().getParent();
-
assertNotNull(am);
assertNotNull(im);
assertEquals(1, im.size());
assertTrue(am.size() > 0);
- assertEquals(im.keys()[0], KeyStroke.getKeyStroke('A',
- InputEvent.ALT_DOWN_MASK));
+ assertEquals(im.keys()[0], KeyStroke.getKeyStroke('A', InputEvent.ALT_DOWN_MASK));
Object actionName = im.get(im.keys()[0]);
assertNotNull(am.get(actionName));
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicToggleButtonUITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicToggleButtonUITest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicToggleButtonUITest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicToggleButtonUITest.java Sun Nov 26 12:15:43 2006
@@ -26,16 +26,16 @@
import javax.swing.SwingTestCase;
public class BasicToggleButtonUITest extends SwingTestCase {
-
public class MyBasicToggleButtonUI extends BasicToggleButtonUI {
+ @Override
public String getPropertyPrefix() {
return super.getPropertyPrefix();
}
+ @Override
public int getTextShiftOffset() {
return super.getTextShiftOffset();
}
-
};
public MyBasicToggleButtonUI ui = null;
@@ -47,16 +47,19 @@
/*
* @see TestCase#setUp()
*/
+ @Override
protected void setUp() throws Exception {
super.setUp();
-
ui = new MyBasicToggleButtonUI();
}
public void testCreateUI() {
- assertTrue("created UI is not null", null != BasicToggleButtonUI.createUI(new JButton()));
- assertTrue("created UI is of the proper class", BasicToggleButtonUI.createUI(null) instanceof BasicToggleButtonUI);
- assertTrue("created UI is of unique", BasicToggleButtonUI.createUI(null) == BasicToggleButtonUI.createUI(null));
+ assertTrue("created UI is not null", null != BasicToggleButtonUI
+ .createUI(new JButton()));
+ assertTrue("created UI is of the proper class",
+ BasicToggleButtonUI.createUI(null) instanceof BasicToggleButtonUI);
+ assertTrue("created UI is of unique",
+ BasicToggleButtonUI.createUI(null) == BasicToggleButtonUI.createUI(null));
}
public void testGetPropertyPrefix() {
@@ -66,5 +69,4 @@
public void testGetTextShiftOffset() {
assertEquals("offset", 0, ui.getTextShiftOffset());
}
-
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicToolBarSeparatorUITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicToolBarSeparatorUITest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicToolBarSeparatorUITest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicToolBarSeparatorUITest.java Sun Nov 26 12:15:43 2006
@@ -21,7 +21,6 @@
package javax.swing.plaf.basic;
import java.awt.Dimension;
-
import javax.swing.JToolBar;
import javax.swing.SwingTestCase;
import javax.swing.UIManager;
@@ -29,16 +28,18 @@
public class BasicToolBarSeparatorUITest extends SwingTestCase {
private JToolBar.Separator separator;
+
private BasicToolBarSeparatorUI ui;
+ @Override
protected void setUp() throws Exception {
super.setUp();
-
separator = new JToolBar.Separator();
ui = new BasicToolBarSeparatorUI();
separator.setUI(ui);
}
+ @Override
protected void tearDown() throws Exception {
super.tearDown();
}
@@ -52,30 +53,26 @@
}
public void testGetPreferredSize() {
- assertEquals(UIManager.getDimension("ToolBar.separatorSize"),
- ui.getPreferredSize(separator));
-
+ assertEquals(UIManager.getDimension("ToolBar.separatorSize"), ui
+ .getPreferredSize(separator));
ui = new BasicToolBarSeparatorUI();
- assertEquals(UIManager.getDimension("ToolBar.separatorSize"),
- ui.getPreferredSize(separator));
+ assertEquals(UIManager.getDimension("ToolBar.separatorSize"), ui
+ .getPreferredSize(separator));
}
public void testCreateUI() {
ComponentUI ui1 = BasicToolBarSeparatorUI.createUI(separator);
assertTrue(ui1 instanceof BasicToolBarSeparatorUI);
-
ComponentUI ui2 = BasicToolBarSeparatorUI.createUI(separator);
assertNotSame(ui1, ui2);
}
public void testInstallDefaults() {
ui.installDefaults(separator);
-
assertNull(separator.getBackground());
assertNull(separator.getForeground());
- assertEquals(UIManager.getDimension("ToolBar.separatorSize"),
- separator.getSeparatorSize());
-
+ assertEquals(UIManager.getDimension("ToolBar.separatorSize"), separator
+ .getSeparatorSize());
Dimension size = new Dimension(1, 2);
separator.setSeparatorSize(size);
ui.installDefaults(separator);
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicToolBarUI$DragWindowTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicToolBarUI%24DragWindowTest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicToolBarUI$DragWindowTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicToolBarUI$DragWindowTest.java Sun Nov 26 12:15:43 2006
@@ -24,7 +24,6 @@
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.Point;
-
import javax.swing.JFrame;
import javax.swing.JToolBar;
import javax.swing.SwingConstants;
@@ -32,12 +31,14 @@
public class BasicToolBarUI$DragWindowTest extends SwingTestCase {
private JToolBar toolBar;
+
private BasicToolBarUI ui;
+
private BasicToolBarUI.DragWindow dragWindow;
+ @Override
protected void setUp() throws Exception {
super.setUp();
-
ui = new BasicToolBarUI();
toolBar = new JToolBar();
toolBar.setUI(ui);
@@ -46,6 +47,7 @@
dragWindow = ui.createDragWindow(toolBar);
}
+ @Override
protected void tearDown() throws Exception {
super.tearDown();
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicToolBarUIRTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicToolBarUIRTest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicToolBarUIRTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicToolBarUIRTest.java Sun Nov 26 12:15:43 2006
@@ -22,31 +22,36 @@
import javax.swing.JButton;
import javax.swing.JToolBar;
+import javax.swing.SwingConstants;
import javax.swing.SwingTestCase;
public class BasicToolBarUIRTest extends SwingTestCase {
-
public BasicToolBarUIRTest(final String name) {
super(name);
}
+ @Override
protected void setUp() throws Exception {
super.setUp();
}
+ @Override
protected void tearDown() throws Exception {
super.tearDown();
}
public void testNavigateFocusedComponent() {
class MyButton extends JButton {
+ private static final long serialVersionUID = 1L;
+
public boolean requestedFocus;
+
+ @Override
public void requestFocus() {
requestedFocus = true;
super.requestFocus();
}
}
-
JToolBar toolbar = new JToolBar();
BasicToolBarUI ui = new BasicToolBarUI();
toolbar.setUI(ui);
@@ -56,8 +61,7 @@
toolbar.add(b1);
toolbar.add(b2);
ui.focusedCompIndex = 0;
-
- ui.navigateFocusedComp(BasicToolBarUI.EAST);
+ ui.navigateFocusedComp(SwingConstants.EAST);
assertFalse(b2.requestedFocus);
}
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicToolBarUITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicToolBarUITest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicToolBarUITest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicToolBarUITest.java Sun Nov 26 12:15:43 2006
@@ -32,7 +32,6 @@
import java.awt.event.MouseEvent;
import java.awt.event.WindowListener;
import java.util.Arrays;
-
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
@@ -55,37 +54,46 @@
public class BasicToolBarUITest extends SwingTestCase {
private class TestBasicToolBarUI extends BasicToolBarUI {
public Border rolloverBorder;
+
public Border nonRolloverBorder;
+
public Container floatingWindow;
public boolean setFloatingCalled;
+
public boolean setFloatingBParam;
+
private boolean dragToCalled;
+ @Override
protected Border createRolloverBorder() {
rolloverBorder = super.createRolloverBorder();
return rolloverBorder;
}
+ @Override
protected Border createNonRolloverBorder() {
nonRolloverBorder = super.createNonRolloverBorder();
return nonRolloverBorder;
}
+ @Override
protected RootPaneContainer createFloatingWindow(final JToolBar toolbar) {
RootPaneContainer result = super.createFloatingWindow(toolbar);
if (result instanceof Container) {
- floatingWindow = (Container)result;
+ floatingWindow = (Container) result;
}
return result;
}
+ @Override
public void setFloating(final boolean b, final Point p) {
setFloatingCalled = true;
setFloatingBParam = b;
super.setFloating(b, p);
}
+ @Override
protected void dragTo(final Point position, final Point origin) {
dragToCalled = true;
super.dragTo(position, origin);
@@ -93,34 +101,38 @@
}
private class TestJButton extends JButton {
+ private static final long serialVersionUID = 1L;
+
+ @Override
public void requestFocus() {
- BasicToolBarUITest.this.ui.focusedCompIndex =
- toolBar.getComponentIndex(this);
+ BasicToolBarUITest.this.ui.focusedCompIndex = toolBar.getComponentIndex(this);
super.requestFocus();
}
}
private JToolBar toolBar;
+
private TestBasicToolBarUI ui;
+
private JButton b;
+
private JLabel label;
- private JFrame frame;
+ private JFrame frame;
+ @Override
protected void setUp() throws Exception {
super.setUp();
-
toolBar = new JToolBar();
ui = new TestBasicToolBarUI();
toolBar.setUI(ui);
-
b = new JButton();
label = new JLabel();
}
+ @Override
protected void tearDown() throws Exception {
super.tearDown();
-
if (frame != null) {
frame.dispose();
frame = null;
@@ -134,25 +146,21 @@
public void testInstallUI() {
ui = new TestBasicToolBarUI();
ui.installUI(toolBar);
-
assertSame(ui.toolBar, toolBar);
- assertEquals(UIManager.getColor("ToolBar.dockingForeground"),
- ui.dockingBorderColor);
- assertTrue(Arrays.asList(toolBar.getContainerListeners())
- .contains(ui.toolBarContListener));
- assertSame(UIManager.get("ToolBar.ancestorInputMap"),
- SwingUtilities.getUIInputMap(toolBar,
- JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT));
+ assertEquals(UIManager.getColor("ToolBar.dockingForeground"), ui.dockingBorderColor);
+ assertTrue(Arrays.asList(toolBar.getContainerListeners()).contains(
+ ui.toolBarContListener));
+ assertSame(UIManager.get("ToolBar.ancestorInputMap"), SwingUtilities.getUIInputMap(
+ toolBar, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT));
}
public void testUninstallUI() {
ui.uninstallUI(toolBar);
-
assertNull(toolBar.getBorder());
- assertFalse(Arrays.asList(toolBar.getContainerListeners())
- .contains(ui.toolBarContListener));
+ assertFalse(Arrays.asList(toolBar.getContainerListeners()).contains(
+ ui.toolBarContListener));
assertNull(SwingUtilities.getUIInputMap(toolBar,
- JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT));
+ JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT));
}
public void testUninstallUIWhenFloating() {
@@ -170,7 +178,6 @@
public void testCreateUI() {
ComponentUI ui1 = BasicToolBarUI.createUI(toolBar);
assertTrue(ui1 instanceof BasicToolBarUI);
-
ComponentUI ui2 = BasicToolBarUI.createUI(toolBar);
assertNotSame(ui1, ui2);
}
@@ -186,20 +193,15 @@
panel.add(toolBar);
panel.setSize(400, 300);
panel.doLayout();
-
- assertTrue(ui.canDock(panel, new Point(panel.getWidth() / 2,
- toolBar.getHeight() - 1)));
- assertTrue(ui.canDock(panel, new Point(panel.getWidth() / 2,
- panel.getHeight() - (toolBar.getHeight() - 1))));
- assertTrue(ui.canDock(panel, new Point(toolBar.getHeight() - 1,
- panel.getHeight() / 2)));
- assertTrue(ui.canDock(panel,
- new Point(panel.getWidth() - (toolBar.getHeight() - 1),
+ assertTrue(ui.canDock(panel, new Point(panel.getWidth() / 2, toolBar.getHeight() - 1)));
+ assertTrue(ui.canDock(panel, new Point(panel.getWidth() / 2, panel.getHeight()
+ - (toolBar.getHeight() - 1))));
+ assertTrue(ui.canDock(panel, new Point(toolBar.getHeight() - 1, panel.getHeight() / 2)));
+ assertTrue(ui.canDock(panel, new Point(panel.getWidth() - (toolBar.getHeight() - 1),
panel.getHeight() / 2)));
assertFalse(ui.canDock(panel, new Point(toolBar.getHeight() + 1,
toolBar.getHeight() + 1)));
- assertFalse(ui.canDock(panel, new Point(panel.getWidth(),
- panel.getHeight())));
+ assertFalse(ui.canDock(panel, new Point(panel.getWidth(), panel.getHeight())));
}
public void testCreateDockingListener() {
@@ -225,7 +227,7 @@
toolBar.setName("The toolbar");
RootPaneContainer floatingWindow = ui.createFloatingWindow(toolBar);
assertTrue(floatingWindow instanceof JDialog);
- JDialog floatingFrame = (JDialog)floatingWindow;
+ JDialog floatingFrame = (JDialog) floatingWindow;
assertFalse(floatingFrame.isAncestorOf(toolBar));
assertEquals("The toolbar", floatingFrame.getTitle());
assertTrue(floatingFrame.getWindowListeners().length > 0);
@@ -266,24 +268,20 @@
Point origin = new Point(1, 2);
Point position1 = frame.getLocation();
position1.translate(frame.getWidth() + 1, 0);
-
toolBar.setFloatable(false);
ui.dragTo(position1, origin);
assertNull(ui.dragWindow);
toolBar.setFloatable(true);
-
ui.dragTo(position1, origin);
assertNotNull(ui.dragWindow);
assertTrue(ui.dragWindow.isVisible());
Point dragWindowPosition1 = ui.dragWindow.getLocation();
-
Point position2 = new Point(position1);
position2.translate(1, 2);
ui.dragTo(position2, origin);
Point dragWindowPosition2 = ui.dragWindow.getLocation();
position2.translate(-position1.x, -position1.y);
- dragWindowPosition2.translate(-dragWindowPosition1.x,
- -dragWindowPosition1.y);
+ dragWindowPosition2.translate(-dragWindowPosition1.x, -dragWindowPosition1.y);
assertEquals(position2, dragWindowPosition2);
}
@@ -292,13 +290,11 @@
Point origin = new Point(1, 2);
Point position1 = frame.getLocation();
position1.translate(frame.getWidth() + 1, 0);
-
toolBar.setFloatable(false);
ui.dragTo(position1, origin);
ui.floatAt(position1, origin);
assertNull(ui.floatingWindow);
toolBar.setFloatable(true);
-
ui.dragTo(position1, origin);
ui.floatAt(position1, origin);
assertFalse(ui.dragWindow.isVisible());
@@ -309,7 +305,6 @@
public void testSetGetDockingColor() {
assertSame(ui.getDockingColor(), ui.dockingColor);
-
Color c = Color.RED;
ui.setDockingColor(c);
assertSame(c, ui.dockingColor);
@@ -318,7 +313,6 @@
public void testSetGetFloatingColor() {
assertSame(ui.getFloatingColor(), ui.floatingColor);
-
Color c = Color.RED;
ui.setFloatingColor(c);
assertSame(c, ui.floatingColor);
@@ -329,7 +323,6 @@
toolBar.add(b);
ui.uninstallComponents();
int compCount = toolBar.getComponentCount();
-
ui.installComponents();
assertEquals(compCount, toolBar.getComponentCount());
}
@@ -337,7 +330,6 @@
public void testUninstallComponents() {
toolBar.add(b);
int compCount = toolBar.getComponentCount();
-
ui.uninstallComponents();
assertEquals(compCount, toolBar.getComponentCount());
}
@@ -348,22 +340,15 @@
toolBar.add(b);
b.setBorder(null);
ui.installDefaults();
-
assertTrue(toolBar.getForeground() instanceof UIResource);
assertTrue(toolBar.getForeground() instanceof UIResource);
assertTrue(toolBar.getFont() instanceof UIResource);
assertTrue(toolBar.getBorder() instanceof UIResource);
-
- assertEquals(UIManager.getColor("ToolBar.dockingForeground"),
- ui.dockingBorderColor);
- assertEquals(UIManager.getColor("ToolBar.dockingBackground"),
- ui.dockingColor);
- assertEquals(UIManager.getColor("ToolBar.floatingForeground"),
- ui.floatingBorderColor);
- assertEquals(UIManager.getColor("ToolBar.floatingBackground"),
- ui.floatingColor);
+ assertEquals(UIManager.getColor("ToolBar.dockingForeground"), ui.dockingBorderColor);
+ assertEquals(UIManager.getColor("ToolBar.dockingBackground"), ui.dockingColor);
+ assertEquals(UIManager.getColor("ToolBar.floatingForeground"), ui.floatingBorderColor);
+ assertEquals(UIManager.getColor("ToolBar.floatingBackground"), ui.floatingColor);
assertTrue(toolBar.isOpaque());
-
if (isHarmony()) {
assertTrue(b.getBorder() instanceof UIResource);
}
@@ -373,7 +358,6 @@
b.setBorder(null);
toolBar.add(b);
ui.uninstallDefaults();
-
assertNull(toolBar.getBorder());
assertNull(b.getBorder());
assertTrue(toolBar.isOpaque());
@@ -381,18 +365,16 @@
public void testInstallKeyboardActions() {
ui.uninstallKeyboardActions();
-
ui.installKeyboardActions();
- assertSame(UIManager.get("ToolBar.ancestorInputMap"),
- SwingUtilities.getUIInputMap(toolBar,
- JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT));
+ assertSame(UIManager.get("ToolBar.ancestorInputMap"), SwingUtilities.getUIInputMap(
+ toolBar, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT));
assertNotNull(SwingUtilities.getUIActionMap(toolBar));
}
public void testUninstallKeyboardActions() {
ui.uninstallKeyboardActions();
assertNull(SwingUtilities.getUIInputMap(toolBar,
- JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT));
+ JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT));
assertNull(SwingUtilities.getUIActionMap(toolBar));
}
@@ -400,37 +382,31 @@
ui.uninstallListeners();
toolBar.add(b);
ui.installListeners();
-
- assertTrue(Arrays.asList(toolBar.getContainerListeners())
- .contains(ui.toolBarContListener));
- assertTrue(Arrays.asList(toolBar.getPropertyChangeListeners())
- .contains(ui.propertyListener));
- assertTrue(Arrays.asList(toolBar.getMouseListeners())
- .contains(ui.dockingListener));
+ assertTrue(Arrays.asList(toolBar.getContainerListeners()).contains(
+ ui.toolBarContListener));
+ assertTrue(Arrays.asList(toolBar.getPropertyChangeListeners()).contains(
+ ui.propertyListener));
+ assertTrue(Arrays.asList(toolBar.getMouseListeners()).contains(ui.dockingListener));
assertTrue(Arrays.asList(toolBar.getMouseMotionListeners())
- .contains(ui.dockingListener));
+ .contains(ui.dockingListener));
assertFalse(Arrays.asList(toolBar.getFocusListeners())
- .contains(ui.toolBarFocusListener));
- assertTrue(Arrays.asList(b.getFocusListeners())
- .contains(ui.toolBarFocusListener));
+ .contains(ui.toolBarFocusListener));
+ assertTrue(Arrays.asList(b.getFocusListeners()).contains(ui.toolBarFocusListener));
}
public void testUninstallListeners() {
toolBar.add(b);
ui.uninstallListeners();
-
- assertFalse(Arrays.asList(toolBar.getContainerListeners())
- .contains(ui.toolBarContListener));
- assertFalse(Arrays.asList(toolBar.getPropertyChangeListeners())
- .contains(ui.propertyListener));
- assertFalse(Arrays.asList(toolBar.getMouseListeners())
- .contains(ui.dockingListener));
- assertFalse(Arrays.asList(toolBar.getMouseMotionListeners())
- .contains(ui.dockingListener));
+ assertFalse(Arrays.asList(toolBar.getContainerListeners()).contains(
+ ui.toolBarContListener));
+ assertFalse(Arrays.asList(toolBar.getPropertyChangeListeners()).contains(
+ ui.propertyListener));
+ assertFalse(Arrays.asList(toolBar.getMouseListeners()).contains(ui.dockingListener));
+ assertFalse(Arrays.asList(toolBar.getMouseMotionListeners()).contains(
+ ui.dockingListener));
assertFalse(Arrays.asList(toolBar.getFocusListeners())
- .contains(ui.toolBarFocusListener));
- assertFalse(Arrays.asList(b.getFocusListeners())
- .contains(ui.toolBarFocusListener));
+ .contains(ui.toolBarFocusListener));
+ assertFalse(Arrays.asList(b.getFocusListeners()).contains(ui.toolBarFocusListener));
}
public void testInstallNonRolloverBorders() {
@@ -438,7 +414,6 @@
toolBar.add(label);
b.setBorder(null);
label.setBorder(null);
-
ui.installNonRolloverBorders(toolBar);
assertSame(ui.nonRolloverBorder, b.getBorder());
assertNull(label.getBorder());
@@ -449,7 +424,6 @@
Border labelBorder = label.getBorder();
toolBar.add(b);
toolBar.add(label);
-
ui.installNormalBorders(toolBar);
assertSame(bBorder, b.getBorder());
assertSame(labelBorder, label.getBorder());
@@ -460,7 +434,6 @@
toolBar.add(label);
b.setBorder(null);
label.setBorder(null);
-
ui.installRolloverBorders(toolBar);
assertSame(ui.rolloverBorder, b.getBorder());
assertNull(label.getBorder());
@@ -471,16 +444,12 @@
toolBar.add(new TestJButton());
toolBar.add(new TestJButton());
ui.focusedCompIndex = 0;
-
ui.navigateFocusedComp(SwingConstants.EAST);
assertEquals(1, ui.focusedCompIndex);
-
ui.navigateFocusedComp(SwingConstants.WEST);
assertEquals(0, ui.focusedCompIndex);
-
ui.navigateFocusedComp(SwingConstants.NORTH);
assertEquals(2, ui.focusedCompIndex);
-
ui.navigateFocusedComp(SwingConstants.SOUTH);
assertEquals(0, ui.focusedCompIndex);
}
@@ -493,15 +462,12 @@
ui.setBorderToNonRollover(b);
assertSame(ui.nonRolloverBorder, b.getBorder());
assertFalse(b.isRolloverEnabled());
-
Border border = new EmptyBorder(new Insets(0, 0, 0, 0));
b.setBorder(border);
ui.setBorderToNonRollover(b);
assertSame(border, b.getBorder());
-
ui.setBorderToNonRollover(label);
assertNull(label.getBorder());
-
ui.setBorderToNonRollover(null);
}
@@ -515,7 +481,6 @@
ui.setBorderToNormal(b);
assertSame(oldBorder, b.getBorder());
assertEquals(oldRolloverEnabled, b.isRolloverEnabled());
-
ui.setBorderToRollover(b);
b.setBorder(new BorderUIResource.LineBorderUIResource(Color.RED));
ui.setBorderToNormal(b);
@@ -527,15 +492,12 @@
ui.setBorderToRollover(b);
assertSame(ui.rolloverBorder, b.getBorder());
assertTrue(b.isRolloverEnabled());
-
Border border = new EmptyBorder(new Insets(0, 0, 0, 0));
b.setBorder(border);
ui.setBorderToRollover(b);
assertSame(border, b.getBorder());
-
ui.setBorderToRollover(label);
assertNull(label.getBorder());
-
ui.setBorderToRollover(null);
}
@@ -546,35 +508,29 @@
position1.translate(frame.getWidth() + 1, 0);
ui.dragTo(position1, origin);
Container parent = toolBar.getParent();
- Object constraint = ((BorderLayout)parent.getLayout())
- .getConstraints(toolBar);
+ Object constraint = ((BorderLayout) parent.getLayout()).getConstraints(toolBar);
ui.setFloatingLocation(position1.x, position1.y);
ui.setFloating(true, null);
assertTrue(ui.isFloating());
if (isHarmony()) {
- Point offset = SwingUtilities.convertPoint(toolBar,
- ui.dragWindow.getOffset(),
+ Point offset = SwingUtilities.convertPoint(toolBar, ui.dragWindow.getOffset(),
SwingUtilities.getWindowAncestor(toolBar));
position1.translate(-offset.x, -offset.y);
}
- assertEquals(position1,
- ui.floatingWindow.getLocation());
+ assertEquals(position1, ui.floatingWindow.getLocation());
assertTrue(ui.floatingWindow.isAncestorOf(toolBar));
assertTrue(ui.floatingWindow.isVisible());
-
ui.setFloating(false, null);
assertFalse(ui.isFloating());
assertFalse(ui.floatingWindow.isVisible());
assertSame(parent, toolBar.getParent());
- assertEquals(constraint,
- ((BorderLayout)parent.getLayout()).getConstraints(toolBar));
-
+ assertEquals(constraint, ((BorderLayout) parent.getLayout()).getConstraints(toolBar));
ui.setFloating(false, new Point(1, frame.getHeight() / 2));
assertFalse(ui.isFloating());
assertFalse(ui.floatingWindow.isVisible());
assertSame(parent, toolBar.getParent());
- assertEquals(BorderLayout.WEST,
- ((BorderLayout)parent.getLayout()).getConstraints(toolBar));
+ assertEquals(BorderLayout.WEST, ((BorderLayout) parent.getLayout())
+ .getConstraints(toolBar));
}
public void testSetFloatingLocation() {
@@ -585,11 +541,9 @@
ui.dragTo(position1, origin);
Point p = new Point(100, 200);
ui.setFloatingLocation(p.x, p.y);
-
ui.setFloating(true, null);
if (isHarmony()) {
- Point offset = SwingUtilities.convertPoint(toolBar,
- ui.dragWindow.getOffset(),
+ Point offset = SwingUtilities.convertPoint(toolBar, ui.dragWindow.getOffset(),
SwingUtilities.getWindowAncestor(toolBar));
p.translate(-offset.x, -offset.y);
}
@@ -599,14 +553,12 @@
public void testSetOrientation() {
ui.setOrientation(SwingConstants.VERTICAL);
assertEquals(SwingConstants.VERTICAL, toolBar.getOrientation());
-
ui.setOrientation(SwingConstants.HORIZONTAL);
assertEquals(SwingConstants.HORIZONTAL, toolBar.getOrientation());
}
public void testSetIsRolloverBorders() {
ui.setRolloverBorders(false);
-
toolBar.add(b);
toolBar.add(label);
b.setBorder(null);
@@ -615,7 +567,6 @@
assertSame(ui.rolloverBorder, b.getBorder());
assertNull(label.getBorder());
assertTrue(ui.isRolloverBorders());
-
b.setBorder(null);
ui.setRolloverBorders(false);
assertSame(ui.nonRolloverBorder, b.getBorder());
@@ -625,15 +576,12 @@
public void testDockingListener() {
createAndShowFrame();
BasicToolBarUI.DockingListener l = ui.new DockingListener(toolBar);
- MouseEvent e = new MouseEvent(toolBar, MouseEvent.MOUSE_DRAGGED,
- 0, 0, 0, 0, 0, false);
+ MouseEvent e = new MouseEvent(toolBar, MouseEvent.MOUSE_DRAGGED, 0, 0, 0, 0, 0, false);
l.mouseDragged(e);
assertTrue(l.isDragging);
assertFalse(new Point(0, 0).equals(l.origin));
assertTrue(ui.dragToCalled);
-
- e = new MouseEvent(toolBar, MouseEvent.MOUSE_DRAGGED,
- 0, 0, 0, 0, 1, false);
+ e = new MouseEvent(toolBar, MouseEvent.MOUSE_DRAGGED, 0, 0, 0, 0, 1, false);
l.mouseReleased(e);
assertFalse(l.isDragging);
assertTrue(ui.setFloatingCalled);
@@ -654,7 +602,6 @@
public void testPropertyListener() {
toolBar.setRollover(false);
toolBar.add(b);
-
toolBar.setRollover(true);
assertSame(ui.rolloverBorder, b.getBorder());
toolBar.setRollover(false);
@@ -664,13 +611,10 @@
public void testToolBarContListener() {
ContainerListener l = ui.createToolBarContListener();
Border border = b.getBorder();
- ContainerEvent e = new ContainerEvent(toolBar,
- ContainerEvent.COMPONENT_ADDED, b);
+ ContainerEvent e = new ContainerEvent(toolBar, ContainerEvent.COMPONENT_ADDED, b);
l.componentAdded(e);
assertNotSame(border, b.getBorder());
-
- e = new ContainerEvent(toolBar,
- ContainerEvent.COMPONENT_REMOVED, b);
+ e = new ContainerEvent(toolBar, ContainerEvent.COMPONENT_REMOVED, b);
l.componentRemoved(e);
assertSame(border, b.getBorder());
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicToolTipUITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicToolTipUITest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicToolTipUITest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicToolTipUITest.java Sun Nov 26 12:15:43 2006
@@ -20,8 +20,6 @@
*/
package javax.swing.plaf.basic;
-import java.awt.Dimension;
-
import javax.swing.JToolTip;
import javax.swing.SwingTestCase;
import javax.swing.UIManager;
@@ -29,26 +27,37 @@
public class BasicToolTipUITest extends SwingTestCase {
private BasicToolTipUI tooltipUI;
+
private JToolTip tooltip;
+ @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 "";
}
@@ -60,6 +69,7 @@
tooltipUI = new BasicToolTipUI();
}
+ @Override
protected void tearDown() throws Exception {
tooltipUI = null;
tooltip = null;