[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29330] branches/soc-2010-leifandersen: 1.

Leif Andersen leif.a.andersen at gmail.com
Tue Jun 8 05:18:11 CEST 2010


Revision: 29330
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29330
Author:   leifandersen
Date:     2010-06-08 05:18:10 +0200 (Tue, 08 Jun 2010)

Log Message:
-----------
1.  Changed the reset_objects() module to be a bit less of a hack, and it doesn't crash, although it currently only removes the objects in the current scene.

2.  removed calling roundf(), so that it will compile properly in MSVC.

3.  Started adding ops testing in order to help in debugging, although currently I'm running into problems about bpy.context.object not exisitng when running a script as blender_exe -b -P pythonscript.py.  (Not just bpy.context.object being none, but not actually existing).

4.  Changed CMake to add the extra test.

5.  Updated the scenehashes, although that may be inacurate.

Modified Paths:
--------------
    branches/soc-2010-leifandersen/release/scripts/modules/tests/meshes.py
    branches/soc-2010-leifandersen/release/scripts/modules/tests/objects.py
    branches/soc-2010-leifandersen/tests/gtest/blenlib/BLI_math_base_test.cpp
    branches/soc-2010-leifandersen/tests/pyunit/data/CMakeLists.txt
    branches/soc-2010-leifandersen/tests/pyunit/data/meshes.py
    branches/soc-2010-leifandersen/tests/pyunit/data/objects.py
    branches/soc-2010-leifandersen/tests/pyunit/data/scenehashes.txt
    branches/soc-2010-leifandersen/tests/pyunit/ops/CMakeLists.txt

Added Paths:
-----------
    branches/soc-2010-leifandersen/tests/pyunit/ops/particle.py

Modified: branches/soc-2010-leifandersen/release/scripts/modules/tests/meshes.py
===================================================================
--- branches/soc-2010-leifandersen/release/scripts/modules/tests/meshes.py	2010-06-08 00:51:57 UTC (rev 29329)
+++ branches/soc-2010-leifandersen/release/scripts/modules/tests/meshes.py	2010-06-08 03:18:10 UTC (rev 29330)
@@ -18,6 +18,8 @@
 
 import bpy
 
+
+#Don't use for now, this could cause blender to crash.
 def reset_meshes():
     while len(bpy.data.meshes) > 0:
         bpy.data.meshes[0].user_clear()

Modified: branches/soc-2010-leifandersen/release/scripts/modules/tests/objects.py
===================================================================
--- branches/soc-2010-leifandersen/release/scripts/modules/tests/objects.py	2010-06-08 00:51:57 UTC (rev 29329)
+++ branches/soc-2010-leifandersen/release/scripts/modules/tests/objects.py	2010-06-08 03:18:10 UTC (rev 29330)
@@ -20,6 +20,5 @@
 import bpy
 
 def reset_objects():
-    while len(bpy.data.objects) > 0:
-        bpy.data.objects[0].user_clear()
-        bpy.data.objects.remove(bpy.data.objects[0])
+    bpy.ops.object.select_all()
+    bpy.ops.object.delete()

Modified: branches/soc-2010-leifandersen/tests/gtest/blenlib/BLI_math_base_test.cpp
===================================================================
--- branches/soc-2010-leifandersen/tests/gtest/blenlib/BLI_math_base_test.cpp	2010-06-08 00:51:57 UTC (rev 29329)
+++ branches/soc-2010-leifandersen/tests/gtest/blenlib/BLI_math_base_test.cpp	2010-06-08 03:18:10 UTC (rev 29330)
@@ -65,7 +65,8 @@
 	EXPECT_EQ(0, maxf(0,-7));
 	
 	// Test floating point arrithmatic
-	EXPECT_EQ(roundf(5.3 * 100)/100, roundf(maxf(0.1, 5.3)*100)/100);
+	// MSVC doesn't have a roundf function...
+	// EXPECT_EQ(roundf(5.3 * 100)/100, roundf(maxf(0.1, 5.3)*100)/100);
 	
 	// Preform a Random test
 	fnumpair nums;

Modified: branches/soc-2010-leifandersen/tests/pyunit/data/CMakeLists.txt
===================================================================
--- branches/soc-2010-leifandersen/tests/pyunit/data/CMakeLists.txt	2010-06-08 00:51:57 UTC (rev 29329)
+++ branches/soc-2010-leifandersen/tests/pyunit/data/CMakeLists.txt	2010-06-08 03:18:10 UTC (rev 29330)
@@ -1,11 +1,11 @@
-ADD_TEST(DataMeshTest ${Blender_BINARY_DIR}/bin/blender -b -P ${Blender_BINARY_DIR}/tests/pyunit/data/meshes.py)
-SET_TESTS_PROPERTIES(DataMeshTest PROPERTIES PASS_REGULAR_EXPRESSION "OK")
+ADD_TEST(Data_Mesh_Test ${Blender_BINARY_DIR}/bin/blender -b -P ${Blender_BINARY_DIR}/tests/pyunit/data/meshes.py)
+SET_TESTS_PROPERTIES(Data_Mesh_Test PROPERTIES PASS_REGULAR_EXPRESSION "OK")
 
