Beispiel #1
0
 def createWidget(self, block, name="myname", user_params=True):
     t = ParamsByType(block, {})
     t.resize(480, 480)
     t.needBlockList.connect(lambda paths: self.needBlockList(t, paths))
     if block:
         t.setBlockType("type_0")
         t.block.addUserParam("user1", "foo")
         t.block.addUserParam("user2", "bar")
     t.updateWatchers()
     t.show()
     return t
Beispiel #2
0
 def createWidget(self, block, name="myname", user_params=True):
     t = ParamsByType(block, {})
     t.resize(480, 480)
     t.needBlockList.connect(lambda paths: self.needBlockList(t, paths))
     if block:
         t.setBlockType("type_0")
         t.block.addUserParam("user1", "foo")
         t.block.addUserParam("user2", "bar")
     t.updateWatchers()
     t.show()
     return t
Beispiel #3
0
    def testParams(self):
        t = self.createWidget(self.createTypes(), "")
        self.assertEqual(t.combo.count(), 4)
        self.assertEqual(t.table_stack.count(), 1)
        # add a user param
        t.addUserParam("foo")
        row = t.getTable().findTable("Main").findRow("foo")
        self.assertNotEqual(row, -1)

        # make sure the user param still shows up after switching types
        t.setBlockType("type_2")
        self.assertEqual(t.table_stack.count(), 2)
        self.assertEqual(t.getTable().findTable("Main").findRow("foo"), row)
        t.reset()
        # the user param shouldn't be there after a reset
        self.assertEqual(t.getTable().findTable("Main").findRow("foo"), -1)
        self.assertEqual(t.block.getParamInfo("foo"), None)

        # add user params again
        t.addUserParam("foo1")
        t.addUserParam("foo")
        t.setBlockType("type_3")
        self.assertNotEqual(t.getTable().findTable("Main").findRow("foo"), -1)
        self.assertNotEqual(t.getTable().findTable("Main").findRow("foo1"), -1)
        # remove one of the user params
        InputTesting.clickTableButton(t.getTable().findTable("Main"), "foo1",
                                      2)
        self.assertEqual(t.getTable().findTable("Main").findRow("foo1"), -1)
        self.assertNotEqual(t.getTable().findTable("Main").findRow("foo"), -1)

        t.setBlockType("type_2")
        self.assertEqual(t.combo.currentText(), "type_2")
        self.assertEqual(t.getTable().findTable("Main").findRow("foo1"), -1)
        self.assertNotEqual(t.getTable().findTable("Main").findRow("foo"), -1)
        t.save()

        # saved, so one should be gone and one should be there
        self.assertEqual(t.block.blockType(), "type_2")
        self.assertNotEqual(t.block.getParamInfo("foo"), None)
        self.assertEqual(t.block.getParamInfo("foo1"), None)
        self.assertEqual(t.currentType(), "type_2")

        # had a problem where after we created a user param it
        # wasn't showing up in a new widget
        t = ParamsByType(t.block, {})
        self.assertEqual(t.block.blockType(), "type_2")
        self.assertEqual(t.combo.currentText(), "type_2")
        self.assertNotEqual(t.getTable().findTable("Main").findRow("foo"), -1)
Beispiel #4
0
    def testParams(self):
        t = self.createWidget(self.createTypes(), "")
        self.assertEqual(t.combo.count(), 4)
        self.assertEqual(t.table_stack.count(), 1)
        # add a user param
        t.addUserParam("foo")
        row = t.getTable().findTable("Main").findRow("foo")
        self.assertNotEqual(row, -1)

        # make sure the user param still shows up after switching types
        t.setBlockType("type_2")
        self.assertEqual(t.table_stack.count(), 2)
        self.assertEqual(t.getTable().findTable("Main").findRow("foo"), row)
        t.reset()
        # the user param shouldn't be there after a reset
        self.assertEqual(t.getTable().findTable("Main").findRow("foo"), -1)
        self.assertEqual(t.block.getParamInfo("foo"), None)

        # add user params again
        t.addUserParam("foo1")
        t.addUserParam("foo")
        t.setBlockType("type_3")
        self.assertNotEqual(t.getTable().findTable("Main").findRow("foo"), -1)
        self.assertNotEqual(t.getTable().findTable("Main").findRow("foo1"), -1)
        # remove one of the user params
        InputTesting.clickTableButton(t.getTable().findTable("Main"), "foo1", 2)
        self.assertEqual(t.getTable().findTable("Main").findRow("foo1"), -1)
        self.assertNotEqual(t.getTable().findTable("Main").findRow("foo"), -1)

        t.setBlockType("type_2")
        self.assertEqual(t.combo.currentText(), "type_2")
        self.assertEqual(t.getTable().findTable("Main").findRow("foo1"), -1)
        self.assertNotEqual(t.getTable().findTable("Main").findRow("foo"), -1)
        t.save()

        # saved, so one should be gone and one should be there
        self.assertEqual(t.block.blockType(), "type_2")
        self.assertNotEqual(t.block.getParamInfo("foo"), None)
        self.assertEqual(t.block.getParamInfo("foo1"), None)
        self.assertEqual(t.currentType(), "type_2")

        # had a problem where after we created a user param it
        # wasn't showing up in a new widget
        t = ParamsByType(t.block, {})
        self.assertEqual(t.block.blockType(), "type_2")
        self.assertEqual(t.combo.currentText(), "type_2")
        self.assertNotEqual(t.getTable().findTable("Main").findRow("foo"), -1)