/tests/Marathon/TestCases/FileOperations.py
Python | 59 lines | 46 code | 10 blank | 3 comment | 10 complexity | f9244ad0789b342e93e74eaf192ceec4 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
- #{{{ Marathon Fixture
- from default import *
- from java.lang import System
- from util import *
- import os
- import shutil
- #}}} Marathon Fixture
-
- def enterString(str):
- for char in list(str):
- keystroke('JEditTextArea', char)
-
- def test():
- java_recorded_version = '1.6.0_11'
-
- projDir = makePath(System.getProperty('marathon.test.dir')
, '..')
- inputDir = makePath(projDir, 'Input')
- outputDir = makePath(projDir, 'Output')
- inputFile = makePath(inputDir, 'TestPlan.txt')
- saveFile = makePath(outputDir, 'savedFile.txt')
- try:
- os.remove(saveFile)
- shutil.copy(makePath(inputDir, 'properties'), makePath(settingsDir, 'properties'))
- except os.error:
- pass
-
- if window('/jEdit - .*'):
- select_menu('File>>Open...')
-
- if window('File Browser'):
- select('File name', inputFile)
- click('Open')
- close()
- close()
-
- if window(r'/jEdit - .*TestPlan.txt'):
- # Verify that the text area shows the opened file
- textArea = get_component('JEditTextArea')
- s = textArea.getText(0, textArea.getLineEndOffset(0))
- assert s.startswith('jEdit Test Plan'), inputFile + ' not opened correctly.'
- select_menu('File>>New')
- close()
-
- if window('jEdit - Untitled-1'):
- enterString("This is a dummy file to test Save As...")
- close()
-
- if window('jEdit - Untitled-1 (modified)'):
- select_menu('File>>Save')
-
- if window('File Browser'):
- select('File name', saveFile)
- click('Save')
- close()
- close()
-
- if window(r'/jEdit - .*savedFile.txt'):
- a = 1
- close()