-ADD_TEST(DataSceneTest ${Blender_BINARY_DIR}/bin/blender -b -P ${Blender_BINARY_DIR}/tests/pyunit/data/scenes.py)
-SET_TESTS_PROPERTIES(DataSceneTest PROPERTIES PASS_REGULAR_EXPRESSION "OK")
+ADD_TEST(Data_Scene_Test ${Blender_BINARY_DIR}/bin/blender -b -P ${Blender_BINARY_DIR}/tests/pyunit/data/scenes.py)
+SET_TESTS_PROPERTIES(Data_Scene_Test PROPERTIES PASS_REGULAR_EXPRESSION "OK")
 
-ADD_TEST(DataLampTest ${Blender_BINARY_DIR}/bin/blender -b -P ${Blender_BINARY_DIR}/tests/pyunit/data/lamps.py)
-SET_TESTS_PROPERTIES(DataLampTest PROPERTIES PASS_REGULAR_EXPRESSION "OK")
+ADD_TEST(Data_Lamp_Test ${Blender_BINARY_DIR}/bin/blender -b -P ${Blender_BINARY_DIR}/tests/pyunit/data/lamps.py)
+SET_TESTS_PROPERTIES(Data_Lamp_Test PROPERTIES PASS_REGULAR_EXPRESSION "OK")
 
-ADD_TEST(DataObjectTest ${Blender_BINARY_DIR}/bin/blender -b -P ${Blender_BINARY_DIR}/tests/pyunit/data/objects.py)
-SET_TESTS_PROPERTIES(DataObjectTest PROPERTIES PASS_REGULAR_EXPRESSION "OK")
+ADD_TEST(Data_Object_Test ${Blender_BINARY_DIR}/bin/blender -b -P ${Blender_BINARY_DIR}/tests/pyunit/data/objects.py)
+SET_TESTS_PROPERTIES(Data_Object_Test PROPERTIES PASS_REGULAR_EXPRESSION "OK")

Modified: branches/soc-2010-leifandersen/tests/pyunit/data/meshes.py
===================================================================
--- branches/soc-2010-leifandersen/tests/pyunit/data/meshes.py	2010-06-08 00:51:57 UTC (rev 29329)
+++ branches/soc-2010-leifandersen/tests/pyunit/data/meshes.py	2010-06-08 03:18:10 UTC (rev 29330)
@@ -2,31 +2,33 @@
 import random
 
 class TestMeshCreation(unittest.TestCase):
-	def setUp(self):
-		bpy.data.meshes.new("Test")
-		while len(bpy.data.meshes) > 1:
-			bpy.data.meshes[0].user_clear()
-			bpy.data.meshes.remove(bpy.data.meshes[0])
-		if bpy.data.meshes[0].name != "Test":
-			bpy.data.meshes.new("Test")
-			bpy.data.meshes.remove(bpy.data.meshes[1])
+    def setUp(self):
+        bpy.data.meshes.new("Test")
+        while len(bpy.data.meshes) > 1:
+            bpy.data.meshes[0].user_clear()
+            bpy.data.meshes.remove(bpy.data.meshes[0])
+        if bpy.data.meshes[0].name != "Test":
+            bpy.data.meshes.new("Test")
+            bpy.data.meshes.remove(bpy.data.meshes[1])
 
-	def test_mesh_count(self):
-		self.assertEqual(1,len(bpy.data.meshes))
+    def test_mesh_count(self):
+        self.assertEqual(1,len(bpy.data.meshes))
 
-	def test_mesh_creation(self):
-		self.assertEqual(1,len(bpy.data.meshes))
-		bpy.data.meshes.new("Test")
-		self.assertEqual(2,len(bpy.data.meshes))
+    def test_mesh_creation(self):
+        self.assertEqual(1,len(bpy.data.meshes))
+        bpy.data.meshes.new("Test")
+        self.assertEqual(2,len(bpy.data.meshes))
 
-	def test_mesh_count_setup(self):
-		self.assertEqual(1,len(bpy.data.meshes))
+    def test_mesh_count_setup(self):
+        self.assertEqual(1,len(bpy.data.meshes))
 
-	def test_name(self):
-		self.assertEqual("Test", bpy.data.meshes[0].name)
+    def test_name(self):
+        self.assertEqual("Test", bpy.data.meshes[0].name)
 
 def suite():
-	return unittest.TestSuite([unittest.TestLoader().loadTestsFromTestCase(TestMeshCreation)])
+    return unittest.TestSuite([
+unittest.TestLoader().loadTestsFromTestCase(TestMeshCreation),
+])
 
 if __name__ == "__main__":
-	unittest.TextTestRunner(verbosity=2).run(suite())
+    unittest.TextTestRunner(verbosity=2).run(suite())

