def test_accel(self):
     """Tests the method accel"""
     experiment = Experiment(TasksMock())
     experiment.accel(80, 48, 97, time.time())
     experiment.accel(3, 42, 79, time.time())
     self.assertRegexpMatches(experiment.get_output(),
                              '^[0-9]* 80 48 97\n[0-9]* 3 42 79\n$')
 def __init__(self):
     try:
         self.xwiimote = __import__("xwiimote")
     except ImportError:
         print "No xwiimote found"
         exit(1)
     else:
         self.fd_value = None
         self.dev = None
         self.ini_xwii()
         self.queue = Queue.Queue()
         self.poll = poll()
         self.poll.register(self.fd_value, POLLIN)
         self.loop_active = True
         gui = TasksGui()
         experiment = Experiment(gui)
         threading.Thread.__init__(self)
         self.start()
         output_file = None
         while self.loop_active:
             evt = self.queue.get()
             if evt[0] == 1:
                 experiment.press_b_down(evt[1])
             elif evt[0] == 2:
                 experiment.press_b_up(evt[1])
                 if experiment.is_finished():
                     output_file = open(
                         "data/record-" + str(time.time()) + ".txt", "w")
                     output_file.write(experiment.get_output())
                     output_file.close()
                     self.loop_active = False
             elif evt[0] == 3:
                 experiment.accel(evt[1], evt[2], evt[3], evt[4])
             elif evt[0] == 4:
                 self.loop_active = False
         gui.quit()
 def test_press_b_success(self):
     """Tests the method press_b_down"""
     experiment = Experiment(TasksMock())
     experiment.accel(80, 48, 97, time.time())
     experiment.press_b_down(time.time())
     experiment.accel(3, 42, 79, time.time())
     experiment.press_b_up(time.time())
     experiment.accel(56, 21, 43, time.time())
     experiment.press_b_down(time.time())
     experiment.accel(62, 32, 28, time.time())
     experiment.press_b_up(time.time())
     self.assertRegexpMatches(
         experiment.get_output(),
         '^[0-9]* 80 48 97\n[0-9]* START 0\n[0-9]* 3 42 79\n[0-9]* END 0' \
         '\n[0-9]* 56 21 43\n[0-9]* START 1\n[0-9]* 62 32 28\n[0-9]* END ' \
         '1\n$'
     )