Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRüdiger Herrmann2011-01-24 10:37:38 +0000
committerRüdiger Herrmann2011-01-24 10:37:38 +0000
commitc819adf583bc04f1c51b9bcab667b96115235be3 (patch)
treeb83ee31f2928adb29808ecd3325d8b76c835fd7e /tests
parent2031ea94bacb02d886a5f2701f2565103fa36f33 (diff)
downloadorg.eclipse.rap-c819adf583bc04f1c51b9bcab667b96115235be3.tar.gz
org.eclipse.rap-c819adf583bc04f1c51b9bcab667b96115235be3.tar.xz
org.eclipse.rap-c819adf583bc04f1c51b9bcab667b96115235be3.zip
RESOLVED 335112: ToolTip widget is missing
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.rap.rwt.q07.test/src/org/eclipse/RWTQ07TestSuite.java3
-rw-r--r--tests/org.eclipse.rap.rwt.q07.test/src/org/eclipse/swt/internal/widgets/tooltipkit/ToolTipLCA_Test.java170
-rw-r--r--tests/org.eclipse.rap.rwt.test/src/org/eclipse/RWTHostTestSuite.java1
-rw-r--r--tests/org.eclipse.rap.rwt.test/src/org/eclipse/swt/internal/widgets/WidgetTreeVisitor_Test.java38
-rw-r--r--tests/org.eclipse.rap.rwt.test/src/org/eclipse/swt/widgets/Shell_Test.java32
-rw-r--r--tests/org.eclipse.rap.rwt.test/src/org/eclipse/swt/widgets/ToolTip_Test.java194
6 files changed, 422 insertions, 16 deletions
diff --git a/tests/org.eclipse.rap.rwt.q07.test/src/org/eclipse/RWTQ07TestSuite.java b/tests/org.eclipse.rap.rwt.q07.test/src/org/eclipse/RWTQ07TestSuite.java
index 1a699ebb50..0cad43f6b0 100644
--- a/tests/org.eclipse.rap.rwt.q07.test/src/org/eclipse/RWTQ07TestSuite.java
+++ b/tests/org.eclipse.rap.rwt.q07.test/src/org/eclipse/RWTQ07TestSuite.java
@@ -58,6 +58,7 @@ import org.eclipse.swt.internal.widgets.tableitemkit.TableItemLCA_Test;
import org.eclipse.swt.internal.widgets.tablekit.TableLCA_Test;
import org.eclipse.swt.internal.widgets.textkit.TextLCA_Test;
import org.eclipse.swt.internal.widgets.toolitemkit.ToolItemLCA_Test;
+import org.eclipse.swt.internal.widgets.tooltipkit.ToolTipLCA_Test;
import org.eclipse.swt.internal.widgets.treecolumnkit.TreeColumnLCA_Test;
import org.eclipse.swt.internal.widgets.treeitemkit.TreeItemLCA_Test;
import org.eclipse.swt.internal.widgets.treekit.TreeLCA_Test;
@@ -143,7 +144,7 @@ public class RWTQ07TestSuite {
suite.addTestSuite( DNDSupport_Test.class );
suite.addTestSuite( CanvasLCA_Test.class );
suite.addTestSuite( GCOperationWriter_Test.class );
-
+ suite.addTestSuite( ToolTipLCA_Test.class );
return suite;
}
} \ No newline at end of file
diff --git a/tests/org.eclipse.rap.rwt.q07.test/src/org/eclipse/swt/internal/widgets/tooltipkit/ToolTipLCA_Test.java b/tests/org.eclipse.rap.rwt.q07.test/src/org/eclipse/swt/internal/widgets/tooltipkit/ToolTipLCA_Test.java
new file mode 100644
index 0000000000..eaa10a3d1b
--- /dev/null
+++ b/tests/org.eclipse.rap.rwt.q07.test/src/org/eclipse/swt/internal/widgets/tooltipkit/ToolTipLCA_Test.java
@@ -0,0 +1,170 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Rdiger Herrmann and others. All rights reserved.
+ * 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:
+ * Rdiger Herrmann - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.swt.internal.widgets.tooltipkit;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.eclipse.rwt.Fixture;
+import org.eclipse.rwt.internal.lifecycle.JSConst;
+import org.eclipse.rwt.lifecycle.IWidgetAdapter;
+import org.eclipse.rwt.lifecycle.WidgetUtil;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.*;
+
+
+public class ToolTipLCA_Test extends TestCase {
+ private Display display;
+ private Shell shell;
+ private ToolTip toolTip;
+
+ public void testPreserveVisible() {
+ toolTip.setVisible( true );
+ Fixture.preserveWidgets();
+ assertEquals( Boolean.TRUE, getPreserved( ToolTipLCA.PROP_VISIBLE ) );
+ }
+
+ public void testPreserveLocation() {
+ Point location = new Point( 1, 2 );
+ toolTip.setLocation( location );
+ Fixture.preserveWidgets();
+ assertEquals( location, getPreserved( ToolTipLCA.PROP_LOCATION ) );
+ }
+
+ public void testPreserveText() {
+ final String text = "text";
+ toolTip.setText( text );
+ Fixture.preserveWidgets();
+ assertEquals( text, getPreserved( ToolTipLCA.PROP_TEXT ) );
+ }
+
+ public void testPreserveMessage() {
+ final String text = "message";
+ toolTip.setMessage( text );
+ Fixture.preserveWidgets();
+ assertEquals( text, getPreserved( ToolTipLCA.PROP_MESSAGE ) );
+ }
+
+ public void testPreserveAutoHide() {
+ toolTip.setAutoHide( false );
+ Fixture.preserveWidgets();
+ assertEquals( Boolean.FALSE, getPreserved( ToolTipLCA.PROP_AUTO_HIDE ) );
+ }
+
+ public void testPreserveSelectionListeners() {
+ SelectionListener selectionListener = new SelectionAdapter() { };
+ toolTip.addSelectionListener( selectionListener );
+ Fixture.preserveWidgets();
+ assertEquals( Boolean.TRUE,
+ getPreserved( ToolTipLCA.PROP_SELECTION_LISTENER ) );
+ }
+
+ public void testReadVisibleWithRequestParamFalse() {
+ toolTip.setVisible( true );
+ String toolTipId = WidgetUtil.getId( toolTip );
+ Fixture.fakeRequestParam( toolTipId + ".visible", "false" );
+ Fixture.readDataAndProcessAction( display );
+ assertFalse( toolTip.isVisible() );
+ }
+
+ public void testReadVisibleWithNoRequestParam() {
+ toolTip.setVisible( true );
+ Fixture.readDataAndProcessAction( display );
+ assertTrue( toolTip.isVisible() );
+ }
+
+ public void testSelectionEvent() {
+ final SelectionEvent[] eventLog = { null };
+ toolTip.addSelectionListener( new SelectionAdapter() {
+ public void widgetSelected( final SelectionEvent event ) {
+ eventLog[ 0 ] = event;
+ }
+ } );
+ String toolTipId = WidgetUtil.getId( toolTip );
+ Fixture.fakeRequestParam( JSConst.EVENT_WIDGET_SELECTED, toolTipId );
+ Fixture.readDataAndProcessAction( display );
+ SelectionEvent event = eventLog[ 0 ];
+ assertNotNull( event );
+ assertSame( toolTip, event.widget );
+ assertTrue( event.doit );
+ assertNull( event.data );
+ assertNull( event.text );
+ assertEquals( 0, event.detail );
+ assertEquals( 0, event.y );
+ assertEquals( 0, event.y );
+ assertEquals( 0, event.width );
+ assertEquals( 0, event.height );
+ assertSame( display, event.display );
+ assertNull( event.item );
+ }
+
+ public void testPropertySetterOrderInRenderChanges() throws IOException {
+ toolTip.setText( "text" );
+ toolTip.setMessage( "message" );
+ toolTip.setAutoHide( false );
+ toolTip.setLocation( 1, 2 );
+ toolTip.setVisible( true );
+ Fixture.markInitialized( toolTip );
+ new ToolTipLCA().renderChanges( toolTip );
+ String markup = Fixture.getAllMarkup();
+ int setVisibleIndex = markup.indexOf( "setVisible" );
+ assertTrue( markup.indexOf( "setText" ) < setVisibleIndex );
+ assertTrue( markup.indexOf( "setMessage" ) < setVisibleIndex );
+ assertTrue( markup.indexOf( "setLocation" ) < setVisibleIndex );
+ assertTrue( markup.indexOf( "setHideAfterTimeout" ) < setVisibleIndex );
+ }
+
+ public void testEscapeText() throws IOException {
+ toolTip.setText( "E<s>ca'pe\" && me" );
+ ToolTipLCA.writeText( toolTip );
+ String expected = "w.setText( \"E&lt;s&gt;ca'pe&quot; &amp;&amp; me\" );";
+ assertTrue( Fixture.getAllMarkup().indexOf( expected ) > -1 );
+ }
+
+ public void testEscapeMessage() throws IOException {
+ toolTip.setMessage( "E<s>ca'pe\" && me\n" );
+ ToolTipLCA.writeMessage( toolTip );
+ String expected
+ = "w.setMessage( \"E&lt;s&gt;ca'pe&quot; &amp;&amp; me<br/>\" );";
+ assertTrue( Fixture.getAllMarkup().indexOf( expected ) > -1 );
+ }
+
+ public void testGetImageWithErrorIconStyle() {
+ ToolTip toolTip = new ToolTip( shell, SWT.ICON_ERROR );
+ assertNotNull( ToolTipLCA.getImage( toolTip ) );
+ }
+
+ public void testGetImageWithNoStyle() {
+ ToolTip toolTip = new ToolTip( shell, SWT.NONE );
+ assertNull( ToolTipLCA.getImage( toolTip ) );
+ }
+
+ private Object getPreserved( String propertyName ) {
+ IWidgetAdapter adapter = WidgetUtil.getAdapter( toolTip );
+ return adapter.getPreserved( propertyName );
+ }
+
+ protected void setUp() throws Exception {
+ Fixture.setUp();
+ Fixture.fakeResponseWriter();
+ display = new Display();
+ shell = new Shell( display, SWT.NONE );
+ toolTip = new ToolTip( shell, SWT.NONE );
+ Fixture.markInitialized( display );
+ }
+
+ protected void tearDown() throws Exception {
+ Fixture.tearDown();
+ }
+}
diff --git a/tests/org.eclipse.rap.rwt.test/src/org/eclipse/RWTHostTestSuite.java b/tests/org.eclipse.rap.rwt.test/src/org/eclipse/RWTHostTestSuite.java
index f032c197b0..b8c0d97c0d 100644
--- a/tests/org.eclipse.rap.rwt.test/src/org/eclipse/RWTHostTestSuite.java
+++ b/tests/org.eclipse.rap.rwt.test/src/org/eclipse/RWTHostTestSuite.java
@@ -174,6 +174,7 @@ public class RWTHostTestSuite {
suite.addTestSuite( ByteArrayTransfer_Test.class );
suite.addTestSuite( Tree_Test.class );
suite.addTestSuite( TreeItem_Test.class );
+ suite.addTestSuite( ToolTip_Test.class );
suite.addTestSuite( Image_Test.class );
suite.addTestSuite( ImageData_Test.class );
diff --git a/tests/org.eclipse.rap.rwt.test/src/org/eclipse/swt/internal/widgets/WidgetTreeVisitor_Test.java b/tests/org.eclipse.rap.rwt.test/src/org/eclipse/swt/internal/widgets/WidgetTreeVisitor_Test.java
index 495abeca31..f35ea8e470 100644
--- a/tests/org.eclipse.rap.rwt.test/src/org/eclipse/swt/internal/widgets/WidgetTreeVisitor_Test.java
+++ b/tests/org.eclipse.rap.rwt.test/src/org/eclipse/swt/internal/widgets/WidgetTreeVisitor_Test.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2009 Innoopract Informationssysteme GmbH.
+ * Copyright (c) 2002, 2011 Innoopract Informationssysteme GmbH.
* 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
@@ -21,9 +21,10 @@ import org.eclipse.swt.widgets.*;
public class WidgetTreeVisitor_Test extends TestCase {
+ private Display display;
+ private Shell shell;
+
public void testTreeVisitor() {
- Display display = new Display();
- Composite shell = new Shell( display , SWT.NONE );
Control control1 = new Button( shell, SWT.PUSH );
Composite composite = new Composite( shell, SWT.NONE );
final Control control2 = new Button( composite, SWT.PUSH );
@@ -85,8 +86,6 @@ public class WidgetTreeVisitor_Test extends TestCase {
}
public void testTreeVisitorWithTable() {
- Display display = new Display();
- final Shell shell = new Shell( display , SWT.NONE );
Table table = new Table( shell, SWT.NONE );
TableItem item1 = new TableItem( table, SWT.NONE );
TableColumn column1 = new TableColumn( table, SWT.NONE );
@@ -119,8 +118,6 @@ public class WidgetTreeVisitor_Test extends TestCase {
}
public void testTreeVisitorWithToolBar() {
- Display display = new Display();
- final Shell shell = new Shell( display , SWT.NONE );
ToolBar toolBar = new ToolBar( shell, SWT.NONE );
ToolItem toolItem = new ToolItem( toolBar, SWT.NONE );
final int[] count = {
@@ -149,8 +146,6 @@ public class WidgetTreeVisitor_Test extends TestCase {
}
public void testTreeVisitorWithMenus() {
- Display display = new Display();
- final Shell shell = new Shell( display , SWT.NONE );
Menu menuBar = new Menu( shell, SWT.BAR );
shell.setMenuBar( menuBar );
Menu shellMenu = new Menu( shell );
@@ -180,8 +175,6 @@ public class WidgetTreeVisitor_Test extends TestCase {
}
public void testTreeVisitorWithDecoration() {
- Display display = new Display();
- final Shell shell = new Shell( display , SWT.NONE );
Control control1 = new Button( shell, SWT.PUSH );
Decorator decoration1 = new Decorator( control1, SWT.RIGHT );
Composite composite = new Composite( shell, SWT.NONE );
@@ -201,7 +194,6 @@ public class WidgetTreeVisitor_Test extends TestCase {
assertEquals( 1, count[ 0 ] );
count[ 0 ] = 0;
WidgetTreeVisitor.accept( shell, new AllWidgetTreeVisitor() {
-
public boolean doVisit( final Widget widget ) {
assertSame( widget, elements[ count[ 0 ] ] );
count[ 0 ]++;
@@ -212,8 +204,6 @@ public class WidgetTreeVisitor_Test extends TestCase {
}
public void testTreeVisitorWithDragSource() {
- Display display = new Display();
- final Shell shell = new Shell( display , SWT.NONE );
DragSource compositeDragSource = new DragSource( shell, SWT.NONE );
Text text = new Text( shell, SWT.NONE );
DragSource controlDragSource = new DragSource( text, SWT.NONE );
@@ -230,9 +220,29 @@ public class WidgetTreeVisitor_Test extends TestCase {
} );
assertEquals( 4, count[ 0 ] );
}
+
+ public void testTreeVisitorWithToolTip() {
+ Control control = new Label( shell, SWT.NONE );
+ ToolTip toolTip = new ToolTip( shell, SWT.NONE );
+ final int[] count = { 0 };
+ final Object[] elements = new Object[]{
+ shell, control, toolTip
+ };
+ WidgetTreeVisitor.accept( shell, new AllWidgetTreeVisitor() {
+ public boolean doVisit( final Widget widget ) {
+ assertSame( elements[ count[ 0 ] ], widget );
+ count[ 0 ]++;
+ return true;
+ }
+ } );
+ assertEquals( 3, count[ 0 ] );
+
+ }
protected void setUp() throws Exception {
Fixture.setUp();
+ display = new Display();
+ shell = new Shell( display , SWT.NONE );
}
protected void tearDown() throws Exception {
diff --git a/tests/org.eclipse.rap.rwt.test/src/org/eclipse/swt/widgets/Shell_Test.java b/tests/org.eclipse.rap.rwt.test/src/org/eclipse/swt/widgets/Shell_Test.java
index 04bdbab0a3..378951ab43 100644
--- a/tests/org.eclipse.rap.rwt.test/src/org/eclipse/swt/widgets/Shell_Test.java
+++ b/tests/org.eclipse.rap.rwt.test/src/org/eclipse/swt/widgets/Shell_Test.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
+ * Copyright (c) 2002, 2011 Innoopract Informationssysteme GmbH.
* 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
@@ -736,7 +736,37 @@ public class Shell_Test extends TestCase {
shell1.setFullScreen( true );
assertEquals( shell1, display.getActiveShell() );
}
+
+ public void testGetToolTipsWhenNoToolTipWasCreated() {
+ Display display = new Display();
+ Shell shell = new Shell( display );
+ IShellAdapter adapter
+ = ( IShellAdapter )shell.getAdapter( IShellAdapter.class );
+ assertNotNull( adapter.getToolTips() );
+ assertEquals( 0, adapter.getToolTips().length );
+ }
+ public void testGetToolTipsWhenToolTipWasCreated() {
+ Display display = new Display();
+ Shell shell = new Shell( display );
+ ToolTip toolTip = new ToolTip( shell, SWT.NONE );
+ IShellAdapter adapter
+ = ( IShellAdapter )shell.getAdapter( IShellAdapter.class );
+ assertEquals( 1, adapter.getToolTips().length );
+ assertEquals( toolTip, adapter.getToolTips()[ 0 ] );
+ }
+
+ public void testGetToolTipsAfterToolTipWasDisposed() {
+ Display display = new Display();
+ Shell shell = new Shell( display );
+ ToolTip toolTip = new ToolTip( shell, SWT.NONE );
+ toolTip.dispose();
+ IShellAdapter adapter
+ = ( IShellAdapter )shell.getAdapter( IShellAdapter.class );
+ assertNotNull( adapter.getToolTips() );
+ assertEquals( 0, adapter.getToolTips().length );
+ }
+
private static IDisplayAdapter getDisplayAdapter( final Display display ) {
Object adapter = display.getAdapter( IDisplayAdapter.class );
return ( IDisplayAdapter )adapter;
diff --git a/tests/org.eclipse.rap.rwt.test/src/org/eclipse/swt/widgets/ToolTip_Test.java b/tests/org.eclipse.rap.rwt.test/src/org/eclipse/swt/widgets/ToolTip_Test.java
new file mode 100644
index 0000000000..520123bbe3
--- /dev/null
+++ b/tests/org.eclipse.rap.rwt.test/src/org/eclipse/swt/widgets/ToolTip_Test.java
@@ -0,0 +1,194 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Rdiger Herrmann 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:
+ * Rdiger Herrmann - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.swt.widgets;
+
+import junit.framework.TestCase;
+
+import org.eclipse.rwt.Fixture;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.internal.widgets.IToolTipAdapter;
+
+
+public class ToolTip_Test extends TestCase {
+
+ private Display display;
+ private Shell shell;
+
+ public void testConstructorWithNullParent() {
+ try {
+ new ToolTip( null, SWT.NONE ) ;
+ } catch( IllegalArgumentException expected ) {
+ }
+ }
+
+ public void testInitialValue() {
+ ToolTip toolTip = new ToolTip( shell, SWT.NONE ) ;
+ assertTrue( toolTip.getAutoHide() );
+ assertFalse( toolTip.isVisible() );
+ assertEquals( "", toolTip.getText() );
+ assertEquals( "", toolTip.getMessage() );
+ Point location = getToolTipAdapter( toolTip ).getLocation();
+ assertEquals( display.getCursorLocation(), location );
+ }
+
+ public void testGetParent() {
+ ToolTip toolTip = new ToolTip( shell, SWT.NONE ) ;
+ assertSame( shell, toolTip.getParent() );
+ }
+
+ public void testGetDisplay() {
+ ToolTip toolTip = new ToolTip( shell, SWT.NONE ) ;
+ assertSame( shell.getDisplay(), toolTip.getDisplay() );
+ }
+
+ public void testAutoHide() {
+ ToolTip toolTip = new ToolTip( shell, SWT.NONE ) ;
+ toolTip.setAutoHide( false );
+ assertFalse( toolTip.getAutoHide() );
+ }
+
+ public void testVisible() {
+ ToolTip toolTip = new ToolTip( shell, SWT.NONE ) ;
+ toolTip.setVisible( true );
+ assertTrue( toolTip.isVisible() );
+ }
+
+ public void testText() {
+ final String text = "text";
+ ToolTip toolTip = new ToolTip( shell, SWT.NONE ) ;
+ toolTip.setText( text );
+ assertEquals( text, toolTip.getText() );
+ }
+
+ public void testSetTextWithNullArgument() {
+ ToolTip toolTip = new ToolTip( shell, SWT.NONE ) ;
+ try {
+ toolTip.setText( null );
+ } catch( Exception expected ) {
+ }
+ }
+
+ public void testMessage() {
+ final String message = "message";
+ ToolTip toolTip = new ToolTip( shell, SWT.NONE ) ;
+ toolTip.setMessage( message );
+ assertEquals( message, toolTip.getMessage() );
+ }
+
+ public void testSetMessageWithNullArgument() {
+ ToolTip toolTip = new ToolTip( shell, SWT.NONE ) ;
+ try {
+ toolTip.setMessage( null );
+ } catch( Exception expected ) {
+ }
+ }
+
+ public void testSetLocationXY() {
+ ToolTip toolTip = new ToolTip( shell, SWT.NONE ) ;
+ toolTip.setLocation( 1, 2 );
+ IToolTipAdapter adapter = getToolTipAdapter( toolTip );
+ Point location = adapter.getLocation();
+ assertEquals( 1, location.x );
+ assertEquals( 2, location.y );
+ }
+
+ public void testSetLocationPoint() {
+ ToolTip toolTip = new ToolTip( shell, SWT.NONE ) ;
+ Point location = new Point( 1, 2 );
+ toolTip.setLocation( location );
+ IToolTipAdapter adapter = getToolTipAdapter( toolTip );
+ Point returnedLocation = adapter.getLocation();
+ assertNotSame( location, returnedLocation );
+ assertEquals( 1, returnedLocation.x );
+ assertEquals( 2, returnedLocation.y );
+ }
+
+ public void testSetLocationPointWithNullArgument() {
+ ToolTip toolTip = new ToolTip( shell, SWT.NONE ) ;
+ try {
+ toolTip.setLocation( null );
+ } catch( IllegalArgumentException expected ) {
+ }
+ }
+
+ public void testGetStyle() {
+ ToolTip toolTip = new ToolTip( shell, SWT.BALLOON );
+ assertTrue( ( toolTip.getStyle() & SWT.BALLOON ) != 0 );
+ toolTip = new ToolTip( shell, SWT.ICON_ERROR );
+ assertTrue( ( toolTip.getStyle() & SWT.ICON_ERROR ) != 0 );
+ toolTip = new ToolTip( shell, SWT.ICON_INFORMATION );
+ assertTrue( ( toolTip.getStyle() & SWT.ICON_INFORMATION ) != 0 );
+ toolTip = new ToolTip( shell, SWT.ICON_WARNING );
+ assertTrue( ( toolTip.getStyle() & SWT.ICON_WARNING ) != 0 );
+ }
+
+ public void testGetStyleWithOverlappingIconBits() {
+ int style = SWT.ICON_ERROR | SWT.ICON_INFORMATION;
+ ToolTip toolTip = new ToolTip( shell, style );
+ assertTrue( ( toolTip.getStyle() & SWT.ICON_ERROR ) == 0 );
+ assertTrue( ( toolTip.getStyle() & SWT.ICON_INFORMATION ) != 0 );
+ }
+
+ public void testAddSelectionListener() {
+ ToolTip toolTip = new ToolTip( shell, SWT.NONE );
+ SelectionAdapter selectionListener = new SelectionAdapter() { };
+ toolTip.addSelectionListener( selectionListener );
+ Object[] listeners = SelectionEvent.getListeners( toolTip );
+ assertSame( selectionListener, listeners[ 0 ] );
+ }
+
+ public void testAddSelectionListenerWithNullArgument() {
+ ToolTip toolTip = new ToolTip( shell, SWT.NONE );
+ try {
+ toolTip.addSelectionListener( null );
+ } catch( IllegalArgumentException expected ) {
+ }
+ }
+
+ public void testRemoveSelectionListener() {
+ ToolTip toolTip = new ToolTip( shell, SWT.NONE );
+ SelectionAdapter selectionListener = new SelectionAdapter() { };
+ toolTip.addSelectionListener( selectionListener );
+ toolTip.removeSelectionListener( selectionListener );
+ Object[] listeners = SelectionEvent.getListeners( toolTip );
+ assertEquals( 0, listeners.length );
+ }
+
+ public void testRemoveSelectionListenerWithNullArgument() {
+ ToolTip toolTip = new ToolTip( shell, SWT.NONE );
+ try {
+ toolTip.removeSelectionListener( null );
+ } catch( IllegalArgumentException expected ) {
+ }
+ }
+
+ public void testDisposeParent() {
+ ToolTip toolTip = new ToolTip( shell, SWT.NONE );
+ shell.dispose();
+ assertTrue( toolTip.isDisposed() );
+ }
+
+ protected void setUp() throws Exception {
+ Fixture.setUp();
+ display = new Display();
+ shell = new Shell( display , SWT.NONE );
+ }
+
+ protected void tearDown() throws Exception {
+ Fixture.tearDown();
+ }
+
+ private static IToolTipAdapter getToolTipAdapter( ToolTip toolTip ) {
+ return ( IToolTipAdapter )toolTip.getAdapter( IToolTipAdapter.class );
+ }
+}

Back to the top