def test_addEvent_None(self):
        cp = ClickPlayer("")
        cp._addEvent(None)
        dq = deque()
        dq.append(None)

        self.assertEqual(dq, cp.eventQueue)
    def test_loadEventList(self):
        lst = []
        lst.append("a")
        lst.append("b")
        lst.append("c")
        cp = ClickPlayer("")
        cp.loadEventList(lst)

        self.assertEqual(len(cp.eventQueue), 3)
        self.assertEqual(cp.eventQueue.pop(), "c")
        self.assertEqual(cp.eventQueue.pop(), "b")
        self.assertEqual(cp.eventQueue.pop(), "a")
    def play(self, keyList, clickList):
        kp = KeyPlayer()
        kp.loadEventList(keyList)

        cp = ClickPlayer()
        cp.loadEventList(clickList)

        try:
            t1 = threading.Thread(target=kp.play)
            t2 = threading.Thread(target=cp.play)
            t1.start()
            t2.start()

            t1.join()
            t2.join()
        #    print "starting thread!"
        #kp.play()
            #thread.start_new_thread( kp.play, ())
        except:
            print "Error: unable to start KeyPlayer thread."
 def _launchClickPlayer(self):
     filename = self._promptForFile()
     clickPlayer = ClickPlayer(filename)
     clickPlayer.play()
 def test_unpackEvent_valid_values_map(self):
     cp = ClickPlayer("")
     event = {"time": 1, "x": 2, "y": 3}
     self.assertEqual((1, 2, 3), cp._unpackEvent(event))
 def test_unpackEvent_invalid_values_map(self):
     cp = ClickPlayer("")
     with self.assertRaises(KeyError) as cm:
         event = {"time": 1, "x": 2}
         cp._unpackEvent(event)
 def test_unpackEvent_None_map(self):
     cp = ClickPlayer("")
     event = {}
     self.assertEqual(None, cp._unpackEvent(event))
 def test_unpackEvent_valid_values_list(self):
     cp = ClickPlayer("")
     self.assertEqual((1, 2, 3), cp._unpackEvent([1, 2, 3]))
     self.assertEqual((1.0, 2.0, 3.0), cp._unpackEvent([1.0, 2.0, 3.0]))
    def test_unpackEvent_invalid_values_list(self):
        cp = ClickPlayer("")
        with self.assertRaises(IndexError) as cm:
            cp._unpackEvent(["test"])
        self.assertEqual("list index out of range", str(cm.exception))

        with self.assertRaises(IndexError) as cm:
            cp._unpackEvent(["test", [1]])
        self.assertEqual("list index out of range", str(cm.exception))

        with self.assertRaises(AssertionError) as cm:
            cp._unpackEvent(["test", 1, 2])
        self.assertEqual("time is non-numeric, 'test'", str(cm.exception))

        with self.assertRaises(AssertionError) as cm:
            cp._unpackEvent([1, "a", 3])
        self.assertEqual("x is non-numeric, 'a'", str(cm.exception))

        with self.assertRaises(AssertionError) as cm:
            cp._unpackEvent([1, 2, "b"])
        self.assertEqual("y is non-numeric, 'b'", str(cm.exception))
 def test_unpackEvent_None(self):
     cp = ClickPlayer("")
     self.assertEqual(None, cp._unpackEvent(None))