Commits

Marcus von Appen  committed 63e43d3

- add simple unit tests for sdl2.ext.Renderer.draw_line() and sdl2.ext.Renderer.draw_point()

  • Participants
  • Parent commits de611e2

Comments (0)

Files changed (3)

File doc/integration.rst

 that you ship a SDL2 library with your project.
 
 If the user has a SDL2 library installed on the target system, the
-:mod:`ctypes` hooks of :mod:`sdl2` try to find it in the OS-specific
-standard locations via :func:`ctypes.util.find_library`. If you are
-going to ship your own SDL2 library with the project or can not rely
-on the standard mechanism of :mod:`ctypes`, it is also possible to set
-the environment variable :envvar:`PYSDL2_DLL_PATH`, which shall point to the
-directory of the SDL2 library.
+:mod:`ctypes` hooks of :mod:`sdl2` try to find it in the OS-specific standard
+locations via :func:`ctypes.util.find_library`. If you are going to ship your
+own SDL2 library with the project or can not rely on the standard mechanism of
+:mod:`ctypes`, it is also possible to set the environment variable
+:envvar:`PYSDL2_DLL_PATH`, which shall point to the directory of the SDL2
+library or consist of a list of directories, in which the SDL2 libraries can
+be found.
 
 .. note::
 
   # Unix/Posix-alike environments - C shells
   setenv PYSDL2_DLL_PATH /path/to/fancy_project/third_party
 
+  # Define multiple paths to search for the libraries - Win32
+  set PYSDL2_DLL_PATH=C:\first\path;C:\second\path
+
 You also can set the environment variable within Python using
 :data:`os.environ`. ::
 

File sdl2/test/sdl2ext_algorithms_test.py

     def test_clipline(self):
         pass
 
+    def test_point_on_line(self):
+        pass
+
 
 if __name__ == '__main__':
     sys.exit(unittest.main())

File sdl2/test/sdl2ext_sprite_test.py

                 else:
                     self.assertTrue(view[y][x] in c2,
                                     msg % (x, y, view[y][x], c2))
-            
+
     def test_SpriteFactory(self):
         factory = sdl2ext.SpriteFactory(sdl2ext.SOFTWARE)
         self.assertIsInstance(factory, sdl2ext.SpriteFactory)
 
     def test_Renderer(self):
         sf = SDL_CreateRGBSurface(0, 10, 10, 32, 0, 0, 0, 0).contents
-        
+
         renderer = sdl2ext.Renderer(sf)
         self.assertEqual(renderer.rendertarget, sf)
         self.assertIsInstance(renderer.renderer.contents, SDL_Renderer)
         del renderer
-        
+
         sprite = sdl2ext.SoftwareSprite(sf, True)
         renderer = sdl2ext.Renderer(sprite)
         self.assertEqual(renderer.rendertarget, sprite.surface)
         self.assertEqual(renderer.rendertarget, sf)
         self.assertIsInstance(renderer.renderer.contents, SDL_Renderer)
         del renderer
-        
+
         window = sdl2ext.Window("Test", size=(1, 1))
         renderer = sdl2ext.Renderer(window)
         self.assertEqual(renderer.rendertarget, window.window)
         self.assertIsInstance(renderer.renderer.contents, SDL_Renderer)
         del renderer
-        
+
         sdlwindow = window.window
         renderer = sdl2ext.Renderer(sdlwindow)
         self.assertEqual(renderer.rendertarget, sdlwindow)
         self.assertIsInstance(renderer.renderer.contents, SDL_Renderer)
         del renderer
         del window
-        
+
         self.assertRaises(TypeError, sdl2ext.Renderer, None)
         self.assertRaises(TypeError, sdl2ext.Renderer, 1234)
         self.assertRaises(TypeError, sdl2ext.Renderer, "test")
         self.check_pixels(view, 128, 128, sp, 0xFF0000, (0x0,))
         del view
 
-    @unittest.skip("not implemented")
+    @unittest.skipIf(_ISPYPY, "PyPy's ctypes can't do byref(value, offset)")
     def test_Renderer_draw_line(self):
-        pass
+        surface = SDL_CreateRGBSurface(0, 128, 128, 32, 0, 0, 0, 0).contents
+        sdl2ext.fill(surface, 0x0)
+        renderer = sdl2ext.Renderer(surface)
+        renderer.draw_line((20, 10, 20, 86), 0x0000FF)
+        view = sdl2ext.PixelView(surface)
+        self.check_lines(view, 128, 128,
+                         [((20, 10), (20, 86))], 0x0000FF, (0x0,))
+        del view
 
     @unittest.skip("not implemented")
     def test_Renderer_draw_point(self):
         surface = SDL_CreateRGBSurface(0, 128, 128, 32, 0, 0, 0, 0).contents
         sdl2ext.fill(surface, 0x0)
         renderer = sdl2ext.Renderer(surface)
-        factory = sdl2ext.SpriteFactory(sdl2ext.TEXTURE, renderer=renderer)
-        w, h = 32, 32
-        sp = factory.from_color(0xFF0000, (w, h))
-        sp.x, sp.y = 40, 50
-        renderer.draw_rect((sp.x, sp.y, w, h), 0x0000FF)
+        renderer.draw_rect((40, 50, 32, 32), 0x0000FF)
         view = sdl2ext.PixelView(surface)
         self.check_lines(view, 128, 128,
             [((40, 50), (71, 50)),