Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/print/attribute/Services_getDocFl.java
41152 views
1
/*
2
* Copyright (c) 2015, 2016, 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
import javax.print.DocFlavor;
25
import javax.print.PrintService;
26
import javax.print.PrintServiceLookup;
27
import javax.print.attribute.HashPrintRequestAttributeSet;
28
29
/*
30
* @test
31
* @bug 4901243 8040139 8167291
32
* @summary JPG, GIF, and PNG DocFlavors (URL) should be supported if Postscript is supported.
33
* @run main Services_getDocFl
34
*/
35
36
37
public class Services_getDocFl {
38
public static void main (String [] args) {
39
40
HashPrintRequestAttributeSet prSet = null;
41
boolean psSupported = false,
42
pngImagesSupported = false,
43
gifImagesSupported = false,
44
jpgImagesSupported = false;
45
String mimeType;
46
47
PrintService[] serv = PrintServiceLookup.lookupPrintServices(null, null);
48
if (serv.length==0) {
49
System.out.println("no PrintService found");
50
} else {
51
System.out.println("number of Services "+serv.length);
52
}
53
54
55
for (int i = 0; i<serv.length ;i++) {
56
System.out.println(" PRINT SERVICE: "+ i+" "+serv[i]);
57
DocFlavor[] flavors = serv[i].getSupportedDocFlavors();
58
pngImagesSupported = false;
59
gifImagesSupported = false;
60
jpgImagesSupported = false;
61
psSupported = false;
62
for (int j=0; j<flavors.length; j++) {
63
System.out.println(flavors[j]);
64
65
if (flavors[j].equals(DocFlavor.URL.PNG)) {
66
pngImagesSupported = true;
67
} else if (flavors[j].equals(DocFlavor.URL.GIF)) {
68
gifImagesSupported = true;
69
} else if (flavors[j].equals(DocFlavor.URL.JPEG)) {
70
jpgImagesSupported = true;
71
} else if (flavors[j].getMimeType().indexOf("postscript") != -1) {
72
psSupported = true;
73
}
74
}
75
76
if (psSupported && !(pngImagesSupported && gifImagesSupported &&
77
jpgImagesSupported)) {
78
79
throw new RuntimeException("Error: URL image DocFlavors are not reported as supported");
80
}
81
}
82
83
}
84
}
85
86
87