[Sugar-devel] [PATCH sugar-toolkit-gtk3] Add a make target for tests
Daniel Narvaez
dwnarvaez at gmail.com
Thu Dec 6 12:24:26 EST 2012
From: Daniel Narvaez <dwnarvaez at gmail.com>
We are running the existing test_mime.py. All the other tests which
are not unit tests but more examples of code one can run interactively
are moved to the example directory.
---
Makefile.am | 4 ++
examples/buttons.py | 64 ++++++++++++++++++++++++++
examples/cellrenderericon.py | 37 +++++++++++++++
examples/common.py | 73 ++++++++++++++++++++++++++++++
examples/customdestroy.py | 44 ++++++++++++++++++
examples/gtktreesensitive.py | 48 ++++++++++++++++++++
examples/iconbadges.py | 28 ++++++++++++
examples/iconcache.py | 70 +++++++++++++++++++++++++++++
examples/iconwidget.py | 87 ++++++++++++++++++++++++++++++++++++
examples/intro.py | 8 ++++
examples/progress.py | 20 +++++++++
examples/tabs.py | 46 +++++++++++++++++++
examples/ticket2855.py | 59 ++++++++++++++++++++++++
examples/ticket2999.py | 38 ++++++++++++++++
examples/ticket3000.py | 48 ++++++++++++++++++++
examples/toolbarpalettes.py | 65 +++++++++++++++++++++++++++
examples/toolbuttons.py | 45 +++++++++++++++++++
examples/tray.py | 82 +++++++++++++++++++++++++++++++++
tests/graphics/buttons.py | 64 --------------------------
tests/graphics/cellrenderericon.py | 37 ---------------
tests/graphics/common.py | 73 ------------------------------
tests/graphics/customdestroy.py | 44 ------------------
tests/graphics/gtktreesensitive.py | 48 --------------------
tests/graphics/iconbadges.py | 28 ------------
tests/graphics/iconcache.py | 70 -----------------------------
tests/graphics/iconwidget.py | 87 ------------------------------------
tests/graphics/intro.py | 8 ----
tests/graphics/progress.py | 20 ---------
tests/graphics/tabs.py | 46 -------------------
tests/graphics/ticket2855.py | 59 ------------------------
tests/graphics/ticket2999.py | 38 ----------------
tests/graphics/ticket3000.py | 48 --------------------
tests/graphics/toolbarpalettes.py | 65 ---------------------------
tests/graphics/toolbuttons.py | 45 -------------------
tests/graphics/tray.py | 82 ---------------------------------
tests/lib/runall.py | 28 ------------
tests/lib/test_mime.py | 84 ----------------------------------
tests/test_mime.py | 84 ++++++++++++++++++++++++++++++++++
38 files changed, 950 insertions(+), 974 deletions(-)
create mode 100644 examples/buttons.py
create mode 100644 examples/cellrenderericon.py
create mode 100644 examples/common.py
create mode 100644 examples/customdestroy.py
create mode 100644 examples/gtktreesensitive.py
create mode 100644 examples/iconbadges.py
create mode 100644 examples/iconcache.py
create mode 100644 examples/iconwidget.py
create mode 100644 examples/intro.py
create mode 100644 examples/progress.py
create mode 100644 examples/tabs.py
create mode 100644 examples/ticket2855.py
create mode 100644 examples/ticket2999.py
create mode 100644 examples/ticket3000.py
create mode 100644 examples/toolbarpalettes.py
create mode 100644 examples/toolbuttons.py
create mode 100644 examples/tray.py
delete mode 100644 tests/graphics/buttons.py
delete mode 100644 tests/graphics/cellrenderericon.py
delete mode 100644 tests/graphics/common.py
delete mode 100644 tests/graphics/customdestroy.py
delete mode 100644 tests/graphics/gtktreesensitive.py
delete mode 100644 tests/graphics/iconbadges.py
delete mode 100644 tests/graphics/iconcache.py
delete mode 100644 tests/graphics/iconwidget.py
delete mode 100644 tests/graphics/intro.py
delete mode 100644 tests/graphics/progress.py
delete mode 100644 tests/graphics/tabs.py
delete mode 100644 tests/graphics/ticket2855.py
delete mode 100644 tests/graphics/ticket2999.py
delete mode 100644 tests/graphics/ticket3000.py
delete mode 100644 tests/graphics/toolbarpalettes.py
delete mode 100644 tests/graphics/toolbuttons.py
delete mode 100644 tests/graphics/tray.py
delete mode 100644 tests/lib/runall.py
delete mode 100644 tests/lib/test_mime.py
create mode 100644 tests/test_mime.py
diff --git a/Makefile.am b/Makefile.am
index 86a095c..f0366b4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -12,3 +12,7 @@ EXTRA_DIST = \
intltool-extract.in
SUBDIRS = bin src po
+
+test:
+ cd $(top_srcdir)/tests && \
+ python -m unittest discover
diff --git a/examples/buttons.py b/examples/buttons.py
new file mode 100644
index 0000000..a222215
--- /dev/null
+++ b/examples/buttons.py
@@ -0,0 +1,64 @@
+from gi.repository import Gtk
+
+import common
+
+
+test = common.Test()
+test.show()
+
+vbox = Gtk.VBox()
+test.pack_start(vbox, True, True, 0)
+vbox.show()
+
+# test Gtk.SpinButton:
+
+adj = Gtk.Adjustment(0, 0, 10, 1, 32, 0)
+spin = Gtk.SpinButton()
+spin.set_adjustment(adj)
+vbox.pack_start(spin, False, False, 1)
+spin.show()
+
+# test Gtk.RadioButton:
+
+radio_1 = Gtk.RadioButton.new_with_label_from_widget(None, 'Radio 1')
+vbox.pack_start(radio_1, False, False, 1)
+radio_1.show()
+radio_2 = Gtk.RadioButton.new_with_label_from_widget(radio_1, 'Radio 2')
+vbox.pack_start(radio_2, False, False, 1)
+radio_2.show()
+radio_3 = Gtk.RadioButton.new_with_label_from_widget(radio_1, 'Radio 3')
+vbox.pack_start(radio_3, False, False, 1)
+radio_3.show()
+
+# test Gtk.CheckButton:
+
+check_1 = Gtk.CheckButton('Check 1')
+vbox.pack_start(check_1, False, False, 1)
+check_1.show()
+
+check_2 = Gtk.CheckButton('Check 2')
+vbox.pack_start(check_2, False, False, 1)
+check_2.show()
+
+# test Gtk.Button:
+
+button = Gtk.Button('Button')
+vbox.pack_start(button, False, False, 1)
+button.show()
+
+# test Gtk.Button insensitive:
+
+insensitive_button = Gtk.Button('Insensitive Button')
+vbox.pack_start(insensitive_button, False, False, 1)
+insensitive_button.props.sensitive = False
+insensitive_button.show()
+
+# test Gtk.ToggleButton:
+
+toggle_button = Gtk.ToggleButton('ToggleButton')
+vbox.pack_start(toggle_button, False, False, 1)
+toggle_button.show()
+
+
+if __name__ == '__main__':
+ common.main(test)
diff --git a/examples/cellrenderericon.py b/examples/cellrenderericon.py
new file mode 100644
index 0000000..1f87552
--- /dev/null
+++ b/examples/cellrenderericon.py
@@ -0,0 +1,37 @@
+from gi.repository import Gtk
+
+from sugar3.graphics import style
+from sugar3.graphics.icon import CellRendererIcon
+
+import common
+
+
+test = common.Test()
+test.show()
+
+model = Gtk.ListStore(str)
+for icon in ['one', 'two', 'three']:
+ model.append([icon])
+
+treeview = Gtk.TreeView()
+treeview.set_model(model)
+test.pack_start(treeview, True, True, 0)
+treeview.show()
+
+col = Gtk.TreeViewColumn()
+treeview.append_column(col)
+
+cell_icon = CellRendererIcon(treeview)
+cell_icon.props.width = style.GRID_CELL_SIZE
+cell_icon.props.height = style.GRID_CELL_SIZE
+cell_icon.props.size = style.SMALL_ICON_SIZE
+cell_icon.props.icon_name = 'emblem-favorite'
+col.pack_start(cell_icon, expand=False)
+
+cell_text = Gtk.CellRendererText()
+col.pack_start(cell_text, expand=True)
+col.add_attribute(cell_text, 'text', 0)
+
+
+if __name__ == '__main__':
+ common.main(test)
diff --git a/examples/common.py b/examples/common.py
new file mode 100644
index 0000000..02c3e19
--- /dev/null
+++ b/examples/common.py
@@ -0,0 +1,73 @@
+# Copyright (C) 2007, Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+from gi.repository import Gtk
+from gi.repository import GObject
+
+from sugar3.graphics.toolbutton import ToolButton
+
+import os
+
+
+def set_theme():
+ settings = Gtk.Settings.get_default()
+ sugar_theme = 'sugar-72'
+ if 'SUGAR_SCALING' in os.environ:
+ if os.environ['SUGAR_SCALING'] == '100':
+ sugar_theme = 'sugar-100'
+ settings.set_property('gtk-theme-name', sugar_theme)
+ settings.set_property('gtk-icon-theme-name', 'sugar')
+
+
+class Test(Gtk.VBox):
+ def __init__(self):
+ GObject.GObject.__init__(self)
+
+
+class TestPalette(Test):
+ def __init__(self):
+ Test.__init__(self)
+
+ toolbar = Gtk.Toolbar()
+
+ self._invoker = ToolButton('go-previous')
+ toolbar.insert(self._invoker, -1)
+ self._invoker.show()
+
+ self.pack_start(toolbar, False)
+ toolbar.show()
+
+ def set_palette(self, palette):
+ self._invoker.set_palette(palette)
+
+
+class TestRunner(object):
+ def run(self, test):
+ set_theme()
+ window = Gtk.Window()
+ window.connect('destroy', lambda w: Gtk.main_quit())
+ window.add(test)
+ test.show()
+
+ window.show()
+
+
+def main(test):
+ runner = TestRunner()
+ runner.run(test)
+
+ Gtk.main()
diff --git a/examples/customdestroy.py b/examples/customdestroy.py
new file mode 100644
index 0000000..72156a8
--- /dev/null
+++ b/examples/customdestroy.py
@@ -0,0 +1,44 @@
+from gi.repository import Gtk
+
+"""
+Since GTK+3 Gtk.CellRenderer doesn't have a destroy signal anymore.
+We can do the cleanup in the python destructor method instead.
+
+"""
+
+
+class MyCellRenderer(Gtk.CellRenderer):
+ def __init__(self):
+ Gtk.CellRenderer.__init__(self)
+
+ def __del__(self):
+ print "cellrenderer destroy"
+
+ def do_render(self, cairo_t, widget, background_area, cell_area, flags):
+ pass
+
+
+def window_destroy_cb(*kwargs):
+ print "window destroy"
+ Gtk.main_quit()
+
+window = Gtk.Window(Gtk.WindowType.TOPLEVEL)
+window.connect("destroy", window_destroy_cb)
+window.show()
+
+
+def treeview_destroy_cb(*kwargs):
+ print "treeview destroy"
+
+treeview = Gtk.TreeView()
+treeview.connect("destroy", treeview_destroy_cb)
+window.add(treeview)
+treeview.show()
+
+col = Gtk.TreeViewColumn()
+treeview.append_column(col)
+
+cel = MyCellRenderer()
+col.pack_start(cel, expand=True)
+
+Gtk.main()
diff --git a/examples/gtktreesensitive.py b/examples/gtktreesensitive.py
new file mode 100644
index 0000000..875612f
--- /dev/null
+++ b/examples/gtktreesensitive.py
@@ -0,0 +1,48 @@
+#!/usr/bin/python
+from gi.repository import Gtk
+
+
+import common
+test = common.Test()
+test.show()
+
+
+class MyBox(Gtk.VBox):
+
+ def __init__(self):
+ Gtk.VBox.__init__(self)
+
+ self.scrolled = Gtk.ScrolledWindow()
+ self.scrolled.set_policy(Gtk.PolicyType.AUTOMATIC,
+ Gtk.PolicyType.AUTOMATIC)
+
+ self.store = Gtk.ListStore(str, str)
+ for i in range(5):
+ self.store.append([str(i), 'Item %s' % i])
+
+ self.treeview = Gtk.TreeView(self.store)
+ renderer_no_sens = Gtk.CellRendererText()
+ # set 'sensitive' property
+ renderer_no_sens.set_property('sensitive', False)
+
+ renderer = Gtk.CellRendererText()
+
+ column = Gtk.TreeViewColumn('\'sensitive\' False',
+ renderer_no_sens, text=0)
+ self.treeview.append_column(column)
+
+ column = Gtk.TreeViewColumn('\'sensitive\' True',
+ renderer, text=1)
+ self.treeview.append_column(column)
+
+ self.scrolled.add(self.treeview)
+ self.add(self.scrolled)
+
+ self.show_all()
+
+vbox = MyBox()
+test.pack_start(vbox, True, True, 0)
+vbox.show()
+
+if __name__ == '__main__':
+ common.main(test)
diff --git a/examples/iconbadges.py b/examples/iconbadges.py
new file mode 100644
index 0000000..f72dfe3
--- /dev/null
+++ b/examples/iconbadges.py
@@ -0,0 +1,28 @@
+from gi.repository import Gtk
+
+from sugar3.graphics.icon import EventIcon
+from sugar3.graphics.icon import Icon
+
+import common
+
+
+test = common.Test()
+test.show()
+
+vbox = Gtk.VBox()
+test.pack_start(vbox, True, True, 0)
+vbox.show()
+
+icon = Icon(icon_name="network-wireless-000")
+icon.props.badge_name = 'emblem-favorite'
+vbox.pack_start(icon, False, False, 0)
+icon.show()
+
+icon = EventIcon(icon_name="network-wireless-000")
+icon.props.badge_name = 'emblem-favorite'
+vbox.pack_start(icon, False, False, 0)
+icon.show()
+
+
+if __name__ == '__main__':
+ common.main(test)
diff --git a/examples/iconcache.py b/examples/iconcache.py
new file mode 100644
index 0000000..5a027d9
--- /dev/null
+++ b/examples/iconcache.py
@@ -0,0 +1,70 @@
+# Copyright (C) 2007, Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+"""
+Test the sugar3.graphics.icon.* cache.
+"""
+
+from gi.repository import Gtk
+
+from sugar3.graphics.icon import Icon
+from sugar3.graphics.xocolor import XoColor
+
+import common
+
+test = common.Test()
+
+data = [
+ ['battery-000', '#FF8F00,#FF2B34'],
+ ['battery-010', '#D1A3FF,#00A0FF'],
+ ['battery-020', '#FF8F00,#FF2B34'],
+ ['battery-030', '#00A0FF,#D1A3FF'],
+ ['battery-040', '#AC32FF,#FF2B34'],
+ ['battery-050', '#D1A3FF,#00A0FF'],
+ ['battery-060', '#AC32FF,#FF2B34'],
+ ['battery-070', '#00A0FF,#D1A3FF'],
+ ['battery-080', '#FF8F00,#FF2B34'],
+ ['battery-090', '#D1A3FF,#00A0FF'],
+ ['battery-100', '#AC32FF,#FF2B34']]
+
+
+def _button_activated_cb(button):
+ import random
+
+ global data
+ random.shuffle(data)
+
+ for i in range(0, len(test.get_children()) - 1):
+ test.get_children()[i].props.icon_name = data[i][0]
+ test.get_children()[i].props.xo_color = XoColor(data[i][1])
+
+for d in data:
+ icon = Icon(icon_name=d[0],
+ icon_size=Gtk.IconSize.LARGE_TOOLBAR,
+ xo_color=XoColor(d[1]))
+ test.pack_start(icon, True, True, 0)
+ icon.show()
+
+button = Gtk.Button('mec mac')
+test.pack_start(button, True, True, 0)
+button.connect('activate', _button_activated_cb)
+button.show()
+
+test.show()
+
+if __name__ == '__main__':
+ common.main(test)
diff --git a/examples/iconwidget.py b/examples/iconwidget.py
new file mode 100644
index 0000000..e4d7f26
--- /dev/null
+++ b/examples/iconwidget.py
@@ -0,0 +1,87 @@
+# Copyright (C) 2007, Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+"""
+Test the sugar3.graphics.icon.Icon widget.
+"""
+
+from gi.repository import Gtk
+
+from sugar3.graphics.icon import Icon
+from sugar3.graphics.xocolor import XoColor
+
+import common
+
+test = common.Test()
+
+hbox = Gtk.HBox()
+test.pack_start(hbox, True, True, 0)
+sensitive_box = Gtk.VBox()
+insensitive_box = Gtk.VBox()
+
+hbox.pack_start(sensitive_box, True, True, 0)
+hbox.pack_start(insensitive_box, True, True, 0)
+hbox.show_all()
+
+
+def create_icon_widgets(box, sensitive=True):
+ icon = Icon(icon_name='go-previous')
+ icon.props.icon_size = Gtk.IconSize.LARGE_TOOLBAR
+ box.pack_start(icon, True, True, 0)
+ icon.set_sensitive(sensitive)
+ icon.show()
+
+ icon = Icon(icon_name='computer-xo',
+ icon_size=Gtk.IconSize.LARGE_TOOLBAR,
+ xo_color=XoColor())
+ box.pack_start(icon, True, True, 0)
+ icon.set_sensitive(sensitive)
+ icon.show()
+
+ icon = Icon(icon_name='battery-000',
+ icon_size=Gtk.IconSize.LARGE_TOOLBAR,
+ badge_name='emblem-busy')
+ box.pack_start(icon, True, True, 0)
+ icon.set_sensitive(sensitive)
+ icon.show()
+
+ icon = Icon(icon_name='gtk-new',
+ icon_size=Gtk.IconSize.LARGE_TOOLBAR,
+ badge_name='gtk-cancel')
+ box.pack_start(icon, True, True, 0)
+ icon.set_sensitive(sensitive)
+ icon.show()
+
+
+create_icon_widgets(sensitive_box, True)
+create_icon_widgets(insensitive_box, False)
+
+test.show()
+
+# This can be used to test for leaks by setting the LRU cache size
+# in icon.py to 1.
+#def idle_cb():
+# import gc
+# gc.collect()
+# test.queue_draw()
+# return True
+#
+#from gi.repository import GObject
+#GObject.idle_add(idle_cb)
+
+if __name__ == '__main__':
+ common.main(test)
diff --git a/examples/intro.py b/examples/intro.py
new file mode 100644
index 0000000..05c5b5a
--- /dev/null
+++ b/examples/intro.py
@@ -0,0 +1,8 @@
+from gi.repository import Gtk
+from common import set_theme
+from jarabe.intro.window import IntroWindow
+
+set_theme()
+win = IntroWindow()
+win.show_all()
+Gtk.main()
diff --git a/examples/progress.py b/examples/progress.py
new file mode 100644
index 0000000..bc176a8
--- /dev/null
+++ b/examples/progress.py
@@ -0,0 +1,20 @@
+from gi.repository import Gtk
+
+import common
+
+
+test = common.Test()
+test.show()
+
+box = Gtk.HBox()
+test.pack_start(box, True, False, 10)
+box.show()
+
+bar = Gtk.ProgressBar()
+bar.set_fraction(0.5)
+box.pack_start(bar, True, True, 10)
+bar.show()
+
+
+if __name__ == '__main__':
+ common.main(test)
diff --git a/examples/tabs.py b/examples/tabs.py
new file mode 100644
index 0000000..fbc4bac
--- /dev/null
+++ b/examples/tabs.py
@@ -0,0 +1,46 @@
+#!/usr/bin/python
+from gi.repository import Gtk
+
+from sugar3.graphics.icon import Icon
+
+import common
+test = common.Test()
+test.show()
+
+box = Gtk.HBox()
+test.pack_start(box, True, True, 0)
+box.show()
+
+# notebook without button
+
+notebook = Gtk.Notebook()
+box.pack_start(notebook, True, True, 0)
+notebook.show()
+
+for i in range(3):
+ hbox = Gtk.HBox()
+ notebook.append_page(hbox, Gtk.Label('Page %d' % (i + 1)))
+ hbox.show()
+
+# notebook with buttons
+
+notebook = Gtk.Notebook()
+box.pack_start(notebook, True, True, 0)
+notebook.show()
+
+add_icon = Icon(icon_name='add')
+button = Gtk.Button()
+button.props.focus_on_click = False
+button.add(add_icon)
+add_icon.show()
+
+notebook.set_action_widget(button, Gtk.PackType.END)
+button.show()
+
+for i in range(3):
+ hbox = Gtk.HBox()
+ notebook.append_page(hbox, Gtk.Label('Page %d' % (i + 1)))
+ hbox.show()
+
+if __name__ == '__main__':
+ common.main(test)
diff --git a/examples/ticket2855.py b/examples/ticket2855.py
new file mode 100644
index 0000000..0de36a3
--- /dev/null
+++ b/examples/ticket2855.py
@@ -0,0 +1,59 @@
+# Copyright (C) 2007, Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+"""
+Test the style of toggle and radio buttons inside a palette. The buttons
+contains only an icon and should be rendered similarly to the toolbar
+controls. Ticket #2855.
+"""
+
+from gi.repository import Gtk
+
+from sugar3.graphics.palette import Palette
+from sugar3.graphics.icon import Icon
+
+import common
+
+test = common.TestPalette()
+
+palette = Palette('Test radio and toggle')
+test.set_palette(palette)
+
+box = Gtk.HBox()
+
+toggle = Gtk.ToggleButton()
+
+icon = Icon(icon_name='go-previous', icon_size=Gtk.IconSize.LARGE_TOOLBAR)
+toggle.set_image(icon)
+
+box.pack_start(toggle, False)
+toggle.show()
+
+radio = Gtk.RadioButton()
+
+icon = Icon(icon_name='go-next', icon_size=Gtk.IconSize.LARGE_TOOLBAR)
+radio.set_image(icon)
+
+radio.set_mode(False)
+box.pack_start(radio, False)
+radio.show()
+
+palette.set_content(box)
+box.show()
+
+if __name__ == '__main__':
+ common.main(test)
diff --git a/examples/ticket2999.py b/examples/ticket2999.py
new file mode 100644
index 0000000..557ba53
--- /dev/null
+++ b/examples/ticket2999.py
@@ -0,0 +1,38 @@
+# Copyright (C) 2007, One Laptop Per Child
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+"""
+Spec in ticket #2999.
+"""
+
+from gi.repository import Gtk
+
+from sugar3.graphics.palette import Palette
+from sugar3.graphics.icon import Icon
+
+import common
+
+test = common.Test()
+test.set_border_width(60)
+
+text_view = Gtk.TextView()
+text_view.props.buffer.props.text = 'Blah blah blah, blah blah blah.'
+test.pack_start(text_view, True, True, 0)
+text_view.show()
+
+if __name__ == '__main__':
+ common.main(test)
diff --git a/examples/ticket3000.py b/examples/ticket3000.py
new file mode 100644
index 0000000..295d796
--- /dev/null
+++ b/examples/ticket3000.py
@@ -0,0 +1,48 @@
+# Copyright (C) 2007, One Laptop Per Child
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+"""
+Spec in ticket #3000.
+"""
+
+from gi.repository import Gtk
+
+from sugar3.graphics.toolbutton import ToolButton
+
+import common
+
+test = common.Test()
+
+toolbar = Gtk.Toolbar()
+test.pack_start(toolbar, False)
+toolbar.show()
+
+button = ToolButton('go-previous')
+toolbar.insert(button, -1)
+button.show()
+
+separator = Gtk.SeparatorToolItem()
+toolbar.add(separator)
+separator.show()
+
+button = ToolButton('go-next')
+toolbar.insert(button, -1)
+button.show()
+
+
+if __name__ == '__main__':
+ common.main(test)
diff --git a/examples/toolbarpalettes.py b/examples/toolbarpalettes.py
new file mode 100644
index 0000000..93177c1
--- /dev/null
+++ b/examples/toolbarpalettes.py
@@ -0,0 +1,65 @@
+# Copyright (C) 2007, Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+"""
+Test palette positioning for toolbar and tray.
+"""
+
+from gi.repository import Gtk
+
+from sugar3.graphics.tray import HTray, TrayButton
+from sugar3.graphics.toolbutton import ToolButton
+
+import common
+
+test = common.Test()
+
+vbox = Gtk.VBox()
+
+theme_icons = Gtk.IconTheme.get_default().list_icons()
+
+toolbar = Gtk.Toolbar()
+vbox.pack_start(toolbar, False)
+toolbar.show()
+
+for i in range(0, 5):
+ button = ToolButton(icon_name=theme_icons[i])
+ button.set_tooltip('Icon %d' % i)
+ toolbar.insert(button, -1)
+ button.show()
+
+content = Gtk.Label()
+vbox.pack_start(content, True, True, 0)
+content.show()
+
+tray = HTray()
+vbox.pack_start(tray, False)
+tray.show()
+
+for i in range(0, 30):
+ button = TrayButton(icon_name=theme_icons[i])
+ button.set_tooltip('Icon %d' % i)
+ tray.add_item(button)
+ button.show()
+
+test.pack_start(vbox, True, True, 0)
+vbox.show()
+
+test.show()
+
+if __name__ == '__main__':
+ common.main(test)
diff --git a/examples/toolbuttons.py b/examples/toolbuttons.py
new file mode 100644
index 0000000..3344cba
--- /dev/null
+++ b/examples/toolbuttons.py
@@ -0,0 +1,45 @@
+from gi.repository import Gtk
+
+from sugar3.graphics.toolbarbox import ToolbarBox
+from sugar3.graphics.colorbutton import ColorToolButton
+from sugar3.graphics.radiotoolbutton import RadioToolButton
+from sugar3.graphics.toggletoolbutton import ToggleToolButton
+
+import common
+
+
+test = common.Test()
+test.show()
+
+vbox = Gtk.VBox()
+test.pack_start(vbox, True, True, 0)
+vbox.show()
+
+toolbar_box = ToolbarBox()
+vbox.pack_start(toolbar_box, False, False, 0)
+toolbar_box.show()
+
+radial_button = RadioToolButton(icon_name='view-radial')
+toolbar_box.toolbar.insert(radial_button, -1)
+radial_button.show()
+
+list_button = RadioToolButton(icon_name='view-list')
+list_button.props.group = radial_button
+toolbar_box.toolbar.insert(list_button, -1)
+list_button.show()
+
+separator = Gtk.SeparatorToolItem()
+toolbar_box.toolbar.insert(separator, -1)
+separator.show()
+
+color_button = ColorToolButton()
+toolbar_box.toolbar.insert(color_button, -1)
+color_button.show()
+
+favorite_button = ToggleToolButton('emblem-favorite')
+toolbar_box.toolbar.insert(favorite_button, -1)
+favorite_button.show()
+
+
+if __name__ == '__main__':
+ common.main(test)
diff --git a/examples/tray.py b/examples/tray.py
new file mode 100644
index 0000000..3da60e3
--- /dev/null
+++ b/examples/tray.py
@@ -0,0 +1,82 @@
+# Copyright (C) 2007, Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+"""
+Test the sugar3.graphics.icon.Icon widget.
+"""
+
+from gi.repository import Gtk
+
+from sugar3.graphics.tray import HTray, VTray
+from sugar3.graphics.tray import TrayButton, TrayIcon
+
+import common
+
+test = common.Test()
+
+vbox = Gtk.VBox()
+
+tray = HTray()
+vbox.pack_start(tray, False, False, 0)
+tray.show()
+
+theme_icons = Gtk.IconTheme.get_default().list_icons(context=None)
+
+for i in range(0, 100):
+ button = TrayButton(icon_name=theme_icons[i])
+ tray.add_item(button)
+ button.show()
+
+tray = HTray()
+vbox.pack_start(tray, False, False, 0)
+tray.show()
+
+for i in range(0, 10):
+ icon = TrayIcon(icon_name=theme_icons[i])
+ tray.add_item(icon)
+ icon.show()
+
+hbox = Gtk.HBox()
+
+tray = VTray()
+hbox.pack_start(tray, False, False, 0)
+tray.show()
+
+for i in range(0, 100):
+ button = TrayButton(icon_name=theme_icons[i])
+ tray.add_item(button)
+ button.show()
+
+tray = VTray()
+hbox.pack_start(tray, False, False, 0)
+tray.show()
+
+for i in range(0, 4):
+ button = TrayButton(icon_name=theme_icons[i])
+ tray.add_item(button)
+ button.show()
+
+vbox.pack_start(hbox, True, True, 0)
+hbox.show()
+
+test.pack_start(vbox, True, True, 0)
+vbox.show()
+
+test.show()
+
+if __name__ == '__main__':
+ common.main(test)
diff --git a/tests/graphics/buttons.py b/tests/graphics/buttons.py
deleted file mode 100644
index a222215..0000000
--- a/tests/graphics/buttons.py
+++ /dev/null
@@ -1,64 +0,0 @@
-from gi.repository import Gtk
-
-import common
-
-
-test = common.Test()
-test.show()
-
-vbox = Gtk.VBox()
-test.pack_start(vbox, True, True, 0)
-vbox.show()
-
-# test Gtk.SpinButton:
-
-adj = Gtk.Adjustment(0, 0, 10, 1, 32, 0)
-spin = Gtk.SpinButton()
-spin.set_adjustment(adj)
-vbox.pack_start(spin, False, False, 1)
-spin.show()
-
-# test Gtk.RadioButton:
-
-radio_1 = Gtk.RadioButton.new_with_label_from_widget(None, 'Radio 1')
-vbox.pack_start(radio_1, False, False, 1)
-radio_1.show()
-radio_2 = Gtk.RadioButton.new_with_label_from_widget(radio_1, 'Radio 2')
-vbox.pack_start(radio_2, False, False, 1)
-radio_2.show()
-radio_3 = Gtk.RadioButton.new_with_label_from_widget(radio_1, 'Radio 3')
-vbox.pack_start(radio_3, False, False, 1)
-radio_3.show()
-
-# test Gtk.CheckButton:
-
-check_1 = Gtk.CheckButton('Check 1')
-vbox.pack_start(check_1, False, False, 1)
-check_1.show()
-
-check_2 = Gtk.CheckButton('Check 2')
-vbox.pack_start(check_2, False, False, 1)
-check_2.show()
-
-# test Gtk.Button:
-
-button = Gtk.Button('Button')
-vbox.pack_start(button, False, False, 1)
-button.show()
-
-# test Gtk.Button insensitive:
-
-insensitive_button = Gtk.Button('Insensitive Button')
-vbox.pack_start(insensitive_button, False, False, 1)
-insensitive_button.props.sensitive = False
-insensitive_button.show()
-
-# test Gtk.ToggleButton:
-
-toggle_button = Gtk.ToggleButton('ToggleButton')
-vbox.pack_start(toggle_button, False, False, 1)
-toggle_button.show()
-
-
-if __name__ == '__main__':
- common.main(test)
diff --git a/tests/graphics/cellrenderericon.py b/tests/graphics/cellrenderericon.py
deleted file mode 100644
index 1f87552..0000000
--- a/tests/graphics/cellrenderericon.py
+++ /dev/null
@@ -1,37 +0,0 @@
-from gi.repository import Gtk
-
-from sugar3.graphics import style
-from sugar3.graphics.icon import CellRendererIcon
-
-import common
-
-
-test = common.Test()
-test.show()
-
-model = Gtk.ListStore(str)
-for icon in ['one', 'two', 'three']:
- model.append([icon])
-
-treeview = Gtk.TreeView()
-treeview.set_model(model)
-test.pack_start(treeview, True, True, 0)
-treeview.show()
-
-col = Gtk.TreeViewColumn()
-treeview.append_column(col)
-
-cell_icon = CellRendererIcon(treeview)
-cell_icon.props.width = style.GRID_CELL_SIZE
-cell_icon.props.height = style.GRID_CELL_SIZE
-cell_icon.props.size = style.SMALL_ICON_SIZE
-cell_icon.props.icon_name = 'emblem-favorite'
-col.pack_start(cell_icon, expand=False)
-
-cell_text = Gtk.CellRendererText()
-col.pack_start(cell_text, expand=True)
-col.add_attribute(cell_text, 'text', 0)
-
-
-if __name__ == '__main__':
- common.main(test)
diff --git a/tests/graphics/common.py b/tests/graphics/common.py
deleted file mode 100644
index 02c3e19..0000000
--- a/tests/graphics/common.py
+++ /dev/null
@@ -1,73 +0,0 @@
-# Copyright (C) 2007, Red Hat, Inc.
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the
-# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-
-from gi.repository import Gtk
-from gi.repository import GObject
-
-from sugar3.graphics.toolbutton import ToolButton
-
-import os
-
-
-def set_theme():
- settings = Gtk.Settings.get_default()
- sugar_theme = 'sugar-72'
- if 'SUGAR_SCALING' in os.environ:
- if os.environ['SUGAR_SCALING'] == '100':
- sugar_theme = 'sugar-100'
- settings.set_property('gtk-theme-name', sugar_theme)
- settings.set_property('gtk-icon-theme-name', 'sugar')
-
-
-class Test(Gtk.VBox):
- def __init__(self):
- GObject.GObject.__init__(self)
-
-
-class TestPalette(Test):
- def __init__(self):
- Test.__init__(self)
-
- toolbar = Gtk.Toolbar()
-
- self._invoker = ToolButton('go-previous')
- toolbar.insert(self._invoker, -1)
- self._invoker.show()
-
- self.pack_start(toolbar, False)
- toolbar.show()
-
- def set_palette(self, palette):
- self._invoker.set_palette(palette)
-
-
-class TestRunner(object):
- def run(self, test):
- set_theme()
- window = Gtk.Window()
- window.connect('destroy', lambda w: Gtk.main_quit())
- window.add(test)
- test.show()
-
- window.show()
-
-
-def main(test):
- runner = TestRunner()
- runner.run(test)
-
- Gtk.main()
diff --git a/tests/graphics/customdestroy.py b/tests/graphics/customdestroy.py
deleted file mode 100644
index 72156a8..0000000
--- a/tests/graphics/customdestroy.py
+++ /dev/null
@@ -1,44 +0,0 @@
-from gi.repository import Gtk
-
-"""
-Since GTK+3 Gtk.CellRenderer doesn't have a destroy signal anymore.
-We can do the cleanup in the python destructor method instead.
-
-"""
-
-
-class MyCellRenderer(Gtk.CellRenderer):
- def __init__(self):
- Gtk.CellRenderer.__init__(self)
-
- def __del__(self):
- print "cellrenderer destroy"
-
- def do_render(self, cairo_t, widget, background_area, cell_area, flags):
- pass
-
-
-def window_destroy_cb(*kwargs):
- print "window destroy"
- Gtk.main_quit()
-
-window = Gtk.Window(Gtk.WindowType.TOPLEVEL)
-window.connect("destroy", window_destroy_cb)
-window.show()
-
-
-def treeview_destroy_cb(*kwargs):
- print "treeview destroy"
-
-treeview = Gtk.TreeView()
-treeview.connect("destroy", treeview_destroy_cb)
-window.add(treeview)
-treeview.show()
-
-col = Gtk.TreeViewColumn()
-treeview.append_column(col)
-
-cel = MyCellRenderer()
-col.pack_start(cel, expand=True)
-
-Gtk.main()
diff --git a/tests/graphics/gtktreesensitive.py b/tests/graphics/gtktreesensitive.py
deleted file mode 100644
index 875612f..0000000
--- a/tests/graphics/gtktreesensitive.py
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/usr/bin/python
-from gi.repository import Gtk
-
-
-import common
-test = common.Test()
-test.show()
-
-
-class MyBox(Gtk.VBox):
-
- def __init__(self):
- Gtk.VBox.__init__(self)
-
- self.scrolled = Gtk.ScrolledWindow()
- self.scrolled.set_policy(Gtk.PolicyType.AUTOMATIC,
- Gtk.PolicyType.AUTOMATIC)
-
- self.store = Gtk.ListStore(str, str)
- for i in range(5):
- self.store.append([str(i), 'Item %s' % i])
-
- self.treeview = Gtk.TreeView(self.store)
- renderer_no_sens = Gtk.CellRendererText()
- # set 'sensitive' property
- renderer_no_sens.set_property('sensitive', False)
-
- renderer = Gtk.CellRendererText()
-
- column = Gtk.TreeViewColumn('\'sensitive\' False',
- renderer_no_sens, text=0)
- self.treeview.append_column(column)
-
- column = Gtk.TreeViewColumn('\'sensitive\' True',
- renderer, text=1)
- self.treeview.append_column(column)
-
- self.scrolled.add(self.treeview)
- self.add(self.scrolled)
-
- self.show_all()
-
-vbox = MyBox()
-test.pack_start(vbox, True, True, 0)
-vbox.show()
-
-if __name__ == '__main__':
- common.main(test)
diff --git a/tests/graphics/iconbadges.py b/tests/graphics/iconbadges.py
deleted file mode 100644
index f72dfe3..0000000
--- a/tests/graphics/iconbadges.py
+++ /dev/null
@@ -1,28 +0,0 @@
-from gi.repository import Gtk
-
-from sugar3.graphics.icon import EventIcon
-from sugar3.graphics.icon import Icon
-
-import common
-
-
-test = common.Test()
-test.show()
-
-vbox = Gtk.VBox()
-test.pack_start(vbox, True, True, 0)
-vbox.show()
-
-icon = Icon(icon_name="network-wireless-000")
-icon.props.badge_name = 'emblem-favorite'
-vbox.pack_start(icon, False, False, 0)
-icon.show()
-
-icon = EventIcon(icon_name="network-wireless-000")
-icon.props.badge_name = 'emblem-favorite'
-vbox.pack_start(icon, False, False, 0)
-icon.show()
-
-
-if __name__ == '__main__':
- common.main(test)
diff --git a/tests/graphics/iconcache.py b/tests/graphics/iconcache.py
deleted file mode 100644
index 5a027d9..0000000
--- a/tests/graphics/iconcache.py
+++ /dev/null
@@ -1,70 +0,0 @@
-# Copyright (C) 2007, Red Hat, Inc.
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the
-# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-
-"""
-Test the sugar3.graphics.icon.* cache.
-"""
-
-from gi.repository import Gtk
-
-from sugar3.graphics.icon import Icon
-from sugar3.graphics.xocolor import XoColor
-
-import common
-
-test = common.Test()
-
-data = [
- ['battery-000', '#FF8F00,#FF2B34'],
- ['battery-010', '#D1A3FF,#00A0FF'],
- ['battery-020', '#FF8F00,#FF2B34'],
- ['battery-030', '#00A0FF,#D1A3FF'],
- ['battery-040', '#AC32FF,#FF2B34'],
- ['battery-050', '#D1A3FF,#00A0FF'],
- ['battery-060', '#AC32FF,#FF2B34'],
- ['battery-070', '#00A0FF,#D1A3FF'],
- ['battery-080', '#FF8F00,#FF2B34'],
- ['battery-090', '#D1A3FF,#00A0FF'],
- ['battery-100', '#AC32FF,#FF2B34']]
-
-
-def _button_activated_cb(button):
- import random
-
- global data
- random.shuffle(data)
-
- for i in range(0, len(test.get_children()) - 1):
- test.get_children()[i].props.icon_name = data[i][0]
- test.get_children()[i].props.xo_color = XoColor(data[i][1])
-
-for d in data:
- icon = Icon(icon_name=d[0],
- icon_size=Gtk.IconSize.LARGE_TOOLBAR,
- xo_color=XoColor(d[1]))
- test.pack_start(icon, True, True, 0)
- icon.show()
-
-button = Gtk.Button('mec mac')
-test.pack_start(button, True, True, 0)
-button.connect('activate', _button_activated_cb)
-button.show()
-
-test.show()
-
-if __name__ == '__main__':
- common.main(test)
diff --git a/tests/graphics/iconwidget.py b/tests/graphics/iconwidget.py
deleted file mode 100644
index e4d7f26..0000000
--- a/tests/graphics/iconwidget.py
+++ /dev/null
@@ -1,87 +0,0 @@
-# Copyright (C) 2007, Red Hat, Inc.
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the
-# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-
-"""
-Test the sugar3.graphics.icon.Icon widget.
-"""
-
-from gi.repository import Gtk
-
-from sugar3.graphics.icon import Icon
-from sugar3.graphics.xocolor import XoColor
-
-import common
-
-test = common.Test()
-
-hbox = Gtk.HBox()
-test.pack_start(hbox, True, True, 0)
-sensitive_box = Gtk.VBox()
-insensitive_box = Gtk.VBox()
-
-hbox.pack_start(sensitive_box, True, True, 0)
-hbox.pack_start(insensitive_box, True, True, 0)
-hbox.show_all()
-
-
-def create_icon_widgets(box, sensitive=True):
- icon = Icon(icon_name='go-previous')
- icon.props.icon_size = Gtk.IconSize.LARGE_TOOLBAR
- box.pack_start(icon, True, True, 0)
- icon.set_sensitive(sensitive)
- icon.show()
-
- icon = Icon(icon_name='computer-xo',
- icon_size=Gtk.IconSize.LARGE_TOOLBAR,
- xo_color=XoColor())
- box.pack_start(icon, True, True, 0)
- icon.set_sensitive(sensitive)
- icon.show()
-
- icon = Icon(icon_name='battery-000',
- icon_size=Gtk.IconSize.LARGE_TOOLBAR,
- badge_name='emblem-busy')
- box.pack_start(icon, True, True, 0)
- icon.set_sensitive(sensitive)
- icon.show()
-
- icon = Icon(icon_name='gtk-new',
- icon_size=Gtk.IconSize.LARGE_TOOLBAR,
- badge_name='gtk-cancel')
- box.pack_start(icon, True, True, 0)
- icon.set_sensitive(sensitive)
- icon.show()
-
-
-create_icon_widgets(sensitive_box, True)
-create_icon_widgets(insensitive_box, False)
-
-test.show()
-
-# This can be used to test for leaks by setting the LRU cache size
-# in icon.py to 1.
-#def idle_cb():
-# import gc
-# gc.collect()
-# test.queue_draw()
-# return True
-#
-#from gi.repository import GObject
-#GObject.idle_add(idle_cb)
-
-if __name__ == '__main__':
- common.main(test)
diff --git a/tests/graphics/intro.py b/tests/graphics/intro.py
deleted file mode 100644
index 05c5b5a..0000000
--- a/tests/graphics/intro.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from gi.repository import Gtk
-from common import set_theme
-from jarabe.intro.window import IntroWindow
-
-set_theme()
-win = IntroWindow()
-win.show_all()
-Gtk.main()
diff --git a/tests/graphics/progress.py b/tests/graphics/progress.py
deleted file mode 100644
index bc176a8..0000000
--- a/tests/graphics/progress.py
+++ /dev/null
@@ -1,20 +0,0 @@
-from gi.repository import Gtk
-
-import common
-
-
-test = common.Test()
-test.show()
-
-box = Gtk.HBox()
-test.pack_start(box, True, False, 10)
-box.show()
-
-bar = Gtk.ProgressBar()
-bar.set_fraction(0.5)
-box.pack_start(bar, True, True, 10)
-bar.show()
-
-
-if __name__ == '__main__':
- common.main(test)
diff --git a/tests/graphics/tabs.py b/tests/graphics/tabs.py
deleted file mode 100644
index fbc4bac..0000000
--- a/tests/graphics/tabs.py
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/usr/bin/python
-from gi.repository import Gtk
-
-from sugar3.graphics.icon import Icon
-
-import common
-test = common.Test()
-test.show()
-
-box = Gtk.HBox()
-test.pack_start(box, True, True, 0)
-box.show()
-
-# notebook without button
-
-notebook = Gtk.Notebook()
-box.pack_start(notebook, True, True, 0)
-notebook.show()
-
-for i in range(3):
- hbox = Gtk.HBox()
- notebook.append_page(hbox, Gtk.Label('Page %d' % (i + 1)))
- hbox.show()
-
-# notebook with buttons
-
-notebook = Gtk.Notebook()
-box.pack_start(notebook, True, True, 0)
-notebook.show()
-
-add_icon = Icon(icon_name='add')
-button = Gtk.Button()
-button.props.focus_on_click = False
-button.add(add_icon)
-add_icon.show()
-
-notebook.set_action_widget(button, Gtk.PackType.END)
-button.show()
-
-for i in range(3):
- hbox = Gtk.HBox()
- notebook.append_page(hbox, Gtk.Label('Page %d' % (i + 1)))
- hbox.show()
-
-if __name__ == '__main__':
- common.main(test)
diff --git a/tests/graphics/ticket2855.py b/tests/graphics/ticket2855.py
deleted file mode 100644
index 0de36a3..0000000
--- a/tests/graphics/ticket2855.py
+++ /dev/null
@@ -1,59 +0,0 @@
-# Copyright (C) 2007, Red Hat, Inc.
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the
-# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-
-"""
-Test the style of toggle and radio buttons inside a palette. The buttons
-contains only an icon and should be rendered similarly to the toolbar
-controls. Ticket #2855.
-"""
-
-from gi.repository import Gtk
-
-from sugar3.graphics.palette import Palette
-from sugar3.graphics.icon import Icon
-
-import common
-
-test = common.TestPalette()
-
-palette = Palette('Test radio and toggle')
-test.set_palette(palette)
-
-box = Gtk.HBox()
-
-toggle = Gtk.ToggleButton()
-
-icon = Icon(icon_name='go-previous', icon_size=Gtk.IconSize.LARGE_TOOLBAR)
-toggle.set_image(icon)
-
-box.pack_start(toggle, False)
-toggle.show()
-
-radio = Gtk.RadioButton()
-
-icon = Icon(icon_name='go-next', icon_size=Gtk.IconSize.LARGE_TOOLBAR)
-radio.set_image(icon)
-
-radio.set_mode(False)
-box.pack_start(radio, False)
-radio.show()
-
-palette.set_content(box)
-box.show()
-
-if __name__ == '__main__':
- common.main(test)
diff --git a/tests/graphics/ticket2999.py b/tests/graphics/ticket2999.py
deleted file mode 100644
index 557ba53..0000000
--- a/tests/graphics/ticket2999.py
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright (C) 2007, One Laptop Per Child
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the
-# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-
-"""
-Spec in ticket #2999.
-"""
-
-from gi.repository import Gtk
-
-from sugar3.graphics.palette import Palette
-from sugar3.graphics.icon import Icon
-
-import common
-
-test = common.Test()
-test.set_border_width(60)
-
-text_view = Gtk.TextView()
-text_view.props.buffer.props.text = 'Blah blah blah, blah blah blah.'
-test.pack_start(text_view, True, True, 0)
-text_view.show()
-
-if __name__ == '__main__':
- common.main(test)
diff --git a/tests/graphics/ticket3000.py b/tests/graphics/ticket3000.py
deleted file mode 100644
index 295d796..0000000
--- a/tests/graphics/ticket3000.py
+++ /dev/null
@@ -1,48 +0,0 @@
-# Copyright (C) 2007, One Laptop Per Child
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the
-# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-
-"""
-Spec in ticket #3000.
-"""
-
-from gi.repository import Gtk
-
-from sugar3.graphics.toolbutton import ToolButton
-
-import common
-
-test = common.Test()
-
-toolbar = Gtk.Toolbar()
-test.pack_start(toolbar, False)
-toolbar.show()
-
-button = ToolButton('go-previous')
-toolbar.insert(button, -1)
-button.show()
-
-separator = Gtk.SeparatorToolItem()
-toolbar.add(separator)
-separator.show()
-
-button = ToolButton('go-next')
-toolbar.insert(button, -1)
-button.show()
-
-
-if __name__ == '__main__':
- common.main(test)
diff --git a/tests/graphics/toolbarpalettes.py b/tests/graphics/toolbarpalettes.py
deleted file mode 100644
index 93177c1..0000000
--- a/tests/graphics/toolbarpalettes.py
+++ /dev/null
@@ -1,65 +0,0 @@
-# Copyright (C) 2007, Red Hat, Inc.
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the
-# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-
-"""
-Test palette positioning for toolbar and tray.
-"""
-
-from gi.repository import Gtk
-
-from sugar3.graphics.tray import HTray, TrayButton
-from sugar3.graphics.toolbutton import ToolButton
-
-import common
-
-test = common.Test()
-
-vbox = Gtk.VBox()
-
-theme_icons = Gtk.IconTheme.get_default().list_icons()
-
-toolbar = Gtk.Toolbar()
-vbox.pack_start(toolbar, False)
-toolbar.show()
-
-for i in range(0, 5):
- button = ToolButton(icon_name=theme_icons[i])
- button.set_tooltip('Icon %d' % i)
- toolbar.insert(button, -1)
- button.show()
-
-content = Gtk.Label()
-vbox.pack_start(content, True, True, 0)
-content.show()
-
-tray = HTray()
-vbox.pack_start(tray, False)
-tray.show()
-
-for i in range(0, 30):
- button = TrayButton(icon_name=theme_icons[i])
- button.set_tooltip('Icon %d' % i)
- tray.add_item(button)
- button.show()
-
-test.pack_start(vbox, True, True, 0)
-vbox.show()
-
-test.show()
-
-if __name__ == '__main__':
- common.main(test)
diff --git a/tests/graphics/toolbuttons.py b/tests/graphics/toolbuttons.py
deleted file mode 100644
index 3344cba..0000000
--- a/tests/graphics/toolbuttons.py
+++ /dev/null
@@ -1,45 +0,0 @@
-from gi.repository import Gtk
-
-from sugar3.graphics.toolbarbox import ToolbarBox
-from sugar3.graphics.colorbutton import ColorToolButton
-from sugar3.graphics.radiotoolbutton import RadioToolButton
-from sugar3.graphics.toggletoolbutton import ToggleToolButton
-
-import common
-
-
-test = common.Test()
-test.show()
-
-vbox = Gtk.VBox()
-test.pack_start(vbox, True, True, 0)
-vbox.show()
-
-toolbar_box = ToolbarBox()
-vbox.pack_start(toolbar_box, False, False, 0)
-toolbar_box.show()
-
-radial_button = RadioToolButton(icon_name='view-radial')
-toolbar_box.toolbar.insert(radial_button, -1)
-radial_button.show()
-
-list_button = RadioToolButton(icon_name='view-list')
-list_button.props.group = radial_button
-toolbar_box.toolbar.insert(list_button, -1)
-list_button.show()
-
-separator = Gtk.SeparatorToolItem()
-toolbar_box.toolbar.insert(separator, -1)
-separator.show()
-
-color_button = ColorToolButton()
-toolbar_box.toolbar.insert(color_button, -1)
-color_button.show()
-
-favorite_button = ToggleToolButton('emblem-favorite')
-toolbar_box.toolbar.insert(favorite_button, -1)
-favorite_button.show()
-
-
-if __name__ == '__main__':
- common.main(test)
diff --git a/tests/graphics/tray.py b/tests/graphics/tray.py
deleted file mode 100644
index 3da60e3..0000000
--- a/tests/graphics/tray.py
+++ /dev/null
@@ -1,82 +0,0 @@
-# Copyright (C) 2007, Red Hat, Inc.
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the
-# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-
-"""
-Test the sugar3.graphics.icon.Icon widget.
-"""
-
-from gi.repository import Gtk
-
-from sugar3.graphics.tray import HTray, VTray
-from sugar3.graphics.tray import TrayButton, TrayIcon
-
-import common
-
-test = common.Test()
-
-vbox = Gtk.VBox()
-
-tray = HTray()
-vbox.pack_start(tray, False, False, 0)
-tray.show()
-
-theme_icons = Gtk.IconTheme.get_default().list_icons(context=None)
-
-for i in range(0, 100):
- button = TrayButton(icon_name=theme_icons[i])
- tray.add_item(button)
- button.show()
-
-tray = HTray()
-vbox.pack_start(tray, False, False, 0)
-tray.show()
-
-for i in range(0, 10):
- icon = TrayIcon(icon_name=theme_icons[i])
- tray.add_item(icon)
- icon.show()
-
-hbox = Gtk.HBox()
-
-tray = VTray()
-hbox.pack_start(tray, False, False, 0)
-tray.show()
-
-for i in range(0, 100):
- button = TrayButton(icon_name=theme_icons[i])
- tray.add_item(button)
- button.show()
-
-tray = VTray()
-hbox.pack_start(tray, False, False, 0)
-tray.show()
-
-for i in range(0, 4):
- button = TrayButton(icon_name=theme_icons[i])
- tray.add_item(button)
- button.show()
-
-vbox.pack_start(hbox, True, True, 0)
-hbox.show()
-
-test.pack_start(vbox, True, True, 0)
-vbox.show()
-
-test.show()
-
-if __name__ == '__main__':
- common.main(test)
diff --git a/tests/lib/runall.py b/tests/lib/runall.py
deleted file mode 100644
index ae1bb3a..0000000
--- a/tests/lib/runall.py
+++ /dev/null
@@ -1,28 +0,0 @@
-# Copyright (C) 2007, Red Hat, Inc.
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the
-# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-
-import unittest
-
-import test_mime
-
-runner = unittest.TextTestRunner()
-loader = unittest.TestLoader()
-
-suite = unittest.TestSuite()
-suite.addTest(loader.loadTestsFromModule(test_mime))
-
-runner.run(suite)
diff --git a/tests/lib/test_mime.py b/tests/lib/test_mime.py
deleted file mode 100644
index b59b58e..0000000
--- a/tests/lib/test_mime.py
+++ /dev/null
@@ -1,84 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright (C) 2006, Red Hat, Inc.
-# Copyright (C) 2007, One Laptop Per Child
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-import sys
-import unittest
-
-from sugar import mime
-
-
-class TestMime(unittest.TestCase):
- def test_from_file_name(self):
- self.assertEqual(mime.get_from_file_name('test.pdf'),
- 'application/pdf')
-
- def test_choose_most_significant(self):
- # Mozilla's text in dnd
- mime_type = mime.choose_most_significant(
- ['text/plain', 'text/_moz_htmlcontext', 'text/unicode',
- 'text/html', 'text/_moz_htmlinfo'])
- self.assertEqual(mime_type, 'text/html')
-
- # Mozilla's text in c&v
- mime_type = mime.choose_most_significant(
- ['text/_moz_htmlcontext', 'STRING', 'text/html',
- 'text/_moz_htmlinfo', 'text/x-moz-url-priv', 'UTF8_STRING',
- 'COMPOUND_TEXT'])
- self.assertEqual(mime_type, 'text/html')
-
- # Mozilla gif in dnd
- mime_type = mime.choose_most_significant(
- ['application/x-moz-file-promise-url',
- 'application/x-moz-file-promise-dest-filename',
- 'text/_moz_htmlinfo', 'text/x-moz-url-desc',
- 'text/_moz_htmlcontext', 'text/x-moz-url-data',
- 'text/uri-list'])
- self.assertEqual(mime_type, 'text/uri-list')
-
- # Mozilla url in dnd
- mime_type = mime.choose_most_significant(
- ['text/_moz_htmlcontext', 'text/html', 'text/_moz_htmlinfo',
- '_NETSCAPE_URL', 'text/x-moz-url', 'text/x-moz-url-desc',
- 'text/x-moz-url-data', 'text/plain', 'text/unicode'])
- self.assertEqual(mime_type, 'text/x-moz-url')
-
- # Abiword text in dnd
- mime_type = mime.choose_most_significant(
- ['text/rtf', 'text/uri-list'])
- self.assertEqual(mime_type, 'text/uri-list')
-
- # Abiword text in c&v
- mime_type = mime.choose_most_significant(
- ['UTF8_STRING', 'STRING', 'text/html', 'TEXT', 'text/rtf',
- 'COMPOUND_TEXT', 'application/rtf', 'text/plain',
- 'application/xhtml+xml'])
- self.assertEqual(mime_type, 'application/rtf')
-
- # Abiword text in c&v
- mime_type = mime.choose_most_significant(
- ['GTK_TEXT_BUFFER_CONTENTS',
- 'application/x-gtk-text-buffer-rich-text',
- 'UTF8_STRING', 'COMPOUND_TEXT', 'TEXT', 'STRING',
- 'text/plain;charset=utf-8', 'text/plain;charset=UTF-8',
- 'text/plain'])
- self.assertEqual(mime_type, 'text/plain')
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/tests/test_mime.py b/tests/test_mime.py
new file mode 100644
index 0000000..b59b58e
--- /dev/null
+++ b/tests/test_mime.py
@@ -0,0 +1,84 @@
+#!/usr/bin/env python
+
+# Copyright (C) 2006, Red Hat, Inc.
+# Copyright (C) 2007, One Laptop Per Child
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+import sys
+import unittest
+
+from sugar import mime
+
+
+class TestMime(unittest.TestCase):
+ def test_from_file_name(self):
+ self.assertEqual(mime.get_from_file_name('test.pdf'),
+ 'application/pdf')
+
+ def test_choose_most_significant(self):
+ # Mozilla's text in dnd
+ mime_type = mime.choose_most_significant(
+ ['text/plain', 'text/_moz_htmlcontext', 'text/unicode',
+ 'text/html', 'text/_moz_htmlinfo'])
+ self.assertEqual(mime_type, 'text/html')
+
+ # Mozilla's text in c&v
+ mime_type = mime.choose_most_significant(
+ ['text/_moz_htmlcontext', 'STRING', 'text/html',
+ 'text/_moz_htmlinfo', 'text/x-moz-url-priv', 'UTF8_STRING',
+ 'COMPOUND_TEXT'])
+ self.assertEqual(mime_type, 'text/html')
+
+ # Mozilla gif in dnd
+ mime_type = mime.choose_most_significant(
+ ['application/x-moz-file-promise-url',
+ 'application/x-moz-file-promise-dest-filename',
+ 'text/_moz_htmlinfo', 'text/x-moz-url-desc',
+ 'text/_moz_htmlcontext', 'text/x-moz-url-data',
+ 'text/uri-list'])
+ self.assertEqual(mime_type, 'text/uri-list')
+
+ # Mozilla url in dnd
+ mime_type = mime.choose_most_significant(
+ ['text/_moz_htmlcontext', 'text/html', 'text/_moz_htmlinfo',
+ '_NETSCAPE_URL', 'text/x-moz-url', 'text/x-moz-url-desc',
+ 'text/x-moz-url-data', 'text/plain', 'text/unicode'])
+ self.assertEqual(mime_type, 'text/x-moz-url')
+
+ # Abiword text in dnd
+ mime_type = mime.choose_most_significant(
+ ['text/rtf', 'text/uri-list'])
+ self.assertEqual(mime_type, 'text/uri-list')
+
+ # Abiword text in c&v
+ mime_type = mime.choose_most_significant(
+ ['UTF8_STRING', 'STRING', 'text/html', 'TEXT', 'text/rtf',
+ 'COMPOUND_TEXT', 'application/rtf', 'text/plain',
+ 'application/xhtml+xml'])
+ self.assertEqual(mime_type, 'application/rtf')
+
+ # Abiword text in c&v
+ mime_type = mime.choose_most_significant(
+ ['GTK_TEXT_BUFFER_CONTENTS',
+ 'application/x-gtk-text-buffer-rich-text',
+ 'UTF8_STRING', 'COMPOUND_TEXT', 'TEXT', 'STRING',
+ 'text/plain;charset=utf-8', 'text/plain;charset=UTF-8',
+ 'text/plain'])
+ self.assertEqual(mime_type, 'text/plain')
+
+
+if __name__ == '__main__':
+ unittest.main()
--
1.7.10.4
More information about the Sugar-devel
mailing list