예제 #1
0
    def _create_main_menu(self):
        """Create main menu of the home screen."""
        menu = ScrollMenu(10, 60, 0.045, "menuitem_active")
        menu.set_name("mainmenu")

        menu.add_item(_("Play CD"), "disc")
        menu.add_item(_("Videos"), "videos")
        menu.add_item(_("Music"), "music")
        menu.add_item(_("Photographs"), "photo")

        if self.config.display_weather_in_client:
            menu.add_item(_("Weather"), "weather")

        if self.media_player.has_media():
            menu.add_item(_("Playing now..."), "playing")

        menu.visible_items = 5
        menu.selected_index = 2

        # Menu position
        menu_clip = menu.visible_items * 70
        menu_y = int((self.config.stage_height - menu_clip + 10) / 2)
        menu.set_position(self.get_abs_x(0.75), menu_y)

        return menu
예제 #2
0
class ScrollMenuTest(EntertainerTest):
    """Test for entertainerlib.gui.widgets.scroll_menu"""
    def setUp(self):
        '''Set up the test.'''
        EntertainerTest.setUp(self)

        self.menu = ScrollMenu(10, 60, 0.045, "menuitem_active")
        self.menu.set_name("mainmenu")

        self.menu.add_item(_("Play CD"), "disc")
        self.menu.add_item(_("Videos"), "videos")
        self.menu.add_item(_("Music"), "music")
        self.menu.add_item(_("Photographs"), "photo")
        self.menu.add_item(_("Headlines"), "rss")

    def tearDown(self):
        '''Clean up after the test.'''
        EntertainerTest.tearDown(self)

    def test_create(self):
        '''Test correct ScrollMenu initialization.'''
        self.assertTrue(isinstance(self.menu, ScrollMenu))

    def test_selected_index(self):
        '''Test the use of the selected_index property.'''
        self.menu.selected_index = 2
        self.assertEqual(self.menu.selected_index,
                         self.menu.get_index("music"))

    def test_get_index(self):
        '''Test the use of the get_index method.'''
        self.assertEqual(self.menu.get_index("photo"), 3)

    def test_scroll_up(self):
        '''Test the use of the scroll_up method.'''
        self.menu.selected_index = 2
        self.menu.stop_animation()
        self.menu.scroll_up()
        time.sleep(1)
        self.assertEqual(self.menu.selected_index, 1)

    def test_scroll_down(self):
        '''Test the use of the scroll_up method.'''
        self.menu.selected_index = 2
        self.menu.stop_animation()
        self.menu.scroll_down()
        time.sleep(1)
        self.assertEqual(self.menu.selected_index, 3)
예제 #3
0
class ScrollMenuTest(EntertainerTest):
    """Test for entertainerlib.gui.widgets.scroll_menu"""

    def setUp(self):
        '''Set up the test.'''
        EntertainerTest.setUp(self)

        self.menu = ScrollMenu(10, 60, 0.045, "menuitem_active")
        self.menu.set_name("mainmenu")

        self.menu.add_item(_("Play CD"), "disc")
        self.menu.add_item(_("Videos"), "videos")
        self.menu.add_item(_("Music"), "music")
        self.menu.add_item(_("Photographs"), "photo")
        self.menu.add_item(_("Headlines"), "rss")

    def tearDown(self):
        '''Clean up after the test.'''
        EntertainerTest.tearDown(self)

    def test_create(self):
        '''Test correct ScrollMenu initialization.'''
        self.assertTrue(isinstance(self.menu, ScrollMenu))

    def test_selected_index(self):
        '''Test the use of the selected_index property.'''
        self.menu.selected_index = 2
        self.assertEqual(self.menu.selected_index, self.menu.get_index("music"))

    def test_get_index(self):
        '''Test the use of the get_index method.'''
        self.assertEqual(self.menu.get_index("photo"), 3)

    def test_scroll_up(self):
        '''Test the use of the scroll_up method.'''
        self.menu.selected_index = 2
        self.menu.stop_animation()
        self.menu.scroll_up()
        time.sleep(1)
        self.assertEqual(self.menu.selected_index, 1)

    def test_scroll_down(self):
        '''Test the use of the scroll_up method.'''
        self.menu.selected_index = 2
        self.menu.stop_animation()
        self.menu.scroll_down()
        time.sleep(1)
        self.assertEqual(self.menu.selected_index, 3)