~ubuntuone-control-tower/software-center/trunk

« back to all changes in this revision

Viewing changes to tests/gtk3/windows.py

  • Committer: Michael Vogt
  • Date: 2012-06-11 15:58:19 UTC
  • mfrom: (3020.1.9 the-organizer)
  • Revision ID: michael.vogt@ubuntu.com-20120611155819-rfz96g7s7bysskrt
mergedĀ lp:~nataliabidart/software-center/the-organizer

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from __future__ import print_function
 
2
 
 
3
import logging
 
4
import os
 
5
import sys
 
6
import urllib
 
7
 
 
8
import xapian
 
9
 
 
10
from gi.repository import Gdk, GObject, Gtk
 
11
from mock import Mock
 
12
 
 
13
import softwarecenter.distro
 
14
import softwarecenter.log
 
15
import softwarecenter.paths
 
16
 
 
17
from softwarecenter.backend import channel
 
18
from softwarecenter.db import (
 
19
    appfilter,
 
20
    application,
 
21
    database,
 
22
    enquire,
 
23
    pkginfo,
 
24
)
 
25
from softwarecenter.enums import (
 
26
    BUY_SOMETHING_HOST,
 
27
    NonAppVisibility,
 
28
)
 
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 (
 
33
    availablepane,
 
34
    globalpane,
 
35
    historypane,
 
36
    installedpane,
 
37
    pendingpane,
 
38
    softwarepane,
 
39
    viewswitcher,
 
40
)
 
41
from softwarecenter.ui.gtk3.session import appmanager
 
42
from softwarecenter.ui.gtk3.utils import (
 
43
    get_sc_icon_theme,
 
44
    init_sc_css_provider,
 
45
)
 
46
from softwarecenter.ui.gtk3.views import (
 
47
    appview,
 
48
    appdetailsview,
 
49
    catview_gtk,
 
50
    pkgnamesview,
 
51
    purchaseview,
 
52
)
 
53
from softwarecenter.ui.gtk3.widgets import (
 
54
    backforward,
 
55
    buttons,
 
56
    containers,
 
57
    description,
 
58
    exhibits,
 
59
    labels,
 
60
    oneconfviews,
 
61
    recommendations,
 
62
    reviews,
 
63
    searchentry,
 
64
    spinner,
 
65
    stars,
 
66
    symbolic_icons,
 
67
    thumbnail,
 
68
    videoplayer,
 
69
)
 
70
from softwarecenter.utils import ExecutionTime
 
71
from tests.utils import (
 
72
    do_events,
 
73
    get_test_categories,
 
74
    get_test_datadir,
 
75
    get_test_db,
 
76
    get_test_gtk3_icon_cache,
 
77
    get_test_gtk3_viewmanager,
 
78
    get_test_install_backend,
 
79
    get_test_pkg_info,
 
80
    patch_datadir,
 
81
)
 
82
 
 
83
 
 
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)
 
89
 
 
90
 
 
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)
 
95
 
 
96
 
 
97
def get_test_window(child, width=600, height=800, border_width=0, title=None):
 
98
    win = Gtk.Window()
 
99
    win.set_size_request(width, height)
 
100
    win.set_position(Gtk.WindowPosition.CENTER)
 
101
    win.set_border_width(border_width)
 
102
    win.add(child)
 
103
    if title is None:
 
104
        title = child.__class__.__name__
 
105
    win.set_title(title)
 
106
    win.show_all()
 
107
    return win
 
108
 
 
109
 
 
110
def get_test_window_dependency_dialog():
 
111
    icons = get_test_gtk3_icon_cache()
 
112
    db = get_test_db()
 
113
 
 
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)
 
122
    return dia
 
123
 
 
124
 
 
125
def get_test_window_confirm_remove():
 
126
    # test real remove dialog
 
127
    icons = get_test_gtk3_icon_cache()
 
128
    db = get_test_db()
 
129
    app = application.Application("", "p7zip-full")
 
130
    return dependency_dialogs.confirm_remove(None,
 
131
        softwarecenter.paths.datadir, app, db, icons)
 
