Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRalf Sternberg2011-01-27 23:11:31 +0000
committerRalf Sternberg2011-01-27 23:11:31 +0000
commitdd51781684222a2ce376bef33e668e2c7dee8f3a (patch)
treeab54e6d37a9b1d88817ee943790cc163266a44a6 /tests
parentbeeb86723c16a05459d9aa6c0008a307da004a0c (diff)
downloadorg.eclipse.rap-dd51781684222a2ce376bef33e668e2c7dee8f3a.tar.gz
org.eclipse.rap-dd51781684222a2ce376bef33e668e2c7dee8f3a.tar.xz
org.eclipse.rap-dd51781684222a2ce376bef33e668e2c7dee8f3a.zip
Applied patch for bug 334675: Provide tooltip support for TreeViewer
https://bugs.eclipse.org/bugs/show_bug.cgi?id=334675
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/TableTest.js33
-rw-r--r--tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/TreeTest.js32
-rw-r--r--tests/org.eclipse.rap.rwt.q07.jstest/js/org/eclipse/rwt/test/tests/TableTest.js33
-rw-r--r--tests/org.eclipse.rap.rwt.q07.jstest/js/org/eclipse/rwt/test/tests/TreeTest.js32
-rw-r--r--tests/org.eclipse.rap.rwt.q07.test/src/org/eclipse/swt/internal/widgets/tablekit/TableLCA_Test.java89
-rw-r--r--tests/org.eclipse.rap.rwt.q07.test/src/org/eclipse/swt/internal/widgets/treekit/TreeLCA_Test.java166
6 files changed, 355 insertions, 30 deletions
diff --git a/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/TableTest.js b/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/TableTest.js
index f5ca782b1a..b99d52801b 100644
--- a/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/TableTest.js
+++ b/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/TableTest.js
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 EclipseSource and others. All rights reserved.
+ * Copyright (c) 2010, 2011 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 http://www.eclipse.org/legal/epl-v10.html
@@ -114,8 +114,37 @@ qx.Class.define( "org.eclipse.rwt.test.tests.TableTest", {
table.destroy();
},
+ testEnableCellToolTip : function() {
+ var table = this._createDefaultTable();
+ assertNull( table._cellToolTip );
+ assertNull( table._clientArea.getToolTip() );
+ table.setEnableCellToolTip( true );
+ assertNotNull( table._cellToolTip );
+ assertNotNull( table._clientArea.getToolTip() );
+ table.setEnableCellToolTip( false );
+ assertNull( table._cellToolTip );
+ assertNull( table._clientArea.getToolTip() );
+ table.destroy();
+ },
+
+ testRequestCellToolTipText : function() {
+ var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
+ var table = this._createDefaultTable();
+ var widgetManager = org.eclipse.swt.WidgetManager.getInstance();
+ widgetManager.add( table, "w3", true );
+ table.setEnableCellToolTip( true );
+ testUtil.prepareTimerUse();
+ testUtil.initRequestLog();
+ table._cellToolTip.setCell( "w45", 5 );
+ testUtil.forceInterval( table._cellToolTip._showTimer );
+ var msg = testUtil.getMessage();
+ var param1 = "org.eclipse.swt.events.cellToolTipTextRequested=w3";
+ var param2 = "org.eclipse.swt.events.cellToolTipTextRequested.cell=w45%2C5";
+ assertTrue( msg.indexOf( param1 ) != -1 );
+ assertTrue( msg.indexOf( param2 ) != -1 );
+ table.destroy();
+ },
-
/////////
// Helper
diff --git a/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/TreeTest.js b/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/TreeTest.js
index 2b6992a209..ecf9e15d67 100644
--- a/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/TreeTest.js
+++ b/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/TreeTest.js
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 EclipseSource and others. All rights reserved.
+ * Copyright (c) 2010, 2011 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 http://www.eclipse.org/legal/epl-v10.html
@@ -3167,6 +3167,36 @@ qx.Class.define( "org.eclipse.rwt.test.tests.TreeTest", {
tree.destroy();
},
+ testEnableCellToolTip : function() {
+ var tree = this._createDefaultTree();
+ assertNull( tree._cellToolTip );
+ assertNull( tree._clientArea.getToolTip() );
+ tree.setEnableCellToolTip( true );
+ assertNotNull( tree._cellToolTip );
+ assertNotNull( tree._clientArea.getToolTip() );
+ tree.setEnableCellToolTip( false );
+ assertNull( tree._cellToolTip );
+ assertNull( tree._clientArea.getToolTip() );
+ tree.destroy();
+ },
+
+ testRequestCellToolTipText : function() {
+ var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
+ var tree = this._createDefaultTree();
+ var widgetManager = org.eclipse.swt.WidgetManager.getInstance();
+ widgetManager.add( tree, "w3", true );
+ tree.setEnableCellToolTip( true );
+ testUtil.prepareTimerUse();
+ testUtil.initRequestLog();
+ tree._cellToolTip.setCell( "w45", 5 );
+ testUtil.forceInterval( tree._cellToolTip._showTimer );
+ var msg = testUtil.getMessage();
+ var param1 = "org.eclipse.swt.events.cellToolTipTextRequested=w3";
+ var param2 = "org.eclipse.swt.events.cellToolTipTextRequested.cell=w45%2C5";
+ assertTrue( msg.indexOf( param1 ) != -1 );
+ assertTrue( msg.indexOf( param2 ) != -1 );
+ tree.destroy();
+ },
/////////
// helper
diff --git a/tests/org.eclipse.rap.rwt.q07.jstest/js/org/eclipse/rwt/test/tests/TableTest.js b/tests/org.eclipse.rap.rwt.q07.jstest/js/org/eclipse/rwt/test/tests/TableTest.js
index f5ca782b1a..b99d52801b 100644
--- a/tests/org.eclipse.rap.rwt.q07.jstest/js/org/eclipse/rwt/test/tests/TableTest.js
+++ b/tests/org.eclipse.rap.rwt.q07.jstest/js/org/eclipse/rwt/test/tests/TableTest.js
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 EclipseSource and others. All rights reserved.
+ * Copyright (c) 2010, 2011 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 http://www.eclipse.org/legal/epl-v10.html
@@ -114,8 +114,37 @@ qx.Class.define( "org.eclipse.rwt.test.tests.TableTest", {
table.destroy();
},
+ testEnableCellToolTip : function() {
+ var table = this._createDefaultTable();
+ assertNull( table._cellToolTip );
+ assertNull( table._clientArea.getToolTip() );
+ table.setEnableCellToolTip( true );
+ assertNotNull( table._cellToolTip );
+ assertNotNull( table._clientArea.getToolTip() );
+ table.setEnableCellToolTip( false );
+ assertNull( table._cellToolTip );
+ assertNull( table._clientArea.getToolTip() );
+ table.destroy();
+ },
+
+ testRequestCellToolTipText : function() {
+ var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
+ var table = this._createDefaultTable();
+ var widgetManager = org.eclipse.swt.WidgetManager.getInstance();
+ widgetManager.add( table, "w3", true );
+ table.setEnableCellToolTip( true );
+ testUtil.prepareTimerUse();
+ testUtil.initRequestLog();
+ table._cellToolTip.setCell( "w45", 5 );
+ testUtil.forceInterval( table._cellToolTip._showTimer );
+ var msg = testUtil.getMessage();
+ var param1 = "org.eclipse.swt.events.cellToolTipTextRequested=w3";
+ var param2 = "org.eclipse.swt.events.cellToolTipTextRequested.cell=w45%2C5";
+ assertTrue( msg.indexOf( param1 ) != -1 );
+ assertTrue( msg.indexOf( param2 ) != -1 );
+ table.destroy();
+ },
-
/////////
// Helper
diff --git a/tests/org.eclipse.rap.rwt.q07.jstest/js/org/eclipse/rwt/test/tests/TreeTest.js b/tests/org.eclipse.rap.rwt.q07.jstest/js/org/eclipse/rwt/test/tests/TreeTest.js
index 2b6992a209..ecf9e15d67 100644
--- a/tests/org.eclipse.rap.rwt.q07.jstest/js/org/eclipse/rwt/test/tests/TreeTest.js
+++ b/tests/org.eclipse.rap.rwt.q07.jstest/js/org/eclipse/rwt/test/tests/TreeTest.js
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 EclipseSource and others. All rights reserved.
+ * Copyright (c) 2010, 2011 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 http://www.eclipse.org/legal/epl-v10.html
@@ -3167,6 +3167,36 @@ qx.Class.define( "org.eclipse.rwt.test.tests.TreeTest", {
tree.destroy();
},
+ testEnableCellToolTip : function() {
+ var tree = this._createDefaultTree();
+ assertNull( tree._cellToolTip );
+ assertNull( tree._clientArea.getToolTip() );
+ tree.setEnableCellToolTip( true );
+ assertNotNull( tree._cellToolTip );
+ assertNotNull( tree._clientArea.getToolTip() );
+ tree.setEnableCellToolTip( false );
+ assertNull( tree._cellToolTip );
+ assertNull( tree._clientArea.getToolTip() );
+ tree.destroy();
+ },
+
+ testRequestCellToolTipText : function() {
+ var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
+ var tree = this._createDefaultTree();
+ var widgetManager = org.eclipse.swt.WidgetManager.getInstance();
+ widgetManager.add( tree, "w3", true );
+ tree.setEnableCellToolTip( true );
+ testUtil.prepareTimerUse();
+ testUtil.initRequestLog();
+ tree._cellToolTip.setCell( "w45", 5 );
+ testUtil.forceInterval( tree._cellToolTip._showTimer );
+ var msg = testUtil.getMessage();
+ var param1 = "org.eclipse.swt.events.cellToolTipTextRequested=w3";
+ var param2 = "org.eclipse.swt.events.cellToolTipTextRequested.cell=w45%2C5";
+ assertTrue( msg.indexOf( param1 ) != -1 );
+ assertTrue( msg.indexOf( param2 ) != -1 );
+ tree.destroy();
+ },
/////////
// helper
diff --git a/tests/org.eclipse.rap.rwt.q07.test/src/org/eclipse/swt/internal/widgets/tablekit/TableLCA_Test.java b/tests/org.eclipse.rap.rwt.q07.test/src/org/eclipse/swt/internal/widgets/tablekit/TableLCA_Test.java
index 860da04db2..9e9e53dd8f 100644
--- a/tests/org.eclipse.rap.rwt.q07.test/src/org/eclipse/swt/internal/widgets/tablekit/TableLCA_Test.java
+++ b/tests/org.eclipse.rap.rwt.q07.test/src/org/eclipse/swt/internal/widgets/tablekit/TableLCA_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
@@ -275,6 +275,24 @@ public class TableLCA_Test extends TestCase {
Fixture.clearPreserved();
}
+ public void testPreserveEnableCellToolTip() {
+ Table table = new Table( shell, SWT.BORDER );
+ Fixture.markInitialized( display );
+ Fixture.preserveWidgets();
+ IWidgetAdapter adapter = WidgetUtil.getAdapter( table );
+ Boolean preserved
+ = ( Boolean )adapter.getPreserved( TableLCA.PROP_ENABLE_CELL_TOOLTIP );
+ assertEquals( Boolean.FALSE, preserved );
+ Fixture.clearPreserved();
+ table.setData( ICellToolTipProvider.ENABLE_CELL_TOOLTIP, Boolean.TRUE );
+ Fixture.preserveWidgets();
+ adapter = WidgetUtil.getAdapter( table );
+ preserved
+ = ( Boolean )adapter.getPreserved( TableLCA.PROP_ENABLE_CELL_TOOLTIP );
+ assertEquals( Boolean.TRUE, preserved );
+ Fixture.clearPreserved();
+ }
+
public void testSetDataEvent() {
final StringBuffer log = new StringBuffer();
final Table table = new Table( shell, SWT.VIRTUAL );
@@ -816,17 +834,34 @@ public class TableLCA_Test extends TestCase {
assertEquals( 0, table.getTopIndex() );
}
+ public void testWriteEnableCellToolTip() throws IOException {
+ Table table = new Table( shell, SWT.NONE );
+ createTableItems( table, 5 );
+ Fixture.fakeNewRequest();
+ table.setData( ICellToolTipProvider.ENABLE_CELL_TOOLTIP, Boolean.TRUE );
+ TableLCA tableLCA = new TableLCA();
+ tableLCA.renderChanges( table );
+ String markup = Fixture.getAllMarkup();
+ String expected = "w.setEnableCellToolTip( true )";
+ assertTrue( markup.indexOf( expected ) != -1 );
+ }
+
public void testGetCellToolTipText() {
Table table = new Table( shell, SWT.NONE );
createTableItems( table, 5 );
Object adapter = table.getAdapter( ITableAdapter.class );
final ITableAdapter tableAdapter = ( ITableAdapter )adapter;
tableAdapter.setCellToolTipProvider( new ICellToolTipProvider() {
- public void getToolTipText( final int itemIndex,
+ public void getToolTipText( final Item item,
final int columnIndex )
{
- String text = "[" + itemIndex + "," + columnIndex + "]";
- tableAdapter.setToolTipText( text );
+ StringBuffer buffer = new StringBuffer();
+ buffer.append( "[" );
+ buffer.append( WidgetUtil.getId( item ) );
+ buffer.append( "," );
+ buffer.append( columnIndex );
+ buffer.append( "]" );
+ tableAdapter.setToolTipText( buffer.toString() );
}
} );
Fixture.fakeNewRequest();
@@ -834,9 +869,10 @@ public class TableLCA_Test extends TestCase {
String markup = Fixture.getAllMarkup();
String expected = "w.setCellToolTipText(";
assertTrue( markup.indexOf( expected ) == -1 );
- processCellToolTipRequest( table, 2, 0 );
+ String itemId = WidgetUtil.getId( table.getItem( 2 ) );
+ processCellToolTipRequest( table, itemId, 0 );
markup = Fixture.getAllMarkup();
- expected = "w.setCellToolTipText( \"[2,0]\" );";
+ expected = "w.setCellToolTipText( \"[" + itemId + ",0]\" );";
assertTrue( markup.indexOf( expected ) != -1 );
}
@@ -848,25 +884,36 @@ public class TableLCA_Test extends TestCase {
= ( ITableAdapter )table.getAdapter( ITableAdapter.class );
tableAdapter.setCellToolTipProvider( new ICellToolTipProvider() {
- public void getToolTipText( final int itemIndex, final int columnIndex ) {
- log.append( "[" + itemIndex + "," + columnIndex + "]" );
+ public void getToolTipText( final Item item, final int columnIndex ) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append( "[" );
+ buffer.append( WidgetUtil.getId( item ) );
+ buffer.append( "," );
+ buffer.append( columnIndex );
+ buffer.append( "]" );
+ log.append( buffer.toString() );
}
} );
- processCellToolTipRequest( table, 0, 0 );
- assertEquals( "[0,0]", log.toString() );
+ String itemId = WidgetUtil.getId( table.getItem( 0 ) );
+ processCellToolTipRequest( table, itemId, 0 );
+ String expected = "[" + itemId + ",0]";
+ assertEquals( expected, log.toString() );
log.setLength( 0 );
- processCellToolTipRequest( table, 2, 0 );
- assertEquals( "[2,0]", log.toString() );
+ itemId = WidgetUtil.getId( table.getItem( 2 ) );
+ processCellToolTipRequest( table, itemId, 0 );
+ expected = "[" + itemId + ",0]";
+ assertEquals( expected, log.toString() );
log.setLength( 0 );
- processCellToolTipRequest( table, 3, 0 );
+ processCellToolTipRequest( table, "xyz", 0 );
assertEquals( "", log.toString() );
- processCellToolTipRequest( table, 2, 1 );
+ processCellToolTipRequest( table, itemId, 1 );
assertEquals( "", log.toString() );
createTableColumns( table, 2 );
- processCellToolTipRequest( table, 2, 1 );
- assertEquals( "[2,1]", log.toString() );
+ processCellToolTipRequest( table, itemId, 1 );
+ expected = "[" + itemId + ",1]";
+ assertEquals( expected, log.toString() );
log.setLength( 0 );
- processCellToolTipRequest( table, 2, 2 );
+ processCellToolTipRequest( table, itemId, 2 );
assertEquals( "", log.toString() );
}
@@ -921,16 +968,16 @@ public class TableLCA_Test extends TestCase {
}
private static void processCellToolTipRequest( final Table table,
- final int item,
+ final String itemId,
final int column )
{
Fixture.fakeNewRequest();
String displayId = DisplayUtil.getId( table.getDisplay() );
Fixture.fakeRequestParam( RequestParams.UIROOT, displayId );
String tableId = WidgetUtil.getId( table );
- Fixture.fakeRequestParam( TableLCA.EVENT_CELL_TOOLTIP_REQUESTED, tableId );
- String cellString = item + "," + column;
- Fixture.fakeRequestParam( TableLCA.EVENT_CELL_TOOLTIP_DETAILS, cellString );
+ Fixture.fakeRequestParam( JSConst.EVENT_CELL_TOOLTIP_REQUESTED, tableId );
+ String cellString = itemId + "," + column;
+ Fixture.fakeRequestParam( JSConst.EVENT_CELL_TOOLTIP_DETAILS, cellString );
Fixture.executeLifeCycleFromServerThread();
}
diff --git a/tests/org.eclipse.rap.rwt.q07.test/src/org/eclipse/swt/internal/widgets/treekit/TreeLCA_Test.java b/tests/org.eclipse.rap.rwt.q07.test/src/org/eclipse/swt/internal/widgets/treekit/TreeLCA_Test.java
index 658f6c20da..a56f8575c5 100644
--- a/tests/org.eclipse.rap.rwt.q07.test/src/org/eclipse/swt/internal/widgets/treekit/TreeLCA_Test.java
+++ b/tests/org.eclipse.rap.rwt.q07.test/src/org/eclipse/swt/internal/widgets/treekit/TreeLCA_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
@@ -27,8 +27,7 @@ import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.events.ActivateAdapter;
import org.eclipse.swt.internal.events.ActivateEvent;
-import org.eclipse.swt.internal.widgets.ITreeAdapter;
-import org.eclipse.swt.internal.widgets.Props;
+import org.eclipse.swt.internal.widgets.*;
import org.eclipse.swt.internal.widgets.treekit.TreeLCA.ItemMetrics;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.*;
@@ -530,6 +529,24 @@ public class TreeLCA_Test extends TestCase {
hasListeners = ( Boolean )adapter.getPreserved( Props.ACTIVATE_LISTENER );
assertEquals( Boolean.TRUE, hasListeners );
}
+
+ public void testPreserveEnableCellToolTip() {
+ Tree tree = new Tree( shell, SWT.BORDER );
+ Fixture.markInitialized( display );
+ Fixture.preserveWidgets();
+ IWidgetAdapter adapter = WidgetUtil.getAdapter( tree );
+ Boolean preserved
+ = ( Boolean )adapter.getPreserved( TreeLCA.PROP_ENABLE_CELL_TOOLTIP );
+ assertEquals( Boolean.FALSE, preserved );
+ Fixture.clearPreserved();
+ tree.setData( ICellToolTipProvider.ENABLE_CELL_TOOLTIP, Boolean.TRUE );
+ Fixture.preserveWidgets();
+ adapter = WidgetUtil.getAdapter( tree );
+ preserved
+ = ( Boolean )adapter.getPreserved( TreeLCA.PROP_ENABLE_CELL_TOOLTIP );
+ assertEquals( Boolean.TRUE, preserved );
+ Fixture.clearPreserved();
+ }
public void testSelectionEvent() {
final StringBuffer log = new StringBuffer();
@@ -672,6 +689,149 @@ public class TreeLCA_Test extends TestCase {
String expected = "w.setHasScrollBarsSelectionListener( true );";
assertTrue( markup.indexOf( expected ) != -1 );
}
+
+ public void testWriteEnableCellToolTip() throws IOException {
+ Tree tree = new Tree( shell, SWT.NONE );
+ createTreeItems( tree, 5 );
+ Fixture.fakeNewRequest();
+ tree.setData( ICellToolTipProvider.ENABLE_CELL_TOOLTIP, Boolean.TRUE );
+ TreeLCA treeLCA = new TreeLCA();
+ treeLCA.renderChanges( tree );
+ String markup = Fixture.getAllMarkup();
+ String expected = "w.setEnableCellToolTip( true )";
+ assertTrue( markup.indexOf( expected ) != -1 );
+ }
+
+ public void testGetCellToolTipText() {
+ Tree tree = new Tree( shell, SWT.NONE );
+ createTreeItems( tree, 5 );
+ Object adapter = tree.getAdapter( ITreeAdapter.class );
+ final ITreeAdapter treeAdapter = ( ITreeAdapter )adapter;
+ treeAdapter.setCellToolTipProvider( new ICellToolTipProvider() {
+ public void getToolTipText( final Item item,
+ final int columnIndex )
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append( "[" );
+ buffer.append( WidgetUtil.getId( item ) );
+ buffer.append( "," );
+ buffer.append( columnIndex );
+ buffer.append( "]" );
+ treeAdapter.setToolTipText( buffer.toString() );
+ }
+ } );
+ Fixture.fakeNewRequest();
+ Fixture.executeLifeCycleFromServerThread();
+ String markup = Fixture.getAllMarkup();
+ String expected = "w.setCellToolTipText(";
+ assertTrue( markup.indexOf( expected ) == -1 );
+ String itemId = WidgetUtil.getId( tree.getItem( 2 ) );
+ processCellToolTipRequest( tree, itemId, 0 );
+ markup = Fixture.getAllMarkup();
+ expected = "w.setCellToolTipText( \"[" + itemId + ",0]\" );";
+ assertTrue( markup.indexOf( expected ) != -1 );
+ }
+
+ public void testGetCellToolTipTextForSubitems() {
+ Tree tree = new Tree( shell, SWT.NONE );
+ createTreeItems( tree, 5 );
+ Object adapter = tree.getAdapter( ITreeAdapter.class );
+ final ITreeAdapter treeAdapter = ( ITreeAdapter )adapter;
+ treeAdapter.setCellToolTipProvider( new ICellToolTipProvider() {
+ public void getToolTipText( final Item item,
+ final int columnIndex )
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append( "[" );
+ buffer.append( WidgetUtil.getId( item ) );
+ buffer.append( "," );
+ buffer.append( columnIndex );
+ buffer.append( "]" );
+ treeAdapter.setToolTipText( buffer.toString() );
+ }
+ } );
+ Fixture.fakeNewRequest();
+ Fixture.executeLifeCycleFromServerThread();
+ String markup = Fixture.getAllMarkup();
+ String expected = "w.setCellToolTipText(";
+ assertTrue( markup.indexOf( expected ) == -1 );
+ String itemId = WidgetUtil.getId( tree.getItem( 2 ).getItem( 1 ) );
+ processCellToolTipRequest( tree, itemId, 0 );
+ markup = Fixture.getAllMarkup();
+ expected = "w.setCellToolTipText( \"[" + itemId + ",0]\" );";
+ assertTrue( markup.indexOf( expected ) != -1 );
+ }
+
+ public void testCellTooltipRequestForMissingCells() {
+ Tree tree = new Tree( shell, SWT.NONE );
+ createTreeItems( tree, 3 );
+ final StringBuffer log = new StringBuffer();
+ final ITreeAdapter treeAdapter
+ = ( ITreeAdapter )tree.getAdapter( ITreeAdapter.class );
+ treeAdapter.setCellToolTipProvider( new ICellToolTipProvider() {
+
+ public void getToolTipText( final Item item, final int columnIndex ) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append( "[" );
+ buffer.append( WidgetUtil.getId( item ) );
+ buffer.append( "," );
+ buffer.append( columnIndex );
+ buffer.append( "]" );
+ log.append( buffer.toString() );
+ }
+ } );
+ String itemId = WidgetUtil.getId( tree.getItem( 0 ) );
+ processCellToolTipRequest( tree, itemId, 0 );
+ String expected = "[" + itemId + ",0]";
+ assertEquals( expected, log.toString() );
+ log.setLength( 0 );
+ itemId = WidgetUtil.getId( tree.getItem( 2 ) );
+ processCellToolTipRequest( tree, itemId, 0 );
+ expected = "[" + itemId + ",0]";
+ assertEquals( expected, log.toString() );
+ log.setLength( 0 );
+ processCellToolTipRequest( tree, "xyz", 0 );
+ assertEquals( "", log.toString() );
+ processCellToolTipRequest( tree, itemId, 1 );
+ assertEquals( "", log.toString() );
+ createTreeColumns( tree, 2 );
+ processCellToolTipRequest( tree, itemId, 1 );
+ expected = "[" + itemId + ",1]";
+ assertEquals( expected, log.toString() );
+ log.setLength( 0 );
+ processCellToolTipRequest( tree, itemId, 2 );
+ assertEquals( "", log.toString() );
+ }
+
+ private static void createTreeColumns( final Tree tree, final int count ) {
+ for( int i = 0; i < count; i++ ) {
+ new TreeColumn( tree, SWT.NONE );
+ }
+ }
+
+ private static void createTreeItems( final Tree tree, final int count ) {
+ for( int i = 0; i < count; i++ ) {
+ TreeItem item = new TreeItem( tree, SWT.NONE );
+ for( int j = 0; j < count; j++ ) {
+ new TreeItem( item, SWT.NONE );
+ }
+ item.setExpanded( true );
+ }
+ }
+
+ private static void processCellToolTipRequest( final Tree tree,
+ final String itemId,
+ final int column )
+ {
+ Fixture.fakeNewRequest();
+ String displayId = DisplayUtil.getId( tree.getDisplay() );
+ Fixture.fakeRequestParam( RequestParams.UIROOT, displayId );
+ String treeId = WidgetUtil.getId( tree );
+ Fixture.fakeRequestParam( JSConst.EVENT_CELL_TOOLTIP_REQUESTED, treeId );
+ String cellString = itemId + "," + column;
+ Fixture.fakeRequestParam( JSConst.EVENT_CELL_TOOLTIP_DETAILS, cellString );
+ Fixture.executeLifeCycleFromServerThread();
+ }
// TODO [tb] : Test for fake redraw calls checkAllData

Back to the top