Esempio n. 1
0
    def test_add_license_key_backend(self):
        self._finished = False
        # add repo
        deb_line = "deb https://mvo:[email protected]/canonical-isd-hackers/internal-qa/ubuntu oneiric main"
        signing_key_id = "F5410BE0"
        app = Application("Test app1", self.PKGNAME)
        # install only when runnig as root, as we require polkit promtps
        # otherwise
        # FIXME: provide InstallBackendSimulate()
        if os.getuid() == 0:
            backend = get_install_backend()
            backend.ui = Mock()
            backend.connect("transaction-finished",
                            self._on_transaction_finished)
            # simulate repos becomes available for the public 20 s later
            GLib.timeout_add_seconds(20, self._add_pw_to_commercial_repo)
            # run it
            backend.add_repo_add_key_and_install_app(deb_line, signing_key_id,
                                                     app, "icon",
                                                     self.LICENSE_KEY)
            # wait until the pkg is installed
            while not self._finished:
                do_events_with_sleep()

        if os.getuid() == 0:
            self.assertTrue(os.path.exists(self.LICENSE_KEY_PATH))
            self.assertEqual(
                open(self.LICENSE_KEY_PATH).read(), self.LICENSE_KEY)
Esempio n. 2
0
 def test_installedpane(self):
     do_events_with_sleep()
     # safe initial show/hide label for later
     initial_actionbar_label = self.pane.action_bar._label_text
     # do simple search
     self.pane.on_search_terms_changed(None, "foo")
     do_events_with_sleep()
     model = self.pane.app_view.tree_view.get_model()
     # FIXME: len(model) *only* counts the size of the top level
     #        (category) hits. thats still ok, as non-apps will
     #        add the "system" category
     len_only_apps = len(model)
     # set to show nonapps
     self.pane._show_nonapp_pkgs()
     do_events_with_sleep()
     len_with_nonapps = len(model)
     self.assertTrue(len_with_nonapps > len_only_apps)
     # set to hide nonapps again and ensure the size matches the
     # previous one
     self.pane._hide_nonapp_pkgs()
     do_events_with_sleep()
     self.assertEqual(len(model), len_only_apps)
     # clear sarch and ensure we get a expanded size again
     self.pane.on_search_terms_changed(None, "")
     do_events_with_sleep()
     all_apps = len(model)
     self.assertTrue(all_apps > len_only_apps)
     # ensure we have the same show/hide info as initially
     self.assertEqual(initial_actionbar_label,
                      self.pane.action_bar._label_text)
Esempio n. 3
0
 def test_installedpane(self):
     do_events_with_sleep()
     # safe initial show/hide label for later
     initial_actionbar_label = self.pane.action_bar._label_text
     # do simple search
     self.pane.on_search_terms_changed(None, "foo")
     do_events_with_sleep()
     model = self.pane.app_view.tree_view.get_model()
     # FIXME: len(model) *only* counts the size of the top level
     #        (category) hits. thats still ok, as non-apps will
     #        add the "system" category
     len_only_apps = len(model)
     # set to show nonapps
     self.pane._show_nonapp_pkgs()
     do_events_with_sleep()
     len_with_nonapps = len(model)
     self.assertTrue(len_with_nonapps > len_only_apps)
     # set to hide nonapps again and ensure the size matches the
     # previous one
     self.pane._hide_nonapp_pkgs()
     do_events_with_sleep()
     self.assertEqual(len(model), len_only_apps)
     # clear sarch and ensure we get a expanded size again
     self.pane.on_search_terms_changed(None, "")
     do_events_with_sleep()
     all_apps = len(model)
     self.assertTrue(all_apps > len_only_apps)
     # ensure we have the same show/hide info as initially
     self.assertEqual(initial_actionbar_label,
                      self.pane.action_bar._label_text)
