clipboard.py 949 B

123456789101112131415161718192021222324252627282930
  1. #!/usr/bin/env python
  2. # License: GPLv3 Copyright: 2022, Kovid Goyal <kovid at kovidgoyal.net>
  3. from kitty.clipboard import WriteRequest
  4. from . import BaseTest
  5. class TestClipboard(BaseTest):
  6. def test_clipboard_write_request(self):
  7. wr = WriteRequest(max_size=64)
  8. wr.add_base64_data('bGlnaHQgd29yaw')
  9. self.ae(bytes(wr.current_leftover_bytes), b'aw')
  10. wr.flush_base64_data()
  11. self.ae(wr.data_for(), b'light work')
  12. wr = WriteRequest(max_size=64)
  13. wr.add_base64_data('bGlnaHQgd29yaw==')
  14. self.ae(wr.data_for(), b'light work')
  15. wr = WriteRequest(max_size=64)
  16. wr.add_base64_data('bGlnaHQgd29')
  17. for x in b'y', b'a', b'y', b'4', b'=':
  18. wr.add_base64_data(x)
  19. self.ae(wr.data_for(), b'light work.')
  20. wr = WriteRequest(max_size=64)
  21. for x in 'bGlnaHQgd29y':
  22. wr.add_base64_data(x)
  23. self.ae(wr.data_for(), b'light wor')