1 /*******************************************************************************
2  * Copyright (c) 2000, 2015 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.swt.tests.junit;
15 
16 import static org.junit.Assert.assertEquals;
17 import static org.junit.Assert.fail;
18 
19 import org.eclipse.swt.SWT;
20 import org.eclipse.swt.widgets.ProgressBar;
21 import org.junit.Before;
22 import org.junit.Test;
23 
24 /**
25  * Automated Test Suite for class org.eclipse.swt.widgets.ProgressBar
26  *
27  * @see org.eclipse.swt.widgets.ProgressBar
28  */
29 public class Test_org_eclipse_swt_widgets_ProgressBar extends Test_org_eclipse_swt_widgets_Control {
30 
31 @Override
32 @Before
setUp()33 public void setUp() {
34 	super.setUp();
35 	progressBar = new ProgressBar(shell, 0);
36 	setWidget(progressBar);
37 }
38 
39 @Override
40 @Test
test_ConstructorLorg_eclipse_swt_widgets_CompositeI()41 public void test_ConstructorLorg_eclipse_swt_widgets_CompositeI() {
42 	try {
43 		progressBar = new ProgressBar(null, 0);
44 		fail("No exception thrown"); //should never get here
45 	}
46 	catch (IllegalArgumentException e) {
47 	}
48 
49 	int[] cases = {0, SWT.HORIZONTAL, SWT.VERTICAL};
50 	for (int style : cases)
51 		progressBar = new ProgressBar(shell, style);
52 }
53 
54 @Override
55 @Test
test_computeSizeIIZ()56 public void test_computeSizeIIZ() {
57 }
58 
59 @Override
60 @Test
test_setFocus()61 public void test_setFocus() {
62 }
63 
64 @Test
test_setMaximumI()65 public void test_setMaximumI() {
66 
67 	int [][] testValues = getSetMaximumValues();
68 
69 	for (int[] intArray : testValues) {
70 		setDefaults();
71 		progressBar.setMaximum(intArray[0]);
72 		report("setMaximum", intArray[0], intArray[1], intArray[2], intArray[3]);
73 	}
74 }
75 
76 @Test
test_setMinimumI()77 public void test_setMinimumI() {
78 
79 	int [][] testValues = getSetMinimumValues();
80 
81 	for (int[] intArray : testValues) {
82 		setDefaults();
83 		progressBar.setMinimum(intArray[0]);
84 		report("setMinimum", intArray[0], intArray[1], intArray[2], intArray[3]);
85 	}
86 }
87 
88 @Test
test_setSelectionI()89 public void test_setSelectionI() {
90 	int [][] testValues = getSetSelectionValues();
91 	for (int[] intArray : testValues) {
92 		setDefaults();
93 		progressBar.setSelection(intArray[0]);
94 		report("setSelection", intArray[0], intArray[1], intArray[2], intArray[3]);
95 	}
96 }
97 
98 /* custom */
99 ProgressBar progressBar;
100 // this method must be private or protected so the auto-gen tool keeps it
report(String call, int set, int minExpected, int maxExpected, int selectionExpected)101 private void report(String call, int set, int minExpected, int maxExpected, int selectionExpected) {
102 	// Uncomment these lines and comment out call to check() if you want the test to report all errors without
103 	// stopping.
104 
105 	//if (progressBar.getMinimum() != minExpected)
106 		//System.out.println(call + "(" + set + "): Minimum Expected: " + minExpected + "  Actual: " + progressBar.getMinimum());
107 	//if (progressBar.getMaximum() != maxExpected)
108 		//System.out.println(call + "(" + set + "): Maximum Expected: " + maxExpected + "  Actual: " + progressBar.getMaximum());
109 	//if (progressBar.getSelection() != selectionExpected)
110 		//System.out.println(call + "(" + set + "): Selection Expected: " + selectionExpected + "  Actual: " + progressBar.getSelection());
111 
112 	check(minExpected, maxExpected, selectionExpected);
113 }
114 // this method must be private or protected so the auto-gen tool keeps it
check(int minExpected, int maxExpected, int selectionExpected)115 private void check(int minExpected, int maxExpected, int selectionExpected) {
116 	assertEquals(progressBar.getMaximum(), maxExpected);
117 	assertEquals(progressBar.getMinimum(), minExpected);
118 	assertEquals(progressBar.getSelection(), selectionExpected);
119 }
120 // this method must be private or protected so the auto-gen tool keeps it
getSetMinimumValues()121 private int[][] getSetMinimumValues() {
122 return new int[][] {
123 {-15, 10, 100, 50, },
124 {-14, 10, 100, 50, },
125 {-13, 10, 100, 50, },
126 {-12, 10, 100, 50, },
127 {-11, 10, 100, 50, },
128 {-10, 10, 100, 50, },
129 {-9, 10, 100, 50, },
130 {-8, 10, 100, 50, },
131 {-7, 10, 100, 50, },
132 {-6, 10, 100, 50, },
133 {-5, 10, 100, 50, },
134 {-4, 10, 100, 50, },
135 {-3, 10, 100, 50, },
136 {-2, 10, 100, 50, },
137 {-1, 10, 100, 50, },
138 {0, 0, 100, 50, },
139 {1, 1, 100, 50, },
140 {2, 2, 100, 50, },
141 {3, 3, 100, 50, },
142 {4, 4, 100, 50, },
143 {5, 5, 100, 50, },
144 {6, 6, 100, 50, },
145 {7, 7, 100, 50, },
146 {8, 8, 100, 50, },
147 {9, 9, 100, 50, },
148 {10, 10, 100, 50, },
149 {11, 11, 100, 50, },
150 {12, 12, 100, 50, },
151 {13, 13, 100, 50, },
152 {14, 14, 100, 50, },
153 {15, 15, 100, 50, },
154 {16, 16, 100, 50, },
155 {17, 17, 100, 50, },
156 {18, 18, 100, 50, },
157 {19, 19, 100, 50, },
158 {20, 20, 100, 50, },
159 {21, 21, 100, 50, },
160 {22, 22, 100, 50, },
161 {23, 23, 100, 50, },
162 {24, 24, 100, 50, },
163 {25, 25, 100, 50, },
164 {26, 26, 100, 50, },
165 {27, 27, 100, 50, },
166 {28, 28, 100, 50, },
167 {29, 29, 100, 50, },
168 {30, 30, 100, 50, },
169 {31, 31, 100, 50, },
170 {32, 32, 100, 50, },
171 {33, 33, 100, 50, },
172 {34, 34, 100, 50, },
173 {35, 35, 100, 50, },
174 {36, 36, 100, 50, },
175 {37, 37, 100, 50, },
176 {38, 38, 100, 50, },
177 {39, 39, 100, 50, },
178 {40, 40, 100, 50, },
179 {41, 41, 100, 50, },
180 {42, 42, 100, 50, },
181 {43, 43, 100, 50, },
182 {44, 44, 100, 50, },
183 {45, 45, 100, 50, },
184 {46, 46, 100, 50, },
185 {47, 47, 100, 50, },
186 {48, 48, 100, 50, },
187 {49, 49, 100, 50, },
188 {50, 50, 100, 50, },
189 {51, 51, 100, 51, },
190 {52, 52, 100, 52, },
191 {53, 53, 100, 53, },
192 {54, 54, 100, 54, },
193 {55, 55, 100, 55, },
194 {56, 56, 100, 56, },
195 {57, 57, 100, 57, },
196 {58, 58, 100, 58, },
197 {59, 59, 100, 59, },
198 {60, 60, 100, 60, },
199 {61, 61, 100, 61, },
200 {62, 62, 100, 62, },
201 {63, 63, 100, 63, },
202 {64, 64, 100, 64, },
203 {65, 65, 100, 65, },
204 {66, 66, 100, 66, },
205 {67, 67, 100, 67, },
206 {68, 68, 100, 68, },
207 {69, 69, 100, 69, },
208 {70, 70, 100, 70, },
209 {71, 71, 100, 71, },
210 {72, 72, 100, 72, },
211 {73, 73, 100, 73, },
212 {74, 74, 100, 74, },
213 {75, 75, 100, 75, },
214 {76, 76, 100, 76, },
215 {77, 77, 100, 77, },
216 {78, 78, 100, 78, },
217 {79, 79, 100, 79, },
218 {80, 80, 100, 80, },
219 {81, 81, 100, 81, },
220 {82, 82, 100, 82, },
221 {83, 83, 100, 83, },
222 {84, 84, 100, 84, },
223 {85, 85, 100, 85, },
224 {86, 86, 100, 86, },
225 {87, 87, 100, 87, },
226 {88, 88, 100, 88, },
227 {89, 89, 100, 89, },
228 {90, 90, 100, 90, },
229 {91, 91, 100, 91, },
230 {92, 92, 100, 92, },
231 {93, 93, 100, 93, },
232 {94, 94, 100, 94, },
233 {95, 95, 100, 95, },
234 {96, 96, 100, 96, },
235 {97, 97, 100, 97, },
236 {98, 98, 100, 98, },
237 {99, 99, 100, 99, },
238 {100, 10, 100, 50, },
239 {101, 10, 100, 50, },
240 {102, 10, 100, 50, },
241 {103, 10, 100, 50, },
242 {104, 10, 100, 50, },
243 {105, 10, 100, 50, },
244 {106, 10, 100, 50, },
245 {107, 10, 100, 50, },
246 {108, 10, 100, 50, },
247 {109, 10, 100, 50, },
248 {110, 10, 100, 50, },
249 {111, 10, 100, 50, },
250 {112, 10, 100, 50, },
251 {113, 10, 100, 50, },
252 {114, 10, 100, 50, },
253 {115, 10, 100, 50, },
254 {116, 10, 100, 50, },
255 {117, 10, 100, 50, },
256 {118, 10, 100, 50, },
257 {119, 10, 100, 50, },
258 {120, 10, 100, 50, },
259 {121, 10, 100, 50, },
260 {122, 10, 100, 50, },
261 {123, 10, 100, 50, },
262 {124, 10, 100, 50, },
263 };
264 }
265 // this method must be private or protected so the auto-gen tool keeps it
getSetMaximumValues()266 private int[][] getSetMaximumValues() {
267 return new int[][] {
268 {-15, 10, 100, 50, },
269 {-14, 10, 100, 50, },
270 {-13, 10, 100, 50, },
271 {-12, 10, 100, 50, },
272 {-11, 10, 100, 50, },
273 {-10, 10, 100, 50, },
274 {-9, 10, 100, 50, },
275 {-8, 10, 100, 50, },
276 {-7, 10, 100, 50, },
277 {-6, 10, 100, 50, },
278 {-5, 10, 100, 50, },
279 {-4, 10, 100, 50, },
280 {-3, 10, 100, 50, },
281 {-2, 10, 100, 50, },
282 {-1, 10, 100, 50, },
283 {0, 10, 100, 50, },
284 {1, 10, 100, 50, },
285 {2, 10, 100, 50, },
286 {3, 10, 100, 50, },
287 {4, 10, 100, 50, },
288 {5, 10, 100, 50, },
289 {6, 10, 100, 50, },
290 {7, 10, 100, 50, },
291 {8, 10, 100, 50, },
292 {9, 10, 100, 50, },
293 {10, 10, 100, 50, },
294 {11, 10, 11, 11, },
295 {12, 10, 12, 12, },
296 {13, 10, 13, 13, },
297 {14, 10, 14, 14, },
298 {15, 10, 15, 15, },
299 {16, 10, 16, 16, },
300 {17, 10, 17, 17, },
301 {18, 10, 18, 18, },
302 {19, 10, 19, 19, },
303 {20, 10, 20, 20, },
304 {21, 10, 21, 21, },
305 {22, 10, 22, 22, },
306 {23, 10, 23, 23, },
307 {24, 10, 24, 24, },
308 {25, 10, 25, 25, },
309 {26, 10, 26, 26, },
310 {27, 10, 27, 27, },
311 {28, 10, 28, 28, },
312 {29, 10, 29, 29, },
313 {30, 10, 30, 30, },
314 {31, 10, 31, 31, },
315 {32, 10, 32, 32, },
316 {33, 10, 33, 33, },
317 {34, 10, 34, 34, },
318 {35, 10, 35, 35, },
319 {36, 10, 36, 36, },
320 {37, 10, 37, 37, },
321 {38, 10, 38, 38, },
322 {39, 10, 39, 39, },
323 {40, 10, 40, 40, },
324 {41, 10, 41, 41, },
325 {42, 10, 42, 42, },
326 {43, 10, 43, 43, },
327 {44, 10, 44, 44, },
328 {45, 10, 45, 45, },
329 {46, 10, 46, 46, },
330 {47, 10, 47, 47, },
331 {48, 10, 48, 48, },
332 {49, 10, 49, 49, },
333 {50, 10, 50, 50, },
334 {51, 10, 51, 50, },
335 {52, 10, 52, 50, },
336 {53, 10, 53, 50, },
337 {54, 10, 54, 50, },
338 {55, 10, 55, 50, },
339 {56, 10, 56, 50, },
340 {57, 10, 57, 50, },
341 {58, 10, 58, 50, },
342 {59, 10, 59, 50, },
343 {60, 10, 60, 50, },
344 {61, 10, 61, 50, },
345 {62, 10, 62, 50, },
346 {63, 10, 63, 50, },
347 {64, 10, 64, 50, },
348 {65, 10, 65, 50, },
349 {66, 10, 66, 50, },
350 {67, 10, 67, 50, },
351 {68, 10, 68, 50, },
352 {69, 10, 69, 50, },
353 {70, 10, 70, 50, },
354 {71, 10, 71, 50, },
355 {72, 10, 72, 50, },
356 {73, 10, 73, 50, },
357 {74, 10, 74, 50, },
358 {75, 10, 75, 50, },
359 {76, 10, 76, 50, },
360 {77, 10, 77, 50, },
361 {78, 10, 78, 50, },
362 {79, 10, 79, 50, },
363 {80, 10, 80, 50, },
364 {81, 10, 81, 50, },
365 {82, 10, 82, 50, },
366 {83, 10, 83, 50, },
367 {84, 10, 84, 50, },
368 {85, 10, 85, 50, },
369 {86, 10, 86, 50, },
370 {87, 10, 87, 50, },
371 {88, 10, 88, 50, },
372 {89, 10, 89, 50, },
373 {90, 10, 90, 50, },
374 {91, 10, 91, 50, },
375 {92, 10, 92, 50, },
376 {93, 10, 93, 50, },
377 {94, 10, 94, 50, },
378 {95, 10, 95, 50, },
379 {96, 10, 96, 50, },
380 {97, 10, 97, 50, },
381 {98, 10, 98, 50, },
382 {99, 10, 99, 50, },
383 {100, 10, 100, 50, },
384 {101, 10, 101, 50, },
385 {102, 10, 102, 50, },
386 {103, 10, 103, 50, },
387 {104, 10, 104, 50, },
388 {105, 10, 105, 50, },
389 {106, 10, 106, 50, },
390 {107, 10, 107, 50, },
391 {108, 10, 108, 50, },
392 {109, 10, 109, 50, },
393 {110, 10, 110, 50, },
394 {111, 10, 111, 50, },
395 {112, 10, 112, 50, },
396 {113, 10, 113, 50, },
397 {114, 10, 114, 50, },
398 {115, 10, 115, 50, },
399 {116, 10, 116, 50, },
400 {117, 10, 117, 50, },
401 {118, 10, 118, 50, },
402 {119, 10, 119, 50, },
403 {120, 10, 120, 50, },
404 {121, 10, 121, 50, },
405 {122, 10, 122, 50, },
406 {123, 10, 123, 50, },
407 {124, 10, 124, 50, },
408 };
409 }
410 // this method must be private or protected so the auto-gen tool keeps it
setDefaults()411 private void setDefaults() {
412 	progressBar.setMaximum(100);
413 	progressBar.setMinimum(10);
414 	progressBar.setSelection(50);
415 }
416 // this method must be private or protected so the auto-gen tool keeps it
getSetSelectionValues()417 private int[][] getSetSelectionValues() {
418 return new int[][] {
419 {-15, 10, 100, 10, },
420 {-14, 10, 100, 10, },
421 {-13, 10, 100, 10, },
422 {-12, 10, 100, 10, },
423 {-11, 10, 100, 10, },
424 {-10, 10, 100, 10, },
425 {-9, 10, 100, 10, },
426 {-8, 10, 100, 10, },
427 {-7, 10, 100, 10, },
428 {-6, 10, 100, 10, },
429 {-5, 10, 100, 10, },
430 {-4, 10, 100, 10, },
431 {-3, 10, 100, 10, },
432 {-2, 10, 100, 10, },
433 {-1, 10, 100, 10, },
434 {0, 10, 100, 10, },
435 {1, 10, 100, 10, },
436 {2, 10, 100, 10, },
437 {3, 10, 100, 10, },
438 {4, 10, 100, 10, },
439 {5, 10, 100, 10, },
440 {6, 10, 100, 10, },
441 {7, 10, 100, 10, },
442 {8, 10, 100, 10, },
443 {9, 10, 100, 10, },
444 {10, 10, 100, 10, },
445 {11, 10, 100, 11, },
446 {12, 10, 100, 12, },
447 {13, 10, 100, 13, },
448 {14, 10, 100, 14, },
449 {15, 10, 100, 15, },
450 {16, 10, 100, 16, },
451 {17, 10, 100, 17, },
452 {18, 10, 100, 18, },
453 {19, 10, 100, 19, },
454 {20, 10, 100, 20, },
455 {21, 10, 100, 21, },
456 {22, 10, 100, 22, },
457 {23, 10, 100, 23, },
458 {24, 10, 100, 24, },
459 {25, 10, 100, 25, },
460 {26, 10, 100, 26, },
461 {27, 10, 100, 27, },
462 {28, 10, 100, 28, },
463 {29, 10, 100, 29, },
464 {30, 10, 100, 30, },
465 {31, 10, 100, 31, },
466 {32, 10, 100, 32, },
467 {33, 10, 100, 33, },
468 {34, 10, 100, 34, },
469 {35, 10, 100, 35, },
470 {36, 10, 100, 36, },
471 {37, 10, 100, 37, },
472 {38, 10, 100, 38, },
473 {39, 10, 100, 39, },
474 {40, 10, 100, 40, },
475 {41, 10, 100, 41, },
476 {42, 10, 100, 42, },
477 {43, 10, 100, 43, },
478 {44, 10, 100, 44, },
479 {45, 10, 100, 45, },
480 {46, 10, 100, 46, },
481 {47, 10, 100, 47, },
482 {48, 10, 100, 48, },
483 {49, 10, 100, 49, },
484 {50, 10, 100, 50, },
485 {51, 10, 100, 51, },
486 {52, 10, 100, 52, },
487 {53, 10, 100, 53, },
488 {54, 10, 100, 54, },
489 {55, 10, 100, 55, },
490 {56, 10, 100, 56, },
491 {57, 10, 100, 57, },
492 {58, 10, 100, 58, },
493 {59, 10, 100, 59, },
494 {60, 10, 100, 60, },
495 {61, 10, 100, 61, },
496 {62, 10, 100, 62, },
497 {63, 10, 100, 63, },
498 {64, 10, 100, 64, },
499 {65, 10, 100, 65, },
500 {66, 10, 100, 66, },
501 {67, 10, 100, 67, },
502 {68, 10, 100, 68, },
503 {69, 10, 100, 69, },
504 {70, 10, 100, 70, },
505 {71, 10, 100, 71, },
506 {72, 10, 100, 72, },
507 {73, 10, 100, 73, },
508 {74, 10, 100, 74, },
509 {75, 10, 100, 75, },
510 {76, 10, 100, 76, },
511 {77, 10, 100, 77, },
512 {78, 10, 100, 78, },
513 {79, 10, 100, 79, },
514 {80, 10, 100, 80, },
515 {81, 10, 100, 81, },
516 {82, 10, 100, 82, },
517 {83, 10, 100, 83, },
518 {84, 10, 100, 84, },
519 {85, 10, 100, 85, },
520 {86, 10, 100, 86, },
521 {87, 10, 100, 87, },
522 {88, 10, 100, 88, },
523 {89, 10, 100, 89, },
524 {90, 10, 100, 90, },
525 {91, 10, 100, 91, },
526 {92, 10, 100, 92, },
527 {93, 10, 100, 93, },
528 {94, 10, 100, 94, },
529 {95, 10, 100, 95, },
530 {96, 10, 100, 96, },
531 {97, 10, 100, 97, },
532 {98, 10, 100, 98, },
533 {99, 10, 100, 99, },
534 {100, 10, 100, 100, },
535 {101, 10, 100, 100, },
536 {102, 10, 100, 100, },
537 {103, 10, 100, 100, },
538 {104, 10, 100, 100, },
539 {105, 10, 100, 100, },
540 {106, 10, 100, 100, },
541 {107, 10, 100, 100, },
542 {108, 10, 100, 100, },
543 {109, 10, 100, 100, },
544 {110, 10, 100, 100, },
545 {111, 10, 100, 100, },
546 {112, 10, 100, 100, },
547 {113, 10, 100, 100, },
548 {114, 10, 100, 100, },
549 {115, 10, 100, 100, },
550 {116, 10, 100, 100, },
551 {117, 10, 100, 100, },
552 {118, 10, 100, 100, },
553 {119, 10, 100, 100, },
554 {120, 10, 100, 100, },
555 {121, 10, 100, 100, },
556 {122, 10, 100, 100, },
557 {123, 10, 100, 100, },
558 {124, 10, 100, 100, },
559 };
560 }
561 
562 @Test
test_consistency_MenuDetect()563 public void test_consistency_MenuDetect () {
564 	consistencyEvent(10, 5, 3, 0, ConsistencyUtility.MOUSE_CLICK);
565 }
566 
567 @Test
test_consistency_DragDetect()568 public void test_consistency_DragDetect () {
569 	consistencyEvent(10, 5, 20, 10, ConsistencyUtility.MOUSE_DRAG);
570 }
571 
572 }
573