| OLD | NEW |
| (Empty) |
| 1 | |
| 2 """ | |
| 3 Tests for the insults windowing module, L{twisted.conch.insults.window}. | |
| 4 """ | |
| 5 | |
| 6 from twisted.trial.unittest import TestCase | |
| 7 | |
| 8 from twisted.conch.insults.window import TopWindow | |
| 9 | |
| 10 | |
| 11 class TopWindowTests(TestCase): | |
| 12 """ | |
| 13 Tests for L{TopWindow}, the root window container class. | |
| 14 """ | |
| 15 | |
| 16 def test_paintScheduling(self): | |
| 17 """ | |
| 18 Verify that L{TopWindow.repaint} schedules an actual paint to occur | |
| 19 using the scheduling object passed to its initializer. | |
| 20 """ | |
| 21 paints = [] | |
| 22 scheduled = [] | |
| 23 root = TopWindow(lambda: paints.append(None), scheduled.append) | |
| 24 | |
| 25 # Nothing should have happened yet. | |
| 26 self.assertEqual(paints, []) | |
| 27 self.assertEqual(scheduled, []) | |
| 28 | |
| 29 # Cause a paint to be scheduled. | |
| 30 root.repaint() | |
| 31 self.assertEqual(paints, []) | |
| 32 self.assertEqual(len(scheduled), 1) | |
| 33 | |
| 34 # Do another one to verify nothing else happens as long as the previous | |
| 35 # one is still pending. | |
| 36 root.repaint() | |
| 37 self.assertEqual(paints, []) | |
| 38 self.assertEqual(len(scheduled), 1) | |
| 39 | |
| 40 # Run the actual paint call. | |
| 41 scheduled.pop()() | |
| 42 self.assertEqual(len(paints), 1) | |
| 43 self.assertEqual(scheduled, []) | |
| 44 | |
| 45 # Do one more to verify that now that the previous one is finished | |
| 46 # future paints will succeed. | |
| 47 root.repaint() | |
| 48 self.assertEqual(len(paints), 1) | |
| 49 self.assertEqual(len(scheduled), 1) | |
| OLD | NEW |