Exemplo n.º 1
0
    def testPlayerControlClass(self):
        pc = PlayerControl()
        pc.addQueueItem(5)
        self.assertEqual(pc.getQueue(), [5])

        # Test queue item removal in an unallowed range
        self.assertFalse(
            pc.removeQueueItem(2),
            "You cannot delete an item at index 2 if there is only 1 item in the queue"
        )
        pc.addQueueItem(6)

        # Test queue item removal on a valid index
        self.assertTrue(
            pc.removeQueueItem(1),
            "You should be able to delete a queue item by a valid index")

        # Create an empty queue
        pc.flushQueue()
        self.assertEqual(pc.getQueue(), [],
                         "Queue should be empty after flushQueue")

        pc.addQueueItem(1)
        pc.addQueueItem(2)
        pc.addQueueItem(3)

        # Set the current queue entry pointer to a valid value. True must be returned.
        self.assertTrue(pc.setCurrentQueueEntry(1))

        # Set the current queue entry pointer to an invalid value. False must be returned.
        self.assertFalse(pc.setCurrentQueueEntry(3))
Exemplo n.º 2
0
	def testPlayerControlClass(self):
		pc = PlayerControl()
		pc.addQueueItem(5)
		self.assertEqual(pc.getQueue(), [5])
		
		# Test queue item removal in an unallowed range
		self.assertFalse(pc.removeQueueItem(2) , "You cannot delete an item at index 2 if there is only 1 item in the queue" )
		pc.addQueueItem(6)
		
		# Test queue item removal on a valid index
		self.assertTrue(pc.removeQueueItem(1) , "You should be able to delete a queue item by a valid index" )
		
		# Create an empty queue
		pc.flushQueue()
		self.assertEqual(pc.getQueue(), [], "Queue should be empty after flushQueue")
		
		pc.addQueueItem(1)
		pc.addQueueItem(2)
		pc.addQueueItem(3)
		
		# Set the current queue entry pointer to a valid value. True must be returned.
		self.assertTrue(pc.setCurrentQueueEntry(1))

		# Set the current queue entry pointer to an invalid value. False must be returned.
		self.assertFalse(pc.setCurrentQueueEntry(3))
	def testPlayerControlInitAndQueueOperations(self):
		pc = PlayerControl(False) # Disable audio playback
		
		# Player should be in STOP state
		self.assertEqual( pc.state , PlayerControl.STATE_STOP )
		# Without any queue entries, the currentQueueEntry should be set to None
		self.assertEqual( pc.currentQueueEntry , None )
		
		firstQueueItem = QueueEntry( QueueEntry.TYPE_FILE, "./dummyMP3Test.mp3")
		pc.addQueueItem(firstQueueItem)
		self.assertEqual( pc.getQueue()[0].toString() ,
		 									QueueEntry( QueueEntry.TYPE_FILE, "./dummyMP3Test.mp3").toString() ,"The list is in an unexcepted state")
		self.assertEqual( pc.getQueue()[0] , firstQueueItem )
		# When the first item is stored in the queue, the currentQueueEntry should be updated.
		self.assertEqual( pc.currentQueueEntry , 0 )
		
		# Delete the item from the list
		pc.removeQueueItem(0)
		# The currentQueueEntry should be set to None again
		self.assertEqual( pc.currentQueueEntry , None )
		
		pc.addQueueItem(firstQueueItem)
		secondQueueItem = QueueEntry( QueueEntry.TYPE_FILE, "./dummyMP3Test2.mp3")
		pc.addQueueItem(secondQueueItem)
		
		# currentQueueEntry should point to the beginning of the queue.
		self.assertEqual( pc.currentQueueEntry , 0 )
		pc.next()
		# currentQueueEntry should now point to the next QueueEntry
		self.assertEqual( pc.currentQueueEntry , 1 )
		pc.next()
		# currentQueueEntry should point to the beginning again, when you call
		# next() on the last QueueEntry.
		self.assertEqual( pc.currentQueueEntry , 0 )
		
		# Test PlayerControl.prev()
		pc.prev()
		self.assertEqual( pc.currentQueueEntry , 1 )
		pc.prev()
		self.assertEqual( pc.currentQueueEntry , 0 )