Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 294639 - [ExpandBar] accepts indexOf( null )
Summary: [ExpandBar] accepts indexOf( null )
Status: RESOLVED FIXED
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: 1.3   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 1.3 M4   Edit
Assignee: Dominik Ebert CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-09 12:53 EST by Benjamin Muskalla CLA
Modified: 2009-12-03 09:47 EST (History)
2 users (show)

See Also:


Attachments
Final draft (2.76 KB, patch)
2009-11-24 11:38 EST, Dominik Ebert CLA
no flags Details | Diff
Final draft for ExpandBar (2.26 KB, patch)
2009-11-25 03:13 EST, Dominik Ebert CLA
no flags Details | Diff
Final draft for ExpandBar (2.26 KB, patch)
2009-11-25 07:20 EST, Dominik Ebert CLA
ruediger.herrmann: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Muskalla CLA 2009-11-09 12:53:15 EST
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
    }
  }
Comment 1 Dominik Ebert CLA 2009-11-24 11:38:59 EST
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.
Comment 2 Ivan Furnadjiev CLA 2009-11-25 01:31:29 EST
Attached patch is for Combo... not for ExpandBar.
Comment 3 Dominik Ebert CLA 2009-11-25 03:13:05 EST
Created attachment 153039 [details]
Final draft for ExpandBar

I'm sorry, this should be the correct patch for ExpandBar
Comment 4 Dominik Ebert CLA 2009-11-25 03:14:44 EST
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 );
>   }
>
Comment 5 Dominik Ebert CLA 2009-11-25 07:20:24 EST
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.
Comment 6 Rüdiger Herrmann CLA 2009-12-03 09:47:14 EST
Applied patch to CVS HEAD