Пример #1
0
 def test_scroll_past_top(self):
     '''Test to scroll past top, should end up at top '''
     lines = 70
     extra_lines = 5
     scroll_win = ScrollWindow(WindowArea(lines, 70, 0, 0, 
                               scrollable_lines=lines + extra_lines),
                               color_theme=ColorTheme(force_bw=True))
     self.assertTrue(scroll_win.at_top())
     scroll_win.scroll(lines=-3)
     self.assertTrue(scroll_win.at_top())
Пример #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())