Use TextSizeUtil#markupExtent if markup is enabled

Switch GridItem_Test to JUnit4 and optimize the tests.

430707: Exclude markup for preferred width calculation
(GridItem/TableItem)
https://bugs.eclipse.org/bugs/show_bug.cgi?id=430707
diff --git a/bundles/org.eclipse.rap.nebula.widgets.grid/src/org/eclipse/nebula/widgets/grid/GridItem.java b/bundles/org.eclipse.rap.nebula.widgets.grid/src/org/eclipse/nebula/widgets/grid/GridItem.java
index af73cb9..2913554 100644
--- a/bundles/org.eclipse.rap.nebula.widgets.grid/src/org/eclipse/nebula/widgets/grid/GridItem.java
+++ b/bundles/org.eclipse.rap.nebula.widgets.grid/src/org/eclipse/nebula/widgets/grid/GridItem.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2012, 2013 EclipseSource and others.
+ * Copyright (c) 2012, 2014 EclipseSource 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
@@ -10,6 +10,8 @@
  ******************************************************************************/
 package org.eclipse.nebula.widgets.grid;
 
+import static org.eclipse.rap.rwt.internal.textsize.TextSizeUtil.markupExtent;
+import static org.eclipse.rap.rwt.internal.textsize.TextSizeUtil.stringExtent;
 import static org.eclipse.swt.internal.widgets.MarkupUtil.isMarkupEnabledFor;
 import static org.eclipse.swt.internal.widgets.MarkupValidator.isValidationDisabledFor;
 
@@ -17,7 +19,6 @@
 import java.util.Iterator;
 
 import org.eclipse.nebula.widgets.grid.internal.IGridItemAdapter;
-import org.eclipse.rap.rwt.internal.textsize.TextSizeUtil;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.Font;
@@ -1420,7 +1421,12 @@
     int result = 0;
     String text = getItemData( index ).text;
     if( text.length() > 0 ) {
-      result += TextSizeUtil.stringExtent( internalGetFont( index ), text ).x;
+      Font font = internalGetFont( index );
+      if( isMarkupEnabledFor( parent ) ) {
+        result = markupExtent( font, text, SWT.DEFAULT ).x;
+      } else {
+        result = stringExtent( font, text ).x;
+      }
     }
     return result;
   }
diff --git a/tests/org.eclipse.rap.nebula.widgets.grid.test/src/org/eclipse/nebula/widgets/grid/GridItem_Test.java b/tests/org.eclipse.rap.nebula.widgets.grid.test/src/org/eclipse/nebula/widgets/grid/GridItem_Test.java
index 6f158d7..6237a84 100644
--- a/tests/org.eclipse.rap.nebula.widgets.grid.test/src/org/eclipse/nebula/widgets/grid/GridItem_Test.java
+++ b/tests/org.eclipse.rap.nebula.widgets.grid.test/src/org/eclipse/nebula/widgets/grid/GridItem_Test.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2012, 2013 EclipseSource and others.
+ * Copyright (c) 2012, 2014 EclipseSource 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
@@ -13,13 +13,17 @@
 import static org.eclipse.nebula.widgets.grid.GridTestUtil.createGridColumns;
 import static org.eclipse.nebula.widgets.grid.GridTestUtil.createGridItems;
 import static org.eclipse.nebula.widgets.grid.GridTestUtil.loadImage;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
 
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
-import junit.framework.TestCase;
-
+import org.eclipse.rap.rwt.RWT;
 import org.eclipse.rap.rwt.lifecycle.PhaseId;
 import org.eclipse.rap.rwt.testfixture.Fixture;
 import org.eclipse.swt.SWT;
@@ -32,17 +36,21 @@
 import org.eclipse.swt.widgets.Event;
 import org.eclipse.swt.widgets.Listener;
 import org.eclipse.swt.widgets.Shell;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
 
