OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / libcore / luni / src / test / java / tests / org / w3c / dom / IsSupported.java
1 package tests.org.w3c.dom;
2
3 import dalvik.annotation.TestTargets;
4 import dalvik.annotation.TestLevel;
5 import dalvik.annotation.TestTargetNew;
6 import dalvik.annotation.TestTargetClass;
7
8 import java.util.ArrayList;
9 import java.util.List;
10
11 import org.w3c.dom.Document;
12 import org.w3c.dom.Node;
13
14 import javax.xml.parsers.DocumentBuilder;
15
16 /**
17  * The "feature" parameter in the isSupported(feature,version)" method is the
18  * name of the feature and the version is the version number of the feature to
19  * test. XXX is NOT a legal value for the feature parameter. The method should
20  * return "false" since XXX is not a valid feature.
21  *
22  * Retrieve the root node of the DOM document by invoking the
23  * "getDocumentElement()" method. This should create a node object on which the
24  * "isSupported(feature,version)" method is invoked with "feature" equal to
25  * "XXX" and version to "1.0". The method should return a boolean "false" since
26  * XXX is not a valid feature.
27  *
28  * @author NIST
29  * @author Mary Brady
30  * @see <a
31  *      href="http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-Node-supports">http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-Node-supports</a>
32  */
33 @TestTargetClass(Document.class)
34 public final class IsSupported extends DOMTestCase {
35
36     DOMDocumentBuilderFactory factory;
37
38     DocumentBuilder builder;
39
40     protected void setUp() throws Exception {
41         super.setUp();
42         try {
43             factory = new DOMDocumentBuilderFactory(DOMDocumentBuilderFactory
44                     .getConfiguration1());
45             builder = factory.getBuilder();
46         } catch (Exception e) {
47             fail("Unexpected exception" + e.getMessage());
48         }
49     }
50
51     protected void tearDown() throws Exception {
52         factory = null;
53         builder = null;
54         super.tearDown();
55     }
56
57     /**
58      * Runs the test case.
59      *
60      * @throws Throwable
61      *             Any uncaught exception causes test to fail
62      */
63     @TestTargetNew(
64         level = TestLevel.PARTIAL,
65         notes = "Verifies that isSupported method returns false.",
66         method = "isSupported",
67         args = {java.lang.String.class, java.lang.String.class}
68     )
69     public void testIsSupported1() throws Throwable {
70         Document doc;
71         Node rootNode;
72         boolean state;
73         doc = (Document) load("staff", builder);
74         rootNode = doc.getDocumentElement();
75         state = rootNode.isSupported("XXX", "1.0");
76         assertFalse("throw_False", state);
77     }
78     @TestTargetNew(
79         level = TestLevel.PARTIAL,
80         notes = "Verifies that isSupported method returns false value.",
81         method = "isSupported",
82         args = {java.lang.String.class, java.lang.String.class}
83     )
84     public void testIsSupported2() throws Throwable {
85         Document doc;
86         Node rootNode;
87         boolean state;
88         doc = (Document) load("staff", builder);
89         rootNode = doc.getDocumentElement();
90         state = rootNode.isSupported("XML", "9.0");
91         assertFalse("throw_False", state);
92     }
93     @TestTargetNew(
94         level = TestLevel.PARTIAL,
95         notes = "Verifies that isSupported method returns true value.",
96         method = "isSupported",
97         args = {java.lang.String.class, java.lang.String.class}
98     )
99     public void testIsSupported4() throws Throwable {
100         Document doc;
101         Node rootNode;
102         boolean state;
103         doc = (Document) load("staff", builder);
104         rootNode = doc.getDocumentElement();
105         state = rootNode.isSupported("xml", "1.0");
106         assertTrue("throw_True", state);
107     }
108     @TestTargetNew(
109         level = TestLevel.PARTIAL,
110         notes = "Verifies that isSupported method returns true value.",
111         method = "isSupported",
112         args = {java.lang.String.class, java.lang.String.class}
113     )
114     public void testIsSupported5() throws Throwable {
115         Document doc;
116         Node rootNode;
117         boolean state;
118         doc = (Document) load("staff", builder);
119         rootNode = doc.getDocumentElement();
120         state = rootNode.isSupported("core", "2.0");
121         assertTrue("throw_True", state);
122     }
123     @TestTargetNew(
124         level = TestLevel.PARTIAL,
125         notes = "Verifies that isSupported method returns true value.",
126         method = "isSupported",
127         args = {java.lang.String.class, java.lang.String.class}
128     )
129     public void testIsSupported6() throws Throwable {
130         Document doc;
131         Node rootNode;
132         boolean state;
133         doc = (Document) load("staff", builder);
134         rootNode = doc.getDocumentElement();
135         state = rootNode.isSupported("xml", "2.0");
136         assertTrue("throw_True", state);
137     }
138     @TestTargetNew(
139         level = TestLevel.PARTIAL,
140         notes = "Verifies that isSupported method returns true value.",
141         method = "isSupported",
142         args = {java.lang.String.class, java.lang.String.class}
143     )
144     public void testIsSupported7() throws Throwable {
145         Document doc;
146         Node rootNode;
147         boolean state;
148         doc = (Document) load("staff", builder);
149         rootNode = doc.getDocumentElement();
150         state = rootNode.isSupported("XML", "");
151         assertTrue("throw_True", state);
152     }
153     @TestTargetNew(
154         level = TestLevel.PARTIAL,
155         notes = "Verifies that isSupported method returns true value.",
156         method = "isSupported",
157         args = {java.lang.String.class, java.lang.String.class}
158     )
159     public void testIsSupported9() throws Throwable {
160         Document doc;
161         Node rootNode;
162         boolean state;
163         doc = (Document) load("staff", builder);
164         rootNode = doc.getDocumentElement();
165         state = rootNode.isSupported("XML", "1.0");
166         assertTrue("throw_True", state);
167     }
168     @TestTargetNew(
169         level = TestLevel.PARTIAL,
170         notes = "Verifies that isSupported method returns true.",
171         method = "isSupported",
172         args = {java.lang.String.class, java.lang.String.class}
173     )
174     public void testIsSupported10() throws Throwable {
175         Document doc;
176         Node rootNode;
177         boolean state;
178         doc = (Document) load("staff", builder);
179         rootNode = doc.getDocumentElement();
180         state = rootNode.isSupported("CORE", "2.0");
181         assertTrue("throw_True", state);
182     }
183     @TestTargetNew(
184         level = TestLevel.PARTIAL,
185         notes = "Verifies that isSupported method returns true.",
186         method = "isSupported",
187         args = {java.lang.String.class, java.lang.String.class}
188     )
189     public void testIsSupported11() throws Throwable {
190         Document doc;
191         Node rootNode;
192         boolean state;
193         doc = (Document) load("staff", builder);
194         rootNode = doc.getDocumentElement();
195         state = rootNode.isSupported("XML", "2.0");
196         assertTrue("throw_True", state);
197     }
198
199     @TestTargetNew(
200         level = TestLevel.PARTIAL,
201         notes = "",
202         method = "isSupported",
203         args = {java.lang.String.class, java.lang.String.class}
204     )
205     public void testIsSupported12() throws Throwable {
206         List<String> features = new ArrayList<String>();
207         features.add("Core");
208         features.add("XML");
209         features.add("HTML");
210         features.add("Views");
211         features.add("StyleSheets");
212         features.add("CSS");
213         features.add("CSS2");
214         features.add("Events");
215         features.add("UIEvents");
216         features.add("MouseEvents");
217         features.add("MutationEvents");
218         features.add("HTMLEvents");
219         features.add("Range");
220         features.add("Traversal");
221         features.add("bogus.bogus.bogus");
222
223         Document doc;
224         Node rootNode;
225         String featureElement;
226         boolean state;
227         doc = (Document) load("staff", builder);
228         rootNode = doc.getDocumentElement();
229         state = rootNode.isSupported("Core", "2.0");
230         assertTrue("Core2", state);
231         for (int indexN10078 = 0; indexN10078 < features.size(); indexN10078++) {
232             featureElement = (String) features.get(indexN10078);
233             state = rootNode.isSupported(featureElement, "1.0");
234         }
235         for (int indexN10083 = 0; indexN10083 < features.size(); indexN10083++) {
236             featureElement = (String) features.get(indexN10083);
237             state = rootNode.isSupported(featureElement, "2.0");
238         }
239     }
240     @TestTargetNew(
241         level = TestLevel.PARTIAL,
242         notes = "Verifies that isSupported method returns correct value if it has empty string as a version parameter.",
243         method = "isSupported",
244         args = {java.lang.String.class, java.lang.String.class}
245     )
246     public void testIsSupported13() throws Throwable {
247         Document doc;
248         Node rootNode;
249         boolean state;
250         doc = (Document) load("staff", builder);
251         rootNode = doc.getDocumentElement();
252         state = rootNode.isSupported("Core", "");
253         assertTrue("Core", state);
254     }
255     @TestTargetNew(
256         level = TestLevel.PARTIAL,
257         notes = "Verifies that isSupported method returns correct value if it has null as a version parameter.",
258         method = "isSupported",
259         args = {java.lang.String.class, java.lang.String.class}
260     )
261     public void testIsSupported14() throws Throwable {
262         Document doc;
263         Node rootNode;
264         boolean state;
265         String nullString = null;
266
267         doc = (Document) load("staff", builder);
268         rootNode = doc.getDocumentElement();
269         state = rootNode.isSupported("Core", nullString);
270         assertTrue("Core", state);
271     }
272 }