Пример #1
0
    def test_active_object(self):
        '''Test that arrow key changes active object'''
        lines = 4
        extra_lines = 9
        scroll_win = ScrollWindow(WindowArea(lines,
                                             70,
                                             0,
                                             0,
                                             scrollable_lines=lines +
                                             extra_lines),
                                  color_theme=ColorTheme(force_bw=True))
        scroll_win.active_object = 0
        myobj0 = MockEditField()
        myobj0.area = MockInnerWin()
        myobj0.area.y_loc = 1
        myobj0.active = True
        myobj1 = MockEditField()
        myobj1.area = MockInnerWin()
        myobj1.area.y_loc = 3
        myobj1.active = False
        scroll_win.objects.append(myobj0)
        scroll_win.objects.append(myobj1)

        key = scroll_win.on_arrow_key(curses.KEY_DOWN)
        self.assertEquals(key, None)
        self.assertEquals(scroll_win.active_object, 1)
Пример #2
0
    def test_scroll_down_up_arrow(self):
        '''Test to scroll down and up with arrow key '''
        lines = 4
        extra_lines = 9
        scroll_win = ScrollWindow(WindowArea(lines, 70, 0, 0, 
                                  scrollable_lines=lines + extra_lines),
                                  color_theme=ColorTheme(force_bw=True))
        scroll_win.active_object = None

        self.assertTrue(scroll_win.at_top())
        key = scroll_win.on_arrow_key(curses.KEY_DOWN)
        self.assertEqual(key, None)
        self.assertFalse(scroll_win.at_top())

        key = scroll_win.on_arrow_key(curses.KEY_UP)
        self.assertEqual(key, None)
        self.assertTrue(scroll_win.at_top())

        key = scroll_win.on_arrow_key(curses.KEY_UP)
        self.assertEqual(key, curses.KEY_UP)
        self.assertTrue(scroll_win.at_top())

        scroll_win.scroll(extra_lines-2)
        self.assertFalse(scroll_win.at_bottom())
        scroll_win.on_arrow_key(curses.KEY_DOWN)
        self.assertTrue(scroll_win.at_bottom())
            
        scroll_win.scroll(-(extra_lines-2))
        self.assertFalse(scroll_win.at_top())
        scroll_win.on_arrow_key(curses.KEY_UP)
        self.assertTrue(scroll_win.at_top())
Пример #3
0
    def test_scroll_right_left_arrow(self):
        '''Test to scroll right and left with arrow key '''
        cols = 3
        extra_cols = 5
        scroll_win = ScrollWindow(WindowArea(10, cols, 0, 0, 
                                  scrollable_columns=cols+extra_cols),
                                  color_theme=ColorTheme(force_bw=True))
        scroll_win.active_object = None

        self.assertTrue(scroll_win.at_left())
        key = scroll_win.on_arrow_key(curses.KEY_RIGHT)
        self.assertEqual(key, None)
        self.assertFalse(scroll_win.at_left())

        key = scroll_win.on_arrow_key(curses.KEY_LEFT)
        self.assertEqual(key, None)
        self.assertTrue(scroll_win.at_left())

        key = scroll_win.on_arrow_key(curses.KEY_LEFT)
        self.assertEqual(key, curses.KEY_LEFT)
        self.assertTrue(scroll_win.at_left())

        scroll_win.scroll(columns=extra_cols-2)
        self.assertFalse(scroll_win.at_left())
        self.assertFalse(scroll_win.at_right())
        scroll_win.on_arrow_key(curses.KEY_RIGHT)
        self.assertTrue(scroll_win.at_right())
            
        scroll_win.scroll(columns=-(extra_cols-2))
        self.assertFalse(scroll_win.at_left())
        self.assertFalse(scroll_win.at_right())
        scroll_win.on_arrow_key(curses.KEY_LEFT)
        self.assertTrue(scroll_win.at_left())
Пример #4
0
 def test_act_obj_indexerr_not_edge(self):
     '''Test arrow key, active object, IndexError, not at edge'''
     lines = 4
     extra_lines = 9
     scroll_win = ScrollWindow(WindowArea(lines, 70, 0, 0, 
                               scrollable_lines=lines + extra_lines),
                               color_theme=ColorTheme(force_bw=True))
     scroll_win.active_object = 0
     scroll_win.objects.append(object())
     key = scroll_win.on_arrow_key(curses.KEY_DOWN)
     self.assertEquals(scroll_win.current_line[0], 1)
     self.assertEquals(key, None)