Merge lp:~nataliabidart/software-center/the-organizer into lp:software-center

Proposed by Natalia Bidart
Status: Merged
Merged at revision: 3030
Proposed branch: lp:~nataliabidart/software-center/the-organizer
Merge into: lp:software-center
Diff against target: 8189 lines (+2221/-2700)
102 files modified
gen-coverage-report.sh (+13/-7)
run-tests.sh (+70/-29)
softwarecenter/log.py (+12/-10)
softwarecenter/ui/gtk3/dialogs/dependency_dialogs.py (+1/-36)
softwarecenter/ui/gtk3/panes/availablepane.py (+0/-47)
softwarecenter/ui/gtk3/panes/globalpane.py (+0/-31)
softwarecenter/ui/gtk3/panes/historypane.py (+2/-34)
softwarecenter/ui/gtk3/panes/installedpane.py (+0/-43)
softwarecenter/ui/gtk3/panes/pendingpane.py (+0/-27)
softwarecenter/ui/gtk3/panes/viewswitcher.py (+0/-38)
softwarecenter/ui/gtk3/review_gui_helper.py (+4/-0)
softwarecenter/ui/gtk3/views/appdetailsview.py (+0/-73)
softwarecenter/ui/gtk3/views/appview.py (+0/-97)
softwarecenter/ui/gtk3/views/catview_gtk.py (+0/-108)
softwarecenter/ui/gtk3/views/pkgnamesview.py (+0/-39)
softwarecenter/ui/gtk3/views/purchaseview.py (+0/-43)
softwarecenter/ui/gtk3/widgets/apptreeview.py (+0/-56)
softwarecenter/ui/gtk3/widgets/backforward.py (+0/-17)
softwarecenter/ui/gtk3/widgets/buttons.py (+0/-40)
softwarecenter/ui/gtk3/widgets/containers.py (+0/-27)
softwarecenter/ui/gtk3/widgets/description.py (+0/-262)
softwarecenter/ui/gtk3/widgets/exhibits.py (+0/-43)
softwarecenter/ui/gtk3/widgets/labels.py (+0/-23)
softwarecenter/ui/gtk3/widgets/oneconfviews.py (+0/-36)
softwarecenter/ui/gtk3/widgets/recommendations.py (+0/-45)
softwarecenter/ui/gtk3/widgets/reviews.py (+0/-43)
softwarecenter/ui/gtk3/widgets/searchentry.py (+0/-22)
softwarecenter/ui/gtk3/widgets/spinner.py (+0/-19)
softwarecenter/ui/gtk3/widgets/stars.py (+0/-54)
softwarecenter/ui/gtk3/widgets/symbolic_icons.py (+0/-25)
softwarecenter/ui/gtk3/widgets/thumbnail.py (+0/-79)
softwarecenter/ui/gtk3/widgets/videoplayer.py (+0/-48)
test/gen-coverage-for-single-test.sh (+0/-4)
tests/channel_query.py (+1/-5)
tests/disabled_test_gnomekeyring.py (+4/-8)
tests/gtk3/test_app.py (+1/-3)
tests/gtk3/test_app_view.py (+14/-23)
tests/gtk3/test_appdetailsview.py (+76/-156)
tests/gtk3/test_appmanager.py (+9/-8)
tests/gtk3/test_appstore2.py (+11/-14)
tests/gtk3/test_catview.py (+31/-33)
tests/gtk3/test_custom_lists.py (+15/-33)
tests/gtk3/test_debfile_view.py (+5/-3)
tests/gtk3/test_dialogs.py (+10/-13)
tests/gtk3/test_globalpane.py (+8/-6)
tests/gtk3/test_install_progress.py (+11/-23)
tests/gtk3/test_installedpane.py (+14/-24)
tests/gtk3/test_navhistory.py (+2/-5)
tests/gtk3/test_panes.py (+17/-33)
tests/gtk3/test_purchase.py (+39/-40)
tests/gtk3/test_recommendations_widgets.py (+10/-24)
tests/gtk3/test_reviews.py (+22/-26)
tests/gtk3/test_search.py (+16/-30)
tests/gtk3/test_spinner.py (+1/-1)
tests/gtk3/test_unity_launcher_integration.py (+62/-64)
tests/gtk3/test_views.py (+19/-28)
tests/gtk3/test_widgets.py (+48/-71)
tests/gtk3/windows.py (+1163/-0)
tests/qml/test_ui_qml_helpers.py (+4/-9)
tests/test_addons.py (+6/-10)
tests/test_aptd.py (+11/-11)
tests/test_apthistory.py (+11/-20)
tests/test_categories.py (+16/-17)
tests/test_channels.py (+6/-7)
tests/test_cmdfiner.py (+4/-5)
tests/test_database.py (+68/-61)
tests/test_debfileapplication.py (+14/-13)
tests/test_description_norm.py (+5/-9)
tests/test_distro.py (+4/-6)
tests/test_downloader.py (+8/-17)
tests/test_enquire.py (+8/-14)
tests/test_gwibber.py (+36/-20)
tests/test_htmlize.py (+3/-5)
tests/test_hw.py (+7/-8)
tests/test_i18n.py (+6/-9)
tests/test_launchpad.py (+7/-13)
tests/test_logging.py (+33/-22)
tests/test_login_backend.py (+3/-5)
tests/test_mime.py (+11/-8)
tests/test_netstatus.py (+4/-6)
tests/test_origin.py (+9/-8)
tests/test_package_info.py (+4/-5)
tests/test_pep8.py (+5/-1)
tests/test_pkginfo.py (+8/-10)
tests/test_plugin.py (+10/-12)
tests/test_ppa_iconfilename.py (+7/-6)
tests/test_purchase_backend.py (+11/-13)
tests/test_pyflakes.py (+1/-5)
tests/test_recagent.py (+28/-34)
tests/test_region.py (+4/-6)
tests/test_reinstall_purchased.py (+6/-6)
tests/test_rnr_api.py (+4/-5)
tests/test_scagent.py (+8/-9)
tests/test_spawn_helper.py (+5/-5)
tests/test_startup.py (+4/-4)
tests/test_testutils.py (+6/-7)
tests/test_ubuntu_sso_api.py (+3/-5)
tests/test_utils.py (+38/-35)
tests/test_where_is_it.py (+17/-16)
tests/test_xapian.py (+7/-7)
tests/test_xapian_query.py (+3/-3)
tests/utils.py (+47/-24)
To merge this branch: bzr merge lp:~nataliabidart/software-center/the-organizer
Reviewer Review Type Date Requested Status
Michael Vogt Approve
Review via email: mp+108162@code.launchpad.net

Commit message

- Tests cleanup:
  - Renamed test/ dir to tests/.
  - Moved the testutils module to tests/utils.py.
  - Removed all unnecessary logging setup per test file.
  - Removed all unnecessary shebangs in test files.
  - Isolated test code into tests/ directory, including moving all the
    get_test_window_foo from the gtk3 production modules to
    tests/gtk3/windows.py module.
  - Removed all the calls to Gtk.main() in gtk3 tests since that blocks the
    execution of the suite.
  - Pep8 and pyflakes fixes in the files already modified in this branch.
  - Minor bug fix in the softwarecenter/log.py module when trying to create a
    log dir with proper perms.

To post a comment you must log in.
3029. By Natalia Bidart

Merged trunk in.

Revision history for this message
Michael Vogt (mvo) wrote :

Thanks and sorry that the review took so long.

