~ubuntu-branches/ubuntu/raring/software-center/raring-proposed

« back to all changes in this revision

Viewing changes to tests/gtk3/windows.py

  • Committer: Package Import Robot
  • Author(s): Michael Vogt
  • Date: 2012-10-11 15:33:05 UTC
  • mfrom: (195.1.18 quantal)
  • Revision ID: package-import@ubuntu.com-20121011153305-fm5ln7if3rpzts4n
Tags: 5.4.1.1
* lp:~mvo/software-center/reinstall-previous-purchase-token-fix:
  - fix reinstall previous purchases that have a system-wide
    license key LP: #1065481
* lp:~mvo/software-center/lp1060106:
  - Add missing gettext init for utils/update-software-center-agent
    (LP: #1060106)

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
    historypane,
36
36
    installedpane,
37
37
    pendingpane,
38
 
    softwarepane,
39
38
    viewswitcher,
40
39
)
41
 
from softwarecenter.ui.gtk3.session import appmanager
 
40
from softwarecenter.ui.gtk3.session import (
 
41
    appmanager,
 
42
    displaystate,
 
43
    )
42
44
from softwarecenter.ui.gtk3.utils import (
43
45
    get_sc_icon_theme,
44
 
    init_sc_css_provider,
45
46
)
46
47
from softwarecenter.ui.gtk3.views import (
47
48
    appview,
48
49
    appdetailsview,
49
 
    catview_gtk,
 
50
    catview,
 
51
    lobbyview,
50
52
    pkgnamesview,
51
53
    purchaseview,
52
54
)
71
73
from tests.utils import (
72
74
    do_events,
73
75
    get_test_categories,
74
 
    get_test_datadir,
75
76
    get_test_db,
76
77
    get_test_gtk3_icon_cache,
77
78
    get_test_gtk3_viewmanager,
127
128
    primary = "primary text"
128
129
    button_text = "button_text"
129
130
    dia = dependency_dialogs._get_confirm_internal_dialog(
130
 
        parent=None, datadir=softwarecenter.paths.datadir, app=app,
 
131
        parent=None, app=app,
131
132
        db=db, icons=icons, primary=primary, button_text=button_text,
132
133
        depends=depends, cache=db._aptcache)
133
134
    return dia
139
140
    db = get_test_db()
140
141
    app = application.Application("", "p7zip-full")
141
142
    return dependency_dialogs.confirm_remove(None,
142
 
        softwarecenter.paths.datadir, app, db, icons)
 
143
        app, db, icons)
143
144
 
144
145
 
145
146
def get_query_from_search_entry(search_term):
251
252
    assert vm is not None
252
253
    db = get_test_db()
253
254
    cache = get_test_pkg_info()
254
 
    datadir = get_test_datadir()
255
255
    icons = get_test_gtk3_icon_cache()
256
256
    backend = get_test_install_backend()
257
257
 
265
265
    navhistory_forward_action = Gtk.Action("navhistory_forward_action",
266
266
        "Forward", "Forward", None)
267
267
 
