Exemple #1
0
  /** Tests the shape actor builder */
  @Test
  public void shapeActorBuilderTest() {
    for (int i = 0; i < BUILDER_ITERATIONS; i++) {
      final String type = "actor";
      final String id = scene.getFactory().newUuid(scene);
      final Camera camera = random.nextBoolean() ? scene.lookup(Camera.class) : null;
      final boolean dirty = random.nextBoolean();
      final DrawingPass drawingPass =
          DrawingPass.values()[random.nextInt(DrawingPass.values().length)];
      final byte passNumber = (byte) random.nextInt(Byte.MAX_VALUE);
      final float thickness = random.nextFloat();
      final boolean visible = random.nextBoolean();
      final boolean wire = random.nextBoolean();
      final Color backgroundColor =
          random.nextBoolean() ? ColorUtil.createRandomColor(0.0f, 1.0f) : null;
      final Color color = random.nextBoolean() ? ColorUtil.createRandomColor(0.0f, 1.0f) : null;
      final Alignment origin = Alignment.values()[random.nextInt(Alignment.values().length)];
      final Shape shape = random.nextBoolean() ? Rectangle.ZERO : null;
      // test
      final Actor a =
          DynamicShapeActor.Builder.construct()
              .scene(scene)
              .type(type)
              .id(id)
              .camera(camera)
              .dirty(dirty)
              .drawingPass(drawingPass)
              .passNumber(passNumber)
              .thickness(thickness)
              .visible(visible)
              .wire(wire)
              .backgroundColor(backgroundColor)
              .color(color)
              .origin(origin)
              .shape(shape)
              .build();

      final Actor b =
          Actor.Builder.construct()
              .scene(scene)
              .type(type)
              .id(id)
              .camera(camera)
              .dirty(dirty)
              .drawingPass(drawingPass)
              .passNumber(passNumber)
              .thickness(thickness)
              .visible(visible)
              .wire(wire)
              .backgroundColor(backgroundColor)
              .color(color)
              .origin(origin)
              .shape(shape)
              .build();

      // test equality
      final boolean result = WeakEqualsHelper.weakEquals(a, b, ignore);
      Assert.assertTrue(WeakEqualsHelper.getErrors().toString(), result);
    }
  }
Exemple #2
0
  /** Tests the node actor builder */
  @Test
  public void nodeActorBuilderTest() {
    for (int i = 0; i < BUILDER_ITERATIONS; i++) {
      final String type = "actor";
      final String id = scene.getFactory().newUuid(scene);
      final Camera camera = random.nextBoolean() ? scene.lookup(Camera.class) : null;
      final boolean dirty = random.nextBoolean();
      final DrawingPass drawingPass =
          DrawingPass.values()[random.nextInt(DrawingPass.values().length)];
      final byte passNumber = (byte) random.nextInt(Byte.MAX_VALUE);
      final float thickness = random.nextFloat();
      final boolean visible = random.nextBoolean();
      final boolean wire = random.nextBoolean();
      // test
      final Actor a =
          NodeActor.Builder.construct()
              .scene(scene)
              .type(type)
              .id(id)
              .camera(camera)
              .dirty(dirty)
              .drawingPass(drawingPass)
              .passNumber(passNumber)
              .thickness(thickness)
              .visible(visible)
              .wire(wire)
              .build();

      final Actor b =
          Actor.Builder.construct()
              .node()
              .scene(scene)
              .type(type)
              .id(id)
              .camera(camera)
              .dirty(dirty)
              .drawingPass(drawingPass)
              .passNumber(passNumber)
              .thickness(thickness)
              .visible(visible)
              .wire(wire)
              .build();

      // test equality
      final boolean result = WeakEqualsHelper.weakEquals(a, b, ignore);
      Assert.assertTrue(WeakEqualsHelper.getErrors().toString(), result);
    }
  }