def set_mock_app_and_details(self, app_name="software-center", **kwargs): app = Application("", app_name) mock_app = get_mock_app_from_real_app(app) mock_details = mock_app.get_details(None) for attr, value in kwargs.iteritems(): setattr(mock_details, attr, value) self.view.app = mock_app self.view.app_details = mock_details
def test_app_icon_loading(self): # get icon app = Application("", "software-center") mock_app = get_mock_app_from_real_app(app) self.view.app = mock_app mock_details = mock_app.get_details(None) mock_details.cached_icon_file_path = "download-icon-test" mock_details.icon = "favicon.ico" mock_details.icon_url = "http://de.wikipedia.org/favicon.ico" self.view.app_details = mock_details self.view.show_app(mock_app) do_events()
def test_videoplayer(self): # show app with no video app = Application("", "2vcard") self.view.show_app(app) do_events() self.assertFalse(self.view.videoplayer.get_property("visible")) # create app with video and ensure its visible app = Application("", "synaptic") mock = get_mock_app_from_real_app(app) details = mock.get_details(None) # this is a example html - any html5 video will do details.video_url = "http://people.canonical.com/~mvo/totem.html" self.view.show_app(mock) do_events() self.assertTrue(self.view.videoplayer.get_property("visible"))
def test_videoplayer(self): # get the widget win = get_test_window_appdetails() view = win.get_data("view") # show app with no video app = Application("", "2vcard") view.show_app(app) while Gtk.events_pending(): Gtk.main_iteration() self.assertFalse(view.videoplayer.get_property("visible")) # create app with video and ensure its visible app = Application("", "synaptic") mock = get_mock_app_from_real_app(app) details = mock.get_details(None) # this is a example html - any html5 video will do details.video_url = "http://people.canonical.com/~mvo/totem.html" view.show_app(mock) while Gtk.events_pending(): Gtk.main_iteration() self.assertTrue(view.videoplayer.get_property("visible"))
def setUp(self): app = Application("", "pitivi") self.app_mock = get_mock_app_from_real_app(app) self.app_mock.details.pkg_state = PkgStates.UNINSTALLED
def test_page_pkgstates(self): # show app app = Application("", "abiword") self.view.show_app(app) do_events() # check that the action bar is given initial focus in the view self.assertTrue(self.view.pkg_statusbar.button.is_focus()) # create mock app mock_app = get_mock_app_from_real_app(app) self.view.app = mock_app mock_details = mock_app.get_details(None) mock_details.purchase_date = "2011-11-20 17:45:01" mock_details._error_not_found = "error not found" mock_details.price = "1.00" mock_details.pkgname = "abiword" mock_details.error = "error-text" self.view.app_details = mock_details # the states and what labels we expect in the pkgstatusbar # first string is status text, second is button text pkg_states_to_labels = { PkgStates.INSTALLED : ("Purchased on 2011-11-20", "Remove"), PkgStates.UNINSTALLED : ('Free', 'Install'), PkgStates.NEEDS_PURCHASE : ('US$ 1.00', u'Buy\u2026'), PkgStates.PURCHASED_BUT_REPO_MUST_BE_ENABLED : ('Purchased on 2011-11-20', 'Install'), } # this describes if a button is visible or invisible button_invisible = [ PkgStates.ERROR, PkgStates.NOT_FOUND, PkgStates.INSTALLING_PURCHASED, PkgStates.PURCHASED_BUT_NOT_AVAILABLE_FOR_SERIES, PkgStates.UNKNOWN, ] # show a app through the various states and test if the right ui # elements are visible and have the right text for var in vars(PkgStates): state = getattr(PkgStates, var) mock_details.pkg_state = state # reset app to ensure its shown again self.view.app = None # show it self.view.show_app(mock_app) #do_events() # check button label if state in pkg_states_to_labels: label, button_label = pkg_states_to_labels[state] self.assertEqual( self.view.pkg_statusbar.get_label(), label.decode("utf-8")) self.assertEqual( self.view.pkg_statusbar.get_button_label().decode("utf-8"), button_label) # check if button should be there or not if state in button_invisible: self.assertFalse( self.view.pkg_statusbar.button.get_property("visible"), "button visible error for state %s" % state) else: self.assertTrue( self.view.pkg_statusbar.button.get_property("visible"), "button visible error for state %s" % state) # regression test for #955005 if state == PkgStates.NOT_FOUND: self.assertFalse(self.view.review_stats.get_property("visible")) self.assertFalse(self.view.reviews.get_property("visible"))
def test_page_pkgstates(self): # show app app = Application("", "abiword") self.view.show_app(app) do_events() # check that the action bar is given initial focus in the view self.assertTrue(self.view.pkg_statusbar.button.is_focus()) # create mock app mock_app = get_mock_app_from_real_app(app) self.view.app = mock_app mock_details = mock_app.get_details(None) mock_details.purchase_date = "2011-11-20 17:45:01" mock_details._error_not_found = "error not found" mock_details.price = "1.00" mock_details.pkgname = "abiword" mock_details.error = "error-text" self.view.app_details = mock_details # the states and what labels we expect in the pkgstatusbar # first string is status text, second is button text pkg_states_to_labels = { PkgStates.INSTALLED: ("Purchased on 2011-11-20", "Remove"), PkgStates.UNINSTALLED: ('Free', 'Install'), PkgStates.NEEDS_PURCHASE: ('US$ 1.00', u'Buy\u2026'), PkgStates.PURCHASED_BUT_REPO_MUST_BE_ENABLED: ('Purchased on 2011-11-20', 'Install'), } # this describes if a button is visible or invisible button_invisible = [ PkgStates.ERROR, PkgStates.NOT_FOUND, PkgStates.INSTALLING_PURCHASED, PkgStates.PURCHASED_BUT_NOT_AVAILABLE_FOR_SERIES, PkgStates.UNKNOWN, ] # show a app through the various states and test if the right ui # elements are visible and have the right text for var in vars(PkgStates): state = getattr(PkgStates, var) mock_details.pkg_state = state # reset app to ensure its shown again self.view.app = None # show it self.view.show_app(mock_app) #do_events() # check button label if state in pkg_states_to_labels: label, button_label = pkg_states_to_labels[state] self.assertEqual(self.view.pkg_statusbar.get_label(), label.decode("utf-8")) self.assertEqual( self.view.pkg_statusbar.get_button_label().decode("utf-8"), button_label) # check if button should be there or not if state in button_invisible: self.assertFalse( self.view.pkg_statusbar.button.get_property("visible"), "button visible error for state %s" % state) else: self.assertTrue( self.view.pkg_statusbar.button.get_property("visible"), "button visible error for state %s" % state) # regression test for #955005 if state == PkgStates.NOT_FOUND: self.assertFalse( self.view.review_stats.get_property("visible")) self.assertFalse(self.view.reviews.get_property("visible"))