Commits

Anonymous committed 76e1de2

Fixed base.Rect.h property.
Minor test additions.

Comments (0)

Files changed (5)

    :maxdepth: 2
 
    ref/pygame2.rst
+   ref/pygame2_colorpalettes.rst
    ref/examples.rst
-   ref/pygame2_colorpalettes.rst
    ref/pygame2_font.rst
    ref/pygame2_freetype_base.rst
    ref/pygame2_mask.rst
     { "width", _rect_getwidth, _rect_setwidth, DOC_BASE_RECT_WIDTH, NULL },
     { "w", _rect_getwidth, _rect_setwidth, DOC_BASE_RECT_WIDTH, NULL },
     { "height", _rect_getheight, _rect_setheight, DOC_BASE_RECT_HEIGHT, NULL },
-    { "h", _rect_getwidth, _rect_setwidth, DOC_BASE_RECT_WIDTH, NULL },
+    { "h", _rect_getheight, _rect_setheight, DOC_BASE_RECT_HEIGHT, NULL },
     { "size", _rect_getsize, _rect_setsize, DOC_BASE_RECT_SIZE, NULL },
 
     { "left", _rect_getx, _rect_setx, DOC_BASE_RECT_LEFT, NULL },

test/base_frect_test.py

         self.assertEqual( new_height, r.height )
         self.assertEqual( old_width, r.width )
         self.assertEqual( old_topleft, r.topleft )
+    
+    def test_pygame2_base_FRect_h(self):
 
+        r = FRect( 1, 2, 3, 4 )
+        new_height = 10
+        old_topleft = r.topleft
+        old_width = r.width
+        
+        r.h = new_height
+        self.assertEqual( new_height, r.h )
+        self.assertEqual( old_width, r.width )
+        self.assertEqual( old_topleft, r.topleft )
     def test_inflate__larger( self ):
         "The inflate method inflates around the center of the rectangle"
         r = FRect( 2, 4, 6, 8 )
         self.assertEqual( new_width, r.width )
         self.assertEqual( old_height, r.height )
         self.assertEqual( old_topleft, r.topleft )
-
+    
+    def test_pygame2_base_FRect_w(self):
+        r = FRect( 1, 2, 3, 4 )
+        new_width = 10
+        old_topleft = r.topleft
+        old_height = r.height
+        
+        r.w = new_width
+        self.assertEqual( new_width, r.w )
+        self.assertEqual( old_height, r.height )
+        self.assertEqual( old_topleft, r.topleft )
     def todo_test_pygame2_base_FRect_x(self):
 
         # __doc__ (as of 2008-10-17) for pygame2.base.FRect.x:

test/base_rect_test.py

         self.assertEqual( new_height, r.height )
         self.assertEqual( old_width, r.width )
         self.assertEqual( old_topleft, r.topleft )
+    
+    def test_pygame2_base_Rect_h(self):
 
+        r = Rect( 1, 2, 3, 4 )
+        new_height = 10
+        old_topleft = r.topleft
+        old_width = r.width
+        
+        r.h = new_height
+        self.assertEqual( new_height, r.h )
+        self.assertEqual( old_width, r.width )
+        self.assertEqual( old_topleft, r.topleft )
+    
     def todo_test_pygame2_base_Rect_inflate(self):
 
         # __doc__ (as of 2008-10-17) for pygame2.base.Rect.inflate:
         self.assertEqual( new_width, r.width )
         self.assertEqual( old_height, r.height )
         self.assertEqual( old_topleft, r.topleft )
-
+    
+    def test_pygame2_base_Rect_w(self):
+        r = Rect( 1, 2, 3, 4 )
+        new_width = 10
+        old_topleft = r.topleft
+        old_height = r.height
+        
+        r.w = new_width
+        self.assertEqual( new_width, r.w )
+        self.assertEqual( old_height, r.height )
+        self.assertEqual( old_topleft, r.topleft )
     def test_pygame2_base_Rect_x(self):
 
         # __doc__ (as of 2008-10-17) for pygame2.base.Rect.x:

