Пример #1
0
 def test_scrap_put_image(self):
     if "pygame.image" not in sys.modules:
         return
     sf = pygame.image.load(trunk_relative_path("examples/data/asprite.bmp"))
     string = pygame.image.tostring(sf, "RGBA")
     scrap.put(pygame.SCRAP_BMP, string)
     self.assertEquals(scrap.get(pygame.SCRAP_BMP), string)
Пример #2
0
    def test_put__bmp_image(self):
        """Ensures put can place a BMP image into the clipboard."""
        sf = pygame.image.load(trunk_relative_path("examples/data/asprite.bmp"))
        expected_string = pygame.image.tostring(sf, "RGBA")
        scrap.put(pygame.SCRAP_BMP, expected_string)

        self.assertEqual(scrap.get(pygame.SCRAP_BMP), expected_string)
Пример #3
0
 def test_scrap_put_image(self):
     if 'pygame.image' not in sys.modules:
         return
     sf = pygame.image.load(
         trunk_relative_path("examples/data/asprite.bmp"))
     string = pygame.image.tostring(sf, "RGBA")
     scrap.put(pygame.SCRAP_BMP, string)
     self.assertEquals(scrap.get(pygame.SCRAP_BMP), string)
 def test_height(self):
     pygame.display.init()
     pygame.mixer.quit()
     movie_file = trunk_relative_path('examples/data/blue.mpg')
     movie = gmovie.Movie(movie_file)
     self.assertEqual(movie.height, 200)
     
     del movie
Пример #5
0
    def test_height(self):
        pygame.display.init()
        pygame.mixer.quit()
        movie_file = trunk_relative_path('examples/data/blue.mpg')
        movie = gmovie.Movie(movie_file)
        self.assertEqual(movie.height, 200)

        del movie
Пример #6
0
    def test_width(self):
        pygame.display.init()
        pygame.mixer.quit()
        movie_file = trunk_relative_path("examples/data/blue.mpg")
        movie = gmovie.Movie(movie_file)
        print movie.width
        self.assertEqual(movie.width, 200)

        del movie
Пример #7
0
    def test_init(self):
        movie_file = trunk_relative_path("examples/data/blue.mpg")
        movie = gmovie.Movie(movie_file)
        self.assertEqual(movie, True)

        # screen = pygame.display.get_surface()
        # movie = pygame.gmovie.Movie(filename, screen)
        # self.assertEqual(movie, True)

        del movie
Пример #8
0
    def test_init(self):
        movie_file = trunk_relative_path('examples/data/blue.mpg')
        movie = gmovie.Movie(movie_file)
        self.assertEqual(movie, True)

        #screen = pygame.display.get_surface()
        #movie = pygame.gmovie.Movie(filename, screen)
        #self.assertEqual(movie, True)

        del movie
Пример #9
0
    def test_resize(self):
        movie_file = trunk_relative_path('examples/data/blue.mpg')
        movie = gmovie.Movie(movie_file)

        movie.play(-1)
        movie.resize(movie.width / 2, movie.height / 2)
        #equivalent to stop without a time-argument

        self.assertEqual(movie.height, 100)
        self.assertEqual(movie.width, 100)

        del movie
Пример #10
0
    def test_resize(self):
        movie_file = trunk_relative_path("examples/data/blue.mpg")
        movie = gmovie.Movie(movie_file)

        movie.play(-1)
        movie.resize(movie.width / 2, movie.height / 2)
        # equivalent to stop without a time-argument

        self.assertEqual(movie.height, 100)
        self.assertEqual(movie.width, 100)

        del movie
Пример #11
0
    def test_rewind(self):
        movie_file = trunk_relative_path("examples/data/blue.mpg")
        movie = gmovie.Movie(movie_file)

        movie.play(-1)
        time.sleep(2)
        # equivalent to stop without a time-argument
        movie.rewind()
        self.assertEqual(movie.playing, False)
        self.assertEqual(movie.paused, False)

        del movie