132
 
 
133
 
 
134
def get_query_from_search_entry(search_term):
 
135
    if not search_term:
 
136
        return xapian.Query("")
 
137
    parser = xapian.QueryParser()
 
138
    user_query = parser.parse_query(search_term)
 
139
    return user_query
 
140
 
 
141
 
 
142
def on_entry_changed(widget, data):
 
143
 
 
144
    def _work():
 
145
        new_text = widget.get_text()
 
146
        (view, enquirer) = data
 
147
 
 
148
        with ExecutionTime("total time"):
 
149
            with ExecutionTime("enquire.set_query()"):
 
150
                enquirer.set_query(get_query_from_search_entry(new_text),
 
151
                    limit=100 * 1000,
 
152
                    nonapps_visible=NonAppVisibility.ALWAYS_VISIBLE)
 
153
 
 
154
            store = view.tree_view.get_model()
 
155
            if store is None:
 
156
                return
 
157
 
 
158
            with ExecutionTime("store.clear()"):
 
159
                store.clear()
 
160
 
 
161
            with ExecutionTime("store.set_from_matches()"):
 
162
                store.set_from_matches(enquirer.matches)
 
163
 
 
164
            with ExecutionTime("model settle (size=%s)" % len(store)):
 
165
                do_events()
 
166
 
 
167
    if widget.stamp:
 
168
        GObject.source_remove(widget.stamp)
 
169
    widget.stamp = GObject.timeout_add(250, _work)
 
170
 
 
171
 
 
172
def get_test_window_appview():
 
173
    db = get_test_db()
 
174
    cache = get_test_pkg_info()
 
175
    icons = get_test_gtk3_icon_cache()
 
176
 
 
177
    # create a filter
 
178
    app_filter = appfilter.AppFilter(db, cache)
 
179
    app_filter.set_supported_only(False)
 
180
    app_filter.set_installed_only(True)
 
181
 
 
182
    # appview
 
183
    enquirer = enquire.AppEnquire(cache, db)
 
184
    store = appstore2.AppListStore(db, cache, icons)
 
185
 
 
186
    view = appview.AppView(db, cache, icons, show_ratings=True)
 
187
    view.set_model(store)
 
188
 
 
189
    entry = Gtk.Entry()
 
190
    entry.stamp = 0
 
191
    entry.connect("changed", on_entry_changed, (view, enquirer))
 
192
    entry.set_text("gtk3")
 
193
 
 
194
    box = Gtk.VBox()
 
195
    box.pack_start(entry, False, True, 0)
 
196
    box.pack_start(view, True, True, 0)
 
197
 
 
198
    win = get_test_window(child=box)
 
199
    win.set_data("appview", view)
 
200
    win.set_data("entry", entry)
 
201
 
 
202
    return win
 
203
 
 
204
 
 
205
def get_test_window_apptreeview():
 
206
    cache = get_test_pkg_info()
 
207
    db = get_test_db()
 
208
    icons = get_test_gtk3_icon_cache()
 
209
 
 
210
    # create a filter
 
211
    app_filter = appfilter.AppFilter(db, cache)
 
212
    app_filter.set_supported_only(False)
 
213
    app_filter.set_installed_only(True)
 
214
 
 
215
    # get the TREEstore
 
216
    store = appstore2.AppTreeStore(db, cache, icons)
 
217
 
 
218
    # populate from data
 
219
    cats = get_test_categories(db)
 
220
    for cat in cats[:3]:
 
221
        with ExecutionTime("query cat '%s'" % cat.name):
 
222
            docs = db.get_docs_from_query(cat.query)
 
223
            store.set_category_documents(cat, docs)
 
224
 
 
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)
 
229
 
 
230
    box = Gtk.VBox()
 
231
    box.pack_start(app_view, True, True, 0)
 
232
 
 
233
    win = get_test_window(child=box)
 
234
    return win
 
235
 
 
236
 
 
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
 
241
    db = get_test_db()
 
242
    cache = get_test_pkg_info()
 
243
    datadir = get_test_datadir()
 
