01: /*
02: *
03: *
04: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License version
09: * 2 only, as published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * General Public License version 2 for more details (a copy is
15: * included at /legal/license.txt).
16: *
17: * You should have received a copy of the GNU General Public License
18: * version 2 along with this work; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA
21: *
22: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23: * Clara, CA 95054 or visit www.sun.com if you need additional
24: * information or have any questions.
25: */
26:
27: package javax.microedition.lcdui;
28:
29: import com.sun.midp.i3test.*;
30:
31: public class TestTwo extends TestCase {
32:
33: public void testCreate() {
34: Gauge g = new Gauge("GaugeTest", true, 100, 50);
35: assertEquals(100, g.maxValue);
36: assertEquals(50, g.value);
37: assertNotNull(g.gaugeLF);
38: assertTrue(g.interactive);
39: }
40:
41: public void testCheckValueIndefinite() {
42: Gauge g = new Gauge("GaugeTest", false, 100, 50);
43:
44: // value out of range should get set to CONTINUOUS_IDLE
45: g.setMaxValue(Gauge.INDEFINITE);
46: assertEquals(Gauge.CONTINUOUS_IDLE, g.value);
47: }
48:
49: public void testCheckValueAbove() {
50: Gauge g = new Gauge("GaugeTest", true, 47, 29);
51:
52: // value above top of range should get set to MAX
53: g.setMaxValue(22);
54: assertEquals(22, g.value);
55: }
56:
57: public void testCheckValueBelow() {
58: Gauge g = new Gauge("GaugeTest", true, 100, 50);
59:
60: // value less than zero should get set to zero
61: g.setValue(-17);
62: assertEquals(0, g.value);
63: }
64:
65: // test driver
66:
67: public void runTests() {
68: declare("testCreate");
69: testCreate();
70: declare("testCheckValueIndefinite");
71: testCheckValueIndefinite();
72: declare("testCheckValueAbove");
73: testCheckValueAbove();
74: declare("testCheckValueBelow");
75: testCheckValueBelow();
76: }
77:
78: }
|