// part I: non-empty contexts
i_undoManager.reset();
m_undoListener.reset();
// put one action on the undo and one on the redo stack, as precondition for the following tests
final XUndoAction undoAction1 = new CustomUndoAction( "Undo Action 1" );
i_undoManager.addUndoAction( undoAction1 );
final XUndoAction undoAction2 = new CustomUndoAction( "Undo Action 2" );
i_undoManager.addUndoAction( undoAction2 );
i_undoManager.undo();
assertTrue( "precondition for context handling tests not met (1)", i_undoManager.isUndoPossible() );
assertTrue( "precondition for context handling tests not met (2)", i_undoManager.isRedoPossible() );
assertArrayEquals( new String[] { undoAction1.getTitle() }, i_undoManager.getAllUndoActionTitles() );
assertArrayEquals( new String[] { undoAction2.getTitle() }, i_undoManager.getAllRedoActionTitles() );
final String[] expectedRedoActionComments = new String[] { undoAction2.getTitle() };
assertArrayEquals( expectedRedoActionComments, i_undoManager.getAllRedoActionTitles() );
// enter a context
i_undoManager.enterUndoContext( "Undo Context" );
// this should not (yet) touch the redo stack
assertArrayEquals( expectedRedoActionComments, i_undoManager.getAllRedoActionTitles() );
assertEquals( "unexpected undo context depth after entering a context", 1, m_undoListener.getCurrentUndoContextDepth() );
// add a single action
XUndoAction undoAction3 = new CustomUndoAction( "Undo Action 3" );
i_undoManager.addUndoAction( undoAction3 );
// still, the redo stack should be untouched - added at a lower level does not affect it at all
assertArrayEquals( expectedRedoActionComments, i_undoManager.getAllRedoActionTitles() );
// while the context is open, its title should already contribute to the stack, ...