Esempio n. 4
0
    def test_add_license_key_backend(self):
        self._finished = False
        # add repo
        deb_line = "deb https://mvo:[email protected]/canonical-isd-hackers/internal-qa/ubuntu oneiric main"
        signing_key_id = "F5410BE0"
        app = Application("Test app1", self.PKGNAME)
        # install only when runnig as root, as we require polkit promtps
        # otherwise
        # FIXME: provide InstallBackendSimulate()
        if os.getuid() == 0:
            backend = get_install_backend()
            backend.ui = Mock()
            backend.connect("transaction-finished",
                            self._on_transaction_finished)
            # simulate repos becomes available for the public 20 s later
            GLib.timeout_add_seconds(20, self._add_pw_to_commercial_repo)
            # run it
            backend.add_repo_add_key_and_install_app(deb_line,
                                                     signing_key_id,
                                                     app,
                                                     "icon",
                                                     self.LICENSE_KEY)
            # wait until the pkg is installed
            while not self._finished:
                do_events_with_sleep()

        if os.getuid() == 0:
            self.assertTrue(os.path.exists(self.LICENSE_KEY_PATH))
            self.assertEqual(open(self.LICENSE_KEY_PATH).read(), self.LICENSE_KEY)
Esempio n. 5
0
 def test_memleak_backend_finished(self):
     backend = get_install_backend()
     backend.emit("transaction-finished", Mock())
     do_events_with_sleep()
     with TraceMemoryUsage("backend.emit('transaction-finished')"):
         for i in range(self.ITERATIONS):
             backend.emit("transaction-finished", Mock())
             do_events_with_sleep()
Esempio n. 6
0
 def test_memleak_backend_finished(self):
     backend = get_install_backend()
     backend.emit("transaction-finished", Mock())
     do_events_with_sleep()
     with TraceMemoryUsage("backend.emit('transaction-finished')"):
         for i in range(self.ITERATIONS):
             backend.emit("transaction-finished", Mock())
             do_events_with_sleep()
Esempio n. 7
0
 def test_memleak_pkginfo_open(self):
     cache = get_pkg_info()
     cache.open()
     do_events_with_sleep()
     with TraceMemoryUsage("PackageInfo.open()"):
         for i in range(self.ITERATIONS):
             cache.open()
             do_events_with_sleep()
Esempio n. 8
0
 def test_memleak_pkginfo_open(self):
     cache = get_pkg_info()
     cache.open()
     do_events_with_sleep()
     with TraceMemoryUsage("PackageInfo.open()"):
         for i in range(self.ITERATIONS):
             cache.open()
             do_events_with_sleep()
Esempio n. 9
0
 def test_reinstall_previous_purchases_lp1011522(self):
     # pretend we have the available_for_me data (much quicker
     # than to do a real s-c-agent query for this)
     self.app.available_for_me_query = xapian.Query()
     self.app.on_menuitem_reinstall_purchases_activate(None)
     do_events_with_sleep()
     self.assertEqual(
         self.app.available_pane.spinner_notebook.get_current_page(),
         SpinnerNotebook.CONTENT_PAGE)
Esempio n. 10
0
 def test_reinstall_previous_purchases_lp1011522(self):
     # pretend we have the available_for_me data (much quicker
     # than to do a real s-c-agent query for this)
     self.app.available_for_me_query = xapian.Query()
     self.app.on_menuitem_reinstall_purchases_activate(None)
     do_events_with_sleep()
     self.assertEqual(
         self.app.available_pane.spinner_notebook.get_current_page(),
         SpinnerNotebook.CONTENT_PAGE)
Esempio n. 11
0
 def test_memleak_catview(self):
     db = get_test_db()
     win = get_test_window_catview(db)
     lobby = win.get_data("lobby")
     # get baseline
     do_events_with_sleep()
     with TraceMemoryUsage("LobbyView.on_db_reopen()"):
         for i in range(self.ITERATIONS):
             lobby._on_db_reopen(db)
             do_events_with_sleep()
Esempio n. 12
0
 def test_regression_lp1041004(self):
     from softwarecenter.ui.gtk3.views import appdetailsview
     db = get_test_db()
     cache = get_test_pkg_info()
     icons = get_test_gtk3_icon_cache()
     distro = get_distro()
     view = appdetailsview.AppDetailsView(db, distro, icons, cache)
     cache.emit("query-total-size-on-install-done", "apt", 10, 10)
     do_events_with_sleep()
     self.assertEqual(view.totalsize_info.value_label.get_text(), "")
