Beispiel #1
0
    def setUp(self):
        # These objects only need to be set / created once.
        if TestActiveToolProxy.proxy is None:
            TestActiveToolProxy.proxy = ActiveToolProxy()

        self.tool = Tool()
        self.tool.setPluginId("test_tool_1")
Beispiel #2
0
def test_getSelectedObjectsWithoutSelectedAncestors():
    scene_node_1 = SceneNode()
    Selection.add(scene_node_1)
    test_tool_1 = Tool()
    assert test_tool_1._getSelectedObjectsWithoutSelectedAncestors() == [
        scene_node_1
    ]
Beispiel #3
0
def test_toolEnabledChanged():
    test_tool_1 = Tool()
    test_tool_1.setPluginId("test_tool_1")
    assert test_tool_1.getEnabled()

    # Fake the signal from the controller
    test_tool_1._onToolEnabledChanged("SomeOtherTOol", True)
    assert test_tool_1.getEnabled()
    # Fake the signal from the controller, but this time it's a signal that should force the tool to change.
    test_tool_1._onToolEnabledChanged("test_tool_1", False)
    assert not test_tool_1.getEnabled()
Beispiel #4
0
def test_setCameraTool(application):
    controller = Controller(application)
    camera_tool = Tool()
    camera_tool.setPluginId("camera_tool")
    controller.addTool(camera_tool)

    controller.setCameraTool(camera_tool)
    assert controller.getCameraTool() == camera_tool

    controller.setCameraTool("")
    assert controller.getCameraTool() is None

    controller.setCameraTool("camera_tool")
    assert controller.getCameraTool() == camera_tool
Beispiel #5
0
def test_getAndSet(data):
    test_tool = Tool()
    # Attempt to set the value
    getattr(test_tool, "set" + data["attribute"])(data["value"])

    # Ensure that the value got set
    assert getattr(test_tool, "get" + data["attribute"])() == data["value"]
    def setUp(self):
        # These objects only need to be set / created once.
        if TestActiveToolProxy.proxy is None:
            TestActiveToolProxy.proxy = ActiveToolProxy()

        self.tool = Tool()
        self.tool.setPluginId("test_tool_1")
Beispiel #7
0
def test_setCameraTool(application):
    controller = Controller(application)

    camera_tool = Tool()
    camera_tool.setPluginId("camera_tool")

    controller.addTool(camera_tool)

    controller.setCameraTool(camera_tool)
    assert controller.getCameraTool() == camera_tool

    controller.setCameraTool("")
    assert controller.getCameraTool() is None

    controller.setCameraTool("camera_tool")
    assert controller.getCameraTool() == camera_tool
def test_addTools(application):
    controller = Controller(application)

    # Switch out the emits with a mock.
    controller.toolsChanged.emit = MagicMock()
    controller.activeToolChanged.emit = MagicMock()

    test_tool_1 = Tool()
    test_tool_1.setPluginId("test_tool_1")
    test_tool_1.event = MagicMock()
    test_tool_2 = Tool()
    test_tool_2.setPluginId("test_tool_2")

    controller.addTool(test_tool_1)
    assert controller.toolsChanged.emit.call_count == 1

    controller.addTool(test_tool_2)
    assert controller.toolsChanged.emit.call_count == 2

    controller.addTool(test_tool_1)
    assert controller.toolsChanged.emit.call_count == 2
    assert len(controller.getAllTools()) == 2

    # Set active tool with an unknown name.
    controller.setActiveTool("nope nope!")
    assert controller.getActiveTool() is None
    assert controller.activeToolChanged.emit.call_count == 0

    # Set active tool by reference
    controller.setActiveTool(test_tool_1)
    assert controller.getActiveTool() == test_tool_1
    assert controller.activeToolChanged.emit.call_count == 1
    # Check if the tool got notified that it's not active.
    assert test_tool_1.event.call_args_list[0][0][
        0].type == Event.ToolActivateEvent

    # Set active tool by ID, but the same as is already active.
    controller.setActiveTool("test_tool_1")
    assert controller.getActiveTool() == test_tool_1
    assert controller.activeToolChanged.emit.call_count == 1

    # Set active tool by ID
    controller.setActiveTool("test_tool_2")
    assert controller.getActiveTool() == test_tool_2
    assert controller.activeToolChanged.emit.call_count == 2
    # Check if the tool got notified that it's no longer active.
    assert test_tool_1.event.call_args_list[1][0][
        0].type == Event.ToolDeactivateEvent

    assert controller.getTool("ZOMG") is None
    assert controller.getTool("test_tool_1") == test_tool_1
    assert controller.getTool("test_tool_2") == test_tool_2