244
    icons = get_test_gtk3_icon_cache()
 
245
    backend = get_test_install_backend()
 
246
 
 
247
    manager = appmanager.get_appmanager()
 
248
    if manager is None:
 
249
        # create global AppManager instance
 
250
        manager = appmanager.ApplicationManager(db, backend, icons)
 
251
 
 
252
    navhistory_back_action = Gtk.Action("navhistory_back_action", "Back",
 
253
        "Back", None)
 
254
    navhistory_forward_action = Gtk.Action("navhistory_forward_action",
 
255
        "Forward", "Forward", None)
 
256
 
 
257
    w = availablepane.AvailablePane(cache, db, 'Ubuntu', icons, datadir,
 
258
        navhistory_back_action, navhistory_forward_action)
 
259
    w.init_view()
 
260
    w.show()
 
261
 
 
262
    win = get_test_window(child=w, width=800, height=600)
 
263
    # this is used later in tests
 
264
    win.set_data("pane", w)
 
265
    return win
 
266
 
 
267
 
 
268
def get_test_window_globalpane():
 
269
    vm = get_test_gtk3_viewmanager()
 
270
    db = get_test_db()
 
271
    cache = get_test_pkg_info()
 
272
    datadir = get_test_datadir()
 
273
    icons = get_test_gtk3_icon_cache()
 
274
 
 
275
    p = globalpane.GlobalPane(vm, datadir, db, cache, icons)
 
276
 
 
277
    win = get_test_window(child=p)
 
278
    win.set_data("pane", p)
 
279
    return win
 
280
 
 
281
 
 
282
def get_test_window_pendingpane():
 
283
    icons = get_test_gtk3_icon_cache()
 
284
 
 
285
    view = pendingpane.PendingPane(icons)
 
286
 
 
287
    # gui
 
288
    scroll = Gtk.ScrolledWindow()
 
289
    scroll.add_with_viewport(view)
 
290
 
 
291
    win = get_test_window(child=scroll)
 
292
    view.grab_focus()
 
293
    return win
 
294
 
 
295
 
 
296
@patch_datadir('./data')
 
297
def get_test_window_viewswitcher():
 
298
    cache = get_test_pkg_info()
 
299
    db = get_test_db()
 
300
    icons = get_test_gtk3_icon_cache()
 
301
    datadir = get_test_datadir()
 
302
    manager = get_test_gtk3_viewmanager()
 
303
 
 
304
    view = viewswitcher.ViewSwitcher(manager, datadir, db, cache, icons)
 
305
 
 
306
    scroll = Gtk.ScrolledWindow()
 
307
    box = Gtk.VBox()
 
308
    box.pack_start(scroll, True, True, 0)
 
309
 
 
310
    win = get_test_window(child=box)
 
311
    scroll.add_with_viewport(view)
 
312
    return win
 
313
 
 
314
 
 
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
 
319
    db = get_test_db()
 
320
    cache = get_test_pkg_info()
 
321
    datadir = get_test_datadir()
 
322
    icons = get_test_gtk3_icon_cache()
 
323
 
 
324
    w = installedpane.InstalledPane(cache, db, 'Ubuntu', icons, datadir)
 
325
    w.show()
 
326
 
 
327
    # init the view
 
328
    w.init_view()
 
329
 
 
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)
 
334
 
 
335
    win = get_test_window(child=w)
 
336
    win.set_data("pane", w)
 
337
    return win
 
338
 
 
339
 
 
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
 
344
    db = get_test_db()
 
345
    cache = get_test_pkg_info()
 
346
    icons = get_test_gtk3_icon_cache()
 
347
 
 
348
    widget = historypane.HistoryPane(cache, db, None, icons, None)
 
349
    widget.show()
 
350
 
 
351
    win = get_test_window(child=widget)
 
352
    widget.init_view()
 
353
    return win
 
354
 
 
355
 
 
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()
 
360
    db = get_test_db()
 
361
    icons = get_test_gtk3_icon_cache()
 