Modified: branches/soc-2010-leifandersen/tests/pyunit/data/objects.py
===================================================================
--- branches/soc-2010-leifandersen/tests/pyunit/data/objects.py	2010-06-08 00:51:57 UTC (rev 29329)
+++ branches/soc-2010-leifandersen/tests/pyunit/data/objects.py	2010-06-08 03:18:10 UTC (rev 29330)
@@ -1,24 +1,31 @@
-#https://projects.blender.org/tracker/index.php?func=detail&aid=22420&group_id=9&atid=498
-#http://projects.blender.org/tracker/index.php?func=detail&aid=22506&group_id=9&atid=498
-
 import bpy
 import mathutils
-#import tests
+import tests
 import unittest
 import random
 
 class TestObjectProperties(unittest.TestCase):
     def setUp(self):
-        pass
 #       TODO (see next class below)
-#        tests.objects.reset_objects()
+        tests.objects.reset_objects()
 
+    def test_object_matrix(self):
+        object = bpy.data.objects.new("Object", None)
+        bpy.data.scenes[0].objects.link(object)
+        object.scale = (1, 1, 1)
+        object.location = (0, 0, 0)
+        object.rotation_euler = (0, 0, 0)
+        self.assertEquals(mathutils.Matrix((1,0,0,0),(0,1,0,0),(0,0,1,0),(0,0,0,1)), object.matrix)
+        object.scale = (5, 5, 5)
+        bpy.data.scenes[0].update()
+        self.assertEquals(mathutils.Matrix((5,0,0,0),(0,5,0,0),(0,0,5,0),(0,0,0,1)), object.matrix)
+
+
 class TestObjectParent(unittest.TestCase):
     def setUp(self):
-        pass
 #       eventually change it to do the commented line of code, but for now, it causes segfaults, do to some bug in blender
 #       TODO, fix the bug
-#        tests.objects.reset_objects()
+        tests.objects.reset_objects()
 
     def test_object_relationship(self):
         parent = bpy.data.objects.new("Parent", None)
@@ -54,6 +61,7 @@
         parent.location = (0, 0, 0)
         child.rotation_euler = (0, 0, 0)
         parent.rotation_euler = (0, 0, 0)
+        bpy.data.scenes[0].update()
         self.assertEquals(mathutils.Matrix((1,0,0,0),(0,1,0,0),(0,0,1,0),(5,5,5,1)), child.matrix)
 
 def suite():

Modified: branches/soc-2010-leifandersen/tests/pyunit/data/scenehashes.txt
===================================================================
--- branches/soc-2010-leifandersen/tests/pyunit/data/scenehashes.txt	2010-06-08 00:51:57 UTC (rev 29329)
+++ branches/soc-2010-leifandersen/tests/pyunit/data/scenehashes.txt	2010-06-08 03:18:10 UTC (rev 29330)
@@ -1,3 +1,3 @@
 empty_scene = -1504849438355502056
 empty_mesh = 3297148919719683587
-cube_mesh = 6456748997015240834
+cube_mesh = 6456748993794178315

Modified: branches/soc-2010-leifandersen/tests/pyunit/ops/CMakeLists.txt
===================================================================
--- branches/soc-2010-leifandersen/tests/pyunit/ops/CMakeLists.txt	2010-06-08 00:51:57 UTC (rev 29329)
+++ branches/soc-2010-leifandersen/tests/pyunit/ops/CMakeLists.txt	2010-06-08 03:18:10 UTC (rev 29330)
@@ -0,0 +1,2 @@
+ADD_TEST(Ops_Particle_Test ${Blender_BINARY_DIR}/bin/blender -b -P ${Blender_BINARY_DIR}/tests/pyunit/ops/particle.py)
+SET_TESTS_PROPERTIES(Ops_Particle_Test PROPERTIES PASS_REGULAR_EXPRESSION "OK")

Added: branches/soc-2010-leifandersen/tests/pyunit/ops/particle.py
===================================================================
--- branches/soc-2010-leifandersen/tests/pyunit/ops/particle.py	                        (rev 0)
+++ branches/soc-2010-leifandersen/tests/pyunit/ops/particle.py	2010-06-08 03:18:10 UTC (rev 29330)
@@ -0,0 +1,25 @@
+import bpy
+import tests
+import unittest
+
+class TestParticles(unittest.TestCase):
+    def setUp(self):
+        tests.objects.reset_objects()
+        tests.scenes.reset_scenes()
+        tests.build.mesh.cube("Cube")
+        cube = bpy.data.objects['Cube']
+        bpy.data.scenes[0].objects.link(cube)
+        bpy.context.scene.objects.active = cube
+        cube.selected = True
+        bpy.ops.object.particle_system_add()
+
+    def test_particle_generation(self):
+        pass
+
+def suite():
+    return unittest.TestSuite([
+unittest.TestLoader().loadTestsFromTestCase(TestParticles),
+])
+
+if __name__ == "__main__":
+    unittest.TextTestRunner(verbosity=2).run(suite())





More information about the Bf-blender-cvs mailing list