def test_context(self): """ Context for a dummy application. """ class DummyApp(object): pass app = DummyApp() switcher_app.Context(app)
def test_page_tile_view(self): dummy_application = object() dummy_context = switcher_app.Context(dummy_application) model = {"items": [{"label": "a"}], "page_interval": 3000} actor = PagedTileView() actor.set_model(model) cycle = actor.create_cycle() selection = cycle.select() selection(dummy_context)
def test_dummy_view_container(self): """ View container usage """ context = switcher_app.Context(object()) view_actor = DummyView() view_container = DummyViewContainer(context) view_container.push_view(view_actor) self.assertTrue(view_container.pushed) view_container.pop_view() self.assertTrue(view_container.popped)
def test_abstract_view_container(self): """ Abstract view container methods """ context = switcher_app.Context(object()) view_container = view.AbstractViewContainer(context) view_actor = DummyView() with self.assertRaises(NotImplementedError): view_container.push_view(view_actor) with self.assertRaises(NotImplementedError): view_container.pop_view()
def test_basic_view_container(self, stage): """ View container as clutter actor """ class DummyViewActor(Clutter.Actor): def create_initial_cycle(self): return DummyCycle() context = switcher_app.Context(object()) view_container = view.BasicViewContainer(context) view_actor_1 = DummyViewActor() view_actor_2 = DummyViewActor() stage.add_child(view_container) view_container.push_view(view_actor_1) view_container.push_view(view_actor_2) view_container.pop_view()
def test_views(self): class DummyCycle(switcher_app.Cycle): interval = 1000 def expose_next(self): pass def stop(self): pass class ViewActor(Clutter.Actor): def create_initial_cycle(self): return DummyCycle() view_1 = ViewActor() view_2 = ViewActor() context = switcher_app.Context(object()) content = application.PisakViewerContainer(context) content.push_view(view_1) content.push_view(view_2)
def test_select_cycle(self): """ Test cycle selection """ class DummyApplication(object): def __init__(self): self.pushed = False def push_view(self, view): self.pushed = True dummy_context = switcher_app.Context(DummyApplication()) def tile_activated(source): dummy_context.application.push_view(None) items = [{ "label": "a" }, { "label": "b" }, { "label": "c" }, { "label": "d" }] tiles = [] for item in items: tile = widgets.Tile() tile.connect("activate", tile_activated) tile.set_model(item) tiles.append(tile) page = widgets.TilePage(tiles) cycle = widgets._TilePageCycle(page) cycle.expose_next() selection = cycle.select() print(selection) selection(dummy_context) self.assertTrue(dummy_context.application.pushed)
def __init__(self): self.context = switcher_app.Context(self)