summaryrefslogtreecommitdiff
path: root/sfx2/qa
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@sun.com>2010-10-22 15:33:15 +0200
committerFrank Schoenheit [fs] <frank.schoenheit@sun.com>2010-10-22 15:33:15 +0200
commit1caeea031494e004f0eea6d27024e50fde72ec86 (patch)
tree2f4674365cab7e98284ae951ab128e91118e4f34 /sfx2/qa
parentbd8a6553efe9126dba65ec6152f5b9e4bca9dbf4 (diff)
undoapi: added locking support to the XUndoManager
Diffstat (limited to 'sfx2/qa')
-rwxr-xr-xsfx2/qa/complex/sfx2/UndoManager.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/sfx2/qa/complex/sfx2/UndoManager.java b/sfx2/qa/complex/sfx2/UndoManager.java
index 6c200ca96a95..2654dc58df17 100755
--- a/sfx2/qa/complex/sfx2/UndoManager.java
+++ b/sfx2/qa/complex/sfx2/UndoManager.java
@@ -435,6 +435,46 @@ public class UndoManager
assertFalse( "adding a new action should have cleared the Redo stack", undoManager.isRedoPossible() );
}
+ // locking the manager
+ {
+ undoManager.clear();
+ listener.reset();
+
+ // implicit Undo actions, triggered by changes to the document
+ assertFalse( "unexpected initial locking state", undoManager.isLocked() );
+ undoManager.lock();
+ assertTrue( "just locked the manager, why does it lie?", undoManager.isLocked() );
+ test.doSingleModification();
+ assertEquals( "when the Undo manager is locked, no implicit additions should happen",
+ 0, listener.getUndoActionsAdded() );
+ undoManager.unlock();
+ assertEquals( "unlock is not expected to add collected actions - they should be discarded",
+ 0, listener.getUndoActionsAdded() );
+ assertFalse( "just unlocked the manager, why does it lie?", undoManager.isLocked() );
+
+ // explicit Undo actions
+ undoManager.lock();
+ undoManager.addUndoAction( new CustomUndoAction( "Dummy Undo Action" ) );
+ undoManager.unlock();
+ assertEquals( "explicit Undo actions are expected to be ignored when the manager is locked",
+ 0, listener.getUndoActionsAdded() );
+
+ // Undo contexts while being locked
+ undoManager.lock();
+ undoManager.enterUndoContext( "Dummy Context" );
+ undoManager.enterHiddenUndoContext();
+ assertEquals( "entering Undo contexts should be ignored when the manager is locked", 0, listener.getUndoContextDepth() );
+ undoManager.leaveUndoContext();
+ undoManager.leaveUndoContext();
+ undoManager.unlock();
+
+ // |unlock| error handling
+ assertFalse( "internal error: manager should not be locked at this point in time", undoManager.isLocked() );
+ caughtExpected = false;
+ try { undoManager.unlock(); } catch ( final InvalidStateException e ) { caughtExpected = true; }
+ assertTrue( "unlocking the manager when it is not locked should throw", caughtExpected );
+ }
+
// close the document, ensure the Undo manager listener gets notified
m_currentDocument.close();
assertTrue( "document is closed, but the UndoManagerListener has not been notified of the disposal", listener.isDisposed() );