test/sdl_video_surface_test.py

                 self.failUnlessEqual (getat (x, y), c,
                     failmsg % (getat (x, y), c, x, y))
     
-    def todo_test_pygame2_sdl_video_Surface_blit(self):
+    def test_pygame2_sdl_video_Surface_blit(self):
         # This is done in sdl_video_surface_blit_test.py
-        self.fail() 
+        pass
 
-    def todo_test_pygame2_sdl_video_Surface_clip_rect(self):
+    def test_pygame2_sdl_video_Surface_clip_rect(self):
 
         # __doc__ (as of 2009-05-15) for pygame2.sdl.video.Surface.clip_rect:
 
         # Gets or sets the current clipping rectangle for
         # operations on the Surface.
         video.init ()
+        modes = [32, 24, 16, 8]
+        for bpp in modes:
+            sf = video.Surface (10, 10, bpp)
+            sf.fill (Color (255, 255, 255))
+            sf.clip_rect = Rect (3, 3, 3, 3)
+            self.assertEqual (sf.clip_rect, Rect (3, 3, 3, 3))
+            
+            sf.fill (Color (255, 0, 0))
+            self._cmpcolor (sf, Color (255, 255, 255), Rect (0, 0,  3, 10))
+            self._cmpcolor (sf, Color (255, 255, 255), Rect (0, 0, 10,  2))
+            self._cmpcolor (sf, Color (255, 255, 255), Rect (6, 0,  4, 10))
+            self._cmpcolor (sf, Color (255, 255, 255), Rect (0, 6, 10,  4))
+            self._cmpcolor (sf, Color (255, 0, 0), Rect (3, 3, 3, 3))
+            
+            sf.clip_rect = None
+            sf.fill (Color (255, 255, 255))
+            self._cmpcolor (sf, Color (255, 255, 255))
+            
+            sf.clip_rect = Rect (3, 3, 3, 3)
+            sf.fill (Color (255, 0, 0))
+            sf.fill (Color (0, 255, 0), Rect (4, 5, 10, 10))
+            self._cmpcolor (sf, Color (255, 255, 255), Rect (0, 0,  3, 10))
+            self._cmpcolor (sf, Color (255, 255, 255), Rect (0, 0, 10,  2))
+            self._cmpcolor (sf, Color (255, 0, 0), Rect (3, 3, 3, 2))
+            self._cmpcolor (sf, Color (255, 0, 0), Rect (3, 3, 1, 3))
+            self._cmpcolor (sf, Color (0, 255, 0), Rect (4, 5, 2, 1))
+            self._cmpcolor (sf, Color (255, 255, 255), Rect (6, 0,  4, 10))
+            self._cmpcolor (sf, Color (255, 255, 255), Rect (0, 6, 10,  4))
+        
         video.quit ()
-        self.fail() 
 
     def todo_test_pygame2_sdl_video_Surface_convert(self):
 
         video.quit ()
         self.fail() 
 
-    def todo_test_pygame2_sdl_video_Surface_set_at(self):
+    def test_pygame2_sdl_video_Surface_set_at(self):
 
         # __doc__ (as of 2009-05-15) for pygame2.sdl.video.Surface.set_at:
 
         # 
         # Sets the Surface pixel value at the specified point.
         video.init ()
+        modes = [32, 24, 16, 8]
+        for bpp in modes:
+            sf = video.Surface (10, 10, bpp)
+            if bpp == 8:
+                sf.set_palette (CGAPALETTE)
+
+            color = Color (255, 255, 255)
+            sf.fill (color)
+            color = Color (100, 37, 44)
+            cc = sf.format.get_rgba (color)
+            rect = Rect (4, 4, 3, 6)
+            for x in range (rect.x, rect.x + rect.w):
+                for y in range (rect.y, rect.y + rect.h):
+                    sf.set_at (x, y, color)
+                    self.assertEqual (sf.get_at (x, y), cc)
+                    sf.set_at ((x, y), color)
+                    self.assertEqual (sf.get_at (x, y), cc)
+            self._cmpcolor (sf, color, rect)
         video.quit ()
-        self.fail() 
 
     def todo_test_pygame2_sdl_video_Surface_set_colorkey(self):