Exemplo n.º 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);
    }
  }
Exemplo n.º 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);
    }
  }
Exemplo n.º 3
0
 /**
  * Creates a new instance of this class and registers it with the scene.
  *
  * @param scene The scene to log to.
  * @param interval The interval in milliseconds to log at
  * @return the new instance
  */
 public static MemLogger newInstance(final Scene scene, final long interval) {
   final MemLogger instance = new MemLogger(scene, interval);
   scene.add(instance);
   return instance;
 }