示例#1
0
 def test_create(self, stage):
     """
     Create a tile
     """
     tile = widgets.Tile()
     tile.set_label("test")
     stage.add_child(tile)
示例#2
0
 def test_model(self, stage):
     """
     Initialize a tile with a model.
     """
     model = {"label": "label"}
     tile = widgets.Tile()
     stage.add_child(tile)
     tile.set_model(model)
示例#3
0
 def test_hilite(self):
     """
     Highlight a tile.
     """
     tile = widgets.Tile()
     tile.hilite_off()
     tile.hilite_on()
     tile.hilite_on()
     tile.hilite_off()
示例#4
0
 def test_model_bad(self, stage):
     """
     Initialize a tile with an invalid model.
     """
     model = {"label": "label", "image_path": "/../nonexistent"}
     tile = widgets.Tile()
     stage.add_child(tile)
     with self.assertRaises(GObject.GError):
         tile.set_model(model)
示例#5
0
 def test_instatiate_cycle(self):
     """
     Get a cycle from a tile page.
     """
     items = [{
         "label": "a"
     }, {
         "label": "b"
     }, {
         "label": "c"
     }, {
         "label": "d"
     }]
     tiles = []
     for item in items:
         tile = widgets.Tile()
         tile.set_model(item)
         tiles.append(tile)
     page = widgets.TilePage(tiles)
     cycle = widgets._TilePageCycle(page)
     cycle.has_next()
示例#6
0
 def test_create(self, stage):
     """
     Create a tile page.
     """
     items = [{
         "label": "a"
     }, {
         "label": "b"
     }, {
         "label": "c"
     }, {
         "label": "d"
     }]
     tiles = []
     for item in items:
         tile = widgets.Tile()
         tile.set_model(item)
         tiles.append(tile)
     page = widgets.TilePage(tiles)
     stage.add_child(page)
     stage.destroy()
示例#7
0
    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)
示例#8
0
 def test_cycle(self, stage):
     """
     Cycle exposing and stopping.
     """
     items = [{
         "label": "a"
     }, {
         "label": "b"
     }, {
         "label": "c"
     }, {
         "label": "d"
     }]
     tiles = []
     for item in items:
         tile = widgets.Tile()
         tile.set_model(item)
         tiles.append(tile)
     page = widgets.TilePage(tiles)
     cycle = page.create_cycle()
     cycle.expose_next()
     cycle.expose_next()
     cycle.stop()
示例#9
0
 def test_expire(self):
     """
     Cycle expiration after 1 round.
     """
     items = [{
         "label": "a"
     }, {
         "label": "b"
     }, {
         "label": "c"
     }, {
         "label": "d"
     }]
     tiles = []
     for item in items:
         tile = widgets.Tile()
         tile.set_model(item)
         tiles.append(tile)
     page = widgets.TilePage(tiles)
     cycle = page.create_cycle()
     for _ in range(len(items)):
         self.assertTrue(cycle.has_next())
         cycle.expose_next()
     self.assertFalse(cycle.has_next())