1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
|
// Tags: GUI JDK1.2
// Copyright (C) 2005, 2006, Red Hat
// This file is part of Mauve.
// Mauve is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or (at your option)
// any later version.
// Mauve is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Mauve; see the file COPYING. If not, write to the
// Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
// 02110-1301 USA.
package gnu.testlet.java.awt.Component;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.awt.Color;
import java.awt.Component;
import java.awt.ComponentOrientation;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.dnd.DropTarget;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Locale;
/**
* Check if bound properties are firing PropertyChangeEvents and
* simple properties not.
*
* @author Roman Kennke (roman@ontographics.com)
*/
public class properties implements Testlet
{
/**
* stores the name of a fired property or <code>null</code> of none has
* been fired.
*/
private String propertyName;
/**
* Non abstract subclass of Component to allow instatiation.
*/
public class TestComponent extends Component {
}
public void test (TestHarness harness)
{
// prepare test component
Component comp = new TestComponent();
comp.addPropertyChangeListener(new PropertyChangeListener() {
// sets <code>propertyName</code> when called
public void propertyChange(PropertyChangeEvent ev) {
propertyName = ev.getPropertyName();
}
});
// check 'background' property (must be fired)
propertyName = null;
comp.setBackground(Color.YELLOW);
harness.check(propertyName, "background", "Property: background");
// check 'bounds' property (must not be fired)
propertyName = null;
comp.setBounds(new Rectangle(143, 564, 1200, 2233));
harness.check(propertyName, null, "Property: bounds");
// check 'componentOrientation' property (should be fired)
propertyName = null;
comp.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
// do second call to assure that the property actually changes
comp.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
harness.check(propertyName, "componentOrientation",
"Property: componentOrientation");
// check 'cursor' property (must not be fired)
propertyName = null;
comp.setCursor(new Cursor(Cursor.HAND_CURSOR));
harness.check(propertyName, null, "Property: cursor");
// check 'dropTarget' property (must not be fired)
propertyName = null;
comp.setDropTarget(new DropTarget());
harness.check(propertyName, null, "Property: dropTarget");
// check 'enabled' property (must not be fired)
propertyName = null;
comp.setEnabled(true);
comp.setEnabled(false);
harness.check(propertyName, null, "Property: enabled");
// check 'font' property (must be fired)
propertyName = null;
comp.setFont(new Font("Monospaced", Font.PLAIN, 12));
harness.check(propertyName, "font", "Property: font");
// check 'foreground' property (must be fired)
propertyName = null;
comp.setForeground(Color.CYAN);
harness.check(propertyName, "foreground", "Property: foreground");
// check 'locale' property (must be fired)
propertyName = null;
comp.setLocale(Locale.CHINESE);
comp.setLocale(Locale.GERMAN);
harness.check(propertyName, "locale", "Property: locale");
// check 'location' property (must not be fired)
propertyName = null;
comp.setLocation(new Point(123, 456));
harness.check(propertyName, null, "Property: location");
// check 'name' property (must be fired)
propertyName = null;
comp.setName("Obelix");
harness.check(propertyName, "name", "Property: name");
// check 'size' property (must not be fired)
propertyName = null;
comp.setSize(new Dimension(987, 654));
harness.check(propertyName, null, "Property: size");
// check 'visible' property (must not be fired)
propertyName = null;
comp.setVisible(true);
comp.setVisible(false);
harness.check(propertyName, null, "Property: visible");
}
}
|