public class testSetBlockIncrement implements Testlet
{
public void test(TestHarness harness)
{
Scrollbar bar = new Scrollbar();
// This check shows that the default value of pageIncrement is 10.
harness.check(bar.getBlockIncrement(), 10);
// These checks show that it is not possible to set pageIncrement
// to 0. Instead, it is set to 1.
bar.setBlockIncrement(0);
harness.check(bar.getBlockIncrement(), 1);
bar.setBlockIncrement(5);
harness.check(bar.getBlockIncrement(), 5);
bar.setBlockIncrement(0);
harness.check(bar.getBlockIncrement(), 1);
// These checks show that there was unnecessary code in the method.
// The unnecessary code would produce a value of 9 as the pageIncrement,
// when in fact it should be set to 30.
// NOTE: It is no longer necessary to check if
// (maximum - minimum) == 0 because maximum will never equal minimum.
bar.setMaximum(10);
bar.setMinimum(1);
harness.check(bar.getMaximum(), 10);
harness.check(bar.getMinimum(), 1);
harness.check(bar.getBlockIncrement(), 1);
bar.setBlockIncrement(30);
harness.check(bar.getBlockIncrement(), 30);
harness.check(bar.getBlockIncrement() != 9);
// This test ensures that pageIncrement is not effected
// if it is greater than the range.
bar.setValues(1,1,1,2);
harness.check(bar.getValue(), 1);
harness.check(bar.getVisibleAmount(), 1);
harness.check(bar.getMinimum(), 1);
harness.check(bar.getMaximum(), 2);
bar.setBlockIncrement(4);
harness.check(bar.getBlockIncrement() >
(bar.getMaximum() - bar.getMinimum()));
harness.check(bar.getBlockIncrement() == 4);
harness.check(bar.getBlockIncrement() !=
(bar.getMaximum() - bar.getMinimum()));
}