def testSerialisation(self):

        scriptNode = Gaffer.ScriptNode()

        layouts = GafferUI.Layouts.acquire(Gaffer.Application("Layout tester"))
        for type in GafferUI.EditorWidget.types():
            editor = GafferUI.EditorWidget.create(type, scriptNode)
            layouts.add("testLayout", editor)
            editor2 = layouts.create("testLayout", scriptNode)
            self.failUnless(editor2.scriptNode() is scriptNode)
Beispiel #2
0
	def testSerialisation( self ) :

		application = Gaffer.Application( "Layout tester" )
		scriptNode = Gaffer.ScriptNode()
		application.root()["scripts"].addChild( scriptNode )

		layouts = GafferUI.Layouts.acquire( application )
		for type in GafferUI.Editor.types() :
			editor = GafferUI.Editor.create( type, scriptNode )
			layouts.add( "testLayout", editor )
			editor2 = layouts.create( "testLayout", scriptNode )
			self.failUnless( editor2.scriptNode() is scriptNode )
Beispiel #3
0
    def testLifetime(self):

        application = Gaffer.Application("Layout tester")
        scriptNode = Gaffer.ScriptNode()
        application.root()["scripts"].addChild(scriptNode)

        scriptNode["write"] = Gaffer.ObjectWriter()
        scriptNode.selection().add(scriptNode["write"])

        for type in GafferUI.EditorWidget.types():
            editor = GafferUI.EditorWidget.create(type, scriptNode)
            w = weakref.ref(editor)
            del editor
            self.assertEqual(w(), None)

        self.assertEqual(w(), None)
Beispiel #4
0
    def testAcquireTargetTypes(self):

        a = Gaffer.Application()

        b = GafferUI.Bookmarks.acquire(a)
        b.setDefault("/a/default/path")

        b = GafferUI.Bookmarks.acquire(a.root())
        self.assertEqual(b.getDefault(), "/a/default/path")

        a.root()["scripts"]["one"] = Gaffer.ScriptNode()

        b = GafferUI.Bookmarks.acquire(a.root()["scripts"]["one"])
        self.assertEqual(b.getDefault(), "/a/default/path")

        s = GafferUI.ScriptWindow(a.root()["scripts"]["one"])

        b = GafferUI.Bookmarks.acquire(s)
        self.assertEqual(b.getDefault(), "/a/default/path")

        s.setLayout(GafferUI.CompoundEditor(a.root()["scripts"]["one"]))

        b = GafferUI.Bookmarks.acquire(s.getLayout())
        self.assertEqual(b.getDefault(), "/a/default/path")

        w = GafferUI.Window()
        w.setChild(GafferUI.Button())
        s.addChildWindow(w)

        b = GafferUI.Bookmarks.acquire(w)
        self.assertEqual(b.getDefault(), "/a/default/path")

        b = GafferUI.Bookmarks.acquire(w.getChild())
        self.assertEqual(b.getDefault(), "/a/default/path")

        w2 = GafferUI.Window()  # not attached to a script at all
        w2.setChild(GafferUI.Button())

        b = GafferUI.Bookmarks.acquire((w2.getChild(), a))
        self.assertEqual(b.getDefault(), "/a/default/path")

        g = Gaffer.GraphComponent()  # not attached to a script at all

        b = GafferUI.Bookmarks.acquire((g, w.getChild()))
        self.assertEqual(b.getDefault(), "/a/default/path")
Beispiel #5
0
    def testNoPersistentLayoutsInDefaultConfigs(self):

        app = Gaffer.Application()

        # Load the GUI config, making sure we only use the standard
        # startup files, and not any others from the current environment
        # (the user running these tests may have their own personal configs).
        startupPaths = os.environ["GAFFER_STARTUP_PATHS"]
        try:
            os.environ["GAFFER_STARTUP_PATHS"] = os.path.expandvars(
                "$GAFFER_ROOT/startup")
            app._executeStartupFiles("gui")
        finally:
            os.environ["GAFFER_STARTUP_PATHS"] = startupPaths

        self.assertEqual(os.environ["GAFFER_STARTUP_PATHS"], startupPaths)

        layouts = GafferUI.Layouts.acquire(app)
        self.assertEqual(layouts.names(persistent=True), [])
        self.assertGreater(len(layouts.names()), 0)