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

Leif Andersen leif.a.andersen at gmail.com
Sat Jun 5 00:13:31 CEST 2010


Revision: 29225
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29225
Author:   leifandersen
Date:     2010-06-05 00:13:30 +0200 (Sat, 05 Jun 2010)

Log Message:
-----------
1.  I deleted the hashtest tests, and merged them into the pyunit tests.

2.  Places Andrea's sample to the code base (for future reference, I didn't link it to anything).

3.  Now that there is enough of a framework put together, coding on non-trivial testing has begun.  I started trying to fix bug #22420, but I think I found another bug in the process...still dealing with that right now.  Currently, this test does fail.

4.  Changed the creator's CMakeLists.txt so that the .svn folders don't get copied over.

Modified Paths:
--------------
    branches/soc-2010-leifandersen/source/creator/CMakeLists.txt
    branches/soc-2010-leifandersen/tests/CMakeLists.txt
    branches/soc-2010-leifandersen/tests/pyunit/data/CMakeLists.txt
    branches/soc-2010-leifandersen/tests/pyunit/data/scenes.py

Added Paths:
-----------
    branches/soc-2010-leifandersen/tests/gtest/sampletesttwo.cpp
    branches/soc-2010-leifandersen/tests/pyunit/data/objects.py
    branches/soc-2010-leifandersen/tests/pyunit/data/scenehashes.txt
    branches/soc-2010-leifandersen/tests/pyunit/hashchanger.py

Removed Paths:
-------------
    branches/soc-2010-leifandersen/tests/hashtests/

Modified: branches/soc-2010-leifandersen/source/creator/CMakeLists.txt
===================================================================
--- branches/soc-2010-leifandersen/source/creator/CMakeLists.txt	2010-06-04 20:56:56 UTC (rev 29224)
+++ branches/soc-2010-leifandersen/source/creator/CMakeLists.txt	2010-06-04 22:13:30 UTC (rev 29225)
@@ -181,7 +181,7 @@
 			ADD_CUSTOM_COMMAND(TARGET blender POST_BUILD MAIN_DEPENDANCY blender
 				COMMENT "copying blender tests..."			
 				COMMAND cp -R ${Blender_SOURCE_DIR}/tests/pyunit ${Blender_BINARY_DIR}/tests
-				COMMAND cp -R ${Blender_SOURCE_DIR}/tests/hashtests ${Blender_BINARY_DIR}/tests
+				COMMAND rm -rf ${Blender_BINARY_DIR}/tests/pyunit/.svn ${Blender_BINARY_DIR}/tests/pyunit/*/.svn
 			)	
 		ENDIF(WITH_TESTS)
 		
@@ -258,7 +258,7 @@
 			ADD_CUSTOM_COMMAND(TARGET blender POST_BUILD MAIN_DEPENDANCY blender
 				COMMENT "copying blender tests..."			
 				COMMAND cp -R ${Blender_SOURCE_DIR}/tests/pyunit ${Blender_BINARY_DIR}/tests
-				COMMAND cp -R ${Blender_SOURCE_DIR}/tests/hashtests ${Blender_BINARY_DIR}/tests
+				COMMAND rm -rf ${Blender_BINARY_DIR}/tests/pyunit/.svn ${Blender_BINARY_DIR}/tests/pyunit/*/.svn
 			)	
 		ENDIF(WITH_TESTS)
 
@@ -357,8 +357,7 @@
 		IF(WITH_TESTS)
 			ADD_CUSTOM_COMMAND(TARGET blender POST_BUILD MAIN_DEPENDANCY blender
 				COMMENT "copying blender tests..."			
-				COMMAND copy /Y \"${Blender_SOURCE_DIR}\tests\pyunit\" \"${Blender_BINARY_DIR}\tests\"
-				COMMAND copy /Y \"${Blender_SOURCE_DIR}\tests\hashtests\" \"${Blender_BINARY_DIR}\tests\"
+				COMMAND xcopy /E /Y \"${Blender_SOURCE_DIR}\tests\pyunit\" \"${Blender_BINARY_DIR}\tests\"
 			)	
 		ENDIF(WITH_TESTS)
 

