Some cleanup prior to release

This commit is contained in:
markm 2006-01-05 14:57:40 +00:00
parent 5959cf3b30
commit 3fac9506ad
2 changed files with 149 additions and 162 deletions

@ -8,9 +8,9 @@
# TopLevel = true/false
import time
import os.path
import re
import ctypes
import re
import win32structures
import win32functions
@ -21,8 +21,6 @@ import controlproperties
import controlactions
import XMLHelpers
# should be possible to get the modules used by a process
class AppStartError(Exception):
pass
@ -40,8 +38,6 @@ class WindowNotFoundError(Exception):
pass
#=========================================================================
def make_valid_filename(filename):
for char in ('\/:*?"<>|'):
@ -471,5 +467,6 @@ def enum_windows():
return windows
if __name__ == '__main__':
import test_application
test_application.Main()

@ -3,17 +3,7 @@ import os
import application
def TestNotepad():
if 1:
# ensure that the XML path exists
example_path = r"examples\notepad_test"
try:
os.makedirs(example_path)
except OSError:
pass
def TestExceptions():
# test that trying to _connect to a non existent app fails
try:
app = application.Application()
@ -40,11 +30,16 @@ def TestNotepad():
pass
def TestNotepad():
app = application.Application()
try:
app._connect(path = ur"c:\windows\system32\notepad.exe")
except application.ProcessNotFoundError:
# # for distribution we don't want to connect to anybodies application
# # because we may mess up something they are working on!
# try:
# app._connect(path = ur"c:\windows\system32\notepad.exe")
# except application.ProcessNotFoundError:
# app._start(ur"c:\windows\system32\notepad.exe")
app._start(ur"c:\windows\system32\notepad.exe")
app.Notepad.MenuSelect("File->PageSetup")
@ -63,7 +58,6 @@ def TestNotepad():
app.ConnectToPrinter.ExpandByDefault.UnCheck()
# try doing the same by using click
app.ConnectToPrinter.ExpandByDefault.Click()
@ -72,8 +66,6 @@ def TestNotepad():
# close the dialog
app.ConnectToPrinter.Cancel.Click()
app.PageSetupDlg2.Properties.Click()
docProps = app._window(title_re = ".*Document Properties")
@ -81,47 +73,32 @@ def TestNotepad():
TestingTabSelect = 1
if TestingTabSelect:
docProps.TabCtrl.Select(0)
docProps.TabCtrl.Select(1)
docProps.TabCtrl.Select(2)
docProps.TabCtrl.Select("PaperQuality")
docProps.TabCtrl.Select("JobRetention")
docProps.TabCtrl.Select("Layout")
TestingRadioButton = 1
if TestingRadioButton:
docProps.RotatedLandscape.Click()
docProps.BackToFront.Click()
docProps.FlipOnShortEdge.Click()
docProps.Portrait.Click()
docProps._None.Click()
docProps.FrontToBack.Click()
#print docProps._ctrl
advbutton = docProps.Advanced
advbutton.Click()
# close the 4 windows
app._window(title_re = ".* Advanced Options").Ok.Click()
docProps.Cancel.Click()
app.PageSetupDlg2.OK.Click()
app.PageSetupDlg.Ok.Click()
# type some text
@ -133,26 +110,29 @@ def TestNotepad():
def TestPaint():
app = application.Application()
try:
app._connect(path = ur"c:\windows\system32\mspaint.exe")
except application.ProcessNotFoundError:
app._start(ur"c:\windows\system32\mspaint.exe")
# # for distribution we don't want to connect to anybodies application
# # because we may mess up something they are working on!
# try:
# app._connect(path = ur"c:\windows\system32\mspaint.exe")
# except application.ProcessNotFoundError:
# app._start(ur"c:\windows\system32\mspaint.exe")
app._start(ur"c:\windows\system32\mspaint.exe")
pwin = app._window(title_re = ".* - Paint")
# get the reference to the Canvas window
canvas = pwin.Afx100000008
# make sure the pencil tool is selected
pwin.Tools2.Click(coords = (91, 16))
size = 30
num_slants = 8
size = 15
num_slants = 20
# draw the axes
canvas.PressMouse(coords = (size, size * num_slants))
@ -161,6 +141,8 @@ def TestPaint():
canvas.ReleaseMouse()
# now draw the lines
print "*** if you move your mouse over Paint as it is drawing ***"
print "*** these lines then it will mess up the drawing! ***\n"
for i in range(1, num_slants):
canvas.PressMouse(coords = (size * num_slants, i * size)) # start
@ -168,11 +150,19 @@ def TestPaint():
canvas.ReleaseMouse()
print "Saved image as: Application_Paint_test.png"
canvas._.CaptureAsImage().save(r"Application_Paint_test.png")
canvas._.CaptureAsImage().save(r"c:\test.png")
# close Paint
pwin.MenuSelect("File->Exit")
# Click the no button on teh message box asking if we want to save
app.Paint.No.Click()
if __name__ == "__main__":
def Main():
TestExceptions()
TestNotepad()
TestPaint()
if __name__ == "__main__":
Main()