Beispiel #1
0
class ButtonTest(MockTestCase):
    def setUp(self):
        self.lcd = self.mock()
        self.button = Button(self.lcd, 'F1', buttons.XK_F1)

    def testInstantiation(self):
        pass

    def testShouldCallLCDButtonSetBacklightWhenSetBacklightCalled(self):
        self.backlight_cb_called = False

        def backlight_cb(state):
            self.failUnlessEqual(True, state)
            self.backlight_cb_called = True

        self.button.registerBacklightCallback(backlight_cb)
        self.button.setBacklight(True)
        self.failUnlessEqual(True, self.backlight_cb_called)

    def testShouldCallRegisteredCallbackWhenPressed(self):
        self.pressed = False

        def pressed_callback():
            self.pressed = True

        self.button.registerPressedCallback(pressed_callback)
        self.lcd.expects(once()).fire_btn_cb(eq(buttons.XK_F1))
        self.button.pressed()
        self.failUnlessEqual(True, self.pressed)
Beispiel #2
0
class ButtonTest(MockTestCase):
    def setUp(self):
        self.lcd = self.mock()
        self.button = Button(self.lcd, 'F1', buttons.XK_F1)

    def testInstantiation(self):
        pass

    def testShouldCallLCDButtonSetBacklightWhenSetBacklightCalled(self):
        self.backlight_cb_called = False
        def backlight_cb(state):
            self.failUnlessEqual(True, state)
            self.backlight_cb_called = True
        self.button.registerBacklightCallback(backlight_cb)
        self.button.setBacklight(True)
        self.failUnlessEqual(True, self.backlight_cb_called)

    def testShouldCallRegisteredCallbackWhenPressed(self):
        self.pressed = False
        def pressed_callback():
            self.pressed = True
        self.button.registerPressedCallback(pressed_callback)
        self.lcd.expects(once()).fire_btn_cb(eq(buttons.XK_F1))
        self.button.pressed()
        self.failUnlessEqual(True, self.pressed)
Beispiel #3
0
 def setUp(self):
     self.lcd = self.mock()
     self.button = Button(self.lcd, 'F1', buttons.XK_F1)
Beispiel #4
0
 def setUp(self):
     self.lcd = self.mock()
     self.button = Button(self.lcd, 'F1', buttons.XK_F1)
Beispiel #5
0
    def __init__(self):
        self.clear()
        peephole.drivers.driver.Driver.__init__(self)

        self.return_button = Button(self, 'Return', buttons.XK_Return)
        self.addButton(self.return_button)

        self.plus_button = Button(self, 'Plus', buttons.XK_plus)
        self.addButton(self.plus_button)

        self.minus_button = Button(self, 'Minus', buttons.XK_minus)
        self.addButton(self.minus_button)

        self.f1_button = Button(self, 'F1', buttons.XK_F1)
        self.addButton(self.f1_button)

        self.f2_button = Button(self, 'F2', buttons.XK_F2)
        self.addButton(self.f2_button)

        self.f3_button = Button(self, 'F3', buttons.XK_F3)
        self.addButton(self.f3_button)

        self.f4_button = Button(self, 'F4', buttons.XK_F4)
        self.addButton(self.f4_button)

        self.f5_button = Button(self, 'F5', buttons.XK_F5)
        self.addButton(self.f5_button)

        self.up_button = Button(self, 'Up', buttons.XK_Up)
        self.addButton(self.up_button)

        self.down_button = Button(self, 'Down', buttons.XK_Down)
        self.addButton(self.down_button)

        self.left_button = Button(self, 'Left', buttons.XK_Left)
        self.addButton(self.left_button)

        self.right_button = Button(self, 'Right', buttons.XK_Right)
        self.addButton(self.right_button)