// --------------------------------------------------------------------------------------------------------
public void testGlobalEvents() throws Exception, IOException
{
XModel databaseDoc = impl_createEmptyEmbeddedHSQLDocument();
final XStorable storeDoc = (XStorable) UnoRuntime.queryInterface(XStorable.class,
databaseDoc);
String context, newURL;
// XStorable.store
final String oldURL = databaseDoc.getURL();
context = "store";
impl_startObservingEvents(context);
storeDoc.store();
assureEquals("store is not expected to change the document URL", databaseDoc.getURL(), oldURL);
impl_stopObservingEvents(m_globalEvents, new String[]
{
"OnSave", "OnSaveDone"
}, context);
// XStorable.storeToURL
context = "storeToURL";
impl_startObservingEvents(context);
storeDoc.storeToURL(createTempFileURL(), new PropertyValue[0]);
assureEquals("storetoURL is not expected to change the document URL", databaseDoc.getURL(), oldURL);
impl_stopObservingEvents(m_globalEvents, new String[]
{
"OnSaveTo", "OnSaveToDone"
}, context);
// XStorable.storeAsURL
newURL = createTempFileURL();
context = "storeAsURL";
impl_startObservingEvents(context);
storeDoc.storeAsURL(newURL, new PropertyValue[0]);
assureEquals("storeAsURL is expected to change the document URL", databaseDoc.getURL(), newURL);
impl_stopObservingEvents(m_globalEvents, new String[]
{
"OnSaveAs", "OnSaveAsDone"
}, context);
// XModifiable.setModified
final XModifiable modifyDoc = (XModifiable) UnoRuntime.queryInterface(XModifiable.class,
databaseDoc);
context = "setModified";
impl_startObservingEvents(context);
modifyDoc.setModified(true);
assureEquals("setModified didn't work", modifyDoc.isModified(), true);
impl_stopObservingEvents(m_globalEvents, new String[]
{
"OnModifyChanged"
}, context);
// XStorable.store, with implicit reset of the "Modified" flag
context = "store (2)";
impl_startObservingEvents(context);
storeDoc.store();
assureEquals("'store' should implicitly reset the modified flag", modifyDoc.isModified(), false);
impl_stopObservingEvents(m_globalEvents, new String[]
{
"OnSave", "OnSaveDone", "OnModifyChanged"
}, context);