~newmanonline/storytext/pyusecase-wx-test

« back to all changes in this revision

Viewing changes to wxpython/widgets/dialog/test_dialog.py

  • Committer: xuan
  • Date: 2010-09-18 22:53:45 UTC
  • Revision ID: xuan@lisa-20100918225345-oinjkzh5sn6vcnon
added a test case for dialog. the results are not consistent in normal speed and slow motion yet.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
import unittest
 
3
import wx
 
4
 
 
5
class MyDialog(wx.Dialog):
 
6
    def __init__(self, parent):
 
7
        wx.Dialog.__init__(self, parent, -1, 'Test')
 
8
        wx.Button(self, wx.ID_OK)
 
9
 
 
10
class TestMyDialog(unittest.TestCase):
 
11
 
 
12
    def setUp(self):
 
13
        self.app = wx.App()
 
14
        self.frame = wx.Frame(None)
 
15
        self.frame.Show()
 
16
 
 
17
    def tearDown(self):
 
18
        wx.CallAfter(self.app.Exit)
 
19
        self.app.MainLoop()
 
20
 
 
21
    def testDialog(self):
 
22
        def clickOK():
 
23
            clickEvent = wx.CommandEvent(wx.wxEVT_COMMAND_BUTTON_CLICKED, wx.ID_OK)
 
24
            self.dlg.ProcessEvent(clickEvent)
 
25
        wx.CallAfter(clickOK)
 
26
        self.ShowDialog()
 
27
 
 
28
    def ShowDialog(self):
 
29
        self.dlg = MyDialog(self.frame)
 
30
        self.dlg.ShowModal()
 
31
        self.dlg.Destroy()
 
32
 
 
33
def main():
 
34
    app = wx.App()
 
35
    app.MainLoop()
 
36
    frame = wx.Frame(None)
 
37
    frame.Show()
 
38
    dlg = MyDialog(frame)
 
39
    dlg.ShowModal()
 
40
    dlg.Destroy()
 
41
 
 
42
if __name__ == '__main__':
 
43
    unittest.main()