Beispiel #9
0
def test_getDragVector():
    test_tool_1 = Tool()
    test_tool_1.setPluginId("test_tool_1")

    # No drag plane set
    assert test_tool_1.getDragVector(0, 0) is None
    test_tool_1.setDragPlane(Plane())
    # No drag start
    assert test_tool_1.getDragVector(0, 0) is None
Beispiel #10
0
def test_exposedProperties():

    test_tool_1 = Tool()
    test_tool_1.setPluginId("test_tool_1")

    test_tool_1.setExposedProperties("bla", "omg", "zomg")
    assert test_tool_1.getExposedProperties() == ["bla", "omg", "zomg"]
Beispiel #11
0
def test_toolOperations(application):
    controller = Controller(application)
    controller.toolOperationStarted.emit = MagicMock()
    controller.toolOperationStopped.emit = MagicMock()
    test_tool_1 = Tool()
    test_tool_1.setPluginId("test_tool_1")

    controller.addTool(test_tool_1)
    # The tool starts an operation
    test_tool_1.operationStarted.emit(test_tool_1)

    controller.toolOperationStarted.emit.assert_called_with(test_tool_1)
    assert controller.isToolOperationActive()

    # The tool stops doing something
    test_tool_1.operationStopped.emit(test_tool_1)
    controller.toolOperationStopped.emit.assert_called_with(test_tool_1)
    assert not controller.isToolOperationActive()
Beispiel #12
0
def test_toolOperations(application):
    controller = Controller(application)
    controller.toolOperationStarted.emit = MagicMock()
    controller.toolOperationStopped.emit = MagicMock()
    test_tool_1 = Tool()
    test_tool_1.setPluginId("test_tool_1")

    controller.addTool(test_tool_1)
    # The tool starts an operation
    test_tool_1.operationStarted.emit(test_tool_1)

    controller.toolOperationStarted.emit.assert_called_with(test_tool_1)
    assert controller.isToolOperationActive()

    # The tool stops doing something
    test_tool_1.operationStopped.emit(test_tool_1)
    controller.toolOperationStopped.emit.assert_called_with(test_tool_1)
    assert not controller.isToolOperationActive()
Beispiel #13
0
def test_setLockedAxis():
    test_tool_1 = Tool()
    test_tool_handle_1 = ToolHandle()
    test_tool_handle_1._auto_scale = False
    # Pretend like the toolhandle actually got rendered at least once
    with patch("UM.View.GL.OpenGL.OpenGL.getInstance"):
        test_tool_handle_1.render(None)

    # Needs to start out with Nothing locked
    assert test_tool_1.getLockedAxis() == ToolHandle.NoAxis

    # Just the vanilla changing.
    test_tool_1.setLockedAxis(ToolHandle.XAxis)
    assert test_tool_1.getLockedAxis() == ToolHandle.XAxis

    test_tool_1.setHandle(test_tool_handle_1)
    test_tool_1.setLockedAxis(ToolHandle.YAxis)
    assert test_tool_1.getLockedAxis() == ToolHandle.YAxis
    assert test_tool_handle_1.getActiveAxis() == ToolHandle.YAxis
Beispiel #14
0
def test_getDragVector():
    test_tool_1 = Tool()
    test_tool_1.setPluginId("test_tool_1")

    # No drag plane set
    assert test_tool_1.getDragVector(0, 0) is None
    test_tool_1.setDragPlane(Plane())
    # No drag start
    assert test_tool_1.getDragVector(0, 0) is None
