diff options
author | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2009-11-13 08:59:36 +0100 |
---|---|---|
committer | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2009-11-13 08:59:36 +0100 |
commit | cc0a4e484b85cb2befd244b6a85b0c72cc806691 (patch) | |
tree | 09fdaef81773a93ea3f75518a49a45907323b4bd /forms | |
parent | fe866adeb5bcf32bbb0ce23a85e20fcefce84986 (diff) |
some refactoring, done during creation of a test case for #i106643#
Diffstat (limited to 'forms')
-rw-r--r-- | forms/qa/integration/forms/DocumentViewHelper.java | 5 | ||||
-rw-r--r-- | forms/qa/integration/forms/FormControlTest.java | 9 | ||||
-rw-r--r-- | forms/qa/integration/forms/FormLayer.java | 30 | ||||
-rw-r--r-- | forms/qa/integration/forms/FormPropertyBags.java | 10 | ||||
-rw-r--r-- | forms/qa/integration/forms/ListSelection.java | 86 | ||||
-rw-r--r-- | forms/qa/integration/forms/MasterDetailForms.java | 46 | ||||
-rw-r--r-- | forms/qa/integration/forms/TestCase.java | 13 | ||||
-rw-r--r-- | forms/qa/integration/forms/dbfTools.java | 9 |
8 files changed, 69 insertions, 139 deletions
diff --git a/forms/qa/integration/forms/DocumentViewHelper.java b/forms/qa/integration/forms/DocumentViewHelper.java index 212800f2b1e0..9f46e006609a 100644 --- a/forms/qa/integration/forms/DocumentViewHelper.java +++ b/forms/qa/integration/forms/DocumentViewHelper.java @@ -190,10 +190,9 @@ public class DocumentViewHelper /* ------------------------------------------------------------------ */ /** retrieves the form controller for a given logical form */ - public XFormController getFormController( XPropertySet _form ) + public XFormController getFormController( Object _form ) { - XFormLayerAccess formLayerAccess = (XFormLayerAccess)query( XFormLayerAccess.class ); - return formLayerAccess.getFormController( (XForm)UnoRuntime.queryInterface( XForm.class, _form ) ); + return getFormController( UnoRuntime.queryInterface( XForm.class, _form )); } /* ------------------------------------------------------------------ */ diff --git a/forms/qa/integration/forms/FormControlTest.java b/forms/qa/integration/forms/FormControlTest.java index 5d2291a06b13..d561ac28ef2c 100644 --- a/forms/qa/integration/forms/FormControlTest.java +++ b/forms/qa/integration/forms/FormControlTest.java @@ -52,6 +52,7 @@ import com.sun.star.util.URL; import com.sun.star.util.XCloseable; import com.sun.star.util.XURLTransformer; import connectivity.tools.HsqlDatabase; +import connectivity.tools.sdb.Connection; import java.io.FileOutputStream; @@ -609,8 +610,8 @@ public class FormControlTest extends complexlib.ComplexTestCase implements XSQLE /* ------------------------------------------------------------------ */ private boolean ensureTables() throws com.sun.star.uno.Exception, java.lang.Exception { - XConnection xConn = m_dataSource.getConnection( "", "" ); - assure( "could not connect to the data source", xConn != null ); + Connection connection = new Connection( m_dataSource.getConnection( "", "" ) ); + assure( "could not connect to the data source", connection != null ); // drop the table, if it already exists if ( !implExecuteStatement( "DROP TABLE \"" + s_tableName + "\" IF EXISTS" ) @@ -630,10 +631,10 @@ public class FormControlTest extends complexlib.ComplexTestCase implements XSQLE return false; } - m_databaseDocument.getDataSource().refreshTables( xConn ); + connection.refreshTables(); // do not need the connection anymore - dbfTools.disposeComponent( xConn ); + connection.close(); return true; } diff --git a/forms/qa/integration/forms/FormLayer.java b/forms/qa/integration/forms/FormLayer.java index 21767b254ae0..4fa85b0a7bd8 100644 --- a/forms/qa/integration/forms/FormLayer.java +++ b/forms/qa/integration/forms/FormLayer.java @@ -31,7 +31,6 @@ package integration.forms; import com.sun.star.accessibility.XAccessible; import com.sun.star.accessibility.XAccessibleEditableText; -import com.sun.star.container.XNameAccess; import com.sun.star.uno.UnoRuntime; import com.sun.star.beans.XPropertySet; @@ -44,6 +43,7 @@ import com.sun.star.awt.Size; import com.sun.star.awt.Point; import com.sun.star.awt.VisualEffect; import com.sun.star.awt.XControlModel; +import com.sun.star.container.XNameAccess; import com.sun.star.text.TextContentAnchorType; import com.sun.star.drawing.XDrawPage; @@ -99,9 +99,9 @@ public class FormLayer int nYPos, int nWidth, int nHeight, Object _parentForm ) throws java.lang.Exception { // let the document create a shape - XMultiServiceFactory xDocAsFactory = (XMultiServiceFactory)UnoRuntime.queryInterface( + XMultiServiceFactory xDocAsFactory = UnoRuntime.queryInterface( XMultiServiceFactory.class, m_document.getDocument() ); - XControlShape xShape = (XControlShape)UnoRuntime.queryInterface( XControlShape.class, + XControlShape xShape = UnoRuntime.queryInterface( XControlShape.class, xDocAsFactory.createInstance( "com.sun.star.drawing.ControlShape" ) ); // position and size of the shape @@ -115,7 +115,7 @@ public class FormLayer // create the form component (the model of a form control) String sQualifiedComponentName = "com.sun.star.form.component." + sFormComponentService; - XControlModel xModel = (XControlModel)UnoRuntime.queryInterface( XControlModel.class, + XControlModel xModel = UnoRuntime.queryInterface( XControlModel.class, m_document.getOrb().createInstance( sQualifiedComponentName ) ); // insert the model into the form component hierarchy, if the caller gave us a location @@ -125,7 +125,7 @@ public class FormLayer if ( _parentForm instanceof XIndexContainer ) parentForm = (XIndexContainer)_parentForm; else - parentForm = (XIndexContainer)UnoRuntime.queryInterface( XIndexContainer.class, _parentForm ); + parentForm = UnoRuntime.queryInterface( XIndexContainer.class, _parentForm ); parentForm.insertByIndex( parentForm.getCount(), xModel ); } @@ -135,7 +135,7 @@ public class FormLayer // add the shape to the shapes collection of the document XDrawPage pageWhereToInsert = ( m_page != null ) ? m_page : m_document.getMainDrawPage(); - XShapes xDocShapes = (XShapes)UnoRuntime.queryInterface( XShapes.class, pageWhereToInsert ); + XShapes xDocShapes = UnoRuntime.queryInterface( XShapes.class, pageWhereToInsert ); xDocShapes.add( xShape ); // and outta here with the XPropertySet interface of the model @@ -226,7 +226,7 @@ public class FormLayer @return the control model of the created data input field */ - public XPropertySet insertControlLine( String sControlType, String sFieldName, String sControlNamePostfix, + public XPropertySet insertControlLine( String sControlType, String sFieldName, String _controlNamePostfix, int nXPos, int nYPos, int nHeight ) throws java.lang.Exception { @@ -247,8 +247,10 @@ public class FormLayer xFieldModel.setPropertyValue( "LabelControl", xLabelModel ); // some names, so later on we can find them - xLabelModel.setPropertyValue( "Name", sFieldName + sControlNamePostfix + "_Label" ); - xFieldModel.setPropertyValue( "Name", sFieldName + sControlNamePostfix ); + if ( _controlNamePostfix == null ) + _controlNamePostfix = ""; + xLabelModel.setPropertyValue( "Name", sFieldName + _controlNamePostfix + "_Label" ); + xFieldModel.setPropertyValue( "Name", sFieldName + _controlNamePostfix ); return xFieldModel; } @@ -282,8 +284,7 @@ public class FormLayer */ public XPropertySet getRadioModelByRefValue( XPropertySet form, String name, String refValue ) throws com.sun.star.uno.Exception, java.lang.Exception { - XIndexAccess indexAccess = (XIndexAccess)UnoRuntime.queryInterface( XIndexAccess.class, - form ); + XIndexAccess indexAccess = UnoRuntime.queryInterface( XIndexAccess.class, form ); for ( int i=0; i<indexAccess.getCount(); ++i ) { @@ -307,8 +308,7 @@ public class FormLayer */ public XPropertySet getRadioModelByTag( XPropertySet form, String name, String tag ) throws com.sun.star.uno.Exception, java.lang.Exception { - XIndexAccess indexAccess = (XIndexAccess)UnoRuntime.queryInterface( XIndexAccess.class, - form ); + XIndexAccess indexAccess = UnoRuntime.queryInterface( XIndexAccess.class, form ); for ( int i=0; i<indexAccess.getCount(); ++i ) { @@ -349,10 +349,10 @@ public class FormLayer // doing a user input, as the latter will trigger a lot of notifications, which the forms runtime environment // (namely the FormController) relies on to notice that the control changed. // Instead, we use the Accessibility interfaces of the control to simulate text input - XAccessible formattedAccessible = (XAccessible)UnoRuntime.queryInterface( XAccessible.class, + XAccessible formattedAccessible = UnoRuntime.queryInterface( XAccessible.class, m_document.getCurrentView().getControl( controlModel ) ); - XAccessibleEditableText textAccess = (XAccessibleEditableText)UnoRuntime.queryInterface( XAccessibleEditableText.class, + XAccessibleEditableText textAccess = UnoRuntime.queryInterface( XAccessibleEditableText.class, formattedAccessible.getAccessibleContext() ); textAccess.setText( text ); } diff --git a/forms/qa/integration/forms/FormPropertyBags.java b/forms/qa/integration/forms/FormPropertyBags.java index 92aa2b8b6236..0998b882915e 100644 --- a/forms/qa/integration/forms/FormPropertyBags.java +++ b/forms/qa/integration/forms/FormPropertyBags.java @@ -47,8 +47,6 @@ import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.util.XCloseable; -import integration.forms.DocumentHelper; - public class FormPropertyBags extends complexlib.ComplexTestCase implements XPropertyChangeListener { private DocumentHelper m_document; @@ -90,8 +88,7 @@ public class FormPropertyBags extends complexlib.ComplexTestCase implements XPro { if ( m_document != null ) { - XCloseable closeDoc = (XCloseable)UnoRuntime.queryInterface( XCloseable.class, - m_document.getDocument() ); + XCloseable closeDoc = UnoRuntime.queryInterface( XCloseable.class, m_document.getDocument() ); closeDoc.close( true ); } } @@ -108,7 +105,7 @@ public class FormPropertyBags extends complexlib.ComplexTestCase implements XPro XPropertySet textFieldModel = m_formLayer.createControlAndShape( "DatabaseTextField", 10, 10, 25, 6 ); // check whether adding new properties is successful - XPropertyContainer propContainer = (XPropertyContainer)UnoRuntime.queryInterface( + XPropertyContainer propContainer = UnoRuntime.queryInterface( XPropertyContainer.class, textFieldModel ); assure("XPropertyContainer not supported!", propContainer != null ); @@ -166,8 +163,7 @@ public class FormPropertyBags extends complexlib.ComplexTestCase implements XPro private void impl_checkPropertyPersistence() throws com.sun.star.uno.Exception { // store the document - XStorable store = (XStorable)UnoRuntime.queryInterface( XStorable.class, - m_document.getDocument() ); + XStorable store = UnoRuntime.queryInterface( XStorable.class, m_document.getDocument() ); String documentURL = util.utils.getOfficeTemp( m_orb ) + "document.odt"; PropertyValue[] storeArguments = new PropertyValue[] { new PropertyValue() }; storeArguments[0].Name = "FilterName"; diff --git a/forms/qa/integration/forms/ListSelection.java b/forms/qa/integration/forms/ListSelection.java index 110380cc660f..818fc262e51c 100644 --- a/forms/qa/integration/forms/ListSelection.java +++ b/forms/qa/integration/forms/ListSelection.java @@ -30,7 +30,6 @@ package integration.forms; import com.sun.star.uno.UnoRuntime; -import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.beans.XPropertySet; import com.sun.star.sheet.XSpreadsheet; import com.sun.star.sheet.XSpreadsheets; @@ -48,15 +47,10 @@ import com.sun.star.script.ScriptEventDescriptor; import com.sun.star.accessibility.XAccessible; import com.sun.star.accessibility.XAccessibleContext; import com.sun.star.accessibility.XAccessibleSelection; -import com.sun.star.accessibility.XAccessibleAction; import com.sun.star.frame.XStorable; -import integration.forms.DocumentHelper; - -public class ListSelection extends integration.forms.TestCase implements com.sun.star.awt.XItemListener +public class ListSelection extends integration.forms.TestCase { - private final static boolean m_useJavaCallbacks = false; - /** Creates a new instance of ListSelection */ public ListSelection() { @@ -98,7 +92,7 @@ public class ListSelection extends integration.forms.TestCase implements com.sun { log.println( "Round " + ( i + 1 ) + " of " + runs ); prepareDocument(); - clickTheListBox(); + impl_clickListBox(); synchronized( this ) { this.wait( 1000 ); } closeDocument(); } @@ -106,7 +100,7 @@ public class ListSelection extends integration.forms.TestCase implements com.sun } /* ------------------------------------------------------------------ */ - final protected void clickTheListBox() + final private void impl_clickListBox() { try { @@ -123,13 +117,6 @@ public class ListSelection extends integration.forms.TestCase implements com.sun XAccessible.class, getListBoxControl( activeSheet ) ); XAccessibleContext context = accessibleListBox.getAccessibleContext(); - // open the popup of the list box (not really necessary, but to better - // simlate user action ...) -/* XAccessibleAction listBoxActions = (XAccessibleAction)UnoRuntime.queryInterface( - XAccessibleAction.class, context ); - listBoxActions.doAccessibleAction( 0 ); -*/ - // the first "accessible child" of a list box is its list XAccessibleSelection accessibleList = (XAccessibleSelection)UnoRuntime.queryInterface( XAccessibleSelection.class, context.getAccessibleChild( 1 ) ); @@ -158,7 +145,7 @@ public class ListSelection extends integration.forms.TestCase implements com.sun } /* ------------------------------------------------------------------ */ - final protected void createListenerScript() + final private void impl_setupListenerScript() { try { @@ -203,7 +190,7 @@ public class ListSelection extends integration.forms.TestCase implements com.sun } /* ------------------------------------------------------------------ */ - final protected void assignCallbackScript( XPropertySet controlModel, String interfaceName, String interfaceMethod, String scriptCode ) + final private void impl_assignStarBasicScript( XPropertySet controlModel, String interfaceName, String interfaceMethod, String scriptCode ) { try { @@ -240,8 +227,7 @@ public class ListSelection extends integration.forms.TestCase implements com.sun protected void prepareDocument() throws com.sun.star.uno.Exception, java.lang.Exception { super.prepareDocument(); - if ( !m_useJavaCallbacks ) - createListenerScript(); + impl_setupListenerScript(); SpreadsheetDocument document = (SpreadsheetDocument)m_document; XSpreadsheets sheets = document.getSheets(); @@ -264,7 +250,7 @@ public class ListSelection extends integration.forms.TestCase implements com.sun for ( int i = 0; i < 4; ++i ) { XPropertySet buttonModel = m_formLayer.createControlAndShape( "CommandButton", 10, 10 + i * 10, 30, 8 ); - assignCallbackScript( buttonModel, "XActionListener", "actionPerformed", "document:default.callbacks.onButtonClicked" ); + impl_assignStarBasicScript( buttonModel, "XActionListener", "actionPerformed", "document:default.callbacks.onButtonClicked" ); } // and a list box @@ -273,25 +259,15 @@ public class ListSelection extends integration.forms.TestCase implements com.sun listBox.setPropertyValue( "StringItemList", newSheetNames ); listBox.setPropertyValue( "Name", "ListBox" ); - if ( !m_useJavaCallbacks ) - assignCallbackScript( listBox, "XItemListener", "itemStateChanged", "document:default.callbacks.onListBoxSelected" ); + impl_assignStarBasicScript( listBox, "XItemListener", "itemStateChanged", "document:default.callbacks.onListBoxSelected" ); // clone this sheet for ( short i = 1; i < newSheetNames.length; ++i ) - sheets.copyByName( newSheetNames[0], newSheetNames[i], (short)i ); + sheets.copyByName( newSheetNames[0], newSheetNames[i], i ); // switch the thing to alive mode m_document.getCurrentView().toggleFormDesignMode(); - // add to the list box control as item listener - if ( m_useJavaCallbacks ) - { - XControl control = m_document.getCurrentView().getControl( listBox ); - XListBox listBoxControl = (XListBox)UnoRuntime.queryInterface( - XListBox.class, control ); - listBoxControl.addItemListener( this ); - } - try { XStorable storable = (XStorable)m_document.query( XStorable.class ); @@ -322,48 +298,4 @@ public class ListSelection extends integration.forms.TestCase implements com.sun return (XListBox)UnoRuntime.queryInterface( XListBox.class, m_document.getCurrentView().getControl( getListBoxModel( sheet ) ) ); } - - /* ------------------------------------------------------------------ */ - public void itemStateChanged( com.sun.star.awt.ItemEvent event ) throws com.sun.star.uno.RuntimeException - { - try - { - // get the selected string - XControl control = (XControl)UnoRuntime.queryInterface( XControl.class, - event.Source ); - XPropertySet model = dbfTools.queryPropertySet( control.getModel() ); - String[] entries = (String[])model.getPropertyValue( "StringItemList" ); - String selectedEntry = entries[ event.Selected ]; - - // activate this sheet - SpreadsheetDocument document = (SpreadsheetDocument)m_document; - XSpreadsheet sheet = (XSpreadsheet)UnoRuntime.queryInterface( - XSpreadsheet.class, document.getSheets().getByName( selectedEntry ) ); - XSpreadsheetView view = (XSpreadsheetView)m_document.getCurrentView().query( XSpreadsheetView.class ); - view.setActiveSheet( sheet ); - - if ( m_useJavaCallbacks ) - { - // after we switched to another sheet, we need to register at its list box - // control, again. The reason is that controls exist as long as their sheet is active. - XListBox listBoxControl = getListBoxControl( sheet ); - listBoxControl.addItemListener( this ); - - // in the list box of this new sheet, select its name. Everything else - // is way too confusing - listBoxControl.selectItem( selectedEntry, true ); - // don't do it. It deadlocks :( - } - } - catch( com.sun.star.uno.Exception e ) - { - e.printStackTrace( System.err ); - } - } - - /* ------------------------------------------------------------------ */ - public void disposing( com.sun.star.lang.EventObject rEvent ) throws com.sun.star.uno.RuntimeException - { - // not interested in by now - } } diff --git a/forms/qa/integration/forms/MasterDetailForms.java b/forms/qa/integration/forms/MasterDetailForms.java index ffebe93ee559..3bf14aae70cd 100644 --- a/forms/qa/integration/forms/MasterDetailForms.java +++ b/forms/qa/integration/forms/MasterDetailForms.java @@ -122,28 +122,27 @@ public class MasterDetailForms extends complexlib.ComplexTestCase implements com _databaseDocument.executeSQL( "INSERT INTO \"detail\" VALUES ( 2, 1, 1, 'record 1.1 (2)')"); _databaseDocument.executeSQL( "INSERT INTO \"detail\" VALUES ( 3, 1, 2, 'record 1.2 (1)')"); - _databaseDocument.getDataSource().refreshTables( _databaseDocument.defaultConnection() ); + _databaseDocument.defaultConnection().refreshTables(); } /* ------------------------------------------------------------------ */ private void impl_createForms( final HsqlDatabase _databaseDocument ) throws com.sun.star.uno.Exception { m_masterForm = dbfTools.queryPropertySet( m_orb.createInstance( "com.sun.star.form.component.DataForm" ) ); - m_masterForm.setPropertyValue( "ActiveConnection", _databaseDocument.defaultConnection() ); + m_masterForm.setPropertyValue( "ActiveConnection", _databaseDocument.defaultConnection().getXConnection() ); m_masterForm.setPropertyValue( "CommandType", new Integer( com.sun.star.sdb.CommandType.TABLE ) ); m_masterForm.setPropertyValue( "Command", "master" ); m_masterResult = new ResultSet( m_masterForm ); m_detailForm = dbfTools.queryPropertySet( m_orb.createInstance( "com.sun.star.form.component.DataForm" ) ); - m_detailForm.setPropertyValue( "ActiveConnection", _databaseDocument.defaultConnection() ); + m_detailForm.setPropertyValue( "ActiveConnection", _databaseDocument.defaultConnection().getXConnection() ); m_detailForm.setPropertyValue( "CommandType", new Integer( com.sun.star.sdb.CommandType.TABLE ) ); m_detailForm.setPropertyValue( "Command", "detail" ); m_detailResult = new ResultSet( m_detailForm ); - XNameContainer masterContainer = (XNameContainer)UnoRuntime.queryInterface( XNameContainer.class, - m_masterForm ); + XNameContainer masterContainer = UnoRuntime.queryInterface( XNameContainer.class, m_masterForm ); masterContainer.insertByName( "slave", m_detailForm ); } @@ -162,8 +161,8 @@ public class MasterDetailForms extends complexlib.ComplexTestCase implements com m_detailForm.setPropertyValue( "MasterFields", new String[] { "ID1", "ID2" } ); m_detailForm.setPropertyValue( "DetailFields", new String[] { "FK_ID1", "FK_ID2" } ); - XLoadable loadMaster = (XLoadable)UnoRuntime.queryInterface( XLoadable.class, m_masterForm ); - XLoadable loadDetail = (XLoadable)UnoRuntime.queryInterface( XLoadable.class, m_detailForm ); + XLoadable loadMaster = UnoRuntime.queryInterface( XLoadable.class, m_masterForm ); + XLoadable loadDetail = UnoRuntime.queryInterface( XLoadable.class, m_detailForm ); loadDetail.addLoadListener( this ); // wait until the detail form is loaded @@ -227,16 +226,14 @@ public class MasterDetailForms extends complexlib.ComplexTestCase implements com database = new CRMDatabase( m_orb, true ); // create a form document therein - XFormDocumentsSupplier formDocSupp = (XFormDocumentsSupplier)UnoRuntime.queryInterface( - XFormDocumentsSupplier.class, database.getDatabase().getModel() ); - XMultiServiceFactory formFactory = (XMultiServiceFactory)UnoRuntime.queryInterface( - XMultiServiceFactory.class, formDocSupp.getFormDocuments() ); + XFormDocumentsSupplier formDocSupp = UnoRuntime.queryInterface( XFormDocumentsSupplier.class, database.getDatabase().getModel() ); + XMultiServiceFactory formFactory = UnoRuntime.queryInterface( XMultiServiceFactory.class, formDocSupp.getFormDocuments() ); NamedValue[] loadArgs = new NamedValue[] { - new NamedValue( "ActiveConnection", database.getConnection() ), + new NamedValue( "ActiveConnection", database.getConnection().getXConnection() ), new NamedValue( "MediaType", "application/vnd.oasis.opendocument.text" ) }; - subComponentCommands = (XCommandProcessor)UnoRuntime.queryInterface( + subComponentCommands = UnoRuntime.queryInterface( XCommandProcessor.class, formFactory.createInstanceWithArguments( "com.sun.star.sdb.DocumentDefinition", loadArgs ) ); Command command = new Command(); @@ -244,7 +241,7 @@ public class MasterDetailForms extends complexlib.ComplexTestCase implements com command.Argument = new Short( OpenMode.DOCUMENT ); DocumentHelper subDocument = new DocumentHelper( m_orb, - (XComponent)UnoRuntime.queryInterface( XComponent.class, + UnoRuntime.queryInterface( XComponent.class, subComponentCommands.execute( command, subComponentCommands.createCommandIdentifier(), null ) ) ); @@ -258,8 +255,7 @@ public class MasterDetailForms extends complexlib.ComplexTestCase implements com m_masterForm.setPropertyValue( "CommandType", new Integer( CommandType.TABLE ) ); // create a detail form - m_detailForm = (XPropertySet)UnoRuntime.queryInterface( - XPropertySet.class, subDocument.createSubForm( m_masterForm, "products" ) ); + m_detailForm = UnoRuntime.queryInterface( XPropertySet.class, subDocument.createSubForm( m_masterForm, "products" ) ); m_detailForm.setPropertyValue( "Command", "SELECT \"ID\", \"Name\", \"CategoryID\" FROM \"products\"" ); m_detailForm.setPropertyValue( "CommandType", new Integer( CommandType.COMMAND ) ); m_detailForm.setPropertyValue( "MasterFields", new String[] { "ID" } ); @@ -268,8 +264,7 @@ public class MasterDetailForms extends complexlib.ComplexTestCase implements com // create a grid control in the detail form, with some columns XPropertySet gridControlModel = formLayer.createControlAndShape( "GridControl", 20, 40, 130, 50, m_detailForm ); gridControlModel.setPropertyValue( "Name", "product list" ); - XIndexContainer gridColumns = (XIndexContainer)UnoRuntime.queryInterface( - XIndexContainer.class, gridControlModel ); + XIndexContainer gridColumns = UnoRuntime.queryInterface( XIndexContainer.class, gridControlModel ); impl_createGridColumn( gridColumns, "TextField", "ID" ); XPropertySet nameColumn = impl_createGridColumn( gridColumns, "TextField", "Name" ); nameColumn.setPropertyValue( "Width", new Integer( 600 ) ); // 6 cm @@ -279,7 +274,7 @@ public class MasterDetailForms extends complexlib.ComplexTestCase implements com m_masterResult = new ResultSet( m_masterForm ); m_detailResult = new ResultSet( m_detailForm ); - XLoadable loadDetail = (XLoadable)UnoRuntime.queryInterface( XLoadable.class, m_detailForm ); + XLoadable loadDetail = UnoRuntime.queryInterface( XLoadable.class, m_detailForm ); loadDetail.addLoadListener( this ); subDocument.getCurrentView().toggleFormDesignMode(); @@ -314,10 +309,8 @@ public class MasterDetailForms extends complexlib.ComplexTestCase implements com { if ( subComponentCommands != null ) { - XComponentSupplier componentSupplier = (XComponentSupplier)UnoRuntime.queryInterface( XComponentSupplier.class, - subComponentCommands ); - XModifiable modifySubComponent = (XModifiable)UnoRuntime.queryInterface( XModifiable.class, - componentSupplier.getComponent() ); + XComponentSupplier componentSupplier = UnoRuntime.queryInterface( XComponentSupplier.class, subComponentCommands ); + XModifiable modifySubComponent = UnoRuntime.queryInterface( XModifiable.class, componentSupplier.getComponent() ); modifySubComponent.setModified( false ); Command command = new Command(); command.Name = "close"; @@ -349,8 +342,7 @@ public class MasterDetailForms extends complexlib.ComplexTestCase implements com /* ------------------------------------------------------------------ */ private XPropertySet impl_createGridColumn( final XIndexContainer _gridModel, final String _columnType, final String _boundField ) throws Exception { - final XGridColumnFactory columnFactory = (XGridColumnFactory)UnoRuntime.queryInterface( - XGridColumnFactory.class, _gridModel ); + final XGridColumnFactory columnFactory = UnoRuntime.queryInterface( XGridColumnFactory.class, _gridModel ); XPropertySet column = columnFactory.createColumn( _columnType ); column.setPropertyValue( "DataField", _boundField ); column.setPropertyValue( "Name", _boundField ); @@ -399,8 +391,8 @@ public class MasterDetailForms extends complexlib.ComplexTestCase implements com */ private void verifyColumnValueIdentity( final String masterColName, final String detailColName ) throws SQLException { - XColumnLocate locateMasterCols = (XColumnLocate)UnoRuntime.queryInterface( XColumnLocate.class, m_masterForm ); - XColumnLocate locateDetailCols = (XColumnLocate)UnoRuntime.queryInterface( XColumnLocate.class, m_detailForm ); + XColumnLocate locateMasterCols = UnoRuntime.queryInterface( XColumnLocate.class, m_masterForm ); + XColumnLocate locateDetailCols = UnoRuntime.queryInterface( XColumnLocate.class, m_detailForm ); int masterValue = m_masterResult.getInt( locateMasterCols.findColumn( masterColName ) ); int detailValue = m_detailResult.getInt( locateDetailCols.findColumn( detailColName ) ); diff --git a/forms/qa/integration/forms/TestCase.java b/forms/qa/integration/forms/TestCase.java index 1f019d6fa278..7ebcb56a54bd 100644 --- a/forms/qa/integration/forms/TestCase.java +++ b/forms/qa/integration/forms/TestCase.java @@ -30,11 +30,9 @@ package integration.forms; -import com.sun.star.uno.*; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.util.XCloseable; import com.sun.star.util.XModifiable; -import integration.forms.DocumentType; public abstract class TestCase extends complexlib.ComplexTestCase implements com.sun.star.lang.XEventListener { @@ -50,12 +48,23 @@ public abstract class TestCase extends complexlib.ComplexTestCase implements com } /* ------------------------------------------------------------------ */ + public String getTestObjectName() + { + return this.getClass().getName(); + } + + /* ------------------------------------------------------------------ */ public void before() throws com.sun.star.uno.Exception, java.lang.Exception { m_orb = (XMultiServiceFactory)param.getMSF(); } /* ------------------------------------------------------------------ */ + public void after() throws com.sun.star.uno.Exception, java.lang.Exception + { + } + + /* ------------------------------------------------------------------ */ /** closes our document, if we have an open one, via (simulated) user input */ protected void closeDocumentByUI() diff --git a/forms/qa/integration/forms/dbfTools.java b/forms/qa/integration/forms/dbfTools.java index 2f100a2c2128..8588cf8a0f55 100644 --- a/forms/qa/integration/forms/dbfTools.java +++ b/forms/qa/integration/forms/dbfTools.java @@ -24,7 +24,7 @@ class dbfTools */ static public XPropertySet queryPropertySet( Object aComp ) { - return (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, aComp ); + return UnoRuntime.queryInterface( XPropertySet.class, aComp ); } /* ------------------------------------------------------------------ */ @@ -32,7 +32,7 @@ class dbfTools */ static public XIndexContainer queryIndexContainer( Object aComp ) { - return (XIndexContainer)UnoRuntime.queryInterface( XIndexContainer.class, aComp ); + return UnoRuntime.queryInterface( XIndexContainer.class, aComp ); } /* ------------------------------------------------------------------ */ @@ -40,15 +40,16 @@ class dbfTools */ static public XComponent queryComponent( Object aComp ) { - return (XComponent)UnoRuntime.queryInterface( XComponent.class, aComp ); + return UnoRuntime.queryInterface( XComponent.class, aComp ); } /* ------------------------------------------------------------------ */ /** retrieves the parent of the given object */ + @SuppressWarnings("unchecked") static Object getParent( Object aComponent, Class aInterfaceClass ) { - XChild xAsChild = (XChild)UnoRuntime.queryInterface( XChild.class, aComponent ); + XChild xAsChild = UnoRuntime.queryInterface( XChild.class, aComponent ); return UnoRuntime.queryInterface( aInterfaceClass, xAsChild.getParent() ); } }; |