Test complete undo/redo cycle.
(self)
| 146 | self.assertEqual(self.history.get_command_count(), 1) |
| 147 | |
| 148 | def test_undo_redo_cycle(self): |
| 149 | """Test complete undo/redo cycle.""" |
| 150 | cmd1 = MockCommand("Command 1") |
| 151 | cmd2 = MockCommand("Command 2") |
| 152 | |
| 153 | # Execute commands |
| 154 | self.history.execute_command(cmd1) |
| 155 | self.history.execute_command(cmd2) |
| 156 | |
| 157 | # Should be able to undo |
| 158 | self.assertTrue(self.history.can_undo()) |
| 159 | self.assertEqual(self.history.get_undo_description(), "Command 2") |
| 160 | |
| 161 | # Undo last command |
| 162 | undone = self.history.undo() |
| 163 | self.assertEqual(undone, "Command 2") |
| 164 | self.assertEqual(cmd2.undo_count, 1) |
| 165 | |
| 166 | # Should be able to redo |
| 167 | self.assertTrue(self.history.can_redo()) |
| 168 | self.assertEqual(self.history.get_redo_description(), "Command 2") |
| 169 | |
| 170 | # Redo command |
| 171 | redone = self.history.redo() |
| 172 | self.assertEqual(redone, "Command 2") |
| 173 | self.assertEqual(cmd2.execute_count, 2) # Executed twice |
| 174 | |
| 175 | def test_depth_limit_enforcement(self): |
| 176 | """Test that command history respects depth limits.""" |
nothing calls this directly
no test coverage detected