268
 
    w = availablepane.AvailablePane(cache, db, 'Ubuntu', icons, datadir,
 
268
    w = availablepane.AvailablePane(cache, db, 'Ubuntu', icons,
269
269
        navhistory_back_action, navhistory_forward_action)
270
270
    w.init_view()
271
271
    w.show()
281
281
    vm = get_test_gtk3_viewmanager()
282
282
    db = get_test_db()
283
283
    cache = get_test_pkg_info()
284
 
    datadir = get_test_datadir()
285
284
    icons = get_test_gtk3_icon_cache()
286
285
 
287
 
    p = globalpane.GlobalPane(vm, datadir, db, cache, icons)
 
286
    p = globalpane.GlobalPane(vm, db, cache, icons)
288
287
 
289
288
    win = get_test_window(child=p)
290
289
    win.set_data("pane", p)
310
309
    cache = get_test_pkg_info()
311
310
    db = get_test_db()
312
311
    icons = get_test_gtk3_icon_cache()
313
 
    datadir = get_test_datadir()
314
312
    manager = get_test_gtk3_viewmanager()
315
313
 
316
 
    view = viewswitcher.ViewSwitcher(manager, datadir, db, cache, icons)
 
314
    view = viewswitcher.ViewSwitcher(manager, db, cache, icons)
317
315
 
318
316
    scroll = Gtk.ScrolledWindow()
319
317
    box = Gtk.VBox()
330
328
    vm  # make pyflakes happy
331
329
    db = get_test_db()
332
330
    cache = get_test_pkg_info()
333
 
    datadir = get_test_datadir()
334
331
    icons = get_test_gtk3_icon_cache()
335
332
 
336
 
    w = installedpane.InstalledPane(cache, db, 'Ubuntu', icons, datadir)
 
333
    w = installedpane.InstalledPane(cache, db, 'Ubuntu', icons)
337
334
    w.show()
338
335
 
339
336
    # init the view
340
337
    w.init_view()
341
338
 
342
339
    w.state.channel = channel.AllInstalledChannel()
343
 
    view_state = softwarepane.DisplayState()
 
340
    view_state = displaystate.DisplayState()
344
341
    view_state.channel = channel.AllInstalledChannel()
345
342
    w.display_overview_page(view_state)
346
343
 
357
354
    cache = get_test_pkg_info()
358
355
    icons = get_test_gtk3_icon_cache()
359
356
 
360
 
    widget = historypane.HistoryPane(cache, db, None, icons, None)
 
357
    widget = historypane.HistoryPane(cache, db, None, icons)
361
358
    widget.show()
362
359
 
363
360
    win = get_test_window(child=widget)
366
363
 
367
364
 
368
365
def get_test_window_recommendations(panel_type="lobby"):
369
 
    # this is *way* too complicated we should *not* need a CatView
370
 
    # here! see FIXME in RecommendationsPanel.__init__()
371
366
    cache = get_test_pkg_info()
372
367
    db = get_test_db()
373
368
    icons = get_test_gtk3_icon_cache()
374
 
    catview = catview_gtk.CategoriesViewGtk(softwarecenter.paths.datadir,
375
 
        softwarecenter.paths.APP_INSTALL_PATH, cache, db, icons)
376
 
 
 
369
    from softwarecenter.ui.gtk3.models.appstore2 import AppPropertiesHelper
 
370
    properties_helper = AppPropertiesHelper(db, cache, icons)
 
371
            
377
372
    if panel_type is "lobby":
378
 
        view = recommendations.RecommendationsPanelLobby(catview)
 
373
        view = recommendations.RecommendationsPanelLobby(
 
374
                db, properties_helper)
379
375
    elif panel_type is "category":
380
376
        cats = get_test_categories(db)
381
 
        view = recommendations.RecommendationsPanelCategory(catview, cats[0])
 
377
        view = recommendations.RecommendationsPanelCategory(
 
378
                db, properties_helper, cats[0])
382
379
    else:  # panel_type is "details":
383
 
        view = recommendations.RecommendationsPanelDetails(catview)
 
380
        view = recommendations.RecommendationsPanelDetails(
 
381
                db, properties_helper)
384
382
 
385
 
    win = get_test_window(child=view)
 
383
    win = get_test_window(child=view, width=600, height=300)
386
384
    win.set_data("rec_panel", view)
387
385
    return win
388
386
 
389
387
 
390
 
def get_test_window_catview(db=None):
391
 
 
 
388
def get_test_window_catview(db=None, selected_category="Internet"):
 
389
    ''' 
 
390
        Note that selected_category must specify a category that includes
 
391
        subcategories, else a ValueError will be raised.
 
392
    '''
392
393
    def on_category_selected(view, cat):
393
394
        print("on_category_selected view: ", view)
394
395
        print("on_category_selected cat: ", cat)
404
405
    else:
405
406
        cache = db._aptcache
406
407
 
407
 
    datadir = softwarecenter.paths.datadir
408
 
    icons = get_sc_icon_theme(datadir)
 
408
    icons = get_sc_icon_theme()
409
409
    distro = softwarecenter.distro.get_distro()
410
410
    apps_filter = appfilter.AppFilter(db, cache)
411
411
 
412
412
    # gui
413
413
    notebook = Gtk.Notebook()
414
414
 
415
 
    lobby_view = catview_gtk.LobbyViewGtk(softwarecenter.paths.datadir,
416
 
        softwarecenter.paths.APP_INSTALL_PATH,
417
 
        cache, db, icons, distro, apps_filter)
 
415
    lobby_view = lobbyview.LobbyView(cache, db, icons, distro, apps_filter)
418
416
 
419
417
    scroll = Gtk.ScrolledWindow()
420
418
    scroll.add(lobby_view)
421
419
    notebook.append_page(scroll, Gtk.Label(label="Lobby"))
422
420
 
423
 
    # find a cat in the LobbyView that has subcategories
424
421
    subcat_cat = None
425
 
    for cat in reversed(lobby_view.categories):
426
 
        if cat.subcategories:
 
422
    for cat in lobby_view.categories:
 
423
        if cat.name == selected_category:
 
424
            if not cat.subcategories:
 
425
                raise ValueError('The value specified for selected_category '
 
426
                                 '*must* specify a '
 
427
                                 'category that contains subcategories!!')
427
428
            subcat_cat = cat
428
429
            break
429
430
 
430
 
    subcat_view = catview_gtk.SubCategoryViewGtk(datadir,
431
 
        softwarecenter.paths.APP_INSTALL_PATH, cache, db, icons, apps_filter)
 
431
    subcat_view = catview.SubCategoryView(cache, db, icons, apps_filter)
432
432
    subcat_view.connect("category-selected", on_category_selected)
433
433
    subcat_view.set_subcategory(subcat_cat)
434
434
 
455
455
    db = database.StoreDatabase(pathname, cache)
456
456
    db.open()
457
457
 
458
 
    datadir = softwarecenter.paths.datadir
459
 
    icons = get_sc_icon_theme(datadir)
 
458
    icons = get_sc_icon_theme()
460
459
    distro = softwarecenter.distro.get_distro()
461
460
    apps_filter = appfilter.AppFilter(db, cache)
462
461
 
463
 
    cat_view = catview_gtk.LobbyViewGtk(softwarecenter.paths.datadir,
464
 
        softwarecenter.paths.APP_INSTALL_PATH,
465
 
        cache, db, icons, distro, apps_filter)
 
462
    cat_view = lobbyview.LobbyView(cache, db, icons, distro, apps_filter)
466
463
 
467
464
    return cat_view
468
465
 
476
473
    db = database.StoreDatabase(pathname, cache)
477
474
    db.open()
478
475
 
479
 
    datadir = softwarecenter.paths.datadir
480
 
    icons = get_sc_icon_theme(datadir)
 
476
    icons = get_sc_icon_theme()
481
477
    distro = softwarecenter.distro.get_distro()
482
478
 
483
479
    # gui
484
480
    scroll = Gtk.ScrolledWindow()
485
 
    view = appdetailsview.AppDetailsView(db, distro, icons, cache, datadir)
 
481
    view = appdetailsview.AppDetailsView(db, distro, icons, cache)
486
482
 
487
483
    if pkgname is None:
488
484
        pkgname = "totem"
517
513
    db = database.StoreDatabase(pathname, cache)
518
514
    db.open()
519
515
 
520
 
    datadir = softwarecenter.paths.datadir
521
 
    icons = get_sc_icon_theme(datadir)
 
516
    icons = get_sc_icon_theme()
522
517
    pkgs = ["apt", "software-center"]
523
518
    view = pkgnamesview.PackageNamesView("header", cache, pkgs, icons, 32, db)
524
519
    view.show()
554
549
    return win
555
550
 
556
551
 
557
 
def get_test_backforward_window():
 
552
def get_test_backforward_window(*args, **kwargs):
558
553
    backforward_button = backforward.BackForwardButton()
559
 
    win = get_test_window(child=backforward_button)
 
554
    win = get_test_window(child=backforward_button, *args, **kwargs)
560
555
    return win
561
556
 
562
557
 
1042
1037
 
1043
1038
 
1044
1039
def get_test_screenshot_thumbnail_window():
 
1040
 
 
1041
    class CycleState(object):
 
1042
        def __init__(self):
 
1043
            self.app_n = 0
 
1044
            self.apps = [application.Application("Movie Player", "totem"),
 
1045
                         application.Application("Comix", "comix"),
 
1046
                         application.Application("Gimp", "gimp"),
 
1047
                         #application.Application("ACE", "uace"),
 
1048
                         ]
 
1049
 
 
1050
    def testing_cycle_apps(widget, thumb, db, cycle_state):
 
1051
        d = cycle_state.apps[cycle_state.app_n].get_details(db)
 
1052
 
 
1053
        if cycle_state.app_n + 1 < len(cycle_state.apps):
 
1054
            cycle_state.app_n += 1
 
1055
        else:
 
1056
            cycle_state.app_n = 0
 
1057
 
 
1058
        thumb.fetch_screenshots(d)
 
1059
        return True
 
1060
 
 
1061
    cycle_state = CycleState()
 
1062
 
1045
1063
    vb = Gtk.VBox(spacing=6)
1046
1064
    win = get_test_window(child=vb)
1047
1065
 
1048
 
    icons = Gtk.IconTheme.get_default()
1049
 
    icons.append_search_path("/usr/share/app-install/icons/")
1050
 
 
 
1066
    icons = get_test_gtk3_icon_cache()
1051
1067
    distro = softwarecenter.distro.get_distro()
1052
1068
 
1053
 
    init_sc_css_provider(win, Gtk.Settings.get_default(),
1054
 
                         Gdk.Screen.get_default(), "data")
1055
 
 
1056
1069
    t = thumbnail.ScreenshotGallery(distro, icons)
1057
1070
    t.connect('draw', t.draw)
1058
1071
    frame = containers.FramedBox()
1060
1073
 
1061
1074
    win.set_data("screenshot_thumbnail_widget", t)
1062
1075
 
1063
 
    b = Gtk.Button('A button for focus testing')
1064
 
    vb.pack_start(b, True, True, 0)
 
1076
    b = Gtk.Button('A button for cycle testing')
 
1077
    vb.pack_start(b, False, False, 8)
1065
1078
    win.set_data("screenshot_button_widget", b)
1066
1079
    vb.pack_start(frame, True, True, 0)
1067
 
 
1068
 
    cache = pkginfo.get_pkg_info()
1069
 
    cache.open()
1070
 
 
1071
 
    xapian_base_path = "/var/cache/software-center"
1072
 
    pathname = os.path.join(xapian_base_path, "xapian")
1073
 
    db = database.StoreDatabase(pathname, cache)
1074
 
    db.open()
1075
 
 
1076
 
    apps = [application.Application("Movie Player", "totem"),
1077
 
            application.Application("Comix", "comix"),
1078
 
            application.Application("Gimp", "gimp"),
1079
 
            application.Application("ACE", "uace")]
1080
 
 
1081
 
    app_n = 0
1082
 
 
1083
 
    def testing_cycle_apps(_, thumb, apps, db):
1084
 
        global app_n
1085
 
        d = apps[app_n].get_details(db)
1086
 
 
1087
 
        if app_n + 1 < len(apps):
1088
 
            app_n += 1
1089
 
        else:
1090
 
            app_n = 0
1091
 
 
1092
 
        thumb.fetch_screenshots(d)
1093
 
        return True
1094
 
 
1095
 
    b.connect("clicked", testing_cycle_apps, t, apps, db)
 
1080
    win.set_data("screenshot_thumbnail_cycle_test_button", b)
 
1081
 
 
1082
    db = get_test_db()
 
1083
    win.show_all()
 
1084
 
 
1085
    testing_cycle_apps(None, t, db, cycle_state)
 
1086
    b.connect("clicked", testing_cycle_apps, t, db, cycle_state)
1096
1087
 
1097
1088
    return win
1098
1089