23 package com.realtime.crossfire.jxclient.gui.gauge;
25 import java.lang.reflect.InvocationTargetException;
26 import org.jetbrains.annotations.NotNull;
27 import org.junit.Assert;
28 import org.junit.Test;
58 private static void check(@NotNull
final Class<? extends Orientation> class_,
final boolean useX,
final boolean flip)
throws IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException {
74 private static void checkPositive(@NotNull
final Class<? extends Orientation> class_,
final boolean useX,
final boolean flip)
throws IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException {
75 final Orientation o = class_.getConstructor().newInstance();
77 o.
setExtends(useX ? 100 : 32, useX ? 32 : 100);
78 check(o, useX, flip,
false, 0, 0, 0, 32,
false);
82 check(o, useX, flip,
true, 0, 0, 0, 32,
false);
86 check(o, useX, flip,
true, 0, 0, 25, 32,
false);
90 check(o, useX, flip,
true, 0, 0, 100, 32,
false);
94 check(o, useX, flip,
true, 0, 0, 100, 32,
false);
98 check(o, useX, flip,
true, 0, 0, 0, 32,
false);
102 check(o, useX, flip,
true, 0, 0, 0, 32,
false);
116 private static void checkNegative(@NotNull
final Class<? extends Orientation> class_,
final boolean useX,
final boolean flip)
throws IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException {
117 final Orientation o = class_.getConstructor().newInstance();
119 o.
setExtends(useX ? 100 : 32, useX ? 32 : 100);
120 check(o, useX, flip,
false, 0, 0, 0, 32,
false);
124 check(o, useX, flip,
true, 0, 0, 0, 32,
false);
128 check(o, useX, flip,
true, 0, 0, 25, 32,
false);
132 check(o, useX, flip,
true, 0, 0, 100, 32,
false);
136 check(o, useX, flip,
true, 0, 0, 100, 32,
false);
140 check(o, useX, flip,
true, 0, 0, 50, 32,
true);
144 check(o, useX, flip,
true, 0, 0, 100, 32,
true);
159 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) {
160 final int isX = useX ? o.getX() : o.getY();
161 final int isY = useX ? o.getY() : o.getX();
162 final int isW = useX ? o.getW() : o.getH();
163 final int isH = useX ? o.getH() : o.getW();
164 Assert.assertEquals(valid, o.isValid());
165 Assert.assertEquals(flip ? 100-x-w : x, isX);
166 Assert.assertEquals(y, isY);
167 Assert.assertEquals(w, isW);
168 Assert.assertEquals(h, isH);
169 Assert.assertEquals(negativeImage, o.isNegativeImage());