Modified: branches/soc-2010-leifandersen/tests/CMakeLists.txt
===================================================================
--- branches/soc-2010-leifandersen/tests/CMakeLists.txt	2010-06-04 20:56:56 UTC (rev 29224)
+++ branches/soc-2010-leifandersen/tests/CMakeLists.txt	2010-06-04 22:13:30 UTC (rev 29225)
@@ -26,4 +26,3 @@
 ENABLE_TESTING()
 ADD_SUBDIRECTORY(gtest)
 ADD_SUBDIRECTORY(pyunit)
-ADD_SUBDIRECTORY(hashtests)

Added: branches/soc-2010-leifandersen/tests/gtest/sampletesttwo.cpp
===================================================================
--- branches/soc-2010-leifandersen/tests/gtest/sampletesttwo.cpp	                        (rev 0)
+++ branches/soc-2010-leifandersen/tests/gtest/sampletesttwo.cpp	2010-06-04 22:13:30 UTC (rev 29225)
@@ -0,0 +1,53 @@
+#include <gtest/gtest.h>
+ 
+extern "C" {
+        #include "MEM_guardedalloc.h"
+        #include "BLI_math_matrix.h"
+        #include "BLI_uvproject.h"
+        #include "DNA_object_types.h"
+        #include "DNA_camera_types.h"
+}
+ 
+class UvProjectTest : public testing::Test {
+ 
+protected:
+        // set up the camera
+        virtual void SetUp() {
+                struct Camera* cam;
+ 
+                cam_ob = (Object*)MEM_callocN(sizeof(Object), "object");
+                cam_ob->data = cam = (Camera*)MEM_callocN(sizeof(Camera), "camera");
+                cam->lens= 35.0f;
+                cam->clipsta= 0.1f;
+                cam->clipend= 100.0f;
+                cam->drawsize= 0.5f;
+                cam->ortho_scale= 6.0;
+                cam->flag |= CAM_SHOWTITLESAFE;
+                cam->passepartalpha = 0.2f;
+        }
+ 
+        virtual void TearDown() {
+        }
+ 
+        struct Object* cam_ob;
+};
+ 
+// Tests that the Camera projection is correct
+TEST_F(UvProjectTest, ProjectFromCamera) {
+ 
+        struct UvCameraInfo *uci;
+        float rotmat[4][4];
+        float target[2];
+        float source[3] = { 1.0f, 1.0f, 0.0f };
+ 
+        unit_m4(rotmat);
+        unit_m4(cam_ob->obmat);
+       
+        uci= project_camera_info(cam_ob, rotmat, 100.0f, 100.0f);
+        project_from_camera(target, source, uci);
+ 
+        // projected result
+        EXPECT_FLOAT_EQ(1.0f, target[0]);
+        EXPECT_FLOAT_EQ(1.0f, target[1]);
+       
+}

