1 #!/usr/bin/env python2.3
4 from os
.path
import dirname
, abspath
, join
5 rox_lib
= dirname(dirname(dirname(abspath(sys
.argv
[0]))))
6 sys
.path
.insert(0, join(rox_lib
, 'python'))
8 os
.environ
['CHOICESPATH'] = '/tmp/choices:/tmp/choices2'
9 os
.environ
['XDG_CONFIG_HOME'] = '/tmp/config'
12 from rox
.Menu
import Menu
, set_save_name
, SubMenu
13 from rox
.Menu
import Separator
, Action
, ToggleItem
14 from rox
import basedir
, choices
, g
17 class MyToggleItem(ToggleItem
):
20 def update(self
, menu
, widget
):
22 self
.my_widget
= widget
23 ToggleItem
.update(self
, menu
, widget
)
25 class TestMenu(unittest
.TestCase
):
30 self
.my_t1
= MyToggleItem('Toggle 1', 't1')
31 self
.my_t2
= MyToggleItem('Toggle 2', 't2')
33 self
.menu
= Menu('main', [
35 Action('Save', 'save', '<Ctrl>S', g
.STOCK_SAVE
),
36 Action('Parent', 'up', '', g
.STOCK_GO_UP
),
37 Action('Close', 'close','', g
.STOCK_CLOSE
),
39 Action('New', 'new', '', g
.STOCK_NEW
)]),
40 Action('Help', 'help', 'F1', g
.STOCK_HELP
),
46 self
.menu
.menu
.destroy()
48 def testNothing(self
):
51 def testToggles(self
):
52 self
.menu
.popup(self
, None)
53 assert self
.my_t1
.my_widget
!= None
54 assert self
.my_t2
.my_widget
!= None
56 assert self
.my_t2
.my_widget
!= self
.my_t1
.my_widget
57 assert self
.my_t1
.my_menu
== self
.my_t2
.my_menu
== self
.menu
59 suite
= unittest
.makeSuite(TestMenu
)
60 if __name__
== '__main__':