Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/print/attribute/SidesPageRangesTest.java
38838 views
1
/*
2
* Copyright (c) 2003, 2010, 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
* @test
25
* @bug 4903366
26
* @summary No crash should occur.
27
* @run main SidesPageRangesTest
28
*/
29
import java.awt.*;
30
import javax.print.*;
31
import javax.print.attribute.standard.*;
32
import javax.print.attribute.*;
33
import java.io.*;
34
import java.util.Locale;
35
import java.net.URL;
36
37
public class SidesPageRangesTest {
38
/**
39
* Constructor
40
*/
41
public SidesPageRangesTest() {
42
super();
43
}
44
/**
45
* Starts the application.
46
*/
47
public static void main(java.lang.String[] args) {
48
SidesPageRangesTest pd = new SidesPageRangesTest();
49
PrintService defService = null;
50
DocFlavor flavors[] = null;
51
PrintService[] pservice;
52
defService = PrintServiceLookup.lookupDefaultPrintService();
53
if (defService == null) {
54
pservice = PrintServiceLookup.lookupPrintServices(null, null);
55
if (pservice.length == 0) {
56
throw new RuntimeException("Printer is required for this test. TEST ABORTED");
57
}
58
defService = pservice[0];
59
}
60
System.out.println("Default Print Service "+defService);
61
62
63
if (defService.isAttributeCategorySupported(PageRanges.class)) {
64
System.out.println("\nPageRanges Attribute category is supported");
65
} else {
66
System.out.println("\nPageRanges Attribute category is not supported. terminating...");
67
return;
68
}
69
70
flavors = defService.getSupportedDocFlavors();
71
System.out.println("\nGetting Supported values for PageRanges for each supported DocFlavor");
72
System.out.println("===============================================================\n");
73
for (int y = 0; y < flavors.length; y ++) {
74
System.out.println("\n\n");
75
76
System.out.println("Doc Flavor: "+flavors[y]);
77
System.out.println("-----------------------------");
78
79
Object vals = defService.getSupportedAttributeValues(PageRanges.class, flavors[y], null);
80
if (vals == null) {
81
System.out.println("No supported values for PageRanges for this doc flavor. ");
82
}
83
84
PageRanges[] pr = null;
85
if (vals instanceof PageRanges[]) {
86
pr = (PageRanges[]) vals;
87
for (int x = 0; x < pr.length; x ++) {
88
System.out.println("\nSupported Value "+pr[x]);
89
System.out.println("is "+pr[x]+" value supported? "+defService.isAttributeValueSupported(pr[x], flavors[y], null));
90
91
if (!defService.isAttributeValueSupported(pr[x], flavors[y], null)) {
92
throw new RuntimeException("PageRanges contradicts getSupportedAttributeValues");
93
}
94
}
95
} else if (vals instanceof PageRanges) {
96
System.out.println(vals);
97
System.out.println("is "+vals+" value supported? "+defService.isAttributeValueSupported((javax.print.attribute.Attribute)vals, flavors[y], null));
98
if (!defService.isAttributeValueSupported((javax.print.attribute.Attribute)vals, flavors[y], null)) {
99
throw new RuntimeException("PageRanges contradicts getSupportedAttributeValues");
100
}
101
}
102
103
// SIDES test
104
vals = defService.getSupportedAttributeValues(Sides.class, flavors[y], null);
105
if (vals == null) {
106
System.out.println("No supported values for Sides for this doc flavor. ");
107
}
108
109
Sides[] s = null;
110
if (vals instanceof Sides[]) {
111
s = (Sides[]) vals;
112
for (int x = 0; x < s.length; x ++) {
113
System.out.println("\nSupported Value "+s[x]);
114
System.out.println("is "+s[x]+" value supported? "+defService.isAttributeValueSupported(s[x], flavors[y], null));
115
if (!defService.isAttributeValueSupported(s[x], flavors[y], null)) {
116
throw new RuntimeException("Sides contradicts getSupportedAttributeValues");
117
}
118
}
119
}
120
}
121
}
122
}
123
124