Community
Participate
Working Groups
null is not allowed for indexOf public void testIndexOfNull() { Display display = new Display(); Shell shell = new Shell( display ); ExpandBar expandBar = new ExpandBar( shell, SWT.NONE ); try { expandBar.indexOf( null ); fail( "No exception thrown for expandItem == null" ); } catch( IllegalArgumentException e ) { // expected } }
Created attachment 152972 [details] Final draft Implemented that ExpandBar#indexOf( null ) throws an IllegalArgumentException. I used the test method above. I also implemented that ExpandBar#indexOf(Item item) throws an IllegalArgumentException if the item is disposed. This may fit to bug #294593. I also added a test method ExpandBar_Test#testIndexOfDisposed() to test the behaviour if the method ExpandBar#indexOf(Item item) receives a disposed argument.
Attached patch is for Combo... not for ExpandBar.
Created attachment 153039 [details] Final draft for ExpandBar I'm sorry, this should be the correct patch for ExpandBar
Comment on attachment 153039 [details] Final draft for ExpandBar >### Eclipse Workspace Patch 1.0 >#P org.eclipse.rap.rwt.test >Index: src/org/eclipse/swt/widgets/ExpandBar_Test.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt.test/org.eclipse.rap.rwt.test/src/org/eclipse/swt/widgets/ExpandBar_Test.java,v >retrieving revision 1.2 >diff -u -r1.2 ExpandBar_Test.java >--- src/org/eclipse/swt/widgets/ExpandBar_Test.java 10 Nov 2009 11:39:43 -0000 1.2 >+++ src/org/eclipse/swt/widgets/ExpandBar_Test.java 24 Nov 2009 16:34:19 -0000 >@@ -131,4 +131,30 @@ > expandBar.notifyListeners( SWT.Collapse, new Event() ); > assertEquals( "expanded|collapsed", log.toString() ); > } >+ >+ public void testIndexOfNull() { >+ Display display = new Display(); >+ Shell shell = new Shell( display ); >+ ExpandBar expandBar = new ExpandBar( shell, SWT.NONE ); >+ try { >+ expandBar.indexOf( null ); >+ fail( "No exception thrown for expandItem == null" ); >+ } catch( IllegalArgumentException e ) { >+ // expected >+ } >+ } >+ >+ public void testIndexOfDisposed() { >+ Display display = new Display(); >+ Shell shell = new Shell( display ); >+ ExpandBar expandBar = new ExpandBar( shell, SWT.NONE ); >+ ExpandItem item = new ExpandItem( expandBar, SWT.NONE ); >+ item.dispose(); >+ try { >+ expandBar.indexOf( item ); >+ fail( "No exception thrown for disposed expandItem" ); >+ } catch( IllegalArgumentException e ) { >+ // expected >+ } >+ } > } >#P org.eclipse.rap.rwt >Index: src/org/eclipse/swt/widgets/ExpandBar.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/ExpandBar.java,v >retrieving revision 1.5 >diff -u -r1.5 ExpandBar.java >--- src/org/eclipse/swt/widgets/ExpandBar.java 16 Oct 2009 08:05:47 -0000 1.5 >+++ src/org/eclipse/swt/widgets/ExpandBar.java 24 Nov 2009 16:34:20 -0000 >@@ -343,6 +343,12 @@ > */ > public int indexOf( final ExpandItem item ) { > checkWidget(); >+ if( item == null ) { >+ error( SWT.ERROR_NULL_ARGUMENT ); >+ } >+ if( item.isDisposed() ) { >+ error( SWT.ERROR_INVALID_ARGUMENT ); >+ } > return itemHolder.indexOf( item ); > } >
Created attachment 153057 [details] Final draft for ExpandBar Sorry, i am new to the bugzilla system and i made some mistakes in uploading the correct patch. So please ignore my previous patch and comments.
Applied patch to CVS HEAD