Пример #12
0
    def test_rewind(self):
        movie_file = trunk_relative_path('examples/data/blue.mpg')
        movie = gmovie.Movie(movie_file)

        movie.play(-1)
        time.sleep(2)
        #equivalent to stop without a time-argument
        movie.rewind()
        self.assertEqual(movie.playing, False)
        self.assertEqual(movie.paused, False)

        del movie
Пример #13
0
    def test_stop(self):
        movie_file = trunk_relative_path("examples/data/blue.mpg")
        movie = gmovie.Movie(movie_file)

        self.assertEqual(movie.playing, False)
        movie.play(-1)
        self.assertEqual(movie.playing, True)
        self.assertEqual(movie.paused, False)
        movie.stop()
        self.assertEqual(movie.playing, False)
        self.assertEqual(movie.paused, False)

        del movie
Пример #14
0
    def test_stop(self):
        movie_file = trunk_relative_path('examples/data/blue.mpg')
        movie = gmovie.Movie(movie_file)

        self.assertEqual(movie.playing, False)
        movie.play(-1)
        self.assertEqual(movie.playing, True)
        self.assertEqual(movie.paused, False)
        movie.stop()
        self.assertEqual(movie.playing, False)
        self.assertEqual(movie.paused, False)

        del movie
 def test_stop(self):
     pygame.display.init()
     pygame.mixer.quit()
     movie_file = trunk_relative_path('examples/data/blue.mpg')
     movie = gmovie.Movie(movie_file)
     
     self.assertEqual(movie.playing, False)
     movie.play(-1)
     self.assertEqual(movie.playing, True)
     self.assertEqual(movie.paused, False)
     movie.stop()
     self.assertEqual(movie.playing, False)
     self.assertEqual(movie.paused, False)
     
     del movie
Пример #16
0
    def dont_test_render_frame__on_screen(self):

        pygame.display.init() # Needs to be init or will segfault
        
        movie_file = test_utils.trunk_relative_path('examples/data/blue.mpg')
        movie = pygame.movie.Movie(movie_file)
        movie_dimensions = movie.get_size()

        self.assertEqual(movie_dimensions, (320, 240))

        screen = pygame.display.set_mode(movie_dimensions)
        movie.set_display(screen)
        movie.render_frame(5)
        
        #self.assertEqual(screen.get_at((10,10)), (16, 16, 255, 255))
        #self.assert_(screen.get_at((10,10)) in [(16, 16, 255, 255), (18, 13, 238, 255)])
        self.assert_(within_seq( screen.get_at((10,10)), (16, 16, 255, 255), 20 ))

        pygame.display.quit()
Пример #17
0
    def dont_test_render_frame__on_screen(self):

        pygame.display.init()  # Needs to be init or will segfault

        movie_file = test_utils.trunk_relative_path('examples/data/blue.mpg')
        movie = pygame.movie.Movie(movie_file)
        movie_dimensions = movie.get_size()

        self.assertEqual(movie_dimensions, (320, 240))

        screen = pygame.display.set_mode(movie_dimensions)
        movie.set_display(screen)
        movie.render_frame(5)

        #self.assertEqual(screen.get_at((10,10)), (16, 16, 255, 255))
        #self.assert_(screen.get_at((10,10)) in [(16, 16, 255, 255), (18, 13, 238, 255)])
        self.assert_(
            within_seq(screen.get_at((10, 10)), (16, 16, 255, 255), 20))

        pygame.display.quit()
