use of org.whole.lang.model.InternalIEntity in project whole by wholeplatform.
the class HistoryInvariantsTest method testPrevCommandExecutionTimeOrder.
// The entity local history of binding commands is ordered
// invariant: for each cmd, cmd.prevCommand.executionTime <= cmd.executionTime
@Test
public void testPrevCommandExecutionTimeOrder() {
performChanges(model);
IEntityIterator<IEntity> i = IteratorFactory.descendantOrSelfIterator();
i.reset(model);
for (IEntity e : i) {
ICommand cmd = ((InternalIEntity) e).wGetBindingCommand();
while (cmd.getKind() != CommandKind.NULL) {
ICommand cmd1 = cmd.getPrevCommand();
Assert.assertTrue(cmd1.getExecutionTime() <= cmd.getExecutionTime());
cmd = cmd1;
}
}
}
use of org.whole.lang.model.InternalIEntity in project whole by wholeplatform.
the class HistoryInvariantsTest method testUndo.
@Test
public void testUndo() {
InternalIEntity e1 = (InternalIEntity) model.getName();
e1.wSetValue("newLangName1");
ICommand c1 = e1.wGetLastCommand();
e1.wSetValue("newLangName2");
ICommand c2 = e1.wGetLastCommand();
e1.wSetValue("newLangName3");
Assert.assertNotSame(c1, e1.wGetLastCommand());
history.undo();
Assert.assertEquals(e1.wStringValue(), "newLangName2");
Assert.assertEquals(e1.wGetLastCommand(), c2);
history.undo();
Assert.assertEquals(e1.wStringValue(), "newLangName1");
Assert.assertEquals(e1.wGetLastCommand(), c1);
}
use of org.whole.lang.model.InternalIEntity in project whole by wholeplatform.
the class HistoryInvariantsTest method testLastCommand.
@Test
public void testLastCommand() {
IEntity e1 = model.getName();
e1.wSetValue("newLangName");
ICommand c1 = ((InternalIEntity) e1).wGetLastCommand();
List<ICommand> changes = history.getUndoCommands();
ICommand lastCmd = (ICommand) changes.get(changes.size() - 1);
Assert.assertSame(lastCmd, c1);
}
use of org.whole.lang.model.InternalIEntity in project whole by wholeplatform.
the class HistoryInvariantsTest method testUndoRedo.
@Test
public void testUndoRedo() {
InternalIEntity e1 = (InternalIEntity) model.getName();
e1.wSetValue("newLangName1");
ICommand c1 = e1.wGetLastCommand();
e1.wSetValue("newLangName2");
ICommand c2 = e1.wGetLastCommand();
history.undo();
Assert.assertEquals(e1.wStringValue(), "newLangName1");
Assert.assertEquals(e1.wGetLastCommand(), c1);
history.redo();
Assert.assertEquals(e1.wStringValue(), "newLangName2");
Assert.assertEquals(e1.wGetLastCommand(), c2);
}
use of org.whole.lang.model.InternalIEntity in project whole by wholeplatform.
the class HistoryInvariantsTest method testUndoSet.
@Test
public void testUndoSet() {
InternalIEntity e1 = (InternalIEntity) model.getName();
e1.wSetValue("newLangName1");
ICommand c1 = e1.wGetLastCommand();
e1.wSetValue("newLangName2");
ICommand c2 = e1.wGetLastCommand();
Assert.assertNotSame(c2, c1);
history.undo();
e1.wSetValue("newLangName3");
Assert.assertSame(e1.wGetLastCommand().getPrevCommand(), c1);
}
Aggregations