-public class GridItem_Test extends TestCase {
+@SuppressWarnings( "deprecation" )
+public class GridItem_Test {
 
   private Display display;
   private Shell shell;
   private Grid grid;
   private List<Event> eventLog;
 
-  @Override
-  protected void setUp() throws Exception {
+  @Before
+  public void setUp() throws Exception {
     Fixture.setUp();
     Fixture.fakePhase( PhaseId.PROCESS_ACTION );
     display = new Display();
@@ -52,11 +60,12 @@
     eventLog = new ArrayList<Event>();
   }
 
-  @Override
-  protected void tearDown() throws Exception {
+  @After
+  public void tearDown() {
     Fixture.tearDown();
   }
 
+  @Test
   public void testGridItemCreation_GridParent() {
     GridItem item = new GridItem( grid, SWT.NONE );
 
@@ -69,6 +78,7 @@
     assertEquals( 1, grid.getRootItemCount() );
   }
 
+  @Test
   public void testGridItemCreation_GridItemParent() {
     GridItem parentItem = new GridItem( grid, SWT.NONE );
 
@@ -83,6 +93,7 @@
     assertEquals( 1, parentItem.getItemCount() );
   }
 
+  @Test
   public void testGridItemCreation_AtIndexWithGridParent() {
     createGridItems( grid, 5, 5 );
 
@@ -95,6 +106,7 @@
     assertEquals( 6, grid.getRootItemCount() );
   }
 
+  @Test
   public void testGridItemCreation_AtIndexWithGridItemParent() {
     createGridItems( grid, 5, 5 );
     GridItem parentItem = grid.getItem( 6 );
@@ -108,12 +120,14 @@
     assertEquals( 6, parentItem.getItemCount() );
   }
 
+  @Test
   public void testGetItemCount() {
     createGridItems( grid, 1, 10 );
 
     assertEquals( 10, grid.getItem( 0 ).getItemCount() );
   }
 
+  @Test
   public void testGetItemCount_AfterDispose() {
     GridItem[] items = createGridItems( grid, 1, 10 );
 
@@ -123,6 +137,7 @@
     assertEquals( 9, grid.getItem( 0 ).getItemCount() );
   }
 
+  @Test
   public void testGetItems() {
     GridItem[] items = createGridItems( grid, 1, 10 );
     GridItem[] expected = new GridItem[ 10 ];
@@ -131,28 +146,28 @@
     assertTrue( Arrays.equals( expected, items[ 0 ].getItems() ) );
   }
 
+  @Test
   public void testGetItem() {
     GridItem[] items = createGridItems( grid, 1, 10 );
 
     assertSame( items[ 5 ], items[ 0 ].getItem( 4 ) );
   }
 
+  @Test( expected = IndexOutOfBoundsException.class )
   public void testGetItem_InvalidIndex() {
     GridItem[] items = createGridItems( grid, 1, 10 );
 
-    try {
-      items[ 0 ].getItem( 100 );
-      fail();
-    } catch( IndexOutOfBoundsException expected ) {
-    }
+    items[ 0 ].getItem( 100 );
   }
 
+  @Test
   public void testIndexOf() {
     GridItem[] items = createGridItems( grid, 1, 10 );
 
     assertEquals( 5, items[ 0 ].indexOf( items[ 6 ] ) );
   }
 
+  @Test
   public void testIndexOf_AfterDispose() {
     GridItem[] items = createGridItems( grid, 1, 10 );
 
@@ -161,39 +176,36 @@
     assertEquals( 4, items[ 0 ].indexOf( items[ 6 ] ) );
   }
 
+  @Test( expected = IllegalArgumentException.class )
   public void testIndexOf_NullArgument() {
     GridItem[] items = createGridItems( grid, 1, 10 );
 
-    try {
-      items[ 0 ].indexOf( null );
-      fail();
-    } catch( IllegalArgumentException expected ) {
-    }
+    items[ 0 ].indexOf( null );
   }
 
+  @Test( expected = IllegalArgumentException.class )
   public void testIndexOf_WithDisposedItem() {
     GridItem[] items = createGridItems( grid, 1, 10 );
     items[ 6 ].dispose();
 
-    try {
-      items[ 0 ].indexOf( items[ 6 ] );
-      fail();
-    } catch( IllegalArgumentException expected ) {
-    }
+    items[ 0 ].indexOf( items[ 6 ] );
   }
 
+  @Test
   public void testHasChildren() {
     GridItem[] items = createGridItems( grid, 1, 10 );
 
     assertTrue( items[ 0 ].hasChildren() );
   }
 
+  @Test
   public void testHasChildren_NoChildren() {
     GridItem[] items = createGridItems( grid, 1, 0 );
 
     assertFalse( items[ 0 ].hasChildren() );
   }
 
+  @Test
   public void testHasChildren_AfterItemRemove() {
     GridItem[] items = createGridItems( grid, 1, 1 );
 
@@ -202,6 +214,7 @@
     assertFalse( items[ 0 ].hasChildren() );
   }
 
+  @Test
   public void testDispose() {
     GridItem[] items = createGridItems( grid, 1, 1 );
 
@@ -213,6 +226,7 @@
     assertEquals( 0, grid.getRootItemCount() );
   }
 
+  @Test
   public void testSendDisposeEvent() {
     GridItem[] items = createGridItems( grid, 1, 1 );
     items[ 0 ].addListener( SWT.Dispose, new LoggingListener() );
@@ -223,6 +237,7 @@
     assertSame( items[ 0 ], eventLog.get( 0 ).widget );
   }
 
+  @Test
   public void testSendDisposeEventOnGridDispose() {
     GridItem[] items = createGridItems( grid, 1, 1 );
     items[ 0 ].addListener( SWT.Dispose, new LoggingListener() );
@@ -233,6 +248,7 @@
     assertSame( items[ 0 ], eventLog.get( 0 ).widget );
   }
 
+  @Test
   public void testGetLevel() {
     GridItem[] items = createGridItems( grid, 1, 1 );
 
@@ -240,6 +256,7 @@
     assertEquals( 1, items[ 1 ].getLevel() );
   }
 
+  @Test
   public void testSetExpanded() {
     GridItem[] items = createGridItems( grid, 1, 1 );
 
@@ -252,6 +269,7 @@
     assertTrue( items[ 1 ].isVisible() );
   }
 
+  @Test
   public void testSetExpanded_ChangedFocusItem() {
     GridItem[] items = createGridItems( grid, 1, 1 );
     items[ 0 ].setExpanded( true );
@@ -262,6 +280,7 @@
     assertSame( items[ 0 ], grid.getFocusItem() );
   }
 
+  @Test
   public void testSetExpanded_ChangeSelection() {
     GridItem[] items = createGridItems( grid, 1, 1 );
     items[ 0 ].setExpanded( true );
@@ -272,6 +291,7 @@
     assertFalse( grid.isSelected( 1 ) );
   }
 
+  @Test
   public void testSetExpanded_FireSelectionEvent() {
     GridItem[] items = createGridItems( grid, 1, 1 );
     items[ 0 ].setExpanded( true );
@@ -285,6 +305,7 @@
     assertSame( items[ 0 ], event.item );
   }
 
+  @Test
   public void testIsVisibleOnCreation() {
     GridItem[] items = createGridItems( grid, 1, 1 );
     items[ 0 ].setExpanded( true );
@@ -294,6 +315,7 @@
     assertTrue( items[ 1 ].isVisible() );
   }
 
+  @Test
   public void testFireEvent() {
     GridItem item = new GridItem( grid, SWT.NONE );
     grid.addListener( SWT.Expand, new LoggingListener() );
@@ -307,6 +329,7 @@
     assertSame( item, event.item );
   }
 
+  @Test
   public void testFireCheckEvent() {
     GridItem item = new GridItem( grid, SWT.NONE );
     grid.addListener( SWT.Selection, new LoggingListener() );
@@ -322,22 +345,21 @@
     assertEquals( 3, event.index );
   }
 
+  @Test
   public void testGetText_Inital() {
     GridItem item = new GridItem( grid, SWT.NONE );
 
     assertEquals( "", item.getText() );
   }
 
+  @Test( expected = IndexOutOfBoundsException.class )
   public void testGetText_InvalidColumn() {
     GridItem item = new GridItem( grid, SWT.NONE );
 
-    try {
-      item.getText( 5 );
-      fail();
-    } catch( IndexOutOfBoundsException expected ) {
-    }
+    item.getText( 5 );
   }
 
+  @Test
   public void testGetText_AfterSet() {
     GridItem item = new GridItem( grid, SWT.NONE );
     item.setText( "foo" );
@@ -345,6 +367,7 @@
     assertEquals( "foo", item.getText() );
   }
 
+  @Test
   public void testGetText_WithColumns() {
     GridItem item = new GridItem( grid, SWT.NONE );
     createGridColumns( grid, 3, SWT.NONE );
@@ -357,6 +380,7 @@
     assertEquals( "2", item.getText( 2 ) );
   }
 
+  @Test
   public void testGetText_AfterAddColumn() {
     GridItem item = new GridItem( grid, SWT.NONE );
     createGridColumns( grid, 1, SWT.NONE );
@@ -367,6 +391,7 @@
     assertEquals( "foo", item.getText( 1 ) );
   }
 
+  @Test
   public void testGetText_AfterRemoveColumn() {
     GridItem item = new GridItem( grid, SWT.NONE );
     GridColumn[] columns = createGridColumns( grid, 2, SWT.NONE );
@@ -377,6 +402,7 @@
     assertEquals( "foo", item.getText( 0 ) );
   }
 
+  @Test
   public void testGetText_AfterRemoveAllColumns() {
     GridItem item = new GridItem( grid, SWT.NONE );
     GridColumn[] columns = createGridColumns( grid, 2, SWT.NONE );
@@ -388,26 +414,21 @@
     assertEquals( "foo", item.getText( 0 ) );
   }
 
+  @Test( expected = IndexOutOfBoundsException.class )
   public void testSetText_InvalidColumn() {
     GridItem item = new GridItem( grid, SWT.NONE );
 
-    try {
-      item.setText( 5, "foo" );
-      fail();
-    } catch( IndexOutOfBoundsException expected ) {
-    }
+    item.setText( 5, "foo" );
   }
 
+  @Test( expected = IllegalArgumentException.class )
   public void testSetText_NullArgument() {
     GridItem item = new GridItem( grid, SWT.NONE );
 
-    try {
-      item.setText( 5, null );
-      fail();
-    } catch( IllegalArgumentException expected ) {
-    }
+    item.setText( 5, null );
   }
 
+  @Test
   public void testHandleVirtual_RootItem() {
     grid = new Grid( shell, SWT.VIRTUAL );
     GridItem[] items = createGridItems( grid, 3, 3 );
@@ -422,6 +443,7 @@
     assertEquals( 4, event.index );
   }
 
+  @Test
   public void testHandleVirtual_SubItem() {
     grid = new Grid( shell, SWT.VIRTUAL );
     GridItem[] items = createGridItems( grid, 3, 3 );
@@ -436,6 +458,7 @@
     assertEquals( 1, event.index );
   }
 
+  @Test
   public void testHandleVirtual_Twice() {
     grid = new Grid( shell, SWT.VIRTUAL );
     GridItem[] items = createGridItems( grid, 3, 3 );
@@ -447,12 +470,14 @@
     assertEquals( 1, eventLog.size() );
   }
 
+  @Test
   public void testGetFont_Inital() {
     GridItem item = new GridItem( grid, SWT.NONE );
 
     assertSame( grid.getFont(), item.getFont() );
   }
 
+  @Test
   public void testGetFont() {
     GridItem item = new GridItem( grid, SWT.NONE );
     Font font = new Font( display, "Arial", 20, SWT.BOLD );
@@ -462,18 +487,16 @@
     assertSame( font, item.getFont() );
   }
 
+  @Test( expected = IllegalArgumentException.class )
   public void testSetFont_DisposedFont() {
     GridItem item = new GridItem( grid, SWT.NONE );
     Font font = new Font( display, "Arial", 20, SWT.BOLD );
     font.dispose();
 
-    try {
-      item.setFont( font );
-      fail();
-    } catch( IllegalArgumentException expected ) {
-    }
+    item.setFont( font );
   }
 
+  @Test
   public void testGetFontByIndex() {
     createGridColumns( grid, 3, SWT.NONE );
     GridItem item = new GridItem( grid, SWT.NONE );
@@ -486,36 +509,32 @@
     assertSame( grid.getFont(), item.getFont( 2 ) );
   }
 
+  @Test( expected = IndexOutOfBoundsException.class )
   public void testGetFontByIndex_InvalidIndex() {
     createGridColumns( grid, 3, SWT.NONE );
     GridItem item = new GridItem( grid, SWT.NONE );
 
-    try {
-      item.getFont( 10 );
-      fail();
-    } catch( IndexOutOfBoundsException expected ) {
-    }
+    item.getFont( 10 );
   }
 
+  @Test( expected = IllegalArgumentException.class )
   public void testSetFontByIndex_DisposedFont() {
     createGridColumns( grid, 3, SWT.NONE );
     GridItem item = new GridItem( grid, SWT.NONE );
     Font font = new Font( display, "Arial", 20, SWT.BOLD );
     font.dispose();
 
-    try {
-      item.setFont( 1, font );
-      fail();
-    } catch( IllegalArgumentException expected ) {
-    }
+    item.setFont( 1, font );
   }
 
+  @Test
   public void testGetBackground_Initial() {
     GridItem item = new GridItem( grid, SWT.NONE );
 
     assertSame( grid.getBackground(), item.getBackground() );
   }
 
+  @Test
   public void testGetBackground() {
     GridItem item = new GridItem( grid, SWT.NONE );
     Color background = new Color( display, 0, 0, 255 );
@@ -525,18 +544,16 @@
     assertSame( background, item.getBackground() );
   }
 
+  @Test( expected = IllegalArgumentException.class )
   public void testSetBackground_DisposedFont() {
     GridItem item = new GridItem( grid, SWT.NONE );
     Color background = new Color( display, 0, 0, 255 );
     background.dispose();
 
-    try {
-      item.setBackground( background );
-      fail();
-    } catch( IllegalArgumentException expected ) {
-    }
+    item.setBackground( background );
   }
 
+  @Test
   public void testGetBackgroundByIndex() {
     createGridColumns( grid, 3, SWT.NONE );
     GridItem item = new GridItem( grid, SWT.NONE );
@@ -549,36 +566,32 @@
     assertSame( grid.getBackground(), item.getBackground( 2 ) );
   }
 
+  @Test( expected = IndexOutOfBoundsException.class )
   public void testGetBackgroundByIndex_InvalidIndex() {
     createGridColumns( grid, 3, SWT.NONE );
     GridItem item = new GridItem( grid, SWT.NONE );
 
-    try {
-      item.getBackground( 10 );
-      fail();
-    } catch( IndexOutOfBoundsException expected ) {
-    }
+    item.getBackground( 10 );
   }
 
+  @Test( expected = IllegalArgumentException.class )
   public void testSetBackgroundByIndex_DisposedFont() {
     createGridColumns( grid, 3, SWT.NONE );
     GridItem item = new GridItem( grid, SWT.NONE );
     Color background = new Color( display, 0, 0, 255 );
     background.dispose();
 
-    try {
-      item.setBackground( 1, background );
-      fail();
-    } catch( IllegalArgumentException expected ) {
-    }
+    item.setBackground( 1, background );
   }
 
+  @Test
   public void testGetForeground_Initial() {
     GridItem item = new GridItem( grid, SWT.NONE );
 
     assertSame( grid.getForeground(), item.getForeground() );
   }
 
+  @Test
   public void testGetForeground() {
     GridItem item = new GridItem( grid, SWT.NONE );
     Color foreground = new Color( display, 0, 0, 255 );
@@ -588,18 +601,16 @@
     assertSame( foreground, item.getForeground() );
   }
 
+  @Test( expected = IllegalArgumentException.class )
   public void testSetForeground_DisposedFont() {
     GridItem item = new GridItem( grid, SWT.NONE );
     Color foreground = new Color( display, 0, 0, 255 );
     foreground.dispose();
 
-    try {
-      item.setForeground( foreground );
-      fail();
-    } catch( IllegalArgumentException expected ) {
-    }
+    item.setForeground( foreground );
   }
 
+  @Test
   public void testGetForegroundByIndex() {
     createGridColumns( grid, 3, SWT.NONE );
     GridItem item = new GridItem( grid, SWT.NONE );
@@ -612,30 +623,25 @@
     assertSame( grid.getForeground(), item.getForeground( 2 ) );
   }
 
+  @Test( expected = IndexOutOfBoundsException.class )
   public void testGetForegroundByIndex_InvalidIndex() {
     createGridColumns( grid, 3, SWT.NONE );
     GridItem item = new GridItem( grid, SWT.NONE );
 
-    try {
-      item.getForeground( 10 );
-      fail();
-    } catch( IndexOutOfBoundsException expected ) {
-    }
+    item.getForeground( 10 );
   }
 
+  @Test( expected = IllegalArgumentException.class )
   public void testSetForegroundByIndex_DisposedFont() {
     createGridColumns( grid, 3, SWT.NONE );
     GridItem item = new GridItem( grid, SWT.NONE );
     Color foreground = new Color( display, 0, 0, 255 );
     foreground.dispose();
 
-    try {
-      item.setForeground( 1, foreground );
-      fail();
-    } catch( IllegalArgumentException expected ) {
-    }
+    item.setForeground( 1, foreground );
   }
 
+  @Test
   public void testClear() {
     GridItem item = new GridItem( grid, SWT.NONE );
     Font font = new Font( display, "Arial", 20, SWT.BOLD );
@@ -652,6 +658,7 @@
     assertSame( grid.getForeground(), item.getForeground() );
   }
 
+  @Test
   public void testGetToolTipText() {
     GridItem item = new GridItem( grid, SWT.NONE );
 
@@ -660,6 +667,7 @@
     assertEquals( "foo", item.getToolTipText( 0 ) );
   }
 
+  @Test
   public void testGetToolTipText_WithColumns() {
     createGridColumns( grid, 3, SWT.NONE );
     GridItem item = new GridItem( grid, SWT.NONE );
@@ -671,12 +679,14 @@
     assertNull( item.getToolTipText( 2 ) );
   }
 
+  @Test
   public void testGetImage_Inital() {
     GridItem item = new GridItem( grid, SWT.NONE );
 
     assertNull( item.getImage() );
   }
 
+  @Test
   public void testGetImage() {
     GridItem item = new GridItem( grid, SWT.NONE );
     Image image = loadImage( display, Fixture.IMAGE1 );
@@ -686,18 +696,16 @@
     assertSame( image, item.getImage() );
   }
 
+  @Test( expected = IllegalArgumentException.class )
   public void testSetImage_DisposedImage() {
     GridItem item = new GridItem( grid, SWT.NONE );
     Image image = loadImage( display, Fixture.IMAGE1 );
     image.dispose();
 
-    try {
-      item.setImage( image );
-      fail();
-    } catch( IllegalArgumentException expected ) {
-    }
+    item.setImage( image );
   }
 
+  @Test
   public void testGetImageByIndex() {
     createGridColumns( grid, 3, SWT.NONE );
     GridItem item = new GridItem( grid, SWT.NONE );
@@ -710,36 +718,32 @@
     assertNull( item.getImage( 2 ) );
   }
 
+  @Test( expected = IndexOutOfBoundsException.class )
   public void testGetImagetByIndex_InvalidIndex() {
     createGridColumns( grid, 3, SWT.NONE );
     GridItem item = new GridItem( grid, SWT.NONE );
 
-    try {
-      item.getImage( 10 );
-      fail();
-    } catch( IndexOutOfBoundsException expected ) {
-    }
+    item.getImage( 10 );
   }
 
+  @Test( expected = IllegalArgumentException.class )
   public void testSetImageByIndex_DisposedFont() {
     createGridColumns( grid, 3, SWT.NONE );
     GridItem item = new GridItem( grid, SWT.NONE );
     Image image = loadImage( display, Fixture.IMAGE1 );
     image.dispose();
 
-    try {
-      item.setImage( 1, image );
-      fail();
-    } catch( IllegalArgumentException expected ) {
-    }
+    item.setImage( 1, image );
   }
 
+  @Test
   public void testGetChecked_Inital() {
     GridItem item = new GridItem( grid, SWT.NONE );
 
     assertFalse( item.getChecked() );
   }
 
+  @Test
   public void testGetChecked() {
     GridItem item = new GridItem( grid, SWT.NONE );
 
@@ -748,6 +752,7 @@
     assertTrue( item.getChecked() );
   }
 
+  @Test
   public void testGetCheckedByIndex() {
     createGridColumns( grid, 3, SWT.NONE );
     GridItem item = new GridItem( grid, SWT.NONE );
@@ -759,23 +764,22 @@
     assertFalse( item.getChecked( 2 ) );
   }
 
+  @Test( expected = IndexOutOfBoundsException.class )
   public void testGetCheckedByIndex_InvalidIndex() {
     createGridColumns( grid, 3, SWT.NONE );
     GridItem item = new GridItem( grid, SWT.NONE );
 
-    try {
-      item.getChecked( 10 );
-      fail();
-    } catch( IndexOutOfBoundsException expected ) {
-    }
+    item.getChecked( 10 );
   }
 
+  @Test
   public void testGetGrayed_Inital() {
     GridItem item = new GridItem( grid, SWT.NONE );
 
     assertFalse( item.getGrayed() );
   }
 
+  @Test
   public void testGetGrayed() {
     GridItem item = new GridItem( grid, SWT.NONE );
 
@@ -784,6 +788,7 @@
     assertTrue( item.getGrayed() );
   }
 
+  @Test
   public void testGetGrayedByIndex() {
     createGridColumns( grid, 3, SWT.NONE );
     GridItem item = new GridItem( grid, SWT.NONE );
@@ -795,17 +800,15 @@
     assertFalse( item.getGrayed( 2 ) );
   }
 
+  @Test( expected = IndexOutOfBoundsException.class )
   public void testGetGrayedByIndex_InvalidIndex() {
     createGridColumns( grid, 3, SWT.NONE );
     GridItem item = new GridItem( grid, SWT.NONE );
 
-    try {
-      item.getGrayed( 10 );
-      fail();
-    } catch( IndexOutOfBoundsException expected ) {
-    }
+    item.getGrayed( 10 );
   }
 
+  @Test
   public void testGetCheckable_Inital() {
     createGridColumns( grid, 3, SWT.NONE );
     GridItem item = new GridItem( grid, SWT.NONE );
@@ -813,6 +816,7 @@
     assertTrue( item.getCheckable( 1 ) );
   }
 
+  @Test
   public void testGetCheckable() {
     createGridColumns( grid, 3, SWT.NONE );
     GridItem item = new GridItem( grid, SWT.NONE );
@@ -822,17 +826,15 @@
     assertFalse( item.getCheckable( 1 ) );
   }
 
+  @Test( expected = IndexOutOfBoundsException.class )
   public void testGetCheckableByIndex_InvalidIndex() {
     createGridColumns( grid, 3, SWT.NONE );
     GridItem item = new GridItem( grid, SWT.NONE );
 
-    try {
-      item.getCheckable( 10 );
-      fail();
-    } catch( IndexOutOfBoundsException expected ) {
-    }
+    item.getCheckable( 10 );
   }
 
+  @Test
   public void testGetCheckable_NotCheckableColumn() {
     GridColumn[] columns = createGridColumns( grid, 3, SWT.NONE );
     columns[ 1 ].setCheckable( false );
@@ -841,12 +843,14 @@
     assertFalse( item.getCheckable( 1 ) );
   }
 
+  @Test
   public void testGetHeight_Initial() {
     GridItem item = new GridItem( grid, SWT.NONE );
 
     assertEquals( 27, item.getHeight() );
   }
 
+  @Test
   public void testGetHeight() {
     GridItem item = new GridItem( grid, SWT.NONE );
 
@@ -855,6 +859,7 @@
     assertEquals( 30, item.getHeight() );
   }
 
+  @Test
   public void testGetHeight_CustomHeight() {
     GridItem item = new GridItem( grid, SWT.NONE );
 
@@ -864,6 +869,7 @@
     assertTrue( grid.getItemHeight() != item.getHeight() );
   }
 
+  @Test
   public void testGetCellSize_WithoutSpan() {
     createGridColumns( grid, 5, SWT.NONE );
     createGridItems( grid, 5, 5 );
@@ -872,6 +878,7 @@
     assertEquals( new Point( 60, 27 ), item.getCellSize( 2 ) );
   }
 
+  @Test
   public void testGetPreferredWidth_Initial() {
     createGridColumns( grid, 2, SWT.NONE );
     GridItem item = new GridItem( grid, SWT.NONE );
@@ -882,6 +889,7 @@
     assertEquals( 12, item.getPreferredWidth( 1 ) );
   }
 
+  @Test
   public void testGetPreferredWidth_InitialTree() {
     createGridColumns( grid, 2, SWT.NONE );
     GridItem item = new GridItem( grid, SWT.NONE );
@@ -895,6 +903,7 @@
     assertEquals( 38, subitem.getPreferredWidth( 0 ) );
   }
 
+  @Test
   public void testGetPreferredWidth_WithCheck() {
     grid = new Grid( shell, SWT.CHECK );
     createGridColumns( grid, 2, SWT.NONE );
@@ -909,6 +918,7 @@
     assertEquals( 61, subitem.getPreferredWidth( 0 ) );
   }
 
+  @Test
   public void testGetPreferredWidth_WithImage() {
     createGridColumns( grid, 2, SWT.NONE );
     Image image = loadImage( display, Fixture.IMAGE1 );
@@ -927,6 +937,7 @@
     assertEquals( 96, subitem.getPreferredWidth( 0 ) );
   }
 
+  @Test
   public void testGetPreferredWidth_WithText() {
     createGridColumns( grid, 2, SWT.NONE );
     GridItem item = new GridItem( grid, SWT.NONE );
@@ -944,6 +955,7 @@
     assertEquals( 58, subitem.getPreferredWidth( 0 ) );
   }
 
+  @Test
   public void testGetPreferredWidth_WithImageAndText() {
     createGridColumns( grid, 2, SWT.NONE );
     Image image = loadImage( display, Fixture.IMAGE1 );
@@ -967,6 +979,20 @@
     assertEquals( 119, subitem.getPreferredWidth( 0 ) );
   }
 
+  @Test
+  public void testGetPreferredWidth_WithMarkup() {
+    createGridColumns( grid, 2, SWT.NONE );
+    GridItem item = new GridItem( grid, SWT.NONE );
+    item.setText( "<b>foo</bar>" );
+    int width1 = item.getPreferredWidth( 0 );
+
+    grid.setData( RWT.MARKUP_ENABLED, Boolean.TRUE );
+    int width2 = item.getPreferredWidth( 0 );
+
+    assertTrue( width1 > width2 );
+  }
+
+  @Test
   public void testGetBounds() {
     createGridColumns( grid, 3, SWT.NONE );
     createGridItems( grid, 3, 3 );
@@ -976,6 +1002,7 @@
     assertEquals( new Rectangle( 60, 27, 60, 27 ), grid.getItem( 4 ).getBounds( 2 ) );
   }
 
+  @Test
   public void testGetBounds_WithOffset() {
     createGridColumns( grid, 5, SWT.NONE );
     createGridItems( grid, 20, 3 );
@@ -987,6 +1014,7 @@
     assertEquals( new Rectangle( 30, 54, 60, 27 ), grid.getItem( 20 ).getBounds( 2 ) );
   }
 
+  @Test
   public void testGetBounds_InvisibleItem() {
     createGridColumns( grid, 3, SWT.NONE );
     createGridItems( grid, 3, 3 );
@@ -995,6 +1023,7 @@
     assertEquals( expected, grid.getItem( 1 ).getBounds( 0 ) );
   }
 
+  @Test
   public void testGetBounds_HiddenItem() {
     createGridColumns( grid, 3, SWT.NONE );
     createGridItems( grid, 20, 3 );
@@ -1004,6 +1033,7 @@
     assertEquals( expected, grid.getItem( 8 ).getBounds( 0 ) );
   }
 
+  @Test
   public void testUpdateColumnImageCount_AddRemoveImage() {
     GridColumn[] columns = createGridColumns( grid, 3, SWT.NONE );
     GridItem[] items = createGridItems( grid, 3, 0 );
@@ -1017,6 +1047,7 @@
     assertEquals( 1, columns[ 1 ].imageCount );
   }
 
+  @Test
   public void testUpdateColumnImageCount_ClearItem() {
     GridColumn[] columns = createGridColumns( grid, 3, SWT.NONE );
     GridItem[] items = createGridItems( grid, 3, 0 );
@@ -1029,6 +1060,7 @@
     assertEquals( 1, columns[ 1 ].imageCount );
   }
 
+  @Test
   public void testUpdateColumnImageCount_DisposeItem() {
     GridColumn[] columns = createGridColumns( grid, 3, SWT.NONE );
     GridItem[] items = createGridItems( grid, 3, 0 );
@@ -1056,4 +1088,5 @@
       eventLog.add( event );
     }
   }
+
 }