@After publicvoid afterTest()
{ if ( m_document != null )
{
assertTrue( "closing the test document failed", m_document.close() );
m_document = null;
}
}
/** * sets up the environment for a test which checks the behavior upon closing a doc
*/ privatevoid impl_setupDocCloseTest()
{
m_observedCloseEvents.clear();
final XDocumentEventBroadcaster docEventBroadcaster = UnoRuntime.queryInterface(
XDocumentEventBroadcaster.class, m_document.getDocument() );
docEventBroadcaster.addDocumentEventListener( new DocumentEventListener() );
final XCloseable docCloseable = UnoRuntime.queryInterface( XCloseable.class,
m_document.getDocument() );
docCloseable.addCloseListener( new CloseListener() );
m_document.getDocument().addEventListener( new DocDisposeListener() );
}
/** * sets up the environment for a test which checks the behavior upon closing a doc
*/ privatevoid impl_tearDownDocCloseTest( final String i_docCloseMethod )
{ synchronized( m_document )
{ try
{
m_document.wait(10000);
} catch (InterruptedException ex)
{ // don't continue the test if somebody interrupted us ... return;
}
}
m_document = null; synchronized( m_observedCloseEvents )
{
assertArrayEquals( "wrong order of events when closing a doc " + i_docCloseMethod, new CloseEventType[] { CloseEventType.OnUnload, CloseEventType.NotifyClosing, CloseEventType.Disposing },
m_observedCloseEvents.toArray( new CloseEventType[0] )
);
}
}
//@Test publicvoid testCloseByAPI()
{
impl_setupDocCloseTest(); // closing the doc by API is synchronous, so do this in a separate thread, else we will get a deadlock // when the document tries to call back our listener (well, I admit I didn't understand *why* we get this // deadlock ... :-\ )
(new DocCloser()).start();
impl_tearDownDocCloseTest( "by API" );
}
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.