Modified: branches/soc-2010-leifandersen/tests/pyunit/data/CMakeLists.txt
===================================================================
--- branches/soc-2010-leifandersen/tests/pyunit/data/CMakeLists.txt	2010-06-04 20:56:56 UTC (rev 29224)
+++ branches/soc-2010-leifandersen/tests/pyunit/data/CMakeLists.txt	2010-06-04 22:13:30 UTC (rev 29225)
@@ -7,4 +7,5 @@
 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(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")

Added: branches/soc-2010-leifandersen/tests/pyunit/data/objects.py
===================================================================
--- branches/soc-2010-leifandersen/tests/pyunit/data/objects.py	                        (rev 0)
+++ branches/soc-2010-leifandersen/tests/pyunit/data/objects.py	2010-06-04 22:13:30 UTC (rev 29225)
@@ -0,0 +1,65 @@
+#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 unittest
+import random
+
+class TestObjectProperties(unittest.TestCase):
+    def setUp(self):
+        pass
+#       TODO (see next class below)
+#        tests.objects.reset_objects()
+
+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()
+
+    def test_object_relationship(self):
+        parent = bpy.data.objects.new("Parent", None)
+        child_1 = bpy.data.objects.new("Child-1", None)
+        child_2 = bpy.data.objects.new("Child-2", None)
+        self.assertEquals(child_1.parent, None)
+        self.assertEquals(parent.children, ())
+        child_1.parent = child_2.parent = parent
+        self.assertEquals(child_2.parent, parent)
+        self.assertEquals(parent.children, (child_1, child_2)) #XXX, should we be testing the order?
+        child_2.parent = None
+        self.assertEquals(child_2.parent, None)
+        self.assertEquals(parent.children, (child_1,))
+        child_1.parent = None
+        self.assertEquals(child_1.parent, None)
+        self.assertEquals(parent.children, ())
+
+    def test_object_matrix(self):
+        child_mesh = bpy.data.meshes.new("Child")        
+        parent_mesh = bpy.data.meshes.new("Parent")
+        child = bpy.data.objects.new("Child", child_mesh)
+        parent = bpy.data.objects.new("Parent", parent_mesh)
+        bpy.data.scenes[0].objects.link(child)
+        bpy.data.scenes[0].objects.link(parent)
+        child.scale = (3, 3, 3)
+        parent.scale = (.5, .5, .5)
+
+        child.parent = parent
+
+        child.scale = (1, 1, 1)
+        parent.scale = (1, 1, 1)
+        child.location = (5, 5, 5)
+        parent.location = (0, 0, 0)
+        child.rotation_euler = (0, 0, 0)
+        parent.rotation_euler = (0, 0, 0)
+        self.assertEquals(mathutils.Matrix((1,0,0,0),(0,1,0,0),(0,0,1,0),(5,5,5,1)), child.matrix)
+
+def suite():
+    return unittest.TestSuite([
+unittest.TestLoader().loadTestsFromTestCase(TestObjectProperties),
+unittest.TestLoader().loadTestsFromTestCase(TestObjectParent)])
+
+if __name__ == "__main__":
+    unittest.TextTestRunner(verbosity=2).run(suite())

Added: branches/soc-2010-leifandersen/tests/pyunit/data/scenehashes.txt
===================================================================
--- branches/soc-2010-leifandersen/tests/pyunit/data/scenehashes.txt	                        (rev 0)
+++ branches/soc-2010-leifandersen/tests/pyunit/data/scenehashes.txt	2010-06-04 22:13:30 UTC (rev 29225)
@@ -0,0 +1,3 @@
+empty_scene = -1504849438355502056
+empty_mesh = 3297148919719683587
+cube_mesh = 6456748997015240834

Modified: branches/soc-2010-leifandersen/tests/pyunit/data/scenes.py
===================================================================
--- branches/soc-2010-leifandersen/tests/pyunit/data/scenes.py	2010-06-04 20:56:56 UTC (rev 29224)
+++ branches/soc-2010-leifandersen/tests/pyunit/data/scenes.py	2010-06-04 22:13:30 UTC (rev 29225)
@@ -1,3 +1,22 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+
 import unittest
 import random
 import tests
@@ -2,2 +21,12 @@
 
+from tests.scenes import hashcode
+
+# A list of all of the hash codes
+# TODO:  Add an easier way to update?
+path = "scenehashes.txt"
+
+empty_scene = 0
+empty_mesh = 0
+cube_mesh = 0
+
 class TestSceneCreationAndRemoval(unittest.TestCase):
@@ -127,6 +156,26 @@
         except IndexError:
             pass
 
+class TestSceneHashing(unittest.TestCase):
+    def setUp(self):
+        tests.scenes.reset_scenes()
+        tests.meshes.reset_meshes()
+        tests.objects.reset_objects()
+
+    def test_empy_scene(self):
+        self.assertEqual(empty_scene, hashcode(bpy.data.scenes[0]))
+
+    def test_empty_mesh_scene(self):
+        mesh = bpy.data.meshes.new("Test")
+        obj = bpy.data.objects.new("Test", mesh)
+        bpy.data.scenes[0].objects.link(obj)
+        self.assertEquals(empty_mesh, hashcode(bpy.data.scenes[0]))
+
+    def test_cube_mesh_scene(self):
+        tests.build.mesh.cube("Cube")
+        bpy.data.scenes[0].objects.link(bpy.data.objects['Cube'])
+        self.assertEquals(cube_mesh, hashcode(bpy.data.scenes[0]))
+
 def rand_pos_int():
     return random.randint(0, 2000)
 
@@ -142,8 +191,17 @@
         return (count_add, count_delete)
 
 
+
 def suite():

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list