/******************************************************************************* * Copyright (c) 2000, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.swt.tests.junit; import junit.framework.*; import junit.textui.*; import org.eclipse.swt.SWT; import org.eclipse.swt.events.*; import org.eclipse.swt.widgets.*; /** * Automated Test Suite for class org.eclipse.swt.widgets.Slider * * @see org.eclipse.swt.widgets.Slider */ public class Test_org_eclipse_swt_widgets_Slider extends Test_org_eclipse_swt_widgets_Control { public Test_org_eclipse_swt_widgets_Slider(String name) { super(name); } public static void main(String[] args) { TestRunner.run(suite()); } protected void setUp() { super.setUp(); slider = new Slider(shell, 0); setWidget(slider); } protected void tearDown() { super.tearDown(); } protected String valueString(int[] intArray) { return " ("+intArray[1]+","+intArray[2]+","+intArray[3]+","+intArray[4]+")"; } public void test_ConstructorLorg_eclipse_swt_widgets_CompositeI() { try { slider = new Slider(null, 0); fail("No exception thrown for parent == null"); } catch (IllegalArgumentException e) { } int[] cases = {0, SWT.HORIZONTAL, SWT.VERTICAL}; for (int i = 0; i < cases.length; i++) slider = new Slider(shell, cases[i]); } public void test_addSelectionListenerLorg_eclipse_swt_events_SelectionListener() { listenerCalled = false; boolean exceptionThrown = false; SelectionListener listener = new SelectionListener() { public void widgetSelected(SelectionEvent event) { listenerCalled = true; } public void widgetDefaultSelected(SelectionEvent event) { } }; try { slider.addSelectionListener(null); } catch (IllegalArgumentException e) { exceptionThrown = true; } assertTrue("Expected exception not thrown", exceptionThrown); exceptionThrown = false; slider.addSelectionListener(listener); slider.setSelection(0); assertTrue(":a:", listenerCalled == false); slider.removeSelectionListener(listener); try { slider.removeSelectionListener(null); } catch (IllegalArgumentException e) { exceptionThrown = true; } assertTrue("Expected exception not thrown", exceptionThrown); } public void test_computeSizeIIZ() { // super class method sufficient test } public void test_getEnabled() { // tested in setEnabled method } public void test_getIncrement() { int[] cases = {1, 10, 10000}; for (int i=0; i