22 package com.realtime.crossfire.jxclient.gui.gauge;
24 import org.jetbrains.annotations.NotNull;
25 import org.junit.Assert;
26 import org.junit.Test;
56 private static void check(@NotNull
final Class<? extends Orientation> class_,
final boolean useX,
final boolean flip)
throws IllegalAccessException, InstantiationException {
70 private static void checkPositive(@NotNull
final Class<? extends Orientation> class_,
final boolean useX,
final boolean flip)
throws IllegalAccessException, InstantiationException {
73 o.
setExtends(useX ? 100 : 32, useX ? 32 : 100);
74 check(o, useX, flip,
false, 0, 0, 0, 32,
false);
78 check(o, useX, flip,
true, 0, 0, 0, 32,
false);
82 check(o, useX, flip,
true, 0, 0, 25, 32,
false);
86 check(o, useX, flip,
true, 0, 0, 100, 32,
false);
90 check(o, useX, flip,
true, 0, 0, 100, 32,
false);
94 check(o, useX, flip,
true, 0, 0, 0, 32,
false);
98 check(o, useX, flip,
true, 0, 0, 0, 32,
false);
110 private static void checkNegative(@NotNull
final Class<? extends Orientation> class_,
final boolean useX,
final boolean flip)
throws IllegalAccessException, InstantiationException {
113 o.
setExtends(useX ? 100 : 32, useX ? 32 : 100);
114 check(o, useX, flip,
false, 0, 0, 0, 32,
false);
118 check(o, useX, flip,
true, 0, 0, 0, 32,
false);
122 check(o, useX, flip,
true, 0, 0, 25, 32,
false);
126 check(o, useX, flip,
true, 0, 0, 100, 32,
false);
130 check(o, useX, flip,
true, 0, 0, 100, 32,
false);
134 check(o, useX, flip,
true, 0, 0, 50, 32,
true);
138 check(o, useX, flip,
true, 0, 0, 100, 32,
true);
153 private static void check(@NotNull
final Orientation o,
final boolean useX,
final boolean flip,
final boolean valid,
final int x,
final int y,
final int w,
final int h,
final boolean negativeImage) {
154 final int isX = useX ? o.getX() : o.getY();
155 final int isY = useX ? o.getY() : o.getX();
156 final int isW = useX ? o.getW() : o.getH();
157 final int isH = useX ? o.getH() : o.getW();
158 Assert.assertEquals(valid, o.isValid());
159 Assert.assertEquals(flip ? 100-x-w : x, isX);
160 Assert.assertEquals(y, isY);
161 Assert.assertEquals(w, isW);
162 Assert.assertEquals(h, isH);
163 Assert.assertEquals(negativeImage, o.isNegativeImage());
Regression tests for class Orientation and implementing classes.
static void checkNegative(@NotNull final Class<? extends Orientation > class_, final boolean useX, final boolean flip)
Checks that negative values are correctly handled by an Orientation instance.
Implements an Orientation which grows west to east.
Interface for orientation images.
Implements an Orientation which grows north to south.
static void check(@NotNull final Orientation o, final boolean useX, final boolean flip, final boolean valid, final int x, final int y, final int w, final int h, final boolean negativeImage)
Checks that a value is correctly handled.
boolean setValues(int cur, int min, int max)
Sets the gauge's values.
static void check(@NotNull final Class<? extends Orientation > class_, final boolean useX, final boolean flip)
Checks an Orientation instance.
void setHasNegativeImage(boolean hasNegativeImage)
Sets whether the gauge can display negative images.
boolean setExtends(int width, int height)
Sets the extends of the image.
static void checkPositive(@NotNull final Class<? extends Orientation > class_, final boolean useX, final boolean flip)
Checks that positive values are correctly handled by an Orientation instance.
void testOrientations()
Checks that Orientation instances work correctly.
Implements an Orientation which grows south to north.
Implements an Orientation which grows east to west.