362
    catview = catview_gtk.CategoriesViewGtk(softwarecenter.paths.datadir,
 
363
        softwarecenter.paths.APP_INSTALL_PATH, cache, db, icons)
 
364
 
 
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)
 
372
 
 
373
    win = get_test_window(child=view)
 
374
    win.set_data("rec_panel", view)
 
375
    return win
 
376
 
 
377
 
 
378
def get_test_window_catview(db=None):
 
379
 
 
380
    def on_category_selected(view, cat):
 
381
        print("on_category_selected view: ", view)
 
382
        print("on_category_selected cat: ", cat)
 
383
 
 
384
    if db is None:
 
385
        cache = pkginfo.get_pkg_info()
 
386
        cache.open()
 
387
 
 
388
        xapian_base_path = "/var/cache/software-center"
 
389
        pathname = os.path.join(xapian_base_path, "xapian")
 
390
        db = database.StoreDatabase(pathname, cache)
 
391
        db.open()
 
392
    else:
 
393
        cache = db._aptcache
 
394
 
 
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)
 
399
 
 
400
    # gui
 
401
    notebook = Gtk.Notebook()
 
402
 
 
403
    lobby_view = catview_gtk.LobbyViewGtk(softwarecenter.paths.datadir,
 
404
        softwarecenter.paths.APP_INSTALL_PATH,
 
405
        cache, db, icons, distro, apps_filter)
 
406
 
 
407
    scroll = Gtk.ScrolledWindow()
 
408
    scroll.add(lobby_view)
 
409
    notebook.append_page(scroll, Gtk.Label(label="Lobby"))
 
410
 
 
411
    # find a cat in the LobbyView that has subcategories
 
412
    subcat_cat = None
 
413
    for cat in reversed(lobby_view.categories):
 
414
        if cat.subcategories:
 
415
            subcat_cat = cat
 
416
            break
 
417
 
 
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)
 
422
 
 
423
    scroll = Gtk.ScrolledWindow()
 
424
    scroll.add(subcat_view)
 
425
    notebook.append_page(scroll, Gtk.Label(label="Subcats"))
 
426
 
 
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)
 
430
    return win
 
431
 
 
432
 
 
433
def get_test_catview():
 
434
 
 
435
    def on_category_selected(view, cat):
 
436
        print("on_category_selected %s %s" % (view, cat))
 
437
 
 
438
    cache = pkginfo.get_pkg_info()
 
439
    cache.open()
 
440
 
 
441
    xapian_base_path = "/var/cache/software-center"
 
442
    pathname = os.path.join(xapian_base_path, "xapian")
 
443
    db = database.StoreDatabase(pathname, cache)
 
444
    db.open()
 
445
 
 
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)
 
450
 
 
451
    cat_view = catview_gtk.LobbyViewGtk(softwarecenter.paths.datadir,
 
452
        softwarecenter.paths.APP_INSTALL_PATH,
 
453
        cache, db, icons, distro, apps_filter)
 
454
 
 
455
    return cat_view
 
456
 
 
457
 
 
458
def get_test_window_appdetails(pkgname=None):
 
459
    cache = pkginfo.get_pkg_info()
 
460
    cache.open()
 
461
 
 
462
    xapian_base_path = "/var/cache/software-center"
 
463
    pathname = os.path.join(xapian_base_path, "xapian")
 
464
    db = database.StoreDatabase(pathname, cache)
 
465
    db.open()
 
466
 
 
467
    datadir = softwarecenter.paths.datadir
 
468
    icons = get_sc_icon_theme(datadir)
 
469
    distro = softwarecenter.distro.get_distro()
 
470
 
 
471
    # gui
 
472
    scroll = Gtk.ScrolledWindow()
 
473
    view = appdetailsview.AppDetailsView(db, distro, icons, cache, datadir)
 
474
 
 
475
    if pkgname is None:
 
476
        pkgname = "totem"
 
477
 
 
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"))
 
484
 
 
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")
 
490
 
 
491
    scroll.add(view)
 
492
    scroll.show()
 
493
 
 
494
    win = get_test_window(child=scroll, width=800, height=800)
 
