1
from __future__ import print_function
10
from gi.repository import Gdk, GObject, Gtk
13
import softwarecenter.distro
14
import softwarecenter.log
15
import softwarecenter.paths
17
from softwarecenter.backend import channel
18
from softwarecenter.db import (
25
from softwarecenter.enums import (
29
from softwarecenter.ui.gtk3 import em
30
from softwarecenter.ui.gtk3.dialogs import dependency_dialogs
31
from softwarecenter.ui.gtk3.models import appstore2
32
from softwarecenter.ui.gtk3.panes import (
41
from softwarecenter.ui.gtk3.session import appmanager
42
from softwarecenter.ui.gtk3.utils import (
46
from softwarecenter.ui.gtk3.views import (
53
from softwarecenter.ui.gtk3.widgets import (
70
from softwarecenter.utils import ExecutionTime
71
from tests.utils import (
76
get_test_gtk3_icon_cache,
77
get_test_gtk3_viewmanager,
78
get_test_install_backend,
84
if os.environ.get('SOFTWARE_CENTER_PERFORMANCE_DEBUG', False):
85
softwarecenter.log.root.setLevel(level=logging.DEBUG)
86
softwarecenter.log.add_filters_from_string("performance")
87
fmt = logging.Formatter("%(name)s - %(message)s", None)
88
softwarecenter.log.handler.setFormatter(fmt)
91
if os.environ.get('SOFTWARE_CENTER_DEBUG', False):
92
softwarecenter.log.root.setLevel(level=logging.DEBUG)
93
fmt = logging.Formatter("%(name)s - %(message)s", None)
94
softwarecenter.log.handler.setFormatter(fmt)
97
def get_test_window(child, width=600, height=800, border_width=0, title=None):
99
win.set_size_request(width, height)
100
win.set_position(Gtk.WindowPosition.CENTER)
101
win.set_border_width(border_width)
104
title = child.__class__.__name__
110
def get_test_window_dependency_dialog():
111
icons = get_test_gtk3_icon_cache()
114
depends = ["apt", "synaptic"]
115
app = application.Application("", "software-center")
116
primary = "primary text"
117
button_text = "button_text"
118
dia = dependency_dialogs._get_confirm_internal_dialog(
119
parent=None, datadir=softwarecenter.paths.datadir, app=app,
120
db=db, icons=icons, primary=primary, button_text=button_text,
121
depends=depends, cache=db._aptcache)
125
def get_test_window_confirm_remove():
126
# test real remove dialog
127
icons = get_test_gtk3_icon_cache()
129
app = application.Application("", "p7zip-full")
130
return dependency_dialogs.confirm_remove(None,
131
softwarecenter.paths.datadir, app, db, icons)
134
def get_query_from_search_entry(search_term):
136
return xapian.Query("")
137
parser = xapian.QueryParser()
138
user_query = parser.parse_query(search_term)
142
def on_entry_changed(widget, data):
145
new_text = widget.get_text()
146
(view, enquirer) = data
148
with ExecutionTime("total time"):
149
with ExecutionTime("enquire.set_query()"):
150
enquirer.set_query(get_query_from_search_entry(new_text),
152
nonapps_visible=NonAppVisibility.ALWAYS_VISIBLE)
154
store = view.tree_view.get_model()
158
with ExecutionTime("store.clear()"):
161
with ExecutionTime("store.set_from_matches()"):
162
store.set_from_matches(enquirer.matches)
164
with ExecutionTime("model settle (size=%s)" % len(store)):
168
GObject.source_remove(widget.stamp)
169
widget.stamp = GObject.timeout_add(250, _work)
172
def get_test_window_appview():
174
cache = get_test_pkg_info()
175
icons = get_test_gtk3_icon_cache()
178
app_filter = appfilter.AppFilter(db, cache)
179
app_filter.set_supported_only(False)
180
app_filter.set_installed_only(True)
183
enquirer = enquire.AppEnquire(cache, db)
184
store = appstore2.AppListStore(db, cache, icons)
186
view = appview.AppView(db, cache, icons, show_ratings=True)
187
view.set_model(store)
191
entry.connect("changed", on_entry_changed, (view, enquirer))
192
entry.set_text("gtk3")
195
box.pack_start(entry, False, True, 0)
196
box.pack_start(view, True, True, 0)
198
win = get_test_window(child=box)
199
win.set_data("appview", view)
200
win.set_data("entry", entry)
205
def get_test_window_apptreeview():
206
cache = get_test_pkg_info()
208
icons = get_test_gtk3_icon_cache()
211
app_filter = appfilter.AppFilter(db, cache)
212
app_filter.set_supported_only(False)
213
app_filter.set_installed_only(True)
216
store = appstore2.AppTreeStore(db, cache, icons)
219
cats = get_test_categories(db)
221
with ExecutionTime("query cat '%s'" % cat.name):
222
docs = db.get_docs_from_query(cat.query)
223
store.set_category_documents(cat, docs)
225
# ok, this is confusing - the AppView contains the AppTreeView that
226
# is a tree or list depending on the model
227
app_view = appview.AppView(db, cache, icons, show_ratings=True)
228
app_view.set_model(store)
231
box.pack_start(app_view, True, True, 0)
233
win = get_test_window(child=box)
237
def get_test_window_availablepane():
238
# needed because available pane will try to get it
239
vm = get_test_gtk3_viewmanager()
240
vm # make pyflakes happy
242
cache = get_test_pkg_info()
243
datadir = get_test_datadir()
244
icons = get_test_gtk3_icon_cache()
245
backend = get_test_install_backend()
247
manager = appmanager.get_appmanager()
249
# create global AppManager instance
250
manager = appmanager.ApplicationManager(db, backend, icons)
252
navhistory_back_action = Gtk.Action("navhistory_back_action", "Back",
254
navhistory_forward_action = Gtk.Action("navhistory_forward_action",
255
"Forward", "Forward", None)
257
w = availablepane.AvailablePane(cache, db, 'Ubuntu', icons, datadir,
258
navhistory_back_action, navhistory_forward_action)
262
win = get_test_window(child=w, width=800, height=600)
263
# this is used later in tests
264
win.set_data("pane", w)
268
def get_test_window_globalpane():
269
vm = get_test_gtk3_viewmanager()
271
cache = get_test_pkg_info()
272
datadir = get_test_datadir()
273
icons = get_test_gtk3_icon_cache()
275
p = globalpane.GlobalPane(vm, datadir, db, cache, icons)
277
win = get_test_window(child=p)
278
win.set_data("pane", p)
282
def get_test_window_pendingpane():
283
icons = get_test_gtk3_icon_cache()
285
view = pendingpane.PendingPane(icons)
288
scroll = Gtk.ScrolledWindow()
289
scroll.add_with_viewport(view)
291
win = get_test_window(child=scroll)
296
@patch_datadir('./data')
297
def get_test_window_viewswitcher():
298
cache = get_test_pkg_info()
300
icons = get_test_gtk3_icon_cache()
301
datadir = get_test_datadir()
302
manager = get_test_gtk3_viewmanager()
304
view = viewswitcher.ViewSwitcher(manager, datadir, db, cache, icons)
306
scroll = Gtk.ScrolledWindow()
308
box.pack_start(scroll, True, True, 0)
310
win = get_test_window(child=box)
311
scroll.add_with_viewport(view)
315
def get_test_window_installedpane():
316
# needed because available pane will try to get it
317
vm = get_test_gtk3_viewmanager()
318
vm # make pyflakes happy
320
cache = get_test_pkg_info()
321
datadir = get_test_datadir()
322
icons = get_test_gtk3_icon_cache()
324
w = installedpane.InstalledPane(cache, db, 'Ubuntu', icons, datadir)
330
w.state.channel = channel.AllInstalledChannel()
331
view_state = softwarepane.DisplayState()
332
view_state.channel = channel.AllInstalledChannel()
333
w.display_overview_page(None, view_state)
335
win = get_test_window(child=w)
336
win.set_data("pane", w)
340
def get_test_window_historypane():
341
# needed because available pane will try to get it
342
vm = get_test_gtk3_viewmanager()
343
vm # make pyflakes happy
345
cache = get_test_pkg_info()
346
icons = get_test_gtk3_icon_cache()
348
widget = historypane.HistoryPane(cache, db, None, icons, None)
351
win = get_test_window(child=widget)
356
def get_test_window_recommendations(panel_type="lobby"):
357
# this is *way* too complicated we should *not* need a CatView
358
# here! see FIXME in RecommendationsPanel.__init__()
359
cache = get_test_pkg_info()
361
icons = get_test_gtk3_icon_cache()
362
catview = catview_gtk.CategoriesViewGtk(softwarecenter.paths.datadir,
363
softwarecenter.paths.APP_INSTALL_PATH, cache, db, icons)
365
if panel_type is "lobby":
366
view = recommendations.RecommendationsPanelLobby(catview)
367
elif panel_type is "category":
368
cats = get_test_categories(db)
369
view = recommendations.RecommendationsPanelCategory(catview, cats[0])
370
else: # panel_type is "details":
371
view = recommendations.RecommendationsPanelDetails(catview)
373
win = get_test_window(child=view)
374
win.set_data("rec_panel", view)
378
def get_test_window_catview(db=None):
380
def on_category_selected(view, cat):
381
print("on_category_selected view: ", view)
382
print("on_category_selected cat: ", cat)
385
cache = pkginfo.get_pkg_info()
388
xapian_base_path = "/var/cache/software-center"
389
pathname = os.path.join(xapian_base_path, "xapian")
390
db = database.StoreDatabase(pathname, cache)
395
datadir = softwarecenter.paths.datadir
396
icons = get_sc_icon_theme(datadir)
397
distro = softwarecenter.distro.get_distro()
398
apps_filter = appfilter.AppFilter(db, cache)
401
notebook = Gtk.Notebook()
403
lobby_view = catview_gtk.LobbyViewGtk(softwarecenter.paths.datadir,
404
softwarecenter.paths.APP_INSTALL_PATH,
405
cache, db, icons, distro, apps_filter)
407
scroll = Gtk.ScrolledWindow()
408
scroll.add(lobby_view)
409
notebook.append_page(scroll, Gtk.Label(label="Lobby"))
411
# find a cat in the LobbyView that has subcategories
413
for cat in reversed(lobby_view.categories):
414
if cat.subcategories:
418
subcat_view = catview_gtk.SubCategoryViewGtk(datadir,
419
softwarecenter.paths.APP_INSTALL_PATH, cache, db, icons, apps_filter)
420
subcat_view.connect("category-selected", on_category_selected)
421
subcat_view.set_subcategory(subcat_cat)
423
scroll = Gtk.ScrolledWindow()
424
scroll.add(subcat_view)
425
notebook.append_page(scroll, Gtk.Label(label="Subcats"))
427
win = get_test_window(child=notebook, width=800, height=800)
428
win.set_data("subcat", subcat_view)
429
win.set_data("lobby", lobby_view)
433
def get_test_catview():
435
def on_category_selected(view, cat):
436
print("on_category_selected %s %s" % (view, cat))
438
cache = pkginfo.get_pkg_info()
441
xapian_base_path = "/var/cache/software-center"
442
pathname = os.path.join(xapian_base_path, "xapian")
443
db = database.StoreDatabase(pathname, cache)
446
datadir = softwarecenter.paths.datadir
447
icons = get_sc_icon_theme(datadir)
448
distro = softwarecenter.distro.get_distro()
449
apps_filter = appfilter.AppFilter(db, cache)
451
cat_view = catview_gtk.LobbyViewGtk(softwarecenter.paths.datadir,
452
softwarecenter.paths.APP_INSTALL_PATH,
453
cache, db, icons, distro, apps_filter)
458
def get_test_window_appdetails(pkgname=None):
459
cache = pkginfo.get_pkg_info()
462
xapian_base_path = "/var/cache/software-center"
463
pathname = os.path.join(xapian_base_path, "xapian")
464
db = database.StoreDatabase(pathname, cache)
467
datadir = softwarecenter.paths.datadir
468
icons = get_sc_icon_theme(datadir)
469
distro = softwarecenter.distro.get_distro()
472
scroll = Gtk.ScrolledWindow()
473
view = appdetailsview.AppDetailsView(db, distro, icons, cache, datadir)
478
view.show_app(application.Application("", pkgname))
479
#view.show_app(application.Application("Pay App Example", "pay-app"))
480
#view.show_app(application.Application("3D Chess", "3dchess"))
481
#view.show_app(application.Application("Movie Player", "totem"))
482
#view.show_app(application.Application("ACE", "unace"))
483
#~ view.show_app(application.Application("", "apt"))
485
#view.show_app("AMOR")
486
#view.show_app("Configuration Editor")
487
#view.show_app("Artha")
488
#view.show_app("cournol")
489
#view.show_app("Qlix")
494
win = get_test_window(child=scroll, width=800, height=800)
495
win.set_data("view", view)
499
def get_test_window_pkgnamesview():
500
cache = pkginfo.get_pkg_info()
503
xapian_base_path = "/var/cache/software-center"
504
pathname = os.path.join(xapian_base_path, "xapian")
505
db = database.StoreDatabase(pathname, cache)
508
datadir = softwarecenter.paths.datadir
509
icons = get_sc_icon_theme(datadir)
510
pkgs = ["apt", "software-center"]
511
view = pkgnamesview.PackageNamesView("header", cache, pkgs, icons, 32, db)
514
win = get_test_window(child=view)
518
@patch_datadir('./tests/data')
519
def get_test_window_purchaseview(url=None):
521
#url = "http://www.animiertegifs.de/java-scripts/alertbox.php"
522
url = "http://www.ubuntu.cohtml=DUMMY_m"
523
#d = PurchaseDialog(app=None, url="http://spiegel.de")
524
url_args = urllib.urlencode({'archive_id': "mvo/private-test",
526
url = (BUY_SOMETHING_HOST +
527
"/subscriptions/en/ubuntu/precise/+new/?%s" % url_args)
529
# useful for debugging
530
#d.connect("key-press-event", _on_key_press)
531
#GObject.timeout_add_seconds(1, _generate_events, d)
533
widget = purchaseview.PurchaseView()
534
widget.config = Mock()
536
win = get_test_window(child=widget)
537
win.set_data("view", widget)
539
widget.initiate_purchase(app=None, iconname=None, url=url)
540
#widget.initiate_purchase(app=None, iconname=None, html=DUMMY_HTML)
545
def get_test_backforward_window():
546
backforward_button = backforward.BackForwardButton()
547
win = get_test_window(child=backforward_button)
551
def get_test_container_window():
552
f = containers.FlowableGrid()
555
t = buttons.CategoryTile("test", "folder")
558
scroll = Gtk.ScrolledWindow()
559
scroll.add_with_viewport(f)
561
win = get_test_window(child=scroll)
565
def _build_channels_list(popup):
567
item = Gtk.MenuItem.new()
568
label = Gtk.Label.new("channel_name %s" % i)
569
box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, em.StockEms.MEDIUM)
570
box.pack_start(label, False, False, 0)
573
popup.attach(item, 0, 1, i, i + 1)
576
def get_test_buttons_window():
577
vb = Gtk.VBox(spacing=12)
578
link = buttons.Link("<small>test link</small>", uri="www.google.co.nz")
579
vb.pack_start(link, False, False, 0)
581
button = Gtk.Button()
582
button.set_label("channels")
583
channels_button = buttons.ChannelSelector(button)
584
channels_button.parent_style_type = Gtk.Window
585
channels_button.set_build_func(_build_channels_list)
587
hb.pack_start(button, False, False, 0)
588
hb.pack_start(channels_button, False, False, 0)
589
vb.pack_start(hb, False, False, 0)
591
win = get_test_window(child=vb)
595
def get_test_description_window():
596
EXAMPLE0 = """p7zip is the Unix port of 7-Zip, a file archiver that \
597
archives with very high compression ratios.
601
- /usr/bin/7za a standalone version of the 7-zip tool that handles
602
7z archives (implementation of the LZMA compression algorithm) and some \
605
- /usr/bin/7z not only does it handle 7z but also ZIP, Zip64, CAB, RAR, \
607
BZIP2, TAR, CPIO, RPM, ISO and DEB archives. 7z compression is 30-50% \
608
better than ZIP compression.
610
p7zip provides 7zr, a light version of 7za, and p7zip a gzip like wrapper \
613
EXAMPLE1 = """Transmageddon supports almost any format as its input and \
614
can generate a very large host of output files. The goal of the application \
615
was to help people to create the files they need to be able to play on their \
616
mobile devices and for people not hugely experienced with multimedia to \
617
generate a multimedia file without having to resort to command line tools \
618
with ungainly syntaxes.
619
The currently supported codecs are:
646
It also provide the support for the GStreamer's plugins auto-search."""
648
EXAMPLE2 = """File-roller is an archive manager for the GNOME \
649
environment. It allows you to:
650
* Create and modify archives.
651
* View the content of an archive.
652
* View a file contained in an archive.
653
* Extract files from the archive.
654
File-roller supports the following formats:
655
* Tar (.tar) archives, including those compressed with
656
gzip (.tar.gz, .tgz), bzip (.tar.bz, .tbz), bzip2 (.tar.bz2, .tbz2),
657
compress (.tar.Z, .taz), lzip (.tar.lz, .tlz), lzop (.tar.lzo, .tzo),
658
lzma (.tar.lzma) and xz (.tar.xz)
659
* Zip archives (.zip)
660
* Jar archives (.jar, .ear, .war)
662
* iso9660 CD images (.iso)
663
* Lha archives (.lzh)
664
* Single files compressed with gzip (.gz), bzip (.bz), bzip2 (.bz2),
665
compress (.Z), lzip (.lz), lzop (.lzo), lzma (.lzma) and xz (.xz)
666
File-roller doesn't perform archive operations by itself, but relies on \
667
standard tools for this."""
669
EXAMPLE3 = """This package includes the following CTAN packages:
670
Asana-Math -- A font to typeset maths in Xe(La)TeX.
672
allrunes -- Fonts and LaTeX package for almost all runes.
673
antiqua -- the URW Antiqua Condensed Font.
674
antp -- Antykwa Poltawskiego: a Type 1 family of Polish traditional type.
675
antt -- Antykwa Torunska: a Type 1 family of a Polish traditional type.
676
apl -- Fonts for typesetting APL programs.
677
ar -- Capital A and capital R ligature for Apsect Ratio.
678
archaic -- A collection of archaic fonts.
679
arev -- Fonts and LaTeX support files for Arev Sans.
680
ascii -- Support for IBM "standard ASCII" font.
681
astro -- Astronomical (planetary) symbols.
683
augie -- Calligraphic font for typesetting handwriting.
684
auncial-new -- Artificial Uncial font and LaTeX support macros.
685
aurical -- Calligraphic fonts for use with LaTeX in T1 encoding.
686
barcodes -- Fonts for making barcodes.
687
bayer -- Herbert Bayers Universal Font For Metafont.
688
bbding -- A symbol (dingbat) font and LaTeX macros for its use.
689
bbm -- "Blackboard-style" cm fonts.
690
bbm-macros -- LaTeX support for "blackboard-style" cm fonts.
691
bbold -- Sans serif blackboard bold.
692
belleek -- Free replacement for basic MathTime fonts.
694
blacklettert1 -- T1-encoded versions of Haralambous old German fonts.
695
boisik -- A font inspired by Baskerville design.
696
bookhands -- A collection of book-hand fonts.
697
braille -- Support for braille.
698
brushscr -- A handwriting script font.
699
calligra -- Calligraphic font.
700
carolmin-ps -- Adobe Type 1 format of Carolingian Minuscule fonts.
701
cherokee -- A font for the Cherokee script.
703
cm-lgc -- Type 1 CM-based fonts for Latin, Greek and Cyrillic.
704
cmbright -- Computer Modern Bright fonts.
705
cmll -- Symbols for linear logic.
706
cmpica -- A Computer Modern Pica variant.
708
courier-scaled -- Provides a scaled Courier font.
709
cryst -- Font for graphical symbols used in crystallography.
710
cyklop -- The Cyclop typeface.
711
dancers -- Font for Conan Doyle's "The Dancing Men".
712
dice -- A font for die faces.
713
dictsym -- DictSym font and macro package
714
dingbat -- Two dingbat symbol fonts.
715
doublestroke -- Typeset mathematical double stroke symbols.
716
dozenal -- Typeset documents using base twelve numbering (also called
718
duerer -- Computer Duerer fonts.
719
duerer-latex -- LaTeX support for the Duerer fonts.
720
ean -- Macros for making EAN barcodes.
721
ecc -- Sources for the European Concrete fonts.
722
eco -- Oldstyle numerals using EC fonts.
723
eiad -- Traditional style Irish fonts.
724
eiad-ltx -- LaTeX support for the eiad font.
725
elvish -- Fonts for typesetting Tolkien Elvish scripts.
726
epigrafica -- A Greek and Latin font.
727
epsdice -- A scalable dice "font".
728
esvect -- Vector arrows.
729
eulervm -- Euler virtual math fonts.
731
feyn -- A font for in-text Feynman diagrams.
732
fge -- A font for Frege's Grundgesetze der Arithmetik.
733
foekfont -- The title font of the Mads Fok magazine.
734
fonetika -- Support for the danish "Dania" phonetic system.
735
fourier -- Using Utopia fonts in LaTeX documents.
736
fouriernc -- Use New Century Schoolbook text with Fourier maths fonts.
737
frcursive -- French cursive hand fonts.
739
genealogy -- A compilation genealogy font.
740
gfsartemisia -- A modern Greek font design.
741
gfsbodoni -- A Greek and Latin font based on Bodoni.
742
gfscomplutum -- A Greek font with a long history.
743
gfsdidot -- A Greek font based on Didot's work.
744
gfsneohellenic -- A Greek font in the Neo-Hellenic style.
745
gfssolomos -- A Greek-alphabet font.
746
gothic -- A collection of old German-style fonts.
747
greenpoint -- The Green Point logo.
749
grotesq -- the URW Grotesk Bold Font.
750
hands -- Pointing hand font.
751
hfbright -- The hfbright fonts.
752
hfoldsty -- Old style numerals with EC fonts.
753
ifsym -- A collection of symbols.
754
inconsolata -- A monospaced font, with support files for use with TeX.
755
initials -- Adobe Type 1 decorative initial fonts.
756
iwona -- A two-element sans-serif font.
757
junicode -- A TrueType font for mediaevalists.
758
kixfont -- A font for KIX codes.
760
kpfonts -- A complete set of fonts for text and mathematics.
761
kurier -- A two-element sans-serif typeface.
763
lfb -- A Greek font with normal and bold variants.
764
libertine -- Use the font Libertine with LaTeX.
765
libris -- Libris ADF fonts, with LaTeX support.
766
linearA -- Linear A script fonts.
767
logic -- A font for electronic logic design.
768
lxfonts -- Set of slide fonts based on CM.
769
ly1 -- Support for LY1 LaTeX encoding.
771
mathabx -- Three series of mathematical symbols.
772
mathdesign -- Mathematical fonts to fit with particular text fonts.
773
mnsymbol -- Mathematical symbol font for Adobe MinionPro.
774
nkarta -- A "new" version of the karta cartographic fonts.
775
ocherokee -- LaTeX Support for the Cherokee language.
776
ogham -- Fonts for typesetting Ogham script.
777
oinuit -- LaTeX Support for the Inuktitut Language.
779
orkhun -- A font for orkhun script.
780
osmanian -- Osmanian font for writing Somali.
781
pacioli -- Fonts designed by Fra Luca de Pacioli in 1497.
782
pclnfss -- Font support for current PCL printers.
783
phaistos -- Disk of Phaistos font.
784
phonetic -- MetaFont Phonetic fonts, based on Computer Modern.
785
pigpen -- A font for the pigpen (or masonic) cipher.
787
punk -- Donald Knuth's punk font.
788
recycle -- A font providing the "recyclable" logo.
789
sauter -- Wide range of design sizes for CM fonts.
790
sauterfonts -- Use sauter fonts in LaTeX.
791
semaphor -- Semaphore alphabet font.
792
simpsons -- MetaFont source for Simpsons characters.
793
skull -- A font to draw a skull.
794
staves -- Typeset Icelandic staves and runic letters.
795
tapir -- A simple geometrical font.
796
tengwarscript -- LaTeX support for using Tengwar fonts.
797
trajan -- Fonts from the Trajan column in Rome.
798
umtypewriter -- Fonts to typeset with the xgreek package.
800
universa -- Herbert Bayer's 'universal' font.
801
venturisadf -- Venturis ADF fonts collection.
802
wsuipa -- International Phonetic Alphabet fonts.
803
yfonts -- Support for old German fonts.
804
zefonts -- Virtual fonts to provide T1 encoding from existing fonts."""
806
EXAMPLE4 = """Arista is a simple multimedia transcoder, it focuses on \
807
being easy to use by making complex task of encoding for various devices \
809
Users should pick an input and a target device, choose a file to save to and \
811
* Presets for iPod, computer, DVD player, PSP, Playstation 3, and more.
812
* Live preview to see encoded quality.
813
* Automatically discover available DVD media and Video 4 Linux (v4l) devices.
814
* Rip straight from DVD media easily (requires libdvdcss).
815
* Rip straight from v4l devices.
816
* Simple terminal client for scripting.
817
* Automatic preset updating."""
819
def on_clicked(widget, desc_widget, descs):
821
if widget.position >= len(descs):
823
desc_widget.set_description(*descs[widget.position])
825
descs = ((EXAMPLE0, ''),
828
(EXAMPLE3, 'texlive-fonts-extra'),
832
b = Gtk.Button('Next test description >>')
834
vb.pack_start(b, False, False, 0)
835
scroll = Gtk.ScrolledWindow()
837
d = description.AppDescription()
838
#~ d.description.DEBUG_PAINT_BBOXES = True
839
d.set_description(EXAMPLE0, pkgname='')
840
scroll.add_with_viewport(d)
842
b.connect("clicked", on_clicked, d, descs)
844
win = get_test_window(child=vb)
845
win.set_has_resize_grip(True)
849
@patch_datadir('./data')
850
def get_test_exhibits_window():
851
exhibit_banner = exhibits.ExhibitBanner()
853
exhibits_list = [exhibits.FeaturedExhibit()]
854
for (i, (title, url)) in enumerate([
855
("1 some title", "https://wiki.ubuntu.com/Brand?"
856
"action=AttachFile&do=get&target=orangeubuntulogo.png"),
857
("2 another title", "https://wiki.ubuntu.com/Brand?"
858
"action=AttachFile&do=get&target=blackeubuntulogo.png"),
859
("3 yet another title", "https://wiki.ubuntu.com/Brand?"
860
"action=AttachFile&do=get&target=xubuntu.png"),
864
exhibit.package_names = "apt,2vcard"
865
exhibit.published = True
866
exhibit.style = "some uri to html"
867
exhibit.title_translated = title
868
exhibit.banner_url = url
870
exhibits_list.append(exhibit)
872
exhibit_banner.set_exhibits(exhibits_list)
874
scroll = Gtk.ScrolledWindow()
875
scroll.add_with_viewport(exhibit_banner)
877
win = get_test_window(child=scroll)
881
def get_test_window_labels():
883
'hardware::gps': 'yes',
884
'hardware::video:opengl': 'no',
888
hwbox = labels.HardwareRequirementsBox()
889
hwbox.set_hardware_requirements(HW_TEST_RESULT)
891
win = get_test_window(child=hwbox)
895
def get_test_window_oneconfviews():
897
w = oneconfviews.OneConfViews(Gtk.IconTheme.get_default())
898
win = get_test_window(child=w)
899
win.set_data("pane", w)
902
w.register_computer("AAAAA", "NameA")
903
w.register_computer("ZZZZZ", "NameZ")
904
w.register_computer("DDDDD", "NameD")
905
w.register_computer("CCCCC", "NameC")
906
w.register_computer("", "This computer should be first")
909
GObject.timeout_add_seconds(5, w.register_computer, "EEEEE", "NameE")
911
def print_selected_hostid(widget, hostid, hostname):
912
print("%s selected for %s" % (hostid, hostname))
914
w.connect("computer-changed", print_selected_hostid)
916
w.remove_computer("DDDDD")
920
@patch_datadir('./data')
921
def get_test_reviews_window():
922
appdetails_mock = Mock()
923
appdetails_mock.version = "2.0"
926
parent.app_details = appdetails_mock
929
review_data.app_name = "app"
930
review_data.usefulness_favorable = 10
931
review_data.usefulness_total = 12
932
review_data.usefulness_submit_error = False
933
review_data.reviewer_username = "name"
934
review_data.reviewer_displayname = "displayname"
935
review_data.date_created = "2011-01-01 18:00:00"
936
review_data.summary = "summary"
937
review_data.review_text = 10 * "loonng text"
938
review_data.rating = "3.0"
939
review_data.version = "1.0"
942
vb = reviews.UIReviewsList(parent)
943
vb.add_review(review_data)
944
vb.configure_reviews_ui()
946
win = get_test_window(child=vb)
950
def get_test_searchentry_window():
951
icons = Gtk.IconTheme.get_default()
952
entry = searchentry.SearchEntry(icons)
953
entry.connect("terms-changed", lambda w, terms: print(terms))
955
win = get_test_window(child=entry)
960
def get_test_spinner_window():
961
label = Gtk.Label("foo")
962
spinner_notebook = spinner.SpinnerNotebook(label, "random msg")
964
win = get_test_window(child=spinner_notebook)
965
spinner_notebook.show_spinner("Loading for 1s ...")
966
GObject.timeout_add_seconds(1, lambda: spinner_notebook.hide_spinner())
970
def get_test_stars_window():
974
win = get_test_window(child=vb)
977
vb.add(Gtk.Label(label="BLAHHHHHH"))
982
star.set_size(stars.StarSize.SMALL)
983
vb.pack_start(star, False, False, 0)
988
star.set_size(stars.StarSize.NORMAL)
989
vb.pack_start(star, False, False, 0)
993
star.set_rating(2.575)
994
star.set_size(stars.StarSize.BIG)
995
vb.pack_start(star, False, False, 0)
999
star.set_rating(3.333)
1000
star.set_size_as_pixel_value(36)
1001
vb.pack_start(star, False, False, 0)
1003
star = stars.ReactiveStar()
1006
star.set_size_as_pixel_value(em.big_em(3))
1007
vb.pack_start(star, False, False, 0)
1009
selector = stars.StarRatingSelector()
1010
vb.pack_start(selector, False, False, 0)
1015
@patch_datadir('./data')
1016
def get_test_symbolic_icons_window():
1017
hb = Gtk.HBox(spacing=12)
1018
ico = symbolic_icons.SymbolicIcon("available")
1020
ico = symbolic_icons.PendingSymbolicIcon("pending")
1022
ico.set_transaction_count(33)
1024
ico = symbolic_icons.PendingSymbolicIcon("pending")
1026
ico.set_transaction_count(1)
1028
win = get_test_window(child=hb)
1032
def get_test_screenshot_thumbnail_window():
1033
vb = Gtk.VBox(spacing=6)
1034
win = get_test_window(child=vb)
1036
icons = Gtk.IconTheme.get_default()
1037
icons.append_search_path("/usr/share/app-install/icons/")
1039
distro = softwarecenter.distro.get_distro()
1041
init_sc_css_provider(win, Gtk.Settings.get_default(),
1042
Gdk.Screen.get_default(), "data")
1044
t = thumbnail.ScreenshotGallery(distro, icons)
1045
t.connect('draw', t.draw)
1046
frame = containers.FramedBox()
1049
win.set_data("screenshot_thumbnail_widget", t)
1051
b = Gtk.Button('A button for focus testing')
1052
vb.pack_start(b, True, True, 0)
1053
win.set_data("screenshot_button_widget", b)
1054
vb.pack_start(frame, True, True, 0)
1056
cache = pkginfo.get_pkg_info()
1059
xapian_base_path = "/var/cache/software-center"
1060
pathname = os.path.join(xapian_base_path, "xapian")
1061
db = database.StoreDatabase(pathname, cache)
1064
apps = [application.Application("Movie Player", "totem"),
1065
application.Application("Comix", "comix"),
1066
application.Application("Gimp", "gimp"),
1067
application.Application("ACE", "uace")]
1071
def testing_cycle_apps(_, thumb, apps, db):
1073
d = apps[app_n].get_details(db)
1075
if app_n + 1 < len(apps):
1080
thumb.fetch_screenshots(d)
1083
b.connect("clicked", testing_cycle_apps, t, apps, db)
1088
def get_test_videoplayer_window(video_url=None):
1091
# youtube example fragment
1092
html_youtube = """<iframe width="640" height="390"
1093
src="http://www.youtube.com/embed/h3oBU0NZJuA" frameborder="0"
1094
allowfullscreen></iframe>"""
1095
# vimeo example video fragment
1096
html_vimeo = """<iframe
1097
src="http://player.vimeo.com/video/2891554?title=0&byline=0&portrait=0"
1098
width="400" height="308" frameborder="0" webkitAllowFullScreen
1099
allowFullScreen></iframe><p><a href="http://vimeo.com/2891554">
1100
Supertuxkart 0.6</a> from <a href="http://vimeo.com/user1183699">
1101
constantin pelikan</a> on <a href="http://vimeo.com">Vimeo</a>.</p>"""
1102
# dailymotion example video fragment
1103
html_dailymotion = """<iframe frameborder="0" width="480" height="270"
1104
src="http://www.dailymotion.com/embed/video/xm4ysu"></iframe>"""
1105
html_dailymotion2 = """<iframe frameborder="0" width="480" height="379"
1106
src="http://www.dailymotion.com/embed/video/xdiktp"></iframe>"""
1108
html_youtube # pyflakes
1109
html_dailymotion # pyflakes
1110
html_dailymotion2 # pyflakes
1112
player = videoplayer.VideoPlayer()
1113
win = get_test_window(child=player, width=500, height=400)
1115
if video_url is None:
1116
#player.uri = "http://upload.wikimedia.org/wikipedia/commons/9/9b/" \
1117
# "Pentagon_News_Sample.ogg"
1118
#player.uri = "http://people.canonical.com/~mvo/totem.html"
1119
player.load_html_string(html_vimeo)
1121
player.uri = video_url
1126
if __name__ == '__main__':
1127
if len(sys.argv) > 1:
1128
window_name = sys.argv[1]
1130
for i in ('get_test_window_%s',
1131
'get_%s_test_window',
1132
'get_test_%s_window'):
1133
name = i % window_name
1134
print('Trying to execute: ', name)
1135
f = locals().get(name)
1137
print('Success! Running the main loop and showing the window.')
1138
# pass the renaming sys.argv to the function
1139
result = f(*sys.argv[2:])
1142
if result is not None:
1143
if isinstance(result, Gtk.Dialog):
1144
response = result.run()
1146
GObject.timeout_add(1, Gtk.main_quit)
1147
elif isinstance(result, Gtk.Window):
1148
result.connect("destroy", Gtk.main_quit)
1151
print('ERROR: Found no test functions for', name)
1154
print("""Please provide the name of the window to test.
1157
PYTHONPATH=. python tests/gtk3/windows.py dependency_dialog
1158
PYTHONPATH=. python tests/gtk3/windows.py videoplayer
1159
PYTHONPATH=. python tests/gtk3/windows.py videoplayer http://google.com
1160
PYTHONPATH=. python tests/gtk3/windows.py appdetails
1161
PYTHONPATH=. python tests/gtk3/windows.py appdetails firefox
1163
""".format(sys.argv[0]))