PageRenderTime 25ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/Marathon/TestCases/EditOperations.py

#
Python | 64 lines | 59 code | 3 blank | 2 comment | 1 complexity | f3eed51a3917e93d5b480ef662771b86 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 util import *
  4. from java.lang import *
  5. from javax.swing import SwingUtilities
  6. from java.awt.datatransfer import *
  7. from org.gjt.sp.jedit.textarea import Selection
  8. #}}} Marathon Fixture
  9. def enterKeystroke(key, count):
  10. for i in range(1, count + 1):
  11. keystroke('JEditTextArea', key)
  12. def test():
  13. java_recorded_version = '1.6.0_11'
  14. clipboard = java.awt.Toolkit.getDefaultToolkit().getSystemClipboard()
  15. class ClipboardAccess(java.lang.Runnable):
  16. def get(self):
  17. self.setString = ''
  18. SwingUtilities.invokeAndWait(self)
  19. return self.text
  20. def setText(self, st):
  21. self.setString = st
  22. SwingUtilities.invokeAndWait(self)
  23. def run(self):
  24. if (self.setString != ''):
  25. clipboard.setContents(StringSelection(self.setString), None)
  26. else:
  27. self.text = clipboard.getContents(None).getTransferData(DataFlavor.stringFlavor)
  28. if window('jEdit - TestPlan.txt'):
  29. selection = Selection.Range(284, 327)
  30. get_component('JEditTextArea').setSelection(selection)
  31. select_menu('Edit>>Cut')
  32. clipObj = ClipboardAccess()
  33. s = clipObj.get()
  34. assert s.startswith('test plan of the open source software jEdit'), 'Cut failure'
  35. close()
  36. if window('jEdit - TestPlan.txt (modified)'):
  37. select_menu('Edit>>Undo')
  38. close()
  39. if window('jEdit - TestPlan.txt'):
  40. selection = Selection.Range(1565, 1590)
  41. get_component('JEditTextArea').setSelection(selection)
  42. select_menu('Edit>>Copy')
  43. clipObj = ClipboardAccess()
  44. s = clipObj.get()
  45. assert s.startswith('Basic features of the GUI'), 'Copy failure'
  46. selection = Selection.Range(1583, 1590)
  47. get_component('JEditTextArea').setSelection(selection)
  48. clipObj = ClipboardAccess()
  49. s = clipObj.setText('jEdit')
  50. select_menu('Edit>>Paste')
  51. selection = Selection.Range(1565, 1590)
  52. get_component('JEditTextArea').setSelection(selection)
  53. s = get_component('JEditTextArea').getSelectedText()
  54. assert s.startswith('Basic features of jEdit'), 'Paste failure'
  55. close()