Add unit tests to check the new Prop_NoRecompute value

This commit is contained in:
wmayer
2018-11-08 10:24:14 +01:00
parent 6186a310d7
commit 36b9a1c45c
3 changed files with 47 additions and 10 deletions

View File

@@ -102,6 +102,7 @@ FeatureTest::FeatureTest()
ADD_PROPERTY_TYPE(TypeReadOnly,(4711),group,Prop_ReadOnly ,"An example property which has the type 'ReadOnly'" );
ADD_PROPERTY_TYPE(TypeOutput ,(4711),group,Prop_Output ,"An example property which has the type 'Output'" );
ADD_PROPERTY_TYPE(TypeTransient,(4711),group,Prop_Transient ,"An example property which has the type 'Transient'" );
ADD_PROPERTY_TYPE(TypeNoRecompute,(4711),group,Prop_NoRecompute,"An example property which has the type 'NoRecompute'");
ADD_PROPERTY_TYPE(TypeAll ,(4711),group,(App::PropertyType) (Prop_Output|Prop_ReadOnly |Prop_Hidden ),
"An example property which has the types 'Output', 'ReadOnly' and 'Hidden'");
@@ -123,9 +124,6 @@ FeatureTest::~FeatureTest()
short FeatureTest::mustExecute(void) const
{
if (isTouched())
return 1;
return DocumentObject::mustExecute();
}

View File

@@ -96,7 +96,8 @@ public:
App::PropertyInteger TypeOutput;
App::PropertyInteger TypeAll;
App::PropertyInteger TypeTransient;
App::PropertyInteger TypeNoRecompute;
App::PropertyQuantity QuantityLength;
App::PropertyQuantity QuantityOther;
//App::PropertyQuantity QuantityMass;

View File

@@ -57,6 +57,44 @@ class DocumentBasicCases(unittest.TestCase):
self.Doc.undo()
self.Doc.undo()
def testNoRecompute(self):
L1 = self.Doc.addObject("App::FeatureTest","Label")
self.Doc.recompute()
L1.TypeNoRecompute = 2
execcount = L1.ExecCount
objectcount = self.Doc.recompute()
self.assertEqual(objectcount, 0)
self.assertEqual(L1.ExecCount, execcount)
def testNoRecomputeParent(self):
L1 = self.Doc.addObject("App::FeatureTest","Child")
L2 = self.Doc.addObject("App::FeatureTest","Parent")
L2.Source1 = L1
self.Doc.recompute()
L1.TypeNoRecompute = 2
countChild = L1.ExecCount
countParent = L2.ExecCount
objectcount = self.Doc.recompute()
self.assertEqual(objectcount, 1)
self.assertEqual(L1.ExecCount, countChild)
self.assertEqual(L2.ExecCount, countParent+1)
L1.touch()
countChild = L1.ExecCount
countParent = L2.ExecCount
objectcount = self.Doc.recompute()
self.assertEqual(objectcount, 1)
self.assertEqual(L1.ExecCount, countChild)
self.assertEqual(L2.ExecCount, countParent+1)
L1.enforceRecompute()
countChild = L1.ExecCount
countParent = L2.ExecCount
objectcount = self.Doc.recompute()
self.assertEqual(objectcount, 2)
self.assertEqual(L1.ExecCount, countChild+1)
self.assertEqual(L2.ExecCount, countParent+1)
def testAbortTransaction(self):
self.Doc.openTransaction("Add")
obj=self.Doc.addObject("App::FeatureTest","Label")
@@ -542,23 +580,23 @@ class DocumentRecomputeCases(unittest.TestCase):
self.failUnless((0, 0, 0, 0, 0, 0)==(L1.ExecCount,L2.ExecCount,L3.ExecCount,L4.ExecCount,L5.ExecCount,L6.ExecCount))
self.failUnless(self.Doc.recompute()==4)
self.failUnless((1, 1, 1, 0, 0, 0)==(L1.ExecCount,L2.ExecCount,L3.ExecCount,L4.ExecCount,L5.ExecCount,L6.ExecCount))
L5.touch()
L5.enforceRecompute()
self.failUnless((1, 1, 1, 0, 0, 0)==(L1.ExecCount,L2.ExecCount,L3.ExecCount,L4.ExecCount,L5.ExecCount,L6.ExecCount))
self.failUnless(self.Doc.recompute()==4)
self.failUnless((2, 2, 2, 0, 1, 0)==(L1.ExecCount,L2.ExecCount,L3.ExecCount,L4.ExecCount,L5.ExecCount,L6.ExecCount))
L4.touch()
L4.enforceRecompute()
self.failUnless(self.Doc.recompute()==3)
self.failUnless((3, 3, 2, 1, 1, 0)==(L1.ExecCount,L2.ExecCount,L3.ExecCount,L4.ExecCount,L5.ExecCount,L6.ExecCount))
L5.touch()
L5.enforceRecompute()
self.failUnless(self.Doc.recompute()==4)
self.failUnless((4, 4, 3, 1, 2, 0)==(L1.ExecCount,L2.ExecCount,L3.ExecCount,L4.ExecCount,L5.ExecCount,L6.ExecCount))
L6.touch()
L6.enforceRecompute()
self.failUnless(self.Doc.recompute()==3)
self.failUnless((5, 4, 4, 1, 2, 1)==(L1.ExecCount,L2.ExecCount,L3.ExecCount,L4.ExecCount,L5.ExecCount,L6.ExecCount))
L2.touch()
L2.enforceRecompute()
self.failUnless(self.Doc.recompute()==2)
self.failUnless((6, 5, 4, 1, 2, 1)==(L1.ExecCount,L2.ExecCount,L3.ExecCount,L4.ExecCount,L5.ExecCount,L6.ExecCount))
L1.touch()
L1.enforceRecompute()
self.failUnless(self.Doc.recompute()==1)
self.failUnless((7, 5, 4, 1, 2, 1)==(L1.ExecCount,L2.ExecCount,L3.ExecCount,L4.ExecCount,L5.ExecCount,L6.ExecCount))