001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: /**
018: * @author Alexey A. Ivanov
019: * @version $Revision$
020: */package javax.swing.text.html;
021:
022: import javax.swing.BasicSwingTestCase;
023: import javax.swing.text.MutableAttributeSet;
024: import javax.swing.text.SimpleAttributeSet;
025: import javax.swing.text.html.CSS.Attribute;
026:
027: import junit.framework.TestCase;
028:
029: public class StyleSheet_ConvertAttr_ListStyleTest extends TestCase {
030: private StyleSheet ss;
031: private MutableAttributeSet simple;
032: private Object cssValue;
033:
034: protected void setUp() throws Exception {
035: super .setUp();
036: ss = new StyleSheet();
037: simple = new SimpleAttributeSet();
038: }
039:
040: public void testListStyle01() throws Exception {
041: ss.addCSSAttribute(simple, Attribute.LIST_STYLE, "none");
042: if (!BasicSwingTestCase.isHarmony()) {
043: assertEquals(1, simple.getAttributeCount());
044: cssValue = simple.getAttribute(Attribute.LIST_STYLE);
045: assertEquals("none", cssValue.toString());
046: return;
047: }
048:
049: assertEquals(3, simple.getAttributeCount());
050:
051: cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
052: assertEquals("none", cssValue.toString());
053: cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
054: assertEquals("outside", cssValue.toString());
055: cssValue = simple.getAttribute(Attribute.LIST_STYLE_IMAGE);
056: assertEquals("none", cssValue.toString());
057: }
058:
059: public void testListStyle02() throws Exception {
060: ss.addCSSAttribute(simple, Attribute.LIST_STYLE, "disc");
061: if (!BasicSwingTestCase.isHarmony()) {
062: assertEquals(1, simple.getAttributeCount());
063: cssValue = simple.getAttribute(Attribute.LIST_STYLE);
064: assertEquals("disc", cssValue.toString());
065: return;
066: }
067:
068: assertEquals(3, simple.getAttributeCount());
069:
070: cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
071: assertEquals("disc", cssValue.toString());
072: cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
073: assertEquals("outside", cssValue.toString());
074: cssValue = simple.getAttribute(Attribute.LIST_STYLE_IMAGE);
075: assertEquals("none", cssValue.toString());
076: }
077:
078: public void testListStyle03() throws Exception {
079: ss.addCSSAttribute(simple, Attribute.LIST_STYLE, "decimal");
080: if (!BasicSwingTestCase.isHarmony()) {
081: assertEquals(1, simple.getAttributeCount());
082: cssValue = simple.getAttribute(Attribute.LIST_STYLE);
083: assertEquals("decimal", cssValue.toString());
084: return;
085: }
086:
087: assertEquals(3, simple.getAttributeCount());
088:
089: cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
090: assertEquals("decimal", cssValue.toString());
091: cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
092: assertEquals("outside", cssValue.toString());
093: cssValue = simple.getAttribute(Attribute.LIST_STYLE_IMAGE);
094: assertEquals("none", cssValue.toString());
095: }
096:
097: public void testListStyle04() throws Exception {
098: ss.addCSSAttribute(simple, Attribute.LIST_STYLE, "outside");
099: if (!BasicSwingTestCase.isHarmony()) {
100: assertEquals(1, simple.getAttributeCount());
101: cssValue = simple.getAttribute(Attribute.LIST_STYLE);
102: assertEquals("outside", cssValue.toString());
103: return;
104: }
105:
106: assertEquals(3, simple.getAttributeCount());
107:
108: cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
109: assertEquals("disc", cssValue.toString());
110: cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
111: assertEquals("outside", cssValue.toString());
112: cssValue = simple.getAttribute(Attribute.LIST_STYLE_IMAGE);
113: assertEquals("none", cssValue.toString());
114: }
115:
116: public void testListStyle05() throws Exception {
117: ss.addCSSAttribute(simple, Attribute.LIST_STYLE, "inside");
118: if (!BasicSwingTestCase.isHarmony()) {
119: assertEquals(1, simple.getAttributeCount());
120: cssValue = simple.getAttribute(Attribute.LIST_STYLE);
121: assertEquals("inside", cssValue.toString());
122: return;
123: }
124:
125: assertEquals(3, simple.getAttributeCount());
126:
127: cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
128: assertEquals("disc", cssValue.toString());
129: cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
130: assertEquals("inside", cssValue.toString());
131: cssValue = simple.getAttribute(Attribute.LIST_STYLE_IMAGE);
132: assertEquals("none", cssValue.toString());
133: }
134:
135: public void testListStyle06() throws Exception {
136: ss.addCSSAttribute(simple, Attribute.LIST_STYLE,
137: "url(bullet.gif)");
138: if (!BasicSwingTestCase.isHarmony()) {
139: assertEquals(1, simple.getAttributeCount());
140: cssValue = simple.getAttribute(Attribute.LIST_STYLE);
141: assertEquals("url(bullet.gif)", cssValue.toString());
142: return;
143: }
144:
145: assertEquals(3, simple.getAttributeCount());
146:
147: cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
148: assertEquals("disc", cssValue.toString());
149: cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
150: assertEquals("outside", cssValue.toString());
151: cssValue = simple.getAttribute(Attribute.LIST_STYLE_IMAGE);
152: assertEquals("url(bullet.gif)", cssValue.toString());
153: }
154:
155: public void testListStyle07() throws Exception {
156: ss.addCSSAttribute(simple, Attribute.LIST_STYLE,
157: "square inside");
158: if (!BasicSwingTestCase.isHarmony()) {
159: assertEquals(1, simple.getAttributeCount());
160: cssValue = simple.getAttribute(Attribute.LIST_STYLE);
161: assertEquals("square inside", cssValue.toString());
162: return;
163: }
164:
165: assertEquals(3, simple.getAttributeCount());
166:
167: cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
168: assertEquals("square", cssValue.toString());
169: cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
170: assertEquals("inside", cssValue.toString());
171: cssValue = simple.getAttribute(Attribute.LIST_STYLE_IMAGE);
172: assertEquals("none", cssValue.toString());
173: }
174:
175: public void testListStyle08() throws Exception {
176: ss.addCSSAttribute(simple, Attribute.LIST_STYLE,
177: "inside square");
178: if (!BasicSwingTestCase.isHarmony()) {
179: assertEquals(1, simple.getAttributeCount());
180: cssValue = simple.getAttribute(Attribute.LIST_STYLE);
181: assertEquals("inside square", cssValue.toString());
182: return;
183: }
184:
185: assertEquals(3, simple.getAttributeCount());
186:
187: cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
188: assertEquals("square", cssValue.toString());
189: cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
190: assertEquals("inside", cssValue.toString());
191: cssValue = simple.getAttribute(Attribute.LIST_STYLE_IMAGE);
192: assertEquals("none", cssValue.toString());
193: }
194:
195: public void testListStyle09() throws Exception {
196: ss.addCSSAttribute(simple, Attribute.LIST_STYLE,
197: "square url(buller.gif)");
198: if (!BasicSwingTestCase.isHarmony()) {
199: assertEquals(1, simple.getAttributeCount());
200: cssValue = simple.getAttribute(Attribute.LIST_STYLE);
201: assertEquals("square url(buller.gif)", cssValue.toString());
202: return;
203: }
204:
205: assertEquals(3, simple.getAttributeCount());
206:
207: cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
208: assertEquals("square", cssValue.toString());
209: cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
210: assertEquals("outside", cssValue.toString());
211: cssValue = simple.getAttribute(Attribute.LIST_STYLE_IMAGE);
212: assertEquals("url(buller.gif)", cssValue.toString());
213: }
214:
215: public void testListStyle10() throws Exception {
216: ss.addCSSAttribute(simple, Attribute.LIST_STYLE,
217: "url(buller.gif) inside square");
218: if (!BasicSwingTestCase.isHarmony()) {
219: assertEquals(1, simple.getAttributeCount());
220: cssValue = simple.getAttribute(Attribute.LIST_STYLE);
221: assertEquals("url(buller.gif) inside square", cssValue
222: .toString());
223: return;
224: }
225:
226: assertEquals(3, simple.getAttributeCount());
227:
228: cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
229: assertEquals("square", cssValue.toString());
230: cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
231: assertEquals("inside", cssValue.toString());
232: cssValue = simple.getAttribute(Attribute.LIST_STYLE_IMAGE);
233: assertEquals("url(buller.gif)", cssValue.toString());
234: }
235:
236: public void testListStyle11() throws Exception {
237: ss.addCSSAttribute(simple, Attribute.LIST_STYLE, "disc square");
238: if (!BasicSwingTestCase.isHarmony()) {
239: assertEquals(1, simple.getAttributeCount());
240: cssValue = simple.getAttribute(Attribute.LIST_STYLE);
241: assertEquals("disc square", cssValue.toString());
242: return;
243: }
244:
245: assertEquals(0, simple.getAttributeCount());
246:
247: // cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
248: // assertEquals("square", cssValue.toString());
249: // cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
250: // assertEquals("inside", cssValue.toString());
251: // cssValue = simple.getAttribute(Attribute.LIST_STYLE_IMAGE);
252: // assertEquals("url(buller.gif)", cssValue.toString());
253: }
254:
255: public void testListStyle12() throws Exception {
256: ss.addCSSAttribute(simple, Attribute.LIST_STYLE,
257: "inside outside");
258: if (!BasicSwingTestCase.isHarmony()) {
259: assertEquals(1, simple.getAttributeCount());
260: cssValue = simple.getAttribute(Attribute.LIST_STYLE);
261: assertEquals("inside outside", cssValue.toString());
262: return;
263: }
264:
265: assertEquals(0, simple.getAttributeCount());
266: }
267:
268: public void testListStyle13() throws Exception {
269: ss.addCSSAttribute(simple, Attribute.LIST_STYLE,
270: "url(bullet.gif) url('square.gif')");
271: if (!BasicSwingTestCase.isHarmony()) {
272: assertEquals(1, simple.getAttributeCount());
273: cssValue = simple.getAttribute(Attribute.LIST_STYLE);
274: assertEquals("url(bullet.gif) url('square.gif')", cssValue
275: .toString());
276: return;
277: }
278:
279: assertEquals(0, simple.getAttributeCount());
280: }
281:
282: public void testListStyle14() throws Exception {
283: ss.addCSSAttribute(simple, Attribute.LIST_STYLE, "none none");
284: if (!BasicSwingTestCase.isHarmony()) {
285: return;
286: }
287:
288: assertEquals(3, simple.getAttributeCount());
289:
290: cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
291: assertEquals("none", cssValue.toString());
292: cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
293: assertEquals("outside", cssValue.toString());
294: cssValue = simple.getAttribute(Attribute.LIST_STYLE_IMAGE);
295: assertEquals("none", cssValue.toString());
296: }
297:
298: public void testListStyle15() throws Exception {
299: ss.addCSSAttribute(simple, Attribute.LIST_STYLE, "none disc");
300: if (!BasicSwingTestCase.isHarmony()) {
301: return;
302: }
303:
304: assertEquals(3, simple.getAttributeCount());
305:
306: cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
307: assertEquals("disc", cssValue.toString());
308: cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
309: assertEquals("outside", cssValue.toString());
310: cssValue = simple.getAttribute(Attribute.LIST_STYLE_IMAGE);
311: assertEquals("none", cssValue.toString());
312: }
313:
314: public void testListStyle16() throws Exception {
315: ss.addCSSAttribute(simple, Attribute.LIST_STYLE, "disc none");
316: if (!BasicSwingTestCase.isHarmony()) {
317: return;
318: }
319:
320: assertEquals(3, simple.getAttributeCount());
321:
322: cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
323: assertEquals("disc", cssValue.toString());
324: cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
325: assertEquals("outside", cssValue.toString());
326: cssValue = simple.getAttribute(Attribute.LIST_STYLE_IMAGE);
327: assertEquals("none", cssValue.toString());
328: }
329:
330: public void testListStyle17() throws Exception {
331: ss.addCSSAttribute(simple, Attribute.LIST_STYLE,
332: "none url(bullet.gif)");
333: if (!BasicSwingTestCase.isHarmony()) {
334: return;
335: }
336:
337: assertEquals(3, simple.getAttributeCount());
338:
339: cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
340: assertEquals("none", cssValue.toString());
341: cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
342: assertEquals("outside", cssValue.toString());
343: cssValue = simple.getAttribute(Attribute.LIST_STYLE_IMAGE);
344: assertEquals("url(bullet.gif)", cssValue.toString());
345: }
346:
347: public void testListStyle18() throws Exception {
348: ss.addCSSAttribute(simple, Attribute.LIST_STYLE,
349: "url(bullet.gif) none");
350: if (!BasicSwingTestCase.isHarmony()) {
351: return;
352: }
353:
354: assertEquals(3, simple.getAttributeCount());
355:
356: cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
357: assertEquals("none", cssValue.toString());
358: cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
359: assertEquals("outside", cssValue.toString());
360: cssValue = simple.getAttribute(Attribute.LIST_STYLE_IMAGE);
361: assertEquals("url(bullet.gif)", cssValue.toString());
362: }
363:
364: public void testListStyle19() throws Exception {
365: ss.addCSSAttribute(simple, Attribute.LIST_STYLE,
366: "url(bullet.gif) none none");
367: if (!BasicSwingTestCase.isHarmony()) {
368: return;
369: }
370:
371: assertEquals(0, simple.getAttributeCount());
372: }
373:
374: public void testListStyle20() throws Exception {
375: ss.addCSSAttribute(simple, Attribute.LIST_STYLE,
376: "url(bullet.gif) none disc");
377: if (!BasicSwingTestCase.isHarmony()) {
378: return;
379: }
380:
381: assertEquals(0, simple.getAttributeCount());
382: }
383:
384: public void testListStyle21() throws Exception {
385: ss.addCSSAttribute(simple, Attribute.LIST_STYLE,
386: "url(bullet.gif) disc none");
387: if (!BasicSwingTestCase.isHarmony()) {
388: return;
389: }
390:
391: assertEquals(0, simple.getAttributeCount());
392: }
393:
394: public void testListStyle22() throws Exception {
395: ss.addCSSAttribute(simple, Attribute.LIST_STYLE,
396: "url(bullet.gif) disc inside none");
397: if (!BasicSwingTestCase.isHarmony()) {
398: return;
399: }
400:
401: assertEquals(0, simple.getAttributeCount());
402: }
403: }
|