1 package tests.org.w3c.dom;
3 import dalvik.annotation.TestTargets;
4 import dalvik.annotation.TestLevel;
5 import dalvik.annotation.TestTargetNew;
6 import dalvik.annotation.TestTargetClass;
8 import java.util.ArrayList;
11 import org.w3c.dom.Document;
12 import org.w3c.dom.Node;
14 import javax.xml.parsers.DocumentBuilder;
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.
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.
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>
33 @TestTargetClass(Document.class)
34 public final class IsSupported extends DOMTestCase {
36 DOMDocumentBuilderFactory factory;
38 DocumentBuilder builder;
40 protected void setUp() throws Exception {
43 factory = new DOMDocumentBuilderFactory(DOMDocumentBuilderFactory
44 .getConfiguration1());
45 builder = factory.getBuilder();
46 } catch (Exception e) {
47 fail("Unexpected exception" + e.getMessage());
51 protected void tearDown() throws Exception {
61 * Any uncaught exception causes test to fail
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}
69 public void testIsSupported1() throws Throwable {
73 doc = (Document) load("staff", builder);
74 rootNode = doc.getDocumentElement();
75 state = rootNode.isSupported("XXX", "1.0");
76 assertFalse("throw_False", state);
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}
84 public void testIsSupported2() throws Throwable {
88 doc = (Document) load("staff", builder);
89 rootNode = doc.getDocumentElement();
90 state = rootNode.isSupported("XML", "9.0");
91 assertFalse("throw_False", state);
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}
99 public void testIsSupported4() throws Throwable {
103 doc = (Document) load("staff", builder);
104 rootNode = doc.getDocumentElement();
105 state = rootNode.isSupported("xml", "1.0");
106 assertTrue("throw_True", state);
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}
114 public void testIsSupported5() throws Throwable {
118 doc = (Document) load("staff", builder);
119 rootNode = doc.getDocumentElement();
120 state = rootNode.isSupported("core", "2.0");
121 assertTrue("throw_True", state);
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}
129 public void testIsSupported6() throws Throwable {
133 doc = (Document) load("staff", builder);
134 rootNode = doc.getDocumentElement();
135 state = rootNode.isSupported("xml", "2.0");
136 assertTrue("throw_True", state);
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}
144 public void testIsSupported7() throws Throwable {
148 doc = (Document) load("staff", builder);
149 rootNode = doc.getDocumentElement();
150 state = rootNode.isSupported("XML", "");
151 assertTrue("throw_True", state);
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}
159 public void testIsSupported9() throws Throwable {
163 doc = (Document) load("staff", builder);
164 rootNode = doc.getDocumentElement();
165 state = rootNode.isSupported("XML", "1.0");
166 assertTrue("throw_True", state);
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}
174 public void testIsSupported10() throws Throwable {
178 doc = (Document) load("staff", builder);
179 rootNode = doc.getDocumentElement();
180 state = rootNode.isSupported("CORE", "2.0");
181 assertTrue("throw_True", state);
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}
189 public void testIsSupported11() throws Throwable {
193 doc = (Document) load("staff", builder);
194 rootNode = doc.getDocumentElement();
195 state = rootNode.isSupported("XML", "2.0");
196 assertTrue("throw_True", state);
200 level = TestLevel.PARTIAL,
202 method = "isSupported",
203 args = {java.lang.String.class, java.lang.String.class}
205 public void testIsSupported12() throws Throwable {
206 List<String> features = new ArrayList<String>();
207 features.add("Core");
209 features.add("HTML");
210 features.add("Views");
211 features.add("StyleSheets");
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");
225 String featureElement;
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");
235 for (int indexN10083 = 0; indexN10083 < features.size(); indexN10083++) {
236 featureElement = (String) features.get(indexN10083);
237 state = rootNode.isSupported(featureElement, "2.0");
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}
246 public void testIsSupported13() throws Throwable {
250 doc = (Document) load("staff", builder);
251 rootNode = doc.getDocumentElement();
252 state = rootNode.isSupported("Core", "");
253 assertTrue("Core", state);
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}
261 public void testIsSupported14() throws Throwable {
265 String nullString = null;
267 doc = (Document) load("staff", builder);
268 rootNode = doc.getDocumentElement();
269 state = rootNode.isSupported("Core", nullString);
270 assertTrue("Core", state);