1 /* 2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 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 } 87 88 @Override 89 public FontMetrics getFontMetrics(final Font font) { 90 return null; 91 } 92 93 @Override 94 public void sync() { 95 96 } 97 98 @Override 99 public Image getImage(final String filename) { 100 return null; 101 } 102 103 @Override 104 public Image getImage(final URL url) { 105 return null; 106 } 107 108 @Override 109 public Image createImage(final String filename) { 110 return null; 111 } 112 113 @Override 114 public Image createImage(final URL url) { 115 return null; 116 } 117 118 @Override 119 public boolean prepareImage( 120 final Image image, final int width, final int height, 121 final ImageObserver observer) { 122 return false; 123 } 124 125 @Override 126 public int checkImage(final Image image, final int width, final int height, 127 final ImageObserver observer) { 128 return 0; 129 } 130 131 @Override 132 public Image createImage(final ImageProducer producer) { 133 return null; 134 } 135 136 @Override 137 public Image createImage(final byte[] imagedata, final int imageoffset, 138 final int imagelength) { 139 return null; 140 } 141 142 @Override 143 public PrintJob getPrintJob(final Frame frame, final String jobtitle, 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 }