495
    win.set_data("view", view)
 
496
    return win
 
497
 
 
498
 
 
499
def get_test_window_pkgnamesview():
 
500
    cache = pkginfo.get_pkg_info()
 
501
    cache.open()
 
502
 
 
503
    xapian_base_path = "/var/cache/software-center"
 
504
    pathname = os.path.join(xapian_base_path, "xapian")
 
505
    db = database.StoreDatabase(pathname, cache)
 
506
    db.open()
 
507
 
 
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)
 
512
    view.show()
 
513
 
 
514
    win = get_test_window(child=view)
 
515
    return win
 
516
 
 
517
 
 
518
@patch_datadir('./tests/data')
 
519
def get_test_window_purchaseview(url=None):
 
520
    if url is 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",
 
525
                                     'arch': "i386"})
 
526
        url = (BUY_SOMETHING_HOST +
 
527
               "/subscriptions/en/ubuntu/precise/+new/?%s" % url_args)
 
528
 
 
529
    # useful for debugging
 
530
    #d.connect("key-press-event", _on_key_press)
 
531
    #GObject.timeout_add_seconds(1, _generate_events, d)
 
532
 
 
533
    widget = purchaseview.PurchaseView()
 
534
    widget.config = Mock()
 
535
 
 
536
    win = get_test_window(child=widget)
 
537
    win.set_data("view", widget)
 
538
 
 
539
    widget.initiate_purchase(app=None, iconname=None, url=url)
 
540
    #widget.initiate_purchase(app=None, iconname=None, html=DUMMY_HTML)
 
541
 
 
542
    return win
 
543
 
 
544
 
 
545
def get_test_backforward_window():
 
546
    backforward_button = backforward.BackForwardButton()
 
547
    win = get_test_window(child=backforward_button)
 
548
    return win
 
549
 
 
550
 
 
551
def get_test_container_window():
 
552
    f = containers.FlowableGrid()
 
553
 
 
554
    for i in range(10):
 
555
        t = buttons.CategoryTile("test", "folder")
 
556
        f.add_child(t)
 
557
 
 
558
    scroll = Gtk.ScrolledWindow()
 
559
    scroll.add_with_viewport(f)
 
560
 
 
561
    win = get_test_window(child=scroll)
 
562
    return win
 
563
 
 
564
 
 
565
def _build_channels_list(popup):
 
566
    for i in range(3):
 
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)
 
571
        item.add(box)
 
572
        item.show_all()
 
573
        popup.attach(item, 0, 1, i, i + 1)
 
574
 
 
575
 
 
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)
 
580
 
 
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)
 
586
    hb = Gtk.HBox()
 
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)
 
590
 
 
591
    win = get_test_window(child=vb)
 
592
    return win
 
593
 
 
594
 
 
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.
 
598
 
 
599
p7zip-full provides:
 
600
 
 
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 \
 
603
other formats.
 
604
 
 
605
 - /usr/bin/7z not only does it handle 7z but also ZIP, Zip64, CAB, RAR, \
 
606
ARJ, GZIP,
 
607
   BZIP2, TAR, CPIO, RPM, ISO and DEB archives. 7z compression is 30-50% \
 
608
better than ZIP compression.
 
609
 
 
610
p7zip provides 7zr, a light version of 7za, and p7zip a gzip like wrapper \
 
611
around 7zr."""
 
612
 
 
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:
 
620
 * Containers:
 
621
  - Ogg
 
622
  - Matroska
 
623
  - AVI
 
624
  - MPEG TS
 
625
  - flv
 
626
  - QuickTime
 
627
  - MPEG4
 
628
  - 3GPP
 
629
  - MXT
 
630
 * Audio encoders:
 
631
  - Vorbis
 
632
  - FLAC
 
633
  - MP3
 
634
  - AAC
 
635
  - AC3
 
636
  - Speex
 
637
  - Celt
 
638
 * Video encoders:
 
639
  - Theora
 
640
  - Dirac
 
641
  - H264
 
642
  - MPEG2
 
643
  - MPEG4/DivX5
 
644
  - xvid
 
645
  - DNxHD
 
646
It also provide the support for the GStreamer's plugins auto-search."""
 
