PageRenderTime 67ms CodeModel.GetById 58ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/Marathon/TestCases/FileOperations.py

#
Python | 59 lines | 46 code | 10 blank | 3 comment | 9 complexity | f9244ad0789b342e93e74eaf192ceec4 MD5 | raw file
 1#{{{ Marathon Fixture

 2from default import *
 3from java.lang import System
 4from util import *
 5import os
 6import shutil
 7#}}} Marathon Fixture

 8
 9def enterString(str):
10	for char in list(str):
11		keystroke('JEditTextArea', char)
12
13def test():
14	java_recorded_version = '1.6.0_11'
15
16	projDir = makePath(System.getProperty('marathon.test.dir')
, '..')
17	inputDir = makePath(projDir, 'Input')
18	outputDir = makePath(projDir, 'Output')
19	inputFile = makePath(inputDir, 'TestPlan.txt')
20	saveFile = makePath(outputDir, 'savedFile.txt')
21	try:
22		os.remove(saveFile)
23		shutil.copy(makePath(inputDir, 'properties'), makePath(settingsDir, 'properties'))
24	except os.error:
25		pass
26
27	if window('/jEdit - .*'):
28		select_menu('File>>Open...')
29
30		if window('File Browser'):
31			select('File name', inputFile)
32			click('Open')
33		close()
34	close()
35
36	if window(r'/jEdit - .*TestPlan.txt'):
37		# Verify that the text area shows the opened file

38		textArea = get_component('JEditTextArea')
39		s = textArea.getText(0, textArea.getLineEndOffset(0))
40		assert s.startswith('jEdit Test Plan'), inputFile + ' not opened correctly.'
41		select_menu('File>>New')
42	close()
43
44	if window('jEdit - Untitled-1'):
45		enterString("This is a dummy file to test Save As...")
46	close()
47
48	if window('jEdit - Untitled-1 (modified)'):
49		select_menu('File>>Save')
50
51		if window('File Browser'):
52			select('File name', saveFile)
53			click('Save')
54		close()
55	close()
56
57	if window(r'/jEdit - .*savedFile.txt'):
58		a = 1
59	close()