Esempio n. 13
0
 def test_regression_lp1041004(self):
     from softwarecenter.ui.gtk3.views import appdetailsview
     db = get_test_db()
     cache = get_test_pkg_info()
     icons = get_test_gtk3_icon_cache()
     distro = get_distro()
     view = appdetailsview.AppDetailsView(db, distro, icons, cache)
     cache.emit("query-total-size-on-install-done", "apt", 10, 10)
     do_events_with_sleep()
     self.assertEqual(view.totalsize_info.value_label.get_text(), "")
Esempio n. 14
0
 def test_memleak_catview(self):
     db = get_test_db()
     win = get_test_window_catview(db)
     lobby = win.get_data("lobby")
     # get baseline
     do_events_with_sleep()
     with TraceMemoryUsage("LobbyView.on_db_reopen()"):
         for i in range(self.ITERATIONS):
             lobby._on_db_reopen(db)
             do_events_with_sleep()
Esempio n. 15
0
 def test_screenshot_thumbnail(self):
     win = get_test_screenshot_thumbnail_window()
     self.addCleanup(win.destroy)
     t = win.get_data("screenshot_thumbnail_widget")
     b = win.get_data("screenshot_thumbnail_cycle_test_button")
     for i in range(5):
         b.clicked()
         do_events_with_sleep(iterations=5)
         # ensure that either the big screeshot is visible or the loading
         # spinner
         self.assertTrue(t.main_screenshot.get_property("visible") or
                         t.spinner.get_property("visible"))
Esempio n. 16
0
 def test_recommended_for_you_spinner_display(self, 
                                          mock_network_state_is_connected):
     # pretend we have network even if we don't
     mock_network_state_is_connected.return_value = True
     # click the opt-in button to initiate the process,
     # this will show the spinner
     self.rec_panel.opt_in_button.clicked()
     do_events_with_sleep()
     self.assertEqual(self.rec_panel.spinner_notebook.get_current_page(),
                      SpinnerNotebook.SPINNER_PAGE)
     self.assertTrue(
         self.rec_panel.recommended_for_you_content.get_property("visible"))
Esempio n. 17
0
 def test_spinner_emits_signals(self):
     win = get_test_window_purchaseview()
     self.addCleanup(win.destroy)
     do_events_with_sleep()
     # get the view
     view = win.get_data("view")
     # ensure "purchase-needs-spinner" signals are send
     signal_mock = Mock()
     view.connect("purchase-needs-spinner", signal_mock)
     view.wk.webkit.load_uri("http://www.ubuntu.com/")
     do_events_with_sleep()
     self.assertTrue(signal_mock.called)
Esempio n. 18
0
 def _simulate_install_events(self,
                              app,
                              result_event="transaction-finished"):
     # pretend we started an install
     self.available_pane.backend.emit("transaction-started", app.pkgname,
                                      app.appname, "testid101",
                                      TransactionTypes.INSTALL)
     do_events_with_sleep()
     # send the signal to complete the install
     mock_result = Mock()
     mock_result.pkgname = app.pkgname
     self.available_pane.backend.emit(result_event, mock_result)
     do_events_with_sleep()
Esempio n. 19
0
 def _simulate_install_events(self, app):
     # pretend we started an install
     self.rec_panel.backend.emit("transaction-started",
                                 app.pkgname, app.appname,
                                 "testid101",
                                 TransactionTypes.INSTALL)
     do_events_with_sleep()
     # send the signal to complete the install
     mock_result = Mock()
     mock_result.pkgname = app.pkgname
     self.rec_panel.backend.emit("transaction-finished",
                                 mock_result)
     do_events()
Esempio n. 20
0
 def test_memleak_subcatview(self):
     db = get_test_db()
     win = get_test_window_catview(db)
     lobby =  win.get_data("lobby")
     cat = [cat for cat in lobby.categories if cat.name == "Internet"][0]
     subcat = win.get_data("subcat")
     # get baseline
     subcat.set_subcategory(cat)
     do_events_with_sleep()
     with TraceMemoryUsage("SubcategoryView.set_subcategory()"):
         for i in range(self.ITERATIONS):
             subcat._set_subcategory(cat, 0)
             do_events_with_sleep()