Beispiel #15
0
def test_tools():
    mock_application = MagicMock()

    Application.getInstance = MagicMock(return_type=mock_application)
    controller = Controller(mock_application)

    # Switch out the emits with a mock.
    controller.toolsChanged.emit = MagicMock()
    controller.activeToolChanged.emit = MagicMock()
    controller.toolOperationStarted.emit = MagicMock()
    controller.toolOperationStopped.emit = MagicMock()

    test_tool_1 = Tool()
    test_tool_1.setPluginId("test_tool_1")

    test_tool_2 = Tool()
    test_tool_2.setPluginId("test_tool_2")

    controller.addTool(test_tool_1)
    assert controller.toolsChanged.emit.call_count == 1

    controller.addTool(test_tool_2)
    assert controller.toolsChanged.emit.call_count == 2

    controller.addTool(test_tool_1)
    assert controller.toolsChanged.emit.call_count == 2
    assert len(controller.getAllTools()) == 2

    # Set if with an unknown name.
    controller.setActiveTool("nope nope!")
    assert controller.getActiveTool() is None
    assert controller.activeToolChanged.emit.call_count == 0

    # Set active tool by reference
    controller.setActiveTool(test_tool_1)
    assert controller.getActiveTool() == test_tool_1
    assert controller.activeToolChanged.emit.call_count == 1

    # Set active tool by ID, but the same as is already active.
    controller.setActiveTool("test_tool_1")
    assert controller.getActiveTool() == test_tool_1
    assert controller.activeToolChanged.emit.call_count == 1

    # Set active tool by ID
    controller.setActiveTool("test_tool_2")
    assert controller.getActiveTool() == test_tool_2
    assert controller.activeToolChanged.emit.call_count == 2

    assert controller.getTool("ZOMG") is None
    assert controller.getTool("test_tool_1") == test_tool_1
    assert controller.getTool("test_tool_2") == test_tool_2
Beispiel #16
0
def test_exposedProperties():

    test_tool_1 = Tool()
    test_tool_1.setPluginId("test_tool_1")

    test_tool_1.setExposedProperties("bla", "omg", "zomg")
    assert test_tool_1.getExposedProperties() == ["bla", "omg", "zomg"]
Beispiel #17
0
def test_addTools(application):
    controller = Controller(application)

    # Switch out the emits with a mock.
    controller.toolsChanged.emit = MagicMock()
    controller.activeToolChanged.emit = MagicMock()

    test_tool_1 = Tool()
    test_tool_1.setPluginId("test_tool_1")
    test_tool_1.event = MagicMock()
    test_tool_2 = Tool()
    test_tool_2.setPluginId("test_tool_2")

    controller.addTool(test_tool_1)
    assert controller.toolsChanged.emit.call_count == 1

    controller.addTool(test_tool_2)
    assert controller.toolsChanged.emit.call_count == 2

    controller.addTool(test_tool_1)
    assert controller.toolsChanged.emit.call_count == 2
    assert len(controller.getAllTools()) == 2

    # Set active tool with an unknown name.
    controller.setActiveTool("nope nope!")
    assert controller.getActiveTool() is None
    assert controller.activeToolChanged.emit.call_count == 0

    # Set active tool by reference
    controller.setActiveTool(test_tool_1)
    assert controller.getActiveTool() == test_tool_1
    assert controller.activeToolChanged.emit.call_count == 1
    # Check if the tool got notified that it's not active.
    assert test_tool_1.event.call_args_list[0][0][0].type == Event.ToolActivateEvent

    # Set active tool by ID, but the same as is already active.
    controller.setActiveTool("test_tool_1")
    assert controller.getActiveTool() == test_tool_1
    assert controller.activeToolChanged.emit.call_count == 1

    # Set active tool by ID
    controller.setActiveTool("test_tool_2")
    assert controller.getActiveTool() == test_tool_2
    assert controller.activeToolChanged.emit.call_count == 2
    # Check if the tool got notified that it's no longer active.
    assert test_tool_1.event.call_args_list[1][0][0].type == Event.ToolDeactivateEvent

    assert controller.getTool("ZOMG") is None
    assert controller.getTool("test_tool_1") == test_tool_1
    assert controller.getTool("test_tool_2") == test_tool_2
Beispiel #18
0
def test_tools():
    mock_application = MagicMock()

    Application.getInstance = MagicMock(return_type = mock_application)
    controller = Controller(mock_application)

    # Switch out the emits with a mock.
    controller.toolsChanged.emit = MagicMock()
    controller.activeToolChanged.emit = MagicMock()
    controller.toolOperationStarted.emit = MagicMock()
    controller.toolOperationStopped.emit = MagicMock()

    test_tool_1 = Tool()
    test_tool_1.setPluginId("test_tool_1")

    test_tool_2 = Tool()
    test_tool_2.setPluginId("test_tool_2")

    controller.addTool(test_tool_1)
    assert controller.toolsChanged.emit.call_count == 1

    controller.addTool(test_tool_2)
    assert controller.toolsChanged.emit.call_count == 2

    controller.addTool(test_tool_1)
    assert controller.toolsChanged.emit.call_count == 2
    assert len(controller.getAllTools()) == 2

    # Set if with an unknown name.
    controller.setActiveTool("nope nope!")
    assert controller.getActiveTool() is None
    assert controller.activeToolChanged.emit.call_count == 0

    # Set active tool by reference
    controller.setActiveTool(test_tool_1)
    assert controller.getActiveTool() == test_tool_1
    assert controller.activeToolChanged.emit.call_count == 1

    # Set active tool by ID, but the same as is already active.
    controller.setActiveTool("test_tool_1")
    assert controller.getActiveTool() == test_tool_1
    assert controller.activeToolChanged.emit.call_count == 1

    # Set active tool by ID
    controller.setActiveTool("test_tool_2")
    assert controller.getActiveTool() == test_tool_2
    assert controller.activeToolChanged.emit.call_count == 2

    assert controller.getTool("ZOMG") is None
    assert controller.getTool("test_tool_1") == test_tool_1
    assert controller.getTool("test_tool_2") == test_tool_2