647
 
 
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)
 
661
 * 7z archives (.7z)
 
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."""
 
668
 
 
669
    EXAMPLE3 = """This package includes the following CTAN packages:
 
670
 Asana-Math -- A font to typeset maths in Xe(La)TeX.
 
671
 albertus --
 
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.
 
682
 atqolive --
 
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.
 
693
 bera -- Bera 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.
 
702
 clarendo --
 
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.
 
707
 coronet --
 
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
 
717
  "dozenal")
 
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.
 
730
 euxm --
 
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.
 
738
 garamond --
 
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.
 
748
 groff --
 
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.
 
759
 knuthotherfonts --
 
760
 kpfonts -- A complete set of fonts for text and mathematics.
 
761
 kurier -- A two-element sans-serif typeface.
 
762
 lettrgth --
 
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.
 
770
 marigold --
 
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.
 
778
 optima --
 
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.
 
786
 psafm --
 
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.
 
799
 univers --
 
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."""
 
805
 
 
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 \
 
808
simple.
 
809
Users should pick an input and a target device, choose a file to save to and \
 
810
go. Features:
 
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."""
 
818
 
 
819
    def on_clicked(widget, desc_widget, descs):
 
820
        widget.position += 1
 
821
        if widget.position >= len(descs):
 
822
            widget.position = 0
 
823
        desc_widget.set_description(*descs[widget.position])
 
824
 
 
825
    descs = ((EXAMPLE0, ''),
 
826
             (EXAMPLE1, ''),
 
827
             (EXAMPLE2, ''),
 
828
             (EXAMPLE3, 'texlive-fonts-extra'),
 
829
             (EXAMPLE4, ''))
 
830
 
 
831
    vb = Gtk.VBox()
 
832
    b = Gtk.Button('Next test description >>')
 
833
    b.position = 0
 
834
    vb.pack_start(b, False, False, 0)
 
835
    scroll = Gtk.ScrolledWindow()
 
836
    vb.add(scroll)
 
837
    d = description.AppDescription()
 
838
    #~ d.description.DEBUG_PAINT_BBOXES = True
 
839
    d.set_description(EXAMPLE0, pkgname='')
 
840
    scroll.add_with_viewport(d)
 
841
 
 
842
    b.connect("clicked", on_clicked, d, descs)
 
843
 
 
844
    win = get_test_window(child=vb)
 
845
    win.set_has_resize_grip(True)
 
846
    return win
 
847
 
 
848
 
 
849
@patch_datadir('./data')
 
850
def get_test_exhibits_window():
 
851
    exhibit_banner = exhibits.ExhibitBanner()
 
852
 
 
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"),
 
861
        ]):
 
862
        exhibit = Mock()
 
863
        exhibit.id = i
 
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
 
869
        exhibit.html = None
 
870
        exhibits_list.append(exhibit)
 
871
 
 
872
    exhibit_banner.set_exhibits(exhibits_list)
 
873
 
 
874
    scroll = Gtk.ScrolledWindow()
 
875
    scroll.add_with_viewport(exhibit_banner)
 
876
 
 
877
    win = get_test_window(child=scroll)
 
878
    return win
 
879
 
 
880
 
 
881
def get_test_window_labels():
 
882
    HW_TEST_RESULT = {
 
883
        'hardware::gps': 'yes',
 
884
        'hardware::video:opengl': 'no',
 
885
    }
 
886
 
 
887
    # add it
 
888
    hwbox = labels.HardwareRequirementsBox()
 
889
    hwbox.set_hardware_requirements(HW_TEST_RESULT)
 
890
 
 
891
    win = get_test_window(child=hwbox)
 
892
    return win
 
893
 
 
894
 
 
895
def get_test_window_oneconfviews():
 
896
 
 
897
    w = oneconfviews.OneConfViews(Gtk.IconTheme.get_default())
 
898
    win = get_test_window(child=w)
 
