1
1
/*
2
- * Copyright (c) 2013, 2016 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2013, 2019 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
24
24
/*
25
25
* @test
26
26
* @key headful
27
- * @bug 8007146
27
+ * @bug 8007146 8213119
28
28
* @summary [macosx] Setting a display mode crashes JDK under VNC
29
- * @author Alexander Scherbatiy
30
- * @run main CheckDisplayModes
31
29
*/
32
30
import java .awt .DisplayMode ;
33
31
import java .awt .GraphicsDevice ;
@@ -37,27 +35,28 @@ public class CheckDisplayModes {
37
35
38
36
public static void main (String [] args ) {
39
37
GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment ();
40
- GraphicsDevice graphicDevice = ge .getDefaultScreenDevice ();
41
- if (!graphicDevice .isDisplayChangeSupported ()) {
42
- System .err .println ("Display mode change is not supported on this host. Test is considered passed." );
43
- return ;
44
- }
45
- DisplayMode defaultDisplayMode = graphicDevice .getDisplayMode ();
46
- checkDisplayMode (defaultDisplayMode );
47
- graphicDevice .setDisplayMode (defaultDisplayMode );
38
+ for ( GraphicsDevice graphicDevice : ge .getScreenDevices ()) {
39
+ if (!graphicDevice .isDisplayChangeSupported ()) {
40
+ System .err .println ("Display mode change is not supported on this host. Test is considered passed." );
41
+ continue ;
42
+ }
43
+ DisplayMode defaultDisplayMode = graphicDevice .getDisplayMode ();
44
+ checkDisplayMode (defaultDisplayMode );
45
+ graphicDevice .setDisplayMode (defaultDisplayMode );
48
46
49
- DisplayMode [] displayModes = graphicDevice .getDisplayModes ();
50
- boolean isDefaultDisplayModeIncluded = false ;
51
- for (DisplayMode displayMode : displayModes ) {
52
- checkDisplayMode (displayMode );
53
- graphicDevice .setDisplayMode (displayMode );
54
- if (defaultDisplayMode .equals (displayMode )) {
55
- isDefaultDisplayModeIncluded = true ;
47
+ DisplayMode [] displayModes = graphicDevice .getDisplayModes ();
48
+ boolean isDefaultDisplayModeIncluded = false ;
49
+ for (DisplayMode displayMode : displayModes ) {
50
+ checkDisplayMode (displayMode );
51
+ graphicDevice .setDisplayMode (displayMode );
52
+ if (defaultDisplayMode .equals (displayMode )) {
53
+ isDefaultDisplayModeIncluded = true ;
54
+ }
56
55
}
57
- }
58
56
59
- if (!isDefaultDisplayModeIncluded ) {
60
- throw new RuntimeException ("Default display mode is not included" );
57
+ if (!isDefaultDisplayModeIncluded ) {
58
+ throw new RuntimeException ("Default display mode is not included" );
59
+ }
61
60
}
62
61
}
63
62
0 commit comments