Esempio n. 21
0
 def test_screenshot_thumbnail(self):
     win = get_test_screenshot_thumbnail_window()
     self.addCleanup(win.destroy)
     t = win.get_data("screenshot_thumbnail_widget")
     b = win.get_data("screenshot_thumbnail_cycle_test_button")
     for i in range(5):
         b.clicked()
         do_events_with_sleep(iterations=5)
         # ensure that either the big screeshot is visible or the loading
         # spinner
         self.assertTrue(
             t.main_screenshot.get_property("visible")
             or t.spinner.get_property("visible"))
Esempio n. 22
0
 def test_memleak_subcatview(self):
     db = get_test_db()
     win = get_test_window_catview(db)
     lobby = win.get_data("lobby")
     cat = [cat for cat in lobby.categories if cat.name == "Internet"][0]
     subcat = win.get_data("subcat")
     # get baseline
     subcat.set_subcategory(cat)
     do_events_with_sleep()
     with TraceMemoryUsage("SubcategoryView.set_subcategory()"):
         for i in range(self.ITERATIONS):
             subcat._set_subcategory(cat, 0)
             do_events_with_sleep()
Esempio n. 23
0
 def test_memleak_app(self):
     options = Mock()
     options.display_navlog = False
     args = []
     # ensure the cache is fully ready before taking the baseline
     cache = get_pkg_info()
     cache.open(blocking=True)
     app = SoftwareCenterAppGtk3(options, args)
     app.window_main.show_all()
     do_events_with_sleep()
     with TraceMemoryUsage("app._on_transaction_finished"):
         for i in range(self.ITERATIONS):
             app._on_transaction_finished(None, None)
             cache.open()
             do_events_with_sleep()
Esempio n. 24
0
 def test_memleak_appdetails(self):
     cache = get_pkg_info()
     cache.open(blocking=True)
     win = get_test_window_appdetails()
     view = win.get_data("view")
     app = Application("", "gedit")
     # get baseline
     view.show_app(app)
     do_events_with_sleep()
     with TraceMemoryUsage("AppdetailsView.show_app()"):
         for i in range(self.ITERATIONS):
             view.show_app(app, force=True)
             # this causes a huge memleak of ~35mb/run
             cache.open()
             do_events_with_sleep()
Esempio n. 25
0
 def test_memleak_app_recommendations(self):
     cache = get_pkg_info()
     cache.open(blocking=True)
     win = get_test_window_appdetails()
     view = win.get_data("view")
     app = Application("", "gedit")
     # get baseline
     view.show_app(app)
     do_events_with_sleep()
     with TraceMemoryUsage("AppdetailsView.show_app()"):
         with TraceActiveObjectTypes("view.recommended_for_app.set_pkgname"):
             for i in range(self.ITERATIONS):
                 view.recommended_for_app_panel.set_pkgname("gedit")
                 cache.open()
                 do_events_with_sleep()
Esempio n. 26
0
 def test_memleak_appdetails(self):
     cache = get_pkg_info()
     cache.open(blocking=True)
     win = get_test_window_appdetails()
     view = win.get_data("view")
     app = Application("", "gedit")
     # get baseline
     view.show_app(app)
     do_events_with_sleep()
     with TraceMemoryUsage("AppdetailsView.show_app()"):
         for i in range(self.ITERATIONS):
             view.show_app(app, force=True)
             # this causes a huge memleak of ~35mb/run
             cache.open()
             do_events_with_sleep()
Esempio n. 27
0
 def test_memleak_app(self):
     options = Mock()
     options.display_navlog = False
     args = []
     # ensure the cache is fully ready before taking the baseline
     cache = get_pkg_info()
     cache.open(blocking=True)
     app = SoftwareCenterAppGtk3(options, args)
     app.window_main.show_all()
     do_events_with_sleep()
     with TraceMemoryUsage("app._on_transaction_finished"):
         for i in range(self.ITERATIONS):
             app._on_transaction_finished(None, None)
             cache.open()
             do_events_with_sleep()
Esempio n. 28
0
 def test_memleak_app_recommendations(self):
     cache = get_pkg_info()
     cache.open(blocking=True)
     win = get_test_window_appdetails()
     view = win.get_data("view")
     app = Application("", "gedit")
     # get baseline
     view.show_app(app)
     do_events_with_sleep()
     with TraceMemoryUsage("AppdetailsView.show_app()"):
         with TraceActiveObjectTypes(
                 "view.recommended_for_app.set_pkgname"):
             for i in range(self.ITERATIONS):
                 view.recommended_for_app_panel.set_pkgname("gedit")
                 cache.open()
                 do_events_with_sleep()
