001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: /**
018: * @author Dmitry A. Durnev
019: * @version $Revision$
020: */package java.awt;
021:
022: import java.awt.Scrollbar.AccessibleAWTScrollBar;
023:
024: import javax.accessibility.AccessibleContext;
025: import javax.accessibility.AccessibleRole;
026: import javax.accessibility.AccessibleState;
027: import javax.accessibility.AccessibleStateSet;
028: import javax.accessibility.AccessibleValue;
029:
030: import junit.framework.TestCase;
031:
032: /**
033: * AccessibleAWTScrollBarTest
034: */
035: public class AccessibleAWTScrollBarTest extends TestCase {
036: Scrollbar scrollbar;
037: AccessibleContext ac;
038:
039: @Override
040: protected void setUp() throws Exception {
041: super .setUp();
042: scrollbar = new Scrollbar();
043: ac = scrollbar.getAccessibleContext();
044: }
045:
046: public final void testGetAccessibleRole() {
047: assertSame(AccessibleRole.SCROLL_BAR, ac.getAccessibleRole());
048: }
049:
050: public final void testGetAccessibleStateSet() {
051: AccessibleStateSet ass = ac.getAccessibleStateSet();
052: assertTrue(ass.contains(AccessibleState.VERTICAL));
053: scrollbar = new Scrollbar(Scrollbar.HORIZONTAL);
054: ac = scrollbar.getAccessibleContext();
055: ass = ac.getAccessibleStateSet();
056: assertFalse(ass.contains(AccessibleState.VERTICAL));
057: assertTrue(ass.contains(AccessibleState.HORIZONTAL));
058: }
059:
060: public final void testGetAccessibleValue() {
061: assertNotNull(ac.getAccessibleValue());
062: assertTrue(ac.getAccessibleValue() instanceof AccessibleAWTScrollBar);
063: }
064:
065: public final void testAccessibleAWTScrollBar() {
066: assertTrue(ac instanceof AccessibleAWTScrollBar);
067: }
068:
069: public final void testGetCurrentAccessibleValue() {
070: AccessibleValue av = ac.getAccessibleValue();
071: assertEquals(new Integer(0), av.getCurrentAccessibleValue());
072: int val = 13;
073: scrollbar.setValue(val);
074: assertEquals(new Integer(val), av.getCurrentAccessibleValue());
075: }
076:
077: public final void testGetMaximumAccessibleValue() {
078: AccessibleValue av = ac.getAccessibleValue();
079: assertEquals(new Integer(100), av.getMaximumAccessibleValue());
080: int val = 666;
081: scrollbar.setMaximum(val);
082: assertEquals(new Integer(val), av.getMaximumAccessibleValue());
083: }
084:
085: public final void testGetMinimumAccessibleValue() {
086: AccessibleValue av = ac.getAccessibleValue();
087: assertEquals(new Integer(0), av.getMinimumAccessibleValue());
088: int val = -10;
089: scrollbar.setMinimum(val);
090: assertEquals(new Integer(val), av.getMinimumAccessibleValue());
091: }
092:
093: public final void testSetCurrentAccessibleValue() {
094: AccessibleValue av = ac.getAccessibleValue();
095: int val = 25;
096: assertTrue(av.setCurrentAccessibleValue(new Integer(25)));
097: assertEquals(val, scrollbar.getValue());
098: assertEquals(new Integer(val), av.getCurrentAccessibleValue());
099: assertTrue(av.setCurrentAccessibleValue(new Integer(
100: Integer.MAX_VALUE)));
101: assertEquals(90, scrollbar.getValue());
102: }
103:
104: }
|