/* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
// wait until the detail form is loaded
loadMaster.load();
impl_waitForLoadedEvent();
// okay, now the master form should be on the first record
assure( "wrong form state after loading (ID1)", m_masterResult.getInt(1) == 1 );
assure( "wrong form state after loading (ID2)", m_masterResult.getInt(2) == 1 );
assure( "wrong form state after loading (value)", m_masterResult.getString(3).equals( "First Record" ) );
// the values in the linked fields should be identical int expectedDetailRowCounts[] = { 2, 1 }; do
{
verifyColumnValueIdentity( "ID1", "FK_ID1" );
verifyColumnValueIdentity( "ID2", "FK_ID2" );
m_detailResult.last(); int masterPos = m_masterResult.getRow();
assure( "wrong number of records in detail form, for master form at pos " + masterPos,
((Integer)m_detailForm.getPropertyValue( "RowCount" )).intValue() == expectedDetailRowCounts[ masterPos - 1 ] );
if (!m_masterResult.next()) return;
impl_waitForLoadedEvent();
} while ( !m_masterResult.isAfterLast() );
assure( "wrong number of records in master form", 2 == ((Integer)m_masterForm.getPropertyValue( "RowCount" )).intValue() );
} finally
{ if ( databaseDocument != null )
databaseDocument.closeAndDelete();
impl_cleanUpStep();
}
}
/* ------------------------------------------------------------------ */ /** checks whether default values in detail forms work as expected. * * Effectively, this test case verifies the issues #i106574# and #i105235# did not creep back in.
*/ publicvoid checkDetailFormDefaults() throws Exception
{
CRMDatabase database = null;
XCommandProcessor subComponentCommands = null; try
{ // create our standard CRM database document
database = new CRMDatabase( m_orb, true );
// create a form document therein
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().getXConnection() ), new NamedValue( "MediaType", "application/vnd.oasis.opendocument.text" )
};
// now that we set up this, do the actual tests // First, https://bz.apache.org/ooo/show_bug.cgi?id=105235 described the problem // that default values in the sub form didn't work when the master form was navigated to a row // for which no detail records were present, and the default of the column/control is the same // as the last known value.
// so, take the current value of the "Name" column, and set it as default value ...
String defaultValue = m_detailResult.getString( 2 );
nameColumn.setPropertyValue( "DefaultText", defaultValue ); // ... then move to the second main form row ...
m_masterResult.absolute( 2 );
impl_waitForLoadedEvent(); // ... which should result in an empty sub form ...
assure( "test precondition not met: The second master form record is expected to have no detail records, " + "else the test becomes meaningless", impl_isNewRecord( m_detailForm ) ); // ... and in the "Name" column having the proper text
String actualValue = (String)nameColumn.getPropertyValue( "Text" );
assureEquals( "#i105235#: default value in sub form not working (not propagated to column model)", defaultValue, actualValue ); // However, checking the column model's value alone is not enough - we need to ensure it is properly // propagated to the control.
XGridFieldDataSupplier gridData = subDocument.getCurrentView().getControl(
gridControlModel, XGridFieldDataSupplier.class );
actualValue = (String)(gridData.queryFieldData( 0, Type.STRING )[1]);
assureEquals( "#i105235#: default value in sub form not working (not propagated to column)", defaultValue, actualValue );
} finally
{ if ( subComponentCommands != null )
{
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";
subComponentCommands.execute( command, subComponentCommands.createCommandIdentifier(), null );
}
privatevoid impl_waitForLoadedEvent()
{ synchronized( m_waitForLoad )
{ while ( !m_loaded )
{ try { m_waitForLoad.wait(); } catch( InterruptedException e ) { }
} // reset the flag for the next time
m_loaded = false;
}
}
/** assures that the (integer) values in the given columns of our master and detail forms are identical
*/ privatevoid verifyColumnValueIdentity( final String masterColName, final String detailColName ) throws SQLException
{
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 ) );
assure( "values in linked column pair " + detailColName + "->" + masterColName + " (" +
detailValue + "->" + masterValue + ") do not match (master position: " + m_masterResult.getRow() + ")!",
masterValue == detailValue );
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.