java/awt/FullScreen/NonExistentDisplayModeTest/NonExistentDisplayModeTest.java
Print this page
@@ -1,21 +1,45 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.DisplayMode;
+import java.awt.Frame;
+import java.awt.GraphicsDevice;
+import java.util.ArrayList;
+import java.util.Random;
+
+import static java.awt.DisplayMode.REFRESH_RATE_UNKNOWN;
+
/**
* @test
* @bug 6430607
* @summary Test that we throw an exception for incorrect display modes
* @author Dmitri.Trembovetski@Sun.COM area=FullScreen
* @run main/othervm NonExistentDisplayModeTest
* @run main/othervm -Dsun.java2d.noddraw=true NonExistentDisplayModeTest
* @run main/othervm -Dsun.java2d.opengl=true NonExistentDisplayModeTest
*/
-
-import java.awt.DisplayMode;
-import java.awt.Frame;
-import java.awt.GraphicsDevice;
-import java.util.ArrayList;
-import java.util.Random;
-
public class NonExistentDisplayModeTest {
public static void main(String[] args) {
new NonExistentDisplayModeTest().start();
}
@@ -31,10 +55,11 @@
}
gd.setFullScreenWindow(f);
if (!gd.isDisplayChangeSupported()) {
System.out.println("DisplayMode change not supported, test passed.");
+ f.dispose();
return;
}
DisplayMode dms[] = gd.getDisplayModes();
ArrayList<DisplayMode> dmList = new ArrayList<DisplayMode>(dms.length);
@@ -90,14 +115,16 @@
newList.add(newDM);
}
break;
}
case 2: {
+ if (dm.getRefreshRate() != REFRESH_RATE_UNKNOWN) {
DisplayMode newDM = deriveRR(dm);
if (!dmList.contains(newDM)) {
newList.add(newDM);
}
+ }
break;
}
}
}
return newList;