def test_monitors_new_windows(self): StackIDEManager.check_windows() self.assertEqual(0, len(StackIDEManager.ide_backend_instances)) sublime.create_window('.') StackIDEManager.check_windows() self.assertEqual(1, len(StackIDEManager.ide_backend_instances)) sublime.destroy_windows()
def test_retains_live_instances(self): window = mock_window(['.']) sublime.add_window(window) StackIDEManager.check_windows() self.assertEqual(1, len(StackIDEManager.ide_backend_instances)) # substitute a 'live' instance instance = stack_ide.StackIDE(window, test_settings, FakeBackend()) StackIDEManager.ide_backend_instances[window.id()] = instance # instance should still exist. StackIDEManager.check_windows() self.assertEqual(1, len(StackIDEManager.ide_backend_instances)) self.assertEqual(instance, StackIDEManager.ide_backend_instances[window.id()]) sublime.destroy_windows()
def test_kills_live_orphans(self): window = sublime.create_window('.') StackIDEManager.check_windows() self.assertEqual(1, len(StackIDEManager.ide_backend_instances)) # substitute a 'live' instance backend = MagicMock() stack_ide.stack_ide_loadtargets = Mock(return_value=['app/Main.hs', 'src/Lib.hs']) instance = stack_ide.StackIDE(window, test_settings, backend) StackIDEManager.ide_backend_instances[window.id()] = instance # close the window sublime.destroy_windows() # instance should be killed StackIDEManager.check_windows() self.assertEqual(0, len(StackIDEManager.ide_backend_instances)) self.assertFalse(instance.is_alive) backend.send_request.assert_called_with(Req.get_shutdown())
def test_reset(self): window = mock_window(['.']) sublime.add_window(window) StackIDEManager.check_windows() self.assertEqual(1, len(StackIDEManager.ide_backend_instances)) # substitute a 'live' instance backend = MagicMock() stack_ide.stack_ide_loadtargets = Mock(return_value=['app/Main.hs', 'src/Lib.hs']) instance = stack_ide.StackIDE(window, test_settings, backend) StackIDEManager.ide_backend_instances[window.id()] = instance StackIDEManager.reset() # instances should be shut down. self.assertEqual(1, len(StackIDEManager.ide_backend_instances)) self.assertFalse(instance.is_alive) backend.send_request.assert_called_with(Req.get_shutdown()) sublime.destroy_windows()
def test_retains_existing_instances(self): StackIDEManager.check_windows() self.assertEqual(0, len(StackIDEManager.ide_backend_instances)) sublime.create_window('.') StackIDEManager.check_windows() self.assertEqual(1, len(StackIDEManager.ide_backend_instances)) StackIDEManager.check_windows() self.assertEqual(1, len(StackIDEManager.ide_backend_instances)) sublime.destroy_windows()
def test_creates_initial_window(self): sublime.create_window('.') StackIDEManager.check_windows() self.assertEqual(1, len(StackIDEManager.ide_backend_instances)) sublime.destroy_windows()
def test_defaults(self): StackIDEManager.check_windows() self.assertEqual(0, len(StackIDEManager.ide_backend_instances))
def check_for_processes(self): StackIDEManager.check_windows() self.timer = threading.Timer(1.0, self.check_for_processes) self.timer.start()