899
    win.set_data("pane", w)
 
900
 
 
901
    # init the view
 
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")
 
907
    w.select_first()
 
908
 
 
909
    GObject.timeout_add_seconds(5, w.register_computer, "EEEEE", "NameE")
 
910
 
 
911
    def print_selected_hostid(widget, hostid, hostname):
 
912
        print("%s selected for %s" % (hostid, hostname))
 
913
 
 
914
    w.connect("computer-changed", print_selected_hostid)
 
915
 
 
916
    w.remove_computer("DDDDD")
 
917
    return win
 
918
 
 
919
 
 
920
@patch_datadir('./data')
 
921
def get_test_reviews_window():
 
922
    appdetails_mock = Mock()
 
923
    appdetails_mock.version = "2.0"
 
924
 
 
925
    parent = Mock()
 
926
    parent.app_details = appdetails_mock
 
927
 
 
928
    review_data = 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"
 
940
 
 
941
    # create reviewslist
 
942
    vb = reviews.UIReviewsList(parent)
 
943
    vb.add_review(review_data)
 
944
    vb.configure_reviews_ui()
 
945
 
 
946
    win = get_test_window(child=vb)
 
947
    return win
 
948
 
 
949
 
 
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))
 
954
 
 
955
    win = get_test_window(child=entry)
 
956
    win.entry = entry
 
957
    return win
 
958
 
 
959
 
 
960
def get_test_spinner_window():
 
961
    label = Gtk.Label("foo")
 
962
    spinner_notebook = spinner.SpinnerNotebook(label, "random msg")
 
963
 
 
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())
 
967
    return win
 
968
 
 
969
 
 
970
def get_test_stars_window():
 
971
    vb = Gtk.VBox()
 
972
    vb.set_spacing(6)
 
973
 
 
974
    win = get_test_window(child=vb)
 
975
 
 
976
    vb.add(Gtk.Button())
 
977
    vb.add(Gtk.Label(label="BLAHHHHHH"))
 
978
 
 
979
    star = stars.Star()
 
980
    star.set_n_stars(5)
 
981
    star.set_rating(2.5)
 
982
    star.set_size(stars.StarSize.SMALL)
 
983
    vb.pack_start(star, False, False, 0)
 
984
 
 
985
    star = stars.Star()
 
986
    star.set_n_stars(5)
 
987
    star.set_rating(2.5)
 
988
    star.set_size(stars.StarSize.NORMAL)
 
989
    vb.pack_start(star, False, False, 0)
 
990
 
 
991
    star = stars.Star()
 
992
    star.set_n_stars(5)
 
993
    star.set_rating(2.575)
 
994
    star.set_size(stars.StarSize.BIG)
 
995
    vb.pack_start(star, False, False, 0)
 
996
 
 
997
    star = stars.Star()
 
998
    star.set_n_stars(5)
 
999
    star.set_rating(3.333)
 
1000
    star.set_size_as_pixel_value(36)
 
1001
    vb.pack_start(star, False, False, 0)
 
1002
 
 
1003
    star = stars.ReactiveStar()
 
1004
    star.set_n_stars(5)
 
1005
    star.set_rating(3)
 
1006
    star.set_size_as_pixel_value(em.big_em(3))
 
1007
    vb.pack_start(star, False, False, 0)
 
1008
 
 
1009
    selector = stars.StarRatingSelector()
 
1010
    vb.pack_start(selector, False, False, 0)
 
1011
 
 
1012
    return win
 
1013
 
 
1014
 
 
1015
@patch_datadir('./data')
 
1016
def get_test_symbolic_icons_window():
 
1017
    hb = Gtk.HBox(spacing=12)
 
1018
    ico = symbolic_icons.SymbolicIcon("available")
 
1019
    hb.add(ico)
 
1020
    ico = symbolic_icons.PendingSymbolicIcon("pending")
 
1021
    ico.start()
 
1022
    ico.set_transaction_count(33)
 
1023
    hb.add(ico)
 
1024
    ico = symbolic_icons.PendingSymbolicIcon("pending")
 