Пример #18
0
    def test_render_frame__off_screen(self):
        # __doc__ (as of 2008-06-25) for pygame.movie.Movie:
    
          # pygame.movie.Movie(filename): return Movie
          # pygame.movie.Movie(object): return Movie
          # load an mpeg movie file

        # pygame accepts only MPEG program stream containers, 
        # with MPEG1 video and MPEG2 audio. I found
        # that the command 
        
        # mencoder -of mpeg -ovc lavc -oac lavc -lavcopts \
        # acodec=mp2:vcodec=mpeg1video:vbitrate=1000 -o new.mpg old.avi 
        
        # os.environ.update({"SDL_VIDEODRIVER":'windib'})
        
        movie_file = test_utils.trunk_relative_path('examples/data/blue.mpg')
        
        # Need to init display before using it.
        self.assertRaises(Exception, (pygame.movie.Movie, movie_file))

    
        pygame.display.init() # Needs to be init
        
        
        movie = pygame.movie.Movie(movie_file)
        movie_dimensions = movie.get_size()
        screen = pygame.display.set_mode(movie_dimensions)

        self.assertEqual(movie_dimensions, (320, 240))

        off_screen = pygame.Surface(movie_dimensions).convert()

        movie.set_display(off_screen)
        frame_number = movie.render_frame(5)

        #self.assertEqual(off_screen.get_at((10,10)), (16, 16, 255, 255))
        #self.assert_(off_screen.get_at((10,10)) in [(16, 16, 255, 255), (18, 13, 238, 255)])
        self.assert_(within_seq( off_screen.get_at((10,10)), (16, 16, 255, 255), 20 ))

        pygame.display.quit()
Пример #19
0
    def test_render_frame__off_screen(self):
        # __doc__ (as of 2008-06-25) for pygame.movie.Movie:

        # pygame.movie.Movie(filename): return Movie
        # pygame.movie.Movie(object): return Movie
        # load an mpeg movie file

        # pygame accepts only MPEG program stream containers,
        # with MPEG1 video and MPEG2 audio. I found
        # that the command

        # mencoder -of mpeg -ovc lavc -oac lavc -lavcopts \
        # acodec=mp2:vcodec=mpeg1video:vbitrate=1000 -o new.mpg old.avi

        # os.environ.update({"SDL_VIDEODRIVER":'windib'})

        movie_file = test_utils.trunk_relative_path('examples/data/blue.mpg')

        # Need to init display before using it.
        self.assertRaises(Exception, (pygame.movie.Movie, movie_file))

        pygame.display.init()  # Needs to be init

        movie = pygame.movie.Movie(movie_file)
        movie_dimensions = movie.get_size()
        screen = pygame.display.set_mode(movie_dimensions)

        self.assertEqual(movie_dimensions, (320, 240))

        off_screen = pygame.Surface(movie_dimensions).convert()

        movie.set_display(off_screen)
        frame_number = movie.render_frame(5)

        #self.assertEqual(off_screen.get_at((10,10)), (16, 16, 255, 255))
        #self.assert_(off_screen.get_at((10,10)) in [(16, 16, 255, 255), (18, 13, 238, 255)])
        self.assert_(
            within_seq(off_screen.get_at((10, 10)), (16, 16, 255, 255), 20))

        pygame.display.quit()
Пример #20
0
    def test_play_pause(self):
        pygame.display.init()
        pygame.mixer.quit()
        movie_file = trunk_relative_path('examples/data/blue.mpg')
        movie = gmovie.Movie(movie_file)

        self.assertEqual(movie.playing, False)

        movie.play(-1)

        self.assertEqual(movie.playing, True)
        self.assertEqual(movie.paused, False)

        movie.pause()

        self.assertEqual(movie.playing, False)
        self.assertEqual(movie.paused, True)

        movie.pause()

        self.assertEqual(movie.playing, True)
        self.assertEqual(movie.paused, False)

        del movie
Пример #21
0
    def test_height(self):
        movie_file = trunk_relative_path('examples/data/blue.mpg')
        movie = gmovie.Movie(movie_file)
        self.assertEqual(movie.height, 200)

        del movie
Пример #22
0
 def test_width(self):
     movie_file = trunk_relative_path('examples/data/blue.mpg')
     movie = gmovie.Movie(movie_file)
     self.assertEqual(movie.width, 200)
     
     del movie
Пример #23
0
    def test_height(self):
        movie_file = trunk_relative_path("examples/data/blue.mpg")
        movie = gmovie.Movie(movie_file)
        self.assertEqual(movie.height, 200)

        del movie