This is a great cleanup! I really like tests/windows.py and the examples how to create the
interactive test windows. This should probably get a small README.debug file so that its
easy to find this really useful helper.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== renamed file 'test/gen-coverage-report.sh' => 'gen-coverage-report.sh'
2--- test/gen-coverage-report.sh 2011-08-17 16:13:33 +0000
3+++ gen-coverage-report.sh 2012-06-11 15:00:29 +0000
4@@ -1,18 +1,24 @@
5-#/bin/sh
6+#! /bin/sh
7
8 set -e
9
10+COVERAGE_DIR="./tests/coverage_html"
11+
12+# run for a single test if the argument is given
13+if [ $1 ]; then
14+ python-coverage run --parallel $1
15+fi
16+
17 # combine the reports
18 python-coverage combine
19
20-if [ -d coverage_html ]; then
21- rm -rf coverage_html
22+if [ -d $COVERAGE_DIR ]; then
23+ rm -rf $COVERAGE_DIR
24 fi
25
26 # generate the coverage data
27 OMIT="/usr/share/pyshared/*,*piston*,*test_"
28-python-coverage report --omit=$OMIT | tee coverage_summary | tail
29+python-coverage report --omit=$OMIT | tee $COVERAGE_DIR/coverage_summary | tail
30
31-DIR="coverage_html"
32-python-coverage html --omit=$OMIT -d $DIR
33-echo "see $DIR/index.html for the coverage details"
34\ No newline at end of file
35+python-coverage html --omit=$OMIT -d $COVERAGE_DIR
36+echo "see $COVERAGE_DIR/index.html for the coverage details"
37
38=== renamed file 'test/test-all.sh' => 'run-tests.sh'
39--- test/test-all.sh 2012-01-17 08:19:49 +0000
40+++ run-tests.sh 2012-06-11 15:00:29 +0000
41@@ -2,6 +2,8 @@
42
43 set -e
44
45+TESTS_DIR="tests"
46+
47 if [ ! -x /usr/bin/python-coverage ]; then
48 echo "please install python-coverage"
49 exit 1
50@@ -39,39 +41,78 @@
51
52
53 # clear coverage data
54-# coverage erase will not erase the files from --parallel-mode
55-rm -f .coverage*
56+# coverage erase will not erase the files from --parallel-mode
57+rm -f $TESTS_DIR/.coverage*
58
59 # run with xvfb and coverage
60-PYTHON="python-coverage run --parallel-mode"
61-#PYTHON="xvfb-run $PYTHON"
62+
63+XVFB_CMDLINE=""
64+XVFB=$(which xvfb-run)
65+if [ $XVFB ]; then
66+ XVFB_CMDLINE="$XVFB -a"
67+fi
68+
69+COVERAGE_CMDLINE=""
70+COVERAGE=$(which python-coverage)
71+if [ $COVERAGE ]; then
72+ # If you are measuring coverage in a multi-process program, or across a
73+ # number of machines, you’ll want the --parallel-mode switch to keep the
74+ # data separate during measurement. See Combining data files below.
75+ ##COVERAGE_CMDLINE="$COVERAGE run --parallel-mode"
76+ echo "No coverage for now."
77+fi
78+
79+PYTHON="$XVFB_CMDLINE $COVERAGE_CMDLINE python -m unittest"
80
81 # and record failures here
82-OUTPUT="./output"
83-rm -rf $OUTPUT
84+OUTPUT=$TESTS_DIR"/output"
85
86 FAILED=""
87-FILES=$(find . -name 'test_*.py')
88-for file in $FILES; do
89- if [ -f $file ]; then
90- echo -n "Testing $file"
91- mkdir -p ${OUTPUT}/$(dirname $file)
92- if ! $PYTHON $file >output/$file.out 2>&1 ; then
93- FAILED="$FAILED $file"
94- echo " FAIL"
95- else
96- echo " success"
97- rm -f ${OUTPUT}/$file.out;
98- fi
99- fi
100-done;
101-
102-# gather the coverage data
103-./gen-coverage-report.sh
104-
105-if [ -n "$FAILED" ]; then
106- echo "FAILED: $FAILED";
107- echo "Check ${OUTPUT}/ directory for the details";
108- exit 1;
109+run_tests_for_dir() {
110+ for i in $(find $1 -maxdepth 1 -name 'test_*.py'); do
111+ TEST_NAME=$(basename $i | cut -d '.' -f 1)
112+ TEST_PREFIX=$(echo `dirname $i` | sed -e s'/\//./g')
113+ printf '%-50s' "Testing $TEST_NAME..."
114+ if ! $PYTHON -v -c -b $TEST_PREFIX.$TEST_NAME > $OUTPUT/$TEST_NAME.out 2>&1; then
115+ FAILED="$FAILED $TEST_NAME"
116+ echo "[ FAIL ]"
117+ else
118+ echo "[ OK ]"
119+ rm -f ${OUTPUT}/$file.out;
120+ fi
121+ done
122+}
123+
124+if [ $# -gt 0 ]; then
125+ # run the requested tests if arguments were given,
126+ # otherwise run the whole suite
127+ # example of custom params (discover all the tests under the tests/gtk3 dir):
128+
129+ # ./run-tests.sh discover -v -s tests/gtk3/
130+
131+ # See http://docs.python.org/library/unittest.html#test-discovery
132+ # for more info.
133+ RUN_TESTS="$PYTHON $@"
134+ echo "Running the command: $RUN_TESTS"
135+ $RUN_TESTS
136+else
137+ # 2012-05-30, nessita: Ideally, we should be able to run the whole suite
138+ # using discovery, but there is too much interference between tests in
139+ # order to do so, so we need a new python process per test file.
140+ ##RUN_TESTS="$PYTHON discover -v -c -b"
141+ rm -rf $OUTPUT
142+ mkdir $OUTPUT
143+ run_tests_for_dir $TESTS_DIR
144+ run_tests_for_dir "$TESTS_DIR/gtk3"
145+
146+ # gather the coverage data
147+ ##./gen-coverage-report.sh
148+
149+ if [ -n "$FAILED" ]; then
150+ echo "FAILED: $FAILED"
151+ echo "Check ${OUTPUT}/ directory for the details"
152+ exit 1
153+ else
154+ echo "All OK!"
155+ fi
156 fi
157-
158
159=== modified file 'softwarecenter/log.py'
160--- softwarecenter/log.py 2012-05-15 07:51:29 +0000
161+++ softwarecenter/log.py 2012-06-11 15:00:29 +0000
162@@ -22,8 +22,8 @@
163 import logging.handlers
164 import os.path
165
166-from paths import SOFTWARE_CENTER_CACHE_DIR
167-from utils import (
168+import softwarecenter.paths
169+from softwarecenter.utils import (
170 ensure_file_writable_and_delete_if_not,
171 safe_makedirs,
172 )
173@@ -96,22 +96,24 @@
174 handler.addFilter(NullFilterThatWarnsAboutRootLoggerUsage())
175
176 # create log file
177-safe_makedirs(SOFTWARE_CENTER_CACHE_DIR)
178-logfile_path = os.path.join(SOFTWARE_CENTER_CACHE_DIR, "software-center.log")
179+safe_makedirs(softwarecenter.paths.SOFTWARE_CENTER_CACHE_DIR)
180
181 # try to fix inaccessible s-c directory (#688682)
182-if not os.access(SOFTWARE_CENTER_CACHE_DIR, os.W_OK):
183+if not os.access(softwarecenter.paths.SOFTWARE_CENTER_CACHE_DIR, os.W_OK):
184 logging.warn("found not writable '%s' dir, trying to fix" %
185- SOFTWARE_CENTER_CACHE_DIR)
186+ softwarecenter.paths.SOFTWARE_CENTER_CACHE_DIR)
187 # if we have to do more renames, soemthing else is wrong and its
188 # ok to crash later to learn about the problem
189 for i in range(10):
190- target = "%s.%s" % (SOFTWARE_CENTER_CACHE_DIR, i)
191+ target = "%s.%s" % (softwarecenter.paths.SOFTWARE_CENTER_CACHE_DIR, i)
192 if not os.path.exists(target):
193- os.rename(SOFTWARE_CENTER_CACHE_DIR, target)
194+ softwarecenter.paths.SOFTWARE_CENTER_CACHE_DIR = target
195 break
196- safe_makedirs(SOFTWARE_CENTER_CACHE_DIR)
197-
198+ safe_makedirs(softwarecenter.paths.SOFTWARE_CENTER_CACHE_DIR)
199+
200+
201+logfile_path = os.path.join(softwarecenter.paths.SOFTWARE_CENTER_CACHE_DIR,
202+ "software-center.log")
203 # according to bug 688682 many people have a non-writeable logfile
204 ensure_file_writable_and_delete_if_not(logfile_path)
205
206
207=== modified file 'softwarecenter/ui/gtk3/dialogs/dependency_dialogs.py'
208--- softwarecenter/ui/gtk3/dialogs/dependency_dialogs.py 2012-03-15 01:39:09 +0000
209+++ softwarecenter/ui/gtk3/dialogs/dependency_dialogs.py 2012-06-11 15:00:29 +0000
210@@ -23,11 +23,9 @@
211
212 from softwarecenter.ui.gtk3.dialogs import SimpleGtkbuilderDialog
213
214-from softwarecenter.db.application import Application
215 from softwarecenter.distro import get_distro
216 from softwarecenter.enums import Icons
217 from softwarecenter.ui.gtk3.views.pkgnamesview import PackageNamesView
218-import softwarecenter.ui.gtk3.dialogs
219
220 LOG = logging.getLogger(__name__)
221
222@@ -118,37 +116,4 @@
223 _DIALOG = dialog
224 result = dialog.run()
225 dialog.hide()
226- if result == Gtk.ResponseType.ACCEPT:
227- return True
228- return False
229-
230-
231-def get_test_dialog():
232- import softwarecenter
233- from softwarecenter.db.application import Application
234- from softwarecenter.testutils import (
235- get_test_gtk3_icon_cache, get_test_db)
236-
237- icons = get_test_gtk3_icon_cache()
238- db = get_test_db()
239-
240- depends = ["apt", "synaptic"]
241- app = Application("", "software-center")
242- primary = "primary text"
243- button_text = "button_text"
244- dia = _get_confirm_internal_dialog(
245- parent=None, datadir=softwarecenter.paths.datadir, app=app,
246- db=db, icons=icons, primary=primary, button_text=button_text,
247- depends=depends, cache=db._aptcache)
248- return dia
249-
250-
251-if __name__ == "__main__":
252-
253- # test real remove dialog
254- from softwarecenter.testutils import (
255- get_test_gtk3_icon_cache, get_test_db)
256- icons = get_test_gtk3_icon_cache()
257- db = get_test_db()
258- app = Application("", "p7zip-full")
259- confirm_remove(None, softwarecenter.paths.datadir, app, db, icons)
260+ return result == Gtk.ResponseType.ACCEPT
261
262=== modified file 'softwarecenter/ui/gtk3/panes/availablepane.py'
263--- softwarecenter/ui/gtk3/panes/availablepane.py 2012-06-08 23:42:50 +0000
264+++ softwarecenter/ui/gtk3/panes/availablepane.py 2012-06-11 15:00:29 +0000
265@@ -821,50 +821,3 @@
266 # and the subcat view as well...
267 if self.subcategories_view:
268 self.subcategories_view.refresh_apps()
269-
270-
271-def get_test_window():
272- from softwarecenter.testutils import (get_test_db,
273- get_test_datadir,
274- get_test_install_backend,
275- get_test_gtk3_viewmanager,
276- get_test_pkg_info,
277- get_test_gtk3_icon_cache,
278- )
279- # needed because available pane will try to get it
280- vm = get_test_gtk3_viewmanager()
281- vm # make pyflakes happy
282- db = get_test_db()
283- cache = get_test_pkg_info()
284- datadir = get_test_datadir()
285- icons = get_test_gtk3_icon_cache()
286- backend = get_test_install_backend()
287-
288- # create global AppManager instance
289- from softwarecenter.ui.gtk3.session.appmanager import ApplicationManager
290- ApplicationManager(db, backend, icons)
291-
292- navhistory_back_action = Gtk.Action("navhistory_back_action", "Back",
293- "Back", None)
294- navhistory_forward_action = Gtk.Action("navhistory_forward_action",
295- "Forward", "Forward", None)
296-
297- w = AvailablePane(cache, db, 'Ubuntu', icons, datadir,
298- navhistory_back_action, navhistory_forward_action)
299- w.init_view()
300- w.show()
301-
302- win = Gtk.Window()
303- win.connect("destroy", Gtk.main_quit)
304- win.add(w)
305- win.set_size_request(800, 600)
306- win.show_all()
307-
308- # this is used later in tests
309- win.set_data("pane", w)
310-
311- return win
312-
313-if __name__ == "__main__":
314- win = get_test_window()
315- Gtk.main()
316
317=== modified file 'softwarecenter/ui/gtk3/panes/globalpane.py'
318--- softwarecenter/ui/gtk3/panes/globalpane.py 2012-03-15 00:52:10 +0000
319+++ softwarecenter/ui/gtk3/panes/globalpane.py 2012-06-11 15:00:29 +0000
320@@ -69,34 +69,3 @@
321 item.add(widget)
322 self.insert(item, pos)
323 return item
324-
325-
326-def get_test_window():
327-
328- from softwarecenter.testutils import (get_test_db,
329- get_test_datadir,
330- get_test_gtk3_viewmanager,
331- get_test_pkg_info,
332- get_test_gtk3_icon_cache,
333- )
334- vm = get_test_gtk3_viewmanager()
335- db = get_test_db()
336- cache = get_test_pkg_info()
337- datadir = get_test_datadir()
338- icons = get_test_gtk3_icon_cache()
339-
340- p = GlobalPane(vm, datadir, db, cache, icons)
341-
342- win = Gtk.Window()
343- win.set_size_request(400, 200)
344- win.set_data("pane", p)
345- win.connect("destroy", Gtk.main_quit)
346- win.add(p)
347- win.show_all()
348- return win
349-
350-if __name__ == "__main__":
351-
352- win = get_test_window()
353-
354- Gtk.main()
355
356=== modified file 'softwarecenter/ui/gtk3/panes/historypane.py'
357--- softwarecenter/ui/gtk3/panes/historypane.py 2012-05-29 18:07:46 +0000
358+++ softwarecenter/ui/gtk3/panes/historypane.py 2012-06-11 15:00:29 +0000
359@@ -393,38 +393,6 @@
360 action_text = _('removed %s') % time_text
361 elif action == self.UPGRADED:
362 action_text = _('updated %s') % time_text
363- text = ('<span color="%(color)s">%(action)s</span>' %
364- {'color': '#8A8A8A', 'action': action_text})
365+ color = {'color': '#8A8A8A', 'action': action_text}
366+ text = '<span color="%(color)s">%(action)s</span>' % color
367 cell.set_property('markup', text)
368-
369-
370-def get_test_window():
371-
372- from softwarecenter.testutils import (get_test_db,
373- get_test_gtk3_viewmanager,
374- get_test_pkg_info,
375- get_test_gtk3_icon_cache,
376- )
377- # needed because available pane will try to get it
378- vm = get_test_gtk3_viewmanager()
379- vm # make pyflakes happy
380- db = get_test_db()
381- cache = get_test_pkg_info()
382- icons = get_test_gtk3_icon_cache()
383-
384- widget = HistoryPane(cache, db, None, icons, None)
385- widget.show()
386-
387- win = Gtk.Window()
388- win.add(widget)
389- win.set_size_request(600, 500)
390- win.set_position(Gtk.WindowPosition.CENTER)
391- win.show_all()
392- win.connect('destroy', Gtk.main_quit)
393-
394- widget.init_view()
395- return win
396-
397-if __name__ == '__main__':
398- win = get_test_window()
399- Gtk.main()
400
401=== modified file 'softwarecenter/ui/gtk3/panes/installedpane.py'
402--- softwarecenter/ui/gtk3/panes/installedpane.py 2012-05-17 12:27:58 +0000
403+++ softwarecenter/ui/gtk3/panes/installedpane.py 2012-06-11 15:00:29 +0000
404@@ -746,46 +746,3 @@
405 def is_app_details_view_showing(self):
406 """Return True if we are in the app_details view """
407 return self.notebook.get_current_page() == InstalledPane.Pages.DETAILS
408-
409-
410-def get_test_window():
411- from softwarecenter.testutils import (get_test_db,
412- get_test_datadir,
413- get_test_gtk3_viewmanager,
414- get_test_pkg_info,
415- get_test_gtk3_icon_cache,
416- )
417- # needed because available pane will try to get it
418- vm = get_test_gtk3_viewmanager()
419- vm # make pyflakes happy
420- db = get_test_db()
421- cache = get_test_pkg_info()
422- datadir = get_test_datadir()
423- icons = get_test_gtk3_icon_cache()
424-
425- w = InstalledPane(cache, db, 'Ubuntu', icons, datadir)
426- w.show()
427-
428- win = Gtk.Window()
429- win.set_data("pane", w)
430- win.add(w)
431- win.set_size_request(400, 600)
432- win.connect("destroy", lambda x: Gtk.main_quit())
433-
434- # init the view
435- w.init_view()
436-
437- from softwarecenter.backend.channel import AllInstalledChannel
438- from softwarecenter.ui.gtk3.panes.softwarepane import DisplayState
439- w.state.channel = AllInstalledChannel()
440- view_state = DisplayState()
441- view_state.channel = AllInstalledChannel()
442- w.display_overview_page(None, view_state)
443-
444- win.show()
445- return win
446-
447-
448-if __name__ == "__main__":
449- win = get_test_window()
450- Gtk.main()
451
452=== modified file 'softwarecenter/ui/gtk3/panes/pendingpane.py'
453--- softwarecenter/ui/gtk3/panes/pendingpane.py 2012-03-15 00:16:03 +0000
454+++ softwarecenter/ui/gtk3/panes/pendingpane.py 2012-06-11 15:00:29 +0000
455@@ -124,30 +124,3 @@
456
457 def get_callback_for_page(self, page_id, view_state):
458 return None
459-
460-
461-def get_test_window():
462-
463- from softwarecenter.testutils import get_test_gtk3_icon_cache
464- icons = get_test_gtk3_icon_cache()
465-
466- view = PendingPane(icons)
467-
468- # gui
469- scroll = Gtk.ScrolledWindow()
470- scroll.add_with_viewport(view)
471-
472- win = Gtk.Window()
473- win.add(scroll)
474- view.grab_focus()
475- win.set_size_request(500, 200)
476- win.show_all()
477- win.connect("destroy", Gtk.main_quit)
478-
479- return win
480-
481-if __name__ == "__main__":
482- logging.basicConfig(level=logging.DEBUG)
483-
484- win = get_test_window()
485- Gtk.main()
486
487=== modified file 'softwarecenter/ui/gtk3/panes/viewswitcher.py'
488--- softwarecenter/ui/gtk3/panes/viewswitcher.py 2012-03-15 17:49:44 +0000
489+++ softwarecenter/ui/gtk3/panes/viewswitcher.py 2012-06-11 15:00:29 +0000
490@@ -277,41 +277,3 @@
491 return False
492
493 GObject.idle_add(config_view)
494-
495-
496-def get_test_window_viewswitcher():
497- from softwarecenter.testutils import (get_test_db,
498- get_test_datadir,
499- get_test_gtk3_viewmanager,
500- get_test_pkg_info,
501- get_test_gtk3_icon_cache,
502- )
503- cache = get_test_pkg_info()
504- db = get_test_db()
505- icons = get_test_gtk3_icon_cache()
506- datadir = get_test_datadir()
507- manager = get_test_gtk3_viewmanager()
508-
509- view = ViewSwitcher(manager, datadir, db, cache, icons)
510-
511- scroll = Gtk.ScrolledWindow()
512- box = Gtk.VBox()
513- box.pack_start(scroll, True, True, 0)
514-
515- win = Gtk.Window()
516- scroll.add_with_viewport(view)
517-
518- win.add(box)
519- win.set_size_request(400, 200)
520- win.connect("destroy", Gtk.main_quit)
521- win.show_all()
522- return win
523-
524-if __name__ == "__main__":
525- import softwarecenter.paths
526- logging.basicConfig(level=logging.DEBUG)
527-
528- softwarecenter.paths.datadir = "./data"
529- win = get_test_window_viewswitcher()
530-
531- Gtk.main()
532
533=== modified file 'softwarecenter/ui/gtk3/review_gui_helper.py'
534--- softwarecenter/ui/gtk3/review_gui_helper.py 2012-04-30 22:27:29 +0000
535+++ softwarecenter/ui/gtk3/review_gui_helper.py 2012-06-11 15:00:29 +0000
536@@ -716,6 +716,10 @@
537 self.quit(2)
538
539 def _setup_details(self, widget, app, iconname, version, display_name):
540+ if app is None:
541+ logging.warning('Can not setup details since app is None.')
542+ return
543+
544 # icon shazam
545 try:
546 icon = self.icons.load_icon(iconname, self.APP_ICON_SIZE, 0)
547
548=== modified file 'softwarecenter/ui/gtk3/views/appdetailsview.py'
549--- softwarecenter/ui/gtk3/views/appdetailsview.py 2012-05-23 16:05:31 +0000
550+++ softwarecenter/ui/gtk3/views/appdetailsview.py 2012-06-11 15:00:29 +0000
551@@ -2040,76 +2040,3 @@
552
553 def set_section(self, section):
554 self.section = section
555-
556-
557-def get_test_window_appdetails():
558-
559- from softwarecenter.db.pkginfo import get_pkg_info
560- cache = get_pkg_info()
561- cache.open()
562-
563- from softwarecenter.db.database import StoreDatabase
564- xapian_base_path = "/var/cache/software-center"
565- pathname = os.path.join(xapian_base_path, "xapian")
566- db = StoreDatabase(pathname, cache)
567- db.open()
568-
569- import softwarecenter.paths
570- datadir = softwarecenter.paths.datadir
571-
572- from softwarecenter.ui.gtk3.utils import get_sc_icon_theme
573- icons = get_sc_icon_theme(datadir)
574-
575- import softwarecenter.distro
576- distro = softwarecenter.distro.get_distro()
577-
578- # gui
579- win = Gtk.Window()
580- scroll = Gtk.ScrolledWindow()
581- view = AppDetailsView(db, distro, icons, cache, datadir)
582-
583- import sys
584- if len(sys.argv) > 1:
585- pkgname = sys.argv[1]
586- else:
587- pkgname = "totem"
588-
589- view.show_app(Application("", pkgname))
590- #view.show_app(Application("Pay App Example", "pay-app"))
591- #view.show_app(Application("3D Chess", "3dchess"))
592- #view.show_app(Application("Movie Player", "totem"))
593- #view.show_app(Application("ACE", "unace"))
594- #~ view.show_app(Application("", "apt"))
595-
596- #view.show_app("AMOR")
597- #view.show_app("Configuration Editor")
598- #view.show_app("Artha")
599- #view.show_app("cournol")
600- #view.show_app("Qlix")
601-
602- scroll.add(view)
603- scroll.show()
604- win.add(scroll)
605- win.set_size_request(600, 800)
606- win.show()
607- win.connect('destroy', Gtk.main_quit)
608- win.set_data("view", view)
609- return win
610-
611-
612-if __name__ == "__main__":
613- def _show_app(view):
614- if view.app.pkgname == "totem":
615- view.show_app(Application("Pithos", "pithos"))
616- else:
617- view.show_app(Application("Movie Player", "totem"))
618- return True
619-
620- win = get_test_window_appdetails()
621-
622- # keep it spinning to test for re-draw issues and memleaks
623- #view = win.get_data("view")
624- #GObject.timeout_add_seconds(2, _show_app, view)
625-
626- # run it
627- Gtk.main()
628
629=== modified file 'softwarecenter/ui/gtk3/views/appview.py'
630--- softwarecenter/ui/gtk3/views/appview.py 2012-05-16 15:52:07 +0000
631+++ softwarecenter/ui/gtk3/views/appview.py 2012-06-11 15:00:29 +0000
632@@ -27,7 +27,6 @@
633 from softwarecenter.ui.gtk3.models.appstore2 import AppTreeStore
634 from softwarecenter.ui.gtk3.widgets.apptreeview import AppTreeView
635 from softwarecenter.ui.gtk3.models.appstore2 import AppPropertiesHelper
636-from softwarecenter.utils import ExecutionTime
637
638 LOG = logging.getLogger(__name__)
639
640@@ -282,99 +281,3 @@
641 py + self.tree_view.selected_row_renderer.icon_y_offset)
642 else:
643 return (px, py)
644-
645-
646-# ----------------------------------------------- testcode
647-from softwarecenter.enums import NonAppVisibility
648-
649-
650-def get_query_from_search_entry(search_term):
651- import xapian
652- if not search_term:
653- return xapian.Query("")
654- parser = xapian.QueryParser()
655- user_query = parser.parse_query(search_term)
656- return user_query
657-
658-
659-def on_entry_changed(widget, data):
660-
661- def _work():
662- new_text = widget.get_text()
663- (view, enquirer) = data
664-
665- with ExecutionTime("total time"):
666- with ExecutionTime("enquire.set_query()"):
667- enquirer.set_query(get_query_from_search_entry(new_text),
668- limit=100 * 1000,
669- nonapps_visible=NonAppVisibility.ALWAYS_VISIBLE)
670-
671- store = view.tree_view.get_model()
672- with ExecutionTime("store.clear()"):
673- store.clear()
674-
675- with ExecutionTime("store.set_from_matches()"):
676- store.set_from_matches(enquirer.matches)
677-
678- with ExecutionTime("model settle (size=%s)" % len(store)):
679- while Gtk.events_pending():
680- Gtk.main_iteration()
681- return
682-
683- if widget.stamp:
684- GObject.source_remove(widget.stamp)
685- widget.stamp = GObject.timeout_add(250, _work)
686-
687-
688-def get_test_window():
689- import softwarecenter.log
690- softwarecenter.log.root.setLevel(level=logging.DEBUG)
691- softwarecenter.log.add_filters_from_string("performance")
692- fmt = logging.Formatter("%(name)s - %(message)s", None)
693- softwarecenter.log.handler.setFormatter(fmt)
694-
695- from softwarecenter.testutils import (
696- get_test_db, get_test_pkg_info, get_test_gtk3_icon_cache)
697- from softwarecenter.ui.gtk3.models.appstore2 import AppListStore
698-
699- db = get_test_db()
700- cache = get_test_pkg_info()
701- icons = get_test_gtk3_icon_cache()
702-
703- # create a filter
704- from softwarecenter.db.appfilter import AppFilter
705- filter = AppFilter(db, cache)
706- filter.set_supported_only(False)
707- filter.set_installed_only(True)
708-
709- # appview
710- from softwarecenter.db.enquire import AppEnquire
711- enquirer = AppEnquire(cache, db)
712- store = AppListStore(db, cache, icons)
713-
714- from softwarecenter.ui.gtk3.views.appview import AppView
715- view = AppView(db, cache, icons, show_ratings=True)
716- view.set_model(store)
717-
718- entry = Gtk.Entry()
719- entry.stamp = 0
720- entry.connect("changed", on_entry_changed, (view, enquirer))
721-
722- box = Gtk.VBox()
723- box.pack_start(entry, False, True, 0)
724- box.pack_start(view, True, True, 0)
725-
726- win = Gtk.Window()
727- win.set_data("appview", view)
728- win.set_data("entry", entry)
729- win.connect("destroy", lambda x: Gtk.main_quit())
730- win.add(box)
731- win.set_size_request(600, 400)
732- win.show_all()
733-
734- return win
735-
736-if __name__ == "__main__":
737- win = get_test_window()
738- win.get_data("entry").set_text("gtk3")
739- Gtk.main()
740
741=== modified file 'softwarecenter/ui/gtk3/views/catview_gtk.py'
742--- softwarecenter/ui/gtk3/views/catview_gtk.py 2012-05-22 15:40:01 +0000
743+++ softwarecenter/ui/gtk3/views/catview_gtk.py 2012-06-11 15:00:29 +0000
744@@ -726,111 +726,3 @@
745 #self.in_subsection = True
746 #self.set_subcategory(self.root_category)
747 #return
748-
749-
750-def get_test_window_catview(db=None):
751-
752- def on_category_selected(view, cat):
753- print "on_category_selected view: ", view
754- print "on_category_selected cat: ", cat
755-
756- if db is None:
757- from softwarecenter.db.pkginfo import get_pkg_info
758- cache = get_pkg_info()
759- cache.open()
760-
761- from softwarecenter.db.database import StoreDatabase
762- xapian_base_path = "/var/cache/software-center"
763- pathname = os.path.join(xapian_base_path, "xapian")
764- db = StoreDatabase(pathname, cache)
765- db.open()
766- else:
767- cache = db._aptcache
768-
769- import softwarecenter.paths
770- datadir = softwarecenter.paths.datadir
771-
772- from softwarecenter.ui.gtk3.utils import get_sc_icon_theme
773- icons = get_sc_icon_theme(datadir)
774-
775- import softwarecenter.distro
776- distro = softwarecenter.distro.get_distro()
777-
778- apps_filter = AppFilter(db, cache)
779-
780- # gui
781- win = Gtk.Window()
782- notebook = Gtk.Notebook()
783-
784- from softwarecenter.paths import APP_INSTALL_PATH
785- view = LobbyViewGtk(datadir, APP_INSTALL_PATH,
786- cache, db, icons, distro, apps_filter)
787- win.set_data("lobby", view)
788-
789- scroll = Gtk.ScrolledWindow()
790- scroll.add(view)
791- notebook.append_page(scroll, Gtk.Label(label="Lobby"))
792-
793- # find a cat in the LobbyView that has subcategories
794- subcat_cat = None
795- for cat in reversed(view.categories):
796- if cat.subcategories:
797- subcat_cat = cat
798- break
799-
800- view = SubCategoryViewGtk(datadir, APP_INSTALL_PATH, cache, db, icons,
801- apps_filter)
802- view.connect("category-selected", on_category_selected)
803- view.set_subcategory(subcat_cat)
804- win.set_data("subcat", view)
805-
806- scroll = Gtk.ScrolledWindow()
807- scroll.add(view)
808- notebook.append_page(scroll, Gtk.Label(label="Subcats"))
809-
810- win.add(notebook)
811- win.set_size_request(800, 800)
812- win.show_all()
813- win.connect('destroy', Gtk.main_quit)
814- return win
815-
816-
817-def get_test_catview():
818-
819- def on_category_selected(view, cat):
820- print("on_category_selected %s %s" % view, cat)
821-
822- from softwarecenter.db.pkginfo import get_pkg_info
823- cache = get_pkg_info()
824- cache.open()
825-
826- from softwarecenter.db.database import StoreDatabase
827- xapian_base_path = "/var/cache/software-center"
828- pathname = os.path.join(xapian_base_path, "xapian")
829- db = StoreDatabase(pathname, cache)
830- db.open()
831-
832- import softwarecenter.paths
833- datadir = softwarecenter.paths.datadir
834-
835- from softwarecenter.ui.gtk3.utils import get_sc_icon_theme
836- icons = get_sc_icon_theme(datadir)
837-
838- import softwarecenter.distro
839- distro = softwarecenter.distro.get_distro()
840-
841- apps_filter = AppFilter(db, cache)
842-
843- from softwarecenter.paths import APP_INSTALL_PATH
844- cat_view = LobbyViewGtk(datadir, APP_INSTALL_PATH,
845- cache, db, icons, distro, apps_filter)
846- return cat_view
847-
848-if __name__ == "__main__":
849- import os
850- logging.basicConfig(level=logging.DEBUG)
851-
852- win = get_test_window_catview()
853-
854- # run it
855- Gtk.main()
856
857=== modified file 'softwarecenter/ui/gtk3/views/pkgnamesview.py'
858--- softwarecenter/ui/gtk3/views/pkgnamesview.py 2012-03-14 16:34:56 +0000
859+++ softwarecenter/ui/gtk3/views/pkgnamesview.py 2012-06-11 15:00:29 +0000
860@@ -20,7 +20,6 @@
861 from gi.repository import Pango
862
863 import logging
864-import os
865
866 from softwarecenter.db.application import Application
867 from softwarecenter.enums import Icons
868@@ -74,41 +73,3 @@
869 # finally, we don't allow selection, it's just a simple display list
870 tree_selection = self.get_selection()
871 tree_selection.set_mode(Gtk.SelectionMode.NONE)
872-
873-
874-def get_test_window_pkgnamesview():
875-
876- from softwarecenter.db.pkginfo import get_pkg_info
877- cache = get_pkg_info()
878- cache.open()
879-
880- from softwarecenter.db.database import StoreDatabase
881- xapian_base_path = "/var/cache/software-center"
882- pathname = os.path.join(xapian_base_path, "xapian")
883- db = StoreDatabase(pathname, cache)
884- db.open()
885-
886- import softwarecenter.paths
887- datadir = softwarecenter.paths.datadir
888-
889- from softwarecenter.ui.gtk3.utils import get_sc_icon_theme
890- icons = get_sc_icon_theme(datadir)
891-
892- pkgs = ["apt", "software-center"]
893- view = PackageNamesView("header", cache, pkgs, icons, 32, db)
894- view.show()
895-
896- win = Gtk.Window()
897- win.add(view)
898- win.set_size_request(600, 400)
899- win.show()
900- win.connect('destroy', Gtk.main_quit)
901- return win
902-
903-
904-if __name__ == "__main__":
905- import logging
906- logging.basicConfig()
907-
908- win = get_test_window_pkgnamesview()
909- Gtk.main()
910
911=== modified file 'softwarecenter/ui/gtk3/views/purchaseview.py'
912--- softwarecenter/ui/gtk3/views/purchaseview.py 2012-05-29 18:07:46 +0000
913+++ softwarecenter/ui/gtk3/views/purchaseview.py 2012-06-11 15:00:29 +0000
914@@ -25,8 +25,6 @@
915 import logging
916 import os
917 import json
918-import sys
919-import urllib
920
921 from gi.repository import WebKit as webkit
922
923@@ -402,44 +400,3 @@
924 # # for debugging only
925 # def _on_key_press(dialog, event):
926 # print event, event.keyval
927-
928-
929-def get_test_window_purchaseview():
930- #url = "http://www.animiertegifs.de/java-scripts/alertbox.php"
931- url = "http://www.ubuntu.cohtml=DUMMY_m"
932- #d = PurchaseDialog(app=None, url="http://spiegel.de")
933- from softwarecenter.enums import BUY_SOMETHING_HOST
934- url = BUY_SOMETHING_HOST + "/subscriptions/en/ubuntu/maverick/+new/?%s" % (
935- urllib.urlencode({
936- 'archive_id': "mvo/private-test",
937- 'arch': "i386",
938- }))
939- # use cmdline if available
940- if len(sys.argv) > 1:
941- url = sys.argv[1]
942- # useful for debugging
943- #d.connect("key-press-event", _on_key_press)
944- #GObject.timeout_add_seconds(1, _generate_events, d)
945-
946- widget = PurchaseView()
947- from mock import Mock
948- widget.config = Mock()
949-
950- win = Gtk.Window()
951- win.set_data("view", widget)
952- win.add(widget)
953- win.set_size_request(600, 500)
954- win.set_position(Gtk.WindowPosition.CENTER)
955- win.show_all()
956- win.connect('destroy', Gtk.main_quit)
957-
958- widget.initiate_purchase(app=None, iconname=None, url=url)
959- #widget.initiate_purchase(app=None, iconname=None, html=DUMMY_HTML)
960-
961- return win
962-
963-if __name__ == "__main__":
964- import softwarecenter.paths
965- softwarecenter.paths.datadir = "./data"
966- win = get_test_window_purchaseview()
967- Gtk.main()
968
969=== modified file 'softwarecenter/ui/gtk3/widgets/apptreeview.py'
970--- softwarecenter/ui/gtk3/widgets/apptreeview.py 2012-04-30 22:27:29 +0000
971+++ softwarecenter/ui/gtk3/widgets/apptreeview.py 2012-06-11 15:00:29 +0000
972@@ -12,7 +12,6 @@
973
974 from softwarecenter.ui.gtk3.em import em, StockEms
975 from softwarecenter.enums import (AppActions, Icons)
976-from softwarecenter.utils import ExecutionTime
977 from softwarecenter.backend import get_install_backend
978 from softwarecenter.netstatus import (get_network_watcher,
979 network_state_is_connected)
980@@ -660,58 +659,3 @@
981 if not res:
982 return False
983 return self.get_path_at_pos(x, y)[0] == self.get_cursor()[0]
984-
985-
986-def get_test_window():
987- import softwarecenter.log
988- softwarecenter.log.root.setLevel(level=logging.DEBUG)
989- softwarecenter.log.add_filters_from_string("performance")
990- fmt = logging.Formatter("%(name)s - %(message)s", None)
991- softwarecenter.log.handler.setFormatter(fmt)
992-
993- from softwarecenter.testutils import (
994- get_test_db, get_test_pkg_info, get_test_gtk3_icon_cache,
995- get_test_categories)
996-
997- cache = get_test_pkg_info()
998- db = get_test_db()
999- icons = get_test_gtk3_icon_cache()
1000-
1001- # create a filter
1002- from softwarecenter.db.appfilter import AppFilter
1003- filter = AppFilter(db, cache)
1004- filter.set_supported_only(False)
1005- filter.set_installed_only(True)
1006-
1007- # get the TREEstore
1008- from softwarecenter.ui.gtk3.models.appstore2 import AppTreeStore
1009- store = AppTreeStore(db, cache, icons)
1010-
1011- # populate from data
1012- cats = get_test_categories(db)
1013- for cat in cats[:3]:
1014- with ExecutionTime("query cat '%s'" % cat.name):
1015- docs = db.get_docs_from_query(cat.query)
1016- store.set_category_documents(cat, docs)
1017-
1018- # ok, this is confusing - the AppView contains the AppTreeView that
1019- # is a tree or list depending on the model
1020- from softwarecenter.ui.gtk3.views.appview import AppView
1021- app_view = AppView(db, cache, icons, show_ratings=True)
1022- app_view.set_model(store)
1023-
1024- box = Gtk.VBox()
1025- box.pack_start(app_view, True, True, 0)
1026-
1027- win = Gtk.Window()
1028- win.add(box)
1029- win.connect("destroy", lambda x: Gtk.main_quit())
1030- win.set_size_request(600, 400)
1031- win.show_all()
1032-
1033- return win
1034-
1035-
1036-if __name__ == "__main__":
1037- win = get_test_window()
1038- Gtk.main()
1039
1040=== modified file 'softwarecenter/ui/gtk3/widgets/backforward.py'
1041--- softwarecenter/ui/gtk3/widgets/backforward.py 2012-03-10 02:05:59 +0000
1042+++ softwarecenter/ui/gtk3/widgets/backforward.py 2012-06-11 15:00:29 +0000
1043@@ -161,20 +161,3 @@
1044
1045 for child in self:
1046 self.propagate_draw(child, cr)
1047-
1048-
1049-# this is used in the automatic tests as well
1050-def get_test_backforward_window():
1051- win = Gtk.Window()
1052- win.set_border_width(20)
1053- win.connect("destroy", lambda x: Gtk.main_quit())
1054- win.set_default_size(300, 100)
1055- backforward = BackForwardButton()
1056- win.add(backforward)
1057- return win
1058-
1059-if __name__ == "__main__":
1060- win = get_test_backforward_window()
1061- win.show_all()
1062-
1063- Gtk.main()
1064
1065=== modified file 'softwarecenter/ui/gtk3/widgets/buttons.py'
1066--- softwarecenter/ui/gtk3/widgets/buttons.py 2012-05-17 11:33:19 +0000
1067+++ softwarecenter/ui/gtk3/widgets/buttons.py 2012-06-11 15:00:29 +0000
1068@@ -616,43 +616,3 @@
1069 def on_leave(self, widget, event):
1070 window = self.get_window()
1071 window.set_cursor(None)
1072-
1073-
1074-def _build_channels_list(popup):
1075- for i in range(3):
1076- item = Gtk.MenuItem.new()
1077- label = Gtk.Label.new("channel_name %s" % i)
1078- box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, StockEms.MEDIUM)
1079- box.pack_start(label, False, False, 0)
1080- item.add(box)
1081- item.show_all()
1082- popup.attach(item, 0, 1, i, i + 1)
1083-
1084-
1085-def get_test_buttons_window():
1086- win = Gtk.Window()
1087- win.set_size_request(200, 200)
1088-
1089- vb = Gtk.VBox(spacing=12)
1090- win.add(vb)
1091-
1092- link = Link("<small>test link</small>", uri="www.google.co.nz")
1093- vb.pack_start(link, False, False, 0)
1094-
1095- button = Gtk.Button()
1096- button.set_label("channels")
1097- channels_button = ChannelSelector(button)
1098- channels_button.parent_style_type = Gtk.Window
1099- channels_button.set_build_func(_build_channels_list)
1100- hb = Gtk.HBox()
1101- hb.pack_start(button, False, False, 0)
1102- hb.pack_start(channels_button, False, False, 0)
1103- vb.pack_start(hb, False, False, 0)
1104-
1105- win.show_all()
1106- win.connect("destroy", Gtk.main_quit)
1107- return win
1108-
1109-if __name__ == "__main__":
1110- win = get_test_buttons_window()
1111- Gtk.main()
1112
1113=== modified file 'softwarecenter/ui/gtk3/widgets/containers.py'
1114--- softwarecenter/ui/gtk3/widgets/containers.py 2012-03-19 19:45:20 +0000
1115+++ softwarecenter/ui/gtk3/widgets/containers.py 2012-06-11 15:00:29 +0000
1116@@ -573,30 +573,3 @@
1117 # paint the containers children
1118 for child in self:
1119 self.propagate_draw(child, cr)
1120-
1121-
1122-# this is used in the automatic tests
1123-def get_test_container_window():
1124- win = Gtk.Window()
1125- win.set_size_request(500, 300)
1126- f = FlowableGrid()
1127-
1128- import buttons
1129-
1130- for i in range(10):
1131- t = buttons.CategoryTile("test", "folder")
1132- f.add_child(t)
1133-
1134- scroll = Gtk.ScrolledWindow()
1135- scroll.add_with_viewport(f)
1136-
1137- win.add(scroll)
1138- win.show_all()
1139-
1140- win.connect("destroy", lambda x: Gtk.main_quit())
1141- return win
1142-
1143-if __name__ == '__main__':
1144- win = get_test_container_window()
1145- win.show_all()
1146- Gtk.main()
1147
1148=== modified file 'softwarecenter/ui/gtk3/widgets/description.py'
1149--- softwarecenter/ui/gtk3/widgets/description.py 2012-03-10 02:05:59 +0000
1150+++ softwarecenter/ui/gtk3/widgets/description.py 2012-06-11 15:00:29 +0000
1151@@ -1184,265 +1184,3 @@
1152
1153 def select_all(self):
1154 return TextBlock.select_all(self.description)
1155-
1156-
1157-def get_test_description_window():
1158- EXAMPLE0 = """p7zip is the Unix port of 7-Zip, a file archiver that \
1159-archives with very high compression ratios.
1160-
1161-p7zip-full provides:
1162-
1163- - /usr/bin/7za a standalone version of the 7-zip tool that handles
1164- 7z archives (implementation of the LZMA compression algorithm) and some \
1165-other formats.
1166-
1167- - /usr/bin/7z not only does it handle 7z but also ZIP, Zip64, CAB, RAR, \
1168-ARJ, GZIP,
1169- BZIP2, TAR, CPIO, RPM, ISO and DEB archives. 7z compression is 30-50% \
1170-better than ZIP compression.
1171-
1172-p7zip provides 7zr, a light version of 7za, and p7zip a gzip like wrapper \
1173-around 7zr."""
1174-
1175- EXAMPLE1 = """Transmageddon supports almost any format as its input and \
1176-can generate a very large host of output files. The goal of the application \
1177-was to help people to create the files they need to be able to play on their \
1178-mobile devices and for people not hugely experienced with multimedia to \
1179-generate a multimedia file without having to resort to command line tools \
1180-with ungainly syntaxes.
1181-The currently supported codecs are:
1182- * Containers:
1183- - Ogg
1184- - Matroska
1185- - AVI
1186- - MPEG TS
1187- - flv
1188- - QuickTime
1189- - MPEG4
1190- - 3GPP
1191- - MXT
1192- * Audio encoders:
1193- - Vorbis
1194- - FLAC
1195- - MP3
1196- - AAC
1197- - AC3
1198- - Speex
1199- - Celt
1200- * Video encoders:
1201- - Theora
1202- - Dirac
1203- - H264
1204- - MPEG2
1205- - MPEG4/DivX5
1206- - xvid
1207- - DNxHD
1208-It also provide the support for the GStreamer's plugins auto-search."""
1209-
1210- EXAMPLE2 = """File-roller is an archive manager for the GNOME \
1211-environment. It allows you to:
1212- * Create and modify archives.
1213- * View the content of an archive.
1214- * View a file contained in an archive.
1215- * Extract files from the archive.
1216-File-roller supports the following formats:
1217- * Tar (.tar) archives, including those compressed with
1218- gzip (.tar.gz, .tgz), bzip (.tar.bz, .tbz), bzip2 (.tar.bz2, .tbz2),
1219- compress (.tar.Z, .taz), lzip (.tar.lz, .tlz), lzop (.tar.lzo, .tzo),
1220- lzma (.tar.lzma) and xz (.tar.xz)
1221- * Zip archives (.zip)
1222- * Jar archives (.jar, .ear, .war)
1223- * 7z archives (.7z)
1224- * iso9660 CD images (.iso)
1225- * Lha archives (.lzh)
1226- * Single files compressed with gzip (.gz), bzip (.bz), bzip2 (.bz2),
1227- compress (.Z), lzip (.lz), lzop (.lzo), lzma (.lzma) and xz (.xz)
1228-File-roller doesn't perform archive operations by itself, but relies on \
1229-standard tools for this."""
1230-
1231- EXAMPLE3 = """This package includes the following CTAN packages:
1232- Asana-Math -- A font to typeset maths in Xe(La)TeX.
1233- albertus --
1234- allrunes -- Fonts and LaTeX package for almost all runes.
1235- antiqua -- the URW Antiqua Condensed Font.
1236- antp -- Antykwa Poltawskiego: a Type 1 family of Polish traditional type.
1237- antt -- Antykwa Torunska: a Type 1 family of a Polish traditional type.
1238- apl -- Fonts for typesetting APL programs.
1239- ar -- Capital A and capital R ligature for Apsect Ratio.
1240- archaic -- A collection of archaic fonts.
1241- arev -- Fonts and LaTeX support files for Arev Sans.
1242- ascii -- Support for IBM "standard ASCII" font.
1243- astro -- Astronomical (planetary) symbols.
1244- atqolive --
1245- augie -- Calligraphic font for typesetting handwriting.
1246- auncial-new -- Artificial Uncial font and LaTeX support macros.
1247- aurical -- Calligraphic fonts for use with LaTeX in T1 encoding.
1248- barcodes -- Fonts for making barcodes.
1249- bayer -- Herbert Bayers Universal Font For Metafont.
1250- bbding -- A symbol (dingbat) font and LaTeX macros for its use.
1251- bbm -- "Blackboard-style" cm fonts.
1252- bbm-macros -- LaTeX support for "blackboard-style" cm fonts.
1253- bbold -- Sans serif blackboard bold.
1254- belleek -- Free replacement for basic MathTime fonts.
1255- bera -- Bera fonts.
1256- blacklettert1 -- T1-encoded versions of Haralambous old German fonts.
1257- boisik -- A font inspired by Baskerville design.
1258- bookhands -- A collection of book-hand fonts.
1259- braille -- Support for braille.
1260- brushscr -- A handwriting script font.
1261- calligra -- Calligraphic font.
1262- carolmin-ps -- Adobe Type 1 format of Carolingian Minuscule fonts.
1263- cherokee -- A font for the Cherokee script.
1264- clarendo --
1265- cm-lgc -- Type 1 CM-based fonts for Latin, Greek and Cyrillic.
1266- cmbright -- Computer Modern Bright fonts.
1267- cmll -- Symbols for linear logic.
1268- cmpica -- A Computer Modern Pica variant.
1269- coronet --
1270- courier-scaled -- Provides a scaled Courier font.
1271- cryst -- Font for graphical symbols used in crystallography.
1272- cyklop -- The Cyclop typeface.
1273- dancers -- Font for Conan Doyle's "The Dancing Men".
1274- dice -- A font for die faces.
1275- dictsym -- DictSym font and macro package
1276- dingbat -- Two dingbat symbol fonts.
1277- doublestroke -- Typeset mathematical double stroke symbols.
1278- dozenal -- Typeset documents using base twelve numbering (also called
1279- "dozenal")
1280- duerer -- Computer Duerer fonts.
1281- duerer-latex -- LaTeX support for the Duerer fonts.
1282- ean -- Macros for making EAN barcodes.
1283- ecc -- Sources for the European Concrete fonts.
1284- eco -- Oldstyle numerals using EC fonts.
1285- eiad -- Traditional style Irish fonts.
1286- eiad-ltx -- LaTeX support for the eiad font.
1287- elvish -- Fonts for typesetting Tolkien Elvish scripts.
1288- epigrafica -- A Greek and Latin font.
1289- epsdice -- A scalable dice "font".
1290- esvect -- Vector arrows.
1291- eulervm -- Euler virtual math fonts.
1292- euxm --
1293- feyn -- A font for in-text Feynman diagrams.
1294- fge -- A font for Frege's Grundgesetze der Arithmetik.
1295- foekfont -- The title font of the Mads Fok magazine.
1296- fonetika -- Support for the danish "Dania" phonetic system.
1297- fourier -- Using Utopia fonts in LaTeX documents.
1298- fouriernc -- Use New Century Schoolbook text with Fourier maths fonts.
1299- frcursive -- French cursive hand fonts.
1300- garamond --
1301- genealogy -- A compilation genealogy font.
1302- gfsartemisia -- A modern Greek font design.
1303- gfsbodoni -- A Greek and Latin font based on Bodoni.
1304- gfscomplutum -- A Greek font with a long history.
1305- gfsdidot -- A Greek font based on Didot's work.
1306- gfsneohellenic -- A Greek font in the Neo-Hellenic style.
1307- gfssolomos -- A Greek-alphabet font.
1308- gothic -- A collection of old German-style fonts.
1309- greenpoint -- The Green Point logo.
1310- groff --
1311- grotesq -- the URW Grotesk Bold Font.
1312- hands -- Pointing hand font.
1313- hfbright -- The hfbright fonts.
1314- hfoldsty -- Old style numerals with EC fonts.
1315- ifsym -- A collection of symbols.
1316- inconsolata -- A monospaced font, with support files for use with TeX.
1317- initials -- Adobe Type 1 decorative initial fonts.
1318- iwona -- A two-element sans-serif font.
1319- junicode -- A TrueType font for mediaevalists.
1320- kixfont -- A font for KIX codes.
1321- knuthotherfonts --
1322- kpfonts -- A complete set of fonts for text and mathematics.
1323- kurier -- A two-element sans-serif typeface.
1324- lettrgth --
1325- lfb -- A Greek font with normal and bold variants.
1326- libertine -- Use the font Libertine with LaTeX.
1327- libris -- Libris ADF fonts, with LaTeX support.
1328- linearA -- Linear A script fonts.
1329- logic -- A font for electronic logic design.
1330- lxfonts -- Set of slide fonts based on CM.
1331- ly1 -- Support for LY1 LaTeX encoding.
1332- marigold --
1333- mathabx -- Three series of mathematical symbols.
1334- mathdesign -- Mathematical fonts to fit with particular text fonts.
1335- mnsymbol -- Mathematical symbol font for Adobe MinionPro.
1336- nkarta -- A "new" version of the karta cartographic fonts.
1337- ocherokee -- LaTeX Support for the Cherokee language.
1338- ogham -- Fonts for typesetting Ogham script.
1339- oinuit -- LaTeX Support for the Inuktitut Language.
1340- optima --
1341- orkhun -- A font for orkhun script.
1342- osmanian -- Osmanian font for writing Somali.
1343- pacioli -- Fonts designed by Fra Luca de Pacioli in 1497.
1344- pclnfss -- Font support for current PCL printers.
1345- phaistos -- Disk of Phaistos font.
1346- phonetic -- MetaFont Phonetic fonts, based on Computer Modern.
1347- pigpen -- A font for the pigpen (or masonic) cipher.
1348- psafm --
1349- punk -- Donald Knuth's punk font.
1350- recycle -- A font providing the "recyclable" logo.
1351- sauter -- Wide range of design sizes for CM fonts.
1352- sauterfonts -- Use sauter fonts in LaTeX.
1353- semaphor -- Semaphore alphabet font.
1354- simpsons -- MetaFont source for Simpsons characters.
1355- skull -- A font to draw a skull.
1356- staves -- Typeset Icelandic staves and runic letters.
1357- tapir -- A simple geometrical font.
1358- tengwarscript -- LaTeX support for using Tengwar fonts.
1359- trajan -- Fonts from the Trajan column in Rome.
1360- umtypewriter -- Fonts to typeset with the xgreek package.
1361- univers --
1362- universa -- Herbert Bayer's 'universal' font.
1363- venturisadf -- Venturis ADF fonts collection.
1364- wsuipa -- International Phonetic Alphabet fonts.
1365- yfonts -- Support for old German fonts.
1366- zefonts -- Virtual fonts to provide T1 encoding from existing fonts."""
1367-
1368- EXAMPLE4 = """Arista is a simple multimedia transcoder, it focuses on \
1369-being easy to use by making complex task of encoding for various devices \
1370-simple.
1371-Users should pick an input and a target device, choose a file to save to and \
1372-go. Features:
1373-* Presets for iPod, computer, DVD player, PSP, Playstation 3, and more.
1374-* Live preview to see encoded quality.
1375-* Automatically discover available DVD media and Video 4 Linux (v4l) devices.
1376-* Rip straight from DVD media easily (requires libdvdcss).
1377-* Rip straight from v4l devices.
1378-* Simple terminal client for scripting.
1379-* Automatic preset updating."""
1380-
1381- def on_clicked(widget, desc_widget, descs):
1382- widget.position += 1
1383- if widget.position >= len(descs):
1384- widget.position = 0
1385- desc_widget.set_description(*descs[widget.position])
1386-
1387- descs = ((EXAMPLE0, ''),
1388- (EXAMPLE1, ''),
1389- (EXAMPLE2, ''),
1390- (EXAMPLE3, 'texlive-fonts-extra'),
1391- (EXAMPLE4, ''))
1392-
1393- win = Gtk.Window()
1394- win.set_default_size(300, 400)
1395- win.set_has_resize_grip(True)
1396- vb = Gtk.VBox()
1397- win.add(vb)
1398- b = Gtk.Button('Next test description >>')
1399- b.position = 0
1400- vb.pack_start(b, False, False, 0)
1401- scroll = Gtk.ScrolledWindow()
1402- vb.add(scroll)
1403- d = AppDescription()
1404- #~ d.description.DEBUG_PAINT_BBOXES = True
1405- d.set_description(EXAMPLE0, pkgname='')
1406- scroll.add_with_viewport(d)
1407- win.show_all()
1408-
1409- b.connect("clicked", on_clicked, d, descs)
1410- win.connect('destroy', lambda x: Gtk.main_quit())
1411- return win
1412-
1413-if __name__ == '__main__':
1414- win = get_test_description_window()
1415- win.show_all()
1416- Gtk.main()
1417
1418=== modified file 'softwarecenter/ui/gtk3/widgets/exhibits.py'
1419--- softwarecenter/ui/gtk3/widgets/exhibits.py 2012-03-19 22:05:35 +0000
1420+++ softwarecenter/ui/gtk3/widgets/exhibits.py 2012-06-11 15:00:29 +0000
1421@@ -608,46 +608,3 @@
1422 self.index_hbox.show_all()
1423
1424 self._render_exhibit_at_cursor()
1425-
1426-
1427-def get_test_exhibits_window():
1428- from mock import Mock
1429-
1430- win = Gtk.Window()
1431- win.set_size_request(600, 200)
1432-
1433- exhibit_banner = ExhibitBanner()
1434-
1435- exhibits_list = [FeaturedExhibit()]
1436- for (i, (title, url)) in enumerate([
1437- ("1 some title", "https://wiki.ubuntu.com/Brand?"
1438- "action=AttachFile&do=get&target=orangeubuntulogo.png"),
1439- ("2 another title", "https://wiki.ubuntu.com/Brand?"
1440- "action=AttachFile&do=get&target=blackeubuntulogo.png"),
1441- ("3 yet another title", "https://wiki.ubuntu.com/Brand?"
1442- "action=AttachFile&do=get&target=xubuntu.png"),
1443- ]):
1444- exhibit = Mock()
1445- exhibit.id = i
1446- exhibit.package_names = "apt,2vcard"
1447- exhibit.published = True
1448- exhibit.style = "some uri to html"
1449- exhibit.title_translated = title
1450- exhibit.banner_url = url
1451- exhibit.html = None
1452- exhibits_list.append(exhibit)
1453-
1454- exhibit_banner.set_exhibits(exhibits_list)
1455-
1456- scroll = Gtk.ScrolledWindow()
1457- scroll.add_with_viewport(exhibit_banner)
1458- win.add(scroll)
1459-
1460- win.show_all()
1461- win.connect("destroy", Gtk.main_quit)
1462- return win
1463-
1464-if __name__ == "__main__":
1465- softwarecenter.paths.datadir = "./data"
1466- win = get_test_exhibits_window()
1467- Gtk.main()
1468
1469=== modified file 'softwarecenter/ui/gtk3/widgets/labels.py'
1470--- softwarecenter/ui/gtk3/widgets/labels.py 2012-06-05 09:15:00 +0000
1471+++ softwarecenter/ui/gtk3/widgets/labels.py 2012-06-11 15:00:29 +0000
1472@@ -112,26 +112,3 @@
1473 @property
1474 def hw_labels(self):
1475 return self.get_children()
1476-
1477-
1478-def get_test_window():
1479- win = Gtk.Window()
1480- win.set_size_request(300, 200)
1481-
1482- HW_TEST_RESULT = {
1483- 'hardware::gps': 'yes',
1484- 'hardware::video:opengl': 'no',
1485- }
1486-
1487- # add it
1488- hwbox = HardwareRequirementsBox()
1489- hwbox.set_hardware_requirements(HW_TEST_RESULT)
1490- win.add(hwbox)
1491-
1492- win.show_all()
1493- win.connect("destroy", Gtk.main_quit)
1494- return win
1495-
1496-if __name__ == "__main__":
1497- win = get_test_window()
1498- Gtk.main()
1499
1500=== modified file 'softwarecenter/ui/gtk3/widgets/oneconfviews.py'
1501--- softwarecenter/ui/gtk3/widgets/oneconfviews.py 2012-03-09 12:50:38 +0000
1502+++ softwarecenter/ui/gtk3/widgets/oneconfviews.py 2012-06-11 15:00:29 +0000
1503@@ -127,39 +127,3 @@
1504 return 1
1505 else:
1506 return -1
1507-
1508-
1509-def get_test_window():
1510-
1511- w = OneConfViews(Gtk.IconTheme.get_default())
1512- w.show()
1513-
1514- win = Gtk.Window()
1515- win.set_data("pane", w)
1516- win.add(w)
1517- win.set_size_request(400, 600)
1518- win.connect("destroy", lambda x: Gtk.main_quit())
1519-
1520- # init the view
1521- w.register_computer("AAAAA", "NameA")
1522- w.register_computer("ZZZZZ", "NameZ")
1523- w.register_computer("DDDDD", "NameD")
1524- w.register_computer("CCCCC", "NameC")
1525- w.register_computer("", "This computer should be first")
1526- w.select_first()
1527-
1528- GObject.timeout_add_seconds(5, w.register_computer, "EEEEE", "NameE")
1529-
1530- def print_selected_hostid(widget, hostid, hostname):
1531- print "%s selected for %s" % (hostid, hostname)
1532-
1533- w.connect("computer-changed", print_selected_hostid)
1534-
1535- w.remove_computer("DDDDD")
1536- win.show_all()
1537- return win
1538-
1539-
1540-if __name__ == "__main__":
1541- win = get_test_window()
1542- Gtk.main()
1543
1544=== modified file 'softwarecenter/ui/gtk3/widgets/recommendations.py'
1545--- softwarecenter/ui/gtk3/widgets/recommendations.py 2012-04-30 22:27:29 +0000
1546+++ softwarecenter/ui/gtk3/widgets/recommendations.py 2012-06-11 15:00:29 +0000
1547@@ -394,48 +394,3 @@
1548 _(RecommendationsPanelLobby.TURN_ON_RECOMMENDATIONS_TEXT),
1549 Gtk.ResponseType.YES)
1550 self.set_default_response(Gtk.ResponseType.YES)
1551-
1552-
1553-# test helpers
1554-def get_test_window(panel_type="lobby"):
1555- import softwarecenter.log
1556- softwarecenter.log.root.setLevel(level=logging.DEBUG)
1557- fmt = logging.Formatter("%(name)s - %(message)s", None)
1558- softwarecenter.log.handler.setFormatter(fmt)
1559-
1560- # this is *way* too complicated we should *not* need a CatView
1561- # here! see FIXME in RecommendationsPanel.__init__()
1562- from softwarecenter.ui.gtk3.views.catview_gtk import CategoriesViewGtk
1563- from softwarecenter.testutils import (
1564- get_test_db, get_test_pkg_info, get_test_gtk3_icon_cache,
1565- get_test_categories)
1566- cache = get_test_pkg_info()
1567- db = get_test_db()
1568- icons = get_test_gtk3_icon_cache()
1569- catview = CategoriesViewGtk(softwarecenter.paths.datadir,
1570- softwarecenter.paths.APP_INSTALL_PATH,
1571- cache,
1572- db,
1573- icons)
1574-
1575- if panel_type is "lobby":
1576- view = RecommendationsPanelLobby(catview)
1577- elif panel_type is "category":
1578- cats = get_test_categories(db)
1579- view = RecommendationsPanelCategory(catview, cats[0])
1580- else: # panel_type is "details":
1581- view = RecommendationsPanelDetails(catview)
1582-
1583- win = Gtk.Window()
1584- win.connect("destroy", lambda x: Gtk.main_quit())
1585- win.add(view)
1586- win.set_data("rec_panel", view)
1587- win.set_size_request(600, 200)
1588- win.show_all()
1589-
1590- return win
1591-
1592-
1593-if __name__ == "__main__":
1594- win = get_test_window()
1595- Gtk.main()
1596
1597=== modified file 'softwarecenter/ui/gtk3/widgets/reviews.py'
1598--- softwarecenter/ui/gtk3/widgets/reviews.py 2012-05-31 08:52:50 +0000
1599+++ softwarecenter/ui/gtk3/widgets/reviews.py 2012-06-11 15:00:29 +0000
1600@@ -943,46 +943,3 @@
1601 msg = _('Be the first to contribute a review for this application')
1602
1603 EmbeddedMessage.__init__(self, title, msg, 'text-editor')
1604-
1605-
1606-def get_test_reviews_window():
1607- from mock import Mock
1608-
1609- appdetails_mock = Mock()
1610- appdetails_mock.version = "2.0"
1611-
1612- parent = Mock()
1613- parent.app_details = appdetails_mock
1614-
1615- review_data = Mock()
1616- review_data.app_name = "app"
1617- review_data.usefulness_favorable = 10
1618- review_data.usefulness_total = 12
1619- review_data.usefulness_submit_error = False
1620- review_data.reviewer_username = "name"
1621- review_data.reviewer_displayname = "displayname"
1622- review_data.date_created = "2011-01-01 18:00:00"
1623- review_data.summary = "summary"
1624- review_data.review_text = 10 * "loonng text"
1625- review_data.rating = "3.0"
1626- review_data.version = "1.0"
1627-
1628- # create reviewslist
1629- vb = UIReviewsList(parent)
1630- vb.add_review(review_data)
1631- vb.configure_reviews_ui()
1632-
1633- win = Gtk.Window()
1634- win.set_size_request(200, 200)
1635- win.add(vb)
1636- win.connect('destroy', Gtk.main_quit)
1637- win.show_all()
1638- return win
1639-
1640-if __name__ == "__main__":
1641- import softwarecenter.paths
1642- softwarecenter.paths.datadir = "./data"
1643-
1644- win = get_test_reviews_window()
1645-
1646- Gtk.main()
1647
1648=== modified file 'softwarecenter/ui/gtk3/widgets/searchentry.py'
1649--- softwarecenter/ui/gtk3/widgets/searchentry.py 2012-05-12 04:28:52 +0000
1650+++ softwarecenter/ui/gtk3/widgets/searchentry.py 2012-06-11 15:00:29 +0000
1651@@ -152,25 +152,3 @@
1652 self.set_icon_from_pixbuf(Gtk.EntryIconPosition.SECONDARY, pb)
1653 else:
1654 self.set_icon_from_stock(Gtk.EntryIconPosition.SECONDARY, None)
1655-
1656-
1657-def on_entry_changed(self, terms):
1658- print(terms)
1659-
1660-
1661-def get_test_searchentry_window():
1662- icons = Gtk.IconTheme.get_default()
1663- entry = SearchEntry(icons)
1664- entry.connect("terms-changed", on_entry_changed)
1665-
1666- win = Gtk.Window()
1667- win.connect("destroy", Gtk.main_quit)
1668- win.add(entry)
1669- win.set_size_request(400, 400)
1670- win.show_all()
1671- win.entry = entry
1672- return win
1673-
1674-if __name__ == "__main__":
1675- win = get_test_searchentry_window()
1676- Gtk.main()
1677
1678=== modified file 'softwarecenter/ui/gtk3/widgets/spinner.py'
1679--- softwarecenter/ui/gtk3/widgets/spinner.py 2012-05-22 12:22:28 +0000
1680+++ softwarecenter/ui/gtk3/widgets/spinner.py 2012-06-11 15:00:29 +0000
1681@@ -114,22 +114,3 @@
1682 self._last_timeout_id = None
1683 self.spinner_view.stop_and_hide()
1684 self.set_current_page(self.CONTENT_PAGE)
1685-
1686-
1687-def get_test_spinner_window():
1688- label = Gtk.Label("foo")
1689- spinner_notebook = SpinnerNotebook(label, "random msg")
1690-
1691- window = Gtk.Window()
1692- window.add(spinner_notebook)
1693- window.set_size_request(600, 500)
1694- window.set_position(Gtk.WindowPosition.CENTER)
1695- window.show_all()
1696- window.connect('destroy', Gtk.main_quit)
1697- spinner_notebook.show_spinner("Loading for 1s ...")
1698- GObject.timeout_add_seconds(1, lambda: spinner_notebook.hide_spinner())
1699- return window
1700-
1701-if __name__ == "__main__":
1702- win = get_test_spinner_window()
1703- Gtk.main()
1704
1705=== modified file 'softwarecenter/ui/gtk3/widgets/stars.py'
1706--- softwarecenter/ui/gtk3/widgets/stars.py 2012-03-23 14:24:05 +0000
1707+++ softwarecenter/ui/gtk3/widgets/stars.py 2012-06-11 15:00:29 +0000
1708@@ -533,57 +533,3 @@
1709 self.set_orientation(Gtk.Orientation.HORIZONTAL)
1710 self.pack_start(self.selector, False, False, 0)
1711 self.pack_start(self.caption, False, False, 0)
1712-
1713-
1714-# test helper also used in the unit tests
1715-def get_test_stars_window():
1716- win = Gtk.Window()
1717- win.set_size_request(200, 200)
1718-
1719- vb = Gtk.VBox()
1720- vb.set_spacing(6)
1721- win.add(vb)
1722-
1723- vb.add(Gtk.Button())
1724- vb.add(Gtk.Label(label="BLAHHHHHH"))
1725-
1726- star = Star()
1727- star.set_n_stars(5)
1728- star.set_rating(2.5)
1729- star.set_size(StarSize.SMALL)
1730- vb.pack_start(star, False, False, 0)
1731-
1732- star = Star()
1733- star.set_n_stars(5)
1734- star.set_rating(2.5)
1735- star.set_size(StarSize.NORMAL)
1736- vb.pack_start(star, False, False, 0)
1737-
1738- star = Star()
1739- star.set_n_stars(5)
1740- star.set_rating(2.575)
1741- star.set_size(StarSize.BIG)
1742- vb.pack_start(star, False, False, 0)
1743-
1744- star = Star()
1745- star.set_n_stars(5)
1746- star.set_rating(3.333)
1747- star.set_size_as_pixel_value(36)
1748- vb.pack_start(star, False, False, 0)
1749-
1750- star = ReactiveStar()
1751- star.set_n_stars(5)
1752- star.set_rating(3)
1753- star.set_size_as_pixel_value(big_em(3))
1754- vb.pack_start(star, False, False, 0)
1755-
1756- selector = StarRatingSelector()
1757- vb.pack_start(selector, False, False, 0)
1758-
1759- win.connect("destroy", Gtk.main_quit)
1760- return win
1761-
1762-if __name__ == "__main__":
1763- win = get_test_stars_window()
1764- win.show_all()
1765- Gtk.main()
1766
1767=== modified file 'softwarecenter/ui/gtk3/widgets/symbolic_icons.py'
1768--- softwarecenter/ui/gtk3/widgets/symbolic_icons.py 2012-03-08 17:42:36 +0000
1769+++ softwarecenter/ui/gtk3/widgets/symbolic_icons.py 2012-06-11 15:00:29 +0000
1770@@ -204,28 +204,3 @@
1771 (self.BUBBLE_FONT_DESC, "white", count))
1772 self.layout.set_markup(m, -1)
1773 self.queue_draw()
1774-
1775-
1776-def get_test_symbolic_icons_window():
1777- win = Gtk.Window()
1778- win.set_border_width(20)
1779- hb = Gtk.HBox(spacing=12)
1780- win.add(hb)
1781- ico = SymbolicIcon("available")
1782- hb.add(ico)
1783- ico = PendingSymbolicIcon("pending")
1784- ico.start()
1785- ico.set_transaction_count(33)
1786- hb.add(ico)
1787- ico = PendingSymbolicIcon("pending")
1788- ico.start()
1789- ico.set_transaction_count(1)
1790- hb.add(ico)
1791- win.show_all()
1792- win.connect("destroy", Gtk.main_quit)
1793- return win
1794-
1795-if __name__ == "__main__":
1796- softwarecenter.paths.datadir = os.path.join(os.getcwd(), 'data')
1797- win = get_test_symbolic_icons_window()
1798- Gtk.main()
1799
1800=== modified file 'softwarecenter/ui/gtk3/widgets/thumbnail.py'
1801--- softwarecenter/ui/gtk3/widgets/thumbnail.py 2012-05-21 09:40:47 +0000
1802+++ softwarecenter/ui/gtk3/widgets/thumbnail.py 2012-06-11 15:00:29 +0000
1803@@ -21,9 +21,7 @@
1804 from gi.repository import Gtk, Gdk, Atk, Gio, GObject, GdkPixbuf
1805
1806 import logging
1807-import os
1808
1809-from softwarecenter.db.pkginfo import get_pkg_info
1810 from softwarecenter.utils import SimpleFileDownloader
1811
1812 from imagedialog import SimpleShowImageDialog
1813@@ -472,80 +470,3 @@
1814 thumb.set_state_flags(Gtk.StateFlags.SELECTED, False)
1815 self._prev = thumb
1816 self.emit("thumb-selected", thumb.id_)
1817-
1818-
1819-def get_test_screenshot_thumbnail_window():
1820- icons = Gtk.IconTheme.get_default()
1821- icons.append_search_path("/usr/share/app-install/icons/")
1822-
1823- import softwarecenter.distro
1824- distro = softwarecenter.distro.get_distro()
1825-
1826- win = Gtk.Window()
1827- win.set_border_width(10)
1828-
1829- from gi.repository import Gdk
1830- from softwarecenter.ui.gtk3.utils import init_sc_css_provider
1831- from softwarecenter.ui.gtk3.widgets.containers import FramedBox
1832- init_sc_css_provider(win, Gtk.Settings.get_default(),
1833- Gdk.Screen.get_default(), "data")
1834-
1835- t = ScreenshotGallery(distro, icons)
1836- t.connect('draw', t.draw)
1837- frame = FramedBox()
1838- frame.add(t)
1839- win.set_data("screenshot_thumbnail_widget", t)
1840-
1841- vb = Gtk.VBox(spacing=6)
1842- win.add(vb)
1843-
1844- b = Gtk.Button('A button for focus testing')
1845- vb.pack_start(b, True, True, 0)
1846- win.set_data("screenshot_button_widget", b)
1847- vb.pack_start(frame, True, True, 0)
1848-
1849- win.show_all()
1850- win.connect('destroy', Gtk.main_quit)
1851-
1852- return win
1853-
1854-if __name__ == '__main__':
1855-
1856- app_n = 0
1857-
1858- def testing_cycle_apps(_, thumb, apps, db):
1859- global app_n
1860- d = apps[app_n].get_details(db)
1861-
1862- if app_n + 1 < len(apps):
1863- app_n += 1
1864- else:
1865- app_n = 0
1866-
1867- thumb.fetch_screenshots(d)
1868- return True
1869-
1870- logging.basicConfig(level=logging.DEBUG)
1871-
1872- cache = get_pkg_info()
1873- cache.open()
1874-
1875- from softwarecenter.db.database import StoreDatabase
1876- xapian_base_path = "/var/cache/software-center"
1877- pathname = os.path.join(xapian_base_path, "xapian")
1878- db = StoreDatabase(pathname, cache)
1879- db.open()
1880-
1881- w = get_test_screenshot_thumbnail_window()
1882- t = w.get_data("screenshot_thumbnail_widget")
1883- b = w.get_data("screenshot_button_widget")
1884-
1885- from softwarecenter.db.application import Application
1886- apps = [Application("Movie Player", "totem"),
1887- Application("Comix", "comix"),
1888- Application("Gimp", "gimp"),
1889- Application("ACE", "uace")]
1890-
1891- b.connect("clicked", testing_cycle_apps, t, apps, db)
1892-
1893- Gtk.main()
1894
1895=== modified file 'softwarecenter/ui/gtk3/widgets/videoplayer.py'
1896--- softwarecenter/ui/gtk3/widgets/videoplayer.py 2012-04-18 21:04:11 +0000
1897+++ softwarecenter/ui/gtk3/widgets/videoplayer.py 2012-06-11 15:00:29 +0000
1898@@ -18,7 +18,6 @@
1899
1900 import logging
1901 import subprocess
1902-import sys
1903
1904 from gettext import gettext as _
1905 from gi.repository import Gdk
1906@@ -156,50 +155,3 @@
1907 xid = self.player.movie_window.get_window().get_xid()
1908 imagesink.set_xwindow_id(xid)
1909 Gdk.threads_leave()
1910-
1911-
1912-def get_test_videoplayer_window():
1913-
1914- # youtube example fragment
1915- html_youtube = """<iframe width="640" height="390"
1916-src="http://www.youtube.com/embed/h3oBU0NZJuA" frameborder="0"
1917-allowfullscreen></iframe>"""
1918- # vimeo example video fragment
1919- html_vimeo = """<iframe
1920-src="http://player.vimeo.com/video/2891554?title=0&amp;byline=0&amp;portrait=0"
1921-width="400" height="308" frameborder="0" webkitAllowFullScreen
1922-allowFullScreen></iframe><p><a href="http://vimeo.com/2891554">
1923-Supertuxkart 0.6</a> from <a href="http://vimeo.com/user1183699">
1924-constantin pelikan</a> on <a href="http://vimeo.com">Vimeo</a>.</p>"""
1925- # dailymotion example video fragment
1926- html_dailymotion = """<iframe frameborder="0" width="480" height="270"
1927-src="http://www.dailymotion.com/embed/video/xm4ysu"></iframe>"""
1928- html_dailymotion2 = """<iframe frameborder="0" width="480" height="379"
1929-src="http://www.dailymotion.com/embed/video/xdiktp"></iframe>"""
1930-
1931- html_youtube # pyflakes
1932- html_dailymotion # pyflakes
1933- html_dailymotion2 # pyflakes
1934-
1935- win = Gtk.Window.new(Gtk.WindowType.TOPLEVEL)
1936- win.set_default_size(500, 400)
1937- win.connect("destroy", Gtk.main_quit)
1938- player = VideoPlayer()
1939- win.add(player)
1940- if len(sys.argv) < 2:
1941- #player.uri = "http://upload.wikimedia.org/wikipedia/commons/9/9b/" \
1942- # "Pentagon_News_Sample.ogg"
1943- #player.uri = "http://people.canonical.com/~mvo/totem.html"
1944- player.load_html_string(html_vimeo)
1945- else:
1946- player.uri = sys.argv[1]
1947- win.show_all()
1948- return win
1949-
1950-if __name__ == "__main__":
1951- logging.basicConfig()
1952- Gdk.threads_init()
1953- # Gst.init(sys.argv)
1954-
1955- win = get_test_videoplayer_window()
1956- Gtk.main()
1957
1958=== removed file 'test/gen-coverage-for-single-test.sh'
1959--- test/gen-coverage-for-single-test.sh 2011-12-01 03:27:43 +0000
1960+++ test/gen-coverage-for-single-test.sh 1970-01-01 00:00:00 +0000
1961@@ -1,4 +0,0 @@
1962-#!/bin/sh
1963-
1964-python-coverage run --parallel $1
1965-./gen-coverage-report.sh
1966
1967=== removed symlink 'test/gtk3/testutils.py'
1968=== target was u'../../softwarecenter/testutils.py'
1969=== removed symlink 'test/testutils.py'
1970=== target was u'../softwarecenter/testutils.py'
1971=== renamed directory 'test' => 'tests'
1972=== modified file 'tests/channel_query.py'
1973--- test/channel_query.py 2011-05-18 08:26:04 +0000
1974+++ tests/channel_query.py 2012-06-11 15:00:29 +0000
1975@@ -1,5 +1,3 @@
1976-#!/usr/bin/python
1977-
1978 import os
1979 import sys
1980 import xapian
1981@@ -29,11 +27,9 @@
1982 # print "'%s': %s (%s); " % (t.term, t.wdf, t.termfreq),
1983 #print "\n"
1984 print ";".join(sorted(apps))
1985-
1986+
1987 for i in db.postlist(""):
1988 doc = db.get_document(i.docid)
1989 for t in doc.termlist():
1990 if t.term.startswith("XOL"):
1991 print "doc: '%s', term: '%s'" % (doc.get_data(), t.term)
1992-
1993-
1994
1995=== added directory 'tests/data/test_images'
1996=== added file 'tests/data/test_images/fallback.png'
1997Binary files tests/data/test_images/fallback.png 1970-01-01 00:00:00 +0000 and tests/data/test_images/fallback.png 2012-06-11 15:00:29 +0000 differ
1998=== modified file 'tests/disabled_test_gnomekeyring.py'
1999--- test/disabled_test_gnomekeyring.py 2011-07-14 14:42:36 +0000
2000+++ tests/disabled_test_gnomekeyring.py 2012-06-11 15:00:29 +0000
2001@@ -1,10 +1,9 @@
2002-#!/usr/bin/python
2003+import unittest
2004
2005+import gnomekeyring as gk
2006 from gi.repository import GObject
2007-import gnomekeyring as gk
2008-import unittest
2009
2010-class testGnomeKeyringUsage(unittest.TestCase):
2011+class TestGnomeKeyringUsage(unittest.TestCase):
2012
2013 APP = "gk-test"
2014 KEYRING_NAME = "gk-test-keyring"
2015@@ -15,7 +14,7 @@
2016 def test_keyring_available(self):
2017 available = gk.is_available()
2018 self.assertTrue(available)
2019-
2020+
2021 def test_keyring_populate(self):
2022 attr = { 'token' : 'the-token',
2023 'consumer-key' : 'the-consumer-key',
2024@@ -57,7 +56,4 @@
2025
2026
2027 if __name__ == "__main__":
2028- import logging
2029- logging.basicConfig(level=logging.DEBUG)
2030 unittest.main()
2031-
2032
2033=== modified file 'tests/gtk3/test_app.py'
2034--- test/gtk3/test_app.py 2012-06-05 18:53:06 +0000
2035+++ tests/gtk3/test_app.py 2012-06-11 15:00:29 +0000
2036@@ -1,5 +1,3 @@
2037-#!/usr/bin/python
2038-
2039 import os
2040 import unittest
2041
2042@@ -8,7 +6,7 @@
2043
2044 from mock import Mock
2045
2046-from testutils import FakedCache, get_mock_options, setup_test_env
2047+from tests.utils import FakedCache, get_mock_options, setup_test_env
2048 setup_test_env()
2049
2050 import softwarecenter.paths
2051
2052=== modified file 'tests/gtk3/test_app_view.py'
2053--- test/gtk3/test_app_view.py 2012-04-12 12:29:34 +0000
2054+++ tests/gtk3/test_app_view.py 2012-06-11 15:00:29 +0000
2055@@ -1,19 +1,20 @@
2056-#!/usr/bin/python
2057-
2058 import unittest
2059 import xapian
2060
2061-from testutils import setup_test_env
2062+from tests.utils import (
2063+ do_events,
2064+ get_test_db,
2065+ get_test_enquirer_matches,
2066+ get_test_gtk3_icon_cache,
2067+ get_test_pkg_info,
2068+ setup_test_env,
2069+)
2070 setup_test_env()
2071
2072 from softwarecenter.db.enquire import AppEnquire
2073 from softwarecenter.enums import SortMethods
2074+from tests.gtk3.windows import get_test_window_appview
2075
2076-from softwarecenter.testutils import (get_test_db,
2077- get_test_pkg_info,
2078- get_test_gtk3_icon_cache,
2079- do_events,
2080- )
2081
2082 class TestAppView(unittest.TestCase):
2083 """ test the app view """
2084@@ -24,7 +25,6 @@
2085 self.db = get_test_db()
2086
2087 def test_app_view(self):
2088- from softwarecenter.ui.gtk3.views.appview import get_test_window
2089 enquirer = AppEnquire(self.cache, self.db)
2090 enquirer.set_query(xapian.Query(""),
2091 sortmode=SortMethods.BY_CATALOGED_TIME,
2092@@ -32,7 +32,8 @@
2093 nonblocking_load=False)
2094
2095 # get test window
2096- win = get_test_window()
2097+ win = get_test_window_appview()
2098+ self.addCleanup(win.destroy)
2099 appview = win.get_data("appview")
2100 # set matches
2101 appview.clear_model()
2102@@ -42,17 +43,12 @@
2103 model = appview.tree_view.get_model()
2104 docs_in_model = [item[0] for item in model]
2105 docs_from_enquirer = [m.document for m in enquirer.matches]
2106- self.assertEqual(len(docs_in_model),
2107- len(docs_from_enquirer))
2108+ self.assertEqual(len(docs_in_model), len(docs_from_enquirer))
2109 for i in range(len(docs_in_model)):
2110 self.assertEqual(self.db.get_pkgname(docs_in_model[i]),
2111 self.db.get_pkgname(docs_from_enquirer[i]))
2112- win.destroy()
2113
2114 def test_appview_search_combo(self):
2115- from softwarecenter.ui.gtk3.views.appview import get_test_window
2116- from softwarecenter.testutils import get_test_enquirer_matches
2117-
2118 # test if combox sort option "by relevance" vanishes for non-searches
2119 # LP: #861778
2120 expected_normal = ["By Name", "By Top Rated", "By Newest First"]
2121@@ -60,7 +56,8 @@
2122 "By Relevance"]
2123
2124 # setup goo
2125- win = get_test_window()
2126+ win = get_test_window_appview()
2127+ self.addCleanup(win.destroy)
2128 appview = win.get_data("appview")
2129 #entry = win.get_data("entry")
2130 do_events()
2131@@ -99,12 +96,6 @@
2132 in_model.append(model.get_value(item.iter, 0))
2133 self.assertEqual(expected_normal, in_model)
2134
2135- # destroy
2136- win.destroy()
2137-
2138-
2139
2140 if __name__ == "__main__":
2141- #import logging
2142- #logging.basicConfig(level=logging.DEBUG)
2143 unittest.main()
2144
2145=== modified file 'tests/gtk3/test_appdetailsview.py'
2146--- test/gtk3/test_appdetailsview.py 2012-04-17 14:27:43 +0000
2147+++ tests/gtk3/test_appdetailsview.py 2012-06-11 15:00:29 +0000
2148@@ -1,38 +1,43 @@
2149-#!/usr/bin/python
2150-
2151 import unittest
2152
2153-from gi.repository import Gtk, GObject
2154 from gettext import gettext as _
2155
2156-from testutils import setup_test_env
2157+from tests.utils import (
2158+ do_events,
2159+ get_mock_app_from_real_app,
2160+ get_test_db,
2161+ make_recommend_app_data,
2162+ setup_test_env,
2163+)
2164 setup_test_env()
2165
2166 from mock import Mock, patch
2167
2168 from softwarecenter.db.application import Application
2169-from softwarecenter.testutils import get_mock_app_from_real_app, do_events, make_recommend_app_data
2170+from softwarecenter.enums import PkgStates
2171 from softwarecenter.ui.gtk3.widgets.labels import HardwareRequirementsBox
2172-from softwarecenter.ui.gtk3.views.appdetailsview import get_test_window_appdetails
2173-from softwarecenter.enums import PkgStates
2174 from softwarecenter.region import REGION_WARNING_STRING
2175-
2176-from test.test_database import make_purchased_app_details
2177-
2178-
2179-
2180-# window destory timeout
2181-TIMEOUT=100
2182-
2183-class TestAppdetailsView(unittest.TestCase):
2184+from tests.gtk3.windows import get_test_window_appdetails
2185+from tests.test_database import make_purchased_app_details
2186+
2187+
2188+class BaseViewTestCase(unittest.TestCase):
2189+
2190+ db = get_test_db()
2191+ app_name = "software-center"
2192+ pkg_state = PkgStates.UNINSTALLED
2193
2194 def setUp(self):
2195 self.win = get_test_window_appdetails()
2196+ self.addCleanup(self.win.destroy)
2197 self.view = self.win.get_data("view")
2198
2199- def tearDown(self):
2200- GObject.timeout_add(TIMEOUT, lambda: self.win.destroy())
2201- Gtk.main()
2202+ app = Application("", self.app_name)
2203+ self.app_mock = get_mock_app_from_real_app(app)
2204+ self.app_mock.details.pkg_state = self.pkg_state
2205+
2206+
2207+class TestAppdetailsView(BaseViewTestCase):
2208
2209 def test_videoplayer(self):
2210 # show app with no video
2211@@ -50,13 +55,13 @@
2212 self.view.show_app(mock)
2213 do_events()
2214 self.assertTrue(self.view.videoplayer.get_property("visible"))
2215-
2216+
2217 def test_page_pkgstates(self):
2218- # show app
2219+ # show app
2220 app = Application("", "abiword")
2221 self.view.show_app(app)
2222 do_events()
2223-
2224+
2225 # check that the action bar is given initial focus in the view
2226 self.assertTrue(self.view.pkg_statusbar.button.is_focus())
2227
2228@@ -74,10 +79,11 @@
2229 # the states and what labels we expect in the pkgstatusbar
2230 # first string is status text, second is button text
2231 pkg_states_to_labels = {
2232- PkgStates.INSTALLED : ("Purchased on 2011-11-20", "Remove"),
2233- PkgStates.UNINSTALLED : ('Free', 'Install'),
2234- PkgStates.NEEDS_PURCHASE : ('US$ 1.00', u'Buy\u2026'),
2235- PkgStates.PURCHASED_BUT_REPO_MUST_BE_ENABLED : ('Purchased on 2011-11-20', 'Install'),
2236+ PkgStates.INSTALLED: ("Purchased on 2011-11-20", "Remove"),
2237+ PkgStates.UNINSTALLED: ('Free', 'Install'),
2238+ PkgStates.NEEDS_PURCHASE: ('US$ 1.00', u'Buy\u2026'),
2239+ PkgStates.PURCHASED_BUT_REPO_MUST_BE_ENABLED:
2240+ ('Purchased on 2011-11-20', 'Install'),
2241 }
2242 # this describes if a button is visible or invisible
2243 button_invisible = [ PkgStates.ERROR,
2244@@ -101,7 +107,7 @@
2245 if state in pkg_states_to_labels:
2246 label, button_label = pkg_states_to_labels[state]
2247 self.assertEqual(
2248- self.view.pkg_statusbar.get_label(),
2249+ self.view.pkg_statusbar.get_label(),
2250 label.decode("utf-8"))
2251 self.assertEqual(
2252 self.view.pkg_statusbar.get_button_label().decode("utf-8"),
2253@@ -117,8 +123,8 @@
2254 "button visible error for state %s" % state)
2255 # regression test for #955005
2256 if state == PkgStates.NOT_FOUND:
2257- self.assertFalse(self.view.review_stats.get_property("visible"))
2258- self.assertFalse(self.view.reviews.get_property("visible"))
2259+ self.assertFalse(self.view.review_stats.get_visible())
2260+ self.assertFalse(self.view.reviews.get_visible())
2261
2262 def test_app_icon_loading(self):
2263 # get icon
2264@@ -142,22 +148,21 @@
2265 self.view.show_app(app)
2266 self.view._add_where_is_it_commandline("apt")
2267 do_events()
2268- self.view._add_where_is_it_launcher("/usr/share/applications/ubuntu-software-center.desktop")
2269+ self.view._add_where_is_it_launcher(
2270+ "/usr/share/applications/ubuntu-software-center.desktop")
2271 do_events()
2272
2273 def test_reviews_page(self):
2274- win = get_test_window_appdetails()
2275- view = win.get_data("view")
2276 # show s-c and click on more review
2277 app = Application("", "software-center")
2278- view.show_app(app)
2279- self.assertEqual(view._reviews_server_page, 1)
2280- view._on_more_reviews_clicked(None)
2281- self.assertEqual(view._reviews_server_page, 2)
2282+ self.view.show_app(app)
2283+ self.assertEqual(self.view._reviews_server_page, 1)
2284+ self.view._on_more_reviews_clicked(None)
2285+ self.assertEqual(self.view._reviews_server_page, 2)
2286 # show different app, ensure page is reset
2287 app = Application("", "apt")
2288- view.show_app(app)
2289- self.assertEqual(view._reviews_server_page, 1)
2290+ self.view.show_app(app)
2291+ self.assertEqual(self.view._reviews_server_page, 1)
2292
2293 def test_human_readable_name_in_view(self):
2294 model = self.view.reviews.review_language.get_model()
2295@@ -236,6 +241,8 @@
2296
2297 @patch('softwarecenter.backend.spawn_helper.SpawnHelper.run')
2298 def test_submit_new_review_disables_button(self, mock_run):
2299+ app = Application("", "2vcard")
2300+ self.view.show_app(app)
2301 button = self.view.reviews.new_review
2302 self.assertTrue(button.is_sensitive())
2303
2304@@ -250,35 +257,16 @@
2305 self.view._submit_reviews_done_callback(None, 0)
2306
2307 self.assertTrue(button.is_sensitive())
2308-
2309-
2310-class MultipleVersionsTestCase(unittest.TestCase):
2311-
2312- @classmethod
2313- def setUpClass(cls):
2314- # Set these as class attributes as we don't modify either
2315- # during the tests.
2316- from softwarecenter.testutils import get_test_db
2317- cls.db = get_test_db()
2318- cls.win = get_test_window_appdetails()
2319- cls.view = cls.win.get_data("view")
2320-
2321- @classmethod
2322- def tearDownClass(cls):
2323- GObject.timeout_add(TIMEOUT, lambda: cls.win.destroy())
2324- Gtk.main()
2325-
2326- def setUp(self):
2327- app = Application("", "software-center")
2328- self.app_mock = get_mock_app_from_real_app(app)
2329- self.app_mock.details.pkg_state = PkgStates.UNINSTALLED
2330+
2331+
2332+class MultipleVersionsTestCase(BaseViewTestCase):
2333
2334 def test_multiple_versions_automatic_button(self):
2335 # normal app
2336 self.view.show_app(self.app_mock)
2337 self.assertFalse(self.view.pkg_statusbar.combo_multiple_versions.get_visible())
2338 # switch to not-automatic app with different description
2339- self.app_mock.details.get_not_automatic_archive_versions = lambda: [
2340+ self.app_mock.details.get_not_automatic_archive_versions = lambda: [
2341 ("5.0", "precise"),
2342 ("12.0", "precise-backports"),
2343 ]
2344@@ -290,7 +278,7 @@
2345 def test_combo_multiple_versions(self):
2346 self.app_mock.details.get_not_automatic_archive_versions = lambda: [
2347 ("5.0", "precise"),
2348- ("12.0", "precise-backports")
2349+ ("12.0", "precise-backports")
2350 ]
2351 # ensure that the right method is called
2352 self.app_mock.details.force_not_automatic_archive_suite = Mock()
2353@@ -305,7 +293,7 @@
2354 def test_installed_multiple_version_default(self):
2355 self.app_mock.details.get_not_automatic_archive_versions = lambda: [
2356 ("5.0", "precise"),
2357- ("12.0", "precise-backports")
2358+ ("12.0", "precise-backports")
2359 ]
2360 self.app_mock.details.pkg_state = PkgStates.INSTALLED
2361 self.app_mock.details.version = "12.0"
2362@@ -332,33 +320,14 @@
2363 #self.assertEqual(call_args, (("precise",), {}))
2364 # ensure the button changes
2365 self.assertEqual(self.view.pkg_statusbar.button.get_label(), "Change")
2366-
2367-
2368-class HardwareRequirementsTestCase(unittest.TestCase):
2369-
2370- @classmethod
2371- def setUpClass(cls):
2372- # Set these as class attributes as we don't modify either
2373- # during the tests.
2374- from softwarecenter.testutils import get_test_db
2375- cls.db = get_test_db()
2376- cls.win = get_test_window_appdetails()
2377- cls.view = cls.win.get_data("view")
2378-
2379- @classmethod
2380- def tearDownClass(cls):
2381- GObject.timeout_add(TIMEOUT, lambda: cls.win.destroy())
2382- Gtk.main()
2383-
2384- def setUp(self):
2385- app = Application("", "software-center")
2386- self.app_mock = get_mock_app_from_real_app(app)
2387- self.app_mock.details.pkg_state = PkgStates.UNINSTALLED
2388+
2389+
2390+class HardwareRequirementsTestCase(BaseViewTestCase):
2391
2392 def test_show_hardware_requirements(self):
2393- self.app_mock.details.hardware_requirements = {
2394- 'hardware::video:opengl' : 'yes',
2395- 'hardware::gps' : 'no',
2396+ self.app_mock.details.hardware_requirements = {
2397+ 'hardware::video:opengl': 'yes',
2398+ 'hardware::gps': 'no',
2399 }
2400 self.app_mock.details.hardware_requirements_satisfied = False
2401 self.view.show_app(self.app_mock)
2402@@ -378,7 +347,7 @@
2403 self.app_mock.details.pkg_state = PkgStates.NEEDS_PURCHASE
2404 self.view.show_app(self.app_mock)
2405 self.assertEqual(
2406- self.view.pkg_statusbar.button.get_label(),
2407+ self.view.pkg_statusbar.button.get_label(),
2408 _(u"Buy Anyway\u2026").encode("utf-8"))
2409 # check if the warning bar is displayed
2410 self.assertTrue(self.view.pkg_warningbar.get_property("visible"))
2411@@ -401,31 +370,13 @@
2412 self.app_mock.details.pkg_state = PkgStates.NEEDS_PURCHASE
2413 self.view.show_app(self.app_mock)
2414 self.assertEqual(
2415- self.view.pkg_statusbar.button.get_label(),
2416+ self.view.pkg_statusbar.button.get_label(),
2417 _(u'Buy\u2026').encode("utf-8"))
2418 # check if the warning bar is invisible
2419 self.assertFalse(self.view.pkg_warningbar.get_property("visible"))
2420
2421-class RegionRequirementsTestCase(unittest.TestCase):
2422-
2423- @classmethod
2424- def setUpClass(cls):
2425- # Set these as class attributes as we don't modify either
2426- # during the tests.
2427- from softwarecenter.testutils import get_test_db
2428- cls.db = get_test_db()
2429- cls.win = get_test_window_appdetails()
2430- cls.view = cls.win.get_data("view")
2431-
2432- @classmethod
2433- def tearDownClass(cls):
2434- GObject.timeout_add(TIMEOUT, lambda: cls.win.destroy())
2435- Gtk.main()
2436-
2437- def setUp(self):
2438- app = Application("", "software-center")
2439- self.app_mock = get_mock_app_from_real_app(app)
2440- self.app_mock.details.pkg_state = PkgStates.UNINSTALLED
2441+
2442+class RegionRequirementsTestCase(BaseViewTestCase):
2443
2444 def test_show_region_requirements(self):
2445 self.app_mock.details.region_requirements_satisfied = False
2446@@ -438,7 +389,7 @@
2447 self.app_mock.details.pkg_state = PkgStates.NEEDS_PURCHASE
2448 self.view.show_app(self.app_mock)
2449 self.assertEqual(
2450- self.view.pkg_statusbar.button.get_label(),
2451+ self.view.pkg_statusbar.button.get_label(),
2452 _(u"Buy Anyway\u2026").encode("utf-8"))
2453 # check if the warning bar is displayed
2454 self.assertTrue(self.view.pkg_warningbar.get_property("visible"))
2455@@ -446,20 +397,7 @@
2456 REGION_WARNING_STRING)
2457
2458
2459-class PurchasedAppDetailsStatusBarTestCase(unittest.TestCase):
2460-
2461- @classmethod
2462- def setUpClass(cls):
2463- # Set these as class attributes as we don't modify either
2464- # during the tests.
2465- from softwarecenter.testutils import get_test_db
2466- cls.db = get_test_db()
2467- cls.win = get_test_window_appdetails()
2468-
2469- @classmethod
2470- def tearDownClass(cls):
2471- GObject.timeout_add(TIMEOUT, lambda: cls.win.destroy())
2472- Gtk.main()
2473+class PurchasedAppDetailsStatusBarTestCase(BaseViewTestCase):
2474
2475 def _make_statusbar_view_for_state(self, state):
2476 app_details = make_purchased_app_details(db=self.db)
2477@@ -537,34 +475,18 @@
2478 self.assertEqual(
2479 [method_name],
2480 all_method_calls)
2481-
2482-class AppRecommendationsTestCase(unittest.TestCase):
2483-
2484- @classmethod
2485- def setUpClass(cls):
2486- # Set these as class attributes as we don't modify either
2487- # during the tests.
2488- cls.win = get_test_window_appdetails()
2489- cls.view = cls.win.get_data("view")
2490- from softwarecenter.testutils import get_test_db
2491- cls.db = get_test_db()
2492-
2493- @classmethod
2494- def tearDownClass(cls):
2495- GObject.timeout_add(TIMEOUT, lambda: cls.win.destroy())
2496- Gtk.main()
2497-
2498- def setUp(self):
2499- app = Application("", "pitivi")
2500- self.app_mock = get_mock_app_from_real_app(app)
2501- self.app_mock.details.pkg_state = PkgStates.UNINSTALLED
2502-
2503+
2504+
2505+class AppRecommendationsTestCase(BaseViewTestCase):
2506+
2507+ app_name = "pitivi"
2508+
2509 def on_query_done(self, recagent, data):
2510- print "query done, data: '%s'" % data
2511+ # print "query done, data: '%s'" % data
2512 self.loop.quit()
2513-
2514+
2515 def on_query_error(self, recagent, error):
2516- print "query error received: ", error
2517+ # print "query error received: ", error
2518 self.loop.quit()
2519 self.error = True
2520
2521@@ -574,17 +496,15 @@
2522 def test_show_recommendations_for_app(self, mock_query):
2523 self.view.show_app(self.app_mock)
2524 do_events()
2525- self.view.recommended_for_app_panel._update_app_recommendations_content()
2526+ panel = self.view.recommended_for_app_panel
2527+ panel._update_app_recommendations_content()
2528 do_events()
2529 # we fake the callback from the agent here
2530- self.view.recommended_for_app_panel.app_recommendations_cat._recommend_app_result(
2531- None,
2532+ panel.app_recommendations_cat._recommend_app_result(None,
2533 make_recommend_app_data())
2534 self.assertNotEqual(
2535- self.view.recommended_for_app_panel.app_recommendations_cat.get_documents(self.db), [])
2536+ panel.app_recommendations_cat.get_documents(self.db), [])
2537
2538
2539 if __name__ == "__main__":
2540- import logging
2541- logging.basicConfig(level=logging.DEBUG)
2542 unittest.main()
2543
2544=== modified file 'tests/gtk3/test_appmanager.py'
2545--- test/gtk3/test_appmanager.py 2012-01-16 14:42:49 +0000
2546+++ tests/gtk3/test_appmanager.py 2012-06-11 15:00:29 +0000
2547@@ -1,19 +1,22 @@
2548-#!/usr/bin/python
2549+import unittest
2550
2551 from mock import Mock
2552-import unittest
2553
2554-from testutils import setup_test_env
2555+from tests.utils import (
2556+ do_events,
2557+ get_test_db,
2558+ get_test_gtk3_icon_cache,
2559+ setup_test_env,
2560+)
2561 setup_test_env()
2562
2563 import softwarecenter.paths
2564 from softwarecenter.db.application import Application
2565 from softwarecenter.distro import get_distro
2566-from softwarecenter.testutils import (
2567- get_test_db, get_test_gtk3_icon_cache, do_events)
2568 from softwarecenter.ui.gtk3.session.appmanager import (
2569 ApplicationManager, get_appmanager)
2570
2571+
2572 class TestAppManager(unittest.TestCase):
2573 """ tests the appmanager """
2574
2575@@ -38,7 +41,7 @@
2576 # test creating it twice raises a error
2577 self.assertRaises(
2578 ValueError, ApplicationManager, self.db, self.backend, self.icons)
2579-
2580+
2581 def test_appmanager(self):
2582 app_manager = get_appmanager()
2583 self.assertNotEqual(app_manager, None)
2584@@ -74,6 +77,4 @@
2585 self._purchase_requested_signal = True
2586
2587 if __name__ == "__main__":
2588- import logging
2589- logging.basicConfig(level=logging.DEBUG)
2590 unittest.main()
2591
2592=== modified file 'tests/gtk3/test_appstore2.py'
2593--- test/gtk3/test_appstore2.py 2012-06-06 04:42:07 +0000
2594+++ tests/gtk3/test_appstore2.py 2012-06-11 15:00:29 +0000
2595@@ -1,20 +1,20 @@
2596-#!/usr/bin/python
2597-
2598 import unittest
2599 import xapian
2600
2601-from gi.repository import Gtk
2602 from mock import Mock, patch
2603
2604-from testutils import setup_test_env
2605+from tests.utils import (
2606+ do_events,
2607+ get_test_db,
2608+ get_test_gtk3_icon_cache,
2609+ get_test_pkg_info,
2610+ setup_test_env,
2611+)
2612 setup_test_env()
2613+
2614 from softwarecenter.ui.gtk3.models.appstore2 import AppListStore
2615 from softwarecenter.db.enquire import AppEnquire
2616
2617-from softwarecenter.testutils import (get_test_db,
2618- get_test_pkg_info,
2619- get_test_gtk3_icon_cache,
2620- )
2621
2622 class AppStoreTestCase(unittest.TestCase):
2623 """ test the appstore """
2624@@ -27,7 +27,7 @@
2625
2626 def test_lp872760(self):
2627 def monkey_(s):
2628- translations = {
2629+ translations = {
2630 "Painting &amp; Editing" : "translation for Painting &amp; "
2631 "Editing",
2632 }
2633@@ -62,14 +62,13 @@
2634 # ensure buffer_icons works and loads stuff into the cache
2635 model.buffer_icons()
2636 self.assertEqual(len(model.icon_cache), 0)
2637- while Gtk.events_pending():
2638- Gtk.main_iteration()
2639+ do_events()
2640 self.assertTrue(len(model.icon_cache) > 0)
2641
2642 # ensure clear works
2643 model.clear()
2644 self.assertEqual(model.current_matches, None)
2645-
2646+
2647 def test_lp971776(self):
2648 """ ensure that refresh is not called for invalid image files """
2649 model = AppListStore(self.db, self.cache, self.icons)
2650@@ -78,6 +77,4 @@
2651 self.assertFalse(model.emit.called)
2652
2653 if __name__ == "__main__":
2654- import logging
2655- logging.basicConfig(level=logging.DEBUG)
2656 unittest.main()
2657
2658=== modified file 'tests/gtk3/test_catview.py'
2659--- test/gtk3/test_catview.py 2012-06-06 11:31:51 +0000
2660+++ tests/gtk3/test_catview.py 2012-06-11 15:00:29 +0000
2661@@ -3,26 +3,28 @@
2662 from gi.repository import Gtk
2663 from mock import patch, Mock
2664
2665-from testutils import setup_test_env
2666-setup_test_env()
2667-
2668-import softwarecenter.distro
2669-import softwarecenter.paths
2670-
2671-from softwarecenter.db.database import StoreDatabase
2672-from softwarecenter.enums import SortMethods
2673-from softwarecenter.testutils import (
2674+from tests.utils import (
2675+ do_events,
2676 do_events_with_sleep,
2677- do_events,
2678 FakedCache,
2679 get_test_db,
2680+ get_test_gtk3_icon_cache,
2681 make_recommender_agent_recommend_me_dict,
2682 ObjectWithSignals,
2683+ setup_test_env,
2684 )
2685+setup_test_env()
2686+
2687+import softwarecenter.distro
2688+import softwarecenter.paths
2689+
2690+from softwarecenter.db.appfilter import AppFilter
2691+from softwarecenter.db.database import StoreDatabase
2692+from softwarecenter.enums import SortMethods
2693 from softwarecenter.ui.gtk3.views import catview_gtk
2694-from softwarecenter.ui.gtk3.views.catview_gtk import get_test_window_catview
2695 from softwarecenter.ui.gtk3.widgets.containers import FramedHeaderBox
2696 from softwarecenter.ui.gtk3.widgets.spinner import SpinnerNotebook
2697+from tests.gtk3.windows import get_test_window_catview
2698
2699
2700 class CatViewBaseTestCase(unittest.TestCase):
2701@@ -78,23 +80,18 @@
2702 def test_new_no_sort_info_yet(self):
2703 # ensure that we don't show a empty "whats new" category
2704 # see LP: #865985
2705- from softwarecenter.testutils import get_test_db
2706 db = get_test_db()
2707 cache = db._aptcache
2708 # simulate a fresh install with no catalogedtime info
2709 del db._axi_values["catalogedtime"]
2710
2711- from softwarecenter.testutils import get_test_gtk3_icon_cache
2712 icons = get_test_gtk3_icon_cache()
2713
2714- from softwarecenter.db.appfilter import AppFilter
2715 apps_filter = AppFilter(db, cache)
2716
2717- from softwarecenter.distro import get_distro
2718- from softwarecenter.ui.gtk3.views.catview_gtk import LobbyViewGtk
2719- view = LobbyViewGtk(softwarecenter.paths.datadir,
2720- softwarecenter.paths.APP_INSTALL_PATH,
2721- cache, db, icons, get_distro(), apps_filter)
2722+ view = catview_gtk.LobbyViewGtk(softwarecenter.paths.datadir,
2723+ softwarecenter.paths.APP_INSTALL_PATH, cache, db, icons,
2724+ softwarecenter.distro.get_distro(), apps_filter)
2725 view.show()
2726
2727 # gui
2728@@ -117,14 +114,14 @@
2729
2730 # FIXME: reenable
2731 @unittest.skip("Disabled because of race condition in test")
2732+ @patch('softwarecenter.ui.gtk3.widgets.recommendations.get_sso_backend')
2733 @patch('softwarecenter.backend.recagent.RecommenderAgent.is_opted_in')
2734- def test_recommended_for_you_opt_in_display(
2735- self, mock_get_recommender_opted_in):
2736+ def test_recommended_for_you_opt_in_display(self,
2737+ mock_get_recommender_opted_in, mock_sso):
2738 # patch the recommender UUID value to ensure that we are not opted-in
2739 # for this test
2740 mock_get_recommender_opted_in.return_value = False
2741
2742- do_events_with_sleep()
2743 self.assertEqual(self.rec_panel.spinner_notebook.get_current_page(),
2744 FramedHeaderBox.CONTENT)
2745 self.assertTrue(self.rec_panel.opt_in_vbox.get_property("visible"))
2746@@ -132,11 +129,12 @@
2747 # FIXME: reenable
2748 @unittest.skip("Disabled because of race condition in test")
2749 # patch out the agent query method to avoid making the actual server call
2750+ @patch('softwarecenter.ui.gtk3.widgets.recommendations.get_sso_backend')
2751 @patch('softwarecenter.backend.recagent.RecommenderAgent.is_opted_in')
2752 @patch('softwarecenter.backend.recagent.RecommenderAgent'
2753 '.post_submit_profile')
2754- def test_recommended_for_you_spinner_display(
2755- self, mock_query, mock_get_recommender_opted_in):
2756+ def test_recommended_for_you_spinner_display(self,
2757+ mock_query, mock_get_recommender_opted_in, mock_sso):
2758 # patch the recommender UUID value to insure that we are not opted-in
2759 # for this test
2760 mock_get_recommender_opted_in.return_value = False
2761@@ -147,14 +145,15 @@
2762 do_events_with_sleep()
2763 self.assertEqual(self.rec_panel.spinner_notebook.get_current_page(),
2764 SpinnerNotebook.SPINNER_PAGE)
2765- self.assertTrue(self.rec_panel.opt_in_vbox.get_property("visible"))
2766+ self.assertTrue(self.rec_panel.opt_in_vbox.get_visible())
2767
2768 # patch out the agent query method to avoid making the actual server call
2769+ @patch('softwarecenter.ui.gtk3.widgets.recommendations.get_sso_backend')
2770 @patch('softwarecenter.backend.recagent.RecommenderAgent.is_opted_in')
2771 @patch('softwarecenter.backend.recagent.RecommenderAgent'
2772 '.post_submit_profile')
2773 def test_recommended_for_you_display_recommendations(self,
2774- mock_query, mock_get_recommender_opted_in):
2775+ mock_query, mock_get_recommender_opted_in, mock_sso):
2776 # patch the recommender UUID value to insure that we are not opted-in
2777 # for this test
2778 mock_get_recommender_opted_in.return_value = False
2779@@ -182,11 +181,12 @@
2780 self.assertEqual(self._cat.name, "Recommended For You")
2781
2782 # patch out the agent query method to avoid making the actual server call
2783+ @patch('softwarecenter.ui.gtk3.widgets.recommendations.get_sso_backend')
2784 @patch('softwarecenter.backend.recagent.RecommenderAgent.is_opted_in')
2785 @patch('softwarecenter.backend.recagent.RecommenderAgent'
2786 '.query_recommend_me')
2787 def test_recommended_for_you_display_recommendations_not_opted_in(self,
2788- mock_query, mock_get_recommender_opted_in):
2789+ mock_query, mock_get_recommender_opted_in, mock_sso):
2790 # patch the recommender UUID value to insure that we are not opted-in
2791 # for this test
2792 mock_get_recommender_opted_in.return_value = False
2793@@ -200,11 +200,12 @@
2794 self.assertFalse(visible)
2795
2796 # patch out the agent query method to avoid making the actual server call
2797+ @patch('softwarecenter.ui.gtk3.widgets.recommendations.get_sso_backend')
2798 @patch('softwarecenter.backend.recagent.RecommenderAgent.is_opted_in')
2799 @patch('softwarecenter.backend.recagent.RecommenderAgent'
2800 '.query_recommend_me')
2801- def test_recommended_for_you_display_recommendations_opted_in(
2802- self, mock_query, mock_get_recommender_opted_in):
2803+ def test_recommended_for_you_display_recommendations_opted_in(self,
2804+ mock_query, mock_get_recommender_opted_in, mock_sso):
2805 # patch the recommender UUID value to insure that we are not opted-in
2806 # for this test
2807 mock_get_recommender_opted_in.return_value = True
2808@@ -229,12 +230,11 @@
2809 self.assertEqual(rec_cat_panel.spinner_notebook.get_current_page(),
2810 SpinnerNotebook.CONTENT_PAGE)
2811 # check that the tiles themselves are visible
2812- do_events()
2813 self.assertTrue(rec_cat_panel.recommended_for_you_content.get_property(
2814 "visible"))
2815 self.assertTrue(rec_cat_panel.recommended_for_you_content.get_children(
2816 )[0].title.get_property("visible"))
2817- do_events()
2818+
2819 # test clicking recommended_for_you More button
2820 self.subcat_view.connect(
2821 "category-selected", self._on_category_selected)
2822@@ -330,6 +330,4 @@
2823
2824
2825 if __name__ == "__main__":
2826- #import logging
2827- #logging.basicConfig(level=logging.DEBUG)
2828 unittest.main()
2829
2830=== modified file 'tests/gtk3/test_custom_lists.py'
2831--- test/gtk3/test_custom_lists.py 2012-01-16 14:42:49 +0000
2832+++ tests/gtk3/test_custom_lists.py 2012-06-11 15:00:29 +0000
2833@@ -1,61 +1,43 @@
2834-#!/usr/bin/python
2835-
2836-from gi.repository import Gtk, GObject
2837-import time
2838 import unittest
2839
2840-from testutils import setup_test_env
2841+from tests.utils import (
2842+ do_events_with_sleep,
2843+ setup_test_env,
2844+)
2845 setup_test_env()
2846
2847 from softwarecenter.enums import XapianValues, ActionButtons
2848+from tests.gtk3.windows import get_test_window_availablepane
2849
2850-TIMEOUT=300
2851
2852 class TestCustomLists(unittest.TestCase):
2853
2854- def _debug(self, index, model, needle):
2855- print ("Expected '%s' at index '%s', " +
2856- "and custom list contained: '%s'") % (
2857- needle, index, model[index][0].get_value(XapianValues.PKGNAME))
2858-
2859 def assertPkgInListAtIndex(self, index, model, needle):
2860- doc = model[index][0]
2861- self.assertEqual(doc.get_value(XapianValues.PKGNAME),
2862- needle, self._debug(index, model, needle))
2863+ doc_name = model[index][0].get_value(XapianValues.PKGNAME)
2864+ msg = "Expected %r at index %r, and custom list contained: %r"
2865+ self.assertEqual(doc_name, needle, msg % (needle, index, doc_name))
2866
2867 def test_custom_lists(self):
2868- from softwarecenter.ui.gtk3.panes.availablepane import get_test_window
2869- win = get_test_window()
2870+ win = get_test_window_availablepane()
2871+ self.addCleanup(win.destroy)
2872 pane = win.get_data("pane")
2873- self._p()
2874+ do_events_with_sleep()
2875 pane.on_search_terms_changed(None, "ark,artha,software-center")
2876- self._p()
2877+ do_events_with_sleep()
2878 model = pane.app_view.tree_view.get_model()
2879-
2880+
2881 # custom list should return three items
2882 self.assertTrue(len(model) == 3)
2883-
2884+
2885 # check package names, ordering is default "by relevance"
2886 self.assertPkgInListAtIndex(0, model, "ark")
2887 self.assertPkgInListAtIndex(1, model, "software-center")
2888 self.assertPkgInListAtIndex(2, model, "artha")
2889-
2890+
2891 # check that the status bar offers to install the packages
2892 install_button = pane.action_bar.get_button(ActionButtons.INSTALL)
2893 self.assertNotEqual(install_button, None)
2894-
2895- GObject.timeout_add(TIMEOUT, lambda: win.destroy())
2896- Gtk.main()
2897-
2898- def _p(self):
2899- for i in range(10):
2900- time.sleep(0.1)
2901- while Gtk.events_pending():
2902- Gtk.main_iteration()
2903
2904
2905 if __name__ == "__main__":
2906- import logging
2907- logging.basicConfig(level=logging.INFO)
2908 unittest.main()
2909-
2910
2911=== modified file 'tests/gtk3/test_debfile_view.py'
2912--- test/gtk3/test_debfile_view.py 2012-04-17 16:32:09 +0000
2913+++ tests/gtk3/test_debfile_view.py 2012-06-11 15:00:29 +0000
2914@@ -1,9 +1,11 @@
2915-#!/usr/bin/python
2916-
2917 import time
2918 import unittest
2919
2920-from testutils import do_events, get_mock_options, setup_test_env
2921+from tests.utils import (
2922+ do_events,
2923+ get_mock_options,
2924+ setup_test_env,
2925+)
2926 setup_test_env()
2927
2928 import softwarecenter.paths
2929
2930=== modified file 'tests/gtk3/test_dialogs.py'
2931--- test/gtk3/test_dialogs.py 2012-03-15 13:08:19 +0000
2932+++ tests/gtk3/test_dialogs.py 2012-06-11 15:00:29 +0000
2933@@ -1,33 +1,32 @@
2934-#!/usr/bin/python
2935+import unittest
2936
2937 from gi.repository import Gtk, GObject
2938-import unittest
2939-
2940-from testutils import setup_test_env
2941+from tests.utils import setup_test_env
2942 setup_test_env()
2943
2944 import softwarecenter.ui.gtk3.dialogs
2945+from tests.gtk3.windows import get_test_window_dependency_dialog
2946
2947 # window destory timeout
2948 TIMEOUT=200
2949
2950+
2951 class TestDialogs(unittest.TestCase):
2952 """ basic tests for the various gtk3 dialogs """
2953
2954- def test_dependency_dialogs(self):
2955- from softwarecenter.ui.gtk3.dialogs.dependency_dialogs import get_test_dialog
2956- dia = get_test_dialog()
2957- GObject.timeout_add(TIMEOUT,
2958+ def get_test_window_dependency_dialog(self):
2959+ dia = get_test_window_dependency_dialog()
2960+ GObject.timeout_add(TIMEOUT,
2961 lambda: dia.response(Gtk.ResponseType.ACCEPT))
2962 dia.run()
2963-
2964+
2965 def test_confirm_repair_broken_cache(self):
2966 datadir = softwarecenter.paths.datadir
2967 GObject.timeout_add(TIMEOUT, self._close_dialog)
2968 res = softwarecenter.ui.gtk3.dialogs.confirm_repair_broken_cache(
2969 parent=None, datadir=datadir)
2970 self.assertEqual(res, False)
2971-
2972+
2973 def test_error_dialog(self):
2974 GObject.timeout_add(TIMEOUT, self._close_dialog)
2975 res = softwarecenter.ui.gtk3.dialogs.error(
2976@@ -39,12 +38,10 @@
2977 res = softwarecenter.ui.gtk3.dialogs.show_accept_tos_dialog(
2978 parent=None)
2979 self.assertEqual(res, False)
2980-
2981+
2982 # helper
2983 def _close_dialog(self):
2984 softwarecenter.ui.gtk3.dialogs._DIALOG.response(0)
2985
2986 if __name__ == "__main__":
2987- import logging
2988- logging.basicConfig(level=logging.DEBUG)
2989 unittest.main()
2990
2991=== modified file 'tests/gtk3/test_globalpane.py'
2992--- test/gtk3/test_globalpane.py 2012-01-16 14:42:49 +0000
2993+++ tests/gtk3/test_globalpane.py 2012-06-11 15:00:29 +0000
2994@@ -1,17 +1,19 @@
2995-#!/usr/bin/python
2996-
2997 import unittest
2998
2999-from testutils import setup_test_env
3000+from tests.utils import (
3001+ do_events,
3002+ setup_test_env,
3003+)
3004 setup_test_env()
3005
3006-from testutils import do_events
3007+from tests.gtk3.windows import get_test_window_globalpane
3008+
3009
3010 class TestGlobalPane(unittest.TestCase):
3011
3012 def test_spinner_available(self):
3013- from softwarecenter.ui.gtk3.panes.globalpane import get_test_window
3014- win = get_test_window()
3015+ win = get_test_window_globalpane()
3016+ self.addCleanup(win.destroy)
3017 pane = win.get_data("pane")
3018 self.assertNotEqual(pane.spinner, None)
3019 do_events()
3020
3021=== modified file 'tests/gtk3/test_install_progress.py'
3022--- test/gtk3/test_install_progress.py 2012-02-14 16:28:48 +0000
3023+++ tests/gtk3/test_install_progress.py 2012-06-11 15:00:29 +0000
3024@@ -1,44 +1,32 @@
3025-#!/usr/bin/python
3026-
3027-from gi.repository import Gtk
3028-import time
3029 import unittest
3030
3031-from testutils import setup_test_env
3032+from tests.utils import (
3033+ setup_test_env,
3034+ start_dummy_backend,
3035+ stop_dummy_backend,
3036+)
3037 setup_test_env()
3038
3039
3040 from softwarecenter.db.application import Application
3041-from softwarecenter.testutils import start_dummy_backend, stop_dummy_backend
3042+from tests.gtk3.windows import get_test_window_appdetails
3043
3044-TIMEOUT=300
3045
3046 class TestViews(unittest.TestCase):
3047
3048- def setUp(self):
3049+ def setUpNo(self):
3050 start_dummy_backend()
3051-
3052- def tearDown(self):
3053- stop_dummy_backend()
3054+ self.addCleanup(stop_dummy_backend)
3055
3056 def test_install_appdetails(self):
3057- from softwarecenter.ui.gtk3.views.appdetailsview import get_test_window_appdetails
3058 win = get_test_window_appdetails()
3059+ self.addCleanup(win.destroy)
3060 view = win.get_data("view")
3061 view.show_app(Application("", "2vcard"))
3062- self._p()
3063- app = view.app
3064- view.backend.install(app, "")
3065- self._p()
3066+ view.backend.emit('transaction-progress-changed',
3067+ view.app_details.pkgname, 10)
3068 self.assertTrue(view.pkg_statusbar.progress.get_property("visible"))
3069
3070- def _p(self):
3071- for i in range(20):
3072- time.sleep(0.1)
3073- while Gtk.events_pending():
3074- Gtk.main_iteration()
3075
3076 if __name__ == "__main__":
3077- import logging
3078- logging.basicConfig(level=logging.INFO)
3079 unittest.main()
3080
3081=== modified file 'tests/gtk3/test_installedpane.py'
3082--- test/gtk3/test_installedpane.py 2012-01-16 14:42:49 +0000
3083+++ tests/gtk3/test_installedpane.py 2012-06-11 15:00:29 +0000
3084@@ -1,60 +1,50 @@
3085-#!/usr/bin/python
3086-
3087-from gi.repository import Gtk, GObject
3088-import time
3089 import unittest
3090
3091-from testutils import setup_test_env
3092+from tests.utils import (
3093+ do_events_with_sleep,
3094+ setup_test_env,
3095+)
3096 setup_test_env()
3097
3098-TIMEOUT=300
3099+from tests.gtk3.windows import get_test_window_installedpane
3100+
3101
3102 class TestInstalledPane(unittest.TestCase):
3103
3104 def test_installedpane(self):
3105- from softwarecenter.ui.gtk3.panes.installedpane import get_test_window
3106- win = get_test_window()
3107+ win = get_test_window_installedpane()
3108+ self.addCleanup(win.destroy)
3109 installedpane = win.get_data("pane")
3110- self._p()
3111+ do_events_with_sleep()
3112 # safe initial show/hide label for later
3113 initial_actionbar_label = installedpane.action_bar._label_text
3114 # do simple search
3115 installedpane.on_search_terms_changed(None, "foo")
3116- self._p()
3117+ do_events_with_sleep()
3118 model = installedpane.app_view.tree_view.get_model()
3119 # FIXME: len(model) *only* counts the size of the top level
3120- # (category) hits. thats still ok, as non-apps will
3121+ # (category) hits. thats still ok, as non-apps will
3122 # add the "system" category
3123 len_only_apps = len(model)
3124 # set to show nonapps
3125 installedpane._show_nonapp_pkgs()
3126- self._p()
3127+ do_events_with_sleep()
3128 len_with_nonapps = len(model)
3129 self.assertTrue(len_with_nonapps > len_only_apps)
3130 # set to hide nonapps again and ensure the size matches the
3131 # previous one
3132 installedpane._hide_nonapp_pkgs()
3133- self._p()
3134+ do_events_with_sleep()
3135 self.assertEqual(len(model), len_only_apps)
3136 # clear sarch and ensure we get a expanded size again
3137 installedpane.on_search_terms_changed(None, "")
3138- self._p()
3139+ do_events_with_sleep()
3140 all_apps = len(model)
3141 self.assertTrue(all_apps > len_only_apps)
3142 # ensure we have the same show/hide info as initially
3143 self.assertEqual(initial_actionbar_label,
3144 installedpane.action_bar._label_text)
3145- GObject.timeout_add(TIMEOUT, lambda: win.destroy())
3146- Gtk.main()
3147-
3148- def _p(self):
3149- for i in range(10):
3150- time.sleep(0.1)
3151- while Gtk.events_pending():
3152- Gtk.main_iteration()
3153
3154
3155 if __name__ == "__main__":
3156- import logging
3157- logging.basicConfig(level=logging.INFO)
3158 unittest.main()
3159
3160=== modified file 'tests/gtk3/test_navhistory.py'
3161--- test/gtk3/test_navhistory.py 2012-04-16 21:51:02 +0000
3162+++ tests/gtk3/test_navhistory.py 2012-06-11 15:00:29 +0000
3163@@ -1,10 +1,8 @@
3164-#!/usr/bin/python
3165-
3166 import unittest
3167
3168 from mock import Mock
3169
3170-from testutils import setup_test_env
3171+from tests.utils import setup_test_env
3172 setup_test_env()
3173
3174 from softwarecenter.ui.gtk3.session.navhistory import (
3175@@ -25,6 +23,7 @@
3176 def has_focus(self):
3177 return False
3178
3179+
3180 class TestNavhistory(unittest.TestCase):
3181 """ basic tests for navigation history """
3182
3183@@ -207,6 +206,4 @@
3184
3185
3186 if __name__ == "__main__":
3187- import logging
3188- logging.basicConfig(level=logging.DEBUG)
3189 unittest.main()
3190
3191=== modified file 'tests/gtk3/test_panes.py'
3192--- test/gtk3/test_panes.py 2012-01-16 14:42:49 +0000
3193+++ tests/gtk3/test_panes.py 2012-06-11 15:00:29 +0000
3194@@ -1,58 +1,42 @@
3195-#!/usr/bin/python
3196-
3197-from gi.repository import Gtk, GObject
3198 import unittest
3199
3200-from testutils import setup_test_env
3201+from tests.utils import (
3202+ do_events,
3203+ setup_test_env,
3204+)
3205 setup_test_env()
3206
3207-TIMEOUT=300
3208+from tests.gtk3 import windows
3209+
3210
3211 class TestPanes(unittest.TestCase):
3212
3213 def test_availablepane(self):
3214- from softwarecenter.ui.gtk3.panes.availablepane import get_test_window
3215- win = get_test_window()
3216- GObject.timeout_add(TIMEOUT, lambda: win.destroy())
3217- Gtk.main()
3218+ win = windows.get_test_window_availablepane()
3219+ self.addCleanup(win.destroy)
3220
3221 def test_globalpane(self):
3222- from softwarecenter.ui.gtk3.panes.globalpane import get_test_window
3223- win = get_test_window()
3224- GObject.timeout_add(TIMEOUT, lambda: win.destroy())
3225- Gtk.main()
3226+ win = windows.get_test_window_globalpane()
3227+ self.addCleanup(win.destroy)
3228
3229 def test_pendingpane(self):
3230- from softwarecenter.ui.gtk3.panes.pendingpane import get_test_window
3231- win = get_test_window()
3232- GObject.timeout_add(TIMEOUT, lambda: win.destroy())
3233- Gtk.main()
3234+ win = windows.get_test_window_pendingpane()
3235+ self.addCleanup(win.destroy)
3236
3237 def test_historypane(self):
3238- from softwarecenter.ui.gtk3.panes.historypane import get_test_window
3239- win = get_test_window()
3240- GObject.timeout_add(TIMEOUT, lambda: win.destroy())
3241- Gtk.main()
3242+ win = windows.get_test_window_historypane()
3243+ self.addCleanup(win.destroy)
3244
3245 def test_installedpane(self):
3246- from softwarecenter.ui.gtk3.panes.installedpane import get_test_window
3247- win = get_test_window()
3248+ win = windows.get_test_window_installedpane()
3249+ self.addCleanup(win.destroy)
3250 pane = win.get_data("pane")
3251 # ensure it visible
3252 self.assertTrue(pane.get_property("visible"))
3253 # ensure the treeview is there and has data
3254- self._p()
3255+ do_events()
3256 self.assertTrue(len(pane.treefilter.get_model()) > 5)
3257- # schedule close
3258- GObject.timeout_add(TIMEOUT, lambda: win.destroy())
3259- Gtk.main()
3260-
3261- def _p(self):
3262- while Gtk.events_pending():
3263- Gtk.main_iteration()
3264
3265
3266 if __name__ == "__main__":
3267- import logging
3268- logging.basicConfig(level=logging.DEBUG)
3269 unittest.main()
3270
3271=== modified file 'tests/gtk3/test_purchase.py'
3272--- test/gtk3/test_purchase.py 2012-04-16 21:51:02 +0000
3273+++ tests/gtk3/test_purchase.py 2012-06-11 15:00:29 +0000
3274@@ -1,47 +1,51 @@
3275-#!/usr/bin/python
3276-
3277-import time
3278 import unittest
3279
3280 from mock import Mock, patch
3281
3282-from testutils import setup_test_env
3283+from tests.utils import (
3284+ do_events_with_sleep,
3285+ get_mock_options,
3286+ setup_test_env,
3287+)
3288 setup_test_env()
3289
3290-from softwarecenter.testutils import do_events, get_mock_options
3291+import softwarecenter.paths
3292+
3293+from softwarecenter.ui.gtk3.views import purchaseview
3294 from softwarecenter.ui.gtk3.app import SoftwareCenterAppGtk3
3295 from softwarecenter.ui.gtk3.panes.availablepane import AvailablePane
3296-import softwarecenter.paths
3297+from tests.gtk3.windows import get_test_window_purchaseview
3298+
3299
3300 class TestPurchase(unittest.TestCase):
3301
3302 def test_purchase_view_log_cleaner(self):
3303- import softwarecenter.ui.gtk3.views.purchaseview
3304- from softwarecenter.ui.gtk3.views.purchaseview import get_test_window_purchaseview
3305 win = get_test_window_purchaseview()
3306- self._p()
3307+ self.addCleanup(win.destroy)
3308+ do_events_with_sleep()
3309 # get the view
3310 view = win.get_data("view")
3311 # install the mock
3312- softwarecenter.ui.gtk3.views.purchaseview.LOG = mock = Mock()
3313+ purchaseview.LOG = mock = Mock()
3314 # run a "harmless" log message and ensure its logged normally
3315 view.wk.webkit.execute_script('console.log("foo")')
3316 self.assertTrue("foo" in mock.debug.call_args[0][0])
3317 mock.reset_mock()
3318
3319 # run a message that contains token info
3320- 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"}'
3321+ s = ('http://sca.razorgirl.info/subscriptions/19077/checkout_complete/'
3322+ ' @10: {"token_key": "hiddenXXXXXXXXXX", "consumer_secret": '
3323+ '"hiddenXXXXXXXXXXXX", "api_version": 2.0, "subscription_id": '
3324+ '19077, "consumer_key": "rKhNPBw", "token_secret": '
3325+ '"hiddenXXXXXXXXXXXXXXX"}')
3326 view.wk.webkit.execute_script("console.log('%s')" % s)
3327 self.assertTrue("skipping" in mock.debug.call_args[0][0])
3328 self.assertFalse("consumer_secret" in mock.debug.call_args[0][0])
3329 mock.reset_mock()
3330
3331- # run another one
3332- win.destroy()
3333-
3334 def test_purchase_view_tos(self):
3335- from softwarecenter.ui.gtk3.views.purchaseview import get_test_window_purchaseview
3336 win = get_test_window_purchaseview()
3337+ self.addCleanup(win.destroy)
3338 view = win.get_data("view")
3339 # install the mock
3340 mock_config = Mock()
3341@@ -54,50 +58,45 @@
3342 res = view.initiate_purchase(None, None)
3343 self.assertFalse(res)
3344 self.assertTrue(mock_func.called)
3345- win.destroy()
3346
3347 def test_spinner_emits_signals(self):
3348- from softwarecenter.ui.gtk3.views.purchaseview import get_test_window_purchaseview
3349 win = get_test_window_purchaseview()
3350- self._p()
3351+ self.addCleanup(win.destroy)
3352+ do_events_with_sleep()
3353 # get the view
3354 view = win.get_data("view")
3355 # ensure "purchase-needs-spinner" signals are send
3356 signal_mock = Mock()
3357 view.connect("purchase-needs-spinner", signal_mock)
3358 view.wk.webkit.load_uri("http://www.ubuntu.com/")
3359- self._p()
3360+ do_events_with_sleep()
3361 self.assertTrue(signal_mock.called)
3362- # run another one
3363- win.destroy()
3364
3365 def test_reinstall_previous_purchase_display(self):
3366 mock_options = get_mock_options()
3367 xapiandb = "/var/cache/software-center/"
3368 app = SoftwareCenterAppGtk3(
3369 softwarecenter.paths.datadir, xapiandb, mock_options)
3370+ self.addCleanup(app.destroy)
3371 # real app opens cache async
3372 app.cache.open()
3373- # show it
3374- app.window_main.show_all()
3375- app.available_pane.init_view()
3376- self._p()
3377- app.on_menuitem_reinstall_purchases_activate(None)
3378- # it can take a bit until the sso client is ready
3379- for i in range(100):
3380- if (app.available_pane.get_current_page() ==
3381- AvailablePane.Pages.LIST):
3382- break
3383- self._p()
3384- self.assertEqual(
3385- app.available_pane.get_current_page(), AvailablePane.Pages.LIST)
3386+ # no real sso
3387+ with patch.object(app, '_login_via_dbus_sso',
3388+ lambda: app._available_for_me_result(None, [])):
3389+ # show it
3390+ app.window_main.show_all()
3391+ app.available_pane.init_view()
3392+ do_events_with_sleep()
3393+ app.on_menuitem_reinstall_purchases_activate(None)
3394+ # it can take a bit until the sso client is ready
3395+ for i in range(100):
3396+ if (app.available_pane.get_current_page() ==
3397+ AvailablePane.Pages.LIST):
3398+ break
3399+ do_events_with_sleep()
3400+ self.assertEqual(app.available_pane.get_current_page(),
3401+ AvailablePane.Pages.LIST)
3402
3403- def _p(self):
3404- for i in range(5):
3405- time.sleep(0.1)
3406- do_events()
3407
3408 if __name__ == "__main__":
3409- import logging
3410- logging.basicConfig(level=logging.DEBUG)
3411 unittest.main()
3412
3413=== modified file 'tests/gtk3/test_recommendations_widgets.py'
3414--- test/gtk3/test_recommendations_widgets.py 2012-03-19 01:14:26 +0000
3415+++ tests/gtk3/test_recommendations_widgets.py 2012-06-11 15:00:29 +0000
3416@@ -1,15 +1,10 @@
3417-#!/usr/bin/python
3418-
3419-from gi.repository import Gtk, GObject
3420 import unittest
3421
3422-from testutils import setup_test_env
3423+from tests.utils import setup_test_env
3424 setup_test_env()
3425
3426-from softwarecenter.ui.gtk3.widgets.recommendations import get_test_window
3427+from tests.gtk3.windows import get_test_window_recommendations
3428
3429-# window destory timeout
3430-TIMEOUT=100
3431
3432 # FIXME: the code from test_catview that tests the lobby widget should
3433 # move here as it should be fine to test it in isolation
3434@@ -17,26 +12,17 @@
3435 class TestRecommendationsWidgets(unittest.TestCase):
3436
3437 def test_recommendations_lobby(self):
3438- win = get_test_window(panel_type="lobby")
3439- win.show_all()
3440- GObject.timeout_add(TIMEOUT, lambda: win.destroy())
3441- Gtk.main()
3442-
3443+ win = get_test_window_recommendations(panel_type="lobby")
3444+ self.addCleanup(win.destroy)
3445+
3446 def test_recommendations_category(self):
3447- win = get_test_window(panel_type="category")
3448- win.show_all()
3449- GObject.timeout_add(TIMEOUT, lambda: win.destroy())
3450- Gtk.main()
3451-
3452+ win = get_test_window_recommendations(panel_type="category")
3453+ self.addCleanup(win.destroy)
3454+
3455 def test_recommendations_details(self):
3456- win = get_test_window(panel_type="details")
3457- win.show_all()
3458- GObject.timeout_add(TIMEOUT, lambda: win.destroy())
3459- Gtk.main()
3460-
3461+ win = get_test_window_recommendations(panel_type="details")
3462+ self.addCleanup(win.destroy)
3463
3464
3465 if __name__ == "__main__":
3466- #import logging
3467- #logging.basicConfig(level=logging.DEBUG)
3468 unittest.main()
3469
3470=== modified file 'tests/gtk3/test_reviews.py'
3471--- test/gtk3/test_reviews.py 2012-01-24 10:23:51 +0000
3472+++ tests/gtk3/test_reviews.py 2012-06-11 15:00:29 +0000
3473@@ -1,22 +1,26 @@
3474-#!/usr/bin/python
3475-
3476 import unittest
3477
3478-from gi.repository import GObject
3479+from time import sleep
3480
3481-from testutils import setup_test_env
3482-setup_test_env()
3483 from gettext import gettext as _
3484 from mock import Mock, patch
3485
3486+from tests.utils import (
3487+ do_events,
3488+ get_test_db,
3489+ get_test_pkg_info,
3490+ REAL_DATA_DIR,
3491+ setup_test_env,
3492+)
3493+setup_test_env()
3494+
3495 from softwarecenter.backend.piston.rnrclient_pristine import ReviewDetails
3496-from softwarecenter.testutils import get_test_pkg_info, get_test_db
3497 from softwarecenter.ui.gtk3.review_gui_helper import (
3498 TRANSMIT_STATE_DONE,
3499 GRatingsAndReviews,
3500 SubmitReviewsApp,
3501 )
3502-from time import sleep
3503+
3504
3505 class TestReviewLoader(unittest.TestCase):
3506 cache = get_test_pkg_info()
3507@@ -32,7 +36,7 @@
3508 # review_loader = ReviewLoader(self.cache, self.db)
3509 # review_loader.refresh_review_stats(self._review_stats_ready_callback)
3510 # while not self._stats_ready:
3511-# self._p()
3512+# do_events()
3513 # self.assertTrue(len(self._review_stats) > 0)
3514 # self.assertTrue(os.path.exists(review_loader.REVIEW_STATS_CACHE_FILE))
3515 # self.assertTrue(os.path.exists(review_loader.REVIEW_STATS_BSDDB_FILE))
3516@@ -47,7 +51,7 @@
3517 def test_edit_review_screen_has_right_labels(self):
3518 """Check that LP #880255 stays fixed. """
3519
3520- review_app = SubmitReviewsApp(datadir="../data", app=None,
3521+ review_app = SubmitReviewsApp(datadir=REAL_DATA_DIR, app=None,
3522 parent_xid='', iconname='accessories-calculator', origin=None,
3523 version=None, action='modify', review_id=10000)
3524 # monkey patch away login to avoid that we actually login
3525@@ -58,9 +62,9 @@
3526 # run the main app
3527 review_app.run()
3528
3529- self._p()
3530+ do_events()
3531 review_app.login_successful('foobar')
3532- self._p()
3533+ do_events()
3534 self.assertEqual(_('Rating:'), review_app.rating_label.get_label())
3535 self.assertEqual(_('Summary:'),
3536 review_app.review_summary_label.get_label())
3537@@ -69,7 +73,7 @@
3538 review_app.submit_window.hide()
3539
3540 def test_get_fade_colour_markup(self):
3541- review_app = SubmitReviewsApp(datadir="../data", app=None,
3542+ review_app = SubmitReviewsApp(datadir=REAL_DATA_DIR, app=None,
3543 parent_xid='', iconname='accessories-calculator', origin=None,
3544 version=None, action='nothing')
3545 cases = (
3546@@ -85,7 +89,7 @@
3547 self.assertEqual(expected, result)
3548
3549 def test_modify_review_is_the_same_supports_unicode(self):
3550- review_app = SubmitReviewsApp(datadir="../data", app=None,
3551+ review_app = SubmitReviewsApp(datadir=REAL_DATA_DIR, app=None,
3552 parent_xid='', iconname='accessories-calculator', origin=None,
3553 version=None, action='modify', review_id=10000)
3554 self.assertTrue(review_app._modify_review_is_the_same())
3555@@ -103,7 +107,7 @@
3556 self.assertFalse(review_app._modify_review_is_the_same())
3557
3558 def test_change_status(self):
3559- review_app = SubmitReviewsApp(datadir="../data", app=None,
3560+ review_app = SubmitReviewsApp(datadir=REAL_DATA_DIR, app=None,
3561 parent_xid='', iconname='accessories-calculator', origin=None,
3562 version=None, action='nothing')
3563 msg = 'Something completely different'
3564@@ -136,23 +140,17 @@
3565 include_hidden_chars=False))
3566 review_app.detail_expander.get_visible()
3567
3568- def _p(self):
3569- main_loop = GObject.main_context_default()
3570- while main_loop.pending():
3571- main_loop.iteration()
3572-
3573
3574 class TestGRatingsAndReviews(unittest.TestCase):
3575+
3576 def setUp(self):
3577- mock_token = {'token': 'foobar',
3578+ mock_token = {'token': 'foobar',
3579 'token_secret': 'foobar',
3580 'consumer_key': 'foobar',
3581 'consumer_secret': 'foobar',
3582 }
3583 self.api = GRatingsAndReviews(mock_token)
3584-
3585- def tearDown(self):
3586- self.api.shutdown()
3587+ self.addCleanup(self.api.shutdown)
3588
3589 def make_review(self):
3590 review = Mock()
3591@@ -165,7 +163,7 @@
3592 review.package_version = '1.0'
3593 review.date = '2012-01-22'
3594 review.language = 'en'
3595- return review
3596+ return review
3597
3598 def wait_for_worker(self):
3599 while self.api.worker_thread._transmit_state != TRANSMIT_STATE_DONE:
3600@@ -239,6 +237,4 @@
3601
3602
3603 if __name__ == "__main__":
3604- import logging
3605- logging.basicConfig(level=logging.DEBUG)
3606 unittest.main()
3607
3608=== modified file 'tests/gtk3/test_search.py'
3609--- test/gtk3/test_search.py 2012-01-16 14:42:49 +0000
3610+++ tests/gtk3/test_search.py 2012-06-11 15:00:29 +0000
3611@@ -1,60 +1,46 @@
3612-#!/usr/bin/python
3613-
3614-from gi.repository import Gtk, GObject
3615-import time
3616 import unittest
3617
3618-from testutils import setup_test_env
3619+from tests.utils import do_events_with_sleep, setup_test_env
3620 setup_test_env()
3621
3622-TIMEOUT=300
3623+from tests.gtk3.windows import (
3624+ get_test_window_availablepane,
3625+ get_test_window_installedpane,
3626+)
3627+
3628
3629 class TestSearch(unittest.TestCase):
3630
3631 def test_installedpane(self):
3632- from softwarecenter.ui.gtk3.panes.installedpane import get_test_window
3633- win = get_test_window()
3634+ win = get_test_window_installedpane()
3635+ self.addCleanup(win.destroy)
3636 installedpane = win.get_data("pane")
3637- self._p()
3638+ do_events_with_sleep()
3639 installedpane.on_search_terms_changed(None, "the")
3640- self._p()
3641+ do_events_with_sleep()
3642 model = installedpane.app_view.tree_view.get_model()
3643 len1 = len(model)
3644 installedpane.on_search_terms_changed(None, "nosuchsearchtermforsure")
3645- self._p()
3646+ do_events_with_sleep()
3647 len2 = len(model)
3648 self.assertTrue(len2 < len1)
3649- GObject.timeout_add(TIMEOUT, lambda: win.destroy())
3650- Gtk.main()
3651
3652 def test_availablepane(self):
3653- from softwarecenter.ui.gtk3.panes.availablepane import get_test_window
3654- win = get_test_window()
3655+ win = get_test_window_availablepane()
3656+ self.addCleanup(win.destroy)
3657 pane = win.get_data("pane")
3658- self._p()
3659+ do_events_with_sleep()
3660 pane.on_search_terms_changed(None, "the")
3661- self._p()
3662+ do_events_with_sleep()
3663 sortmode = pane.app_view.sort_methods_combobox.get_active_text()
3664 self.assertEqual(sortmode, "By Relevance")
3665 model = pane.app_view.tree_view.get_model()
3666 len1 = len(model)
3667 pane.on_search_terms_changed(None, "nosuchsearchtermforsure")
3668- self._p()
3669+ do_events_with_sleep()
3670 len2 = len(model)
3671 self.assertTrue(len2 < len1)
3672- GObject.timeout_add(TIMEOUT, lambda: win.destroy())
3673- Gtk.main()
3674-
3675-
3676-
3677- def _p(self):
3678- for i in range(10):
3679- time.sleep(0.1)
3680- while Gtk.events_pending():
3681- Gtk.main_iteration()
3682
3683
3684 if __name__ == "__main__":
3685- import logging
3686- logging.basicConfig(level=logging.INFO)
3687 unittest.main()
3688
3689=== modified file 'tests/gtk3/test_spinner.py'
3690--- test/gtk3/test_spinner.py 2012-05-17 17:57:18 +0000
3691+++ tests/gtk3/test_spinner.py 2012-06-11 15:00:29 +0000
3692@@ -4,7 +4,7 @@
3693 from gi.repository import Gtk
3694 from mock import patch
3695
3696-from testutils import setup_test_env
3697+from tests.utils import setup_test_env
3698 setup_test_env()
3699
3700 from softwarecenter.ui.gtk3.widgets import spinner
3701
3702=== modified file 'tests/gtk3/test_unity_launcher_integration.py'
3703--- test/gtk3/test_unity_launcher_integration.py 2012-03-07 06:06:59 +0000
3704+++ tests/gtk3/test_unity_launcher_integration.py 2012-06-11 15:00:29 +0000
3705@@ -1,80 +1,81 @@
3706-#!/usr/bin/python
3707+import os
3708+import unittest
3709
3710 from gi.repository import Gtk
3711-import time
3712-import unittest
3713
3714-from testutils import setup_test_env
3715+from tests.utils import (
3716+ DATA_DIR,
3717+ do_events,
3718+ do_events_with_sleep,
3719+ setup_test_env,
3720+)
3721 setup_test_env()
3722
3723 # overwrite early
3724 import softwarecenter.utils
3725
3726+from softwarecenter.backend.unitylauncher import UnityLauncherInfo
3727+from softwarecenter.db.application import Application
3728 from softwarecenter.enums import TransactionTypes
3729+from softwarecenter.ui.gtk3.panes.availablepane import AvailablePane
3730 from softwarecenter.utils import convert_desktop_file_to_installed_location
3731-from softwarecenter.db.application import Application
3732-from softwarecenter.ui.gtk3.panes.availablepane import get_test_window
3733-from softwarecenter.backend.unitylauncher import UnityLauncherInfo
3734+from tests.gtk3.windows import get_test_window_availablepane
3735
3736 # Tests for Ubuntu Software Center's integration with the Unity launcher,
3737 # see https://wiki.ubuntu.com/SoftwareCenter#Learning%20how%20to%20launch%20an%20application
3738
3739-# we can only have one instance of availablepane, so create it here
3740-win = get_test_window()
3741-available_pane = win.get_data("pane")
3742
3743 class TestUnityLauncherIntegration(unittest.TestCase):
3744
3745 def setUp(self):
3746+ # we can only have one instance of availablepane, so create it here
3747+ win = get_test_window_availablepane()
3748+ self.addCleanup(win.destroy)
3749+ self.available_pane = win.get_data("pane")
3750+
3751 # monkey patch is_unity_running
3752+ original = softwarecenter.utils.is_unity_running
3753 softwarecenter.utils.is_unity_running = lambda: True
3754-
3755- def _zzz(self):
3756- for i in range(10):
3757- time.sleep(0.1)
3758- self._p()
3759-
3760- def _p(self):
3761- while Gtk.events_pending():
3762- Gtk.main_iteration()
3763+ self.addCleanup(setattr, softwarecenter.utils, 'is_unity_running',
3764+ original)
3765
3766 def _install_from_list_view(self, pkgname):
3767- from softwarecenter.ui.gtk3.panes.availablepane import AvailablePane
3768- available_pane.notebook.set_current_page(AvailablePane.Pages.LIST)
3769-
3770- self._p()
3771- available_pane.on_search_terms_changed(None, "ark,artha,software-center")
3772- self._p()
3773-
3774+ self.available_pane.notebook.set_current_page(AvailablePane.Pages.LIST)
3775+
3776+ do_events()
3777+ self.available_pane.on_search_terms_changed(None,
3778+ "ark,artha,software-center")
3779+ do_events()
3780+
3781 # select the first item in the list
3782- available_pane.app_view.tree_view.set_cursor(Gtk.TreePath(0),
3783+ self.available_pane.app_view.tree_view.set_cursor(Gtk.TreePath(0),
3784 None, False)
3785- # ok to just use the test app here
3786+ # ok to just use the test app here
3787 app = Application("", pkgname)
3788- self._p()
3789-
3790+ do_events()
3791+
3792 # pretend we started an install
3793- available_pane.backend.emit("transaction-started",
3794+ self.available_pane.backend.emit("transaction-started",
3795 app.pkgname, app.appname,
3796 "testid101",
3797 TransactionTypes.INSTALL)
3798 # wait a wee bit
3799- self._zzz()
3800+ do_events_with_sleep()
3801
3802 def _navigate_to_appdetails_and_install(self, pkgname):
3803 app = Application("", pkgname)
3804- available_pane.app_view.emit("application-activated",
3805+ self.available_pane.app_view.emit("application-activated",
3806 app)
3807- self._p()
3808-
3809+ do_events()
3810+
3811 # pretend we started an install
3812- available_pane.backend.emit("transaction-started",
3813+ self.available_pane.backend.emit("transaction-started",
3814 app.pkgname, app.appname,
3815 "testid101",
3816 TransactionTypes.INSTALL)
3817 # wait a wee bit
3818- self._zzz()
3819-
3820+ do_events_with_sleep()
3821+
3822 def _fake_send_application_to_launcher_and_check(self,
3823 pkgname, launcher_info):
3824 self.assertEqual(pkgname, self.expected_pkgname)
3825@@ -91,11 +92,11 @@
3826 self.expected_launcher_info.app_install_desktop_file_path)
3827 self.assertEqual(launcher_info.trans_id,
3828 self.expected_launcher_info.trans_id)
3829-
3830+
3831 def test_unity_launcher_integration_list_view(self):
3832 # test the automatic add to launcher enabled functionality when
3833 # installing an app form the list view
3834- available_pane.add_to_launcher_enabled = True
3835+ self.available_pane.add_to_launcher_enabled = True
3836 test_pkgname = "lincity-ng"
3837 # now pretend
3838 # for testing, we substitute a fake version of UnityLauncher's
3839@@ -104,18 +105,17 @@
3840 # to the unity launcher service
3841 self.expected_pkgname = test_pkgname
3842 self.expected_launcher_info = UnityLauncherInfo("lincity-ng",
3843- "lincity-ng",
3844- 0, 0, 0, 0, # these values are set in availablepane
3845- "/usr/share/app-install/desktop/lincity-ng:lincity-ng.desktop",
3846- "testid101")
3847- available_pane.unity_launcher.send_application_to_launcher = (
3848+ "lincity-ng", 0, 0, 0, 0, # these values are set in availablepane
3849+ "/usr/share/app-install/desktop/lincity-ng:lincity-ng.desktop",
3850+ "testid101")
3851+ self.available_pane.unity_launcher.send_application_to_launcher = (
3852 self._fake_send_application_to_launcher_and_check)
3853 self._install_from_list_view(test_pkgname)
3854
3855 def test_unity_launcher_integration_details_view(self):
3856 # test the automatic add to launcher enabled functionality when
3857 # installing an app from the details view
3858- available_pane.add_to_launcher_enabled = True
3859+ self.available_pane.add_to_launcher_enabled = True
3860 test_pkgname = "lincity-ng"
3861 # now pretend
3862 # for testing, we substitute a fake version of UnityLauncher's
3863@@ -124,17 +124,16 @@
3864 # to the unity launcher service
3865 self.expected_pkgname = test_pkgname
3866 self.expected_launcher_info = UnityLauncherInfo("lincity-ng",
3867- "lincity-ng",
3868- 0, 0, 0, 0, # these values are set in availablepane
3869- "/usr/share/app-install/desktop/lincity-ng:lincity-ng.desktop",
3870- "testid101")
3871- available_pane.unity_launcher.send_application_to_launcher = (
3872+ "lincity-ng", 0, 0, 0, 0, # these values are set in availablepane
3873+ "/usr/share/app-install/desktop/lincity-ng:lincity-ng.desktop",
3874+ "testid101")
3875+ self.available_pane.unity_launcher.send_application_to_launcher = (
3876 self._fake_send_application_to_launcher_and_check)
3877 self._navigate_to_appdetails_and_install(test_pkgname)
3878-
3879+
3880 def test_unity_launcher_integration_disabled(self):
3881 # test the case where automatic add to launcher is disabled
3882- available_pane.add_to_launcher_enabled = False
3883+ self.available_pane.add_to_launcher_enabled = False
3884 test_pkgname = "lincity-ng"
3885 # now pretend
3886 # for testing, we substitute a fake version of UnityLauncher's
3887@@ -147,26 +146,25 @@
3888 self.expected_pkgname = ""
3889 self.expected_launcher_info = UnityLauncherInfo("", "",
3890 0, 0, 0, 0, "", "")
3891- available_pane.unity_launcher.send_application_to_launcher = (
3892+ self.available_pane.unity_launcher.send_application_to_launcher = (
3893 self._fake_send_application_to_launcher_and_check)
3894 self._navigate_to_appdetails_and_install(test_pkgname)
3895
3896 def test_desktop_file_path_conversion(self):
3897 # test 'normal' case
3898- app_install_desktop_path = ("./data/app-install/desktop/" +
3899- "deja-dup:deja-dup.desktop")
3900+ app_install_desktop_path = os.path.join(DATA_DIR, "app-install",
3901+ "desktop", "deja-dup:deja-dup.desktop")
3902 installed_desktop_path = convert_desktop_file_to_installed_location(
3903 app_install_desktop_path, "deja-dup")
3904- self.assertEqual(installed_desktop_path,
3905- "./data/applications/deja-dup.desktop")
3906+ self.assertEqual(installed_desktop_path, os.path.join(DATA_DIR,
3907+ "applications", "deja-dup.desktop"))
3908 # test encoded subdirectory case, e.g. e.g. kde4_soundkonverter.desktop
3909- app_install_desktop_path = ("./data/app-install/desktop/" +
3910- "soundkonverter:" +
3911- "kde4__soundkonverter.desktop")
3912+ app_install_desktop_path = os.path.join(DATA_DIR, "app-install",
3913+ "desktop", "soundkonverter:kde4__soundkonverter.desktop")
3914 installed_desktop_path = convert_desktop_file_to_installed_location(
3915 app_install_desktop_path, "soundkonverter")
3916- self.assertEqual(installed_desktop_path,
3917- "./data/applications/kde4/soundkonverter.desktop")
3918+ self.assertEqual(installed_desktop_path, os.path.join(DATA_DIR,
3919+ "applications", "kde4", "soundkonverter.desktop"))
3920 # test the for-purchase case (uses "software-center-agent" as its
3921 # appdetails.desktop_file value)
3922 # FIXME: this will only work if update-manager is installed
3923@@ -182,7 +180,7 @@
3924 # FIXME: this will only work if update-manager is installed
3925 self.assertEqual(installed_desktop_path,
3926 "/usr/share/applications/update-manager.desktop")
3927-
3928+
3929
3930 if __name__ == "__main__":
3931 unittest.main()
3932
3933=== modified file 'tests/gtk3/test_views.py'
3934--- test/gtk3/test_views.py 2012-01-16 14:42:49 +0000
3935+++ tests/gtk3/test_views.py 2012-06-11 15:00:29 +0000
3936@@ -1,53 +1,44 @@
3937-#!/usr/bin/python
3938-
3939-from gi.repository import Gtk, GObject
3940 import unittest
3941
3942-from testutils import setup_test_env
3943+from tests.utils import setup_test_env
3944 setup_test_env()
3945
3946-TIMEOUT=300
3947+from tests.gtk3.windows import (
3948+ get_test_window_appdetails,
3949+ get_test_window_appview,
3950+ get_test_window_catview,
3951+ get_test_window_pkgnamesview,
3952+ get_test_window_purchaseview,
3953+ get_test_window_viewswitcher,
3954+)
3955+
3956
3957 class TestViews(unittest.TestCase):
3958
3959 def test_viewswitcher(self):
3960- from softwarecenter.ui.gtk3.panes.viewswitcher import get_test_window_viewswitcher
3961 win = get_test_window_viewswitcher()
3962- GObject.timeout_add(TIMEOUT, lambda: win.destroy())
3963- Gtk.main()
3964+ self.addCleanup(win.destroy)
3965
3966 def test_catview(self):
3967- from softwarecenter.ui.gtk3.views.catview_gtk import get_test_window_catview
3968 win = get_test_window_catview()
3969- GObject.timeout_add(TIMEOUT, lambda: win.destroy())
3970- Gtk.main()
3971+ self.addCleanup(win.destroy)
3972
3973 def test_appdetails(self):
3974- from softwarecenter.ui.gtk3.views.appdetailsview import get_test_window_appdetails
3975 win = get_test_window_appdetails()
3976- GObject.timeout_add(TIMEOUT, lambda: win.destroy())
3977- Gtk.main()
3978-
3979+ self.addCleanup(win.destroy)
3980+
3981 def test_pkgsnames(self):
3982- from softwarecenter.ui.gtk3.views.pkgnamesview import get_test_window_pkgnamesview
3983 win = get_test_window_pkgnamesview()
3984- GObject.timeout_add(TIMEOUT, lambda: win.destroy())
3985- Gtk.main()
3986+ self.addCleanup(win.destroy)
3987
3988 def test_purchaseview(self):
3989- from softwarecenter.ui.gtk3.views.purchaseview import get_test_window_purchaseview
3990 win = get_test_window_purchaseview()
3991- GObject.timeout_add(TIMEOUT, lambda: win.destroy())
3992- Gtk.main()
3993+ self.addCleanup(win.destroy)
3994
3995 def test_appview(self):
3996- from softwarecenter.ui.gtk3.views.appview import get_test_window
3997- win = get_test_window()
3998- GObject.timeout_add(TIMEOUT, lambda: win.destroy())
3999- Gtk.main()
4000-
4001+ win = get_test_window_appview()
4002+ self.addCleanup(win.destroy)
4003+
4004
4005 if __name__ == "__main__":
4006- import logging
4007- logging.basicConfig(level=logging.DEBUG)
4008 unittest.main()
4009
4010=== modified file 'tests/gtk3/test_widgets.py'
4011--- test/gtk3/test_widgets.py 2012-04-12 07:46:56 +0000
4012+++ tests/gtk3/test_widgets.py 2012-06-11 15:00:29 +0000
4013@@ -1,18 +1,39 @@
4014-#!/usr/bin/python
4015-
4016-from gi.repository import Gtk, GdkPixbuf, GObject
4017 import os
4018 import unittest
4019+
4020+from gi.repository import Gtk, GdkPixbuf, GObject
4021 from gettext import gettext as _
4022-
4023 from mock import Mock, patch
4024
4025-from testutils import setup_test_env, do_events
4026+from tests.utils import (
4027+ DATA_DIR,
4028+ setup_test_env,
4029+ do_events,
4030+)
4031 setup_test_env()
4032+
4033+from softwarecenter.enums import PkgStates
4034 from softwarecenter.utils import utf8
4035-from softwarecenter.ui.gtk3.widgets.reviews import get_test_reviews_window
4036+from softwarecenter.ui.gtk3.widgets.actionbar import ActionBar
4037+from softwarecenter.ui.gtk3.widgets.imagedialog import SimpleShowImageDialog
4038 from softwarecenter.ui.gtk3.widgets.labels import (
4039 HardwareRequirementsLabel, HardwareRequirementsBox)
4040+from tests.gtk3.windows import (
4041+ get_test_backforward_window,
4042+ get_test_buttons_window,
4043+ get_test_container_window,
4044+ get_test_description_window,
4045+ get_test_exhibits_window,
4046+ get_test_reviews_window,
4047+ get_test_searchentry_window,
4048+ get_test_screenshot_thumbnail_window,
4049+ get_test_spinner_window,
4050+ get_test_stars_window,
4051+ get_test_symbolic_icons_window,
4052+ get_test_videoplayer_window,
4053+ get_test_window,
4054+ get_test_window_apptreeview,
4055+)
4056
4057 # window destory timeout
4058 TIMEOUT=100
4059@@ -21,109 +42,72 @@
4060 """ basic tests for the various gtk3 widget """
4061
4062 def test_stars(self):
4063- from softwarecenter.ui.gtk3.widgets.stars import get_test_stars_window
4064 win = get_test_stars_window()
4065- win.show_all()
4066- GObject.timeout_add(TIMEOUT, lambda: win.destroy())
4067- Gtk.main()
4068+ self.addCleanup(win.destroy)
4069
4070 def test_actionbar(self):
4071- from softwarecenter.ui.gtk3.widgets.actionbar import ActionBar
4072 mock = Mock()
4073 actionbar = ActionBar()
4074 actionbar.add_button("id1", "label", mock)
4075 actionbar.add_button("id2", "label", mock)
4076 actionbar.remove_button("id2")
4077- win = Gtk.Window()
4078- win.set_size_request(400, 400)
4079- win.add(actionbar)
4080- win.connect("destroy", Gtk.main_quit)
4081- win.show_all()
4082- GObject.timeout_add(TIMEOUT, lambda: win.destroy())
4083- Gtk.main()
4084+ win = get_test_window(child=actionbar)
4085+ self.addCleanup(win.destroy)
4086
4087 def test_backforward(self):
4088- from softwarecenter.ui.gtk3.widgets.backforward import get_test_backforward_window
4089 win = get_test_backforward_window()
4090- win.show_all()
4091- GObject.timeout_add(TIMEOUT, lambda: win.destroy())
4092- Gtk.main()
4093+ self.addCleanup(win.destroy)
4094
4095 def test_containers(self):
4096- from softwarecenter.ui.gtk3.widgets.containers import get_test_container_window
4097 win = get_test_container_window()
4098- win.show_all()
4099- GObject.timeout_add(TIMEOUT, lambda: win.destroy())
4100- Gtk.main()
4101+ self.addCleanup(win.destroy)
4102
4103 def test_description(self):
4104- from softwarecenter.ui.gtk3.widgets.description import get_test_description_window
4105 win = get_test_description_window()
4106- win.show_all()
4107- GObject.timeout_add(TIMEOUT, lambda: win.destroy())
4108- Gtk.main()
4109+ self.addCleanup(win.destroy)
4110
4111 def test_exhibits(self):
4112- from softwarecenter.ui.gtk3.widgets.exhibits import get_test_exhibits_window
4113 win = get_test_exhibits_window()
4114- GObject.timeout_add(TIMEOUT, lambda: win.destroy())
4115- Gtk.main()
4116+ self.addCleanup(win.destroy)
4117
4118 def test_show_image_dialog(self):
4119- from softwarecenter.ui.gtk3.widgets.imagedialog import SimpleShowImageDialog
4120- if os.path.exists("../../data/default_banner/fallback.png"):
4121- f = "../../data/default_banner/fallback.png"
4122- else:
4123- f = "../data/default_banner/fallback.png"
4124+ f = os.path.join(DATA_DIR, "test_images", "fallback.png")
4125 pix = GdkPixbuf.Pixbuf.new_from_file(f)
4126 d = SimpleShowImageDialog("test caption", pix)
4127 GObject.timeout_add(TIMEOUT, lambda: d.destroy())
4128 d.run()
4129
4130 def test_searchentry(self):
4131- from softwarecenter.ui.gtk3.widgets.searchentry import get_test_searchentry_window
4132 win = get_test_searchentry_window()
4133+ self.addCleanup(win.destroy)
4134 s = "foo"
4135 win.entry.insert_text(s, len(s))
4136- GObject.timeout_add(TIMEOUT, lambda: win.destroy())
4137- Gtk.main()
4138+ self.addCleanup(win.destroy)
4139
4140 def test_spinner(self):
4141- from softwarecenter.ui.gtk3.widgets.spinner import get_test_spinner_window
4142 win = get_test_spinner_window()
4143- GObject.timeout_add(TIMEOUT, lambda: win.destroy())
4144- Gtk.main()
4145+ self.addCleanup(win.destroy)
4146
4147 def test_symbolic_icons(self):
4148- from softwarecenter.ui.gtk3.widgets.symbolic_icons import get_test_symbolic_icons_window
4149 win = get_test_symbolic_icons_window()
4150- GObject.timeout_add(TIMEOUT, lambda: win.destroy())
4151- Gtk.main()
4152+ self.addCleanup(win.destroy)
4153
4154 def test_buttons(self):
4155- from softwarecenter.ui.gtk3.widgets.buttons import get_test_buttons_window
4156 win = get_test_buttons_window()
4157- GObject.timeout_add(TIMEOUT, lambda: win.destroy())
4158- Gtk.main()
4159+ self.addCleanup(win.destroy)
4160
4161 def test_screenshot_thumbnail(self):
4162- from softwarecenter.ui.gtk3.widgets.thumbnail import get_test_screenshot_thumbnail_window
4163 win = get_test_screenshot_thumbnail_window()
4164- GObject.timeout_add(TIMEOUT, lambda: win.destroy())
4165- Gtk.main()
4166+ self.addCleanup(win.destroy)
4167
4168 def test_videoplayer(self):
4169- from softwarecenter.ui.gtk3.widgets.videoplayer import get_test_videoplayer_window
4170 win = get_test_videoplayer_window()
4171- GObject.timeout_add(TIMEOUT, lambda: win.destroy())
4172- Gtk.main()
4173-
4174+ self.addCleanup(win.destroy)
4175
4176 def test_apptreeview(self):
4177- from softwarecenter.ui.gtk3.widgets.apptreeview import get_test_window
4178- win = get_test_window()
4179- GObject.timeout_add(TIMEOUT, lambda: win.destroy())
4180- Gtk.main()
4181+ win = get_test_window_apptreeview()
4182+ self.addCleanup(win.destroy)
4183+
4184
4185 class TestHWRequirements(unittest.TestCase):
4186
4187@@ -177,17 +161,15 @@
4188 # test seting it again
4189 box.set_hardware_requirements(self.HW_TEST_RESULT)
4190 self.assertEqual(len(box.get_children()), 2)
4191-
4192+
4193
4194 class TestUIReviewsList(unittest.TestCase):
4195+
4196 def setUp(self):
4197 self.win = get_test_reviews_window()
4198+ self.addCleanup(self.win.destroy)
4199 self.rl = self.win.get_children()[0]
4200
4201- def tearDown(self):
4202- GObject.timeout_add(TIMEOUT, lambda: self.win.destroy())
4203- Gtk.main()
4204-
4205 def assertComboBoxTextIncludes(self, combo, option):
4206 store = combo.get_model()
4207 self.assertTrue(option in [x[0] for x in store])
4208@@ -228,7 +210,6 @@
4209
4210 @patch('softwarecenter.ui.gtk3.widgets.reviews.network_state_is_connected')
4211 def test_reviews_no_reviews_offer_to_write_one(self, mock_connected):
4212- from softwarecenter.enums import PkgStates
4213 mock_connected.return_value = True
4214 # No reviews found, and the app is installed
4215 self.rl.clear()
4216@@ -241,9 +222,5 @@
4217 _('Be the first to contribute a review for this application'))
4218
4219
4220-
4221-
4222 if __name__ == "__main__":
4223- import logging
4224- logging.basicConfig(level=logging.DEBUG)
4225 unittest.main()
4226
4227=== added file 'tests/gtk3/windows.py'
4228--- tests/gtk3/windows.py 1970-01-01 00:00:00 +0000
4229+++ tests/gtk3/windows.py 2012-06-11 15:00:29 +0000
4230@@ -0,0 +1,1163 @@
4231+from __future__ import print_function
4232+
4233+import logging
4234+import os
4235+import sys
4236+import urllib
4237+
4238+import xapian
4239+
4240+from gi.repository import Gdk, GObject, Gtk
4241+from mock import Mock
4242+
4243+import softwarecenter.distro
4244+import softwarecenter.log
4245+import softwarecenter.paths
4246+
4247+from softwarecenter.backend import channel
4248+from softwarecenter.db import (
4249+ appfilter,
4250+ application,
4251+ database,
4252+ enquire,
4253+ pkginfo,
4254+)
4255+from softwarecenter.enums import (
4256+ BUY_SOMETHING_HOST,
4257+ NonAppVisibility,
4258+)
4259+from softwarecenter.ui.gtk3 import em
4260+from softwarecenter.ui.gtk3.dialogs import dependency_dialogs
4261+from softwarecenter.ui.gtk3.models import appstore2
4262+from softwarecenter.ui.gtk3.panes import (
4263+ availablepane,
4264+ globalpane,
4265+ historypane,
4266+ installedpane,
4267+ pendingpane,
4268+ softwarepane,
4269+ viewswitcher,
4270+)
4271+from softwarecenter.ui.gtk3.session import appmanager
4272+from softwarecenter.ui.gtk3.utils import (
4273+ get_sc_icon_theme,
4274+ init_sc_css_provider,
4275+)
4276+from softwarecenter.ui.gtk3.views import (
4277+ appview,
4278+ appdetailsview,
4279+ catview_gtk,
4280+ pkgnamesview,
4281+ purchaseview,
4282+)
4283+from softwarecenter.ui.gtk3.widgets import (
4284+ backforward,
4285+ buttons,
4286+ containers,
4287+ description,
4288+ exhibits,
4289+ labels,
4290+ oneconfviews,
4291+ recommendations,
4292+ reviews,
4293+ searchentry,
4294+ spinner,
4295+ stars,
4296+ symbolic_icons,
4297+ thumbnail,
4298+ videoplayer,
4299+)
4300+from softwarecenter.utils import ExecutionTime
4301+from tests.utils import (
4302+ do_events,
4303+ get_test_categories,
4304+ get_test_datadir,
4305+ get_test_db,
4306+ get_test_gtk3_icon_cache,
4307+ get_test_gtk3_viewmanager,
4308+ get_test_install_backend,
4309+ get_test_pkg_info,
4310+ patch_datadir,
4311+)
4312+
4313+
4314+if os.environ.get('SOFTWARE_CENTER_PERFORMANCE_DEBUG', False):
4315+ softwarecenter.log.root.setLevel(level=logging.DEBUG)
4316+ softwarecenter.log.add_filters_from_string("performance")
4317+ fmt = logging.Formatter("%(name)s - %(message)s", None)
4318+ softwarecenter.log.handler.setFormatter(fmt)
4319+
4320+
4321+if os.environ.get('SOFTWARE_CENTER_DEBUG', False):
4322+ softwarecenter.log.root.setLevel(level=logging.DEBUG)
4323+ fmt = logging.Formatter("%(name)s - %(message)s", None)
4324+ softwarecenter.log.handler.setFormatter(fmt)
4325+
4326+
4327+def get_test_window(child, width=600, height=800, border_width=0, title=None):
4328+ win = Gtk.Window()
4329+ win.set_size_request(width, height)
4330+ win.set_position(Gtk.WindowPosition.CENTER)
4331+ win.set_border_width(border_width)
4332+ win.add(child)
4333+ if title is None:
4334+ title = child.__class__.__name__
4335+ win.set_title(title)
4336+ win.show_all()
4337+ return win
4338+
4339+
4340+def get_test_window_dependency_dialog():
4341+ icons = get_test_gtk3_icon_cache()
4342+ db = get_test_db()
4343+
4344+ depends = ["apt", "synaptic"]
4345+ app = application.Application("", "software-center")
4346+ primary = "primary text"
4347+ button_text = "button_text"
4348+ dia = dependency_dialogs._get_confirm_internal_dialog(
4349+ parent=None, datadir=softwarecenter.paths.datadir, app=app,
4350+ db=db, icons=icons, primary=primary, button_text=button_text,
4351+ depends=depends, cache=db._aptcache)
4352+ return dia
4353+
4354+
4355+def get_test_window_confirm_remove():
4356+ # test real remove dialog
4357+ icons = get_test_gtk3_icon_cache()
4358+ db = get_test_db()
4359+ app = application.Application("", "p7zip-full")
4360+ return dependency_dialogs.confirm_remove(None,
4361+ softwarecenter.paths.datadir, app, db, icons)
4362+
4363+
4364+def get_query_from_search_entry(search_term):
4365+ if not search_term:
4366+ return xapian.Query("")
4367+ parser = xapian.QueryParser()
4368+ user_query = parser.parse_query(search_term)
4369+ return user_query
4370+
4371+
4372+def on_entry_changed(widget, data):
4373+
4374+ def _work():
4375+ new_text = widget.get_text()
4376+ (view, enquirer) = data
4377+
4378+ with ExecutionTime("total time"):
4379+ with ExecutionTime("enquire.set_query()"):
4380+ enquirer.set_query(get_query_from_search_entry(new_text),
4381+ limit=100 * 1000,
4382+ nonapps_visible=NonAppVisibility.ALWAYS_VISIBLE)
4383+
4384+ store = view.tree_view.get_model()
4385+ if store is None:
4386+ return
4387+
4388+ with ExecutionTime("store.clear()"):
4389+ store.clear()
4390+
4391+ with ExecutionTime("store.set_from_matches()"):
4392+ store.set_from_matches(enquirer.matches)
4393+
4394+ with ExecutionTime("model settle (size=%s)" % len(store)):
4395+ do_events()
4396+
4397+ if widget.stamp:
4398+ GObject.source_remove(widget.stamp)
4399+ widget.stamp = GObject.timeout_add(250, _work)
4400+
4401+
4402+def get_test_window_appview():
4403+ db = get_test_db()
4404+ cache = get_test_pkg_info()
4405+ icons = get_test_gtk3_icon_cache()
4406+
4407+ # create a filter
4408+ app_filter = appfilter.AppFilter(db, cache)
4409+ app_filter.set_supported_only(False)
4410+ app_filter.set_installed_only(True)
4411+
4412+ # appview
4413+ enquirer = enquire.AppEnquire(cache, db)
4414+ store = appstore2.AppListStore(db, cache, icons)
4415+
4416+ view = appview.AppView(db, cache, icons, show_ratings=True)
4417+ view.set_model(store)
4418+
4419+ entry = Gtk.Entry()
4420+ entry.stamp = 0
4421+ entry.connect("changed", on_entry_changed, (view, enquirer))
4422+ entry.set_text("gtk3")
4423+
4424+ box = Gtk.VBox()
4425+ box.pack_start(entry, False, True, 0)
4426+ box.pack_start(view, True, True, 0)
4427+
4428+ win = get_test_window(child=box)
4429+ win.set_data("appview", view)
4430+ win.set_data("entry", entry)
4431+
4432+ return win
4433+
4434+
4435+def get_test_window_apptreeview():
4436+ cache = get_test_pkg_info()
4437+ db = get_test_db()
4438+ icons = get_test_gtk3_icon_cache()
4439+
4440+ # create a filter
4441+ app_filter = appfilter.AppFilter(db, cache)
4442+ app_filter.set_supported_only(False)
4443+ app_filter.set_installed_only(True)
4444+
4445+ # get the TREEstore
4446+ store = appstore2.AppTreeStore(db, cache, icons)
4447+
4448+ # populate from data
4449+ cats = get_test_categories(db)
4450+ for cat in cats[:3]:
4451+ with ExecutionTime("query cat '%s'" % cat.name):
4452+ docs = db.get_docs_from_query(cat.query)
4453+ store.set_category_documents(cat, docs)
4454+
4455+ # ok, this is confusing - the AppView contains the AppTreeView that
4456+ # is a tree or list depending on the model
4457+ app_view = appview.AppView(db, cache, icons, show_ratings=True)
4458+ app_view.set_model(store)
4459+
4460+ box = Gtk.VBox()
4461+ box.pack_start(app_view, True, True, 0)
4462+
4463+ win = get_test_window(child=box)
4464+ return win
4465+
4466+
4467+def get_test_window_availablepane():
4468+ # needed because available pane will try to get it
4469+ vm = get_test_gtk3_viewmanager()
4470+ vm # make pyflakes happy
4471+ db = get_test_db()
4472+ cache = get_test_pkg_info()
4473+ datadir = get_test_datadir()
4474+ icons = get_test_gtk3_icon_cache()
4475+ backend = get_test_install_backend()
4476+
4477+ manager = appmanager.get_appmanager()
4478+ if manager is None:
4479+ # create global AppManager instance
4480+ manager = appmanager.ApplicationManager(db, backend, icons)
4481+
4482+ navhistory_back_action = Gtk.Action("navhistory_back_action", "Back",
4483+ "Back", None)
4484+ navhistory_forward_action = Gtk.Action("navhistory_forward_action",
4485+ "Forward", "Forward", None)
4486+
4487+ w = availablepane.AvailablePane(cache, db, 'Ubuntu', icons, datadir,
4488+ navhistory_back_action, navhistory_forward_action)
4489+ w.init_view()
4490+ w.show()
4491+
4492+ win = get_test_window(child=w, width=800, height=600)
4493+ # this is used later in tests
4494+ win.set_data("pane", w)
4495+ return win
4496+
4497+
4498+def get_test_window_globalpane():
4499+ vm = get_test_gtk3_viewmanager()
4500+ db = get_test_db()
4501+ cache = get_test_pkg_info()
4502+ datadir = get_test_datadir()
4503+ icons = get_test_gtk3_icon_cache()
4504+
4505+ p = globalpane.GlobalPane(vm, datadir, db, cache, icons)
4506+
4507+ win = get_test_window(child=p)
4508+ win.set_data("pane", p)
4509+ return win
4510+
4511+
4512+def get_test_window_pendingpane():
4513+ icons = get_test_gtk3_icon_cache()
4514+
4515+ view = pendingpane.PendingPane(icons)
4516+
4517+ # gui
4518+ scroll = Gtk.ScrolledWindow()
4519+ scroll.add_with_viewport(view)
4520+
4521+ win = get_test_window(child=scroll)
4522+ view.grab_focus()
4523+ return win
4524+
4525+
4526+@patch_datadir('./data')
4527+def get_test_window_viewswitcher():
4528+ cache = get_test_pkg_info()
4529+ db = get_test_db()
4530+ icons = get_test_gtk3_icon_cache()
4531+ datadir = get_test_datadir()
4532+ manager = get_test_gtk3_viewmanager()
4533+
4534+ view = viewswitcher.ViewSwitcher(manager, datadir, db, cache, icons)
4535+
4536+ scroll = Gtk.ScrolledWindow()
4537+ box = Gtk.VBox()
4538+ box.pack_start(scroll, True, True, 0)
4539+
4540+ win = get_test_window(child=box)
4541+ scroll.add_with_viewport(view)
4542+ return win
4543+
4544+
4545+def get_test_window_installedpane():
4546+ # needed because available pane will try to get it
4547+ vm = get_test_gtk3_viewmanager()
4548+ vm # make pyflakes happy
4549+ db = get_test_db()
4550+ cache = get_test_pkg_info()
4551+ datadir = get_test_datadir()
4552+ icons = get_test_gtk3_icon_cache()
4553+
4554+ w = installedpane.InstalledPane(cache, db, 'Ubuntu', icons, datadir)
4555+ w.show()
4556+
4557+ # init the view
4558+ w.init_view()
4559+
4560+ w.state.channel = channel.AllInstalledChannel()
4561+ view_state = softwarepane.DisplayState()
4562+ view_state.channel = channel.AllInstalledChannel()
4563+ w.display_overview_page(None, view_state)
4564+
4565+ win = get_test_window(child=w)
4566+ win.set_data("pane", w)
4567+ return win
4568+
4569+
4570+def get_test_window_historypane():
4571+ # needed because available pane will try to get it
4572+ vm = get_test_gtk3_viewmanager()
4573+ vm # make pyflakes happy
4574+ db = get_test_db()
4575+ cache = get_test_pkg_info()
4576+ icons = get_test_gtk3_icon_cache()
4577+
4578+ widget = historypane.HistoryPane(cache, db, None, icons, None)
4579+ widget.show()
4580+
4581+ win = get_test_window(child=widget)
4582+ widget.init_view()
4583+ return win
4584+
4585+
4586+def get_test_window_recommendations(panel_type="lobby"):
4587+ # this is *way* too complicated we should *not* need a CatView
4588+ # here! see FIXME in RecommendationsPanel.__init__()
4589+ cache = get_test_pkg_info()
4590+ db = get_test_db()
4591+ icons = get_test_gtk3_icon_cache()
4592+ catview = catview_gtk.CategoriesViewGtk(softwarecenter.paths.datadir,
4593+ softwarecenter.paths.APP_INSTALL_PATH, cache, db, icons)
4594+
4595+ if panel_type is "lobby":
4596+ view = recommendations.RecommendationsPanelLobby(catview)
4597+ elif panel_type is "category":
4598+ cats = get_test_categories(db)
4599+ view = recommendations.RecommendationsPanelCategory(catview, cats[0])
4600+ else: # panel_type is "details":
4601+ view = recommendations.RecommendationsPanelDetails(catview)
4602+
4603+ win = get_test_window(child=view)
4604+ win.set_data("rec_panel", view)
4605+ return win
4606+
4607+
4608+def get_test_window_catview(db=None):
4609+
4610+ def on_category_selected(view, cat):
4611+ print("on_category_selected view: ", view)
4612+ print("on_category_selected cat: ", cat)
4613+
4614+ if db is None:
4615+ cache = pkginfo.get_pkg_info()
4616+ cache.open()
4617+
4618+ xapian_base_path = "/var/cache/software-center"
4619+ pathname = os.path.join(xapian_base_path, "xapian")
4620+ db = database.StoreDatabase(pathname, cache)
4621+ db.open()
4622+ else:
4623+ cache = db._aptcache
4624+
4625+ datadir = softwarecenter.paths.datadir
4626+ icons = get_sc_icon_theme(datadir)
4627+ distro = softwarecenter.distro.get_distro()
4628+ apps_filter = appfilter.AppFilter(db, cache)
4629+
4630+ # gui
4631+ notebook = Gtk.Notebook()
4632+
4633+ lobby_view = catview_gtk.LobbyViewGtk(softwarecenter.paths.datadir,
4634+ softwarecenter.paths.APP_INSTALL_PATH,
4635+ cache, db, icons, distro, apps_filter)
4636+
4637+ scroll = Gtk.ScrolledWindow()
4638+ scroll.add(lobby_view)
4639+ notebook.append_page(scroll, Gtk.Label(label="Lobby"))
4640+
4641+ # find a cat in the LobbyView that has subcategories
4642+ subcat_cat = None
4643+ for cat in reversed(lobby_view.categories):
4644+ if cat.subcategories:
4645+ subcat_cat = cat
4646+ break
4647+
4648+ subcat_view = catview_gtk.SubCategoryViewGtk(datadir,
4649+ softwarecenter.paths.APP_INSTALL_PATH, cache, db, icons, apps_filter)
4650+ subcat_view.connect("category-selected", on_category_selected)
4651+ subcat_view.set_subcategory(subcat_cat)
4652+
4653+ scroll = Gtk.ScrolledWindow()
4654+ scroll.add(subcat_view)
4655+ notebook.append_page(scroll, Gtk.Label(label="Subcats"))
4656+
4657+ win = get_test_window(child=notebook, width=800, height=800)
4658+ win.set_data("subcat", subcat_view)
4659+ win.set_data("lobby", lobby_view)
4660+ return win
4661+
4662+
4663+def get_test_catview():
4664+
4665+ def on_category_selected(view, cat):
4666+ print("on_category_selected %s %s" % (view, cat))
4667+
4668+ cache = pkginfo.get_pkg_info()
4669+ cache.open()
4670+
4671+ xapian_base_path = "/var/cache/software-center"
4672+ pathname = os.path.join(xapian_base_path, "xapian")
4673+ db = database.StoreDatabase(pathname, cache)
4674+ db.open()
4675+
4676+ datadir = softwarecenter.paths.datadir
4677+ icons = get_sc_icon_theme(datadir)
4678+ distro = softwarecenter.distro.get_distro()
4679+ apps_filter = appfilter.AppFilter(db, cache)
4680+
4681+ cat_view = catview_gtk.LobbyViewGtk(softwarecenter.paths.datadir,
4682+ softwarecenter.paths.APP_INSTALL_PATH,
4683+ cache, db, icons, distro, apps_filter)
4684+
4685+ return cat_view
4686+
4687+
4688+def get_test_window_appdetails(pkgname=None):
4689+ cache = pkginfo.get_pkg_info()
4690+ cache.open()
4691+
4692+ xapian_base_path = "/var/cache/software-center"
4693+ pathname = os.path.join(xapian_base_path, "xapian")
4694+ db = database.StoreDatabase(pathname, cache)
4695+ db.open()
4696+
4697+ datadir = softwarecenter.paths.datadir
4698+ icons = get_sc_icon_theme(datadir)
4699+ distro = softwarecenter.distro.get_distro()
4700+
4701+ # gui
4702+ scroll = Gtk.ScrolledWindow()
4703+ view = appdetailsview.AppDetailsView(db, distro, icons, cache, datadir)
4704+
4705+ if pkgname is None:
4706+ pkgname = "totem"
4707+
4708+ view.show_app(application.Application("", pkgname))
4709+ #view.show_app(application.Application("Pay App Example", "pay-app"))
4710+ #view.show_app(application.Application("3D Chess", "3dchess"))
4711+ #view.show_app(application.Application("Movie Player", "totem"))
4712+ #view.show_app(application.Application("ACE", "unace"))
4713+ #~ view.show_app(application.Application("", "apt"))
4714+
4715+ #view.show_app("AMOR")
4716+ #view.show_app("Configuration Editor")
4717+ #view.show_app("Artha")
4718+ #view.show_app("cournol")
4719+ #view.show_app("Qlix")
4720+
4721+ scroll.add(view)
4722+ scroll.show()
4723+
4724+ win = get_test_window(child=scroll, width=800, height=800)
4725+ win.set_data("view", view)
4726+ return win
4727+
4728+
4729+def get_test_window_pkgnamesview():
4730+ cache = pkginfo.get_pkg_info()
4731+ cache.open()
4732+
4733+ xapian_base_path = "/var/cache/software-center"
4734+ pathname = os.path.join(xapian_base_path, "xapian")
4735+ db = database.StoreDatabase(pathname, cache)
4736+ db.open()
4737+
4738+ datadir = softwarecenter.paths.datadir
4739+ icons = get_sc_icon_theme(datadir)
4740+ pkgs = ["apt", "software-center"]
4741+ view = pkgnamesview.PackageNamesView("header", cache, pkgs, icons, 32, db)
4742+ view.show()
4743+
4744+ win = get_test_window(child=view)
4745+ return win
4746+
4747+
4748+@patch_datadir('./tests/data')
4749+def get_test_window_purchaseview(url=None):
4750+ if url is None:
4751+ #url = "http://www.animiertegifs.de/java-scripts/alertbox.php"
4752+ url = "http://www.ubuntu.cohtml=DUMMY_m"
4753+ #d = PurchaseDialog(app=None, url="http://spiegel.de")
4754+ url_args = urllib.urlencode({'archive_id': "mvo/private-test",
4755+ 'arch': "i386"})
4756+ url = (BUY_SOMETHING_HOST +
4757+ "/subscriptions/en/ubuntu/precise/+new/?%s" % url_args)
4758+
4759+ # useful for debugging
4760+ #d.connect("key-press-event", _on_key_press)
4761+ #GObject.timeout_add_seconds(1, _generate_events, d)
4762+
4763+ widget = purchaseview.PurchaseView()
4764+ widget.config = Mock()
4765+
4766+ win = get_test_window(child=widget)
4767+ win.set_data("view", widget)
4768+
4769+ widget.initiate_purchase(app=None, iconname=None, url=url)
4770+ #widget.initiate_purchase(app=None, iconname=None, html=DUMMY_HTML)
4771+
4772+ return win
4773+
4774+
4775+def get_test_backforward_window():
4776+ backforward_button = backforward.BackForwardButton()
4777+ win = get_test_window(child=backforward_button)
4778+ return win
4779+
4780+
4781+def get_test_container_window():
4782+ f = containers.FlowableGrid()
4783+
4784+ for i in range(10):
4785+ t = buttons.CategoryTile("test", "folder")
4786+ f.add_child(t)
4787+
4788+ scroll = Gtk.ScrolledWindow()
4789+ scroll.add_with_viewport(f)
4790+
4791+ win = get_test_window(child=scroll)
4792+ return win
4793+
4794+
4795+def _build_channels_list(popup):
4796+ for i in range(3):
4797+ item = Gtk.MenuItem.new()
4798+ label = Gtk.Label.new("channel_name %s" % i)
4799+ box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, em.StockEms.MEDIUM)
4800+ box.pack_start(label, False, False, 0)
4801+ item.add(box)
4802+ item.show_all()
4803+ popup.attach(item, 0, 1, i, i + 1)
4804+
4805+
4806+def get_test_buttons_window():
4807+ vb = Gtk.VBox(spacing=12)
4808+ link = buttons.Link("<small>test link</small>", uri="www.google.co.nz")
4809+ vb.pack_start(link, False, False, 0)
4810+
4811+ button = Gtk.Button()
4812+ button.set_label("channels")
4813+ channels_button = buttons.ChannelSelector(button)
4814+ channels_button.parent_style_type = Gtk.Window
4815+ channels_button.set_build_func(_build_channels_list)
4816+ hb = Gtk.HBox()
4817+ hb.pack_start(button, False, False, 0)
4818+ hb.pack_start(channels_button, False, False, 0)
4819+ vb.pack_start(hb, False, False, 0)
4820+
4821+ win = get_test_window(child=vb)
4822+ return win
4823+
4824+
4825+def get_test_description_window():
4826+ EXAMPLE0 = """p7zip is the Unix port of 7-Zip, a file archiver that \
4827+archives with very high compression ratios.
4828+
4829+p7zip-full provides:
4830+
4831+ - /usr/bin/7za a standalone version of the 7-zip tool that handles
4832+ 7z archives (implementation of the LZMA compression algorithm) and some \
4833+other formats.
4834+
4835+ - /usr/bin/7z not only does it handle 7z but also ZIP, Zip64, CAB, RAR, \
4836+ARJ, GZIP,
4837+ BZIP2, TAR, CPIO, RPM, ISO and DEB archives. 7z compression is 30-50% \
4838+better than ZIP compression.
4839+
4840+p7zip provides 7zr, a light version of 7za, and p7zip a gzip like wrapper \
4841+around 7zr."""
4842+
4843+ EXAMPLE1 = """Transmageddon supports almost any format as its input and \
4844+can generate a very large host of output files. The goal of the application \
4845+was to help people to create the files they need to be able to play on their \
4846+mobile devices and for people not hugely experienced with multimedia to \
4847+generate a multimedia file without having to resort to command line tools \
4848+with ungainly syntaxes.
4849+The currently supported codecs are:
4850+ * Containers:
4851+ - Ogg
4852+ - Matroska
4853+ - AVI
4854+ - MPEG TS
4855+ - flv
4856+ - QuickTime
4857+ - MPEG4
4858+ - 3GPP
4859+ - MXT
4860+ * Audio encoders:
4861+ - Vorbis
4862+ - FLAC
4863+ - MP3
4864+ - AAC
4865+ - AC3
4866+ - Speex
4867+ - Celt
4868+ * Video encoders:
4869+ - Theora
4870+ - Dirac
4871+ - H264
4872+ - MPEG2
4873+ - MPEG4/DivX5
4874+ - xvid
4875+ - DNxHD
4876+It also provide the support for the GStreamer's plugins auto-search."""
4877+
4878+ EXAMPLE2 = """File-roller is an archive manager for the GNOME \
4879+environment. It allows you to:
4880+ * Create and modify archives.
4881+ * View the content of an archive.
4882+ * View a file contained in an archive.
4883+ * Extract files from the archive.
4884+File-roller supports the following formats:
4885+ * Tar (.tar) archives, including those compressed with
4886+ gzip (.tar.gz, .tgz), bzip (.tar.bz, .tbz), bzip2 (.tar.bz2, .tbz2),
4887+ compress (.tar.Z, .taz), lzip (.tar.lz, .tlz), lzop (.tar.lzo, .tzo),
4888+ lzma (.tar.lzma) and xz (.tar.xz)
4889+ * Zip archives (.zip)
4890+ * Jar archives (.jar, .ear, .war)
4891+ * 7z archives (.7z)
4892+ * iso9660 CD images (.iso)
4893+ * Lha archives (.lzh)
4894+ * Single files compressed with gzip (.gz), bzip (.bz), bzip2 (.bz2),
4895+ compress (.Z), lzip (.lz), lzop (.lzo), lzma (.lzma) and xz (.xz)
4896+File-roller doesn't perform archive operations by itself, but relies on \
4897+standard tools for this."""
4898+
4899+ EXAMPLE3 = """This package includes the following CTAN packages:
4900+ Asana-Math -- A font to typeset maths in Xe(La)TeX.
4901+ albertus --
4902+ allrunes -- Fonts and LaTeX package for almost all runes.
4903+ antiqua -- the URW Antiqua Condensed Font.
4904+ antp -- Antykwa Poltawskiego: a Type 1 family of Polish traditional type.
4905+ antt -- Antykwa Torunska: a Type 1 family of a Polish traditional type.
4906+ apl -- Fonts for typesetting APL programs.
4907+ ar -- Capital A and capital R ligature for Apsect Ratio.
4908+ archaic -- A collection of archaic fonts.
4909+ arev -- Fonts and LaTeX support files for Arev Sans.
4910+ ascii -- Support for IBM "standard ASCII" font.
4911+ astro -- Astronomical (planetary) symbols.
4912+ atqolive --
4913+ augie -- Calligraphic font for typesetting handwriting.
4914+ auncial-new -- Artificial Uncial font and LaTeX support macros.
4915+ aurical -- Calligraphic fonts for use with LaTeX in T1 encoding.
4916+ barcodes -- Fonts for making barcodes.
4917+ bayer -- Herbert Bayers Universal Font For Metafont.
4918+ bbding -- A symbol (dingbat) font and LaTeX macros for its use.
4919+ bbm -- "Blackboard-style" cm fonts.
4920+ bbm-macros -- LaTeX support for "blackboard-style" cm fonts.
4921+ bbold -- Sans serif blackboard bold.
4922+ belleek -- Free replacement for basic MathTime fonts.
4923+ bera -- Bera fonts.
4924+ blacklettert1 -- T1-encoded versions of Haralambous old German fonts.
4925+ boisik -- A font inspired by Baskerville design.
4926+ bookhands -- A collection of book-hand fonts.
4927+ braille -- Support for braille.
4928+ brushscr -- A handwriting script font.
4929+ calligra -- Calligraphic font.
4930+ carolmin-ps -- Adobe Type 1 format of Carolingian Minuscule fonts.
4931+ cherokee -- A font for the Cherokee script.
4932+ clarendo --
4933+ cm-lgc -- Type 1 CM-based fonts for Latin, Greek and Cyrillic.
4934+ cmbright -- Computer Modern Bright fonts.
4935+ cmll -- Symbols for linear logic.
4936+ cmpica -- A Computer Modern Pica variant.
4937+ coronet --
4938+ courier-scaled -- Provides a scaled Courier font.
4939+ cryst -- Font for graphical symbols used in crystallography.
4940+ cyklop -- The Cyclop typeface.
4941+ dancers -- Font for Conan Doyle's "The Dancing Men".
4942+ dice -- A font for die faces.
4943+ dictsym -- DictSym font and macro package
4944+ dingbat -- Two dingbat symbol fonts.
4945+ doublestroke -- Typeset mathematical double stroke symbols.
4946+ dozenal -- Typeset documents using base twelve numbering (also called
4947+ "dozenal")
4948+ duerer -- Computer Duerer fonts.
4949+ duerer-latex -- LaTeX support for the Duerer fonts.
4950+ ean -- Macros for making EAN barcodes.
4951+ ecc -- Sources for the European Concrete fonts.
4952+ eco -- Oldstyle numerals using EC fonts.
4953+ eiad -- Traditional style Irish fonts.
4954+ eiad-ltx -- LaTeX support for the eiad font.
4955+ elvish -- Fonts for typesetting Tolkien Elvish scripts.
4956+ epigrafica -- A Greek and Latin font.
4957+ epsdice -- A scalable dice "font".
4958+ esvect -- Vector arrows.
4959+ eulervm -- Euler virtual math fonts.
4960+ euxm --
4961+ feyn -- A font for in-text Feynman diagrams.
4962+ fge -- A font for Frege's Grundgesetze der Arithmetik.
4963+ foekfont -- The title font of the Mads Fok magazine.
4964+ fonetika -- Support for the danish "Dania" phonetic system.
4965+ fourier -- Using Utopia fonts in LaTeX documents.
4966+ fouriernc -- Use New Century Schoolbook text with Fourier maths fonts.
4967+ frcursive -- French cursive hand fonts.
4968+ garamond --
4969+ genealogy -- A compilation genealogy font.
4970+ gfsartemisia -- A modern Greek font design.
4971+ gfsbodoni -- A Greek and Latin font based on Bodoni.
4972+ gfscomplutum -- A Greek font with a long history.
4973+ gfsdidot -- A Greek font based on Didot's work.
4974+ gfsneohellenic -- A Greek font in the Neo-Hellenic style.
4975+ gfssolomos -- A Greek-alphabet font.
4976+ gothic -- A collection of old German-style fonts.
4977+ greenpoint -- The Green Point logo.
4978+ groff --
4979+ grotesq -- the URW Grotesk Bold Font.
4980+ hands -- Pointing hand font.
4981+ hfbright -- The hfbright fonts.
4982+ hfoldsty -- Old style numerals with EC fonts.
4983+ ifsym -- A collection of symbols.
4984+ inconsolata -- A monospaced font, with support files for use with TeX.
4985+ initials -- Adobe Type 1 decorative initial fonts.
4986+ iwona -- A two-element sans-serif font.
4987+ junicode -- A TrueType font for mediaevalists.
4988+ kixfont -- A font for KIX codes.
4989+ knuthotherfonts --
4990+ kpfonts -- A complete set of fonts for text and mathematics.
4991+ kurier -- A two-element sans-serif typeface.
4992+ lettrgth --
4993+ lfb -- A Greek font with normal and bold variants.
4994+ libertine -- Use the font Libertine with LaTeX.
4995+ libris -- Libris ADF fonts, with LaTeX support.
4996+ linearA -- Linear A script fonts.
4997+ logic -- A font for electronic logic design.
4998+ lxfonts -- Set of slide fonts based on CM.
4999+ ly1 -- Support for LY1 LaTeX encoding.
5000+ marigold --
The diff has been truncated for viewing.