You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Test4b.java 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* *******************************************************************
  2. * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Common Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://www.eclipse.org/legal/cpl-v10.html
  8. *
  9. * Contributors:
  10. * PARC initial implementation
  11. * ******************************************************************/
  12. package tests;
  13. import figures.*;
  14. import java.awt.Rectangle;
  15. import junit.framework.*;
  16. public class Test4b extends Test {
  17. public Test4b(String name) { super(name); }
  18. public static void main(String[] args) {
  19. junit.textui.TestRunner.run(Test4b.class);
  20. }
  21. public void setUp() {
  22. super.setUp();
  23. }
  24. public void testBasicEquality() {
  25. assertTrue(g.getBounds() == g.getBounds());
  26. }
  27. public void testEqualityAfterAddition() {
  28. Point p0 = new Point(1, 2);
  29. Point p1 = new Point(2, 3);
  30. Group g0 = new Group(p0);
  31. Group g1 = new Group(p1);
  32. Rectangle r0 = g0.getBounds();
  33. Rectangle r1 = g1.getBounds();
  34. assertTrue(r0 != r1);
  35. g0.add(new Point(37, 90));
  36. assertTrue(g0.getBounds() == r0);
  37. assertTrue(g1.getBounds() != r0);
  38. assertTrue(g0.getBounds() != r1);
  39. assertTrue(g1.getBounds() == r1);
  40. g1.add(new Point(4, 8));
  41. assertTrue(g0.getBounds() == r0);
  42. assertTrue(g1.getBounds() != r0);
  43. assertTrue(g0.getBounds() != r1);
  44. assertTrue(g1.getBounds() == r1);
  45. }
  46. public void testNotWholeCanvas() {
  47. assertTrue("bounds for this group should not be the whole canvas",
  48. g.getBounds().getWidth() <
  49. (FigureElement.MAX_VALUE - FigureElement.MIN_VALUE));
  50. assertTrue("bounds for this group should not be the whole canvas",
  51. g.getBounds().getHeight() <
  52. (FigureElement.MAX_VALUE - FigureElement.MIN_VALUE));
  53. }
  54. }