File: testSetValues.java

package info (click to toggle)
mauve 20161030-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 44,628 kB
  • ctags: 35,425
  • sloc: java: 336,555; sh: 2,834; xml: 208; makefile: 72
file content (199 lines) | stat: -rw-r--r-- 6,390 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
/* testSetValues.java
   Copyright (C) 2006 Red Hat
This file is part of Mauve.

Mauve is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

Mauve is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with Mauve; see the file COPYING.  If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.

*/

// Tags: 1.4

package gnu.testlet.java.awt.Scrollbar;

import java.awt.Scrollbar;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

public class testSetValues implements Testlet
{

  public void test(TestHarness harness)
  {
    test1(harness);
    test2(harness);
    test3(harness);
    test4(harness);
    test5(harness);
    test6(harness);
    test7(harness);
    test8(harness);
    test9(harness);
    test10(harness);
    test11(harness);
  }

  public void test1(TestHarness harness)
  {
    // This test ensures that if value < minimum, then
    // value is set to minimum.
    Scrollbar bar = new Scrollbar();
    bar.setValues(0, 1, 1, 2);
    harness.check(bar.getValue(), 1);
    harness.check(bar.getVisibleAmount(), 1);
    harness.check(bar.getMinimum(), 1);
    harness.check(bar.getMaximum(), 2);
  }
  
  public void test2(TestHarness harness)
  {
    // This test ensures that if visibleAmount < 0, then
    // it is set to 1.
    Scrollbar bar = new Scrollbar();
    bar.setValues(4, -5, 4, 8);
    harness.check(bar.getValue(), 4);
    harness.check(bar.getVisibleAmount(), 1);
    harness.check(bar.getMinimum(), 4);
    harness.check(bar.getMaximum(), 8);
  }
  
  public void test3(TestHarness harness)
  {
    // This test ensures that if visibleAmount = 0, then
    // it is set to 1.
    Scrollbar bar = new Scrollbar();
    bar.setValues(0, 0, 5, 10);
    harness.check(bar.getValue(), 5);
    harness.check(bar.getVisibleAmount(), 1);
    harness.check(bar.getMinimum(), 5);
    harness.check(bar.getMaximum(), 10);
  }
  public void test4(TestHarness harness)
  {
    // This test ensures that if maximum < minimum, then
    // maximum is set to minimum + 1.
    Scrollbar bar = new Scrollbar();
    bar.setValues(10, 1, 10, 5);
    harness.check(bar.getValue(), 10);
    harness.check(bar.getVisibleAmount(), 1);
    harness.check(bar.getMinimum(), 10);
    harness.check(bar.getMaximum(), 11);
  }
  
  public void test5(TestHarness harness)
  {
    // This test ensures that if value > maximum - visibleAmount,
    // then value is set to maximum - visibleAmount.
    Scrollbar bar = new Scrollbar();
    bar.setValues(10, 1, 5, 10);
    harness.check(bar.getValue(), 9);
    harness.check(bar.getVisibleAmount(), 1);
    harness.check(bar.getMinimum(), 5);
    harness.check(bar.getMaximum(), 10);
  }
  
  public void test6(TestHarness harness)
  {
    // This test ensures that if visibleAmount > maximum - minimum,
    // then visibleAmount is set to maximum - minimum.
    Scrollbar bar = new Scrollbar();
    bar.setValues(5, 30, 5, 20);
    harness.check(bar.getValue(), 5);
    harness.check(bar.getVisibleAmount(), 15);
    harness.check(bar.getMinimum(), 5);
    harness.check(bar.getMaximum(), 20);
  }
  
  public void test7(TestHarness harness)
  {
    // This test ensures that if maximum = minimum, 
    // then maximum is set to maximum + 1.
    Scrollbar bar = new Scrollbar();
    bar.setValues(5, 10, 20, 20);
    harness.check(bar.getValue(), 20);
    harness.check(bar.getVisibleAmount(), 1);
    harness.check(bar.getMinimum(), 20);
    harness.check(bar.getMaximum(), 21);
  }
  
  public void test8(TestHarness harness)
  {
    // This test ensures that if negative values are passed
    // as the value, minimum and maximum values, then
    // there is no effect.  That is, they are not rejected or
    // made positive.  
    Scrollbar bar = new Scrollbar();
    bar.setValues(-3, -2, -4, -8);
    harness.check(bar.getValue(), -4);
    harness.check(bar.getVisibleAmount(), 1);
    harness.check(bar.getMinimum(), -4);
    harness.check(bar.getMaximum(), -3);
  }
  
  public void test9(TestHarness harness)
  {
    // This test is taken from Intel's test suite
    // (test.java.awt.ScrollbarTest).  It passes on Sun
    // but fails on Classpath.
    Scrollbar bar = new Scrollbar();
    bar.setValues(0, 10, -100, 100);
    harness.check(bar.getValue(), 0);
    harness.check(bar.getVisibleAmount(), 10);
    harness.check(bar.getMinimum(), -100);
    harness.check(bar.getMaximum(), 100);
    bar.setMinimum(Integer.MIN_VALUE);
    harness.check(bar.getValue(), -11);
    harness.check(bar.getVisibleAmount(), 10);
    harness.check(bar.getMinimum(), Integer.MIN_VALUE);
    harness.check(bar.getMaximum(), -1);
  }

  public void test10(TestHarness harness)
  {
    // This test ensures that lineIncrement is not effected
    // if it is greater than the range.
    Scrollbar bar = new Scrollbar();
    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.setUnitIncrement(4);
    harness.check(bar.getUnitIncrement() > 
                    (bar.getMaximum() - bar.getMinimum()));
    harness.check(bar.getUnitIncrement() == 4);
    harness.check(bar.getUnitIncrement() != 
                    (bar.getMaximum() - bar.getMinimum()));
  }
  
  public void test11(TestHarness harness)
  {
    // This test ensures that pageIncrement is not effected
    // if it is greater than the range.
    Scrollbar bar = new Scrollbar();
    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()));
  }
}