From a33cce71b60bebf59d6ff7e27347a108f2c823a8 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Sun, 10 Sep 2006 23:50:07 +0200 Subject: [PATCH] Add test --- tests/test-grid.py | 54 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100755 tests/test-grid.py diff --git a/tests/test-grid.py b/tests/test-grid.py new file mode 100755 index 00000000..b664fa94 --- /dev/null +++ b/tests/test-grid.py @@ -0,0 +1,54 @@ +#!/usr/bin/python +import pygtk +pygtk.require('2.0') + +from sugar.session.UITestSession import UITestSession + +session = UITestSession() +session.start() + +import gtk +import goocanvas + +from sugar.canvas.IconColor import IconColor +from sugar.canvas.IconItem import IconItem +from sugar.canvas.CanvasView import CanvasView +from sugar.canvas.GridBox import GridBox +from sugar.canvas.GridModel import GridModel +from sugar.canvas.GridLayout import GridConstraints + +def _new_icon_clicked_cb(icon): + box.remove_child(icon) + +def _icon_clicked_cb(icon): + icon = IconItem(color=IconColor(), icon_name='activity-groupchat') + icon.connect('clicked', _new_icon_clicked_cb) + box.add_child(icon, 0) + +model = GridModel('#4f4f4f') +layout = model.get_layout() + +box = GridBox(GridBox.HORIZONTAL, 5, 6) +layout.set_constraints(box, GridConstraints(0, 0, 5, 1)) +model.add(box) + +rect = goocanvas.Rect(fill_color='red') +box.add_child(rect) + +icon = IconItem(color=IconColor(), icon_name='activity-web') +icon.connect('clicked', _icon_clicked_cb) +box.add_child(icon) + +icon = IconItem(color=IconColor(), icon_name='activity-groupchat') +box.add_child(icon) + +window = gtk.Window() +window.connect("destroy", lambda w: gtk.main_quit()) +window.show() + +canvas = CanvasView() +canvas.show() +window.add(canvas) +canvas.set_model(model.get()) + +gtk.main()