Beispiel #19
0
def test_setLockedAxis():
    test_tool_1 = Tool()
    test_tool_handle_1 = ToolHandle()
    test_tool_handle_1._enabled = True
    test_tool_handle_1._auto_scale = False
    # Pretend like the toolhandle actually got rendered at least once
    with patch("UM.View.GL.OpenGL.OpenGL.getInstance"):
        test_tool_handle_1.render(None)

    # Needs to start out with Nothing locked
    assert test_tool_1.getLockedAxis() == ToolHandle.NoAxis

    # Just the vanilla changing.
    test_tool_1.setLockedAxis(ToolHandle.XAxis)
    assert test_tool_1.getLockedAxis() == ToolHandle.XAxis

    test_tool_1.setHandle(test_tool_handle_1)
    test_tool_1.setLockedAxis(ToolHandle.YAxis)
    assert test_tool_1.getLockedAxis() == ToolHandle.YAxis
    assert test_tool_handle_1.getActiveAxis() == ToolHandle.YAxis
Beispiel #20
0
def test_getController():
    test_tool_1 = Tool()
    # Test coverage is magic. It should not be None by default, since the application provided one
    assert test_tool_1.getController() is not None
Beispiel #21
0
def test_getDragStart():
    test_tool_1 = Tool()
    # Test coverage is magic. It should be None by default.
    assert test_tool_1.getDragStart() is None
Beispiel #22
0
def test_getDragStart():
    test_tool_1 = Tool()
    # Test coverage is magic. It should be None by default.
    assert test_tool_1.getDragStart() is None
Beispiel #23
0
def test_getShortcutKey():
    test_tool_1 = Tool()
    # Test coverage is magic. It should be None by default.
    assert test_tool_1.getShortcutKey() is None
Beispiel #24
0
def createTool(tool_id):
    with patch("UM.Application.Application.getInstance"):
        result = Tool()
    result.setPluginId(tool_id)
    return result
Beispiel #25
0
def test_eventHandling(application):
    controller = Controller(application)

    selection_tool = Tool()
    selection_tool.setPluginId("selection_tool")
    selection_tool.event = MagicMock(return_value = True)

    camera_tool = Tool()
    camera_tool.setPluginId("camera_tool")
    camera_tool.event = MagicMock(return_value=True)

    random_tool = Tool()
    random_tool.setPluginId("random_tool")
    random_tool.event = MagicMock(return_value=True)

    event = Event(1)


    controller.setCameraTool(camera_tool)
    controller.event(event)
    # Only the camera tool should be called now.
    camera_tool.event.assert_called_once_with(event)

    controller.setActiveTool(random_tool)
    random_tool.event.reset_mock() #  We don't care about activation events.
    controller.event(event)
    # The camera tool should not get an extra call
    camera_tool.event.assert_called_once_with(event)
    # But the active tool should have gotten one
    random_tool.event.assert_called_once_with(event)

    controller.setSelectionTool(selection_tool)
    controller.event(event)
    # The camera tool should not get an extra call
    camera_tool.event.assert_called_once_with(event)
    # The active tool should not get an extra call
    random_tool.event.assert_called_once_with(event)
    # But the selection tool should have gotten one
    selection_tool.event.assert_called_once_with(event)
