Ejemplo n.º 1
0
def test_start_presentation_no_control(mocked_sleep):
    """
    Test the start_presentation() method when there's no control
    """
    # GIVEN: A LibreOfficeServer instance and some mocks
    server = LibreOfficeServer()
    mocked_control = MagicMock()
    mocked_document = MagicMock()
    mocked_presentation = MagicMock()
    mocked_controller = MagicMock()
    mocked_frame = MagicMock()
    mocked_window = MagicMock()
    server._document = mocked_document
    server._presentation = mocked_presentation
    mocked_document.getCurrentController.return_value = mocked_controller
    mocked_controller.getFrame.return_value = mocked_frame
    mocked_frame.getContainerWindow.return_value = mocked_window
    mocked_presentation.getController.side_effect = [None, mocked_control]

    # WHEN: start_presentation() is called
    server.start_presentation()

    # THEN: The slide number should be correct
    mocked_document.getCurrentController.assert_called_once_with()
    mocked_controller.getFrame.assert_called_once_with()
    mocked_frame.getContainerWindow.assert_called_once_with()
    mocked_presentation.start.assert_called_once_with()
    assert mocked_presentation.getController.call_count == 2
    mocked_sleep.assert_called_once_with(0.1)
    assert mocked_window.setVisible.call_args_list == [call(True), call(False)]
    assert server._control is mocked_control
Ejemplo n.º 2
0
def test_start_presentation():
    """
    Test the start_presentation() method when there's a control
    """
    # GIVEN: A LibreOfficeServer instance and some mocks
    server = LibreOfficeServer()
    mocked_control = MagicMock()
    server._control = mocked_control

    # WHEN: start_presentation() is called
    with patch.object(server, 'goto_slide') as mocked_goto_slide:
        server.start_presentation()

    # THEN: The control should have been activated and the first slide selected
    mocked_control.activate.assert_called_once_with()
    mocked_goto_slide.assert_called_once_with(1)