Esempio n. 29
0
 def test_recommended_for_you_display_recommendations(self):
     self._opt_in_and_populate_recommended_for_you_panel()
     # we fake the callback from the agent here
     for_you = self.rec_panel.recommended_for_you_cat
     for_you._recommend_me_result(None,
         make_recommender_agent_recommend_me_dict())
     self.assertNotEqual(for_you.get_documents(self.db), [])
     self.assertEqual(self.rec_panel.spinner_notebook.get_current_page(),
                      SpinnerNotebook.CONTENT_PAGE)
     do_events()
     # test clicking recommended_for_you More button
     self.lobby.connect("category-selected", self._on_category_selected)
     self.rec_panel.more.clicked()
     # this is delayed for some reason so we need to sleep here
     do_events_with_sleep()
     self.assertNotEqual(self._cat, None)
     self.assertEqual(self._cat.name, "Recommended For You")
Esempio n. 30
0
    def test_custom_lists(self):
        win = get_test_window_availablepane()
        self.addCleanup(win.destroy)
        pane = win.get_data("pane")
        do_events_with_sleep()
        pane.on_search_terms_changed(None, "ark,artha,software-center")
        do_events_with_sleep()
        model = pane.app_view.tree_view.get_model()

        # custom list should return three items
        self.assertTrue(len(model) == 3)

        # check package names, ordering is default "by relevance"
        self.assertPkgInListAtIndex(0, model, "ark")
        self.assertPkgInListAtIndex(1, model, "artha")
        self.assertPkgInListAtIndex(2, model, "software-center")

        # check that the status bar offers to install the packages
        install_button = pane.action_bar.get_button(ActionButtons.INSTALL)
        self.assertNotEqual(install_button, None)
Esempio n. 31
0
    def test_custom_lists(self):
        win = get_test_window_availablepane()
        self.addCleanup(win.destroy)
        pane = win.get_data("pane")
        do_events_with_sleep()
        pane.on_search_terms_changed(None, "ark,artha,software-center")
        do_events_with_sleep()
        model = pane.app_view.tree_view.get_model()

        # custom list should return three items
        self.assertTrue(len(model) == 3)

        # check package names, ordering is default "by relevance"
        self.assertPkgInListAtIndex(0, model, "ark")
        self.assertPkgInListAtIndex(1, model, "artha")
        self.assertPkgInListAtIndex(2, model, "software-center")

        # check that the status bar offers to install the packages
        install_button = pane.action_bar.get_button(ActionButtons.INSTALL)
        self.assertNotEqual(install_button, None)
Esempio n. 32
0
 def test_reinstall_previous_purchase_display(self, mock_find_token):
     mock_find_token.return_value = {'not': 'important'}
     mock_options = get_mock_options()
     app = SoftwareCenterAppGtk3(mock_options)
     self.addCleanup(app.destroy)
     # real app opens cache async
     app.cache.open()
     # .. and now pretend we clicked on the menu item
     app.window_main.show_all()
     app.available_pane.init_view()
     do_events_with_sleep()
     app.on_menuitem_reinstall_purchases_activate(None)
     # it can take a bit until the sso client is ready
     for i in range(10):
         if (app.available_pane.get_current_page() ==
                 AvailablePane.Pages.LIST):
             break
         do_events_with_sleep()
     self.assertEqual(app.available_pane.get_current_page(),
                      AvailablePane.Pages.LIST)