Beispiel #26
0
class TestActiveToolProxy(TestCase):
    proxy = None

    def setUp(self):
        # These objects only need to be set / created once.
        if TestActiveToolProxy.proxy is None:
            TestActiveToolProxy.proxy = ActiveToolProxy()

        self.tool = Tool()
        self.tool.setPluginId("test_tool_1")

    def tearDown(self):
        Application.getInstance().getController().setActiveTool("")

    def test_isValid(self):
        assert not self.proxy.valid
        Application.getInstance().getController().setActiveTool(self.tool)
        assert self.proxy.valid  # It is valid now

    def test_activeToolPanel(self):
        # There is no active tool, so it should be empty
        assert self.proxy.activeToolPanel == QUrl()

        with patch.object(self.tool, "getMetaData", MagicMock(return_value={"tool_panel": "derp"})):
            with patch("UM.PluginRegistry.PluginRegistry.getPluginPath", MagicMock(return_value = "OMG")):
                Application.getInstance().getController().setActiveTool(self.tool)
                assert self.proxy.activeToolPanel == QUrl.fromLocalFile("OMG/derp")
        # Try again with empty metadata
        with patch("UM.PluginRegistry.PluginRegistry.getMetaData", MagicMock(return_value={"tool": {}})):
            Application.getInstance().getController().setActiveTool("")
            Application.getInstance().getController().setActiveTool(self.tool)
            assert self.proxy.activeToolPanel == QUrl.fromLocalFile("")

    def test_triggerAction(self):
        # There is no active tool, so this is just a check to see if nothing breaks.
        self.proxy.triggerAction("derp")

        Application.getInstance().getController().setActiveTool(self.tool)

        # It is active now, but it doesn't have a function called "derp". Again, nothing should break.
        self.proxy.triggerAction("derp")

        self.tool.derp = MagicMock()

        self.proxy.triggerAction("derp")
        assert self.tool.derp.call_count == 1

    def test_triggerActionWithData(self):
        # There is no active tool, so this is just a check to see if nothing breaks.
        self.proxy.triggerActionWithData("derp", "omgzomg")

        Application.getInstance().getController().setActiveTool(self.tool)

        # It is active now, but it doesn't have a function called "derp". Again, nothing should break.
        self.proxy.triggerActionWithData("derp", "omgzomg")

        self.tool.derp = MagicMock()

        self.proxy.triggerActionWithData("derp", "omgzomg")
        self.tool.derp.assert_called_once_with("omgzomg")

    def test_properties(self):
        # There is no active tool, so this is just a check to see if nothing breaks.
        self.proxy.setProperty("derp", "omgzomg")

        self.tool.setExposedProperties("Bla", "beep")
        self.tool.getBla = MagicMock(return_value ="BlaBla")
        self.tool.setBla = MagicMock()
        self.tool.beep = ""
        self.tool.getbeep = MagicMock()

        Application.getInstance().getController().setActiveTool(self.tool)
        assert self.proxy.properties.getValue("Bla") == "BlaBla"  # The default
        self.proxy.forceUpdate()
        self.proxy.setProperty("Bla", "OMGZOMG")
        self.proxy.setProperty("beep", "whoo")
        self.tool.setBla.assert_called_once_with("OMGZOMG")

        assert self.tool.beep == "whoo" # If no set is found, but the property itself it should still be changed.
Beispiel #27
0
def test_getController():
    test_tool_1 = Tool()
    # Test coverage is magic. It should not be None by default, since the application provided one
    assert test_tool_1.getController() is not None
Beispiel #28
0
def test_toolEnabledChanged():
    test_tool_1 = Tool()
    test_tool_1.setPluginId("test_tool_1")
    assert test_tool_1.getEnabled()

    # Fake the signal from the controller
    test_tool_1._onToolEnabledChanged("SomeOtherTOol", True)
    assert test_tool_1.getEnabled()
    # Fake the signal from the controller, but this time it's a signal that should force the tool to change.
    test_tool_1._onToolEnabledChanged("test_tool_1", False)
    assert not test_tool_1.getEnabled()
