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 Alexander T. Simbirtsev
019: * @version $Revision$
020: * Created on 06.12.2004
021:
022: */package javax.swing;
023:
024: import java.awt.Color;
025: import java.awt.Font;
026: import java.awt.Insets;
027: import java.awt.image.BufferedImage;
028: import javax.swing.border.BevelBorder;
029: import javax.swing.border.Border;
030: import javax.swing.border.CompoundBorder;
031: import javax.swing.border.EmptyBorder;
032: import javax.swing.border.EtchedBorder;
033: import javax.swing.border.LineBorder;
034: import javax.swing.border.MatteBorder;
035: import javax.swing.border.TitledBorder;
036:
037: public class BorderFactoryTest extends SwingTestCase {
038: public void testStaticVariablesInitialization() {
039: assertTrue("Shared values are initialized",
040: BorderFactory.emptyBorder != null);
041: assertTrue("Shared values are initialized",
042: BorderFactory.sharedEtchedBorder != null);
043: assertTrue("Shared values are initialized",
044: BorderFactory.sharedLoweredBevel != null);
045: assertTrue("Shared values are initialized",
046: BorderFactory.sharedRaisedBevel != null);
047: EmptyBorder emptyBorder = (EmptyBorder) BorderFactory.emptyBorder;
048: Insets insets = emptyBorder.getBorderInsets();
049: assertEquals(insets, new Insets(0, 0, 0, 0));
050: int etchType = EtchedBorder.LOWERED;
051: Color shadowColor = null;
052: Color highlightedColor = null;
053: Border border = BorderFactory.sharedEtchedBorder;
054: assertEquals("Shadow color coinsides", shadowColor,
055: ((EtchedBorder) border).getShadowColor());
056: assertEquals("Highlighted color coinsides", highlightedColor,
057: ((EtchedBorder) border).getHighlightColor());
058: assertEquals("Etch type coinsides", etchType,
059: ((EtchedBorder) border).getEtchType());
060: int bevelType = BevelBorder.LOWERED;
061: border = BorderFactory.sharedLoweredBevel;
062: assertEquals("highlightOuterColor coinsides", highlightedColor,
063: ((BevelBorder) border).getHighlightOuterColor());
064: assertEquals("highlightInnerColor coinsides", highlightedColor,
065: ((BevelBorder) border).getHighlightInnerColor());
066: assertEquals("shadowOuterColor coinsides", shadowColor,
067: ((BevelBorder) border).getShadowOuterColor());
068: assertEquals("shadowInnerColor coinsides", shadowColor,
069: ((BevelBorder) border).getShadowInnerColor());
070: assertEquals("Bevel type coinsides", bevelType,
071: ((BevelBorder) border).getBevelType());
072: bevelType = BevelBorder.RAISED;
073: border = BorderFactory.sharedRaisedBevel;
074: assertEquals("highlightOuterColor coinsides", highlightedColor,
075: ((BevelBorder) border).getHighlightOuterColor());
076: assertEquals("highlightInnerColor coinsides", highlightedColor,
077: ((BevelBorder) border).getHighlightInnerColor());
078: assertEquals("shadowOuterColor coinsides", shadowColor,
079: ((BevelBorder) border).getShadowOuterColor());
080: assertEquals("shadowInnerColor coinsides", shadowColor,
081: ((BevelBorder) border).getShadowInnerColor());
082: assertEquals("Bevel type coinsides", bevelType,
083: ((BevelBorder) border).getBevelType());
084: }
085:
086: /*
087: * Class under test for TitledBorder createTitledBorder(Border, String, int, int, Font, Color)
088: */
089: public void testCreateTitledBorderBorderStringintintFontColor() {
090: Color color1 = Color.GREEN;
091: Color color2 = null;
092: Font font1 = new Font(null, Font.TRUETYPE_FONT, 30);
093: Font font2 = null;
094: String string1 = "string1";
095: String string2 = null;
096: Border border3 = new EmptyBorder(1, 1, 1, 1);
097: Border border4 = null;
098: int just1 = 1;
099: int just2 = 2;
100: int pos1 = 1;
101: int pos2 = 2;
102: TitledBorder border1 = BorderFactory.createTitledBorder(
103: border3, string1, just1, pos1, font1, color1);
104: TitledBorder border2 = BorderFactory.createTitledBorder(
105: border4, string2, just2, pos2, font2, color2);
106: assertEquals("title field initialized correctly ", string1,
107: border1.getTitle());
108: assertEquals("border field initialized correctly ", border3,
109: border1.getBorder());
110: assertEquals("color field initialized correctly ", color1,
111: border1.getTitleColor());
112: assertEquals("font field initialized correctly ", font1,
113: border1.getTitleFont());
114: assertEquals("position field initialized correctly ", pos1,
115: border1.getTitlePosition());
116: assertEquals("justification field initialized correctly ",
117: just1, border1.getTitleJustification());
118: assertEquals("title field initialized correctly ", string2,
119: border2.getTitle());
120: assertEquals("border field initialized correctly ", UIManager
121: .getDefaults().getBorder("TitledBorder.border"),
122: border2.getBorder());
123: assertEquals("color field initialized correctly ", UIManager
124: .getDefaults().getColor("TitledBorder.titleColor"),
125: border2.getTitleColor());
126: assertEquals("font field initialized correctly ", UIManager
127: .getDefaults().getFont("TitledBorder.font"), border2
128: .getTitleFont());
129: assertEquals("position field initialized correctly ", pos2,
130: border2.getTitlePosition());
131: assertEquals("justification field initialized correctly ",
132: just2, border2.getTitleJustification());
133: }
134:
135: /*
136: * Class under test for TitledBorder createTitledBorder(Border, String, int, int, Font)
137: */
138: public void testCreateTitledBorderBorderStringintintFont() {
139: Font font1 = new Font(null, Font.TRUETYPE_FONT, 30);
140: Font font2 = null;
141: String string1 = "string1";
142: String string2 = null;
143: Border border3 = new EmptyBorder(1, 1, 1, 1);
144: Border border4 = null;
145: int just1 = 1;
146: int just2 = 2;
147: int pos1 = 1;
148: int pos2 = 2;
149: TitledBorder border1 = BorderFactory.createTitledBorder(
150: border3, string1, just1, pos1, font1);
151: TitledBorder border2 = BorderFactory.createTitledBorder(
152: border4, string2, just2, pos2, font2);
153: assertEquals("title field initialized correctly ", string1,
154: border1.getTitle());
155: assertEquals("border field initialized correctly ", border3,
156: border1.getBorder());
157: assertEquals("color field initialized correctly ", UIManager
158: .getDefaults().getColor("TitledBorder.titleColor"),
159: border1.getTitleColor());
160: assertEquals("font field initialized correctly ", font1,
161: border1.getTitleFont());
162: assertEquals("position field initialized correctly ", pos1,
163: border1.getTitlePosition());
164: assertEquals("justification field initialized correctly ",
165: just1, border1.getTitleJustification());
166: assertEquals("title field initialized correctly ", string2,
167: border2.getTitle());
168: assertEquals("border field initialized correctly ", UIManager
169: .getDefaults().getBorder("TitledBorder.border"),
170: border2.getBorder());
171: assertEquals("color field initialized correctly ", UIManager
172: .getDefaults().getColor("TitledBorder.titleColor"),
173: border2.getTitleColor());
174: assertEquals("font field initialized correctly ", UIManager
175: .getDefaults().getFont("TitledBorder.font"), border2
176: .getTitleFont());
177: assertEquals("position field initialized correctly ", pos2,
178: border2.getTitlePosition());
179: assertEquals("justification field initialized correctly ",
180: just2, border2.getTitleJustification());
181: }
182:
183: /*
184: * Class under test for TitledBorder createTitledBorder(Border, String, int, int)
185: */
186: public void testCreateTitledBorderBorderStringintint() {
187: String string1 = "string1";
188: String string2 = null;
189: Border border3 = new EmptyBorder(1, 1, 1, 1);
190: Border border4 = null;
191: int just1 = 1;
192: int just2 = 2;
193: int pos1 = 1;
194: int pos2 = 2;
195: TitledBorder border1 = BorderFactory.createTitledBorder(
196: border3, string1, just1, pos1);
197: TitledBorder border2 = BorderFactory.createTitledBorder(
198: border4, string2, just2, pos2);
199: assertEquals("title field initialized correctly ", string1,
200: border1.getTitle());
201: assertEquals("border field initialized correctly ", border3,
202: border1.getBorder());
203: assertEquals("color field initialized correctly ", UIManager
204: .getDefaults().getColor("TitledBorder.titleColor"),
205: border1.getTitleColor());
206: assertEquals("font field initialized correctly ", UIManager
207: .getDefaults().getFont("TitledBorder.font"), border1
208: .getTitleFont());
209: assertEquals("position field initialized correctly ", pos1,
210: border1.getTitlePosition());
211: assertEquals("justification field initialized correctly ",
212: just1, border1.getTitleJustification());
213: assertEquals("title field initialized correctly ", string2,
214: border2.getTitle());
215: assertEquals("border field initialized correctly ", UIManager
216: .getDefaults().getBorder("TitledBorder.border"),
217: border2.getBorder());
218: assertEquals("color field initialized correctly ", UIManager
219: .getDefaults().getColor("TitledBorder.titleColor"),
220: border2.getTitleColor());
221: assertEquals("font field initialized correctly ", UIManager
222: .getDefaults().getFont("TitledBorder.font"), border2
223: .getTitleFont());
224: assertEquals("position field initialized correctly ", pos2,
225: border2.getTitlePosition());
226: assertEquals("justification field initialized correctly ",
227: just2, border2.getTitleJustification());
228: }
229:
230: /*
231: * Class under test for TitledBorder createTitledBorder(Border, String)
232: */
233: public void testCreateTitledBorderBorderString() {
234: String string1 = "string1";
235: String string2 = null;
236: Border border3 = new EmptyBorder(1, 1, 1, 1);
237: Border border4 = null;
238: TitledBorder border1 = BorderFactory.createTitledBorder(
239: border3, string1);
240: TitledBorder border2 = BorderFactory.createTitledBorder(
241: border4, string2);
242: assertEquals("title field initialized correctly ", string1,
243: border1.getTitle());
244: assertEquals("border field initialized correctly ", border3,
245: border1.getBorder());
246: assertEquals("color field initialized correctly ", UIManager
247: .getDefaults().getColor("TitledBorder.titleColor"),
248: border1.getTitleColor());
249: assertEquals("font field initialized correctly ", UIManager
250: .getDefaults().getFont("TitledBorder.font"), border1
251: .getTitleFont());
252: assertEquals("position field initialized correctly ",
253: TitledBorder.TOP, border1.getTitlePosition());
254: assertEquals("justification field initialized correctly ",
255: TitledBorder.LEADING, border1.getTitleJustification());
256: assertEquals("title field initialized correctly ", string2,
257: border2.getTitle());
258: assertEquals("border field initialized correctly ", UIManager
259: .getDefaults().getBorder("TitledBorder.border"),
260: border2.getBorder());
261: assertEquals("color field initialized correctly ", UIManager
262: .getDefaults().getColor("TitledBorder.titleColor"),
263: border2.getTitleColor());
264: assertEquals("font field initialized correctly ", UIManager
265: .getDefaults().getFont("TitledBorder.font"), border2
266: .getTitleFont());
267: assertEquals("position field initialized correctly ",
268: TitledBorder.TOP, border2.getTitlePosition());
269: assertEquals("justification field initialized correctly ",
270: TitledBorder.LEADING, border2.getTitleJustification());
271: }
272:
273: /*
274: * Class under test for CompoundBorder createCompoundBorder(Border, Border)
275: */
276: public void testCreateCompoundBorderBorderBorder() {
277: LineBorder border1 = new LineBorder(Color.red, 33, false);
278: LineBorder border2 = new LineBorder(Color.red, 33, true);
279: EmptyBorder border3 = new EmptyBorder(1, 1, 1, 1);
280: CompoundBorder border4 = BorderFactory.createCompoundBorder(
281: border1, border2);
282: CompoundBorder border5 = BorderFactory.createCompoundBorder(
283: border2, border3);
284: CompoundBorder border7 = BorderFactory.createCompoundBorder(
285: border2, null);
286: CompoundBorder border8 = BorderFactory.createCompoundBorder(
287: null, border3);
288: assertEquals("border fields coinsides", border1, border4
289: .getOutsideBorder());
290: assertEquals("border fields coinsides", border2, border4
291: .getInsideBorder());
292: assertEquals("border fields coinsides", border2, border5
293: .getOutsideBorder());
294: assertEquals("border fields coinsides", border3, border5
295: .getInsideBorder());
296: assertEquals("border fields coinsides", border2, border7
297: .getOutsideBorder());
298: assertNull("border fields coinsides", border7.getInsideBorder());
299: assertNull("border fields coinsides", border8
300: .getOutsideBorder());
301: assertEquals("border fields coinsides", border3, border8
302: .getInsideBorder());
303: }
304:
305: /*
306: * Class under test for TitledBorder createTitledBorder(Border)
307: */
308: public void testCreateTitledBorderBorder() {
309: Border border3 = new EmptyBorder(1, 1, 1, 1);
310: Border border4 = null;
311: TitledBorder border1 = BorderFactory
312: .createTitledBorder(border3);
313: TitledBorder border2 = BorderFactory
314: .createTitledBorder(border4);
315: assertEquals("title field initialized correctly ", "", border1
316: .getTitle());
317: assertEquals("border field initialized correctly ", border3,
318: border1.getBorder());
319: assertEquals("color field initialized correctly ", UIManager
320: .getDefaults().getColor("TitledBorder.titleColor"),
321: border1.getTitleColor());
322: assertEquals("font field initialized correctly ", UIManager
323: .getDefaults().getFont("TitledBorder.font"), border1
324: .getTitleFont());
325: assertEquals("position field initialized correctly ",
326: TitledBorder.TOP, border1.getTitlePosition());
327: assertEquals("justification field initialized correctly ",
328: TitledBorder.LEADING, border1.getTitleJustification());
329: assertEquals("title field initialized correctly ", "", border2
330: .getTitle());
331: assertEquals("border field initialized correctly ", UIManager
332: .getDefaults().getBorder("TitledBorder.border"),
333: border2.getBorder());
334: assertEquals("color field initialized correctly ", UIManager
335: .getDefaults().getColor("TitledBorder.titleColor"),
336: border2.getTitleColor());
337: assertEquals("font field initialized correctly ", UIManager
338: .getDefaults().getFont("TitledBorder.font"), border2
339: .getTitleFont());
340: assertEquals("position field initialized correctly ",
341: TitledBorder.TOP, border2.getTitlePosition());
342: assertEquals("justification field initialized correctly ",
343: TitledBorder.LEADING, border2.getTitleJustification());
344: }
345:
346: /*
347: * Class under test for TitledBorder createTitledBorder(String)
348: */
349: public void testCreateTitledBorderString() {
350: String string1 = "string1";
351: String string2 = null;
352: TitledBorder border1 = BorderFactory
353: .createTitledBorder(string1);
354: TitledBorder border2 = BorderFactory
355: .createTitledBorder(string2);
356: assertEquals("title field initialized correctly ", string1,
357: border1.getTitle());
358: assertEquals("border field initialized correctly ", UIManager
359: .getDefaults().getBorder("TitledBorder.border"),
360: border1.getBorder());
361: assertEquals("color field initialized correctly ", UIManager
362: .getDefaults().getColor("TitledBorder.titleColor"),
363: border1.getTitleColor());
364: assertEquals("font field initialized correctly ", UIManager
365: .getDefaults().getFont("TitledBorder.font"), border1
366: .getTitleFont());
367: assertEquals("position field initialized correctly ",
368: TitledBorder.TOP, border1.getTitlePosition());
369: assertEquals("justification field initialized correctly ",
370: TitledBorder.LEADING, border1.getTitleJustification());
371: assertEquals("title field initialized correctly ", string2,
372: border2.getTitle());
373: assertEquals("border field initialized correctly ", UIManager
374: .getDefaults().getBorder("TitledBorder.border"),
375: border2.getBorder());
376: assertEquals("color field initialized correctly ", UIManager
377: .getDefaults().getColor("TitledBorder.titleColor"),
378: border2.getTitleColor());
379: assertEquals("font field initialized correctly ", UIManager
380: .getDefaults().getFont("TitledBorder.font"), border2
381: .getTitleFont());
382: assertEquals("position field initialized correctly ",
383: TitledBorder.TOP, border2.getTitlePosition());
384: assertEquals("justification field initialized correctly ",
385: TitledBorder.LEADING, border2.getTitleJustification());
386: }
387:
388: /*
389: * Class under test for MatteBorder createMatteBorder(int, int, int, int, Icon)
390: */
391: public void testCreateMatteBorderintintintintIcon() {
392: Icon icon = new ImageIcon(new BufferedImage(20, 20,
393: BufferedImage.TYPE_BYTE_GRAY));
394: int top = 100;
395: int left = 200;
396: int right = 300;
397: int bottom = 400;
398: MatteBorder border = BorderFactory.createMatteBorder(top, left,
399: bottom, right, icon);
400: Insets insets = border.getBorderInsets(null);
401: assertEquals(insets, new Insets(top, left, bottom, right));
402: icon = new ImageIcon(new BufferedImage(30, 40,
403: BufferedImage.TYPE_4BYTE_ABGR));
404: top = 200;
405: left = 300;
406: right = 200;
407: bottom = 300;
408: border = BorderFactory.createMatteBorder(top, left, bottom,
409: right, icon);
410: Insets insets2 = border.getBorderInsets(null);
411: assertEquals(insets2, new Insets(top, left, bottom, right));
412: }
413:
414: /*
415: * Class under test for MatteBorder createMatteBorder(int, int, int, int, Color)
416: */
417: public void testCreateMatteBorderintintintintColor() {
418: Color color = Color.RED;
419: int top = 100;
420: int left = 200;
421: int right = 300;
422: int bottom = 400;
423: MatteBorder border = BorderFactory.createMatteBorder(top, left,
424: bottom, right, color);
425: Insets insets = border.getBorderInsets(null);
426: assertEquals(insets, new Insets(top, left, bottom, right));
427: color = Color.YELLOW;
428: top = 200;
429: left = 300;
430: right = 200;
431: bottom = 300;
432: border = BorderFactory.createMatteBorder(top, left, bottom,
433: right, color);
434: Insets insets2 = border.getBorderInsets(null);
435: assertEquals(insets2, new Insets(top, left, bottom, right));
436: }
437:
438: /*
439: * Class under test for Border createLineBorder(Color, int)
440: */
441: public void testCreateLineBorderColorint() {
442: int thickness = 11;
443: Color color = Color.yellow;
444: LineBorder border = (LineBorder) BorderFactory
445: .createLineBorder(color, thickness);
446: assertEquals("Thickness coinsides", thickness, border
447: .getThickness());
448: assertFalse("RoundedCorners coinsides", border
449: .getRoundedCorners());
450: assertEquals("Colors coinsides", color, border.getLineColor());
451: }
452:
453: /*
454: * Class under test for Border createLineBorder(Color)
455: */
456: public void testCreateLineBorderColor() {
457: int thickness = 1;
458: boolean roundedCorners = false;
459: Color color = Color.yellow;
460: LineBorder border = (LineBorder) BorderFactory
461: .createLineBorder(color);
462: assertEquals("Thickness coinsides", thickness, border
463: .getThickness());
464: assertEquals("RoundedCorners coinsides", roundedCorners, border
465: .getRoundedCorners());
466: assertEquals("Colors coinsides", color, border.getLineColor());
467: }
468:
469: /*
470: * Class under test for CompoundBorder createCompoundBorder()
471: */
472: public void testCreateCompoundBorder() {
473: CompoundBorder border = BorderFactory.createCompoundBorder();
474: assertNull(border.getInsideBorder());
475: assertNull(border.getOutsideBorder());
476: }
477:
478: /*
479: * Class under test for Border createEmptyBorder(int, int, int, int)
480: */
481: public void testCreateEmptyBorderintintintint() {
482: int top = 100;
483: int left = 200;
484: int right = 300;
485: int bottom = 400;
486: EmptyBorder border = (EmptyBorder) BorderFactory
487: .createEmptyBorder(top, left, bottom, right);
488: Insets insets = border.getBorderInsets(null);
489: assertEquals(insets, new Insets(top, left, bottom, right));
490: }
491:
492: /*
493: * Class under test for Border createEtchedBorder(Color, Color)
494: */
495: public void testCreateEtchedBorderColorColor() {
496: int etchType = EtchedBorder.LOWERED;
497: Color shadowColor = Color.YELLOW;
498: Color highlightedColor = Color.RED;
499: EtchedBorder border = (EtchedBorder) BorderFactory
500: .createEtchedBorder(highlightedColor, shadowColor);
501: assertEquals("Shadow color coinsides", shadowColor, border
502: .getShadowColor());
503: assertEquals("Highlighted color coinsides", highlightedColor,
504: border.getHighlightColor());
505: assertEquals("Etch type coinsides", etchType, border
506: .getEtchType());
507: shadowColor = Color.GREEN;
508: highlightedColor = Color.WHITE;
509: border = (EtchedBorder) BorderFactory.createEtchedBorder(
510: highlightedColor, shadowColor);
511: assertEquals("Shadow color coinsides", shadowColor, border
512: .getShadowColor());
513: assertEquals("Highlighted color coinsides", highlightedColor,
514: border.getHighlightColor());
515: assertEquals("Etch type coinsides", etchType, border
516: .getEtchType());
517: }
518:
519: /*
520: * Class under test for Border createEtchedBorder(int, Color, Color)
521: */
522: public void testCreateEtchedBorderintColorColor() {
523: int etchType = EtchedBorder.LOWERED;
524: Color shadowColor = Color.YELLOW;
525: Color highlightedColor = Color.RED;
526: EtchedBorder border = (EtchedBorder) BorderFactory
527: .createEtchedBorder(etchType, highlightedColor,
528: shadowColor);
529: assertEquals("Shadow color coinsides", shadowColor, border
530: .getShadowColor());
531: assertEquals("Highlighted color coinsides", highlightedColor,
532: border.getHighlightColor());
533: assertEquals("Etch type coinsides", etchType, border
534: .getEtchType());
535: etchType = EtchedBorder.RAISED;
536: shadowColor = Color.GREEN;
537: highlightedColor = Color.WHITE;
538: border = (EtchedBorder) BorderFactory.createEtchedBorder(
539: etchType, highlightedColor, shadowColor);
540: assertEquals("Shadow color coinsides", shadowColor, border
541: .getShadowColor());
542: assertEquals("Highlighted color coinsides", highlightedColor,
543: border.getHighlightColor());
544: assertEquals("Etch type coinsides", etchType, border
545: .getEtchType());
546: }
547:
548: /*
549: * Class under test for Border createEtchedBorder(int)
550: */
551: public void testCreateEtchedBorderint() {
552: int etchType = EtchedBorder.LOWERED;
553: Color shadowColor = null;
554: Color highlightedColor = null;
555: EtchedBorder border = (EtchedBorder) BorderFactory
556: .createEtchedBorder(etchType);
557: assertEquals("Shadow color coinsides", shadowColor, border
558: .getShadowColor());
559: assertEquals("Highlighted color coinsides", highlightedColor,
560: border.getHighlightColor());
561: assertEquals("Etch type coinsides", etchType, border
562: .getEtchType());
563: etchType = EtchedBorder.RAISED;
564: border = (EtchedBorder) BorderFactory
565: .createEtchedBorder(etchType);
566: assertEquals("Shadow color coinsides", shadowColor, border
567: .getShadowColor());
568: assertEquals("Highlighted color coinsides", highlightedColor,
569: border.getHighlightColor());
570: assertEquals("Etch type coinsides", etchType, border
571: .getEtchType());
572: }
573:
574: /*
575: * Class under test for Border createEtchedBorder()
576: */
577: public void testCreateEtchedBorder() {
578: int etchType = EtchedBorder.LOWERED;
579: Color shadowColor = null;
580: Color highlightedColor = null;
581: EtchedBorder border = (EtchedBorder) BorderFactory
582: .createEtchedBorder();
583: assertEquals("Shadow color coinsides", shadowColor, border
584: .getShadowColor());
585: assertEquals("Highlighted color coinsides", highlightedColor,
586: border.getHighlightColor());
587: assertEquals("Etch type coinsides", etchType, border
588: .getEtchType());
589: }
590:
591: /*
592: * Class under test for Border createBevelBorder(int, Color, Color, Color, Color)
593: */
594: public void testCreateBevelBorderintColorColorColorColor() {
595: int bevelType = BevelBorder.LOWERED;
596: Color highlightOuterColor = Color.RED;
597: Color highlightInnerColor = Color.YELLOW;
598: Color shadowOuterColor = Color.GREEN;
599: Color shadowInnerColor = Color.BLACK;
600: BevelBorder border = (BevelBorder) BorderFactory
601: .createBevelBorder(bevelType, highlightOuterColor,
602: highlightInnerColor, shadowOuterColor,
603: shadowInnerColor);
604: assertEquals("highlightOuterColor coinsides",
605: highlightOuterColor, border.getHighlightOuterColor());
606: assertEquals("highlightInnerColor coinsides",
607: highlightInnerColor, border.getHighlightInnerColor());
608: assertEquals("shadowOuterColor coinsides", shadowOuterColor,
609: border.getShadowOuterColor());
610: assertEquals("shadowInnerColor coinsides", shadowInnerColor,
611: border.getShadowInnerColor());
612: assertEquals("Bevel type coinsides", bevelType, border
613: .getBevelType());
614: bevelType = BevelBorder.RAISED;
615: highlightOuterColor = Color.YELLOW;
616: highlightInnerColor = Color.RED;
617: shadowOuterColor = Color.WHITE;
618: shadowInnerColor = Color.BLUE;
619: border = (BevelBorder) BorderFactory.createBevelBorder(
620: bevelType, highlightOuterColor, highlightInnerColor,
621: shadowOuterColor, shadowInnerColor);
622: assertEquals("highlightOuterColor coinsides",
623: highlightOuterColor, border.getHighlightOuterColor());
624: assertEquals("highlightInnerColor coinsides",
625: highlightInnerColor, border.getHighlightInnerColor());
626: assertEquals("shadowOuterColor coinsides", shadowOuterColor,
627: border.getShadowOuterColor());
628: assertEquals("shadowInnerColor coinsides", shadowInnerColor,
629: border.getShadowInnerColor());
630: assertEquals("Bevel type coinsides", bevelType, border
631: .getBevelType());
632: }
633:
634: /*
635: * Class under test for Border createBevelBorder(int, Color, Color)
636: */
637: public void testCreateBevelBorderintColorColor() {
638: int bevelType = BevelBorder.LOWERED;
639: Color highlightColor = Color.RED;
640: Color shadowColor = Color.GREEN;
641: BevelBorder border = (BevelBorder) BorderFactory
642: .createBevelBorder(bevelType, highlightColor,
643: shadowColor);
644: assertEquals("highlightOuterColor coinsides", highlightColor,
645: border.getHighlightOuterColor());
646: assertEquals("highlightInnerColor coinsides", highlightColor,
647: border.getHighlightInnerColor());
648: assertEquals("shadowOuterColor coinsides", shadowColor, border
649: .getShadowOuterColor());
650: assertEquals("shadowInnerColor coinsides", shadowColor, border
651: .getShadowInnerColor());
652: assertEquals("Bevel type coinsides", bevelType, border
653: .getBevelType());
654: bevelType = BevelBorder.RAISED;
655: highlightColor = Color.YELLOW;
656: shadowColor = Color.WHITE;
657: border = (BevelBorder) BorderFactory.createBevelBorder(
658: bevelType, highlightColor, shadowColor);
659: assertEquals("highlightOuterColor coinsides", highlightColor,
660: border.getHighlightOuterColor());
661: assertEquals("highlightInnerColor coinsides", highlightColor,
662: border.getHighlightInnerColor());
663: assertEquals("shadowOuterColor coinsides", shadowColor, border
664: .getShadowOuterColor());
665: assertEquals("shadowInnerColor coinsides", shadowColor, border
666: .getShadowInnerColor());
667: assertEquals("Bevel type coinsides", bevelType, border
668: .getBevelType());
669: }
670:
671: /*
672: * Class under test for Border createBevelBorder(int)
673: */
674: public void testCreateBevelBorderint() {
675: int bevelType = BevelBorder.LOWERED;
676: Color highlightColor = null;
677: Color shadowColor = null;
678: BevelBorder border = (BevelBorder) BorderFactory
679: .createBevelBorder(bevelType);
680: assertEquals("highlightOuterColor coinsides", highlightColor,
681: border.getHighlightOuterColor());
682: assertEquals("highlightInnerColor coinsides", highlightColor,
683: border.getHighlightInnerColor());
684: assertEquals("shadowOuterColor coinsides", shadowColor, border
685: .getShadowOuterColor());
686: assertEquals("shadowInnerColor coinsides", shadowColor, border
687: .getShadowInnerColor());
688: assertEquals("Bevel type coinsides", bevelType, border
689: .getBevelType());
690: bevelType = BevelBorder.RAISED;
691: border = (BevelBorder) BorderFactory
692: .createBevelBorder(bevelType);
693: assertEquals("highlightOuterColor coinsides", highlightColor,
694: border.getHighlightOuterColor());
695: assertEquals("highlightInnerColor coinsides", highlightColor,
696: border.getHighlightInnerColor());
697: assertEquals("shadowOuterColor coinsides", shadowColor, border
698: .getShadowOuterColor());
699: assertEquals("shadowInnerColor coinsides", shadowColor, border
700: .getShadowInnerColor());
701: assertEquals("Bevel type coinsides", bevelType, border
702: .getBevelType());
703: }
704:
705: public void testCreateRaisedBevelBorder() {
706: int bevelType = BevelBorder.RAISED;
707: Color highlightColor = null;
708: Color shadowColor = null;
709: BevelBorder border = (BevelBorder) BorderFactory
710: .createRaisedBevelBorder();
711: assertEquals("highlightOuterColor coinsides", highlightColor,
712: border.getHighlightOuterColor());
713: assertEquals("highlightInnerColor coinsides", highlightColor,
714: border.getHighlightInnerColor());
715: assertEquals("shadowOuterColor coinsides", shadowColor, border
716: .getShadowOuterColor());
717: assertEquals("shadowInnerColor coinsides", shadowColor, border
718: .getShadowInnerColor());
719: assertEquals("Bevel type coinsides", bevelType, border
720: .getBevelType());
721: }
722:
723: public void testCreateLoweredBevelBorder() {
724: int bevelType = BevelBorder.LOWERED;
725: Color highlightColor = null;
726: Color shadowColor = null;
727: BevelBorder border = (BevelBorder) BorderFactory
728: .createLoweredBevelBorder();
729: assertEquals("highlightOuterColor coinsides", highlightColor,
730: border.getHighlightOuterColor());
731: assertEquals("highlightInnerColor coinsides", highlightColor,
732: border.getHighlightInnerColor());
733: assertEquals("shadowOuterColor coinsides", shadowColor, border
734: .getShadowOuterColor());
735: assertEquals("shadowInnerColor coinsides", shadowColor, border
736: .getShadowInnerColor());
737: assertEquals("Bevel type coinsides", bevelType, border
738: .getBevelType());
739: }
740:
741: /*
742: * Class under test for Border createEmptyBorder()
743: */
744: public void testCreateEmptyBorder() {
745: Border border = BorderFactory.createEmptyBorder();
746: Insets insets = border.getBorderInsets(null);
747: assertEquals(insets, new Insets(0, 0, 0, 0));
748: }
749: }
|