Esempio n. 33
0
    def test_purchase_view_log_cleaner(self):
        win = get_test_window_purchaseview()
        self.addCleanup(win.destroy)
        do_events_with_sleep()
        # get the view
        view = win.get_data("view")
        # install the mock
        purchaseview.LOG = mock = Mock()
        # run a "harmless" log message and ensure its logged normally
        view.wk.webkit.execute_script('console.log("foo")')
        self.assertTrue("foo" in mock.debug.call_args[0][0])
        mock.reset_mock()

        # run a message that contains token info
        s = ('http://sca.razorgirl.info/subscriptions/19077/checkout_complete/'
             ' @10: {"token_key": "hiddenXXXXXXXXXX", "consumer_secret": '
             '"hiddenXXXXXXXXXXXX", "api_version": 2.0, "subscription_id": '
             '19077, "consumer_key": "rKhNPBw", "token_secret": '
             '"hiddenXXXXXXXXXXXXXXX"}')
        view.wk.webkit.execute_script("console.log('%s')" % s)
        self.assertTrue("skipping" in mock.debug.call_args[0][0])
        self.assertFalse("consumer_secret" in mock.debug.call_args[0][0])
        mock.reset_mock()
Esempio n. 34
0
    def test_recommended_for_you_display_recommendations_opted_in(self):
        self._opt_in_and_populate_recommended_for_you_panel()

        # we want to work in the "subcat" view
        self.notebook.next_page()

        rec_cat_panel = self.subcat_view.recommended_for_you_in_cat
        rec_cat_panel._update_recommended_for_you_content()
        do_events()
        # we fake the callback from the agent here
        rec_cat_panel.recommended_for_you_cat._recommend_me_result(
                                None,
                                make_recommender_agent_recommend_me_dict())
        result_docs = rec_cat_panel.recommended_for_you_cat.get_documents(
            self.db)
        self.assertNotEqual(result_docs, [])
        # check that we are getting the correct number of results,
        # corresponding to the following Internet items:
        #   Mangler, Midori, Midori Private Browsing, Psi
        self.assertTrue(len(result_docs) == 4)
        self.assertEqual(rec_cat_panel.spinner_notebook.get_current_page(),
                         SpinnerNotebook.CONTENT_PAGE)
        # check that the tiles themselves are visible
        self.assertTrue(rec_cat_panel.recommended_for_you_content.get_property(
            "visible"))
        self.assertTrue(rec_cat_panel.recommended_for_you_content.get_children(
            )[0].title.get_property("visible"))

        # test clicking recommended_for_you More button
        self.subcat_view.connect(
            "category-selected", self._on_category_selected)
        rec_cat_panel.more.clicked()
        # this is delayed for some reason so we need to sleep here
        do_events_with_sleep()
        self.assertNotEqual(self._cat, None)
        self.assertEqual(self._cat.name, "Recommended For You in Internet")
Esempio n. 35
0
 def test_installedpane(self):
     win = get_test_window_installedpane()
     self.addCleanup(win.destroy)
     installedpane = win.get_data("pane")
     do_events_with_sleep()
     installedpane.on_search_terms_changed(None, "the")
     do_events_with_sleep()
     model = installedpane.app_view.tree_view.get_model()
     len1 = len(model)
     installedpane.on_search_terms_changed(None, "nosuchsearchtermforsure")
     do_events_with_sleep()
     len2 = len(model)
     self.assertTrue(len2 < len1)
Esempio n. 36
0
 def test_availablepane(self):
     win = get_test_window_availablepane()
     self.addCleanup(win.destroy)
     pane = win.get_data("pane")
     do_events_with_sleep()
     pane.on_search_terms_changed(None, "the")
     do_events_with_sleep()
     sortmode = pane.app_view.sort_methods_combobox.get_active_text()
     self.assertEqual(sortmode, "By Relevance")
     model = pane.app_view.tree_view.get_model()
     len1 = len(model)
     pane.on_search_terms_changed(None, "nosuchsearchtermforsure")
     do_events_with_sleep()
     len2 = len(model)
     self.assertTrue(len2 < len1)
Esempio n. 37
0
    def test_fake_aptd(self):
        from softwarecenter.backend.installbackend import get_install_backend

        backend = get_install_backend()
        backend.install(Application("2vcard", ""), iconname="")
        do_events_with_sleep()
Esempio n. 38
0
 def test_fake_aptd(self):
     from softwarecenter.backend.installbackend import get_install_backend
     backend = get_install_backend()
     backend.install(Application("2vcard", ""), iconname="")
     do_events_with_sleep()
Esempio n. 39
0
 def _click_first_tile_in_panel(self, framed_header_box):
     first_tile = (framed_header_box.content_box.
                     get_children()[0].get_children()[0])
     first_tile.clicked()
     do_events_with_sleep()