PageRenderTime 47ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/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
  1. #{{{ Marathon Fixture
  2. from default import *
  3. from java.lang import System
  4. from util import *
  5. import os
  6. import shutil
  7. #}}} Marathon Fixture
  8. def enterString(str):
  9. for char in list(str):
  10. keystroke('JEditTextArea', char)
  11. def test():
  12. java_recorded_version = '1.6.0_11'
  13. projDir = makePath(System.getProperty('marathon.test.dir') , '..')
  14. inputDir = makePath(projDir, 'Input')
  15. outputDir = makePath(projDir, 'Output')
  16. inputFile = makePath(inputDir, 'TestPlan.txt')
  17. saveFile = makePath(outputDir, 'savedFile.txt')
  18. try:
  19. os.remove(saveFile)
  20. shutil.copy(makePath(inputDir, 'properties'), makePath(settingsDir, 'properties'))
  21. except os.error:
  22. pass
  23. if window('/jEdit - .*'):
  24. select_menu('File>>Open...')
  25. if window('File Browser'):
  26. select('File name', inputFile)
  27. click('Open')
  28. close()
  29. close()
  30. if window(r'/jEdit - .*TestPlan.txt'):
  31. # Verify that the text area shows the opened file
  32. textArea = get_component('JEditTextArea')
  33. s = textArea.getText(0, textArea.getLineEndOffset(0))
  34. assert s.startswith('jEdit Test Plan'), inputFile + ' not opened correctly.'
  35. select_menu('File>>New')
  36. close()
  37. if window('jEdit - Untitled-1'):
  38. enterString("This is a dummy file to test Save As...")
  39. close()
  40. if window('jEdit - Untitled-1 (modified)'):
  41. select_menu('File>>Save')
  42. if window('File Browser'):
  43. select('File name', saveFile)
  44. click('Save')
  45. close()
  46. close()
  47. if window(r'/jEdit - .*savedFile.txt'):
  48. a = 1
  49. close()