1025
    ico.start()
 
1026
    ico.set_transaction_count(1)
 
1027
    hb.add(ico)
 
1028
    win = get_test_window(child=hb)
 
1029
    return win
 
1030
 
 
1031
 
 
1032
def get_test_screenshot_thumbnail_window():
 
1033
    vb = Gtk.VBox(spacing=6)
 
1034
    win = get_test_window(child=vb)
 
1035
 
 
1036
    icons = Gtk.IconTheme.get_default()
 
1037
    icons.append_search_path("/usr/share/app-install/icons/")
 
1038
 
 
1039
    distro = softwarecenter.distro.get_distro()
 
1040
 
 
1041
    init_sc_css_provider(win, Gtk.Settings.get_default(),
 
1042
                         Gdk.Screen.get_default(), "data")
 
1043
 
 
1044
    t = thumbnail.ScreenshotGallery(distro, icons)
 
1045
    t.connect('draw', t.draw)
 
1046
    frame = containers.FramedBox()
 
1047
    frame.add(t)
 
1048
 
 
1049
    win.set_data("screenshot_thumbnail_widget", t)
 
1050
 
 
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)
 
1055
 
 
1056
    cache = pkginfo.get_pkg_info()
 
1057
    cache.open()
 
1058
 
 
1059
    xapian_base_path = "/var/cache/software-center"
 
1060
    pathname = os.path.join(xapian_base_path, "xapian")
 
1061
    db = database.StoreDatabase(pathname, cache)
 
1062
    db.open()
 
1063
 
 
1064
    apps = [application.Application("Movie Player", "totem"),
 
1065
            application.Application("Comix", "comix"),
 
1066
            application.Application("Gimp", "gimp"),
 
1067
            application.Application("ACE", "uace")]
 
1068
 
 
1069
    app_n = 0
 
1070
 
 
1071
    def testing_cycle_apps(_, thumb, apps, db):
 
1072
        global app_n
 
1073
        d = apps[app_n].get_details(db)
 
1074
 
 
1075
        if app_n + 1 < len(apps):
 
1076
            app_n += 1
 
1077
        else:
 
1078
            app_n = 0
 
1079
 
 
1080
        thumb.fetch_screenshots(d)
 
1081
        return True
 
1082
 
 
1083
    b.connect("clicked", testing_cycle_apps, t, apps, db)
 
1084
 
 
1085
    return win
 
1086
 
 
1087
 
 
1088
def get_test_videoplayer_window(video_url=None):
 
1089
    Gdk.threads_init()
 
1090
 
 
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&amp;byline=0&amp;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>"""
 
1107
 
 
1108
    html_youtube  # pyflakes
 
1109
    html_dailymotion  # pyflakes
 
1110
    html_dailymotion2  # pyflakes
 
1111
 
 
1112
    player = videoplayer.VideoPlayer()
 
1113
    win = get_test_window(child=player, width=500, height=400)
 
1114
 
 
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)
 
1120
    else:
 
1121
        player.uri = video_url
 
1122
 
 
1123
    return win
 
1124
 
 
1125
 
 
1126
if __name__ == '__main__':
 
1127
    if len(sys.argv) > 1:
 
1128
        window_name = sys.argv[1]
 
1129
        result = None
 
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)
 
1136
            if f is not None:
 
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:])
 
1140
                break
 
1141
 
 
1142
        if result is not None:
 
1143
            if isinstance(result, Gtk.Dialog):
 
1144
                response = result.run()
 
1145
                result.hide()
 
1146
                GObject.timeout_add(1, Gtk.main_quit)
 
1147
            elif isinstance(result, Gtk.Window):
 
1148
                result.connect("destroy", Gtk.main_quit)
 
1149
            Gtk.main()
 
1150
        else:
 
1151
            print('ERROR: Found no test functions for', name)
 
1152
 
 
1153
    else:
 
1154
        print("""Please provide the name of the window to test.
 
1155
Examples are:
 
1156
 
 
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
 
1162
 
 
1163
""".format(sys.argv[0]))