import unittest

from enable.testing import EnableTestAssistant
from enable.window import Window

from ensemble.ctf.editor import CtfEditor


def get_color(starting_color=None):
    if starting_color:
        return starting_color
    return (0.0, 1.0, 0.0)


def get_filename(action='save'):
    return 'temp.json'


class TestCtfEditor(EnableTestAssistant, unittest.TestCase):

    def setUp(self):
        tool = CtfEditor(bounds=(400, 100),
                         prompt_color_selection=get_color,
                         prompt_file_selection=get_filename)
        tool.add_function_node(tool.opacities, (0.5, 0.5))
        tool.add_function_node(tool.colors, (0.25, 1.0, 0.0, 0.0))
        self.tool = tool
        self.window = Window(None, size=(100, 100), component=tool)
        self.window.control.show()

    def test_mouse_drag_alpha(self):
        tool = self.tool
        self.press_move_release(tool, [(50, 50), (51, 50), (52, 50),
                                       (53, 50), (54, 50), (55, 50)],
                                window=self.window)

    def test_mouse_drag_color(self):
        tool = self.tool
        self.press_move_release(tool, [(25, 10), (25, 10), (40, 10)],
                                window=self.window)

if __name__ == '__main__':
    unittest.main()

@@ -89,16 +89,85 @@
 t Window
+%0Afrom traits_enaml.testing.gui_test_assistant import GuiTestAssistant
 %0A%0Afrom e
@@ -420,16 +420,34 @@
 sistant,
+ GuiTestAssistant,
  unittes
@@ -473,32 +473,76 @@
 ef setUp(self):%0A
+        super(TestCtfEditor, self).setUp()%0A%0A
         tool = C
@@ -908,16 +908,52 @@
 t=tool)%0A
+        with self.event_loop():%0A    
         

Use GuiTestAssitant to possibly remedy CtfEditor test failures.