class TestActiveToolProxy(TestCase):
    proxy = None

    def setUp(self):
        # These objects only need to be set / created once.
        if TestActiveToolProxy.proxy is None:
            TestActiveToolProxy.proxy = ActiveToolProxy()

        self.tool = Tool()
        self.tool.setPluginId("test_tool_1")

    def tearDown(self):
        Application.getInstance().getController().setActiveTool("")

    def test_isValid(self):
        assert not self.proxy.valid
        Application.getInstance().getController().setActiveTool(self.tool)
        assert self.proxy.valid  # It is valid now

    def test_activeToolPanel(self):
        # There is no active tool, so it should be empty
        assert self.proxy.activeToolPanel == QUrl()

        with patch("UM.PluginRegistry.PluginRegistry.getMetaData", MagicMock(return_value={"tool": {"tool_panel": "derp"}})):
            with patch("UM.PluginRegistry.PluginRegistry.getPluginPath", MagicMock(return_value = "OMG")):
                Application.getInstance().getController().setActiveTool(self.tool)
                assert self.proxy.activeToolPanel == QUrl.fromLocalFile("OMG/derp")
        # Try again with empty metadata
        with patch("UM.PluginRegistry.PluginRegistry.getMetaData", MagicMock(return_value={"tool": {}})):
            Application.getInstance().getController().setActiveTool("")
            Application.getInstance().getController().setActiveTool(self.tool)
            assert self.proxy.activeToolPanel == QUrl.fromLocalFile("")

    def test_triggerAction(self):
        # There is no active tool, so this is just a check to see if nothing breaks.
        self.proxy.triggerAction("derp")

        Application.getInstance().getController().setActiveTool(self.tool)

        # It is active now, but it doesn't have a function called "derp". Again, nothing should break.
        self.proxy.triggerAction("derp")

        self.tool.derp = MagicMock()

        self.proxy.triggerAction("derp")
        assert self.tool.derp.call_count == 1

    def test_triggerActionWithData(self):
        # There is no active tool, so this is just a check to see if nothing breaks.
        self.proxy.triggerActionWithData("derp", "omgzomg")

        Application.getInstance().getController().setActiveTool(self.tool)

        # It is active now, but it doesn't have a function called "derp". Again, nothing should break.
        self.proxy.triggerActionWithData("derp", "omgzomg")

        self.tool.derp = MagicMock()

        self.proxy.triggerActionWithData("derp", "omgzomg")
        self.tool.derp.assert_called_once_with("omgzomg")

    def test_properties(self):
        # There is no active tool, so this is just a check to see if nothing breaks.
        self.proxy.setProperty("derp", "omgzomg")

        self.tool.setExposedProperties("Bla", "beep")
        self.tool.getBla = MagicMock(return_value ="BlaBla")
        self.tool.setBla = MagicMock()
        self.tool.beep = ""
        self.tool.getbeep = MagicMock()

        Application.getInstance().getController().setActiveTool(self.tool)
        assert self.proxy.properties.getValue("Bla") == "BlaBla"  # The default
        self.proxy.forceUpdate()
        self.proxy.setProperty("Bla", "OMGZOMG")
        self.proxy.setProperty("beep", "whoo")
        self.tool.setBla.assert_called_once_with("OMGZOMG")

        assert self.tool.beep == "whoo" # If no set is found, but the property itself it should still be changed.
Beispiel #30
0
def test_getShortcutKey():
    test_tool_1 = Tool()
    # Test coverage is magic. It should be None by default.
    assert test_tool_1.getShortcutKey() is None
Beispiel #31
0
def test_getSelectedObjectsWithoutSelectedAncestors():
    scene_node_1 = SceneNode()
    Selection.add(scene_node_1)
    test_tool_1 = Tool()
    assert test_tool_1._getSelectedObjectsWithoutSelectedAncestors() == [scene_node_1]
Beispiel #32
0
def test_eventHandling(application):
    controller = Controller(application)

    selection_tool = Tool()
    selection_tool.setPluginId("selection_tool")
    selection_tool.event = MagicMock(return_value = True)

    camera_tool = Tool()
    camera_tool.setPluginId("camera_tool")
    camera_tool.event = MagicMock(return_value=True)

    random_tool = Tool()
    random_tool.setPluginId("random_tool")
    random_tool.event = MagicMock(return_value=True)

    event = Event(1)


    controller.setCameraTool(camera_tool)
    controller.event(event)
    # Only the camera tool should be called now.
    camera_tool.event.assert_called_once_with(event)

    controller.setActiveTool(random_tool)
    random_tool.event.reset_mock() #  We don't care about activation events.
    controller.event(event)
    # The camera tool should not get an extra call
    camera_tool.event.assert_called_once_with(event)
    # But the active tool should have gotten one
    random_tool.event.assert_called_once_with(event)

    controller.setSelectionTool(selection_tool)
    controller.event(event)
    # The camera tool should not get an extra call
    camera_tool.event.assert_called_once_with(event)
    # The active tool should not get an extra call
    random_tool.event.assert_called_once_with(event)
    # But the selection tool should have gotten one
    selection_tool.event.assert_called_once_with(event)