test/java/awt/Toolkit/DynamicLayout/bug7172833.java

Print this page




   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 
  25 import java.awt.*;

  26 import java.awt.datatransfer.Clipboard;
  27 import java.awt.dnd.DragGestureEvent;
  28 import java.awt.dnd.InvalidDnDOperationException;
  29 import java.awt.dnd.peer.DragSourceContextPeer;
  30 import java.awt.font.TextAttribute;
  31 import java.awt.im.InputMethodHighlight;
  32 import java.awt.image.ColorModel;
  33 import java.awt.image.ImageObserver;
  34 import java.awt.image.ImageProducer;
  35 import java.awt.peer.*;
  36 import java.net.URL;
  37 import java.util.Map;
  38 import java.util.Properties;
  39 
  40 
  41 /**
  42  * @test
  43  * @bug 7172833
  44  * @summary java.awt.Toolkit methods is/setDynamicLayout() should be consistent.
  45  * @author Sergey Bylokhov
  46  */
  47 public final class bug7172833 {
  48 
  49     public static void main(final String[] args) throws Exception {
  50         final StubbedToolkit t = new StubbedToolkit();
  51 
  52         t.setDynamicLayout(true);
  53         if(!t.isDynamicLayoutSet()){
  54             throw new RuntimeException("'true' expected but 'false' returned");
  55         }
  56 
  57         t.setDynamicLayout(false);
  58         if(t.isDynamicLayoutSet()){
  59             throw new RuntimeException("'false' expected but 'true' returned");
  60         }
  61     }
  62 
  63     static final class StubbedToolkit extends Toolkit {
  64 
  65         @Override
  66         protected boolean isDynamicLayoutSet() throws HeadlessException {
  67             return super.isDynamicLayoutSet();
  68         }
  69 
  70         @Override
  71         protected DesktopPeer createDesktopPeer(final Desktop target)
  72                 throws HeadlessException {
  73             return null;
  74         }
  75 
  76         @Override
  77         protected ButtonPeer createButton(final Button target)
  78                 throws HeadlessException {
  79             return null;
  80         }
  81 
  82         @Override
  83         protected TextFieldPeer createTextField(final TextField target)
  84                 throws HeadlessException {
  85             return null;
  86         }
  87 
  88         @Override
  89         protected LabelPeer createLabel(final Label target) throws HeadlessException {
  90             return null;
  91         }
  92 
  93         @Override
  94         protected ListPeer createList(final List target) throws HeadlessException {
  95             return null;
  96         }
  97 
  98         @Override
  99         protected CheckboxPeer createCheckbox(final Checkbox target)
 100                 throws HeadlessException {
 101             return null;
 102         }
 103 
 104         @Override
 105         protected ScrollbarPeer createScrollbar(final Scrollbar target)
 106                 throws HeadlessException {
 107             return null;
 108         }
 109 
 110         @Override
 111         protected ScrollPanePeer createScrollPane(final ScrollPane target)
 112                 throws HeadlessException {
 113             return null;
 114         }
 115 
 116         @Override
 117         protected TextAreaPeer createTextArea(final TextArea target)
 118                 throws HeadlessException {
 119             return null;
 120         }
 121 
 122         @Override
 123         protected ChoicePeer createChoice(final Choice target)
 124                 throws HeadlessException {
 125             return null;
 126         }
 127 
 128         @Override
 129         protected FramePeer createFrame(final Frame target) throws HeadlessException {
 130             return null;
 131         }
 132 
 133         @Override
 134         protected CanvasPeer createCanvas(final Canvas target) {
 135             return null;
 136         }
 137 
 138         @Override
 139         protected PanelPeer createPanel(final Panel target) {
 140             return null;
 141         }
 142 
 143         @Override
 144         protected WindowPeer createWindow(final Window target)
 145                 throws HeadlessException {
 146             return null;
 147         }
 148 
 149         @Override
 150         protected DialogPeer createDialog(final Dialog target)
 151                 throws HeadlessException {
 152             return null;
 153         }
 154 
 155         @Override
 156         protected MenuBarPeer createMenuBar(final MenuBar target)
 157                 throws HeadlessException {
 158             return null;
 159         }
 160 
 161         @Override
 162         protected MenuPeer createMenu(final Menu target) throws HeadlessException {
 163             return null;
 164         }
 165 
 166         @Override
 167         protected PopupMenuPeer createPopupMenu(final PopupMenu target)
 168                 throws HeadlessException {
 169             return null;
 170         }
 171 
 172         @Override
 173         protected MenuItemPeer createMenuItem(final MenuItem target)
 174                 throws HeadlessException {
 175             return null;
 176         }
 177 
 178         @Override
 179         protected FileDialogPeer createFileDialog(final FileDialog target)
 180                 throws HeadlessException {
 181             return null;
 182         }
 183 
 184         @Override
 185         protected CheckboxMenuItemPeer createCheckboxMenuItem(
 186                 final CheckboxMenuItem target) throws HeadlessException {
 187             return null;
 188         }
 189 
 190         @Override
 191         protected FontPeer getFontPeer(final String name, final int style) {
 192             return null;
 193         }
 194 
 195         @Override
 196         public Dimension getScreenSize() throws HeadlessException {
 197             return null;
 198         }
 199 
 200         @Override
 201         public int getScreenResolution() throws HeadlessException {
 202             return 0;
 203         }
 204 
 205         @Override
 206         public ColorModel getColorModel() throws HeadlessException {
 207             return null;
 208         }
 209 
 210         @Override
 211         public String[] getFontList() {
 212             return new String[0];
 213         }


 271                                     final Properties props) {
 272             return null;
 273         }
 274 
 275         @Override
 276         public void beep() {
 277 
 278         }
 279 
 280         @Override
 281         public Clipboard getSystemClipboard() throws HeadlessException {
 282             return null;
 283         }
 284 
 285         @Override
 286         protected EventQueue getSystemEventQueueImpl() {
 287             return null;
 288         }
 289 
 290         @Override
 291         public DragSourceContextPeer createDragSourceContextPeer(
 292                 final DragGestureEvent dge) throws InvalidDnDOperationException {
 293             return null;
 294         }
 295 
 296         @Override
 297         public boolean isModalityTypeSupported(
 298                 final Dialog.ModalityType modalityType) {
 299             return false;
 300         }
 301 
 302         @Override
 303         public boolean isModalExclusionTypeSupported(
 304                 final Dialog.ModalExclusionType modalExclusionType) {
 305             return false;
 306         }
 307 
 308         @Override
 309         public Map<TextAttribute, ?> mapInputMethodHighlight(
 310                 final InputMethodHighlight highlight) throws HeadlessException {
 311             return null;
 312         }
 313     }
 314 }


   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 
  25 import java.awt.*;
  26 import java.awt.Frame;
  27 import java.awt.datatransfer.Clipboard;



  28 import java.awt.font.TextAttribute;
  29 import java.awt.im.InputMethodHighlight;
  30 import java.awt.image.ColorModel;
  31 import java.awt.image.ImageObserver;
  32 import java.awt.image.ImageProducer;

  33 import java.net.URL;
  34 import java.util.Map;
  35 import java.util.Properties;
  36 
  37 
  38 /**
  39  * @test
  40  * @bug 7172833
  41  * @summary java.awt.Toolkit methods is/setDynamicLayout() should be consistent.
  42  * @author Sergey Bylokhov
  43  */
  44 public final class bug7172833 {
  45 
  46     public static void main(final String[] args) throws Exception {
  47         final StubbedToolkit t = new StubbedToolkit();
  48 
  49         t.setDynamicLayout(true);
  50         if(!t.isDynamicLayoutSet()){
  51             throw new RuntimeException("'true' expected but 'false' returned");
  52         }
  53 
  54         t.setDynamicLayout(false);
  55         if(t.isDynamicLayoutSet()){
  56             throw new RuntimeException("'false' expected but 'true' returned");
  57         }
  58     }
  59 
  60     static final class StubbedToolkit extends Toolkit {
  61 
  62         @Override
  63         protected boolean isDynamicLayoutSet() throws HeadlessException {
  64             return super.isDynamicLayoutSet();
  65         }
  66 




























































































































  67 
  68         @Override
  69         public Dimension getScreenSize() throws HeadlessException {
  70             return null;
  71         }
  72 
  73         @Override
  74         public int getScreenResolution() throws HeadlessException {
  75             return 0;
  76         }
  77 
  78         @Override
  79         public ColorModel getColorModel() throws HeadlessException {
  80             return null;
  81         }
  82 
  83         @Override
  84         public String[] getFontList() {
  85             return new String[0];
  86         }


 144                                     final Properties props) {
 145             return null;
 146         }
 147 
 148         @Override
 149         public void beep() {
 150 
 151         }
 152 
 153         @Override
 154         public Clipboard getSystemClipboard() throws HeadlessException {
 155             return null;
 156         }
 157 
 158         @Override
 159         protected EventQueue getSystemEventQueueImpl() {
 160             return null;
 161         }
 162 
 163         @Override






 164         public boolean isModalityTypeSupported(
 165                 final Dialog.ModalityType modalityType) {
 166             return false;
 167         }
 168 
 169         @Override
 170         public boolean isModalExclusionTypeSupported(
 171                 final Dialog.ModalExclusionType modalExclusionType) {
 172             return false;
 173         }
 174 
 175         @Override
 176         public Map<TextAttribute, ?> mapInputMethodHighlight(
 177                 final InputMethodHighlight highlight) throws HeadlessException {
 178             return null;
 179         }
 180     }
 181 }