Some cleanup prior to release
This commit is contained in:
parent
5959cf3b30
commit
3fac9506ad
@ -8,9 +8,9 @@
|
|||||||
# TopLevel = true/false
|
# TopLevel = true/false
|
||||||
import time
|
import time
|
||||||
import os.path
|
import os.path
|
||||||
|
import re
|
||||||
|
|
||||||
import ctypes
|
import ctypes
|
||||||
import re
|
|
||||||
|
|
||||||
import win32structures
|
import win32structures
|
||||||
import win32functions
|
import win32functions
|
||||||
@ -21,8 +21,6 @@ import controlproperties
|
|||||||
import controlactions
|
import controlactions
|
||||||
import XMLHelpers
|
import XMLHelpers
|
||||||
|
|
||||||
# should be possible to get the modules used by a process
|
|
||||||
|
|
||||||
|
|
||||||
class AppStartError(Exception):
|
class AppStartError(Exception):
|
||||||
pass
|
pass
|
||||||
@ -40,8 +38,6 @@ class WindowNotFoundError(Exception):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#=========================================================================
|
#=========================================================================
|
||||||
def make_valid_filename(filename):
|
def make_valid_filename(filename):
|
||||||
for char in ('\/:*?"<>|'):
|
for char in ('\/:*?"<>|'):
|
||||||
@ -471,5 +467,6 @@ def enum_windows():
|
|||||||
return windows
|
return windows
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
import test_application
|
||||||
|
test_application.Main()
|
@ -3,17 +3,7 @@ import os
|
|||||||
import application
|
import application
|
||||||
|
|
||||||
|
|
||||||
def TestNotepad():
|
def TestExceptions():
|
||||||
|
|
||||||
if 1:
|
|
||||||
|
|
||||||
# ensure that the XML path exists
|
|
||||||
example_path = r"examples\notepad_test"
|
|
||||||
try:
|
|
||||||
os.makedirs(example_path)
|
|
||||||
except OSError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# test that trying to _connect to a non existent app fails
|
# test that trying to _connect to a non existent app fails
|
||||||
try:
|
try:
|
||||||
app = application.Application()
|
app = application.Application()
|
||||||
@ -40,11 +30,16 @@ def TestNotepad():
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def TestNotepad():
|
||||||
|
|
||||||
app = application.Application()
|
app = application.Application()
|
||||||
|
|
||||||
try:
|
# # for distribution we don't want to connect to anybodies application
|
||||||
app._connect(path = ur"c:\windows\system32\notepad.exe")
|
# # because we may mess up something they are working on!
|
||||||
except application.ProcessNotFoundError:
|
# 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._start(ur"c:\windows\system32\notepad.exe")
|
||||||
|
|
||||||
app.Notepad.MenuSelect("File->PageSetup")
|
app.Notepad.MenuSelect("File->PageSetup")
|
||||||
@ -63,7 +58,6 @@ def TestNotepad():
|
|||||||
|
|
||||||
app.ConnectToPrinter.ExpandByDefault.UnCheck()
|
app.ConnectToPrinter.ExpandByDefault.UnCheck()
|
||||||
|
|
||||||
|
|
||||||
# try doing the same by using click
|
# try doing the same by using click
|
||||||
app.ConnectToPrinter.ExpandByDefault.Click()
|
app.ConnectToPrinter.ExpandByDefault.Click()
|
||||||
|
|
||||||
@ -72,8 +66,6 @@ def TestNotepad():
|
|||||||
# close the dialog
|
# close the dialog
|
||||||
app.ConnectToPrinter.Cancel.Click()
|
app.ConnectToPrinter.Cancel.Click()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
app.PageSetupDlg2.Properties.Click()
|
app.PageSetupDlg2.Properties.Click()
|
||||||
|
|
||||||
docProps = app._window(title_re = ".*Document Properties")
|
docProps = app._window(title_re = ".*Document Properties")
|
||||||
@ -81,47 +73,32 @@ def TestNotepad():
|
|||||||
TestingTabSelect = 1
|
TestingTabSelect = 1
|
||||||
if TestingTabSelect:
|
if TestingTabSelect:
|
||||||
docProps.TabCtrl.Select(0)
|
docProps.TabCtrl.Select(0)
|
||||||
|
|
||||||
docProps.TabCtrl.Select(1)
|
docProps.TabCtrl.Select(1)
|
||||||
|
|
||||||
docProps.TabCtrl.Select(2)
|
docProps.TabCtrl.Select(2)
|
||||||
|
|
||||||
|
|
||||||
docProps.TabCtrl.Select("PaperQuality")
|
docProps.TabCtrl.Select("PaperQuality")
|
||||||
|
|
||||||
docProps.TabCtrl.Select("JobRetention")
|
docProps.TabCtrl.Select("JobRetention")
|
||||||
|
|
||||||
docProps.TabCtrl.Select("Layout")
|
docProps.TabCtrl.Select("Layout")
|
||||||
|
|
||||||
|
|
||||||
TestingRadioButton = 1
|
TestingRadioButton = 1
|
||||||
if TestingRadioButton:
|
if TestingRadioButton:
|
||||||
docProps.RotatedLandscape.Click()
|
docProps.RotatedLandscape.Click()
|
||||||
|
|
||||||
docProps.BackToFront.Click()
|
docProps.BackToFront.Click()
|
||||||
|
|
||||||
docProps.FlipOnShortEdge.Click()
|
docProps.FlipOnShortEdge.Click()
|
||||||
|
|
||||||
|
|
||||||
docProps.Portrait.Click()
|
docProps.Portrait.Click()
|
||||||
|
|
||||||
docProps._None.Click()
|
docProps._None.Click()
|
||||||
|
|
||||||
docProps.FrontToBack.Click()
|
docProps.FrontToBack.Click()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#print docProps._ctrl
|
#print docProps._ctrl
|
||||||
advbutton = docProps.Advanced
|
advbutton = docProps.Advanced
|
||||||
advbutton.Click()
|
advbutton.Click()
|
||||||
|
|
||||||
# close the 4 windows
|
# close the 4 windows
|
||||||
app._window(title_re = ".* Advanced Options").Ok.Click()
|
app._window(title_re = ".* Advanced Options").Ok.Click()
|
||||||
|
|
||||||
docProps.Cancel.Click()
|
docProps.Cancel.Click()
|
||||||
|
|
||||||
app.PageSetupDlg2.OK.Click()
|
app.PageSetupDlg2.OK.Click()
|
||||||
|
|
||||||
app.PageSetupDlg.Ok.Click()
|
app.PageSetupDlg.Ok.Click()
|
||||||
|
|
||||||
# type some text
|
# type some text
|
||||||
@ -133,26 +110,29 @@ def TestNotepad():
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def TestPaint():
|
def TestPaint():
|
||||||
|
|
||||||
app = application.Application()
|
app = application.Application()
|
||||||
|
|
||||||
try:
|
# # for distribution we don't want to connect to anybodies application
|
||||||
app._connect(path = ur"c:\windows\system32\mspaint.exe")
|
# # because we may mess up something they are working on!
|
||||||
except application.ProcessNotFoundError:
|
# try:
|
||||||
app._start(ur"c:\windows\system32\mspaint.exe")
|
# 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")
|
pwin = app._window(title_re = ".* - Paint")
|
||||||
|
|
||||||
|
# get the reference to the Canvas window
|
||||||
canvas = pwin.Afx100000008
|
canvas = pwin.Afx100000008
|
||||||
|
|
||||||
# make sure the pencil tool is selected
|
# make sure the pencil tool is selected
|
||||||
pwin.Tools2.Click(coords = (91, 16))
|
pwin.Tools2.Click(coords = (91, 16))
|
||||||
|
|
||||||
size = 30
|
size = 15
|
||||||
num_slants = 8
|
num_slants = 20
|
||||||
|
|
||||||
# draw the axes
|
# draw the axes
|
||||||
canvas.PressMouse(coords = (size, size * num_slants))
|
canvas.PressMouse(coords = (size, size * num_slants))
|
||||||
@ -161,6 +141,8 @@ def TestPaint():
|
|||||||
canvas.ReleaseMouse()
|
canvas.ReleaseMouse()
|
||||||
|
|
||||||
# now draw the lines
|
# 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):
|
for i in range(1, num_slants):
|
||||||
canvas.PressMouse(coords = (size * num_slants, i * size)) # start
|
canvas.PressMouse(coords = (size * num_slants, i * size)) # start
|
||||||
|
|
||||||
@ -168,11 +150,19 @@ def TestPaint():
|
|||||||
|
|
||||||
canvas.ReleaseMouse()
|
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()
|
||||||
|
|
||||||
|
def Main():
|
||||||
if __name__ == "__main__":
|
TestExceptions()
|
||||||
TestNotepad()
|
TestNotepad()
|
||||||
TestPaint()
|
TestPaint()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
Main()
|
Loading…
Reference in New Issue
Block a user